Bug 127170

Summary: [GTK] Add GUniquePtr
Product: WebKit Reporter: Carlos Garcia Campos <cgarcia>
Component: Web Template FrameworkAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: andersca, benjamin, cmarcelo, commit-queue, gns, pnormand, zan
Priority: P2 Keywords: Gtk
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Updated patch
none
Updated patch
none
Updated patch
none
Even simpler patch using template alias
none
Updated patch gns: review+

Description Carlos Garcia Campos 2014-01-17 03:59:04 PST
The idea is to replace GOwnPtr with a new simpler class derived the std:unique_ptr. Not everything can be replaced, though, because GOwnPtr::outPtr() doesn't seem to be possible to implement with unique_ptr.
Comment 1 Carlos Garcia Campos 2014-01-17 04:07:07 PST
Created attachment 221454 [details]
Patch

This is a first patch adding support for glib types already supported by GOwnPtr, except GError that is usually used with GOwnPtr::outPtr(). Then, adding support for Soup and GTK/GDK types would be a matter of defining a macro  FOR_EACH_SOUP_DELETER, FOR_EACH_GDK_DELETER, etc and call it with DEFINE_DELETER. I'll also start porting existing code to GUniquePtr once/if this patch lands.
Comment 2 Carlos Garcia Campos 2014-01-17 04:55:50 PST
Created attachment 221457 [details]
Updated patch

Undef the FOR_EACH_GLIB_DELETER after using it.
Comment 3 Carlos Garcia Campos 2014-01-17 04:59:13 PST
Created attachment 221458 [details]
Updated patch

Forgot to git add the tests makefile changes.
Comment 4 Carlos Garcia Campos 2014-01-17 06:06:04 PST
Created attachment 221461 [details]
Updated patch

Simply made the operator() of the deleters const.
Comment 5 Carlos Garcia Campos 2014-01-17 08:53:39 PST
Created attachment 221470 [details]
Even simpler patch using template alias

This is even simpler now using a template alias as suggested in bug #126255
Comment 6 Carlos Garcia Campos 2014-01-21 09:26:00 PST
Created attachment 221754 [details]
Updated patch

Added deleter for GError and prefixed the DEFINE_DELETER macro with WTF since it's public macro to be used by others.
Comment 7 Gustavo Noronha (kov) 2014-01-21 09:58:57 PST
Comment on attachment 221754 [details]
Updated patch

LGTM, pitty we can't extend std::unique_ptr, but then again, not sure how sane that would be.
Comment 8 Carlos Garcia Campos 2014-01-22 05:59:06 PST
Committed r162516: <http://trac.webkit.org/changeset/162516>
Comment 9 Zan Dobersek 2014-01-24 02:33:17 PST
*** Bug 126255 has been marked as a duplicate of this bug. ***