Title: [218511] trunk
Revision
218511
Author
commit-qu...@webkit.org
Date
2017-06-19 14:55:00 -0700 (Mon, 19 Jun 2017)

Log Message

[WebIDL] Add support for serializers that have members that are themselves serializers (or inherit being a serializer from a parent)
https://bugs.webkit.org/show_bug.cgi?id=173395

Patch by Sam Weinig <s...@webkit.org> on 2017-06-19
Reviewed by Simon Fraser.

Source/WebCore:

Test: fast/css/DOMQuad-serialization.html

* bindings/scripts/CodeGenerator.pm:
(InheritsSerializable):
Helper to determine if an interface inherits from any interfaces
that are serializable. This is necessary because an attribute is
serializable even if its interface is not marked as serializable.

(IsSerializableAttribute):
Check ancestor interfaces as well to determine serializability.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateSerializerDefinition):
Specialize attributes that are serializable interfaces to call its interfaces
serialize function, thus allowing nested objects to be serialized.

* dom/DOMQuad.idl:
Add serializer.

* bindings/scripts/test/JS/JSTestSerialization.cpp:
* bindings/scripts/test/JS/JSTestSerializationIndirectInheritance.cpp: Added.
* bindings/scripts/test/JS/JSTestSerializationIndirectInheritance.h: Added.
* bindings/scripts/test/TestSerialization.idl:
* bindings/scripts/test/TestSerializationIndirectInheritance.idl: Added.
Add and update tests.

LayoutTests:

* fast/css/DOMQuad-serialization-expected.txt: Added.
* fast/css/DOMQuad-serialization.html: Added.
Add test for DOMQuad serialization, now that it is supported.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (218510 => 218511)


--- trunk/LayoutTests/ChangeLog	2017-06-19 21:27:05 UTC (rev 218510)
+++ trunk/LayoutTests/ChangeLog	2017-06-19 21:55:00 UTC (rev 218511)
@@ -1,3 +1,14 @@
+2017-06-19  Sam Weinig  <s...@webkit.org>
+
+        [WebIDL] Add support for serializers that have members that are themselves serializers (or inherit being a serializer from a parent)
+        https://bugs.webkit.org/show_bug.cgi?id=173395
+
+        Reviewed by Simon Fraser.
+
+        * fast/css/DOMQuad-serialization-expected.txt: Added.
+        * fast/css/DOMQuad-serialization.html: Added.
+        Add test for DOMQuad serialization, now that it is supported.
+
 2017-06-19  Commit Queue  <commit-qu...@webkit.org>
 
         Unreviewed, rolling out r218505.

Added: trunk/LayoutTests/fast/css/DOMQuad-serialization-expected.txt (0 => 218511)


--- trunk/LayoutTests/fast/css/DOMQuad-serialization-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css/DOMQuad-serialization-expected.txt	2017-06-19 21:55:00 UTC (rev 218511)
@@ -0,0 +1,5 @@
+
+PASS DOMQuad has a toJSON function 
+PASS The values of all the points in a DOMQuad are serialized to JSON. 
+PASS The values of all the points in a DOMQuad are preserved through a round-trip through JSON.stringify and JSON.parse 
+

Added: trunk/LayoutTests/fast/css/DOMQuad-serialization.html (0 => 218511)


