⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 181644 in webkit


Ignore:
Timestamp:
Mar 17, 2015, 5:23:57 AM (11 years ago)
Author:
Carlos Garcia Campos
Message:

Merge r181643 - [GTK] Wrong transfer annotations used in GObject DOM bindings
https://bugs.webkit.org/show_bug.cgi?id=142780

Reviewed by Gustavo Noronha Silva.

We are using transfer none for all methods returning a GObject DOM
Object. That's not true. Only objects derived from Node are
automatically released by the DOM object cache and can be transfer
none. All other objects are added to the cache only to avoid
creating the same wrapper twice for the same core object, but
caller should release the returned reference.

  • bindings/gobject/WebKitDOMCustomUnstable.h:
  • bindings/scripts/CodeGeneratorGObject.pm:

(GetTransferTypeForReturnType):
(GenerateFunction):

Location:
releases/WebKitGTK/webkit-2.8/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • releases/WebKitGTK/webkit-2.8/Source/WebCore/ChangeLog

    r181641 r181644  
     12015-03-17  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Wrong transfer annotations used in GObject DOM bindings
     4        https://bugs.webkit.org/show_bug.cgi?id=142780
     5
     6        Reviewed by Gustavo Noronha Silva.
     7
     8        We are using transfer none for all methods returning a GObject DOM
     9        Object. That's not true. Only objects derived from Node are
     10        automatically released by the DOM object cache and can be transfer
     11        none. All other objects are added to the cache only to avoid
     12        creating the same wrapper twice for the same core object, but
     13        caller should release the returned reference.
     14
     15        * bindings/gobject/WebKitDOMCustomUnstable.h:
     16        * bindings/scripts/CodeGeneratorGObject.pm:
     17        (GetTransferTypeForReturnType):
     18        (GenerateFunction):
     19
    1202015-03-17  Carlos Garcia Campos  <cgarcia@igalia.com>
    221
  • releases/WebKitGTK/webkit-2.8/Source/WebCore/bindings/gobject/WebKitDOMCustomUnstable.h

    r177143 r181644  
    3030 * @self: A #WebKitDOMDOMWindow
    3131 *
    32  * Returns: (transfer none): A #WebKitDOMWebKitNamespace
     32 * Returns: (transfer full): A #WebKitDOMWebKitNamespace
    3333 *
    3434 * Stability: Unstable
     
    4343 * @name: a #gchar
    4444 *
    45  * Returns: (transfer none): A #WebKitDOMUserMessageHandler
     45 * Returns: (transfer full): A #WebKitDOMUserMessageHandler
    4646 *
    4747 * Stability: Unstable
  • releases/WebKitGTK/webkit-2.8/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm

    r177143 r181644  
    4949                    "NodeIterator" => 1, "TreeWalker" => 1, "AbstractView" => 1, "Blob" => 1, "DOMTokenList" => 1,
    5050                    "HTMLCollection" => 1, "TextTrackCue" => 1);
     51
     52# Only objects derived from Node are released by the DOM object cache and can be
     53# transfer none. Ideally we could use GetBaseClass with the parent type to check
     54# whether it's Node, but unfortunately we only have the name of the return type,
     55# and we can't know its parent base class. Since there are fewer classes in the
     56# API that are not derived from Node, we will list them here to decide the
     57# transfer type.
     58my %transferFullTypeHash = ("AudioTrack" => 1, "AudioTrackList" => 1, "BarProp" => 1, "BatteryManager" => 1,
     59    "CSSRuleList" => 1, "CSSStyleDeclaration" => 1, "CSSStyleSheet" => 1,
     60    "DOMApplicationCache" => 1, "DOMMimeType" => 1, "DOMMimeTypeArray" => 1, "DOMNamedFlowCollection" => 1,
     61    "DOMPlugin" => 1, "DOMPluginArray" => 1, "DOMSecurityPolicy" => 1,
     62    "DOMSelection" => 1, "DOMSettableTokenList" => 1, "DOMStringList" => 1,
     63    "DOMWindow" => 1, "DOMWindowCSS" => 1, "EventTarget" => 1,
     64    "File" => 1, "FileList" => 1, "Gamepad" => 1, "GamepadList" => 1,
     65    "Geolocation" => 1, "HTMLOptionsCollection" => 1, "History" => 1,
     66    "KeyboardEvent" => 1, "MediaError" => 1, "MediaController" => 1,
     67    "MouseEvent" => 1, "MediaQueryList" => 1, "Navigator" => 1, "NodeFilter" => 1,
     68    "Performance" => 1, "PerformanceEntry" => 1, "PerformanceEntryList" => 1, "PerformanceNavigation" => 1, "PerformanceTiming" => 1,
     69    "Range" => 1, "Screen" => 1, "SpeechSynthesis" => 1, "SpeechSynthesisVoice" => 1,
     70    "Storage" => 1, "StyleMedia" => 1, "TextTrack" => 1, "TextTrackCueList" => 1,
     71    "TimeRanges" => 1, "Touch" => 1, "UIEvent" => 1, "UserMessageHandler" => 1, "UserMessageHandlersNamespace" => 1,
     72    "ValidityState" => 1, "VideoTrack" => 1, "WebKitNamedFlow" => 1,
     73    "WebKitNamespace" => 1, "WebKitPoint" => 1, "WheelEvent" => 1, "XPathNSResolver" => 1);
    5174
    5275# List of function parameters that are allowed to be NULL
     
    948971}
    949972
     973sub GetTransferTypeForReturnType {
     974    my $returnType = shift;
     975
     976    # Node is always transfer none.
     977    return "none" if $returnType eq "Node";
     978
     979    # Any base class but Node is transfer full.
     980    return "full" if IsBaseType($returnType);
     981
     982    # Any other class not derived from Node is transfer full.
     983    return "full" if $transferFullTypeHash{$returnType};
     984    return "none";
     985}
     986
    950987sub GenerateFunction {
    951988    my ($object, $interfaceName, $function, $prefix, $parentNode) = @_;
     
    10451082    $returnTypeName =~ s/\*$//;
    10461083    if ($returnValueIsGDOMType) {
    1047         push(@functionHeader, " * Returns: (transfer none): A #${returnTypeName}");
     1084        my $transferType = GetTransferTypeForReturnType($functionSigType);
     1085        push(@functionHeader, " * Returns: (transfer $transferType): A #${returnTypeName}");
    10481086        $hasReturnTag = 1;
    10491087    } elsif ($returnType ne "void") {
Note: See TracChangeset for help on using the changeset viewer.