Title: [103221] trunk/Source/WebCore
Revision
103221
Author
[email protected]
Date
2011-12-18 23:15:58 -0800 (Sun, 18 Dec 2011)

Log Message

REGRESSION(r101445): [JSC] Generated code for custom getters and setters
with the [Supplemental] IDL is wrong
https://bugs.webkit.org/show_bug.cgi?id=74837

Reviewed by Darin Adler.

In bug 73162, we implemented the [Supplemental] IDL, but the generated code
for custom getters and setters was wrong in JSC. This patch fixes CodeGeneratorJS.pm
so that the result of WebCore/bindings/scripts/test/TestInterface.idl becomes as follows:

Wrong:
    JSValue jsTestInterfaceStr3(ExecState* exec, JSValue slotBase, const Identifier&)
    {
        JSTestInterface* castedThis = static_cast<JSTestInterface*>(asObject(slotBase));
        return JSTestSupplemental::str3(castedThis, exec);
    }

Correct:
    JSValue jsTestInterfaceStr3(ExecState* exec, JSValue slotBase, const Identifier&)
    {
        JSTestInterface* castedThis = static_cast<JSTestInterface*>(asObject(slotBase));
        TestInterface* imp = static_cast<TestInterface*>(castedThis->impl());
        return castedThis->str3(imp, exec);
    }

Tests: bindings/scripts/test/JS/TestInterface.idl

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateHeader):
(GenerateImplementation):
* bindings/scripts/test/JS/JSTestInterface.cpp: Updated run-bindings-tests result.
(WebCore::jsTestInterfaceStr3):
(WebCore::setJSTestInterfaceStr3):
* bindings/scripts/test/JS/JSTestInterface.h: Ditto.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (103220 => 103221)


--- trunk/Source/WebCore/ChangeLog	2011-12-19 06:59:54 UTC (rev 103220)
+++ trunk/Source/WebCore/ChangeLog	2011-12-19 07:15:58 UTC (rev 103221)
@@ -1,3 +1,40 @@
+2011-12-18  Kentaro Hara  <[email protected]>
+
+        REGRESSION(r101445): [JSC] Generated code for custom getters and setters
+        with the [Supplemental] IDL is wrong
+        https://bugs.webkit.org/show_bug.cgi?id=74837
+
+        Reviewed by Darin Adler.
+
+        In bug 73162, we implemented the [Supplemental] IDL, but the generated code
+        for custom getters and setters was wrong in JSC. This patch fixes CodeGeneratorJS.pm
+        so that the result of WebCore/bindings/scripts/test/TestInterface.idl becomes as follows:
+
+        Wrong:
+            JSValue jsTestInterfaceStr3(ExecState* exec, JSValue slotBase, const Identifier&)
+            {
+                JSTestInterface* castedThis = static_cast<JSTestInterface*>(asObject(slotBase));
+                return JSTestSupplemental::str3(castedThis, exec);
+            }
+
+        Correct:
+            JSValue jsTestInterfaceStr3(ExecState* exec, JSValue slotBase, const Identifier&)
+            {
+                JSTestInterface* castedThis = static_cast<JSTestInterface*>(asObject(slotBase));
+                TestInterface* imp = static_cast<TestInterface*>(castedThis->impl());
+                return castedThis->str3(imp, exec);
+            }
+
+        Tests: bindings/scripts/test/JS/TestInterface.idl
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateHeader):
+        (GenerateImplementation):
+        * bindings/scripts/test/JS/JSTestInterface.cpp: Updated run-bindings-tests result.
+        (WebCore::jsTestInterfaceStr3):
+        (WebCore::setJSTestInterfaceStr3):
+        * bindings/scripts/test/JS/JSTestInterface.h: Ditto.
+
 2011-12-18  Adam Barth  <[email protected]>
 
         Fix typo in comment.

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (103220 => 103221)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2011-12-19 06:59:54 UTC (rev 103220)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2011-12-19 07:15:58 UTC (rev 103221)
@@ -875,8 +875,8 @@
         foreach (@{$dataNode->attributes}) {
             my $attribute = $_;
             $numCustomAttributes++ if $attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCCustom"};
-            $numCustomAttributes++ if ($attribute->signature->extendedAttributes->{"CustomGetter"} || $attribute->signature->extendedAttributes->{"JSCCustomGetter"}) && !$attribute->signature->extendedAttributes->{"ImplementedBy"};
-            $numCustomAttributes++ if ($attribute->signature->extendedAttributes->{"CustomSetter"} || $attribute->signature->extendedAttributes->{"JSCCustomSetter"}) && !$attribute->signature->extendedAttributes->{"ImplementedBy"};
+            $numCustomAttributes++ if ($attribute->signature->extendedAttributes->{"CustomGetter"} || $attribute->signature->extendedAttributes->{"JSCCustomGetter"});
+            $numCustomAttributes++ if ($attribute->signature->extendedAttributes->{"CustomSetter"} || $attribute->signature->extendedAttributes->{"JSCCustomSetter"});
             if ($attribute->signature->extendedAttributes->{"CachedAttribute"}) {
                 push(@headerContent, "    JSC::WriteBarrier<JSC::Unknown> m_" . $attribute->signature->name . ";\n");
                 $numCachedAttributes++;
@@ -900,11 +900,20 @@
                 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"}) && !$attribute->signature->extendedAttributes->{"ImplementedBy"}) {
-                push(@headerContent, "    JSC::JSValue " . $codeGenerator->WK_lcfirst($attribute->signature->name) . "(JSC::ExecState*) const;\n");
-            } elsif (($attribute->signature->extendedAttributes->{"CustomSetter"} || $attribute->signature->extendedAttributes->{"JSCCustomSetter"}) && !$attribute->signature->extendedAttributes->{"ImplementedBy"}) {
+            } elsif (($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/) {
-                    push(@headerContent, "    void set" . $codeGenerator->WK_ucfirst($attribute->signature->name) . "(JSC::ExecState*, JSC::JSValue);\n");
+                    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");
+                    }
                 }
             }
         }