--- trunk/LayoutTests/fast/css/DOMQuad-serialization.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/DOMQuad-serialization.html	2017-06-19 21:55:00 UTC (rev 218511)
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script src=""
+
+<script>
+
+test(() => {
+    var quad = new DOMQuad();
+    assert_equals(quad.__proto__, DOMQuad.prototype);
+
+    var toJSONDescriptor = Object.getOwnPropertyDescriptor(DOMQuad.prototype, "toJSON");
+    assert_exists(toJSONDescriptor, "value");
+    assert_true(toJSONDescriptor.enumerable);
+    assert_true(toJSONDescriptor.configurable);
+    assert_true(toJSONDescriptor.writable);
+}, "DOMQuad has a toJSON function");
+
+function check(jsonObject, quad)
+{
+    assert_equals(jsonObject.p1.x, quad.p1.x, "Expected value for p1.x is " + quad.p1.x);
+    assert_equals(jsonObject.p1.y, quad.p1.y, "Expected value for p1.y is " + quad.p1.y);
+    assert_equals(jsonObject.p1.z, quad.p1.z, "Expected value for p1.z is " + quad.p1.z);
+    assert_equals(jsonObject.p1.w, quad.p1.w, "Expected value for p1.w is " + quad.p1.w);
+    assert_equals(jsonObject.p2.x, quad.p2.x, "Expected value for p2.x is " + quad.p2.x);
+    assert_equals(jsonObject.p2.y, quad.p2.y, "Expected value for p2.y is " + quad.p2.y);
+    assert_equals(jsonObject.p2.z, quad.p2.z, "Expected value for p2.z is " + quad.p2.z);
+    assert_equals(jsonObject.p2.w, quad.p2.w, "Expected value for p2.w is " + quad.p2.w);
+    assert_equals(jsonObject.p3.x, quad.p3.x, "Expected value for p3.x is " + quad.p3.x);
+    assert_equals(jsonObject.p3.y, quad.p3.y, "Expected value for p3.y is " + quad.p3.y);
+    assert_equals(jsonObject.p3.z, quad.p3.z, "Expected value for p3.z is " + quad.p3.z);
+    assert_equals(jsonObject.p3.w, quad.p3.w, "Expected value for p3.w is " + quad.p3.w);
+    assert_equals(jsonObject.p4.x, quad.p4.x, "Expected value for p4.x is " + quad.p4.x);
+    assert_equals(jsonObject.p4.y, quad.p4.y, "Expected value for p4.y is " + quad.p4.y);
+    assert_equals(jsonObject.p4.z, quad.p4.z, "Expected value for p4.z is " + quad.p4.z);
+    assert_equals(jsonObject.p4.w, quad.p4.w, "Expected value for p4.w is " + quad.p4.w);
+}
+
+test(() => {
+    var quad = new DOMQuad();
+    jsonObject = quad.toJSON();
+    check(jsonObject, quad);
+}, "The values of all the points in a DOMQuad are serialized to JSON.");
+
+test(() => {
+    var quad = new DOMQuad();
+    parsedJSONObject = JSON.parse(JSON.stringify(quad))
+    check(parsedJSONObject, quad);
+}, "The values of all the points in a DOMQuad are preserved through a round-trip through JSON.stringify and JSON.parse");
+
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (218510 => 218511)


--- trunk/Source/WebCore/ChangeLog	2017-06-19 21:27:05 UTC (rev 218510)
+++ trunk/Source/WebCore/ChangeLog	2017-06-19 21:55:00 UTC (rev 218511)
@@ -1,3 +1,36 @@
+2017-06-19  Sam Weinig  <s...@webkit.org>
+
+        [WebIDL] Add support for serializers that have members that are themselves serializers (or inherit being a serializer from a parent)
+        https://bugs.webkit.org/show_bug.cgi?id=173395
+
+        Reviewed by Simon Fraser.
+
+        Test: fast/css/DOMQuad-serialization.html
+
+        * bindings/scripts/CodeGenerator.pm:
+        (InheritsSerializable):
+        Helper to determine if an interface inherits from any interfaces
+        that are serializable. This is necessary because an attribute is
+        serializable even if its interface is not marked as serializable. 
+
+        (IsSerializableAttribute):
+        Check ancestor interfaces as well to determine serializability.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateSerializerDefinition):
+        Specialize attributes that are serializable interfaces to call its interfaces
+        serialize function, thus allowing nested objects to be serialized.
+
+        * dom/DOMQuad.idl:
+        Add serializer.
+
+        * bindings/scripts/test/JS/JSTestSerialization.cpp:
+        * bindings/scripts/test/JS/JSTestSerializationIndirectInheritance.cpp: Added.
+        * bindings/scripts/test/JS/JSTestSerializationIndirectInheritance.h: Added.
+        * bindings/scripts/test/TestSerialization.idl:
+        * bindings/scripts/test/TestSerializationIndirectInheritance.idl: Added.
+        Add and update tests.
+
 2017-06-19  Commit Queue  <commit-qu...@webkit.org>
 
         Unreviewed, rolling out r218505.

Modified: trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm (218510 => 218511)


--- trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm	2017-06-19 21:27:05 UTC (rev 218510)
+++ trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm	2017-06-19 21:55:00 UTC (rev 218511)
@@ -903,9 +903,22 @@
     return 0;
 }
 
+sub InheritsSerializable
+{
+    my ($object, $interface) = @_;
+
+    my $anyParentIsSerializable = 0;
+    $object->ForAllParents($interface, sub {
+        my $parentInterface = shift;
+        $anyParentIsSerializable = 1 if $parentInterface->serializable;
+    }, 0);
+
+    return $anyParentIsSerializable;
+}
+
 sub IsSerializableAttribute
 {
-    my ($object, $currentInterface, $attribute) = @_;
+    my ($object, $interface, $attribute) = @_;
 
     # https://heycam.github.io/webidl/#dfn-serializable-type
 
@@ -920,9 +933,12 @@
         die "Serializer for non-primitive types is not currently supported\n";
     }
 
-    my $interface = GetInterfaceForAttribute($object, $currentInterface, $attribute);
-    if ($interface && $interface->serializable) {
-        die "Serializer for non-primitive types is not currently supported\n";
+    return 0 if !$object->IsInterfaceType($type);
+
+    my $interfaceForAttribute = $object->GetInterfaceForAttribute($interface, $attribute);
+    if ($interfaceForAttribute) {
+        return 1 if $interfaceForAttribute->serializable;
+        return $object->InheritsSerializable($interfaceForAttribute);
     }
 
     return 0;

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (218510 => 218511)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2017-06-19 21:27:05 UTC (rev 218510)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2017-06-19 21:55:00 UTC (rev 218511)
@@ -5192,11 +5192,21 @@
     push(@implContent, "\n");
 
     foreach my $attribute (@serializedAttributes) {
+        assert("Attributes that throw exceptions are not supported with serializers yet.") if $attribute->extendedAttributes->{GetterMayThrowException} || $attribute->extendedAttributes->{MayThrowException};
+
         my $name = $attribute->name;
         my $getFunctionName = GetAttributeGetterName($interface, $className, $attribute);
         push(@implContent, "    auto ${name}Value = ${getFunctionName}Getter(state, thisObject, throwScope);\n");
         push(@implContent, "    throwScope.assertNoException();\n");
-        push(@implContent, "    result->putDirect(vm, Identifier::fromString(&vm, \"${name}\"), ${name}Value);\n");
+
+        if ($codeGenerator->IsInterfaceType($attribute->type)) {
+            my $attributeInterfaceName = $attribute->type->name;
+            push(@implContent, "    auto* ${name}SerializedValue = JS${attributeInterfaceName}::serialize(state, *jsCast<JS${attributeInterfaceName}*>(${name}Value), globalObject, throwScope);\n");
+            push(@implContent, "    result->putDirect(vm, Identifier::fromString(&vm, \"${name}\"), ${name}SerializedValue);\n");
+        } else {
+            push(@implContent, "    result->putDirect(vm, Identifier::fromString(&vm, \"${name}\"), ${name}Value);\n");
+        }
+
         push(@implContent, "\n");
     }
 

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerialization.cpp (218510 => 218511)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerialization.cpp	2017-06-19 21:27:05 UTC (rev 218510)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerialization.cpp	2017-06-19 21:55:00 UTC (rev 218511)
@@ -32,6 +32,8 @@
 #include "JSDOMOperation.h"
 #include "JSDOMWrapperCache.h"
 #include "JSTestException.h"
+#include "JSTestSerializationIndirectInheritance.h"
+#include "JSTestSerializationInheritFinal.h"
 #include <runtime/FunctionPrototype.h>
 #include <runtime/JSCInlines.h>
 #include <runtime/ObjectConstructor.h>
@@ -61,6 +63,10 @@
 bool setJSTestSerializationFifthLongAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
 JSC::EncodedJSValue jsTestSerializationSixthTypedefAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
 bool setJSTestSerializationSixthTypedefAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
+JSC::EncodedJSValue jsTestSerializationSeventhDirectlySerializableAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
+bool setJSTestSerializationSeventhDirectlySerializableAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
+JSC::EncodedJSValue jsTestSerializationEighthIndirectlyAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
+bool setJSTestSerializationEighthIndirectlyAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
 
 class JSTestSerializationPrototype : public JSC::JSNonFinalObject {
 public:
@@ -115,6 +121,8 @@
     { "fourthUnrestrictedDoubleAttribute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializationFourthUnrestrictedDoubleAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializationFourthUnrestrictedDoubleAttribute) } },
     { "fifthLongAttribute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializationFifthLongAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializationFifthLongAttribute) } },
     { "sixthTypedefAttribute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializationSixthTypedefAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializationSixthTypedefAttribute) } },
+    { "seventhDirectlySerializableAttribute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializationSeventhDirectlySerializableAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializationSeventhDirectlySerializableAttribute) } },
+    { "eighthIndirectlyAttribute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializationEighthIndirectlyAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializationEighthIndirectlyAttribute) } },
     { "toJSON", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestSerializationPrototypeFunctionToJSON), (intptr_t) (0) } },
 };
 
@@ -374,6 +382,66 @@
     return IDLAttribute<JSTestSerialization>::set<setJSTestSerializationSixthTypedefAttributeSetter>(*state, thisValue, encodedValue, "sixthTypedefAttribute");
 }
 
+static inline JSValue jsTestSerializationSeventhDirectlySerializableAttributeGetter(ExecState& state, JSTestSerialization& thisObject, ThrowScope& throwScope)
+{
+    UNUSED_PARAM(throwScope);
+    UNUSED_PARAM(state);
+    auto& impl = thisObject.wrapped();
+    JSValue result = toJS<IDLInterface<TestSerializationInheritFinal>>(state, *thisObject.globalObject(), impl.seventhDirectlySerializableAttribute());
+    return result;
+}
+
+EncodedJSValue jsTestSerializationSeventhDirectlySerializableAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName)
+{
+    return IDLAttribute<JSTestSerialization>::get<jsTestSerializationSeventhDirectlySerializableAttributeGetter>(*state, thisValue, "seventhDirectlySerializableAttribute");
+}
+
+static inline bool setJSTestSerializationSeventhDirectlySerializableAttributeSetter(ExecState& state, JSTestSerialization& thisObject, JSValue value, ThrowScope& throwScope)
+{
+    UNUSED_PARAM(state);
+    UNUSED_PARAM(throwScope);
+    auto& impl = thisObject.wrapped();
+    auto nativeValue = convert<IDLInterface<TestSerializationInheritFinal>>(state, value, [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwAttributeTypeError(state, scope, "TestSerialization", "seventhDirectlySerializableAttribute", "TestSerializationInheritFinal"); });
+    RETURN_IF_EXCEPTION(throwScope, false);
+    impl.setSeventhDirectlySerializableAttribute(*nativeValue);
+    return true;
+}
+
+bool setJSTestSerializationSeventhDirectlySerializableAttribute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
+{
+    return IDLAttribute<JSTestSerialization>::set<setJSTestSerializationSeventhDirectlySerializableAttributeSetter>(*state, thisValue, encodedValue, "seventhDirectlySerializableAttribute");
+}
+
+static inline JSValue jsTestSerializationEighthIndirectlyAttributeGetter(ExecState& state, JSTestSerialization& thisObject, ThrowScope& throwScope)
+{
+    UNUSED_PARAM(throwScope);
+    UNUSED_PARAM(state);
+    auto& impl = thisObject.wrapped();
+    JSValue result = toJS<IDLInterface<TestSerializationIndirectInheritance>>(state, *thisObject.globalObject(), impl.eighthIndirectlyAttribute());
+    return result;
+}
+
+EncodedJSValue jsTestSerializationEighthIndirectlyAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName)
+{
+    return IDLAttribute<JSTestSerialization>::get<jsTestSerializationEighthIndirectlyAttributeGetter>(*state, thisValue, "eighthIndirectlyAttribute");
+}
+
+static inline bool setJSTestSerializationEighthIndirectlyAttributeSetter(ExecState& state, JSTestSerialization& thisObject, JSValue value, ThrowScope& throwScope)
+{
+    UNUSED_PARAM(state);
+    UNUSED_PARAM(throwScope);
+    auto& impl = thisObject.wrapped();
+    auto nativeValue = convert<IDLInterface<TestSerializationIndirectInheritance>>(state, value, [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwAttributeTypeError(state, scope, "TestSerialization", "eighthIndirectlyAttribute", "TestSerializationIndirectInheritance"); });
+    RETURN_IF_EXCEPTION(throwScope, false);
+    impl.setEighthIndirectlyAttribute(*nativeValue);
+    return true;
+}
+
+bool setJSTestSerializationEighthIndirectlyAttribute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
+{
+    return IDLAttribute<JSTestSerialization>::set<setJSTestSerializationEighthIndirectlyAttributeSetter>(*state, thisValue, encodedValue, "eighthIndirectlyAttribute");
+}
+
 JSC::JSObject* JSTestSerialization::serialize(ExecState& state, JSTestSerialization& thisObject, JSDOMGlobalObject& globalObject, ThrowScope& throwScope)
 {
     auto& vm = state.vm();
@@ -399,6 +467,16 @@
     throwScope.assertNoException();
     result->putDirect(vm, Identifier::fromString(&vm, "sixthTypedefAttribute"), sixthTypedefAttributeValue);
 
+    auto seventhDirectlySerializableAttributeValue = jsTestSerializationSeventhDirectlySerializableAttributeGetter(state, thisObject, throwScope);
+    throwScope.assertNoException();
+    auto* seventhDirectlySerializableAttributeSerializedValue = JSTestSerializationInheritFinal::serialize(state, *jsCast<JSTestSerializationInheritFinal*>(seventhDirectlySerializableAttributeValue), globalObject, throwScope);
+    result->putDirect(vm, Identifier::fromString(&vm, "seventhDirectlySerializableAttribute"), seventhDirectlySerializableAttributeSerializedValue);
+
+    auto eighthIndirectlyAttributeValue = jsTestSerializationEighthIndirectlyAttributeGetter(state, thisObject, throwScope);
+    throwScope.assertNoException();
+    auto* eighthIndirectlyAttributeSerializedValue = JSTestSerializationIndirectInheritance::serialize(state, *jsCast<JSTestSerializationIndirectInheritance*>(eighthIndirectlyAttributeValue), globalObject, throwScope);
+    result->putDirect(vm, Identifier::fromString(&vm, "eighthIndirectlyAttribute"), eighthIndirectlyAttributeSerializedValue);
+
     return result;
 }
 

Added: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerializationIndirectInheritance.cpp (0 => 218511)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerializationIndirectInheritance.cpp	                        (rev 0)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerializationIndirectInheritance.cpp	2017-06-19 21:55:00 UTC (rev 218511)
@@ -0,0 +1,149 @@
+/*
+    This file is part of the WebKit open source project.
+    This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "JSTestSerializationIndirectInheritance.h"
+
+#include "JSDOMBinding.h"
+#include "JSDOMConstructorNotConstructable.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMWrapperCache.h"
+#include <runtime/JSCInlines.h>
+#include <wtf/GetPtr.h>
+
+using namespace JSC;
+
+namespace WebCore {
+
+// Attributes
+
+JSC::EncodedJSValue jsTestSerializationIndirectInheritanceConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
+bool setJSTestSerializationIndirectInheritanceConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
+
+class JSTestSerializationIndirectInheritancePrototype : public JSC::JSNonFinalObject {
+public:
+    using Base = JSC::JSNonFinalObject;
+    static JSTestSerializationIndirectInheritancePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
+    {
+        JSTestSerializationIndirectInheritancePrototype* ptr = new (NotNull, JSC::allocateCell<JSTestSerializationIndirectInheritancePrototype>(vm.heap)) JSTestSerializationIndirectInheritancePrototype(vm, globalObject, structure);
+        ptr->finishCreation(vm);
+        return ptr;
+    }
+
+    DECLARE_INFO;
+    static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+    {
+        return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+    }
+
+private:
+    JSTestSerializationIndirectInheritancePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
+        : JSC::JSNonFinalObject(vm, structure)
+    {
+    }
+
+    void finishCreation(JSC::VM&);
+};
+
+using JSTestSerializationIndirectInheritanceConstructor = JSDOMConstructorNotConstructable<JSTestSerializationIndirectInheritance>;
+
+template<> JSValue JSTestSerializationIndirectInheritanceConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
+{
+    return JSTestSerializationInherit::getConstructor(vm, &globalObject);
+}
+
+template<> void JSTestSerializationIndirectInheritanceConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
+{
+    putDirect(vm, vm.propertyNames->prototype, JSTestSerializationIndirectInheritance::prototype(vm, globalObject), DontDelete | ReadOnly | DontEnum);
+    putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("TestSerializationIndirectInheritance"))), ReadOnly | DontEnum);
+    putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum);
+}
+
+template<> const ClassInfo JSTestSerializationIndirectInheritanceConstructor::s_info = { "TestSerializationIndirectInheritance", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestSerializationIndirectInheritanceConstructor) };
+
+/* Hash table for prototype */
+
+static const HashTableValue JSTestSerializationIndirectInheritancePrototypeTableValues[] =
+{
+    { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializationIndirectInheritanceConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializationIndirectInheritanceConstructor) } },
+};
+
+const ClassInfo JSTestSerializationIndirectInheritancePrototype::s_info = { "TestSerializationIndirectInheritancePrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestSerializationIndirectInheritancePrototype) };
+
+void JSTestSerializationIndirectInheritancePrototype::finishCreation(VM& vm)
+{
+    Base::finishCreation(vm);
+    reifyStaticProperties(vm, JSTestSerializationIndirectInheritancePrototypeTableValues, *this);
+}
+
+const ClassInfo JSTestSerializationIndirectInheritance::s_info = { "TestSerializationIndirectInheritance", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestSerializationIndirectInheritance) };
+
+JSTestSerializationIndirectInheritance::JSTestSerializationIndirectInheritance(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TestSerializationIndirectInheritance>&& impl)
+    : JSTestSerializationInherit(structure, globalObject, WTFMove(impl))
+{
+}
+
+void JSTestSerializationIndirectInheritance::finishCreation(VM& vm)
+{
+    Base::finishCreation(vm);
+    ASSERT(inherits(vm, info()));
+
+}
+
+JSObject* JSTestSerializationIndirectInheritance::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+    return JSTestSerializationIndirectInheritancePrototype::create(vm, &globalObject, JSTestSerializationIndirectInheritancePrototype::createStructure(vm, &globalObject, JSTestSerializationInherit::prototype(vm, globalObject)));
+}
+
+JSObject* JSTestSerializationIndirectInheritance::prototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+    return getDOMPrototype<JSTestSerializationIndirectInheritance>(vm, globalObject);
+}
+
+JSValue JSTestSerializationIndirectInheritance::getConstructor(VM& vm, const JSGlobalObject* globalObject)
+{
+    return getDOMConstructor<JSTestSerializationIndirectInheritanceConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
+}
+
+EncodedJSValue jsTestSerializationIndirectInheritanceConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
+{
+    VM& vm = state->vm();
+    auto throwScope = DECLARE_THROW_SCOPE(vm);
+    auto* prototype = jsDynamicDowncast<JSTestSerializationIndirectInheritancePrototype*>(vm, JSValue::decode(thisValue));
+    if (UNLIKELY(!prototype))
+        return throwVMTypeError(state, throwScope);
+    return JSValue::encode(JSTestSerializationIndirectInheritance::getConstructor(state->vm(), prototype->globalObject()));
+}
+
+bool setJSTestSerializationIndirectInheritanceConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
+{
+    VM& vm = state->vm();
+    auto throwScope = DECLARE_THROW_SCOPE(vm);
+    auto* prototype = jsDynamicDowncast<JSTestSerializationIndirectInheritancePrototype*>(vm, JSValue::decode(thisValue));
+    if (UNLIKELY(!prototype)) {
+        throwVMTypeError(state, throwScope);
+        return false;
+    }
+    // Shadowing a built-in constructor
+    return prototype->putDirect(state->vm(), state->propertyNames().constructor, JSValue::decode(encodedValue));
+}
+
+
+}

