⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 99793 in webkit


Ignore:
Timestamp:
Nov 9, 2011, 5:41:24 PM (15 years ago)
Author:
haraken@chromium.org
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].
Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r99782 r99793  
     12011-11-09  Kentaro Hara  <haraken@chromium.org>
     2
     3        Remove [CanBeConstructed] IDL from CodeGenerator{JS,V8}.pm
     4        https://bugs.webkit.org/show_bug.cgi?id=71938
     5
     6        Reviewed by Darin Adler.
     7
     8        Now no IDL files are using [CanBeConstructed] IDL.
     9        We can safely remove [CanBeConstructed] IDL from CodeGenerator{JS,V8}.pm.
     10
     11        No tests. No change in behavior.
     12
     13        * bindings/scripts/CodeGeneratorJS.pm: Removed [CanBeConstructed]-related code.
     14        (GenerateConstructorDeclaration):
     15        (GenerateConstructorDefinition):
     16        * bindings/scripts/CodeGeneratorV8.pm: Ditto.
     17        (GenerateImplementation):
     18        * bindings/scripts/test/TestInterface.idl: Removed [CanBeConstructed].
     19        * bindings/v8/V8Proxy.h: Removed V8Proxy::constructDOMObject and V8Proxy::constructDOMObjectWithScriptExecutionContext, which had been used only by [CanBeConstructed].
     20
    1212011-11-09  Tim Horton  <timothy_horton@apple.com>
    222
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r99754 r99793  
    31923192
    31933193    my $constructorClassName = "${className}Constructor";
    3194     my $canConstruct = $dataNode->extendedAttributes->{"CanBeConstructed"} || $dataNode->extendedAttributes->{"Constructor"} || $dataNode->extendedAttributes->{"JSCustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"};
     3194    my $canConstruct = $dataNode->extendedAttributes->{"Constructor"} || $dataNode->extendedAttributes->{"JSCustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"};
    31953195    my $callWith = $dataNode->extendedAttributes->{"CallWith"};
    31963196
     
    32703270    push(@$outputArray, "}\n\n");
    32713271
    3272     if ($dataNode->extendedAttributes->{"CanBeConstructed"} || $dataNode->extendedAttributes->{"Constructor"} || $dataNode->extendedAttributes->{"JSCustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"}) {
     3272    if ($dataNode->extendedAttributes->{"Constructor"} || $dataNode->extendedAttributes->{"JSCustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"}) {
    32733273        if (!($dataNode->extendedAttributes->{"JSCustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) {
    32743274            push(@$outputArray, "EncodedJSValue JSC_HOST_CALL ${constructorClassName}::construct${className}(ExecState* exec)\n");
     
    32773277            push(@$outputArray, "    ${constructorClassName}* jsConstructor = static_cast<${constructorClassName}*>(exec->callee());\n");
    32783278
    3279             if ($dataNode->extendedAttributes->{"Constructor"}) {
    3280                 my $function = $dataNode->constructor;
    3281                 my @constructorArgList;
    3282 
    3283                 $implIncludes{"<runtime/Error.h>"} = 1;
    3284 
    3285                 GenerateArgumentsCountCheck($outputArray, $function, $dataNode);
    3286 
    3287                 if (@{$function->raisesExceptions} || $dataNode->extendedAttributes->{"ConstructorRaisesException"}) {
    3288                     $implIncludes{"ExceptionCode.h"} = 1;
    3289                     push(@$outputArray, "    ExceptionCode ec = 0;\n");
    3290                 }
    3291 
    3292                 # For now, we do not support SVG constructors.
    3293                 # We do not also support a constructor [Optional] argument without CallWithDefaultValue
    3294                 # nor CallWithNullValue.
    3295                 my $numParameters = @{$function->parameters};
    3296                 my ($dummy, $paramIndex) = GenerateParametersCheck($outputArray, $function, $dataNode, $numParameters, $interfaceName, "constructorCallback", undef, undef, undef);
    3297 
    3298                 if ($dataNode->extendedAttributes->{"CallWith"} && $dataNode->extendedAttributes->{"CallWith"} eq "ScriptExecutionContext") {
    3299                     push(@constructorArgList, "context");
    3300                     push(@$outputArray, "    ScriptExecutionContext* context = jsConstructor->scriptExecutionContext();\n");
    3301                     push(@$outputArray, "    if (!context)\n");
    3302                     push(@$outputArray, "        return throwVMError(exec, createReferenceError(exec, \"${interfaceName} constructor associated document is unavailable\"));\n");
    3303                 }
    3304 
    3305                 my $index = 0;
    3306                 foreach my $parameter (@{$function->parameters}) {
    3307                     last if $index eq $paramIndex;
    3308                     push(@constructorArgList, $parameter->name);
    3309                     $index++;
    3310                 }
    3311 
    3312                 if ($dataNode->extendedAttributes->{"ConstructorRaisesException"}) {
    3313                     push(@constructorArgList, "ec");
    3314                 }
    3315                 my $constructorArg = join(", ", @constructorArgList);
    3316                 push(@$outputArray, "    RefPtr<${interfaceName}> object = ${interfaceName}::create(${constructorArg});\n");
    3317                 if ($dataNode->extendedAttributes->{"ConstructorRaisesException"}) {
    3318                     push(@$outputArray, "    if (ec) {\n");
    3319                     push(@$outputArray, "        setDOMException(exec, ec);\n");
    3320                     push(@$outputArray, "        return JSValue::encode(JSValue());\n");
    3321                     push(@$outputArray, "    }\n");
    3322                 }
    3323             } else {
    3324                 my $constructorArg = "";
    3325                 if ($dataNode->extendedAttributes->{"CallWith"} and $dataNode->extendedAttributes->{"CallWith"} eq "ScriptExecutionContext") {
    3326                     $constructorArg = "context";
    3327                     push(@$outputArray, "    ScriptExecutionContext* context = static_cast<${constructorClassName}*>(exec->callee())->scriptExecutionContext();\n");
    3328                     push(@$outputArray, "    if (!context)\n");
    3329                     push(@$outputArray, "        return throwVMError(exec, createReferenceError(exec, \"${interfaceName} constructor associated document is unavailable\"));\n");
    3330                 }
    3331                 push(@$outputArray, "    RefPtr<${interfaceName}> object = ${interfaceName}::create(${constructorArg});\n");
     3279            my $function = $dataNode->constructor;
     3280            my @constructorArgList;
     3281
     3282            $implIncludes{"<runtime/Error.h>"} = 1;
     3283
     3284            GenerateArgumentsCountCheck($outputArray, $function, $dataNode);
     3285
     3286            if (@{$function->raisesExceptions} || $dataNode->extendedAttributes->{"ConstructorRaisesException"}) {
     3287                $implIncludes{"ExceptionCode.h"} = 1;
     3288                push(@$outputArray, "    ExceptionCode ec = 0;\n");
     3289            }
     3290
     3291            # For now, we do not support SVG constructors.
     3292            # We do not also support a constructor [Optional] argument without CallWithDefaultValue
     3293            # nor CallWithNullValue.
     3294            my $numParameters = @{$function->parameters};
     3295            my ($dummy, $paramIndex) = GenerateParametersCheck($outputArray, $function, $dataNode, $numParameters, $interfaceName, "constructorCallback", undef, undef, undef);
     3296
     3297            if ($dataNode->extendedAttributes->{"CallWith"} && $dataNode->extendedAttributes->{"CallWith"} eq "ScriptExecutionContext") {
     3298                push(@constructorArgList, "context");
     3299                push(@$outputArray, "    ScriptExecutionContext* context = jsConstructor->scriptExecutionContext();\n");
     3300                push(@$outputArray, "    if (!context)\n");
     3301                push(@$outputArray, "        return throwVMError(exec, createReferenceError(exec, \"${interfaceName} constructor associated document is unavailable\"));\n");
     3302            }
     3303
     3304            my $index = 0;
     3305            foreach my $parameter (@{$function->parameters}) {
     3306                last if $index eq $paramIndex;
     3307                push(@constructorArgList, $parameter->name);
     3308                $index++;
     3309            }
     3310
     3311            if ($dataNode->extendedAttributes->{"ConstructorRaisesException"}) {
     3312                push(@constructorArgList, "ec");
     3313            }
     3314            my $constructorArg = join(", ", @constructorArgList);
     3315            push(@$outputArray, "    RefPtr<${interfaceName}> object = ${interfaceName}::create(${constructorArg});\n");
     3316            if ($dataNode->extendedAttributes->{"ConstructorRaisesException"}) {
     3317                push(@$outputArray, "    if (ec) {\n");
     3318                push(@$outputArray, "        setDOMException(exec, ec);\n");
     3319                push(@$outputArray, "        return JSValue::encode(JSValue());\n");
     3320                push(@$outputArray, "    }\n");
    33323321            }
    33333322
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r99732 r99793  
    394394    }
    395395
    396     if ($dataNode->extendedAttributes->{"CustomConstructor"} || $dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"CanBeConstructed"} || $dataNode->extendedAttributes->{"Constructor"}) {
     396    if ($dataNode->extendedAttributes->{"CustomConstructor"} || $dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"Constructor"}) {
    397397        push(@headerContent, <<END);
    398398    static v8::Handle<v8::Value> constructorCallback(const v8::Arguments&);
     
    22872287    push(@implContentDecls, "} // namespace ${interfaceName}Internal\n\n");
    22882288
    2289     # In namespace WebCore, add generated implementation for 'CanBeConstructed'.
    2290     if ($dataNode->extendedAttributes->{"CanBeConstructed"} && !$dataNode->extendedAttributes->{"CustomConstructor"} && !$dataNode->extendedAttributes->{"V8CustomConstructor"} && !$dataNode->extendedAttributes->{"Constructor"}) {
    2291         my $v8ConstructFunction;
    2292         my $callWith = $dataNode->extendedAttributes->{"CallWith"};
    2293         if ($callWith and $callWith eq "ScriptExecutionContext") {
    2294             $v8ConstructFunction = "constructDOMObjectWithScriptExecutionContext";
    2295         } else {
    2296             $v8ConstructFunction = "constructDOMObject";
    2297         }
    2298         push(@implContent, <<END);
    2299 v8::Handle<v8::Value> ${className}::constructorCallback(const v8::Arguments& args)
    2300 {
    2301     INC_STATS("DOM.${interfaceName}.Contructor");
    2302     return V8Proxy::${v8ConstructFunction}<$interfaceName>(args, &info);
    2303 }
    2304 
    2305 END
    2306     } elsif ($dataNode->extendedAttributes->{"NamedConstructor"} && !($dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) {
     2289    if ($dataNode->extendedAttributes->{"NamedConstructor"} && !($dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) {
    23072290        GenerateNamedConstructorCallback($dataNode->constructor, $dataNode, $interfaceName);
    2308     } elsif (($dataNode->extendedAttributes->{"CanBeConstructed"} || $dataNode->extendedAttributes->{"Constructor"}) && !($dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) {
     2291    } elsif ($dataNode->extendedAttributes->{"Constructor"} && !($dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) {
    23092292        GenerateConstructorCallback($dataNode->constructor, $dataNode, $interfaceName);
    23102293    }
     
    23802363END
    23812364
    2382     if ($dataNode->extendedAttributes->{"CanBeConstructed"} || $dataNode->extendedAttributes->{"CustomConstructor"} || $dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"Constructor"}) {
     2365    if ($dataNode->extendedAttributes->{"CustomConstructor"} || $dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"Constructor"}) {
    23832366        push(@implContent, <<END);
    23842367    desc->SetCallHandler(V8${interfaceName}::constructorCallback);
  • trunk/Source/WebCore/bindings/scripts/test/TestInterface.idl

    r98695 r99793  
    3333        ActiveDOMObject,
    3434        Conditional=Condition1|Condition2,
    35         CanBeConstructed,
    3635        CallWith=ScriptExecutionContext,
    3736        Constructor(in DOMString str1, in [Optional=CallWithDefaultValue] DOMString str2),
  • trunk/Source/WebCore/bindings/v8/V8Proxy.h

    r99588 r99793  
    252252        static v8::Handle<v8::Value> throwSyntaxError();
    253253
    254         template <typename T>
    255         static v8::Handle<v8::Value> constructDOMObject(const v8::Arguments&, WrapperTypeInfo*);
    256 
    257         template <typename T>
    258         static v8::Handle<v8::Value> constructDOMObjectWithScriptExecutionContext(const v8::Arguments&, WrapperTypeInfo*);
    259 
    260254        v8::Local<v8::Context> context();
    261255        v8::Local<v8::Context> mainWorldContext();
     
    338332    };
    339333
    340     template <typename T>
    341     v8::Handle<v8::Value> V8Proxy::constructDOMObject(const v8::Arguments& args, WrapperTypeInfo* type)
    342     {
    343         if (!args.IsConstructCall())
    344             return throwError(V8Proxy::TypeError, "DOM object constructor cannot be called as a function.");
    345 
    346         // Note: it's OK to let this RefPtr go out of scope because we also call
    347         // SetDOMWrapper(), which effectively holds a reference to obj.
    348         RefPtr<T> obj = T::create();
    349         V8DOMWrapper::setDOMWrapper(args.Holder(), type, obj.get());
    350         obj->ref();
    351         V8DOMWrapper::setJSWrapperForDOMObject(obj.get(), v8::Persistent<v8::Object>::New(args.Holder()));
    352         return args.Holder();
    353     }
    354 
    355     template <typename T>
    356     v8::Handle<v8::Value> V8Proxy::constructDOMObjectWithScriptExecutionContext(const v8::Arguments& args, WrapperTypeInfo* type)
    357     {
    358         if (!args.IsConstructCall())
    359             return throwError(V8Proxy::TypeError, "");
    360 
    361         ScriptExecutionContext* context = getScriptExecutionContext();
    362         if (!context)
    363             return throwError(V8Proxy::ReferenceError, "");
    364 
    365         // Note: it's OK to let this RefPtr go out of scope because we also call
    366         // SetDOMWrapper(), which effectively holds a reference to obj.
    367         RefPtr<T> obj = T::create(context);
    368         V8DOMWrapper::setDOMWrapper(args.Holder(), type, obj.get());
    369         obj->ref();
    370         V8DOMWrapper::setJSWrapperForDOMObject(obj.get(), v8::Persistent<v8::Object>::New(args.Holder()));
    371         return args.Holder();
    372     }
    373 
    374 
    375334    v8::Local<v8::Context> toV8Context(ScriptExecutionContext*, const WorldContextHandle& worldContext);
    376335
Note: See TracChangeset for help on using the changeset viewer.