@@ -1716,9 +1725,8 @@
 
                 if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCCustom"} || $attribute->signature->extendedAttributes->{"CustomGetter"} || $attribute->signature->extendedAttributes->{"JSCCustomGetter"}) {
                     if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) {
-                        my $implementedBy = $attribute->signature->extendedAttributes->{"ImplementedBy"};
-                        $implIncludes{"JS${implementedBy}.h"} = 1;
-                        push(@implContent, "    return JS${implementedBy}::$implGetterFunctionName(castedThis, exec);\n");
+                        push(@implContent, "    ${interfaceName}* imp = static_cast<${interfaceName}*>(castedThis->impl());\n");
+                        push(@implContent, "    return castedThis->$implGetterFunctionName(imp, exec);\n");
                     } else {
                         push(@implContent, "    return castedThis->$implGetterFunctionName(exec);\n");
                     }
@@ -1905,9 +1913,9 @@
 
                         if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCCustom"} || $attribute->signature->extendedAttributes->{"CustomSetter"} || $attribute->signature->extendedAttributes->{"JSCCustomSetter"}) {
                             if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) {
-                                my $implementedBy = $attribute->signature->extendedAttributes->{"ImplementedBy"};
-                                $implIncludes{"JS${implementedBy}.h"} = 1;
-                                push(@implContent, "    JS${implementedBy}::set$implSetterFunctionName(static_cast<$className*>(thisObject), exec, value);\n");
+                                push(@implContent, "    ${className}* castedThis = static_cast<${className}*>(thisObject);\n");
+                                push(@implContent, "    ${interfaceName}* imp = static_cast<${interfaceName}*>(castedThis->impl());\n");
+                                push(@implContent, "    castedThis->set$implSetterFunctionName(imp, exec, value);\n");
                             } else {
                                 push(@implContent, "    static_cast<$className*>(thisObject)->set$implSetterFunctionName(exec, value);\n");
                             }

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


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp	2011-12-19 06:59:54 UTC (rev 103220)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp	2011-12-19 07:15:58 UTC (rev 103221)
@@ -26,7 +26,6 @@
 
 #include "ExceptionCode.h"
 #include "JSDOMBinding.h"
-#include "JSTestSupplemental.h"
 #include "TestInterface.h"
 #include "TestSupplemental.h"
 #include <runtime/Error.h>
@@ -201,7 +200,8 @@
 JSValue jsTestInterfaceStr3(ExecState* exec, JSValue slotBase, const Identifier&)
 {
     JSTestInterface* castedThis = static_cast<JSTestInterface*>(asObject(slotBase));
-    return JSTestSupplemental::str3(castedThis, exec);
+    TestInterface* imp = static_cast<TestInterface*>(castedThis->impl());
+    return castedThis->str3(imp, exec);
 }
 
 #endif
@@ -232,7 +232,9 @@
 #if ENABLE(Condition11) || ENABLE(Condition12)
 void setJSTestInterfaceStr3(ExecState* exec, JSObject* thisObject, JSValue value)
 {
-    JSTestSupplemental::setStr3(static_cast<JSTestInterface*>(thisObject), exec, value);
+    JSTestInterface* castedThis = static_cast<JSTestInterface*>(thisObject);
+    TestInterface* imp = static_cast<TestInterface*>(castedThis->impl());
+    castedThis->setStr3(imp, exec, value);
 }
 
 #endif

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


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.h	2011-12-19 06:59:54 UTC (rev 103220)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.h	2011-12-19 07:15:58 UTC (rev 103221)
@@ -53,6 +53,9 @@
     }
 
     static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*);
+
+    // Custom attributes
+    JSC::JSValue str3(TestInterface*, JSC::ExecState*) const;
     TestInterface* impl() const { return m_impl; }
     void releaseImpl() { m_impl->deref(); m_impl = 0; }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to