Added: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerializationIndirectInheritance.h (0 => 218511)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerializationIndirectInheritance.h	                        (rev 0)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerializationIndirectInheritance.h	2017-06-19 21:55:00 UTC (rev 218511)
@@ -0,0 +1,66 @@
+/*
+    This file is part of the WebKit open source project.
+    This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#pragma once
+
+#include "JSTestSerializationInherit.h"
+#include "TestSerializationIndirectInheritance.h"
+
+namespace WebCore {
+
+class JSTestSerializationIndirectInheritance : public JSTestSerializationInherit {
+public:
+    using Base = JSTestSerializationInherit;
+    using DOMWrapped = TestSerializationIndirectInheritance;
+    static JSTestSerializationIndirectInheritance* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, Ref<TestSerializationIndirectInheritance>&& impl)
+    {
+        JSTestSerializationIndirectInheritance* ptr = new (NotNull, JSC::allocateCell<JSTestSerializationIndirectInheritance>(globalObject->vm().heap)) JSTestSerializationIndirectInheritance(structure, *globalObject, WTFMove(impl));
+        ptr->finishCreation(globalObject->vm());
+        return ptr;
+    }
+
+    static JSC::JSObject* createPrototype(JSC::VM&, JSDOMGlobalObject&);
+    static JSC::JSObject* prototype(JSC::VM&, JSDOMGlobalObject&);
+
+    DECLARE_INFO;
+
+    static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+    {
+        return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+    }
+
+    static JSC::JSValue getConstructor(JSC::VM&, const JSC::JSGlobalObject*);
+    TestSerializationIndirectInheritance& wrapped() const
+    {
+        return static_cast<TestSerializationIndirectInheritance&>(Base::wrapped());
+    }
+protected:
+    JSTestSerializationIndirectInheritance(JSC::Structure*, JSDOMGlobalObject&, Ref<TestSerializationIndirectInheritance>&&);
+
+    void finishCreation(JSC::VM&);
+};
+
+
+template<> struct JSDOMWrapperConverterTraits<TestSerializationIndirectInheritance> {
+    using WrapperClass = JSTestSerializationIndirectInheritance;
+    using ToWrappedReturnType = TestSerializationIndirectInheritance*;
+};
+
+} // namespace WebCore

Modified: trunk/Source/WebCore/bindings/scripts/test/TestSerialization.idl (218510 => 218511)


--- trunk/Source/WebCore/bindings/scripts/test/TestSerialization.idl	2017-06-19 21:27:05 UTC (rev 218510)
+++ trunk/Source/WebCore/bindings/scripts/test/TestSerialization.idl	2017-06-19 21:55:00 UTC (rev 218511)
@@ -33,5 +33,8 @@
     attribute long                  fifthLongAttribute;
     attribute TestTimeStamp         sixthTypedefAttribute;
 
+    attribute TestSerializationInheritFinal seventhDirectlySerializableAttribute;
+    attribute TestSerializationIndirectInheritance eighthIndirectlyAttribute;
+
     serializer = { attribute };
 };

Copied: trunk/Source/WebCore/bindings/scripts/test/TestSerializationIndirectInheritance.idl (from rev 218510, trunk/Source/WebCore/bindings/scripts/test/TestSerialization.idl) (0 => 218511)


--- trunk/Source/WebCore/bindings/scripts/test/TestSerializationIndirectInheritance.idl	                        (rev 0)
+++ trunk/Source/WebCore/bindings/scripts/test/TestSerializationIndirectInheritance.idl	2017-06-19 21:55:00 UTC (rev 218511)
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+interface TestSerializationIndirectInheritance : TestSerializationInherit {
+};

Modified: trunk/Source/WebCore/dom/DOMQuad.idl (218510 => 218511)


--- trunk/Source/WebCore/dom/DOMQuad.idl	2017-06-19 21:27:05 UTC (rev 218510)
+++ trunk/Source/WebCore/dom/DOMQuad.idl	2017-06-19 21:55:00 UTC (rev 218511)
@@ -30,8 +30,7 @@
     Exposed=(Window,Worker),
     ImplementationLacksVTable,
     JSCustomMarkFunction
-]
-interface DOMQuad {
+] interface DOMQuad {
     [NewObject] static DOMQuad fromRect(optional DOMRectInit other);
     [NewObject] static DOMQuad fromQuad(optional DOMQuadInit other);
 
@@ -41,5 +40,5 @@
     readonly attribute DOMPoint p4; // FIXME: Should be [SameObject].
     [NewObject] DOMRect getBounds();
 
-    // serializer = { attribute }; FIXME: implement.
+    serializer = { attribute };
 };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to