Title: [207324] trunk/Source/WebCore
Revision
207324
Author
commit-qu...@webkit.org
Date
2016-10-13 23:19:12 -0700 (Thu, 13 Oct 2016)

Log Message

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

Patch by Youenn Fablet <you...@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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (207323 => 207324)


--- trunk/Source/WebCore/ChangeLog	2016-10-14 05:39:07 UTC (rev 207323)
+++ trunk/Source/WebCore/ChangeLog	2016-10-14 06:19:12 UTC (rev 207324)
@@ -1,3 +1,48 @@
+2016-10-13  Youenn Fablet  <you...@apple.com>
+
+        Update serializer and iterator binding generated code
+        https://bugs.webkit.org/show_bug.cgi?id=163325
+
+        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):
+
 2016-10-13  Alex Christensen  <achristen...@webkit.org>
 
         Fix API test after r207318.

Modified: trunk/Source/WebCore/bindings/js/JSDOMIterator.h (207323 => 207324)


--- trunk/Source/WebCore/bindings/js/JSDOMIterator.h	2016-10-14 05:39:07 UTC (rev 207323)
+++ trunk/Source/WebCore/bindings/js/JSDOMIterator.h	2016-10-14 06:19:12 UTC (rev 207324)
@@ -124,21 +124,16 @@
 };
 
 template<typename JSWrapper>
-JSC::EncodedJSValue iteratorCreate(JSC::ExecState&, IterationKind, const char*);
+JSC::JSValue iteratorCreate(JSWrapper&, IterationKind);
 template<typename JSWrapper>
-JSC::EncodedJSValue iteratorForEach(JSC::ExecState&, const char*);
+JSC::JSValue iteratorForEach(JSC::ExecState&, JSWrapper&, JSC::ThrowScope&);
 
 template<typename JSWrapper>
-JSC::EncodedJSValue iteratorCreate(JSC::ExecState& state, IterationKind kind, const char* propertyName)
+JSC::JSValue iteratorCreate(JSWrapper& thisObject, IterationKind kind)
 {
-    JSC::VM& vm = state.vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    auto wrapper = JSC::jsDynamicCast<JSWrapper*>(state.thisValue());
-    if (UNLIKELY(!wrapper))
-        return throwThisTypeError(state, scope, JSWrapper::info()->className, propertyName);
-    JSDOMGlobalObject& globalObject = *wrapper->globalObject();
-    return JSC::JSValue::encode(JSDOMIterator<JSWrapper>::create(globalObject.vm(), getDOMStructure<JSDOMIterator<JSWrapper>>(globalObject.vm(), globalObject), *wrapper, kind));
+    ASSERT(thisObject.globalObject());
+    JSDOMGlobalObject& globalObject = *thisObject.globalObject();
+    return JSDOMIterator<JSWrapper>::create(globalObject.vm(), getDOMStructure<JSDOMIterator<JSWrapper>>(globalObject.vm(), globalObject), thisObject, kind);
 }
 
 template<typename JSWrapper>
@@ -182,15 +177,8 @@
 }
 
 template<typename JSWrapper>
-JSC::EncodedJSValue iteratorForEach(JSC::ExecState& state, const char* propertyName)
+JSC::JSValue iteratorForEach(JSC::ExecState& state, JSWrapper& thisObject, JSC::ThrowScope& scope)
 {
-    JSC::VM& vm = state.vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    auto wrapper = JSC::jsDynamicCast<JSWrapper*>(state.thisValue());
-    if (UNLIKELY(!wrapper))
-        return throwThisTypeError(state, scope, JSWrapper::info()->className, propertyName);
-
     JSC::JSValue callback = state.argument(0);
     JSC::JSValue thisValue = state.argument(1);
 
@@ -197,18 +185,18 @@
     JSC::CallData callData;
     JSC::CallType callType = JSC::getCallData(callback, callData);
     if (callType == JSC::CallType::None)
-        return throwVMTypeError(&state, scope);
+        return throwTypeError(&state, scope, ASCIILiteral("Cannot call callback"));
 
-    auto iterator = wrapper->wrapped().createIterator();
+    auto iterator = thisObject.wrapped().createIterator();
     while (auto value = iterator.next()) {
         JSC::MarkedArgumentBuffer arguments;
-        appendForEachArguments(state, wrapper->globalObject(), arguments, value);
-        arguments.append(wrapper);
+        appendForEachArguments(state, thisObject.globalObject(), arguments, value);
+        arguments.append(&thisObject);
         JSC::call(&state, callback, callType, callData, thisValue, arguments);
         if (UNLIKELY(scope.exception()))
             break;
     }
-    return JSC::JSValue::encode(JSC::jsUndefined());
+    return JSC::jsUndefined();
 }
 
 template<typename JSWrapper>

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (207323 => 207324)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-10-14 05:39:07 UTC (rev 207323)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-10-14 06:19:12 UTC (rev 207324)
@@ -3976,28 +3976,29 @@
     my $serializerNativeFunctionName = $codeGenerator->WK_lcfirst($className) . "PrototypeFunction" . $codeGenerator->WK_ucfirst($serializerFunctionName);
 
     AddToImplIncludes("ObjectConstructor.h");
