Title: [99673] trunk/Source/WebCore
Revision
99673
Author
[email protected]
Date
2011-11-09 01:56:44 -0800 (Wed, 09 Nov 2011)

Log Message

Make [CanBeConstructed] IDL redundant
https://bugs.webkit.org/show_bug.cgi?id=71871

Reviewed by Adam Barth.

As the first step to remove [CanBeConstructed] IDL completely,
we need to make [CanBeConstructed] IDL redundant.
This patch replaces '[CanBeConstructed]' in CodeGeneratorV8.pm
with '[CanBeConstructed] or [Constructor] or [CustomConstructor] or [V8CustomConstructor]',
and replaces '[CanBeConstructed]' in CodeGeneratorJS.pm
with '[CanBeConstructed] or [Constructor] or [CustomConstructor] or [JSCustomConstructor]'

An example:
    before: '[CanBeConstructed] and ![V8CustomConstructor]'
    after: '([CanBeConstructed] or [Constructor] or [CustomConstructor] or [V8CustomConstructor]) and ![V8CustomConstructor]' <==> '([CanBeConstructed] or [Constructor] or [CustomConstructor]) and ![V8CustomConstructor]'

Tests: bindings/scripts/test/TestObj.idl

* bindings/scripts/CodeGeneratorJS.pm: Modified as I described above.
(GenerateConstructorDeclaration):
(GenerateConstructorDefinition):
* bindings/scripts/CodeGeneratorV8.pm: Ditto.
* bindings/scripts/test/JS/JSTestObj.cpp: Updated a run-bindings-tests result.
(WebCore::JSTestObjConstructor::constructJSTestObj):
(WebCore::JSTestObjConstructor::getConstructData):
* bindings/scripts/test/JS/JSTestObj.h: Ditto.
* bindings/scripts/test/V8/V8TestObj.cpp: Ditto.
(WebCore::V8TestObj::constructorCallback):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (99672 => 99673)


--- trunk/Source/WebCore/ChangeLog	2011-11-09 09:50:01 UTC (rev 99672)
+++ trunk/Source/WebCore/ChangeLog	2011-11-09 09:56:44 UTC (rev 99673)
@@ -1,3 +1,34 @@
+2011-11-09  Kentaro Hara  <[email protected]>
+
+        Make [CanBeConstructed] IDL redundant
+        https://bugs.webkit.org/show_bug.cgi?id=71871
+
+        Reviewed by Adam Barth.
+
+        As the first step to remove [CanBeConstructed] IDL completely,
+        we need to make [CanBeConstructed] IDL redundant.
+        This patch replaces '[CanBeConstructed]' in CodeGeneratorV8.pm
+        with '[CanBeConstructed] or [Constructor] or [CustomConstructor] or [V8CustomConstructor]',
+        and replaces '[CanBeConstructed]' in CodeGeneratorJS.pm
+        with '[CanBeConstructed] or [Constructor] or [CustomConstructor] or [JSCustomConstructor]'
+
+        An example:
+            before: '[CanBeConstructed] and ![V8CustomConstructor]'
+            after: '([CanBeConstructed] or [Constructor] or [CustomConstructor] or [V8CustomConstructor]) and ![V8CustomConstructor]' <==> '([CanBeConstructed] or [Constructor] or [CustomConstructor]) and ![V8CustomConstructor]'
+
+        Tests: bindings/scripts/test/TestObj.idl
+
+        * bindings/scripts/CodeGeneratorJS.pm: Modified as I described above.
+        (GenerateConstructorDeclaration):
+        (GenerateConstructorDefinition):
+        * bindings/scripts/CodeGeneratorV8.pm: Ditto.
+        * bindings/scripts/test/JS/JSTestObj.cpp: Updated a run-bindings-tests result.
+        (WebCore::JSTestObjConstructor::constructJSTestObj):
+        (WebCore::JSTestObjConstructor::getConstructData):
+        * bindings/scripts/test/JS/JSTestObj.h: Ditto.
+        * bindings/scripts/test/V8/V8TestObj.cpp: Ditto.
+        (WebCore::V8TestObj::constructorCallback):
+
 2011-11-09  Nikolas Zimmermann  <[email protected]>
 
         svg failures after r99561

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (99672 => 99673)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2011-11-09 09:50:01 UTC (rev 99672)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2011-11-09 09:56:44 UTC (rev 99673)
@@ -3188,7 +3188,7 @@
     my $dataNode = shift;
 
     my $constructorClassName = "${className}Constructor";
