Changeset 207324 in webkit


Ignore:
Timestamp:
Oct 13, 2016 11:19:12 PM (7 years ago)
Author:
commit-queue@webkit.org
Message:

Update serializer and iterator binding generated code
https://bugs.webkit.org/show_bug.cgi?id=163325

Patch by Youenn Fablet <youenn@apple.com> on 2016-10-13
Reviewed by Darin Adler.

No change of behavior.
Covered by existing tests and rebased binding generated code.

Making use of BindingCaller::callOperation within serializer and iterator operations.
Refactored serializer code to use direct attribute getters.

  • bindings/js/JSDOMIterator.h:

(WebCore::iteratorCreate):
(WebCore::iteratorForEach):

  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateSerializerFunction):
(GenerateImplementationIterableFunctions):

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

(WebCore::jsTestIterablePrototypeFunctionSymbolIteratorCaller):
(WebCore::jsTestIterablePrototypeFunctionSymbolIterator):
(WebCore::jsTestIterablePrototypeFunctionEntriesCaller):
(WebCore::jsTestIterablePrototypeFunctionEntries):
(WebCore::jsTestIterablePrototypeFunctionKeysCaller):
(WebCore::jsTestIterablePrototypeFunctionKeys):
(WebCore::jsTestIterablePrototypeFunctionValuesCaller):
(WebCore::jsTestIterablePrototypeFunctionValues):
(WebCore::jsTestIterablePrototypeFunctionForEachCaller):
(WebCore::jsTestIterablePrototypeFunctionForEach):

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

(WebCore::jsTestNodePrototypeFunctionSymbolIteratorCaller):
(WebCore::jsTestNodePrototypeFunctionSymbolIterator):
(WebCore::jsTestNodePrototypeFunctionEntriesCaller):
(WebCore::jsTestNodePrototypeFunctionEntries):
(WebCore::jsTestNodePrototypeFunctionKeysCaller):
(WebCore::jsTestNodePrototypeFunctionKeys):
(WebCore::jsTestNodePrototypeFunctionValuesCaller):
(WebCore::jsTestNodePrototypeFunctionValues):
(WebCore::jsTestNodePrototypeFunctionForEachCaller):
(WebCore::jsTestNodePrototypeFunctionForEach):
(WebCore::jsTestNodePrototypeFunctionToJSON):

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

