Support the [Supplemental] IDL for constants
authorharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Jan 2012 20:00:34 +0000 (20:00 +0000)
committerharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Jan 2012 20:00:34 +0000 (20:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=77228

Reviewed by Adam Barth.

We have supported the [Supplemental] IDL for attributes and methods.
This patch supports it for constants.

Test: bindings/scripts/test/TestSupplemental.idl

* bindings/scripts/generate-bindings.pl:
Supported [Supplemental] constants.
Updated some comments.

* bindings/scripts/test/TestSupplemental.idl:
Added test cases for [Supplemental] constants.

* bindings/scripts/test/CPP/WebDOMTestInterface.h: Updated the test results.
* bindings/scripts/test/JS/JSTestInterface.cpp: Ditto.
(WebCore::JSTestInterfacePrototype::getOwnPropertySlot):
(WebCore::JSTestInterfacePrototype::getOwnPropertyDescriptor):
(WebCore):
(WebCore::jsTestInterfaceSUPPLEMENTAL_CONSTANT1):
(WebCore::jsTestInterfaceSUPPLEMENTAL_CONSTANT2):
* bindings/scripts/test/JS/JSTestInterface.h: Ditto.
(WebCore):
* bindings/scripts/test/ObjC/DOMTestInterface.h: Ditto.
* bindings/scripts/test/V8/V8TestInterface.cpp: Ditto.
(WebCore::ConfigureV8TestInterfaceTemplate):

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

Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/generate-bindings.pl
Source/WebCore/bindings/scripts/test/CPP/WebDOMTestInterface.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/TestSupplemental.idl
Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp

index 3923c90..703b608 100644 (file)
@@ -1,3 +1,35 @@
+2012-01-27  Kentaro Hara  <haraken@chromium.org>
+
+        Support the [Supplemental] IDL for constants
+        https://bugs.webkit.org/show_bug.cgi?id=77228
+
+        Reviewed by Adam Barth.
+
+        We have supported the [Supplemental] IDL for attributes and methods.
+        This patch supports it for constants.
+
+        Test: bindings/scripts/test/TestSupplemental.idl
+
+        * bindings/scripts/generate-bindings.pl:
+        Supported [Supplemental] constants.
+        Updated some comments.
+
+        * bindings/scripts/test/TestSupplemental.idl:
+        Added test cases for [Supplemental] constants.
+
+        * bindings/scripts/test/CPP/WebDOMTestInterface.h: Updated the test results.
+        * bindings/scripts/test/JS/JSTestInterface.cpp: Ditto.
+        (WebCore::JSTestInterfacePrototype::getOwnPropertySlot):
+        (WebCore::JSTestInterfacePrototype::getOwnPropertyDescriptor):
+        (WebCore):
+        (WebCore::jsTestInterfaceSUPPLEMENTAL_CONSTANT1):
+        (WebCore::jsTestInterfaceSUPPLEMENTAL_CONSTANT2):
+        * bindings/scripts/test/JS/JSTestInterface.h: Ditto.
+        (WebCore):
+        * bindings/scripts/test/ObjC/DOMTestInterface.h: Ditto.
+        * bindings/scripts/test/V8/V8TestInterface.cpp: Ditto.
+        (WebCore::ConfigureV8TestInterfaceTemplate):
+
 2012-01-27  Anders Carlsson  <andersca@apple.com>
 
         When threaded scrolling is enabled for a FrameView, always put scrollbars in layers
index cb51f2c..5e38956 100755 (executable)
@@ -148,6 +148,7 @@ foreach my $idlFile (@supplementedIdlFiles) {
             }
             die "Not found an interface ${targetInterfaceName} in ${targetInterfaceName}.idl." unless defined $targetDataNode;
 
+            # Support [Supplemental] for attributes.
             foreach my $attribute (@{$dataNode->attributes}) {
                 # Record that this attribute is implemented by $interfaceName.
                 $attribute->signature->extendedAttributes->{"ImplementedBy"} = $interfaceName;
@@ -160,17 +161,31 @@ foreach my $idlFile (@supplementedIdlFiles) {
                 push(@{$targetDataNode->attributes}, $attribute);
             }
 
+            # Support [Supplemental] for methods.
             foreach my $function (@{$dataNode->functions}) {
-                # Record that this attribute is implemented by $interfaceName.
+                # Record that this method is implemented by $interfaceName.
                 $function->signature->extendedAttributes->{"ImplementedBy"} = $interfaceName;
 
-                # Add interface-wide extended attributes to each attribute.
+                # Add interface-wide extended attributes to each method.
                 foreach my $extendedAttributeName (keys %{$dataNode->extendedAttributes}) {
                     next if ($extendedAttributeName eq "Supplemental");
                     $function->signature->extendedAttributes->{$extendedAttributeName} = $dataNode->extendedAttributes->{$extendedAttributeName};
                 }
                 push(@{$targetDataNode->functions}, $function);
             }
+
+            # Support [Supplemental] for constants.
+            foreach my $constant (@{$dataNode->constants}) {
+                # Record that this constant is implemented by $interfaceName.
+                $constant->extendedAttributes->{"ImplementedBy"} = $interfaceName;
+
+                # Add interface-wide extended attributes to each constant.
+                foreach my $extendedAttributeName (keys %{$dataNode->extendedAttributes}) {
+                    next if ($extendedAttributeName eq "Supplemental");
+                    $constant->extendedAttributes->{$extendedAttributeName} = $dataNode->extendedAttributes->{$extendedAttributeName};
+                }
+                push(@{$targetDataNode->constants}, $constant);
+            }
         }
     }
 }
