Title: [99793] trunk/Source/WebCore
Revision
99793
Author
[email protected]
Date
2011-11-09 17:41:24 -0800 (Wed, 09 Nov 2011)

Log Message

Remove [CanBeConstructed] IDL from CodeGenerator{JS,V8}.pm
https://bugs.webkit.org/show_bug.cgi?id=71938

Reviewed by Darin Adler.

Now no IDL files are using [CanBeConstructed] IDL.
We can safely remove [CanBeConstructed] IDL from CodeGenerator{JS,V8}.pm.

No tests. No change in behavior.

* bindings/scripts/CodeGeneratorJS.pm: Removed [CanBeConstructed]-related code.
(GenerateConstructorDeclaration):
(GenerateConstructorDefinition):
* bindings/scripts/CodeGeneratorV8.pm: Ditto.
(GenerateImplementation):
* bindings/scripts/test/TestInterface.idl: Removed [CanBeConstructed].
* bindings/v8/V8Proxy.h: Removed V8Proxy::constructDOMObject and V8Proxy::constructDOMObjectWithScriptExecutionContext, which had been used only by [CanBeConstructed].

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (99792 => 99793)


--- trunk/Source/WebCore/ChangeLog	2011-11-10 01:33:32 UTC (rev 99792)
+++ trunk/Source/WebCore/ChangeLog	2011-11-10 01:41:24 UTC (rev 99793)
@@ -1,3 +1,23 @@
+2011-11-09  Kentaro Hara  <[email protected]>
+
+        Remove [CanBeConstructed] IDL from CodeGenerator{JS,V8}.pm
+        https://bugs.webkit.org/show_bug.cgi?id=71938
+
+        Reviewed by Darin Adler.
+
+        Now no IDL files are using [CanBeConstructed] IDL.
+        We can safely remove [CanBeConstructed] IDL from CodeGenerator{JS,V8}.pm.
+
+        No tests. No change in behavior.
+
+        * bindings/scripts/CodeGeneratorJS.pm: Removed [CanBeConstructed]-related code.
+        (GenerateConstructorDeclaration):
+        (GenerateConstructorDefinition):
+        * bindings/scripts/CodeGeneratorV8.pm: Ditto.
+        (GenerateImplementation):
+        * bindings/scripts/test/TestInterface.idl: Removed [CanBeConstructed].
+        * bindings/v8/V8Proxy.h: Removed V8Proxy::constructDOMObject and V8Proxy::constructDOMObjectWithScriptExecutionContext, which had been used only by [CanBeConstructed].
+
 2011-11-09  Tim Horton  <[email protected]>
 
         feImage referencing a primitive draws incorrectly

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (99792 => 99793)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2011-11-10 01:33:32 UTC (rev 99792)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2011-11-10 01:41:24 UTC (rev 99793)
@@ -3191,7 +3191,7 @@
     my $dataNode = shift;
 
     my $constructorClassName = "${className}Constructor";
-    my $canConstruct = $dataNode->extendedAttributes->{"CanBeConstructed"} || $dataNode->extendedAttributes->{"Constructor"} || $dataNode->extendedAttributes->{"JSCustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"};
+    my $canConstruct = $dataNode->extendedAttributes->{"Constructor"} || $dataNode->extendedAttributes->{"JSCustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"};
     my $callWith = $dataNode->extendedAttributes->{"CallWith"};
 
     push(@$outputArray, "class ${constructorClassName} : public DOMConstructorObject {\n");
@@ -3269,67 +3269,56 @@
     push(@$outputArray, "    return getStaticValueDescriptor<${constructorClassName}, JSDOMWrapper>(exec, &${constructorClassName}Table, static_cast<${constructorClassName}*>(object), propertyName, descriptor);\n");
     push(@$outputArray, "}\n\n");
 
