Changeset 104778 in webkit


Ignore:
Timestamp:
Jan 11, 2012 5:57:45 PM (12 years ago)
Author:
haraken@chromium.org
Message:

[JSC] Remove redundant arguments from [Supplemental] custom methods
https://bugs.webkit.org/show_bug.cgi?id=76127

Reviewed by Adam Barth.

Since in JSC a callback of custom methods is non-static, we do not need
to pass a pointer of an implementation object.

Before (JSTestInterface.cpp):

JSValue jsTestInterfaceSupplementalStr3(ExecState* exec, JSValue slotBase, ...)
{

JSTestInterface* castedThis = static_cast<JSTestInterface*>(asObject(slotBase));
TestInterface* impl = static_cast<TestInterface*>(castedThis->impl());
return castedThis->supplementalStr3(impl, exec);

}

After (JSTestInterface.cpp):

JSValue jsTestInterfaceSupplementalStr3(ExecState* exec, JSValue slotBase, ...)
{

JSTestInterface* castedThis = static_cast<JSTestInterface*>(asObject(slotBase));

return castedThis->supplementalStr3(exec); JSTestInterface knows 'impl'.

}

Tests: bindings/scripts/test/TestInterface.idl

http/tests/websocket/tests/*
webaudio/*

  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateHeader): Previously when we specify [CustomGetter, CustomSetter], the header for
the custom setter was not generated. This patch fixes the bug.
(GenerateImplementation):

  • bindings/js/JSDOMWindowWebAudioCustom.cpp: Removed redundant DOMWindow* from webkitAudioContext().

(WebCore::JSDOMWindow::webkitAudioContext):

  • bindings/js/JSDOMWindowWebSocketCustom.cpp: Removed redundant DOMWindow* from webSocket().

(WebCore::JSDOMWindow::webSocket):

  • bindings/scripts/test/JS/JSTestInterface.cpp: Updated the test result.

(WebCore::jsTestInterfaceSupplementalStr3):
(WebCore::setJSTestInterfaceSupplementalStr3):

  • bindings/scripts/test/JS/JSTestInterface.h: Ditto.
Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r104775 r104778  
     12012-01-11  Kentaro Hara  <haraken@chromium.org>
     2
     3        [JSC] Remove redundant arguments from [Supplemental] custom methods
     4        https://bugs.webkit.org/show_bug.cgi?id=76127
     5
     6        Reviewed by Adam Barth.
     7
     8        Since in JSC a callback of custom methods is non-static, we do not need
     9        to pass a pointer of an implementation object.
     10
     11        Before (JSTestInterface.cpp):
     12            JSValue jsTestInterfaceSupplementalStr3(ExecState* exec, JSValue slotBase, ...)
     13            {
     14                JSTestInterface* castedThis = static_cast<JSTestInterface*>(asObject(slotBase));
     15                TestInterface* impl = static_cast<TestInterface*>(castedThis->impl());
     16                return castedThis->supplementalStr3(impl, exec);
     17            }
     18
     19        After (JSTestInterface.cpp):
     20            JSValue jsTestInterfaceSupplementalStr3(ExecState* exec, JSValue slotBase, ...)
     21            {
     22                JSTestInterface* castedThis = static_cast<JSTestInterface*>(asObject(slotBase));
     23                 return castedThis->supplementalStr3(exec);  // JSTestInterface knows 'impl'.
     24            }
     25
     26        Tests: bindings/scripts/test/TestInterface.idl
     27               http/tests/websocket/tests/*
     28               webaudio/*
     29
     30        * bindings/scripts/CodeGeneratorJS.pm:
     31        (GenerateHeader): Previously when we specify [CustomGetter, CustomSetter], the header for
     32        the custom setter was not generated. This patch fixes the bug.
     33        (GenerateImplementation):
     34
     35        * bindings/js/JSDOMWindowWebAudioCustom.cpp: Removed redundant DOMWindow* from webkitAudioContext().
     36        (WebCore::JSDOMWindow::webkitAudioContext):
     37        * bindings/js/JSDOMWindowWebSocketCustom.cpp: Removed redundant DOMWindow* from webSocket().
     38        (WebCore::JSDOMWindow::webSocket):
     39
     40        * bindings/scripts/test/JS/JSTestInterface.cpp: Updated the test result.
     41        (WebCore::jsTestInterfaceSupplementalStr3):
     42        (WebCore::setJSTestInterfaceSupplementalStr3):
     43        * bindings/scripts/test/JS/JSTestInterface.h: Ditto.
     44
    1452012-01-11  Adam Barth  <abarth@webkit.org>
    246
  • trunk/Source/WebCore/bindings/js/JSDOMWindowWebAudioCustom.cpp

    r103274 r104778  
    3838}
    3939
    40 JSValue JSDOMWindow::webkitAudioContext(DOMWindow*, ExecState* exec) const
     40JSValue JSDOMWindow::webkitAudioContext(ExecState* exec) const
    4141{
    4242    Settings* settings = settingsForWindowWebAudio(this);
  • trunk/Source/WebCore/bindings/js/JSDOMWindowWebSocketCustom.cpp

    r103274 r104778  
    3838}
    3939
    40 JSValue JSDOMWindow::webSocket(DOMWindow*, ExecState* exec) const
     40JSValue JSDOMWindow::webSocket(ExecState* exec) const
    4141{
    4242    if (!settingsForWindowWebSocket(this))
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r104643 r104778  
    903903
    904904        foreach my $attribute (@{$dataNode->attributes}) {
    905             if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCCustom"}) {
    906                 push(@headerContent, "    JSC::JSValue " . $codeGenerator->WK_lcfirst($attribute->signature->name) . "(JSC::ExecState*) const;\n");
    907                 if ($attribute->type !~ /^readonly/) {
    908                     push(@headerContent, "    void set" . $codeGenerator->WK_ucfirst($attribute->signature->name) . "(JSC::ExecState*, JSC::JSValue);\n");
    909                 }
    910             } elsif (($attribute->signature->extendedAttributes->{"CustomGetter"} || $attribute->signature->extendedAttributes->{"JSCCustomGetter"})) {
     905            if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCCustom"} || $attribute->signature->extendedAttributes->{"CustomGetter"} || $attribute->signature->extendedAttributes->{"JSCCustomGetter"}) {
    911906                my $methodName = $codeGenerator->WK_lcfirst($attribute->signature->name);
    912                 if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) {
    913                     push(@headerContent, "    JSC::JSValue " . $methodName . "(" . $interfaceName . "*, JSC::ExecState*) const;\n");
    914                 } else {
    915                     push(@headerContent, "    JSC::JSValue " . $methodName . "(JSC::ExecState*) const;\n");
    916                 }
    917             } elsif (($attribute->signature->extendedAttributes->{"CustomSetter"} || $attribute->signature->extendedAttributes->{"JSCCustomSetter"})) {
    918                 if ($attribute->type !~ /^readonly/) {
    919                     if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) {
    920                         push(@headerContent, "    void set" . $codeGenerator->WK_ucfirst($attribute->signature->name) . "(" . $interfaceName . "*, JSC::ExecState*, JSC::JSValue);\n");
    921                     } else {
    922                         push(@headerContent, "    void set" . $codeGenerator->WK_ucfirst($attribute->signature->name) . "(JSC::ExecState*, JSC::JSValue);\n");
    923                     }
    924                 }
     907                push(@headerContent, "    JSC::JSValue " . $methodName . "(JSC::ExecState*) const;\n");
     908            }
     909            if (($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCCustom"} || $attribute->signature->extendedAttributes->{"CustomSetter"} || $attribute->signature->extendedAttributes->{"JSCCustomSetter"}) && $attribute->type !~ /^readonly/) {
     910                push(@headerContent, "    void set" . $codeGenerator->WK_ucfirst($attribute->signature->name) . "(JSC::ExecState*, JSC::JSValue);\n");
    925911            }
    926912        }
     
    17471733
    17481734                if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCCustom"} || $attribute->signature->extendedAttributes->{"CustomGetter"} || $attribute->signature->extendedAttributes->{"JSCCustomGetter"}) {
    1749                     if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) {
    1750                         push(@implContent, "    ${interfaceName}* impl = static_cast<${interfaceName}*>(castedThis->impl());\n");
    1751                         push(@implContent, "    return castedThis->$implGetterFunctionName(impl, exec);\n");
    1752                     } else {
    1753                         push(@implContent, "    return castedThis->$implGetterFunctionName(exec);\n");
    1754                     }
     1735                    push(@implContent, "    return castedThis->$implGetterFunctionName(exec);\n");
    17551736                } elsif ($attribute->signature->extendedAttributes->{"allowAccessToNode"}) {
    17561737                    $implIncludes{"JSDOMBinding.h"} = 1;
     
    19351916
    19361917                        if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCCustom"} || $attribute->signature->extendedAttributes->{"CustomSetter"} || $attribute->signature->extendedAttributes->{"JSCCustomSetter"}) {
    1937                             if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) {
    1938                                 push(@implContent, "    ${className}* castedThis = static_cast<${className}*>(thisObject);\n");
    1939                                 push(@implContent, "    ${interfaceName}* impl = static_cast<${interfaceName}*>(castedThis->impl());\n");
    1940                                 push(@implContent, "    castedThis->set$implSetterFunctionName(impl, exec, value);\n");
    1941                             } else {
    1942                                 push(@implContent, "    static_cast<$className*>(thisObject)->set$implSetterFunctionName(exec, value);\n");
    1943                             }
     1918                            push(@implContent, "    static_cast<$className*>(thisObject)->set$implSetterFunctionName(exec, value);\n");
    19441919                        } elsif ($type eq "EventListener") {
    19451920                            $implIncludes{"JSEventListener.h"} = 1;
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp

    r104767 r104778  
    231231{
    232232    JSTestInterface* castedThis = static_cast<JSTestInterface*>(asObject(slotBase));
    233     TestInterface* impl = static_cast<TestInterface*>(castedThis->impl());
    234     return castedThis->supplementalStr3(impl, exec);
     233    return castedThis->supplementalStr3(exec);
    235234}
    236235
     
    265264void setJSTestInterfaceSupplementalStr3(ExecState* exec, JSObject* thisObject, JSValue value)
    266265{
    267     JSTestInterface* castedThis = static_cast<JSTestInterface*>(thisObject);
    268     TestInterface* impl = static_cast<TestInterface*>(castedThis->impl());
    269     castedThis->setSupplementalStr3(impl, exec, value);
     266    static_cast<JSTestInterface*>(thisObject)->setSupplementalStr3(exec, value);
    270267}
    271268
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.h

    r104767 r104778  
    5858
    5959    // Custom attributes
    60     JSC::JSValue supplementalStr3(TestInterface*, JSC::ExecState*) const;
     60    JSC::JSValue supplementalStr3(JSC::ExecState*) const;
     61    void setSupplementalStr3(JSC::ExecState*, JSC::JSValue);
    6162
    6263    // Custom functions
Note: See TracChangeset for help on using the changeset viewer.