Bug 127170 - [GTK] Add GUniquePtr
Summary: [GTK] Add GUniquePtr
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: Gtk
: 126255 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-01-17 03:59 PST by Carlos Garcia Campos
Modified: 2014-01-24 02:33 PST (History)
7 users (show)

See Also:


Attachments
Patch (8.69 KB, patch)
2014-01-17 04:07 PST, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Updated patch (8.72 KB, patch)
2014-01-17 04:55 PST, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Updated patch (9.37 KB, patch)
2014-01-17 04:59 PST, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Updated patch (9.38 KB, patch)
2014-01-17 06:06 PST, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Even simpler patch using template alias (9.19 KB, patch)
2014-01-17 08:53 PST, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Updated patch (9.67 KB, patch)
2014-01-21 09:26 PST, Carlos Garcia Campos
gns: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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. ***