Title: [140303] trunk/Source/WebCore
Revision
140303
Author
[email protected]
Date
2013-01-20 23:27:56 -0800 (Sun, 20 Jan 2013)

Log Message

Add a [ConstructorConditional] IDL attribute
https://bugs.webkit.org/show_bug.cgi?id=107407

Reviewed by Adam Barth.

Per discussion in webkit-dev, we need to implement DOM4 event constructors
under a enable flag. For that purpose, we implement a [ConstructorConditional]
IDL attribute.

Test: bindings/scripts/test/TestInterface.idl

* bindings/scripts/CodeGenerator.pm:
(GenerateConstructorConditionalString):
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateConstructorDeclaration):
(GenerateConstructorHelperMethods):
* bindings/scripts/CodeGeneratorV8.pm:
(GenerateHeader):
(GenerateImplementation):
* bindings/scripts/IDLAttributes.txt:
* bindings/scripts/test/JS/JSTestInterface.cpp:
(WebCore):
* bindings/scripts/test/JS/JSTestInterface.h:
(JSTestInterfaceConstructor):
* bindings/scripts/test/TestInterface.idl:
* bindings/scripts/test/V8/V8TestInterface.cpp:
(WebCore::ConfigureV8TestInterfaceTemplate):
* bindings/scripts/test/V8/V8TestInterface.h:
(V8TestInterface):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (140302 => 140303)


--- trunk/Source/WebCore/ChangeLog	2013-01-21 07:18:48 UTC (rev 140302)
+++ trunk/Source/WebCore/ChangeLog	2013-01-21 07:27:56 UTC (rev 140303)
@@ -1,5 +1,37 @@
 2013-01-20  Kentaro Hara  <[email protected]>
 
+        Add a [ConstructorConditional] IDL attribute
+        https://bugs.webkit.org/show_bug.cgi?id=107407
+
+        Reviewed by Adam Barth.
+
+        Per discussion in webkit-dev, we need to implement DOM4 event constructors
+        under a enable flag. For that purpose, we implement a [ConstructorConditional]
+        IDL attribute.
+
+        Test: bindings/scripts/test/TestInterface.idl
+
+        * bindings/scripts/CodeGenerator.pm:
+        (GenerateConstructorConditionalString):
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateConstructorDeclaration):
+        (GenerateConstructorHelperMethods):
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (GenerateHeader):
+        (GenerateImplementation):
+        * bindings/scripts/IDLAttributes.txt:
+        * bindings/scripts/test/JS/JSTestInterface.cpp:
+        (WebCore):
+        * bindings/scripts/test/JS/JSTestInterface.h:
+        (JSTestInterfaceConstructor):
+        * bindings/scripts/test/TestInterface.idl:
+        * bindings/scripts/test/V8/V8TestInterface.cpp:
+        (WebCore::ConfigureV8TestInterfaceTemplate):
+        * bindings/scripts/test/V8/V8TestInterface.h:
+        (V8TestInterface):
+
+2013-01-20  Kentaro Hara  <[email protected]>
+
         [V8] We should set a class id for a NPObject wrapper
         https://bugs.webkit.org/show_bug.cgi?id=107249
 

Modified: trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm (140302 => 140303)


--- trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm	2013-01-21 07:18:48 UTC (rev 140302)
+++ trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm	2013-01-21 07:27:56 UTC (rev 140303)
@@ -648,6 +648,19 @@
     }
 }
 
+sub GenerateConstructorConditionalString
+{
+    my $generator = shift;
+    my $node = shift;
+
+    my $conditional = $node->extendedAttributes->{"ConstructorConditional"};
+    if ($conditional) {
+        return $generator->GenerateConditionalStringFromAttributeValue($conditional);
+    } else {
+        return "";
+    }
+}
+
 sub GenerateConditionalStringFromAttributeValue
 {
     my $generator = shift;

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (140302 => 140303)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2013-01-21 07:18:48 UTC (rev 140302)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2013-01-21 07:27:56 UTC (rev 140303)
@@ -3682,7 +3682,10 @@
             }
         }
 
+        my $conditionalString = $codeGenerator->GenerateConstructorConditionalString($interface);
+        push(@$outputArray, "#if $conditionalString\n") if $conditionalString;
         push(@$outputArray, "    static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&);\n");
+        push(@$outputArray, "#endif // $conditionalString\n") if $conditionalString;
     }
     push(@$outputArray, "};\n\n");
 