-    push(@implContent, "EncodedJSValue JSC_HOST_CALL ${serializerNativeFunctionName}(ExecState* state)\n");
+    push(@implContent, "static inline EncodedJSValue ${serializerNativeFunctionName}Caller(ExecState* state, JS$interfaceName* thisObject, JSC::ThrowScope& throwScope)\n");
     push(@implContent, "{\n");
-    push(@implContent, "    ASSERT(state);\n");
-    push(@implContent, "    auto thisValue = state->thisValue();\n");
-    push(@implContent, "    auto castedThis = jsDynamicCast<JS$interfaceName*>(thisValue);\n");
-    push(@implContent, "    VM& vm = state->vm();\n");
-    push(@implContent, "    auto throwScope = DECLARE_THROW_SCOPE(vm);\n");
-    push(@implContent, "    if (UNLIKELY(!castedThis))\n");
-    push(@implContent, "        return throwThisTypeError(*state, throwScope, \"$interfaceName\", \"$serializerFunctionName\");\n");
-    push(@implContent, "    ASSERT_GC_OBJECT_INHERITS(castedThis, ${className}::info());\n\n") unless $interfaceName eq "EventTarget";
+    push(@implContent, "    auto& vm = state->vm();\n");
     push(@implContent, "    auto* result = constructEmptyObject(state);\n");
+    push(@implContent, "\n");
     foreach my $attribute (@{$interface->attributes}) {
         my $name = $attribute->signature->name;
         if (grep $_ eq $name, @{$interface->serializable->attributes}) {
             my $getFunctionName = GetAttributeGetterName($interface, $className, $attribute);
-            push(@implContent, "    auto ${name}Value = ${getFunctionName}(state, JSValue::encode(thisValue), Identifier());\n");
+            push(@implContent, "    auto ${name}Value = ${getFunctionName}Getter(*state, *thisObject, throwScope);\n");
             push(@implContent, "    ASSERT(!throwScope.exception());\n");
-            push(@implContent, "    result->putDirect(vm, Identifier::fromString(&vm, \"${name}\"), JSValue::decode(${name}Value));\n");
+            push(@implContent, "    result->putDirect(vm, Identifier::fromString(&vm, \"${name}\"), ${name}Value);\n");
+            push(@implContent, "\n");
         }
     }
     push(@implContent, "    return JSValue::encode(result);\n");
-    push(@implContent, "}\n\n");
+    push(@implContent, "}\n");
+    push(@implContent, "\n");
+    push(@implContent, "EncodedJSValue JSC_HOST_CALL ${serializerNativeFunctionName}(ExecState* state)\n");
+    push(@implContent, "{\n");
+    push(@implContent, "    return BindingCaller<JS$interfaceName>::callOperation<${serializerNativeFunctionName}Caller>(state, \"$serializerFunctionName\");\n");
+    push(@implContent, "}\n");
+    push(@implContent, "\n");
 }
 
 sub GenerateCallWithUsingReferences
@@ -4801,27 +4802,36 @@
         my $propertyName = $function->signature->name;
         my $functionName = GetFunctionName($interface, $className, $function);
 
