Support [Supplemental] on static methods
authorharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Feb 2012 09:56:02 +0000 (09:56 +0000)
committerharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Feb 2012 09:56:02 +0000 (09:56 +0000)
https://bugs.webkit.org/show_bug.cgi?id=79357

Reviewed by Adam Barth.

[Supplemental] on static methods does not work in CodeGeneratorJS.pm
and CodeGeneratorV8.pm due to mis-ordered if-elsif statements.
This patch fixes it and supports [Supplemental] on static methods.

Test: bindings/scripts/test/TestSupplemental.idl

* bindings/scripts/CodeGeneratorJS.pm: Modified as described above.
(GenerateParametersCheck):
* bindings/scripts/CodeGeneratorV8.pm: Ditto.
(GenerateFunctionCallString):

* bindings/scripts/test/TestSupplemental.idl: Added a test case.

* bindings/scripts/test/CPP/WebDOMTestInterface.cpp: Updated run-bindings-tests results.
(WebDOMTestInterface::supplementalMethod4):
* bindings/scripts/test/CPP/WebDOMTestInterface.h: Ditto.
* bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp: Ditto.
(webkit_dom_test_interface_supplemental_method4):
* bindings/scripts/test/GObject/WebKitDOMTestInterface.h: Ditto.
* bindings/scripts/test/JS/JSTestInterface.cpp: Ditto.
(WebCore):
(WebCore::JSTestInterfaceConstructor::getOwnPropertySlot):
(WebCore::JSTestInterfaceConstructor::getOwnPropertyDescriptor):
(WebCore::jsTestInterfaceConstructorFunctionSupplementalMethod4):
* bindings/scripts/test/JS/JSTestInterface.h: Ditto.
(WebCore):
* bindings/scripts/test/ObjC/DOMTestInterface.h: Ditto.
* bindings/scripts/test/ObjC/DOMTestInterface.mm: Ditto.
(-[DOMTestInterface supplementalMethod4]):
* bindings/scripts/test/V8/V8TestInterface.cpp: Ditto.
(TestInterfaceInternal):
(WebCore::TestInterfaceInternal::supplementalMethod4Callback):
(WebCore::ConfigureV8TestInterfaceTemplate):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@108757 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/CodeGeneratorV8.pm
Source/WebCore/bindings/scripts/test/CPP/WebDOMTestInterface.cpp
Source/WebCore/bindings/scripts/test/CPP/WebDOMTestInterface.h
Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp
Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.h
Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestInterface.h
Source/WebCore/bindings/scripts/test/ObjC/DOMTestInterface.h
Source/WebCore/bindings/scripts/test/ObjC/DOMTestInterface.mm
Source/WebCore/bindings/scripts/test/TestSupplemental.idl
Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp

index c23efc2..d04d1ed 100644 (file)
@@ -1,3 +1,44 @@
+2012-02-24  Kentaro Hara  <haraken@chromium.org>
+
+        Support [Supplemental] on static methods
+        https://bugs.webkit.org/show_bug.cgi?id=79357
+
+        Reviewed by Adam Barth.
+
+        [Supplemental] on static methods does not work in CodeGeneratorJS.pm
+        and CodeGeneratorV8.pm due to mis-ordered if-elsif statements.
+        This patch fixes it and supports [Supplemental] on static methods.
+
+        Test: bindings/scripts/test/TestSupplemental.idl
+
+        * bindings/scripts/CodeGeneratorJS.pm: Modified as described above.
+        (GenerateParametersCheck):
+        * bindings/scripts/CodeGeneratorV8.pm: Ditto.
+        (GenerateFunctionCallString):
+
+        * bindings/scripts/test/TestSupplemental.idl: Added a test case.
+
+        * bindings/scripts/test/CPP/WebDOMTestInterface.cpp: Updated run-bindings-tests results.
+        (WebDOMTestInterface::supplementalMethod4):
+        * bindings/scripts/test/CPP/WebDOMTestInterface.h: Ditto.
+        * bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp: Ditto.
+        (webkit_dom_test_interface_supplemental_method4):
+        * bindings/scripts/test/GObject/WebKitDOMTestInterface.h: Ditto.
+        * bindings/scripts/test/JS/JSTestInterface.cpp: Ditto.
+        (WebCore):
+        (WebCore::JSTestInterfaceConstructor::getOwnPropertySlot):
+        (WebCore::JSTestInterfaceConstructor::getOwnPropertyDescriptor):
+        (WebCore::jsTestInterfaceConstructorFunctionSupplementalMethod4):
+        * bindings/scripts/test/JS/JSTestInterface.h: Ditto.
+        (WebCore):
+        * bindings/scripts/test/ObjC/DOMTestInterface.h: Ditto.
+        * bindings/scripts/test/ObjC/DOMTestInterface.mm: Ditto.
+        (-[DOMTestInterface supplementalMethod4]):
+        * bindings/scripts/test/V8/V8TestInterface.cpp: Ditto.
+        (TestInterfaceInternal):
+        (WebCore::TestInterfaceInternal::supplementalMethod4Callback):
+        (WebCore::ConfigureV8TestInterfaceTemplate):
+
 2012-02-24  Tony Chang  <tony@chromium.org>
 
         Small refactor in RenderFlexibleBox::layoutAndPlaceChildren
