Bug 136613

Summary: Make OSObjectPtr a bit more like RefPtr
Product: WebKit Reporter: Sam Weinig <sam>
Component: New BugsAssignee: Sam Weinig <sam>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, cmarcelo, commit-queue, darin, koivisto, mitz, thorton
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 136636    
Bug Blocks:    
Attachments:
Description Flags
Patch darin: review+

Sam Weinig
Reported 2014-09-07 14:33:24 PDT
Make OSObjectPtr a bit more like RefPtr
Attachments
Patch (2.32 KB, patch)
2014-09-07 14:35 PDT, Sam Weinig
darin: review+
Sam Weinig
Comment 1 2014-09-07 14:35:49 PDT
Sam Weinig
Comment 2 2014-09-07 14:36:56 PDT
This bug is for addressing the feedback in https://bugs.webkit.org/show_bug.cgi?id=136613.
Sam Weinig
Comment 3 2014-09-07 14:39:27 PDT
Two things I didn't do were: - Remove the specialization for nullptr as I don't trust compilers :). - Made it share code with RefPtr, as that would be a much bigger task.
Darin Adler
Comment 4 2014-09-07 18:01:07 PDT
(In reply to comment #3) > - Remove the specialization for nullptr as I don't trust compilers :). But you didn’t add one for RefPtr. You trust compilers only with a class that we use extensively across the entire project, not with a class that’s far less often used?
Darin Adler
Comment 5 2014-09-07 18:03:08 PDT
Comment on attachment 237757 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=237757&action=review > Source/WTF/wtf/OSObjectPtr.h:52 > struct AdoptOSObject { }; Now that this is not part of the public API of OSObjectPtr, could make this struct a private member of the OSObjectPtr class. Would be tidier. > Source/WTF/wtf/OSObjectPtr.h:122 > + OSObjectPtr& operator=(const OSObjectPtr&& other) Unwanted const here prevents the patch from compiling.
Sam Weinig
Comment 6 2014-09-08 10:15:26 PDT
(In reply to comment #4) > (In reply to comment #3) > > - Remove the specialization for nullptr as I don't trust compilers :). > > But you didn’t add one for RefPtr. You trust compilers only with a class that we use extensively across the entire project, not with a class that’s far less often used? I'm writing some test code to figure out if it really is the same. When I finish that experiment, I will either add the code to RefPtr, or remove it from OSObjectPtr.
Sam Weinig
Comment 7 2014-09-08 10:16:09 PDT
(In reply to comment #5) > (From update of attachment 237757 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=237757&action=review > > > Source/WTF/wtf/OSObjectPtr.h:52 > > struct AdoptOSObject { }; > > Now that this is not part of the public API of OSObjectPtr, could make this struct a private member of the OSObjectPtr class. Would be tidier. Will fix. > > > Source/WTF/wtf/OSObjectPtr.h:122 > > + OSObjectPtr& operator=(const OSObjectPtr&& other) > > Unwanted const here prevents the patch from compiling. Do'h.
Sam Weinig
Comment 8 2014-09-08 10:26:44 PDT
Tim Horton
Comment 9 2014-09-08 10:38:20 PDT
WebKit Commit Bot
Comment 10 2014-09-08 11:00:50 PDT
Re-opened since this is blocked by bug 136636
Antti Koivisto
Comment 11 2014-09-26 08:25:13 PDT
How is this better than just having adoptOSObject() function for RetainPtr? That's what I was doing before discovering this and it seemed to work fine.
Sam Weinig
Comment 12 2014-09-26 13:44:36 PDT
(In reply to comment #11) > How is this better than just having adoptOSObject() function for RetainPtr? That's what I was doing before discovering this and it seemed to work fine. It's not. And I will be rolling this out pretty soon.
Antti Koivisto
Comment 13 2014-09-27 00:10:03 PDT
This seemed to work on all platforms: + template<typename T> inline RetainPtr<T> adoptSystem(T ptr) + { +#if OS_OBJECT_USE_OBJC + return adoptNS(ptr); +#else + return adoptCF(ptr); +#endif + } +
Sam Weinig
Comment 14 2014-10-03 17:37:46 PDT
(In reply to comment #13) > This seemed to work on all platforms: > > + template<typename T> inline RetainPtr<T> adoptSystem(T ptr) > + { > +#if OS_OBJECT_USE_OBJC > + return adoptNS(ptr); > +#else > + return adoptCF(ptr); > +#endif > + } > + Actually, I don't believe this actually works. In 32-bit, OS-objects are not objective-c objects, but also not CFObjects, so they can't be CFRetain()/CFReleased(). I think we are going to need to stick with OSObjectPtr for now.
Note You need to log in before you can comment on or make changes to this bug.