@@ -4050,11 +4053,15 @@
 
     if (IsConstructable($interface)) {
         if (!$interface->extendedAttributes->{"NamedConstructor"} || $generatingNamedConstructor) {
+            my $conditionalString = $codeGenerator->GenerateConstructorConditionalString($interface);
+            push(@$outputArray, "#if $conditionalString\n") if $conditionalString;
             push(@$outputArray, "ConstructType ${constructorClassName}::getConstructData(JSCell*, ConstructData& constructData)\n");
             push(@$outputArray, "{\n");
             push(@$outputArray, "    constructData.native.function = construct${className};\n");
             push(@$outputArray, "    return ConstructTypeHost;\n");
-            push(@$outputArray, "}\n\n");
+            push(@$outputArray, "}\n");
+            push(@$outputArray, "#endif // $conditionalString\n") if $conditionalString;
+            push(@$outputArray, "\n");
         }
     }
 }

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (140302 => 140303)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2013-01-21 07:18:48 UTC (rev 140302)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2013-01-21 07:27:56 UTC (rev 140303)
@@ -405,8 +405,10 @@
     }
 
     if (IsConstructable($interface)) {
-        push(@headerContent, <<END);
-    static v8::Handle<v8::Value> constructorCallback(const v8::Arguments&);
+        my $conditionalString = $codeGenerator->GenerateConstructorConditionalString($interface);
+        push(@headerContent, "#if $conditionalString\n") if $conditionalString;
+        push(@headerContent, "    static v8::Handle<v8::Value> constructorCallback(const v8::Arguments&);\n");
+        push(@headerContent, "#endif // $conditionalString\n") if $conditionalString;
 END
     }
     if (HasCustomConstructor($interface)) {
@@ -2948,9 +2950,10 @@
 END
 
     if (IsConstructable($interface)) {
-        push(@implContent, <<END);
-    desc->SetCallHandler(${v8InterfaceName}::constructorCallback);
-END
+        my $conditionalString = $codeGenerator->GenerateConstructorConditionalString($interface);
+        push(@implContent, "#if $conditionalString\n") if $conditionalString;
+        push(@implContent, "    desc->SetCallHandler(${v8InterfaceName}::constructorCallback);\n");
+        push(@implContent, "#endif // $conditionalString\n") if $conditionalString;
     }
 
     if ($access_check or @enabledAtRuntimeAttributes or @normalFunctions or $has_constants) {

Modified: trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt (140302 => 140303)


--- trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt	2013-01-21 07:18:48 UTC (rev 140302)
+++ trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt	2013-01-21 07:27:56 UTC (rev 140303)
@@ -28,6 +28,7 @@
 Clamp
 Conditional=*
 Constructor
+ConstructorConditional=*
 ConstructorParameters=*
 ConstructorRaisesException
 ConstructorTemplate=Event|TypedArray

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


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp	2013-01-21 07:18:48 UTC (rev 140302)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp	2013-01-21 07:27:56 UTC (rev 140303)
@@ -148,11 +148,13 @@
     return getStaticPropertyDescriptor<JSTestInterfaceConstructor, JSDOMWrapper>(exec, &JSTestInterfaceConstructorTable, jsCast<JSTestInterfaceConstructor*>(object), propertyName, descriptor);
 }
 
+#if ENABLE(TEST_INTERFACE)
 ConstructType JSTestInterfaceConstructor::getConstructData(JSCell*, ConstructData& constructData)
 {
     constructData.native.function = constructJSTestInterface;
     return ConstructTypeHost;
 }
+#endif // ENABLE(TEST_INTERFACE)
 
 /* Hash table for prototype */
 

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


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.h	2013-01-21 07:18:48 UTC (rev 140302)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.h	2013-01-21 07:27:56 UTC (rev 140303)
@@ -152,7 +152,9 @@
 protected:
     static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags;
     static JSC::EncodedJSValue JSC_HOST_CALL constructJSTestInterface(JSC::ExecState*);
+#if ENABLE(TEST_INTERFACE)
     static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&);
+#endif // ENABLE(TEST_INTERFACE)
 };
 
 // Functions

Modified: trunk/Source/WebCore/bindings/scripts/test/TestInterface.idl (140302 => 140303)


--- trunk/Source/WebCore/bindings/scripts/test/TestInterface.idl	2013-01-21 07:18:48 UTC (rev 140302)
+++ trunk/Source/WebCore/bindings/scripts/test/TestInterface.idl	2013-01-21 07:27:56 UTC (rev 140303)
@@ -34,6 +34,7 @@
     Conditional=Condition1|Condition2,
     CallWith=ScriptExecutionContext,
     Constructor(in DOMString str1, in [Optional=DefaultIsUndefined] DOMString str2),
-    ConstructorRaisesException
+    ConstructorRaisesException,
+    ConstructorConditional=TEST_INTERFACE
 ] interface TestInterface {
 };

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp (140302 => 140303)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp	2013-01-21 07:18:48 UTC (rev 140302)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp	2013-01-21 07:27:56 UTC (rev 140303)
@@ -265,7 +265,9 @@
         V8TestInterfaceAttrs, WTF_ARRAY_LENGTH(V8TestInterfaceAttrs),
         V8TestInterfaceCallbacks, WTF_ARRAY_LENGTH(V8TestInterfaceCallbacks));
     UNUSED_PARAM(defaultSignature); // In some cases, it will not be used.
+#if ENABLE(TEST_INTERFACE)
     desc->SetCallHandler(V8TestInterface::constructorCallback);
+#endif // ENABLE(TEST_INTERFACE)
     v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
     v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
     UNUSED_PARAM(instance); // In some cases, it will not be used.

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.h (140302 => 140303)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.h	2013-01-21 07:18:48 UTC (rev 140302)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.h	2013-01-21 07:27:56 UTC (rev 140303)
@@ -46,7 +46,9 @@
     static void derefObject(void*);
     static WrapperTypeInfo info;
     static ActiveDOMObject* toActiveDOMObject(v8::Handle<v8::Object>);
+#if ENABLE(TEST_INTERFACE)
     static v8::Handle<v8::Value> constructorCallback(const v8::Arguments&);
+#endif // ENABLE(TEST_INTERFACE)
     static v8::Handle<v8::Value> namedPropertySetter(v8::Local<v8::String>, v8::Local<v8::Value>, const v8::AccessorInfo&);
     static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0;
     static void installPerContextProperties(v8::Handle<v8::Object>, TestInterface*) { }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to