-        if (not $propertyName eq "forEach") {
+        if ($propertyName eq "forEach") {
+            push(@implContent,  <<END);
+static inline EncodedJSValue ${functionName}Caller(ExecState* state, JS$interfaceName* thisObject, JSC::ThrowScope& throwScope)
+{
+    return JSValue::encode(iteratorForEach<${className}>(*state, *thisObject, throwScope));
+}
+
+END
+        } else {
             my $iterationKind = "KeyValue";
             $iterationKind = "Key" if $propertyName eq "keys";
             $iterationKind = "Value" if $propertyName eq "values";
             $iterationKind = "Value" if $propertyName eq "[Symbol.Iterator]" and not $interface->iterable->isKeyValue;
+
             push(@implContent,  <<END);
-JSC::EncodedJSValue JSC_HOST_CALL ${functionName}(JSC::ExecState* state)
+static inline EncodedJSValue ${functionName}Caller(ExecState*, JS$interfaceName* thisObject, JSC::ThrowScope&)
 {
-    return iteratorCreate<${className}>(*state, IterationKind::${iterationKind}, "${propertyName}");
+    return JSValue::encode(iteratorCreate<${className}>(*thisObject, IterationKind::${iterationKind}));
 }
 
 END
-        } else {
-            push(@implContent,  <<END);
+        }
+
+        push(@implContent,  <<END);
 JSC::EncodedJSValue JSC_HOST_CALL ${functionName}(JSC::ExecState* state)
 {
-    return iteratorForEach<${className}>(*state, "${propertyName}");
+    return BindingCaller<$className>::callOperation<${functionName}Caller>(state, "${propertyName}");
 }
 
 END
-        }
     }
 }
 

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestIterable.cpp (207323 => 207324)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestIterable.cpp	2016-10-14 05:39:07 UTC (rev 207323)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestIterable.cpp	2016-10-14 06:19:12 UTC (rev 207324)
@@ -172,29 +172,54 @@
 template<>
 const JSC::ClassInfo TestIterableIteratorPrototype::s_info = { "TestIterable Iterator", &Base::s_info, 0, CREATE_METHOD_TABLE(TestIterableIteratorPrototype) };
 
+static inline EncodedJSValue jsTestIterablePrototypeFunctionSymbolIteratorCaller(ExecState*, JSTestIterable* thisObject, JSC::ThrowScope&)
+{
+    return JSValue::encode(iteratorCreate<JSTestIterable>(*thisObject, IterationKind::Value));
+}
+
 JSC::EncodedJSValue JSC_HOST_CALL jsTestIterablePrototypeFunctionSymbolIterator(JSC::ExecState* state)
 {
-    return iteratorCreate<JSTestIterable>(*state, IterationKind::Value, "[Symbol.Iterator]");
+    return BindingCaller<JSTestIterable>::callOperation<jsTestIterablePrototypeFunctionSymbolIteratorCaller>(state, "[Symbol.Iterator]");
 }
 
+static inline EncodedJSValue jsTestIterablePrototypeFunctionEntriesCaller(ExecState*, JSTestIterable* thisObject, JSC::ThrowScope&)
+{
+    return JSValue::encode(iteratorCreate<JSTestIterable>(*thisObject, IterationKind::KeyValue));
+}
+
 JSC::EncodedJSValue JSC_HOST_CALL jsTestIterablePrototypeFunctionEntries(JSC::ExecState* state)
 {
-    return iteratorCreate<JSTestIterable>(*state, IterationKind::KeyValue, "entries");
+    return BindingCaller<JSTestIterable>::callOperation<jsTestIterablePrototypeFunctionEntriesCaller>(state, "entries");
 }
 
+static inline EncodedJSValue jsTestIterablePrototypeFunctionKeysCaller(ExecState*, JSTestIterable* thisObject, JSC::ThrowScope&)
+{
+    return JSValue::encode(iteratorCreate<JSTestIterable>(*thisObject, IterationKind::Key));
+}
+
 JSC::EncodedJSValue JSC_HOST_CALL jsTestIterablePrototypeFunctionKeys(JSC::ExecState* state)
 {
-    return iteratorCreate<JSTestIterable>(*state, IterationKind::Key, "keys");
+    return BindingCaller<JSTestIterable>::callOperation<jsTestIterablePrototypeFunctionKeysCaller>(state, "keys");
 }
 
+static inline EncodedJSValue jsTestIterablePrototypeFunctionValuesCaller(ExecState*, JSTestIterable* thisObject, JSC::ThrowScope&)
+{
+    return JSValue::encode(iteratorCreate<JSTestIterable>(*thisObject, IterationKind::Value));
+}
+
 JSC::EncodedJSValue JSC_HOST_CALL jsTestIterablePrototypeFunctionValues(JSC::ExecState* state)
 {
-    return iteratorCreate<JSTestIterable>(*state, IterationKind::Value, "values");
+    return BindingCaller<JSTestIterable>::callOperation<jsTestIterablePrototypeFunctionValuesCaller>(state, "values");
 }
 