index 3d48186..4c7f666 100644 (file)
@@ -42,6 +42,16 @@ public:
     WebDOMTestInterface& operator=(const WebDOMTestInterface&);
     virtual ~WebDOMTestInterface();
 
+    enum {
+#if ENABLE(Condition11) || ENABLE(Condition12)
+        WEBDOM_SUPPLEMENTALCONSTANT1 = 1,
+#endif
+#if ENABLE(Condition11) || ENABLE(Condition12)
+        WEBDOM_SUPPLEMENTALCONSTANT2 = 2
+#endif
+
+    };
+
 #if ENABLE(Condition11) || ENABLE(Condition12)
     WebDOMString supplementalStr1() const;
 #endif
index 480fdd9..04c937f 100644 (file)
@@ -68,10 +68,24 @@ static const HashTable JSTestInterfaceTable = { 9, 7, JSTestInterfaceTableValues
 
 static const HashTableValue JSTestInterfaceConstructorTableValues[] =
 {
+#if ENABLE(Condition11) || ENABLE(Condition12)
+    { "SUPPLEMENTALCONSTANT1", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestInterfaceSUPPLEMENTALCONSTANT1), (intptr_t)0, NoIntrinsic },
+#endif
+#if ENABLE(Condition11) || ENABLE(Condition12)
+    { "SUPPLEMENTALCONSTANT2", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestInterfaceSUPPLEMENTALCONSTANT2), (intptr_t)0, NoIntrinsic },
+#endif
     { 0, 0, 0, 0, NoIntrinsic }
 };
 
-static const HashTable JSTestInterfaceConstructorTable = { 1, 0, JSTestInterfaceConstructorTableValues, 0 };
+static const HashTable JSTestInterfaceConstructorTable = { 4, 3, JSTestInterfaceConstructorTableValues, 0 };
+
+#if ENABLE(Condition11) || ENABLE(Condition12)
+COMPILE_ASSERT(1 == TestInterface::SUPPLEMENTALCONSTANT1, TestInterfaceEnumSUPPLEMENTALCONSTANT1IsWrongUseDontCheckEnums);
+#endif
+#if ENABLE(Condition11) || ENABLE(Condition12)
+COMPILE_ASSERT(2 == TestInterface::CONST_IMPL, TestInterfaceEnumCONST_IMPLIsWrongUseDontCheckEnums);
+#endif
+
 ASSERT_HAS_TRIVIAL_DESTRUCTOR(JSTestInterfaceConstructor);
 
 const ClassInfo JSTestInterfaceConstructor::s_info = { "TestInterfaceConstructor", &Base::s_info, &JSTestInterfaceConstructorTable, 0, CREATE_METHOD_TABLE(JSTestInterfaceConstructor) };
