Changeset 138008 in webkit


Ignore:
Timestamp:
Dec 18, 2012, 4:07:45 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

[JSC] Refactoring CodeGeneratorJS.pm to simplify adding support for overloaded constructors
https://bugs.webkit.org/show_bug.cgi?id=105271

Patch by Tommy Widenflycht <tommyw@chromium.org> on 2012-12-18
Reviewed by Kentaro Hara.

This patch splits the very large function that generates constructor code into a few smaller ones.
No changes in actual generated code but some functions in the generated bindings code moves.

Existing tests cover patch.

  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateImplementation):
(GenerateConstructorDefinitions):
(GenerateConstructorDefinition):
(GenerateConstructorSupportDefinitions):
(IsCustomConstructable):
(IsConstructable):

  • bindings/scripts/test/JS/JSFloat64Array.cpp:

(WebCore::JSFloat64ArrayConstructor::constructJSFloat64Array):
(WebCore):
(WebCore::toJS):
(WebCore::JSFloat64Array::indexSetter):

  • bindings/scripts/test/JS/JSTestEventConstructor.cpp:

(WebCore):
(WebCore::JSTestEventConstructorConstructor::JSTestEventConstructorConstructor):
(WebCore::JSTestEventConstructorConstructor::finishCreation):
(WebCore::JSTestEventConstructorConstructor::getOwnPropertySlot):
(WebCore::JSTestEventConstructorConstructor::getOwnPropertyDescriptor):

  • bindings/scripts/test/JS/JSTestInterface.cpp:

(WebCore::JSTestInterfaceConstructor::constructJSTestInterface):
(WebCore):

  • bindings/scripts/test/JS/JSTestNamedConstructor.cpp:

(WebCore):
(WebCore::JSTestNamedConstructorNamedConstructor::JSTestNamedConstructorNamedConstructor):
(WebCore::JSTestNamedConstructorNamedConstructor::finishCreation):

  • bindings/scripts/test/JS/JSTestNode.cpp:

(WebCore::JSTestNodeConstructor::constructJSTestNode):
(WebCore):

  • bindings/scripts/test/JS/JSTestObj.cpp:

(WebCore::JSTestObjConstructor::constructJSTestObj):
(WebCore):

  • bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:

(WebCore::JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors):
(WebCore):

  • bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp:

(WebCore::JSTestSerializedScriptValueInterfaceConstructor::constructJSTestSerializedScriptValueInterface):
(WebCore):