+static inline EncodedJSValue jsTestIterablePrototypeFunctionForEachCaller(ExecState* state, JSTestIterable* thisObject, JSC::ThrowScope& throwScope)
+{
+    return JSValue::encode(iteratorForEach<JSTestIterable>(*state, *thisObject, throwScope));
+}
+
 JSC::EncodedJSValue JSC_HOST_CALL jsTestIterablePrototypeFunctionForEach(JSC::ExecState* state)
 {
-    return iteratorForEach<JSTestIterable>(*state, "forEach");
+    return BindingCaller<JSTestIterable>::callOperation<jsTestIterablePrototypeFunctionForEachCaller>(state, "forEach");
 }
 
 bool JSTestIterableOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp (207323 => 207324)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp	2016-10-14 05:39:07 UTC (rev 207323)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp	2016-10-14 06:19:12 UTC (rev 207324)
@@ -274,49 +274,73 @@
 template<>
 const JSC::ClassInfo TestNodeIteratorPrototype::s_info = { "TestNode Iterator", &Base::s_info, 0, CREATE_METHOD_TABLE(TestNodeIteratorPrototype) };
 
+static inline EncodedJSValue jsTestNodePrototypeFunctionSymbolIteratorCaller(ExecState*, JSTestNode* thisObject, JSC::ThrowScope&)
+{
+    return JSValue::encode(iteratorCreate<JSTestNode>(*thisObject, IterationKind::Value));
+}
+
 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionSymbolIterator(JSC::ExecState* state)
 {
-    return iteratorCreate<JSTestNode>(*state, IterationKind::Value, "[Symbol.Iterator]");
+    return BindingCaller<JSTestNode>::callOperation<jsTestNodePrototypeFunctionSymbolIteratorCaller>(state, "[Symbol.Iterator]");
 }
 
+static inline EncodedJSValue jsTestNodePrototypeFunctionEntriesCaller(ExecState*, JSTestNode* thisObject, JSC::ThrowScope&)
+{
+    return JSValue::encode(iteratorCreate<JSTestNode>(*thisObject, IterationKind::KeyValue));
+}
+
 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionEntries(JSC::ExecState* state)
 {
-    return iteratorCreate<JSTestNode>(*state, IterationKind::KeyValue, "entries");
+    return BindingCaller<JSTestNode>::callOperation<jsTestNodePrototypeFunctionEntriesCaller>(state, "entries");
 }
 
+static inline EncodedJSValue jsTestNodePrototypeFunctionKeysCaller(ExecState*, JSTestNode* thisObject, JSC::ThrowScope&)
+{
+    return JSValue::encode(iteratorCreate<JSTestNode>(*thisObject, IterationKind::Key));
+}
+
 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionKeys(JSC::ExecState* state)
 {
-    return iteratorCreate<JSTestNode>(*state, IterationKind::Key, "keys");
+    return BindingCaller<JSTestNode>::callOperation<jsTestNodePrototypeFunctionKeysCaller>(state, "keys");
 }
 
+static inline EncodedJSValue jsTestNodePrototypeFunctionValuesCaller(ExecState*, JSTestNode* thisObject, JSC::ThrowScope&)
+{
+    return JSValue::encode(iteratorCreate<JSTestNode>(*thisObject, IterationKind::Value));
+}
+
 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionValues(JSC::ExecState* state)
 {
-    return iteratorCreate<JSTestNode>(*state, IterationKind::Value, "values");
+    return BindingCaller<JSTestNode>::callOperation<jsTestNodePrototypeFunctionValuesCaller>(state, "values");
 }
 
+static inline EncodedJSValue jsTestNodePrototypeFunctionForEachCaller(ExecState* state, JSTestNode* thisObject, JSC::ThrowScope& throwScope)
+{
+    return JSValue::encode(iteratorForEach<JSTestNode>(*state, *thisObject, throwScope));
+}
+
 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionForEach(JSC::ExecState* state)
 {
-    return iteratorForEach<JSTestNode>(*state, "forEach");
+    return BindingCaller<JSTestNode>::callOperation<jsTestNodePrototypeFunctionForEachCaller>(state, "forEach");
 }
 
-EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionToJSON(ExecState* state)
+static inline EncodedJSValue jsTestNodePrototypeFunctionToJSONCaller(ExecState* state, JSTestNode* thisObject, JSC::ThrowScope& throwScope)
 {
-    ASSERT(state);
-    auto thisValue = state->thisValue();
-    auto castedThis = jsDynamicCast<JSTestNode*>(thisValue);
-    VM& vm = state->vm();
-    auto throwScope = DECLARE_THROW_SCOPE(vm);
-    if (UNLIKELY(!castedThis))
-        return throwThisTypeError(*state, throwScope, "TestNode", "toJSON");
-    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestNode::info());
+    auto& vm = state->vm();
+    auto* result = constructEmptyObject(state);
 