@@ -132,6 +146,12 @@ ConstructType JSTestInterfaceConstructor::getConstructData(JSCell*, ConstructDat
 static const HashTableValue JSTestInterfacePrototypeTableValues[] =
 {
 #if ENABLE(Condition11) || ENABLE(Condition12)
+    { "SUPPLEMENTALCONSTANT1", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestInterfaceSUPPLEMENTALCONSTANT1), (intptr_t)0, NoIntrinsic },
+#endif
+#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)
     { "supplementalMethod1", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestInterfacePrototypeFunctionSupplementalMethod1), (intptr_t)0, NoIntrinsic },
 #endif
 #if ENABLE(Condition11) || ENABLE(Condition12)
@@ -143,7 +163,7 @@ static const HashTableValue JSTestInterfacePrototypeTableValues[] =
     { 0, 0, 0, 0, NoIntrinsic }
 };
 
-static const HashTable JSTestInterfacePrototypeTable = { 8, 7, JSTestInterfacePrototypeTableValues, 0 };
+static const HashTable JSTestInterfacePrototypeTable = { 17, 15, JSTestInterfacePrototypeTableValues, 0 };
 const ClassInfo JSTestInterfacePrototype::s_info = { "TestInterfacePrototype", &Base::s_info, &JSTestInterfacePrototypeTable, 0, CREATE_METHOD_TABLE(JSTestInterfacePrototype) };
 
 JSObject* JSTestInterfacePrototype::self(ExecState* exec, JSGlobalObject* globalObject)
