Title: [104778] trunk/Source/WebCore
Revision
104778
Author
[email protected]
Date
2012-01-11 17:57:45 -0800 (Wed, 11 Jan 2012)

Log 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.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (104777 => 104778)


--- trunk/Source/WebCore/ChangeLog	2012-01-12 01:30:19 UTC (rev 104777)
+++ trunk/Source/WebCore/ChangeLog	2012-01-12 01:57:45 UTC (rev 104778)
@@ -1,3 +1,47 @@
+2012-01-11  Kentaro Hara  <[email protected]>
+
+        [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.
+
 2012-01-11  Adam Barth  <[email protected]>
 
         iframe sandbox doesn't block autofocus (IETC automatic-feature-block-autofocus-form-control)

Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowWebAudioCustom.cpp (104777 => 104778)


--- trunk/Source/WebCore/bindings/js/JSDOMWindowWebAudioCustom.cpp	2012-01-12 01:30:19 UTC (rev 104777)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowWebAudioCustom.cpp	2012-01-12 01:57:45 UTC (rev 104778)
@@ -37,7 +37,7 @@
     return 0;
 }
 
-JSValue JSDOMWindow::webkitAudioContext(DOMWindow*, ExecState* exec) const
+JSValue JSDOMWindow::webkitAudioContext(ExecState* exec) const
 {
     Settings* settings = settingsForWindowWebAudio(this);
     if (settings && settings->webAudioEnabled())

Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowWebSocketCustom.cpp (104777 => 104778)


--- trunk/Source/WebCore/bindings/js/JSDOMWindowWebSocketCustom.cpp	2012-01-12 01:30:19 UTC (rev 104777)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowWebSocketCustom.cpp	2012-01-12 01:57:45 UTC (rev 104778)
@@ -37,7 +37,7 @@
     return 0;
 }
 
-JSValue JSDOMWindow::webSocket(DOMWindow*, ExecState* exec) const
+JSValue JSDOMWindow::webSocket(ExecState* exec) const
 {
     if (!settingsForWindowWebSocket(this))
         return jsUndefined();

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (104777 => 104778)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2012-01-12 01:30:19 UTC (rev 104777)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2012-01-12 01:57:45 UTC (rev 104778)
@@ -902,27 +902,13 @@
         push(@headerContent, "\n    // Custom attributes\n");
 
         foreach my $attribute (@{$dataNode->attributes}) {
-            if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCCustom"}) {
-                push(@headerContent, "    JSC::JSValue " . $codeGenerator->WK_lcfirst($attribute->signature->name) . "(JSC::ExecState*) const;\n");
-                if ($attribute->type !~ /^readonly/) {
-                    push(@headerContent, "    void set" . $codeGenerator->WK_ucfirst($attribute->signature->name) . "(JSC::ExecState*, JSC::JSValue);\n");
-                }
-            } elsif (($attribute->signature->extendedAttributes->{"CustomGetter"} || $attribute->signature->extendedAttributes->{"JSCCustomGetter"})) {
+            if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCCustom"} || $attribute->signature->extendedAttributes->{"CustomGetter"} || $attribute->signature->extendedAttributes->{"JSCCustomGetter"}) {
                 my $methodName = $codeGenerator->WK_lcfirst($attribute->signature->name);
-                if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) {
-                    push(@headerContent, "    JSC::JSValue " . $methodName . "(" . $interfaceName . "*, JSC::ExecState*) const;\n");
-                } else {
-                    push(@headerContent, "    JSC::JSValue " . $methodName . "(JSC::ExecState*) const;\n");
-                }
-            } elsif (($attribute->signature->extendedAttributes->{"CustomSetter"} || $attribute->signature->extendedAttributes->{"JSCCustomSetter"})) {
-                if ($attribute->type !~ /^readonly/) {
-                    if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) {
-                        push(@headerContent, "    void set" . $codeGenerator->WK_ucfirst($attribute->signature->name) . "(" . $interfaceName . "*, JSC::ExecState*, JSC::JSValue);\n");
-                    } else {
-                        push(@headerContent, "    void set" . $codeGenerator->WK_ucfirst($attribute->signature->name) . "(JSC::ExecState*, JSC::JSValue);\n");
-                    }
-                }
+                push(@headerContent, "    JSC::JSValue " . $methodName . "(JSC::ExecState*) const;\n");
             }