-    if ($dataNode->extendedAttributes->{"CanBeConstructed"} || $dataNode->extendedAttributes->{"Constructor"} || $dataNode->extendedAttributes->{"JSCustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"}) {
+    if ($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");
 
             push(@$outputArray, "    ${constructorClassName}* jsConstructor = static_cast<${constructorClassName}*>(exec->callee());\n");
 
-            if ($dataNode->extendedAttributes->{"Constructor"}) {
-                my $function = $dataNode->constructor;
-                my @constructorArgList;
+            my $function = $dataNode->constructor;
+            my @constructorArgList;
 
-                $implIncludes{"<runtime/Error.h>"} = 1;
+            $implIncludes{"<runtime/Error.h>"} = 1;
 
-                GenerateArgumentsCountCheck($outputArray, $function, $dataNode);
+            GenerateArgumentsCountCheck($outputArray, $function, $dataNode);
 
-                if (@{$function->raisesExceptions} || $dataNode->extendedAttributes->{"ConstructorRaisesException"}) {
-                    $implIncludes{"ExceptionCode.h"} = 1;
-                    push(@$outputArray, "    ExceptionCode ec = 0;\n");
-                }
+            if (@{$function->raisesExceptions} || $dataNode->extendedAttributes->{"ConstructorRaisesException"}) {
+                $implIncludes{"ExceptionCode.h"} = 1;
+                push(@$outputArray, "    ExceptionCode ec = 0;\n");
+            }
 
-                # For now, we do not support SVG constructors.
-                # We do not also support a constructor [Optional] argument without CallWithDefaultValue
-                # nor CallWithNullValue.
-                my $numParameters = @{$function->parameters};
-                my ($dummy, $paramIndex) = GenerateParametersCheck($outputArray, $function, $dataNode, $numParameters, $interfaceName, "constructorCallback", undef, undef, undef);
+            # For now, we do not support SVG constructors.
+            # We do not also support a constructor [Optional] argument without CallWithDefaultValue
+            # nor CallWithNullValue.
+            my $numParameters = @{$function->parameters};
+            my ($dummy, $paramIndex) = GenerateParametersCheck($outputArray, $function, $dataNode, $numParameters, $interfaceName, "constructorCallback", undef, undef, undef);
 
-                if ($dataNode->extendedAttributes->{"CallWith"} && $dataNode->extendedAttributes->{"CallWith"} eq "ScriptExecutionContext") {
-                    push(@constructorArgList, "context");
-                    push(@$outputArray, "    ScriptExecutionContext* context = jsConstructor->scriptExecutionContext();\n");
-                    push(@$outputArray, "    if (!context)\n");
-                    push(@$outputArray, "        return throwVMError(exec, createReferenceError(exec, \"${interfaceName} constructor associated document is unavailable\"));\n");
-                }
+            if ($dataNode->extendedAttributes->{"CallWith"} && $dataNode->extendedAttributes->{"CallWith"} eq "ScriptExecutionContext") {
+                push(@constructorArgList, "context");
+                push(@$outputArray, "    ScriptExecutionContext* context = jsConstructor->scriptExecutionContext();\n");
+                push(@$outputArray, "    if (!context)\n");
+                push(@$outputArray, "        return throwVMError(exec, createReferenceError(exec, \"${interfaceName} constructor associated document is unavailable\"));\n");
+            }
 
-                my $index = 0;
-                foreach my $parameter (@{$function->parameters}) {
-                    last if $index eq $paramIndex;
-                    push(@constructorArgList, $parameter->name);
-                    $index++;
-                }
+            my $index = 0;
+            foreach my $parameter (@{$function->parameters}) {
+                last if $index eq $paramIndex;
+                push(@constructorArgList, $parameter->name);
+                $index++;
+            }
 
-                if ($dataNode->extendedAttributes->{"ConstructorRaisesException"}) {
-                    push(@constructorArgList, "ec");
-                }
-                my $constructorArg = join(", ", @constructorArgList);
-                push(@$outputArray, "    RefPtr<${interfaceName}> object = ${interfaceName}::create(${constructorArg});\n");
-                if ($dataNode->extendedAttributes->{"ConstructorRaisesException"}) {
-                    push(@$outputArray, "    if (ec) {\n");
-                    push(@$outputArray, "        setDOMException(exec, ec);\n");
-                    push(@$outputArray, "        return JSValue::encode(JSValue());\n");
-                    push(@$outputArray, "    }\n");
-                }
-            } else {
-                my $constructorArg = "";
-                if ($dataNode->extendedAttributes->{"CallWith"} and $dataNode->extendedAttributes->{"CallWith"} eq "ScriptExecutionContext") {
-                    $constructorArg = "context";
-                    push(@$outputArray, "    ScriptExecutionContext* context = static_cast<${constructorClassName}*>(exec->callee())->scriptExecutionContext();\n");
-                    push(@$outputArray, "    if (!context)\n");
-                    push(@$outputArray, "        return throwVMError(exec, createReferenceError(exec, \"${interfaceName} constructor associated document is unavailable\"));\n");
-                }
-                push(@$outputArray, "    RefPtr<${interfaceName}> object = ${interfaceName}::create(${constructorArg});\n");
+            if ($dataNode->extendedAttributes->{"ConstructorRaisesException"}) {
+                push(@constructorArgList, "ec");
             }
+            my $constructorArg = join(", ", @constructorArgList);
+            push(@$outputArray, "    RefPtr<${interfaceName}> object = ${interfaceName}::create(${constructorArg});\n");
+            if ($dataNode->extendedAttributes->{"ConstructorRaisesException"}) {
+                push(@$outputArray, "    if (ec) {\n");
+                push(@$outputArray, "        setDOMException(exec, ec);\n");
+                push(@$outputArray, "        return JSValue::encode(JSValue());\n");
+                push(@$outputArray, "    }\n");
+            }
 
             push(@$outputArray, "    return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), object.get())));\n");
             push(@$outputArray, "}\n\n");

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (99792 => 99793)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2011-11-10 01:33:32 UTC (rev 99792)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2011-11-10 01:41:24 UTC (rev 99793)
@@ -393,7 +393,7 @@
         }
     }
 
-    if ($dataNode->extendedAttributes->{"CustomConstructor"} || $dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"CanBeConstructed"} || $dataNode->extendedAttributes->{"Constructor"}) {
+    if ($dataNode->extendedAttributes->{"CustomConstructor"} || $dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"Constructor"}) {
         push(@headerContent, <<END);
     static v8::Handle<v8::Value> constructorCallback(const v8::Arguments&);
 END
@@ -2286,26 +2286,9 @@
 
     push(@implContentDecls, "} // namespace ${interfaceName}Internal\n\n");
 
-    # In namespace WebCore, add generated implementation for 'CanBeConstructed'.
-    if ($dataNode->extendedAttributes->{"CanBeConstructed"} && !$dataNode->extendedAttributes->{"CustomConstructor"} && !$dataNode->extendedAttributes->{"V8CustomConstructor"} && !$dataNode->extendedAttributes->{"Constructor"}) {
-        my $v8ConstructFunction;
-        my $callWith = $dataNode->extendedAttributes->{"CallWith"};
-        if ($callWith and $callWith eq "ScriptExecutionContext") {
-            $v8ConstructFunction = "constructDOMObjectWithScriptExecutionContext";
-        } else {
-            $v8ConstructFunction = "constructDOMObject";
-        }
-        push(@implContent, <<END);
-v8::Handle<v8::Value> ${className}::constructorCallback(const v8::Arguments& args)
-{
-    INC_STATS("DOM.${interfaceName}.Contructor");
-    return V8Proxy::${v8ConstructFunction}<$interfaceName>(args, &info);
-}
-
-END
-    } elsif ($dataNode->extendedAttributes->{"NamedConstructor"} && !($dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) {
+    if ($dataNode->extendedAttributes->{"NamedConstructor"} && !($dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) {
         GenerateNamedConstructorCallback($dataNode->constructor, $dataNode, $interfaceName);
-    } elsif (($dataNode->extendedAttributes->{"CanBeConstructed"} || $dataNode->extendedAttributes->{"Constructor"}) && !($dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) {
+    } elsif ($dataNode->extendedAttributes->{"Constructor"} && !($dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) {
         GenerateConstructorCallback($dataNode->constructor, $dataNode, $interfaceName);
     }
 
@@ -2379,7 +2362,7 @@
     UNUSED_PARAM(defaultSignature); // In some cases, it will not be used.
 END
 
-    if ($dataNode->extendedAttributes->{"CanBeConstructed"} || $dataNode->extendedAttributes->{"CustomConstructor"} || $dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"Constructor"}) {
+    if ($dataNode->extendedAttributes->{"CustomConstructor"} || $dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"Constructor"}) {
         push(@implContent, <<END);
     desc->SetCallHandler(V8${interfaceName}::constructorCallback);
 END

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


--- trunk/Source/WebCore/bindings/scripts/test/TestInterface.idl	2011-11-10 01:33:32 UTC (rev 99792)
+++ trunk/Source/WebCore/bindings/scripts/test/TestInterface.idl	2011-11-10 01:41:24 UTC (rev 99793)
@@ -32,7 +32,6 @@
     interface [
         ActiveDOMObject,
         Conditional=Condition1|Condition2,
-        CanBeConstructed,
         CallWith=ScriptExecutionContext,
         Constructor(in DOMString str1, in [Optional=CallWithDefaultValue] DOMString str2),
         ConstructorRaisesException

Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.h (99792 => 99793)


--- trunk/Source/WebCore/bindings/v8/V8Proxy.h	2011-11-10 01:33:32 UTC (rev 99792)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.h	2011-11-10 01:41:24 UTC (rev 99793)
@@ -251,12 +251,6 @@
         static v8::Handle<v8::Value> throwTypeError();
         static v8::Handle<v8::Value> throwSyntaxError();
 
-        template <typename T>
-        static v8::Handle<v8::Value> constructDOMObject(const v8::Arguments&, WrapperTypeInfo*);
-
-        template <typename T>
-        static v8::Handle<v8::Value> constructDOMObjectWithScriptExecutionContext(const v8::Arguments&, WrapperTypeInfo*);
-
         v8::Local<v8::Context> context();
         v8::Local<v8::Context> mainWorldContext();
 
@@ -337,41 +331,6 @@
         IsolatedWorldSecurityOriginMap m_isolatedWorldSecurityOrigins;
     };
 
-    template <typename T>
-    v8::Handle<v8::Value> V8Proxy::constructDOMObject(const v8::Arguments& args, WrapperTypeInfo* type)
-    {
-        if (!args.IsConstructCall())
-            return throwError(V8Proxy::TypeError, "DOM object constructor cannot be called as a function.");
-
-        // Note: it's OK to let this RefPtr go out of scope because we also call
-        // SetDOMWrapper(), which effectively holds a reference to obj.
-        RefPtr<T> obj = T::create();
-        V8DOMWrapper::setDOMWrapper(args.Holder(), type, obj.get());
-        obj->ref();
-        V8DOMWrapper::setJSWrapperForDOMObject(obj.get(), v8::Persistent<v8::Object>::New(args.Holder()));
-        return args.Holder();
-    }
-
-    template <typename T>
-    v8::Handle<v8::Value> V8Proxy::constructDOMObjectWithScriptExecutionContext(const v8::Arguments& args, WrapperTypeInfo* type)
-    {
-        if (!args.IsConstructCall())
-            return throwError(V8Proxy::TypeError, "");
-
-        ScriptExecutionContext* context = getScriptExecutionContext();
-        if (!context)
-            return throwError(V8Proxy::ReferenceError, "");
-
-        // Note: it's OK to let this RefPtr go out of scope because we also call
-        // SetDOMWrapper(), which effectively holds a reference to obj.
-        RefPtr<T> obj = T::create(context);
-        V8DOMWrapper::setDOMWrapper(args.Holder(), type, obj.get());
-        obj->ref();
-        V8DOMWrapper::setJSWrapperForDOMObject(obj.get(), v8::Persistent<v8::Object>::New(args.Holder()));
-        return args.Holder();
-    }
-
-
     v8::Local<v8::Context> toV8Context(ScriptExecutionContext*, const WorldContextHandle& worldContext);
 
     // Used by an interceptor callback that it hasn't found anything to
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to