-    auto* result = constructEmptyObject(state);
-    auto nameValue = jsTestNodeName(state, JSValue::encode(thisValue), Identifier());
+    auto nameValue = jsTestNodeNameGetter(*state, *thisObject, throwScope);
     ASSERT(!throwScope.exception());
-    result->putDirect(vm, Identifier::fromString(&vm, "name"), JSValue::decode(nameValue));
+    result->putDirect(vm, Identifier::fromString(&vm, "name"), nameValue);
+
     return JSValue::encode(result);
 }
 
+EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionToJSON(ExecState* state)
+{
+    return BindingCaller<JSTestNode>::callOperation<jsTestNodePrototypeFunctionToJSONCaller>(state, "toJSON");
+}
+
 void JSTestNode::visitChildren(JSCell* cell, SlotVisitor& visitor)
 {
     auto* thisObject = jsCast<JSTestNode*>(cell);

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


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2016-10-14 05:39:07 UTC (rev 207323)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2016-10-14 06:19:12 UTC (rev 207324)
@@ -7735,33 +7735,35 @@
     return JSValue::encode(result);
 }
 
-EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionToJSON(ExecState* state)
+static inline EncodedJSValue jsTestObjPrototypeFunctionToJSONCaller(ExecState* state, JSTestObj* thisObject, JSC::ThrowScope& throwScope)
 {
-    ASSERT(state);
-    auto thisValue = state->thisValue();
-    auto castedThis = jsDynamicCast<JSTestObj*>(thisValue);
-    VM& vm = state->vm();
-    auto throwScope = DECLARE_THROW_SCOPE(vm);
-    if (UNLIKELY(!castedThis))
-        return throwThisTypeError(*state, throwScope, "TestObj", "toJSON");
-    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
+    auto& vm = state->vm();
+    auto* result = constructEmptyObject(state);
 
-    auto* result = constructEmptyObject(state);
-    auto readOnlyStringAttrValue = jsTestObjReadOnlyStringAttr(state, JSValue::encode(thisValue), Identifier());
+    auto readOnlyStringAttrValue = jsTestObjReadOnlyStringAttrGetter(*state, *thisObject, throwScope);
     ASSERT(!throwScope.exception());
-    result->putDirect(vm, Identifier::fromString(&vm, "readOnlyStringAttr"), JSValue::decode(readOnlyStringAttrValue));
-    auto enumAttrValue = jsTestObjEnumAttr(state, JSValue::encode(thisValue), Identifier());
+    result->putDirect(vm, Identifier::fromString(&vm, "readOnlyStringAttr"), readOnlyStringAttrValue);
+
+    auto enumAttrValue = jsTestObjEnumAttrGetter(*state, *thisObject, throwScope);
     ASSERT(!throwScope.exception());
-    result->putDirect(vm, Identifier::fromString(&vm, "enumAttr"), JSValue::decode(enumAttrValue));
-    auto longAttrValue = jsTestObjLongAttr(state, JSValue::encode(thisValue), Identifier());
+    result->putDirect(vm, Identifier::fromString(&vm, "enumAttr"), enumAttrValue);
+
+    auto longAttrValue = jsTestObjLongAttrGetter(*state, *thisObject, throwScope);
     ASSERT(!throwScope.exception());
-    result->putDirect(vm, Identifier::fromString(&vm, "longAttr"), JSValue::decode(longAttrValue));
-    auto createValue = jsTestObjCreate(state, JSValue::encode(thisValue), Identifier());
+    result->putDirect(vm, Identifier::fromString(&vm, "longAttr"), longAttrValue);
+
+    auto createValue = jsTestObjCreateGetter(*state, *thisObject, throwScope);
     ASSERT(!throwScope.exception());
-    result->putDirect(vm, Identifier::fromString(&vm, "create"), JSValue::decode(createValue));
+    result->putDirect(vm, Identifier::fromString(&vm, "create"), createValue);
+
     return JSValue::encode(result);
 }
 
+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionToJSON(ExecState* state)
+{
+    return BindingCaller<JSTestObj>::callOperation<jsTestObjPrototypeFunctionToJSONCaller>(state, "toJSON");
+}
+
 void JSTestObj::visitChildren(JSCell* cell, SlotVisitor& visitor)
 {
     auto* thisObject = jsCast<JSTestObj*>(cell);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to