+            if (($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCCustom"} || $attribute->signature->extendedAttributes->{"CustomSetter"} || $attribute->signature->extendedAttributes->{"JSCCustomSetter"}) && $attribute->type !~ /^readonly/) {
+                push(@headerContent, "    void set" . $codeGenerator->WK_ucfirst($attribute->signature->name) . "(JSC::ExecState*, JSC::JSValue);\n");
+            }
         }
     }
 
@@ -1746,12 +1732,7 @@
                 }
 
                 if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCCustom"} || $attribute->signature->extendedAttributes->{"CustomGetter"} || $attribute->signature->extendedAttributes->{"JSCCustomGetter"}) {
-                    if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) {
-                        push(@implContent, "    ${interfaceName}* impl = static_cast<${interfaceName}*>(castedThis->impl());\n");
-                        push(@implContent, "    return castedThis->$implGetterFunctionName(impl, exec);\n");
-                    } else {
-                        push(@implContent, "    return castedThis->$implGetterFunctionName(exec);\n");
-                    }
+                    push(@implContent, "    return castedThis->$implGetterFunctionName(exec);\n");
                 } elsif ($attribute->signature->extendedAttributes->{"allowAccessToNode"}) {
                     $implIncludes{"JSDOMBinding.h"} = 1;
                     push(@implContent, "    $implClassName* impl = static_cast<$implClassName*>(castedThis->impl());\n");
@@ -1934,13 +1915,7 @@
                         }
 
                         if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCCustom"} || $attribute->signature->extendedAttributes->{"CustomSetter"} || $attribute->signature->extendedAttributes->{"JSCCustomSetter"}) {
-                            if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) {
-                                push(@implContent, "    ${className}* castedThis = static_cast<${className}*>(thisObject);\n");
-                                push(@implContent, "    ${interfaceName}* impl = static_cast<${interfaceName}*>(castedThis->impl());\n");
-                                push(@implContent, "    castedThis->set$implSetterFunctionName(impl, exec, value);\n");
-                            } else {
-                                push(@implContent, "    static_cast<$className*>(thisObject)->set$implSetterFunctionName(exec, value);\n");
-                            }
+                            push(@implContent, "    static_cast<$className*>(thisObject)->set$implSetterFunctionName(exec, value);\n");
                         } elsif ($type eq "EventListener") {
                             $implIncludes{"JSEventListener.h"} = 1;
                             push(@implContent, "    UNUSED_PARAM(exec);\n");

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp (104777 => 104778)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp	2012-01-12 01:30:19 UTC (rev 104777)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp	2012-01-12 01:57:45 UTC (rev 104778)
@@ -230,8 +230,7 @@
 JSValue jsTestInterfaceSupplementalStr3(ExecState* exec, JSValue slotBase, const Identifier&)
 {
     JSTestInterface* castedThis = static_cast<JSTestInterface*>(asObject(slotBase));
-    TestInterface* impl = static_cast<TestInterface*>(castedThis->impl());
-    return castedThis->supplementalStr3(impl, exec);
+    return castedThis->supplementalStr3(exec);
 }
 
 #endif
@@ -264,9 +263,7 @@
 #if ENABLE(Condition11) || ENABLE(Condition12)
 void setJSTestInterfaceSupplementalStr3(ExecState* exec, JSObject* thisObject, JSValue value)
 {
-    JSTestInterface* castedThis = static_cast<JSTestInterface*>(thisObject);
-    TestInterface* impl = static_cast<TestInterface*>(castedThis->impl());
-    castedThis->setSupplementalStr3(impl, exec, value);
+    static_cast<JSTestInterface*>(thisObject)->setSupplementalStr3(exec, value);
 }
 
 #endif

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.h (104777 => 104778)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.h	2012-01-12 01:30:19 UTC (rev 104777)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.h	2012-01-12 01:57:45 UTC (rev 104778)
@@ -57,7 +57,8 @@
     static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*);
 
     // Custom attributes
-    JSC::JSValue supplementalStr3(TestInterface*, JSC::ExecState*) const;
+    JSC::JSValue supplementalStr3(JSC::ExecState*) const;
+    void setSupplementalStr3(JSC::ExecState*, JSC::JSValue);
 
     // Custom functions
     JSC::JSValue supplementalMethod3(JSC::ExecState*);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to