index b983c46..2aa9f59 100644 (file)
@@ -2396,13 +2396,13 @@ sub GenerateParametersCheck
 
     my @arguments;
     my $functionName;
-    if ($function->isStatic) {
-        $functionName = "${implClassName}::${functionImplementationName}";
-    } elsif ($function->signature->extendedAttributes->{"ImplementedBy"}) {
-        my $implementedBy = $function->signature->extendedAttributes->{"ImplementedBy"};
+    my $implementedBy = $function->signature->extendedAttributes->{"ImplementedBy"};
+    if ($implementedBy) {
         AddToImplIncludes("${implementedBy}.h");
-        unshift(@arguments, "impl");
+        unshift(@arguments, "impl") if !$function->isStatic;
         $functionName = "${implementedBy}::${functionImplementationName}";
+    } elsif ($function->isStatic) {
+        $functionName = "${implClassName}::${functionImplementationName}";
     } elsif ($svgPropertyOrListPropertyType and !$svgListPropertyType) {
         $functionName = "podImpl.${functionImplementationName}";
     } else {
index b805a32..8c46f8c 100644 (file)
@@ -3155,13 +3155,13 @@ sub GenerateFunctionCallString()
 
     my @arguments;
     my $functionName;
-    if ($function->isStatic) {
-        $functionName = "${implClassName}::${name}";
-    } elsif ($function->signature->extendedAttributes->{"ImplementedBy"}) {
-        my $implementedBy = $function->signature->extendedAttributes->{"ImplementedBy"};
+    my $implementedBy = $function->signature->extendedAttributes->{"ImplementedBy"};
+    if ($implementedBy) {
         AddToImplIncludes("${implementedBy}.h");
-        unshift(@arguments, "imp");
+        unshift(@arguments, "imp") if !$function->isStatic;
         $functionName = "${implementedBy}::${name}";
+    } elsif ($function->isStatic) {
+        $functionName = "${implClassName}::${name}";
     } else {
         $functionName = "imp->${name}";
     }
index 37392bc..cd28aab 100644 (file)
@@ -138,6 +138,18 @@ void WebDOMTestInterface::supplementalMethod1()
 
 #endif
 
+
+#if ENABLE(Condition11) || ENABLE(Condition12)
+void WebDOMTestInterface::supplementalMethod4()
+{
+    if (!impl())
+        return;
+
+    WebCore::TestSupplemental::supplementalMethod4(impl());
+}
+
+#endif
+
 WebCore::TestInterface* toWebCore(const WebDOMTestInterface& wrapper)
 {
     return wrapper.impl();
index 1a874d9..280460b 100644 (file)
@@ -65,6 +65,7 @@ public:
 #endif
 
     void supplementalMethod1();
+    void supplementalMethod4();
 
     WebCore::TestInterface* impl() const;
 
index 81b0138..a73ebf1 100644 (file)
@@ -97,6 +97,17 @@ webkit_dom_test_interface_supplemental_method2(WebKitDOMTestInterface* self, con
 #endif /* ENABLE(Condition11) || ENABLE(Condition12) */
 }
 
+void
+webkit_dom_test_interface_supplemental_method4(WebKitDOMTestInterface* self)
+{
+#if ENABLE(Condition11) || ENABLE(Condition12)
+    g_return_if_fail(self);
+    WebCore::JSMainThreadNullState state;
+    WebCore::TestInterface * item = WebKit::core(self);
+    TestSupplemental::supplementalMethod4(item);
+#endif /* ENABLE(Condition11) || ENABLE(Condition12) */
+}
+
 gchar*
 webkit_dom_test_interface_get_supplemental_str1(WebKitDOMTestInterface* self)
 {
index 7947bf3..0b68892 100644 (file)
@@ -70,6 +70,16 @@ WEBKIT_API WebKitDOMTestObj*
 webkit_dom_test_interface_supplemental_method2(WebKitDOMTestInterface* self, const gchar* str_arg, WebKitDOMTestObj* obj_arg, GError **error);
 
 /**
+ * webkit_dom_test_interface_supplemental_method4:
+ * @self: A #WebKitDOMTestInterface
+ *
+ * Returns:
+ *
+**/
+WEBKIT_API void
+webkit_dom_test_interface_supplemental_method4(WebKitDOMTestInterface* self);
+
+/**
  * webkit_dom_test_interface_get_supplemental_str1:
  * @self: A #WebKitDOMTestInterface
  *
index 8699f1b..c3888e8 100644 (file)
@@ -80,6 +80,9 @@ static const HashTableValue JSTestInterfaceConstructorTableValues[] =
 #if ENABLE(Condition11) || ENABLE(Condition12)
     { "SUPPLEMENTALCONSTANT2", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestInterfaceSUPPLEMENTALCONSTANT2), (intptr_t)0, NoIntrinsic },
 #endif
+#if ENABLE(Condition11) || ENABLE(Condition12)
+    { "supplementalMethod4", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestInterfaceConstructorFunctionSupplementalMethod4), (intptr_t)0, NoIntrinsic },
+#endif
     { 0, 0, 0, 0, NoIntrinsic }
 };
 
@@ -109,12 +112,12 @@ void JSTestInterfaceConstructor::finishCreation(ExecState* exec, JSDOMGlobalObje
 
 bool JSTestInterfaceConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
 {
-    return getStaticValueSlot<JSTestInterfaceConstructor, JSDOMWrapper>(exec, &JSTestInterfaceConstructorTable, static_cast<JSTestInterfaceConstructor*>(cell), propertyName, slot);
+    return getStaticPropertySlot<JSTestInterfaceConstructor, JSDOMWrapper>(exec, &JSTestInterfaceConstructorTable, static_cast<JSTestInterfaceConstructor*>(cell), propertyName, slot);
 }
 
 bool JSTestInterfaceConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
 {
-    return getStaticValueDescriptor<JSTestInterfaceConstructor, JSDOMWrapper>(exec, &JSTestInterfaceConstructorTable, static_cast<JSTestInterfaceConstructor*>(object), propertyName, descriptor);
+    return getStaticPropertyDescriptor<JSTestInterfaceConstructor, JSDOMWrapper>(exec, &JSTestInterfaceConstructorTable, static_cast<JSTestInterfaceConstructor*>(object), propertyName, descriptor);
 }
 
 EncodedJSValue JSC_HOST_CALL JSTestInterfaceConstructor::constructJSTestInterface(ExecState* exec)
@@ -382,6 +385,15 @@ EncodedJSValue JSC_HOST_CALL jsTestInterfacePrototypeFunctionSupplementalMethod3
 
 #endif
 
+#if ENABLE(Condition11) || ENABLE(Condition12)
+EncodedJSValue JSC_HOST_CALL jsTestInterfaceConstructorFunctionSupplementalMethod4(ExecState* exec)
+{
+    TestSupplemental::supplementalMethod4();
+    return JSValue::encode(jsUndefined());
+}
+
+#endif
+
 // Constant getters
 
 #if ENABLE(Condition11) || ENABLE(Condition12)
index 14d9812..a0ce244 100644 (file)
@@ -152,6 +152,7 @@ protected:
 JSC::EncodedJSValue JSC_HOST_CALL jsTestInterfacePrototypeFunctionSupplementalMethod1(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestInterfacePrototypeFunctionSupplementalMethod2(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestInterfacePrototypeFunctionSupplementalMethod3(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestInterfaceConstructorFunctionSupplementalMethod4(JSC::ExecState*);
 // Attributes
 
 JSC::JSValue jsTestInterfaceSupplementalStr1(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&);
index 67970c4..7e3b1c4 100644 (file)
@@ -61,6 +61,7 @@ enum {
 - (void)supplementalMethod1;
 - (DOMTestObj *)supplementalMethod2:(NSString *)strArg objArg:(DOMTestObj *)objArg;
 - (void)supplementalMethod3;
+- (void)supplementalMethod4;
 @end
 
 #endif
index b1fc2ea..381e4c2 100644 (file)
 
 #endif
 
+
+#if ENABLE(Condition11) || ENABLE(Condition12)
+- (void)supplementalMethod4
+{
+    WebCore::JSMainThreadNullState state;
+    TestSupplemental::supplementalMethod4(IMPL);
+}
+
+#endif
+
 @end
 
 WebCore::TestInterface* core(DOMTestInterface *wrapper)
index c553312..0d7e961 100644 (file)
@@ -41,6 +41,7 @@ module test {
         void supplementalMethod1();
         [CallWith=ScriptExecutionContext] TestObj supplementalMethod2(in DOMString strArg, in TestObj objArg) raises(DOMException);
         [Custom] void supplementalMethod3();
+        static void supplementalMethod4();
 
         const unsigned short SUPPLEMENTALCONSTANT1 = 1;
         const [Reflect=CONST_IMPL] unsigned short SUPPLEMENTALCONSTANT2 = 2;
index 03be297..a347626 100644 (file)
@@ -145,6 +145,17 @@ static v8::Handle<v8::Value> supplementalMethod2Callback(const v8::Arguments& ar
 
 #endif // ENABLE(Condition11) || ENABLE(Condition12)
 
+#if ENABLE(Condition11) || ENABLE(Condition12)
+
+static v8::Handle<v8::Value> supplementalMethod4Callback(const v8::Arguments& args)
+{
+    INC_STATS("DOM.TestInterface.supplementalMethod4");
+    TestSupplemental::supplementalMethod4();
+    return v8::Handle<v8::Value>();
+}
+
+#endif // ENABLE(Condition11) || ENABLE(Condition12)
+
 } // namespace TestInterfaceInternal
 
 static const BatchedAttribute TestInterfaceAttrs[] = {
@@ -248,6 +259,9 @@ static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestInterfaceTemplate(v8:
 #if ENABLE(Condition11) || ENABLE(Condition12)
     proto->Set(v8::String::New("supplementalMethod2"), v8::FunctionTemplate::New(TestInterfaceInternal::supplementalMethod2Callback, v8::Handle<v8::Value>(), supplementalMethod2Signature));
 #endif // ENABLE(Condition11) || ENABLE(Condition12)
+#if ENABLE(Condition11) || ENABLE(Condition12)
+    desc->Set(v8::String::New("supplementalMethod4"), v8::FunctionTemplate::New(TestInterfaceInternal::supplementalMethod4Callback, v8::Handle<v8::Value>(), v8::Local<v8::Signature>()));
+#endif // ENABLE(Condition11) || ENABLE(Condition12)
     batchConfigureConstants(desc, proto, TestInterfaceConsts, WTF_ARRAY_LENGTH(TestInterfaceConsts));
 
     // Custom toString template