@@ -154,13 +174,13 @@ JSObject* JSTestInterfacePrototype::self(ExecState* exec, JSGlobalObject* global
 bool JSTestInterfacePrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
 {
     JSTestInterfacePrototype* thisObject = jsCast<JSTestInterfacePrototype*>(cell);
-    return getStaticFunctionSlot<JSObject>(exec, &JSTestInterfacePrototypeTable, thisObject, propertyName, slot);
+    return getStaticPropertySlot<JSTestInterfacePrototype, JSObject>(exec, &JSTestInterfacePrototypeTable, thisObject, propertyName, slot);
 }
 
 bool JSTestInterfacePrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
 {
     JSTestInterfacePrototype* thisObject = jsCast<JSTestInterfacePrototype*>(object);
-    return getStaticFunctionDescriptor<JSObject>(exec, &JSTestInterfacePrototypeTable, thisObject, propertyName, descriptor);
+    return getStaticPropertyDescriptor<JSTestInterfacePrototype, JSObject>(exec, &JSTestInterfacePrototypeTable, thisObject, propertyName, descriptor);
 }
 
 const ClassInfo JSTestInterface::s_info = { "TestInterface", &Base::s_info, &JSTestInterfaceTable, 0 , CREATE_METHOD_TABLE(JSTestInterface) };
@@ -330,6 +350,24 @@ EncodedJSValue JSC_HOST_CALL jsTestInterfacePrototypeFunctionSupplementalMethod3
 
 #endif
 
+// Constant getters
+
+#if ENABLE(Condition11) || ENABLE(Condition12)
+JSValue jsTestInterfaceSUPPLEMENTALCONSTANT1(ExecState* exec, JSValue, const Identifier&)
+{
+    UNUSED_PARAM(exec);
+    return jsNumber(static_cast<int>(1));
+}
+
+#endif
+#if ENABLE(Condition11) || ENABLE(Condition12)
+JSValue jsTestInterfaceSUPPLEMENTALCONSTANT2(ExecState* exec, JSValue, const Identifier&)
+{
+    UNUSED_PARAM(exec);
+    return jsNumber(static_cast<int>(2));
+}
+
+#endif
 static inline bool isObservable(JSTestInterface* jsTestInterface)
 {
     if (jsTestInterface->hasCustomProperties())
index f7fa8df..c6f3da9 100644 (file)
@@ -159,6 +159,14 @@ void setJSTestInterfaceSupplementalStr2(JSC::ExecState*, JSC::JSObject*, JSC::JS
 JSC::JSValue jsTestInterfaceSupplementalStr3(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&);
 void setJSTestInterfaceSupplementalStr3(JSC::ExecState*, JSC::JSObject*, JSC::JSValue);
 JSC::JSValue jsTestInterfaceConstructor(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&);
+// Constants
+
+#if ENABLE(Condition11) || ENABLE(Condition12)
+JSC::JSValue jsTestInterfaceSUPPLEMENTALCONSTANT1(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&);
+#endif
+#if ENABLE(Condition11) || ENABLE(Condition12)
+JSC::JSValue jsTestInterfaceSUPPLEMENTALCONSTANT2(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&);
+#endif
 
 } // namespace WebCore
 
index abd5a66..da6f209 100644 (file)
 @class DOMTestObj;
 @class NSString;
 
+enum {
+#if ENABLE(Condition11) || ENABLE(Condition12)
+    DOM_SUPPLEMENTALCONSTANT1 = 1,
+#endif
+#if ENABLE(Condition11) || ENABLE(Condition12)
+    DOM_SUPPLEMENTALCONSTANT2 = 2
+#endif
+
+};
+
 @interface DOMTestInterface : DOMObject
 #if ENABLE(Condition11) || ENABLE(Condition12)
 - (NSString *)supplementalStr1;
index 029bf5b..2355d6d 100644 (file)
@@ -40,5 +40,8 @@ module test {
         void supplementalMethod1();
         [CallWith=ScriptExecutionContext] TestObj supplementalMethod2(in DOMString strArg, in TestObj objArg) raises(DOMException);
         [Custom] void supplementalMethod3();
+
+        const unsigned short SUPPLEMENTALCONSTANT1 = 1;
+        const [Reflect=CONST_IMPL] unsigned short SUPPLEMENTALCONSTANT2 = 2;
     };
 }
index ddb87f6..76ac345 100644 (file)
@@ -146,6 +146,23 @@ static const BatchedCallback TestInterfaceCallbacks[] = {
 #endif
 };
 
+static const BatchedConstant TestInterfaceConsts[] = {
+#if ENABLE(Condition11) || ENABLE(Condition12)
+    {"SUPPLEMENTALCONSTANT1", static_cast<signed int>(1)},
+#endif
+#if ENABLE(Condition11) || ENABLE(Condition12)
+    {"SUPPLEMENTALCONSTANT2", static_cast<signed int>(2)},
+#endif
+};
+
+
+#if ENABLE(Condition11) || ENABLE(Condition12)
+COMPILE_ASSERT(1 == TestInterface::SUPPLEMENTALCONSTANT1, TestInterfaceEnumSUPPLEMENTALCONSTANT1IsWrongUseDontCheckEnums);
+#endif
+#if ENABLE(Condition11) || ENABLE(Condition12)
+COMPILE_ASSERT(2 == TestInterface::CONST_IMPL, TestInterfaceEnumCONST_IMPLIsWrongUseDontCheckEnums);
+#endif
+
 v8::Handle<v8::Value> V8TestInterface::constructorCallback(const v8::Arguments& args)
 {
     INC_STATS("DOM.TestInterface.Constructor");
@@ -202,6 +219,7 @@ 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)
+    batchConfigureConstants(desc, proto, TestInterfaceConsts, WTF_ARRAY_LENGTH(TestInterfaceConsts));
 
     // Custom toString template
     desc->Set(getToStringName(), getToStringTemplate());