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

Changeset 181643 in webkit


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

[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:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r181631 r181643  
     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
  • trunk/Source/WebCore/bindings/gobject/WebKitDOMCustomUnstable.h

    r177143 r181643  
    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
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm

    r181507 r181643  
    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
     
    946969}
    947970
     971sub GetTransferTypeForReturnType {
     972    my $returnType = shift;
     973
     974    # Node is always transfer none.
     975    return "none" if $returnType eq "Node";
     976
     977    # Any base class but Node is transfer full.
     978    return "full" if IsBaseType($returnType);
     979
     980    # Any other class not derived from Node is transfer full.
     981    return "full" if $transferFullTypeHash{$returnType};
     982    return "none";
     983}
     984
    948985sub GenerateFunction {
    949986    my ($object, $interfaceName, $function, $prefix, $parentNode) = @_;
     
    10431080    $returnTypeName =~ s/\*$//;
    10441081    if ($returnValueIsGDOMType) {
    1045         push(@functionHeader, " * Returns: (transfer none): A #${returnTypeName}");
     1082        my $transferType = GetTransferTypeForReturnType($functionSigType);
     1083        push(@functionHeader, " * Returns: (transfer $transferType): A #${returnTypeName}");
    10461084        $hasReturnTag = 1;
    10471085    } elsif ($returnType ne "void") {
Note: See TracChangeset for help on using the changeset viewer.