(WebCore::jsTestObjPrototypeFunctionToJSON):

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r207323 r207324  
     12016-10-13  Youenn Fablet  <youenn@apple.com>
     2
     3        Update serializer and iterator binding generated code
     4        https://bugs.webkit.org/show_bug.cgi?id=163325
     5
     6        Reviewed by Darin Adler.
     7
     8        No change of behavior.
     9        Covered by existing tests and rebased binding generated code.
     10
     11        Making use of BindingCaller::callOperation within serializer and iterator operations.
     12        Refactored serializer code to use direct attribute getters.
     13
     14        * bindings/js/JSDOMIterator.h:
     15        (WebCore::iteratorCreate):
     16        (WebCore::iteratorForEach):
     17        * bindings/scripts/CodeGeneratorJS.pm:
     18        (GenerateSerializerFunction):
     19        (GenerateImplementationIterableFunctions):
     20        * bindings/scripts/test/JS/JSTestIterable.cpp:
     21        (WebCore::jsTestIterablePrototypeFunctionSymbolIteratorCaller):
     22        (WebCore::jsTestIterablePrototypeFunctionSymbolIterator):
     23        (WebCore::jsTestIterablePrototypeFunctionEntriesCaller):
     24        (WebCore::jsTestIterablePrototypeFunctionEntries):
     25        (WebCore::jsTestIterablePrototypeFunctionKeysCaller):
     26        (WebCore::jsTestIterablePrototypeFunctionKeys):
     27        (WebCore::jsTestIterablePrototypeFunctionValuesCaller):
     28        (WebCore::jsTestIterablePrototypeFunctionValues):
     29        (WebCore::jsTestIterablePrototypeFunctionForEachCaller):
     30        (WebCore::jsTestIterablePrototypeFunctionForEach):
     31        * bindings/scripts/test/JS/JSTestNode.cpp:
     32        (WebCore::jsTestNodePrototypeFunctionSymbolIteratorCaller):
     33        (WebCore::jsTestNodePrototypeFunctionSymbolIterator):
     34        (WebCore::jsTestNodePrototypeFunctionEntriesCaller):
     35        (WebCore::jsTestNodePrototypeFunctionEntries):
     36        (WebCore::jsTestNodePrototypeFunctionKeysCaller):
     37        (WebCore::jsTestNodePrototypeFunctionKeys):
     38        (WebCore::jsTestNodePrototypeFunctionValuesCaller):
     39        (WebCore::jsTestNodePrototypeFunctionValues):
     40        (WebCore::jsTestNodePrototypeFunctionForEachCaller):
     41        (WebCore::jsTestNodePrototypeFunctionForEach):
     42        (WebCore::jsTestNodePrototypeFunctionToJSON):
     43        * bindings/scripts/test/JS/JSTestObj.cpp:
     44        (WebCore::jsTestObjPrototypeFunctionToJSON):
     45
    1462016-10-13  Alex Christensen  <achristensen@webkit.org>
    247
  • trunk/Source/WebCore/bindings/js/JSDOMIterator.h

    r205569 r207324  
    125125
    126126template<typename JSWrapper>
    127 JSC::EncodedJSValue iteratorCreate(JSC::ExecState&, IterationKind, const char*);
    128 template<typename JSWrapper>
    129 JSC::EncodedJSValue iteratorForEach(JSC::ExecState&, const char*);
    130 
    131 template<typename JSWrapper>
    132 JSC::EncodedJSValue iteratorCreate(JSC::ExecState& state, IterationKind kind, const char* propertyName)
    133 {
    134     JSC::VM& vm = state.vm();
    135     auto scope = DECLARE_THROW_SCOPE(vm);
    136 
    137     auto wrapper = JSC::jsDynamicCast<JSWrapper*>(state.thisValue());
    138     if (UNLIKELY(!wrapper))
    139         return throwThisTypeError(state, scope, JSWrapper::info()->className, propertyName);
    140     JSDOMGlobalObject& globalObject = *wrapper->globalObject();
    141     return JSC::JSValue::encode(JSDOMIterator<JSWrapper>::create(globalObject.vm(), getDOMStructure<JSDOMIterator<JSWrapper>>(globalObject.vm(), globalObject), *wrapper, kind));
     127JSC::JSValue iteratorCreate(JSWrapper&, IterationKind);
     128template<typename JSWrapper>
     129JSC::JSValue iteratorForEach(JSC::ExecState&, JSWrapper&, JSC::ThrowScope&);
     130
     131template<typename JSWrapper>
     132JSC::JSValue iteratorCreate(JSWrapper& thisObject, IterationKind kind)
     133{
     134    ASSERT(thisObject.globalObject());
     135    JSDOMGlobalObject& globalObject = *thisObject.globalObject();
     136    return JSDOMIterator<JSWrapper>::create(globalObject.vm(), getDOMStructure<JSDOMIterator<JSWrapper>>(globalObject.vm(), globalObject), thisObject, kind);
    142137}
    143138
     
    183178
    184179template<typename JSWrapper>
    185 JSC::EncodedJSValue iteratorForEach(JSC::ExecState& state, const char* propertyName)
    186 {
    187     JSC::VM& vm = state.vm();
    188     auto scope = DECLARE_THROW_SCOPE(vm);
    189 
    190     auto wrapper = JSC::jsDynamicCast<JSWrapper*>(state.thisValue());
    191     if (UNLIKELY(!wrapper))
    192         return throwThisTypeError(state, scope, JSWrapper::info()->className, propertyName);
    193 
     180JSC::JSValue iteratorForEach(JSC::ExecState& state, JSWrapper& thisObject, JSC::ThrowScope& scope)
     181{
    194182    JSC::JSValue callback = state.argument(0);
    195183    JSC::JSValue thisValue = state.argument(1);
     
    198186    JSC::CallType callType = JSC::getCallData(callback, callData);
    199187    if (callType == JSC::CallType::None)
    200         return throwVMTypeError(&state, scope);
    201 
    202     auto iterator = wrapper->wrapped().createIterator();
     188        return throwTypeError(&state, scope, ASCIILiteral("Cannot call callback"));
     189
     190    auto iterator = thisObject.wrapped().createIterator();
    203191    while (auto value = iterator.next()) {
    204192        JSC::MarkedArgumentBuffer arguments;
    205         appendForEachArguments(state, wrapper->globalObject(), arguments, value);
    206         arguments.append(wrapper);
     193        appendForEachArguments(state, thisObject.globalObject(), arguments, value);
     194        arguments.append(&thisObject);
    207195        JSC::call(&state, callback, callType, callData, thisValue, arguments);
    208196        if (UNLIKELY(scope.exception()))
    209197            break;
    210198    }
    211     return JSC::JSValue::encode(JSC::jsUndefined());
     199    return JSC::jsUndefined();
    212200}
    213201
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r207319 r207324  
    39773977
    39783978    AddToImplIncludes("ObjectConstructor.h");
    3979     push(@implContent, "EncodedJSValue JSC_HOST_CALL ${serializerNativeFunctionName}(ExecState* state)\n");
     3979    push(@implContent, "static inline EncodedJSValue ${serializerNativeFunctionName}Caller(ExecState* state, JS$interfaceName* thisObject, JSC::ThrowScope& throwScope)\n");
    39803980    push(@implContent, "{\n");
    3981     push(@implContent, "    ASSERT(state);\n");
    3982     push(@implContent, "    auto thisValue = state->thisValue();\n");
    3983     push(@implContent, "    auto castedThis = jsDynamicCast<JS$interfaceName*>(thisValue);\n");
    3984     push(@implContent, "    VM& vm = state->vm();\n");
    3985     push(@implContent, "    auto throwScope = DECLARE_THROW_SCOPE(vm);\n");
    3986     push(@implContent, "    if (UNLIKELY(!castedThis))\n");
    3987     push(@implContent, "        return throwThisTypeError(*state, throwScope, \"$interfaceName\", \"$serializerFunctionName\");\n");
    3988     push(@implContent, "    ASSERT_GC_OBJECT_INHERITS(castedThis, ${className}::info());\n\n") unless $interfaceName eq "EventTarget";
     3981    push(@implContent, "    auto& vm = state->vm();\n");
    39893982    push(@implContent, "    auto* result = constructEmptyObject(state);\n");
     3983    push(@implContent, "\n");
    39903984    foreach my $attribute (@{$interface->attributes}) {
    39913985        my $name = $attribute->signature->name;
    39923986        if (grep $_ eq $name, @{$interface->serializable->attributes}) {
    39933987            my $getFunctionName = GetAttributeGetterName($interface, $className, $attribute);
    3994             push(@implContent, "    auto ${name}Value = ${getFunctionName}(state, JSValue::encode(thisValue), Identifier());\n");
     3988            push(@implContent, "    auto ${name}Value = ${getFunctionName}Getter(*state, *thisObject, throwScope);\n");
    39953989            push(@implContent, "    ASSERT(!throwScope.exception());\n");
    3996             push(@implContent, "    result->putDirect(vm, Identifier::fromString(&vm, \"${name}\"), JSValue::decode(${name}Value));\n");
     3990            push(@implContent, "    result->putDirect(vm, Identifier::fromString(&vm, \"${name}\"), ${name}Value);\n");
     3991            push(@implContent, "\n");
    39973992        }
    39983993    }
    39993994    push(@implContent, "    return JSValue::encode(result);\n");
    4000     push(@implContent, "}\n\n");
     3995    push(@implContent, "}\n");
     3996    push(@implContent, "\n");
     3997    push(@implContent, "EncodedJSValue JSC_HOST_CALL ${serializerNativeFunctionName}(ExecState* state)\n");
     3998    push(@implContent, "{\n");
     3999    push(@implContent, "    return BindingCaller<JS$interfaceName>::callOperation<${serializerNativeFunctionName}Caller>(state, \"$serializerFunctionName\");\n");
     4000    push(@implContent, "}\n");
     4001    push(@implContent, "\n");
    40014002}
    40024003
     
    48024803        my $functionName = GetFunctionName($interface, $className, $function);
    48034804
    4804         if (not $propertyName eq "forEach") {
     4805        if ($propertyName eq "forEach") {
     4806            push(@implContent,  <<END);
     4807static inline EncodedJSValue ${functionName}Caller(ExecState* state, JS$interfaceName* thisObject, JSC::ThrowScope& throwScope)
     4808{
     4809    return JSValue::encode(iteratorForEach<${className}>(*state, *thisObject, throwScope));
     4810}
     4811
     4812END
     4813        } else {
    48054814            my $iterationKind = "KeyValue";
    48064815            $iterationKind = "Key" if $propertyName eq "keys";
    48074816            $iterationKind = "Value" if $propertyName eq "values";
    48084817            $iterationKind = "Value" if $propertyName eq "[Symbol.Iterator]" and not $interface->iterable->isKeyValue;
     4818
    48094819            push(@implContent,  <<END);
     4820static inline EncodedJSValue ${functionName}Caller(ExecState*, JS$interfaceName* thisObject, JSC::ThrowScope&)
     4821{
     4822    return JSValue::encode(iteratorCreate<${className}>(*thisObject, IterationKind::${iterationKind}));
     4823}
     4824
     4825END
     4826        }
     4827
     4828        push(@implContent,  <<END);
    48104829JSC::EncodedJSValue JSC_HOST_CALL ${functionName}(JSC::ExecState* state)
    48114830{
    4812     return iteratorCreate<${className}>(*state, IterationKind::${iterationKind}, "${propertyName}");
     4831    return BindingCaller<$className>::callOperation<${functionName}Caller>(state, "${propertyName}");
    48134832}
    48144833
    48154834END
    4816         } else {
    4817             push(@implContent,  <<END);
    4818 JSC::EncodedJSValue JSC_HOST_CALL ${functionName}(JSC::ExecState* state)
    4819 {
    4820     return iteratorForEach<${className}>(*state, "${propertyName}");
    4821 }
    4822 
    4823 END
    4824         }
    48254835    }
    48264836}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestIterable.cpp

    r207192 r207324  
    173173const JSC::ClassInfo TestIterableIteratorPrototype::s_info = { "TestIterable Iterator", &Base::s_info, 0, CREATE_METHOD_TABLE(TestIterableIteratorPrototype) };
    174174
     175static inline EncodedJSValue jsTestIterablePrototypeFunctionSymbolIteratorCaller(ExecState*, JSTestIterable* thisObject, JSC::ThrowScope&)
     176{
     177    return JSValue::encode(iteratorCreate<JSTestIterable>(*thisObject, IterationKind::Value));
     178}
     179
    175180JSC::EncodedJSValue JSC_HOST_CALL jsTestIterablePrototypeFunctionSymbolIterator(JSC::ExecState* state)
    176181{
    177     return iteratorCreate<JSTestIterable>(*state, IterationKind::Value, "[Symbol.Iterator]");
     182    return BindingCaller<JSTestIterable>::callOperation<jsTestIterablePrototypeFunctionSymbolIteratorCaller>(state, "[Symbol.Iterator]");
     183}
     184
     185static inline EncodedJSValue jsTestIterablePrototypeFunctionEntriesCaller(ExecState*, JSTestIterable* thisObject, JSC::ThrowScope&)
     186{
     187    return JSValue::encode(iteratorCreate<JSTestIterable>(*thisObject, IterationKind::KeyValue));
    178188}
    179189
    180190JSC::EncodedJSValue JSC_HOST_CALL jsTestIterablePrototypeFunctionEntries(JSC::ExecState* state)
    181191{
    182     return iteratorCreate<JSTestIterable>(*state, IterationKind::KeyValue, "entries");
     192    return BindingCaller<JSTestIterable>::callOperation<jsTestIterablePrototypeFunctionEntriesCaller>(state, "entries");
     193}
     194
     195static inline EncodedJSValue jsTestIterablePrototypeFunctionKeysCaller(ExecState*, JSTestIterable* thisObject, JSC::ThrowScope&)
     196{
     197    return JSValue::encode(iteratorCreate<JSTestIterable>(*thisObject, IterationKind::Key));
    183198}
    184199
    185200JSC::EncodedJSValue JSC_HOST_CALL jsTestIterablePrototypeFunctionKeys(JSC::ExecState* state)
    186201{
    187     return iteratorCreate<JSTestIterable>(*state, IterationKind::Key, "keys");
     202    return BindingCaller<JSTestIterable>::callOperation<jsTestIterablePrototypeFunctionKeysCaller>(state, "keys");
     203}
     204
     205static inline EncodedJSValue jsTestIterablePrototypeFunctionValuesCaller(ExecState*, JSTestIterable* thisObject, JSC::ThrowScope&)
     206{
     207    return JSValue::encode(iteratorCreate<JSTestIterable>(*thisObject, IterationKind::Value));
    188208}
    189209
    190210JSC::EncodedJSValue JSC_HOST_CALL jsTestIterablePrototypeFunctionValues(JSC::ExecState* state)
    191211{
    192     return iteratorCreate<JSTestIterable>(*state, IterationKind::Value, "values");
     212    return BindingCaller<JSTestIterable>::callOperation<jsTestIterablePrototypeFunctionValuesCaller>(state, "values");
     213}
     214
     215static inline EncodedJSValue jsTestIterablePrototypeFunctionForEachCaller(ExecState* state, JSTestIterable* thisObject, JSC::ThrowScope& throwScope)
     216{
     217    return JSValue::encode(iteratorForEach<JSTestIterable>(*state, *thisObject, throwScope));
    193218}
    194219
    195220JSC::EncodedJSValue JSC_HOST_CALL jsTestIterablePrototypeFunctionForEach(JSC::ExecState* state)
    196221{
    197     return iteratorForEach<JSTestIterable>(*state, "forEach");
     222    return BindingCaller<JSTestIterable>::callOperation<jsTestIterablePrototypeFunctionForEachCaller>(state, "forEach");
    198223}
    199224
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp

    r207193 r207324  
    275275const JSC::ClassInfo TestNodeIteratorPrototype::s_info = { "TestNode Iterator", &Base::s_info, 0, CREATE_METHOD_TABLE(TestNodeIteratorPrototype) };
    276276
     277static inline EncodedJSValue jsTestNodePrototypeFunctionSymbolIteratorCaller(ExecState*, JSTestNode* thisObject, JSC::ThrowScope&)
     278{
     279    return JSValue::encode(iteratorCreate<JSTestNode>(*thisObject, IterationKind::Value));
     280}
     281
    277282JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionSymbolIterator(JSC::ExecState* state)
    278283{
    279     return iteratorCreate<JSTestNode>(*state, IterationKind::Value, "[Symbol.Iterator]");
     284    return BindingCaller<JSTestNode>::callOperation<jsTestNodePrototypeFunctionSymbolIteratorCaller>(state, "[Symbol.Iterator]");
     285}
     286
     287static inline EncodedJSValue jsTestNodePrototypeFunctionEntriesCaller(ExecState*, JSTestNode* thisObject, JSC::ThrowScope&)
     288{
     289    return JSValue::encode(iteratorCreate<JSTestNode>(*thisObject, IterationKind::KeyValue));
    280290}
    281291
    282292JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionEntries(JSC::ExecState* state)
    283293{
    284     return iteratorCreate<JSTestNode>(*state, IterationKind::KeyValue, "entries");
     294    return BindingCaller<JSTestNode>::callOperation<jsTestNodePrototypeFunctionEntriesCaller>(state, "entries");
     295}
     296
     297static inline EncodedJSValue jsTestNodePrototypeFunctionKeysCaller(ExecState*, JSTestNode* thisObject, JSC::ThrowScope&)
     298{
     299    return JSValue::encode(iteratorCreate<JSTestNode>(*thisObject, IterationKind::Key));
    285300}
    286301
    287302JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionKeys(JSC::ExecState* state)
    288303{
    289     return iteratorCreate<JSTestNode>(*state, IterationKind::Key, "keys");
     304    return BindingCaller<JSTestNode>::callOperation<jsTestNodePrototypeFunctionKeysCaller>(state, "keys");
     305}
     306
     307static inline EncodedJSValue jsTestNodePrototypeFunctionValuesCaller(ExecState*, JSTestNode* thisObject, JSC::ThrowScope&)
     308{
     309    return JSValue::encode(iteratorCreate<JSTestNode>(*thisObject, IterationKind::Value));
    290310}
    291311
    292312JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionValues(JSC::ExecState* state)
    293313{
    294     return iteratorCreate<JSTestNode>(*state, IterationKind::Value, "values");
     314    return BindingCaller<JSTestNode>::callOperation<jsTestNodePrototypeFunctionValuesCaller>(state, "values");
     315}
     316
     317static inline EncodedJSValue jsTestNodePrototypeFunctionForEachCaller(ExecState* state, JSTestNode* thisObject, JSC::ThrowScope& throwScope)
     318{
     319    return JSValue::encode(iteratorForEach<JSTestNode>(*state, *thisObject, throwScope));
    295320}
    296321
    297322JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionForEach(JSC::ExecState* state)
    298323{
    299     return iteratorForEach<JSTestNode>(*state, "forEach");
     324    return BindingCaller<JSTestNode>::callOperation<jsTestNodePrototypeFunctionForEachCaller>(state, "forEach");
     325}
     326
     327static inline EncodedJSValue jsTestNodePrototypeFunctionToJSONCaller(ExecState* state, JSTestNode* thisObject, JSC::ThrowScope& throwScope)
     328{
     329    auto& vm = state->vm();
     330    auto* result = constructEmptyObject(state);
     331
     332    auto nameValue = jsTestNodeNameGetter(*state, *thisObject, throwScope);
     333    ASSERT(!throwScope.exception());
     334    result->putDirect(vm, Identifier::fromString(&vm, "name"), nameValue);
     335
     336    return JSValue::encode(result);
    300337}
    301338
    302339EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionToJSON(ExecState* state)
    303340{
    304     ASSERT(state);
    305     auto thisValue = state->thisValue();
    306     auto castedThis = jsDynamicCast<JSTestNode*>(thisValue);
    307     VM& vm = state->vm();
    308     auto throwScope = DECLARE_THROW_SCOPE(vm);
    309     if (UNLIKELY(!castedThis))
    310         return throwThisTypeError(*state, throwScope, "TestNode", "toJSON");
    311     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestNode::info());
    312 
    313     auto* result = constructEmptyObject(state);
    314     auto nameValue = jsTestNodeName(state, JSValue::encode(thisValue), Identifier());
    315     ASSERT(!throwScope.exception());
    316     result->putDirect(vm, Identifier::fromString(&vm, "name"), JSValue::decode(nameValue));
    317     return JSValue::encode(result);
     341    return BindingCaller<JSTestNode>::callOperation<jsTestNodePrototypeFunctionToJSONCaller>(state, "toJSON");
    318342}
    319343
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r207243 r207324  
    77367736}
    77377737
     7738static inline EncodedJSValue jsTestObjPrototypeFunctionToJSONCaller(ExecState* state, JSTestObj* thisObject, JSC::ThrowScope& throwScope)
     7739{
     7740    auto& vm = state->vm();
     7741    auto* result = constructEmptyObject(state);
     7742
     7743    auto readOnlyStringAttrValue = jsTestObjReadOnlyStringAttrGetter(*state, *thisObject, throwScope);
     7744    ASSERT(!throwScope.exception());
     7745    result->putDirect(vm, Identifier::fromString(&vm, "readOnlyStringAttr"), readOnlyStringAttrValue);
     7746
     7747    auto enumAttrValue = jsTestObjEnumAttrGetter(*state, *thisObject, throwScope);
     7748    ASSERT(!throwScope.exception());
     7749    result->putDirect(vm, Identifier::fromString(&vm, "enumAttr"), enumAttrValue);
     7750
     7751    auto longAttrValue = jsTestObjLongAttrGetter(*state, *thisObject, throwScope);
     7752    ASSERT(!throwScope.exception());
     7753    result->putDirect(vm, Identifier::fromString(&vm, "longAttr"), longAttrValue);
     7754
     7755    auto createValue = jsTestObjCreateGetter(*state, *thisObject, throwScope);
     7756    ASSERT(!throwScope.exception());
     7757    result->putDirect(vm, Identifier::fromString(&vm, "create"), createValue);
     7758
     7759    return JSValue::encode(result);
     7760}
     7761
    77387762EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionToJSON(ExecState* state)
    77397763{
    7740     ASSERT(state);
    7741     auto thisValue = state->thisValue();
    7742     auto castedThis = jsDynamicCast<JSTestObj*>(thisValue);
    7743     VM& vm = state->vm();
    7744     auto throwScope = DECLARE_THROW_SCOPE(vm);
    7745     if (UNLIKELY(!castedThis))
    7746         return throwThisTypeError(*state, throwScope, "TestObj", "toJSON");
    7747     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
    7748 
    7749     auto* result = constructEmptyObject(state);
    7750     auto readOnlyStringAttrValue = jsTestObjReadOnlyStringAttr(state, JSValue::encode(thisValue), Identifier());
    7751     ASSERT(!throwScope.exception());
    7752     result->putDirect(vm, Identifier::fromString(&vm, "readOnlyStringAttr"), JSValue::decode(readOnlyStringAttrValue));
    7753     auto enumAttrValue = jsTestObjEnumAttr(state, JSValue::encode(thisValue), Identifier());
    7754     ASSERT(!throwScope.exception());
    7755     result->putDirect(vm, Identifier::fromString(&vm, "enumAttr"), JSValue::decode(enumAttrValue));
    7756     auto longAttrValue = jsTestObjLongAttr(state, JSValue::encode(thisValue), Identifier());
    7757     ASSERT(!throwScope.exception());
    7758     result->putDirect(vm, Identifier::fromString(&vm, "longAttr"), JSValue::decode(longAttrValue));
    7759     auto createValue = jsTestObjCreate(state, JSValue::encode(thisValue), Identifier());
    7760     ASSERT(!throwScope.exception());
    7761     result->putDirect(vm, Identifier::fromString(&vm, "create"), JSValue::decode(createValue));
    7762     return JSValue::encode(result);
     7764    return BindingCaller<JSTestObj>::callOperation<jsTestObjPrototypeFunctionToJSONCaller>(state, "toJSON");
    77637765}
    77647766
Note: See TracChangeset for help on using the changeset viewer.