It is too verbose to create a BREW instance. For example, to create a IFileMgr instance, it takes three lines: IFileMgr* fileMgr; IShell* shell = reinterpret_cast<AEEApplet*>(GETAPPINSTANCE())->m_pIShell; ISHELL_CreateInstance(shell, AEECLSID_FILEMGR, reinterpret_cast<void**>(&fileMgr)); This pattern is repeated all over the code, so we need a shortcut here. Add a template function to create a BREW instance in one line. IFileMgr* fileMgr = createInstanceBrew<IFileMgr>(AEECLSID_FILEMGR); This can be nicely combined with OwnPtrBrew. OwnPtrBrew<IFileMgr> fileMgr(createInstanceBrew<IFileMgr>(AEECLSID_FILEMGR));
Created attachment 48333 [details] Patch ShellUtilBrew.h is currently under wtf/brew, but I am not sure if this is the right place to put platform-specific utility functions.
(In reply to comment #1) > ShellUtilBrew.h is currently under wtf/brew, but I am not sure if this is the > right place to put platform-specific utility functions. It’s the right directory for low-level functions of this type. But “utility” is not a word we ever use, and we certainly frown on “Util” in a file name.
Created attachment 48338 [details] Patch Remove Util from the filename and prefix the function with shell createInstanceBrew -> shellCreateInstanceBrew
Should this return a PassOwnPtrBrew?
(In reply to comment #4) > Should this return a PassOwnPtrBrew? These is no PassOwnPtrBrew class. I just wanted to simplify the creation of a BREW instance. As OwnPtrBrew takes a raw pointer in the constructor, we can use an idiom like the following: OwnPtrBrew<IFileMgr> fileMgr(createInstanceBrew<IFileMgr>(AEECLSID_FILEMGR)); Do you suggest that this should return a PassOwnPtrBrew?
> Do you suggest that this should return a PassOwnPtrBrew? In general, createMumble methods return a PassFooBar object to ensure we don't leak the allocated memory.
Comment on attachment 48338 [details] Patch Why would this be part of WTF? This seems like port-specific goop. We don't need to have PassOwnPtrBrew to approve this, but eventually it would be nice to have such a class to make leaking memory returned from this function impossible.
Created attachment 50169 [details] Patch Make the function return PassOwnPtr. This prevents memory leaking.
Comment on attachment 50169 [details] Patch LGTM.
Comment on attachment 50169 [details] Patch Clearing flags on attachment: 50169 Committed r56031: <http://trac.webkit.org/changeset/56031>
All reviewed patches have been landed. Closing bug.