Location:
trunk/Source/WebCore
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r138006 r138008  
     12012-12-18  Tommy Widenflycht  <tommyw@chromium.org>
     2
     3        [JSC] Refactoring CodeGeneratorJS.pm to simplify adding support for overloaded constructors
     4        https://bugs.webkit.org/show_bug.cgi?id=105271
     5
     6        Reviewed by Kentaro Hara.
     7
     8        This patch splits the very large function that generates constructor code into a few smaller ones.
     9        No changes in actual generated code but some functions in the generated bindings code moves.
     10
     11        Existing tests cover patch.
     12
     13        * bindings/scripts/CodeGeneratorJS.pm:
     14        (GenerateImplementation):
     15        (GenerateConstructorDefinitions):
     16        (GenerateConstructorDefinition):
     17        (GenerateConstructorSupportDefinitions):
     18        (IsCustomConstructable):
     19        (IsConstructable):
     20        * bindings/scripts/test/JS/JSFloat64Array.cpp:
     21        (WebCore::JSFloat64ArrayConstructor::constructJSFloat64Array):
     22        (WebCore):
     23        (WebCore::toJS):
     24        (WebCore::JSFloat64Array::indexSetter):
     25        * bindings/scripts/test/JS/JSTestEventConstructor.cpp:
     26        (WebCore):
     27        (WebCore::JSTestEventConstructorConstructor::JSTestEventConstructorConstructor):
     28        (WebCore::JSTestEventConstructorConstructor::finishCreation):
     29        (WebCore::JSTestEventConstructorConstructor::getOwnPropertySlot):
     30        (WebCore::JSTestEventConstructorConstructor::getOwnPropertyDescriptor):
     31        * bindings/scripts/test/JS/JSTestInterface.cpp:
     32        (WebCore::JSTestInterfaceConstructor::constructJSTestInterface):
     33        (WebCore):
     34        * bindings/scripts/test/JS/JSTestNamedConstructor.cpp:
     35        (WebCore):
     36        (WebCore::JSTestNamedConstructorNamedConstructor::JSTestNamedConstructorNamedConstructor):
     37        (WebCore::JSTestNamedConstructorNamedConstructor::finishCreation):
     38        * bindings/scripts/test/JS/JSTestNode.cpp:
     39        (WebCore::JSTestNodeConstructor::constructJSTestNode):
     40        (WebCore):
     41        * bindings/scripts/test/JS/JSTestObj.cpp:
     42        (WebCore::JSTestObjConstructor::constructJSTestObj):
     43        (WebCore):
     44        * bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
     45        (WebCore::JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors):
     46        (WebCore):
     47        * bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp:
     48        (WebCore::JSTestSerializedScriptValueInterfaceConstructor::constructJSTestSerializedScriptValueInterface):
     49        (WebCore):
     50
    1512012-12-18  Max Feil  <mfeil@rim.com>
    252
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r137700 r138008  
    15291529
    15301530        my $protoClassName = "${className}Prototype";
    1531         GenerateConstructorDefinition(\@implContent, $className, $protoClassName, $interfaceName, $visibleInterfaceName, $interface);
     1531        GenerateConstructorDefinitions(\@implContent, $className, $protoClassName, $interfaceName, $visibleInterfaceName, $interface);
    15321532        if ($interface->extendedAttributes->{"NamedConstructor"}) {
    1533             GenerateConstructorDefinition(\@implContent, $className, $protoClassName, $interfaceName, $interface->extendedAttributes->{"NamedConstructor"}, $interface, "GeneratingNamedConstructor");
     1533            GenerateConstructorDefinitions(\@implContent, $className, $protoClassName, $interfaceName, $interface->extendedAttributes->{"NamedConstructor"}, $interface, "GeneratingNamedConstructor");
    15341534        }
    15351535    }
     
    37123712}
    37133713
    3714 sub GenerateConstructorDefinition
     3714sub GenerateConstructorDefinitions
    37153715{
    37163716    my $outputArray = shift;
    3717 
    37183717    my $className = shift;
    37193718    my $protoClassName = shift;
     
    37263725    # For now mimic the old behaviour by only generating code for the last "Constructor" attribute.
    37273726    my $function = @{$interface->constructors}[-1];
     3727
     3728    GenerateConstructorDefinition($outputArray, $className, $protoClassName, $interfaceName, $visibleInterfaceName, $interface, $generatingNamedConstructor, $function);
     3729    GenerateConstructorHelperMethods($outputArray, $className, $protoClassName, $interfaceName, $visibleInterfaceName, $interface, $generatingNamedConstructor, $function);
     3730}
     3731
     3732sub GenerateConstructorDefinition
     3733{
     3734    my $outputArray = shift;
     3735    my $className = shift;
     3736    my $protoClassName = shift;
     3737    my $interfaceName = shift;
     3738    my $visibleInterfaceName = shift;
     3739    my $interface = shift;
     3740    my $generatingNamedConstructor = shift;
     3741    my $function = shift;
     3742
     3743    my $constructorClassName = $generatingNamedConstructor ? "${className}NamedConstructor" : "${className}Constructor";
     3744
     3745    if (IsConstructable($interface)) {
     3746        if ($codeGenerator->IsConstructorTemplate($interface, "Event")) {
     3747            $implIncludes{"JSDictionary.h"} = 1;
     3748            $implIncludes{"<runtime/Error.h>"} = 1;
     3749
     3750            push(@$outputArray, <<END);
     3751EncodedJSValue JSC_HOST_CALL ${constructorClassName}::construct${className}(ExecState* exec)
     3752{
     3753    ${constructorClassName}* jsConstructor = jsCast<${constructorClassName}*>(exec->callee());
     3754
     3755    ScriptExecutionContext* executionContext = jsConstructor->scriptExecutionContext();
     3756    if (!executionContext)
     3757        return throwVMError(exec, createReferenceError(exec, "Constructor associated execution context is unavailable"));
     3758
     3759    AtomicString eventType = exec->argument(0).toString(exec)->value(exec);
     3760    if (exec->hadException())
     3761        return JSValue::encode(jsUndefined());
     3762
     3763    ${interfaceName}Init eventInit;
     3764
     3765    JSValue initializerValue = exec->argument(1);
     3766    if (!initializerValue.isUndefinedOrNull()) {
     3767        // Given the above test, this will always yield an object.
     3768        JSObject* initializerObject = initializerValue.toObject(exec);
     3769
     3770        // Create the dictionary wrapper from the initializer object.
     3771        JSDictionary dictionary(exec, initializerObject);
     3772
     3773        // Attempt to fill in the EventInit.
     3774        if (!fill${interfaceName}Init(eventInit, dictionary))
     3775            return JSValue::encode(jsUndefined());
     3776    }
     3777
     3778    RefPtr<${interfaceName}> event = ${interfaceName}::create(eventType, eventInit);
     3779    return JSValue::encode(toJS(exec, jsConstructor->globalObject(), event.get()));
     3780}
     3781
     3782bool fill${interfaceName}Init(${interfaceName}Init& eventInit, JSDictionary& dictionary)
     3783{
     3784END
     3785
     3786            foreach my $interfaceBase (@{$interface->parents}) {
     3787                push(@implContent, <<END);
     3788    if (!fill${interfaceBase}Init(eventInit, dictionary))
     3789        return false;
     3790
     3791END
     3792            }
     3793
     3794            for (my $index = 0; $index < @{$interface->attributes}; $index++) {
     3795                my $attribute = @{$interface->attributes}[$index];
     3796                if ($attribute->signature->extendedAttributes->{"InitializedByEventConstructor"}) {
     3797                    my $attributeName = $attribute->signature->name;
     3798                    push(@implContent, <<END);
     3799    if (!dictionary.tryGetProperty("${attributeName}", eventInit.${attributeName}))
     3800        return false;
     3801END
     3802                }
     3803            }
     3804
     3805            push(@$outputArray, <<END);
     3806    return true;
     3807}
     3808
     3809END
     3810        } elsif ($codeGenerator->IsConstructorTemplate($interface, "TypedArray")) {
     3811            $implIncludes{"JSArrayBufferViewHelper.h"} = 1;
     3812            my $viewType = $interface->extendedAttributes->{"TypedArray"};
     3813            push(@$outputArray, "EncodedJSValue JSC_HOST_CALL ${constructorClassName}::construct${className}(ExecState* exec)\n");
     3814            push(@$outputArray, "{\n");
     3815            push(@$outputArray, "    ${constructorClassName}* jsConstructor = jsCast<${constructorClassName}*>(exec->callee());\n");
     3816            push(@$outputArray, "    RefPtr<$interfaceName> array = constructArrayBufferView<$interfaceName, $viewType>(exec);\n");
     3817            push(@$outputArray, "    if (!array.get())\n");
     3818            push(@$outputArray, "        // Exception has already been thrown.\n");
     3819            push(@$outputArray, "        return JSValue::encode(JSValue());\n");
     3820            push(@$outputArray, "    return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get())));\n");
     3821            push(@$outputArray, "}\n\n");
     3822
     3823            push(@$outputArray, "JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, ${interfaceName}* object)\n");
     3824            push(@$outputArray, "{\n");
     3825            push(@$outputArray, "    return toJSArrayBufferView<${className}>(exec, globalObject, object);\n");
     3826            push(@$outputArray, "}\n\n");
     3827
     3828            if ($interface->extendedAttributes->{"CustomIndexedSetter"}) {
     3829                push(@$outputArray, "void ${className}::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value)\n");
     3830                push(@$outputArray, "{\n");
     3831                push(@$outputArray, "    impl()->set(index, value.toNumber(exec));\n");
     3832                push(@$outputArray, "}\n\n");
     3833            }
     3834        } elsif (!HasCustomConstructor($interface) && (!$interface->extendedAttributes->{"NamedConstructor"} || $generatingNamedConstructor)) {
     3835            push(@$outputArray, "EncodedJSValue JSC_HOST_CALL ${constructorClassName}::construct${className}(ExecState* exec)\n");
     3836            push(@$outputArray, "{\n");
     3837            push(@$outputArray, "    ${constructorClassName}* castedThis = jsCast<${constructorClassName}*>(exec->callee());\n");
     3838
     3839            my @constructorArgList;
     3840
     3841            $implIncludes{"<runtime/Error.h>"} = 1;
     3842
     3843            GenerateArgumentsCountCheck($outputArray, $function, $interface);
     3844
     3845            if (@{$function->raisesExceptions} || $interface->extendedAttributes->{"ConstructorRaisesException"}) {
     3846                $implIncludes{"ExceptionCode.h"} = 1;
     3847                push(@$outputArray, "    ExceptionCode ec = 0;\n");
     3848            }
     3849
     3850            # FIXME: For now, we do not support SVG constructors.
     3851            # FIXME: Currently [Constructor(...)] does not yet support [Optional] arguments.
     3852            # It just supports [Optional=DefaultIsUndefined] or [Optional=DefaultIsNullString].
     3853            my $numParameters = @{$function->parameters};
     3854            my ($dummy, $paramIndex) = GenerateParametersCheck($outputArray, $function, $interface, $numParameters, $interfaceName, "constructorCallback", undef, undef, undef);
     3855
     3856            if ($codeGenerator->ExtendedAttributeContains($interface->extendedAttributes->{"CallWith"}, "ScriptExecutionContext")) {
     3857                push(@constructorArgList, "context");
     3858                push(@$outputArray, "    ScriptExecutionContext* context = castedThis->scriptExecutionContext();\n");
     3859                push(@$outputArray, "    if (!context)\n");
     3860                push(@$outputArray, "        return throwVMError(exec, createReferenceError(exec, \"${interfaceName} constructor associated document is unavailable\"));\n");
     3861            }
     3862            if ($generatingNamedConstructor) {
     3863                push(@constructorArgList, "castedThis->document()");
     3864            }
     3865
     3866            my $index = 0;
     3867            foreach my $parameter (@{$function->parameters}) {
     3868                last if $index eq $paramIndex;
     3869                push(@constructorArgList, $parameter->name);
     3870                $index++;
     3871            }
     3872
     3873            if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
     3874                push(@constructorArgList, "ec");
     3875            }
     3876            my $constructorArg = join(", ", @constructorArgList);
     3877            if ($generatingNamedConstructor) {
     3878                push(@$outputArray, "    RefPtr<${interfaceName}> object = ${interfaceName}::createForJSConstructor(${constructorArg});\n");
     3879            } else {
     3880                push(@$outputArray, "    RefPtr<${interfaceName}> object = ${interfaceName}::create(${constructorArg});\n");
     3881            }
     3882
     3883            if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
     3884                push(@$outputArray, "    if (ec) {\n");
     3885                push(@$outputArray, "        setDOMException(exec, ec);\n");
     3886                push(@$outputArray, "        return JSValue::encode(JSValue());\n");
     3887                push(@$outputArray, "    }\n");
     3888            }
     3889
     3890            push(@$outputArray, "    return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get())));\n");
     3891            push(@$outputArray, "}\n\n");
     3892        }
     3893    }
     3894}
     3895
     3896sub GenerateConstructorHelperMethods
     3897{
     3898    my $outputArray = shift;
     3899    my $className = shift;
     3900    my $protoClassName = shift;
     3901    my $interfaceName = shift;
     3902    my $visibleInterfaceName = shift;
     3903    my $interface = shift;
     3904    my $generatingNamedConstructor = shift;
     3905    my $function = shift;
    37283906
    37293907    my $constructorClassName = $generatingNamedConstructor ? "${className}NamedConstructor" : "${className}Constructor";
     
    37563934        push(@$outputArray, "${constructorClassName}::${constructorClassName}(Structure* structure, JSDOMGlobalObject* globalObject)\n");
    37573935        push(@$outputArray, "    : DOMConstructorObject(structure, globalObject)\n");
    3758         push(@$outputArray, "{\n");
    3759         push(@$outputArray, "}\n\n");
     3936        push(@$outputArray, "{\n}\n\n");
    37603937    }
    37613938
     
    38013978
    38023979    if (IsConstructable($interface)) {
    3803         if ($codeGenerator->IsConstructorTemplate($interface, "Event")) {
    3804             $implIncludes{"JSDictionary.h"} = 1;
    3805             $implIncludes{"<runtime/Error.h>"} = 1;
    3806 
    3807             push(@$outputArray, <<END);
    3808 EncodedJSValue JSC_HOST_CALL ${constructorClassName}::construct${className}(ExecState* exec)
    3809 {
    3810     ${constructorClassName}* jsConstructor = jsCast<${constructorClassName}*>(exec->callee());
    3811 
    3812     ScriptExecutionContext* executionContext = jsConstructor->scriptExecutionContext();
    3813     if (!executionContext)
    3814         return throwVMError(exec, createReferenceError(exec, "Constructor associated execution context is unavailable"));
    3815 
    3816     AtomicString eventType = exec->argument(0).toString(exec)->value(exec);
    3817     if (exec->hadException())
    3818         return JSValue::encode(jsUndefined());
    3819 
    3820     ${interfaceName}Init eventInit;
    3821 
    3822     JSValue initializerValue = exec->argument(1);
    3823     if (!initializerValue.isUndefinedOrNull()) {
    3824         // Given the above test, this will always yield an object.
    3825         JSObject* initializerObject = initializerValue.toObject(exec);
    3826 
    3827         // Create the dictionary wrapper from the initializer object.
    3828         JSDictionary dictionary(exec, initializerObject);
    3829 
    3830         // Attempt to fill in the EventInit.
    3831         if (!fill${interfaceName}Init(eventInit, dictionary))
    3832             return JSValue::encode(jsUndefined());
    3833     }
    3834 
    3835     RefPtr<${interfaceName}> event = ${interfaceName}::create(eventType, eventInit);
    3836     return JSValue::encode(toJS(exec, jsConstructor->globalObject(), event.get()));
    3837 }
    3838 
    3839 bool fill${interfaceName}Init(${interfaceName}Init& eventInit, JSDictionary& dictionary)
    3840 {
    3841 END
    3842 
    3843             foreach my $interfaceBase (@{$interface->parents}) {
    3844                 push(@implContent, <<END);
    3845     if (!fill${interfaceBase}Init(eventInit, dictionary))
    3846         return false;
    3847 
    3848 END
    3849             }
    3850 
    3851             for (my $index = 0; $index < @{$interface->attributes}; $index++) {
    3852                 my $attribute = @{$interface->attributes}[$index];
    3853                 if ($attribute->signature->extendedAttributes->{"InitializedByEventConstructor"}) {
    3854                     my $attributeName = $attribute->signature->name;
    3855                     push(@implContent, <<END);
    3856     if (!dictionary.tryGetProperty("${attributeName}", eventInit.${attributeName}))
    3857         return false;
    3858 END
    3859                 }
    3860             }
    3861 
    3862             push(@$outputArray, <<END);
    3863     return true;
    3864 }
    3865 
    3866 END
    3867         } elsif ($codeGenerator->IsConstructorTemplate($interface, "TypedArray")) {
    3868             $implIncludes{"JSArrayBufferViewHelper.h"} = 1;
    3869             my $viewType = $interface->extendedAttributes->{"TypedArray"};
    3870             push(@$outputArray, "EncodedJSValue JSC_HOST_CALL ${constructorClassName}::construct${className}(ExecState* exec)\n");
    3871             push(@$outputArray, "{\n");
    3872             push(@$outputArray, "    ${constructorClassName}* jsConstructor = jsCast<${constructorClassName}*>(exec->callee());\n");
    3873             push(@$outputArray, "    RefPtr<$interfaceName> array = constructArrayBufferView<$interfaceName, $viewType>(exec);\n");
    3874             push(@$outputArray, "    if (!array.get())\n");
    3875             push(@$outputArray, "        // Exception has already been thrown.\n");
    3876             push(@$outputArray, "        return JSValue::encode(JSValue());\n");
    3877             push(@$outputArray, "    return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get())));\n");
    3878             push(@$outputArray, "}\n\n");
    3879 
    3880             push(@$outputArray, "JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, ${interfaceName}* object)\n");
    3881             push(@$outputArray, "{\n");
    3882             push(@$outputArray, "    return toJSArrayBufferView<${className}>(exec, globalObject, object);\n");
    3883             push(@$outputArray, "}\n\n");
    3884 
    3885             if ($interface->extendedAttributes->{"CustomIndexedSetter"}) {
    3886                 push(@$outputArray, "void ${className}::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value)\n");
    3887                 push(@$outputArray, "{\n");
    3888                 push(@$outputArray, "    impl()->set(index, value.toNumber(exec));\n");
    3889                 push(@$outputArray, "}\n\n");
    3890             }
    3891         } elsif (!($interface->extendedAttributes->{"JSCustomConstructor"} || $interface->extendedAttributes->{"CustomConstructor"}) && (!$interface->extendedAttributes->{"NamedConstructor"} || $generatingNamedConstructor)) {
    3892             push(@$outputArray, "EncodedJSValue JSC_HOST_CALL ${constructorClassName}::construct${className}(ExecState* exec)\n");
    3893             push(@$outputArray, "{\n");
    3894 
    3895             push(@$outputArray, "    ${constructorClassName}* castedThis = jsCast<${constructorClassName}*>(exec->callee());\n");
    3896 
    3897             my @constructorArgList;
    3898 
    3899             $implIncludes{"<runtime/Error.h>"} = 1;
    3900 
    3901             GenerateArgumentsCountCheck($outputArray, $function, $interface);
    3902 
    3903             if (@{$function->raisesExceptions} || $interface->extendedAttributes->{"ConstructorRaisesException"}) {
    3904                 $implIncludes{"ExceptionCode.h"} = 1;
    3905                 push(@$outputArray, "    ExceptionCode ec = 0;\n");
    3906             }
    3907 
    3908             # FIXME: For now, we do not support SVG constructors.
    3909             # FIXME: Currently [Constructor(...)] does not yet support [Optional] arguments.
    3910             # It just supports [Optional=DefaultIsUndefined] or [Optional=DefaultIsNullString].
    3911             my $numParameters = @{$function->parameters};
    3912             my ($dummy, $paramIndex) = GenerateParametersCheck($outputArray, $function, $interface, $numParameters, $interfaceName, "constructorCallback", undef, undef, undef);
    3913 
    3914             if ($codeGenerator->ExtendedAttributeContains($interface->extendedAttributes->{"CallWith"}, "ScriptExecutionContext")) {
    3915                 push(@constructorArgList, "context");
    3916                 push(@$outputArray, "    ScriptExecutionContext* context = castedThis->scriptExecutionContext();\n");
    3917                 push(@$outputArray, "    if (!context)\n");
    3918                 push(@$outputArray, "        return throwVMError(exec, createReferenceError(exec, \"${interfaceName} constructor associated document is unavailable\"));\n");
    3919             }
    3920             if ($generatingNamedConstructor) {
    3921                 push(@constructorArgList, "castedThis->document()");
    3922             }
    3923 
    3924             my $index = 0;
    3925             foreach my $parameter (@{$function->parameters}) {
    3926                 last if $index eq $paramIndex;
    3927                 push(@constructorArgList, $parameter->name);
    3928                 $index++;
    3929             }
    3930 
    3931             if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
    3932                 push(@constructorArgList, "ec");
    3933             }
    3934             my $constructorArg = join(", ", @constructorArgList);
    3935             if ($generatingNamedConstructor) {
    3936                 push(@$outputArray, "    RefPtr<${interfaceName}> object = ${interfaceName}::createForJSConstructor(${constructorArg});\n");
    3937             } else {
    3938                 push(@$outputArray, "    RefPtr<${interfaceName}> object = ${interfaceName}::create(${constructorArg});\n");
    3939             }
    3940 
    3941             if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
    3942                 push(@$outputArray, "    if (ec) {\n");
    3943                 push(@$outputArray, "        setDOMException(exec, ec);\n");
    3944                 push(@$outputArray, "        return JSValue::encode(JSValue());\n");
    3945                 push(@$outputArray, "    }\n");
    3946             }
    3947 
    3948             push(@$outputArray, "    return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get())));\n");
    3949             push(@$outputArray, "}\n\n");
    3950         }
    3951 
    39523980        if (!$interface->extendedAttributes->{"NamedConstructor"} || $generatingNamedConstructor) {
    39533981            push(@$outputArray, "ConstructType ${constructorClassName}::getConstructData(JSCell*, ConstructData& constructData)\n");
     
    39603988}
    39613989
     3990sub HasCustomConstructor
     3991{
     3992    my $interface = shift;
     3993
     3994    return $interface->extendedAttributes->{"CustomConstructor"} || $interface->extendedAttributes->{"JSCustomConstructor"};
     3995}
     3996
    39623997sub IsConstructable
    39633998{
    39643999    my $interface = shift;
    39654000
    3966     return $interface->extendedAttributes->{"CustomConstructor"} || $interface->extendedAttributes->{"JSCustomConstructor"} || $interface->extendedAttributes->{"Constructor"} || $interface->extendedAttributes->{"NamedConstructor"} || $interface->extendedAttributes->{"ConstructorTemplate"};
     4001    return HasCustomConstructor($interface) || $interface->extendedAttributes->{"Constructor"} || $interface->extendedAttributes->{"NamedConstructor"} || $interface->extendedAttributes->{"ConstructorTemplate"};
    39674002}
    39684003
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSFloat64Array.cpp

    r133007 r138008  
    5454
    5555static const HashTable JSFloat64ArrayConstructorTable = { 1, 0, JSFloat64ArrayConstructorTableValues, 0 };
    56 static const HashTable* getJSFloat64ArrayConstructorTable(ExecState* exec)
    57 {
    58     return getHashTableForGlobalData(exec->globalData(), &JSFloat64ArrayConstructorTable);
    59 }
    60 
    61 const ClassInfo JSFloat64ArrayConstructor::s_info = { "Float64ArrayConstructor", &Base::s_info, 0, getJSFloat64ArrayConstructorTable, CREATE_METHOD_TABLE(JSFloat64ArrayConstructor) };
    62 
    63 JSFloat64ArrayConstructor::JSFloat64ArrayConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
    64     : DOMConstructorObject(structure, globalObject)
    65 {
    66 }
    67 
    68 void JSFloat64ArrayConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
    69 {
    70     Base::finishCreation(exec->globalData());
    71     ASSERT(inherits(&s_info));
    72     putDirect(exec->globalData(), exec->propertyNames().prototype, JSFloat64ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly);
    73     putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(123), ReadOnly | DontDelete | DontEnum);
    74 }
    75 
    76 bool JSFloat64ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
    77 {
    78     return getStaticValueSlot<JSFloat64ArrayConstructor, JSDOMWrapper>(exec, getJSFloat64ArrayConstructorTable(exec), jsCast<JSFloat64ArrayConstructor*>(cell), propertyName, slot);
    79 }
    80 
    81 bool JSFloat64ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
    82 {
    83     return getStaticValueDescriptor<JSFloat64ArrayConstructor, JSDOMWrapper>(exec, getJSFloat64ArrayConstructorTable(exec), jsCast<JSFloat64ArrayConstructor*>(object), propertyName, descriptor);
    84 }
    85 
    8656EncodedJSValue JSC_HOST_CALL JSFloat64ArrayConstructor::constructJSFloat64Array(ExecState* exec)
    8757{
     
    10272{
    10373    impl()->set(index, value.toNumber(exec));
     74}
     75
     76static const HashTable* getJSFloat64ArrayConstructorTable(ExecState* exec)
     77{
     78    return getHashTableForGlobalData(exec->globalData(), &JSFloat64ArrayConstructorTable);
     79}
     80
     81const ClassInfo JSFloat64ArrayConstructor::s_info = { "Float64ArrayConstructor", &Base::s_info, 0, getJSFloat64ArrayConstructorTable, CREATE_METHOD_TABLE(JSFloat64ArrayConstructor) };
     82
     83JSFloat64ArrayConstructor::JSFloat64ArrayConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
     84    : DOMConstructorObject(structure, globalObject)
     85{
     86}
     87
     88void JSFloat64ArrayConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
     89{
     90    Base::finishCreation(exec->globalData());
     91    ASSERT(inherits(&s_info));
     92    putDirect(exec->globalData(), exec->propertyNames().prototype, JSFloat64ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly);
     93    putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(123), ReadOnly | DontDelete | DontEnum);
     94}
     95
     96bool JSFloat64ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
     97{
     98    return getStaticValueSlot<JSFloat64ArrayConstructor, JSDOMWrapper>(exec, getJSFloat64ArrayConstructorTable(exec), jsCast<JSFloat64ArrayConstructor*>(cell), propertyName, slot);
     99}
     100
     101bool JSFloat64ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
     102{
     103    return getStaticValueDescriptor<JSFloat64ArrayConstructor, JSDOMWrapper>(exec, getJSFloat64ArrayConstructorTable(exec), jsCast<JSFloat64ArrayConstructor*>(object), propertyName, descriptor);
    104104}
    105105
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.cpp

    r131088 r138008  
    5252
    5353static const HashTable JSTestEventConstructorConstructorTable = { 1, 0, JSTestEventConstructorConstructorTableValues, 0 };
     54EncodedJSValue JSC_HOST_CALL JSTestEventConstructorConstructor::constructJSTestEventConstructor(ExecState* exec)
     55{
     56    JSTestEventConstructorConstructor* jsConstructor = jsCast<JSTestEventConstructorConstructor*>(exec->callee());
     57
     58    ScriptExecutionContext* executionContext = jsConstructor->scriptExecutionContext();
     59    if (!executionContext)
     60        return throwVMError(exec, createReferenceError(exec, "Constructor associated execution context is unavailable"));
     61
     62    AtomicString eventType = exec->argument(0).toString(exec)->value(exec);
     63    if (exec->hadException())
     64        return JSValue::encode(jsUndefined());
     65
     66    TestEventConstructorInit eventInit;
     67
     68    JSValue initializerValue = exec->argument(1);
     69    if (!initializerValue.isUndefinedOrNull()) {
     70        // Given the above test, this will always yield an object.
     71        JSObject* initializerObject = initializerValue.toObject(exec);
     72
     73        // Create the dictionary wrapper from the initializer object.
     74        JSDictionary dictionary(exec, initializerObject);
     75
     76        // Attempt to fill in the EventInit.
     77        if (!fillTestEventConstructorInit(eventInit, dictionary))
     78            return JSValue::encode(jsUndefined());
     79    }
     80
     81    RefPtr<TestEventConstructor> event = TestEventConstructor::create(eventType, eventInit);
     82    return JSValue::encode(toJS(exec, jsConstructor->globalObject(), event.get()));
     83}
     84
     85bool fillTestEventConstructorInit(TestEventConstructorInit& eventInit, JSDictionary& dictionary)
     86{
     87    if (!dictionary.tryGetProperty("attr2", eventInit.attr2))
     88        return false;
     89    return true;
     90}
     91
    5492const ClassInfo JSTestEventConstructorConstructor::s_info = { "TestEventConstructorConstructor", &Base::s_info, &JSTestEventConstructorConstructorTable, 0, CREATE_METHOD_TABLE(JSTestEventConstructorConstructor) };
    5593
     
    75113{
    76114    return getStaticValueDescriptor<JSTestEventConstructorConstructor, JSDOMWrapper>(exec, &JSTestEventConstructorConstructorTable, jsCast<JSTestEventConstructorConstructor*>(object), propertyName, descriptor);
    77 }
    78 
    79 EncodedJSValue JSC_HOST_CALL JSTestEventConstructorConstructor::constructJSTestEventConstructor(ExecState* exec)
    80 {
    81     JSTestEventConstructorConstructor* jsConstructor = jsCast<JSTestEventConstructorConstructor*>(exec->callee());
    82 
    83     ScriptExecutionContext* executionContext = jsConstructor->scriptExecutionContext();
    84     if (!executionContext)
    85         return throwVMError(exec, createReferenceError(exec, "Constructor associated execution context is unavailable"));
    86 
    87     AtomicString eventType = exec->argument(0).toString(exec)->value(exec);
    88     if (exec->hadException())
    89         return JSValue::encode(jsUndefined());
    90 
    91     TestEventConstructorInit eventInit;
    92 
    93     JSValue initializerValue = exec->argument(1);
    94     if (!initializerValue.isUndefinedOrNull()) {
    95         // Given the above test, this will always yield an object.
    96         JSObject* initializerObject = initializerValue.toObject(exec);
    97 
    98         // Create the dictionary wrapper from the initializer object.
    99         JSDictionary dictionary(exec, initializerObject);
    100 
    101         // Attempt to fill in the EventInit.
    102         if (!fillTestEventConstructorInit(eventInit, dictionary))
    103             return JSValue::encode(jsUndefined());
    104     }
    105 
    106     RefPtr<TestEventConstructor> event = TestEventConstructor::create(eventType, eventInit);
    107     return JSValue::encode(toJS(exec, jsConstructor->globalObject(), event.get()));
    108 }
    109 
    110 bool fillTestEventConstructorInit(TestEventConstructorInit& eventInit, JSDictionary& dictionary)
    111 {
    112     if (!dictionary.tryGetProperty("attr2", eventInit.attr2))
    113         return false;
    114     return true;
    115115}
    116116
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp

    r131088 r138008  
    100100COMPILE_ASSERT(2 == TestSupplemental::CONST_IMPL, TestInterfaceEnumCONST_IMPLIsWrongUseDoNotCheckConstants);
    101101#endif
    102 
    103 const ClassInfo JSTestInterfaceConstructor::s_info = { "TestInterfaceConstructor", &Base::s_info, &JSTestInterfaceConstructorTable, 0, CREATE_METHOD_TABLE(JSTestInterfaceConstructor) };
    104 
    105 JSTestInterfaceConstructor::JSTestInterfaceConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
    106     : DOMConstructorObject(structure, globalObject)
    107 {
    108 }
    109 
    110 void JSTestInterfaceConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
    111 {
    112     Base::finishCreation(exec->globalData());
    113     ASSERT(inherits(&s_info));
    114     putDirect(exec->globalData(), exec->propertyNames().prototype, JSTestInterfacePrototype::self(exec, globalObject), DontDelete | ReadOnly);
    115     putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(2), ReadOnly | DontDelete | DontEnum);
    116 }
    117 
    118 bool JSTestInterfaceConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
    119 {
    120     return getStaticPropertySlot<JSTestInterfaceConstructor, JSDOMWrapper>(exec, &JSTestInterfaceConstructorTable, jsCast<JSTestInterfaceConstructor*>(cell), propertyName, slot);
    121 }
    122 
    123 bool JSTestInterfaceConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
    124 {
    125     return getStaticPropertyDescriptor<JSTestInterfaceConstructor, JSDOMWrapper>(exec, &JSTestInterfaceConstructorTable, jsCast<JSTestInterfaceConstructor*>(object), propertyName, descriptor);
    126 }
    127102
    128103EncodedJSValue JSC_HOST_CALL JSTestInterfaceConstructor::constructJSTestInterface(ExecState* exec)
     
    149124}
    150125
     126const ClassInfo JSTestInterfaceConstructor::s_info = { "TestInterfaceConstructor", &Base::s_info, &JSTestInterfaceConstructorTable, 0, CREATE_METHOD_TABLE(JSTestInterfaceConstructor) };
     127
     128JSTestInterfaceConstructor::JSTestInterfaceConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
     129    : DOMConstructorObject(structure, globalObject)
     130{
     131}
     132
     133void JSTestInterfaceConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
     134{
     135    Base::finishCreation(exec->globalData());
     136    ASSERT(inherits(&s_info));
     137    putDirect(exec->globalData(), exec->propertyNames().prototype, JSTestInterfacePrototype::self(exec, globalObject), DontDelete | ReadOnly);
     138    putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(2), ReadOnly | DontDelete | DontEnum);
     139}
     140
     141bool JSTestInterfaceConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
     142{
     143    return getStaticPropertySlot<JSTestInterfaceConstructor, JSDOMWrapper>(exec, &JSTestInterfaceConstructorTable, jsCast<JSTestInterfaceConstructor*>(cell), propertyName, slot);
     144}
     145
     146bool JSTestInterfaceConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
     147{
     148    return getStaticPropertyDescriptor<JSTestInterfaceConstructor, JSDOMWrapper>(exec, &JSTestInterfaceConstructorTable, jsCast<JSTestInterfaceConstructor*>(object), propertyName, descriptor);
     149}
     150
    151151ConstructType JSTestInterfaceConstructor::getConstructData(JSCell*, ConstructData& constructData)
    152152{
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp

    r131088 r138008  
    7171{
    7272    return getStaticValueDescriptor<JSTestNamedConstructorConstructor, JSDOMWrapper>(exec, &JSTestNamedConstructorConstructorTable, jsCast<JSTestNamedConstructorConstructor*>(object), propertyName, descriptor);
    73 }
    74 
    75 const ClassInfo JSTestNamedConstructorNamedConstructor::s_info = { "AudioConstructor", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSTestNamedConstructorNamedConstructor) };
    76 
    77 JSTestNamedConstructorNamedConstructor::JSTestNamedConstructorNamedConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
    78     : DOMConstructorWithDocument(structure, globalObject)
    79 {
    80 }
    81 
    82 void JSTestNamedConstructorNamedConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
    83 {
    84     Base::finishCreation(globalObject);
    85     ASSERT(inherits(&s_info));
    86     putDirect(exec->globalData(), exec->propertyNames().prototype, JSTestNamedConstructorPrototype::self(exec, globalObject), None);
    8773}
    8874
     
    11096}
    11197
     98const ClassInfo JSTestNamedConstructorNamedConstructor::s_info = { "AudioConstructor", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSTestNamedConstructorNamedConstructor) };
     99
     100JSTestNamedConstructorNamedConstructor::JSTestNamedConstructorNamedConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
     101    : DOMConstructorWithDocument(structure, globalObject)
     102{
     103}
     104
     105void JSTestNamedConstructorNamedConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
     106{
     107    Base::finishCreation(globalObject);
     108    ASSERT(inherits(&s_info));
     109    putDirect(exec->globalData(), exec->propertyNames().prototype, JSTestNamedConstructorPrototype::self(exec, globalObject), None);
     110}
     111
    112112ConstructType JSTestNamedConstructorNamedConstructor::getConstructData(JSCell*, ConstructData& constructData)
    113113{
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp

    r136490 r138008  
    4949
    5050static const HashTable JSTestNodeConstructorTable = { 1, 0, JSTestNodeConstructorTableValues, 0 };
     51EncodedJSValue JSC_HOST_CALL JSTestNodeConstructor::constructJSTestNode(ExecState* exec)
     52{
     53    JSTestNodeConstructor* castedThis = jsCast<JSTestNodeConstructor*>(exec->callee());
     54    RefPtr<TestNode> object = TestNode::create();
     55    return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get())));
     56}
     57
    5158const ClassInfo JSTestNodeConstructor::s_info = { "TestNodeConstructor", &Base::s_info, &JSTestNodeConstructorTable, 0, CREATE_METHOD_TABLE(JSTestNodeConstructor) };
    5259
     
    7279{
    7380    return getStaticValueDescriptor<JSTestNodeConstructor, JSDOMWrapper>(exec, &JSTestNodeConstructorTable, jsCast<JSTestNodeConstructor*>(object), propertyName, descriptor);
    74 }
    75 
    76 EncodedJSValue JSC_HOST_CALL JSTestNodeConstructor::constructJSTestNode(ExecState* exec)
    77 {
    78     JSTestNodeConstructor* castedThis = jsCast<JSTestNodeConstructor*>(exec->callee());
    79     RefPtr<TestNode> object = TestNode::create();
    80     return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get())));
    8181}
    8282
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r137410 r138008  
    200200COMPILE_ASSERT(15 == TestObj::CONST_IMPL, TestObjEnumCONST_IMPLIsWrongUseDoNotCheckConstants);
    201201
     202EncodedJSValue JSC_HOST_CALL JSTestObjConstructor::constructJSTestObj(ExecState* exec)
     203{
     204    JSTestObjConstructor* castedThis = jsCast<JSTestObjConstructor*>(exec->callee());
     205    if (exec->argumentCount() < 1)
     206        return throwVMError(exec, createNotEnoughArgumentsError(exec));
     207    if (exec->argumentCount() <= 0 || !exec->argument(0).isFunction())
     208        return throwVMTypeError(exec);
     209    RefPtr<TestCallback> testCallback = JSTestCallback::create(asObject(exec->argument(0)), castedThis->globalObject());
     210    RefPtr<TestObj> object = TestObj::create(testCallback);
     211    return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get())));
     212}
     213
    202214const ClassInfo JSTestObjConstructor::s_info = { "TestObjectConstructor", &Base::s_info, &JSTestObjConstructorTable, 0, CREATE_METHOD_TABLE(JSTestObjConstructor) };
    203215
     
    223235{
    224236    return getStaticPropertyDescriptor<JSTestObjConstructor, JSDOMWrapper>(exec, &JSTestObjConstructorTable, jsCast<JSTestObjConstructor*>(object), propertyName, descriptor);
    225 }
    226 
    227 EncodedJSValue JSC_HOST_CALL JSTestObjConstructor::constructJSTestObj(ExecState* exec)
    228 {
    229     JSTestObjConstructor* castedThis = jsCast<JSTestObjConstructor*>(exec->callee());
    230     if (exec->argumentCount() < 1)
    231         return throwVMError(exec, createNotEnoughArgumentsError(exec));
    232     if (exec->argumentCount() <= 0 || !exec->argument(0).isFunction())
    233         return throwVMTypeError(exec);
    234     RefPtr<TestCallback> testCallback = JSTestCallback::create(asObject(exec->argument(0)), castedThis->globalObject());
    235     RefPtr<TestObj> object = TestObj::create(testCallback);
    236     return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get())));
    237237}
    238238
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp

    r134221 r138008  
    4949
    5050static const HashTable JSTestOverloadedConstructorsConstructorTable = { 1, 0, JSTestOverloadedConstructorsConstructorTableValues, 0 };
     51EncodedJSValue JSC_HOST_CALL JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors(ExecState* exec)
     52{
     53    JSTestOverloadedConstructorsConstructor* castedThis = jsCast<JSTestOverloadedConstructorsConstructor*>(exec->callee());
     54    if (exec->argumentCount() < 1)
     55        return throwVMError(exec, createNotEnoughArgumentsError(exec));
     56    const String& string(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).isEmpty() ? String() : MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toString(exec)->value(exec));
     57    if (exec->hadException())
     58        return JSValue::encode(jsUndefined());
     59    RefPtr<TestOverloadedConstructors> object = TestOverloadedConstructors::create(string);
     60    return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get())));
     61}
     62
    5163const ClassInfo JSTestOverloadedConstructorsConstructor::s_info = { "TestOverloadedConstructorsConstructor", &Base::s_info, &JSTestOverloadedConstructorsConstructorTable, 0, CREATE_METHOD_TABLE(JSTestOverloadedConstructorsConstructor) };
    5264
     
    7284{
    7385    return getStaticValueDescriptor<JSTestOverloadedConstructorsConstructor, JSDOMWrapper>(exec, &JSTestOverloadedConstructorsConstructorTable, jsCast<JSTestOverloadedConstructorsConstructor*>(object), propertyName, descriptor);
    74 }
    75 
    76 EncodedJSValue JSC_HOST_CALL JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors(ExecState* exec)
    77 {
    78     JSTestOverloadedConstructorsConstructor* castedThis = jsCast<JSTestOverloadedConstructorsConstructor*>(exec->callee());
    79     if (exec->argumentCount() < 1)
    80         return throwVMError(exec, createNotEnoughArgumentsError(exec));
    81     const String& string(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).isEmpty() ? String() : MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toString(exec)->value(exec));
    82     if (exec->hadException())
    83         return JSValue::encode(jsUndefined());
    84     RefPtr<TestOverloadedConstructors> object = TestOverloadedConstructors::create(string);
    85     return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get())));
    8686}
    8787
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp

    r131088 r138008  
    6262
    6363static const HashTable JSTestSerializedScriptValueInterfaceConstructorTable = { 1, 0, JSTestSerializedScriptValueInterfaceConstructorTableValues, 0 };
     64EncodedJSValue JSC_HOST_CALL JSTestSerializedScriptValueInterfaceConstructor::constructJSTestSerializedScriptValueInterface(ExecState* exec)
     65{
     66    JSTestSerializedScriptValueInterfaceConstructor* castedThis = jsCast<JSTestSerializedScriptValueInterfaceConstructor*>(exec->callee());
     67    if (exec->argumentCount() < 2)
     68        return throwVMError(exec, createNotEnoughArgumentsError(exec));
     69    const String& hello(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).isEmpty() ? String() : MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toString(exec)->value(exec));
     70    if (exec->hadException())
     71        return JSValue::encode(jsUndefined());
     72    RefPtr<SerializedScriptValue> data(SerializedScriptValue::create(exec, MAYBE_MISSING_PARAMETER(exec, 1, DefaultIsUndefined), 0, 0));
     73    if (exec->hadException())
     74        return JSValue::encode(jsUndefined());
     75    Array* transferList(toArray(MAYBE_MISSING_PARAMETER(exec, 2, DefaultIsUndefined)));
     76    if (exec->hadException())
     77        return JSValue::encode(jsUndefined());
     78    RefPtr<TestSerializedScriptValueInterface> object = TestSerializedScriptValueInterface::create(hello, data, transferList);
     79    return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get())));
     80}
     81
    6482const ClassInfo JSTestSerializedScriptValueInterfaceConstructor::s_info = { "TestSerializedScriptValueInterfaceConstructor", &Base::s_info, &JSTestSerializedScriptValueInterfaceConstructorTable, 0, CREATE_METHOD_TABLE(JSTestSerializedScriptValueInterfaceConstructor) };
    6583
     
    85103{
    86104    return getStaticValueDescriptor<JSTestSerializedScriptValueInterfaceConstructor, JSDOMWrapper>(exec, &JSTestSerializedScriptValueInterfaceConstructorTable, jsCast<JSTestSerializedScriptValueInterfaceConstructor*>(object), propertyName, descriptor);
    87 }
    88 
    89 EncodedJSValue JSC_HOST_CALL JSTestSerializedScriptValueInterfaceConstructor::constructJSTestSerializedScriptValueInterface(ExecState* exec)
    90 {
    91     JSTestSerializedScriptValueInterfaceConstructor* castedThis = jsCast<JSTestSerializedScriptValueInterfaceConstructor*>(exec->callee());
    92     if (exec->argumentCount() < 2)
    93         return throwVMError(exec, createNotEnoughArgumentsError(exec));
    94     const String& hello(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).isEmpty() ? String() : MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toString(exec)->value(exec));
    95     if (exec->hadException())
    96         return JSValue::encode(jsUndefined());
    97     RefPtr<SerializedScriptValue> data(SerializedScriptValue::create(exec, MAYBE_MISSING_PARAMETER(exec, 1, DefaultIsUndefined), 0, 0));
    98     if (exec->hadException())
    99         return JSValue::encode(jsUndefined());
    100     Array* transferList(toArray(MAYBE_MISSING_PARAMETER(exec, 2, DefaultIsUndefined)));
    101     if (exec->hadException())
    102         return JSValue::encode(jsUndefined());
    103     RefPtr<TestSerializedScriptValueInterface> object = TestSerializedScriptValueInterface::create(hello, data, transferList);
    104     return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get())));
    105105}
    106106
Note: See TracChangeset for help on using the changeset viewer.