-    my $canConstruct = $dataNode->extendedAttributes->{"CanBeConstructed"};
+    my $canConstruct = $dataNode->extendedAttributes->{"CanBeConstructed"} || $dataNode->extendedAttributes->{"Constructor"} || $dataNode->extendedAttributes->{"JSCustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"};
     my $callWith = $dataNode->extendedAttributes->{"CallWith"};
 
     push(@$outputArray, "class ${constructorClassName} : public DOMConstructorObject {\n");
@@ -3266,7 +3266,7 @@
     push(@$outputArray, "    return getStaticValueDescriptor<${constructorClassName}, JSDOMWrapper>(exec, &${constructorClassName}Table, this, propertyName, descriptor);\n");
     push(@$outputArray, "}\n\n");
 
-    if ($dataNode->extendedAttributes->{"CanBeConstructed"}) {
+    if ($dataNode->extendedAttributes->{"CanBeConstructed"} || $dataNode->extendedAttributes->{"Constructor"} || $dataNode->extendedAttributes->{"JSCustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"}) {
         if (!($dataNode->extendedAttributes->{"JSCustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) {
             push(@$outputArray, "EncodedJSValue JSC_HOST_CALL ${constructorClassName}::construct${className}(ExecState* exec)\n");
             push(@$outputArray, "{\n");

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (99672 => 99673)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2011-11-09 09:50:01 UTC (rev 99672)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2011-11-09 09:56:44 UTC (rev 99673)
@@ -2305,7 +2305,7 @@
 END
     } elsif ($dataNode->extendedAttributes->{"NamedConstructor"} && !($dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) {
         GenerateNamedConstructorCallback($dataNode->constructor, $dataNode, $interfaceName);
-    } elsif ($dataNode->extendedAttributes->{"CanBeConstructed"} && !($dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) {
+    } elsif (($dataNode->extendedAttributes->{"CanBeConstructed"} || $dataNode->extendedAttributes->{"Constructor"}) && !($dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) {
         GenerateConstructorCallback($dataNode->constructor, $dataNode, $interfaceName);
     }
 

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (99672 => 99673)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2011-11-09 09:50:01 UTC (rev 99672)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2011-11-09 09:56:44 UTC (rev 99673)
@@ -202,6 +202,19 @@
     return getStaticValueDescriptor<JSTestObjConstructor, JSDOMWrapper>(exec, &JSTestObjConstructorTable, this, propertyName, descriptor);
 }
 
+EncodedJSValue JSC_HOST_CALL JSTestObjConstructor::constructJSTestObj(ExecState* exec)
+{
+    JSTestObjConstructor* jsConstructor = static_cast<JSTestObjConstructor*>(exec->callee());
+    RefPtr<TestObj> object = TestObj::create();
+    return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), object.get())));
+}
+
+ConstructType JSTestObjConstructor::getConstructData(JSCell*, ConstructData& constructData)
+{
+    constructData.native.function = constructJSTestObj;
+    return ConstructTypeHost;
+}
+
 /* Hash table for prototype */
 #if ENABLE(JIT)
 #define THUNK_GENERATOR(generator) , generator

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h (99672 => 99673)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h	2011-11-09 09:50:01 UTC (rev 99672)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h	2011-11-09 09:56:44 UTC (rev 99673)
@@ -124,6 +124,8 @@
     }
 protected:
     static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags;
+    static JSC::EncodedJSValue JSC_HOST_CALL constructJSTestObj(JSC::ExecState*);
+    static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&);
 };
 
 // Functions

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp (99672 => 99673)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp	2011-11-09 09:50:01 UTC (rev 99672)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp	2011-11-09 09:56:44 UTC (rev 99673)
@@ -1489,6 +1489,24 @@
 COMPILE_ASSERT(0x1abc == TestObj::CONST_VALUE_14, TestObjEnumCONST_VALUE_14IsWrongUseDontCheckEnums);
 COMPILE_ASSERT(15 == TestObj::CONST_IMPL, TestObjEnumCONST_IMPLIsWrongUseDontCheckEnums);
 
+v8::Handle<v8::Value> V8TestObj::constructorCallback(const v8::Arguments& args)
+{
+    INC_STATS("DOM.TestObj.Constructor");
+
+    if (!args.IsConstructCall())
+        return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
+
+    if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
+        return args.Holder();
+
+    RefPtr<TestObj> obj = TestObj::create();
+
+    V8DOMWrapper::setDOMWrapper(args.Holder(), &info, obj.get());
+    obj->ref();
+    V8DOMWrapper::setJSWrapperForDOMObject(obj.get(), v8::Persistent<v8::Object>::New(args.Holder()));
+    return args.Holder();
+}
+
 static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestObjTemplate(v8::Persistent<v8::FunctionTemplate> desc)
 {
     desc->ReadOnlyPrototype();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to