Move URL from WebCore to WTF
[WebKit-https.git] / Source / WebCore / bindings / scripts / test / JS / JSTestSerialization.cpp
1 /*
2     This file is part of the WebKit open source project.
3     This file has been generated by generate-bindings.pl. DO NOT MODIFY!
4
5     This library is free software; you can redistribute it and/or
6     modify it under the terms of the GNU Library General Public
7     License as published by the Free Software Foundation; either
8     version 2 of the License, or (at your option) any later version.
9
10     This library is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13     Library General Public License for more details.
14
15     You should have received a copy of the GNU Library General Public License
16     along with this library; see the file COPYING.LIB.  If not, write to
17     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18     Boston, MA 02110-1301, USA.
19 */
20
21 #include "config.h"
22 #include "JSTestSerialization.h"
23
24 #include "JSDOMAttribute.h"
25 #include "JSDOMBinding.h"
26 #include "JSDOMConstructorNotConstructable.h"
27 #include "JSDOMConvertInterface.h"
28 #include "JSDOMConvertNullable.h"
29 #include "JSDOMConvertNumbers.h"
30 #include "JSDOMConvertStrings.h"
31 #include "JSDOMExceptionHandling.h"
32 #include "JSDOMGlobalObject.h"
33 #include "JSDOMOperation.h"
34 #include "JSDOMWrapperCache.h"
35 #include "JSTestException.h"
36 #include "JSTestSerializationIndirectInheritance.h"
37 #include "JSTestSerializationInheritFinal.h"
38 #include "ScriptExecutionContext.h"
39 #include <JavaScriptCore/FunctionPrototype.h>
40 #include <JavaScriptCore/HeapSnapshotBuilder.h>
41 #include <JavaScriptCore/JSCInlines.h>
42 #include <JavaScriptCore/ObjectConstructor.h>
43 #include <wtf/GetPtr.h>
44 #include <wtf/PointerPreparations.h>
45 #include <wtf/URL.h>
46
47
48 namespace WebCore {
49 using namespace JSC;
50
51 // Functions
52
53 JSC::EncodedJSValue JSC_HOST_CALL jsTestSerializationPrototypeFunctionToJSON(JSC::ExecState*);
54
55 // Attributes
56
57 JSC::EncodedJSValue jsTestSerializationConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
58 bool setJSTestSerializationConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
59 JSC::EncodedJSValue jsTestSerializationFirstStringAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
60 bool setJSTestSerializationFirstStringAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
61 JSC::EncodedJSValue jsTestSerializationSecondLongAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
62 bool setJSTestSerializationSecondLongAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
63 JSC::EncodedJSValue jsTestSerializationThirdUnserializableAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
64 bool setJSTestSerializationThirdUnserializableAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
65 JSC::EncodedJSValue jsTestSerializationFourthUnrestrictedDoubleAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
66 bool setJSTestSerializationFourthUnrestrictedDoubleAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
67 JSC::EncodedJSValue jsTestSerializationFifthLongAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
68 bool setJSTestSerializationFifthLongAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
69 JSC::EncodedJSValue jsTestSerializationSixthTypedefAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
70 bool setJSTestSerializationSixthTypedefAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
71 JSC::EncodedJSValue jsTestSerializationSeventhDirectlySerializableAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
72 bool setJSTestSerializationSeventhDirectlySerializableAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
73 JSC::EncodedJSValue jsTestSerializationEighthIndirectlyAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
74 bool setJSTestSerializationEighthIndirectlyAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
75 JSC::EncodedJSValue jsTestSerializationNinthOptionalDirectlySerializableAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
76 bool setJSTestSerializationNinthOptionalDirectlySerializableAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
77
78 class JSTestSerializationPrototype : public JSC::JSNonFinalObject {
79 public:
80     using Base = JSC::JSNonFinalObject;
81     static JSTestSerializationPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
82     {
83         JSTestSerializationPrototype* ptr = new (NotNull, JSC::allocateCell<JSTestSerializationPrototype>(vm.heap)) JSTestSerializationPrototype(vm, globalObject, structure);
84         ptr->finishCreation(vm);
85         return ptr;
86     }
87
88     DECLARE_INFO;
89     static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
90     {
91         return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
92     }
93
94 private:
95     JSTestSerializationPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
96         : JSC::JSNonFinalObject(vm, structure)
97     {
98     }
99
100     void finishCreation(JSC::VM&);
101 };
102
103 using JSTestSerializationConstructor = JSDOMConstructorNotConstructable<JSTestSerialization>;
104
105 template<> JSValue JSTestSerializationConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
106 {
107     UNUSED_PARAM(vm);
108     return globalObject.functionPrototype();
109 }
110
111 template<> void JSTestSerializationConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
112 {
113     putDirect(vm, vm.propertyNames->prototype, JSTestSerialization::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
114     putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("TestSerialization"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
115     putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
116 }
117
118 template<> const ClassInfo JSTestSerializationConstructor::s_info = { "TestSerialization", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestSerializationConstructor) };
119
120 /* Hash table for prototype */
121
122 static const HashTableValue JSTestSerializationPrototypeTableValues[] =
123 {
124     { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializationConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializationConstructor) } },
125     { "firstStringAttribute", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializationFirstStringAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializationFirstStringAttribute) } },
126     { "secondLongAttribute", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializationSecondLongAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializationSecondLongAttribute) } },
127     { "thirdUnserializableAttribute", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializationThirdUnserializableAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializationThirdUnserializableAttribute) } },
128     { "fourthUnrestrictedDoubleAttribute", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializationFourthUnrestrictedDoubleAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializationFourthUnrestrictedDoubleAttribute) } },
129     { "fifthLongAttribute", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializationFifthLongAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializationFifthLongAttribute) } },
130     { "sixthTypedefAttribute", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializationSixthTypedefAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializationSixthTypedefAttribute) } },
131     { "seventhDirectlySerializableAttribute", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializationSeventhDirectlySerializableAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializationSeventhDirectlySerializableAttribute) } },
132     { "eighthIndirectlyAttribute", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializationEighthIndirectlyAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializationEighthIndirectlyAttribute) } },
133     { "ninthOptionalDirectlySerializableAttribute", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializationNinthOptionalDirectlySerializableAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializationNinthOptionalDirectlySerializableAttribute) } },
134     { "toJSON", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestSerializationPrototypeFunctionToJSON), (intptr_t) (0) } },
135 };
136
137 const ClassInfo JSTestSerializationPrototype::s_info = { "TestSerializationPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestSerializationPrototype) };
138
139 void JSTestSerializationPrototype::finishCreation(VM& vm)
140 {
141     Base::finishCreation(vm);
142     reifyStaticProperties(vm, JSTestSerialization::info(), JSTestSerializationPrototypeTableValues, *this);
143 }
144
145 const ClassInfo JSTestSerialization::s_info = { "TestSerialization", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestSerialization) };
146
147 JSTestSerialization::JSTestSerialization(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TestSerialization>&& impl)
148     : JSDOMWrapper<TestSerialization>(structure, globalObject, WTFMove(impl))
149 {
150 }
151
152 void JSTestSerialization::finishCreation(VM& vm)
153 {
154     Base::finishCreation(vm);
155     ASSERT(inherits(vm, info()));
156
157 }
158
159 JSObject* JSTestSerialization::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
160 {
161     return JSTestSerializationPrototype::create(vm, &globalObject, JSTestSerializationPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
162 }
163
164 JSObject* JSTestSerialization::prototype(VM& vm, JSDOMGlobalObject& globalObject)
165 {
166     return getDOMPrototype<JSTestSerialization>(vm, globalObject);
167 }
168
169 JSValue JSTestSerialization::getConstructor(VM& vm, const JSGlobalObject* globalObject)
170 {
171     return getDOMConstructor<JSTestSerializationConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
172 }
173
174 void JSTestSerialization::destroy(JSC::JSCell* cell)
175 {
176     JSTestSerialization* thisObject = static_cast<JSTestSerialization*>(cell);
177     thisObject->JSTestSerialization::~JSTestSerialization();
178 }
179
180 template<> inline JSTestSerialization* IDLAttribute<JSTestSerialization>::cast(ExecState& state, EncodedJSValue thisValue)
181 {
182     return jsDynamicCast<JSTestSerialization*>(state.vm(), JSValue::decode(thisValue));
183 }
184
185 template<> inline JSTestSerialization* IDLOperation<JSTestSerialization>::cast(ExecState& state)
186 {
187     return jsDynamicCast<JSTestSerialization*>(state.vm(), state.thisValue());
188 }
189
190 EncodedJSValue jsTestSerializationConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
191 {
192     VM& vm = state->vm();
193     auto throwScope = DECLARE_THROW_SCOPE(vm);
194     auto* prototype = jsDynamicCast<JSTestSerializationPrototype*>(vm, JSValue::decode(thisValue));
195     if (UNLIKELY(!prototype))
196         return throwVMTypeError(state, throwScope);
197     return JSValue::encode(JSTestSerialization::getConstructor(state->vm(), prototype->globalObject()));
198 }
199
200 bool setJSTestSerializationConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
201 {
202     VM& vm = state->vm();
203     auto throwScope = DECLARE_THROW_SCOPE(vm);
204     auto* prototype = jsDynamicCast<JSTestSerializationPrototype*>(vm, JSValue::decode(thisValue));
205     if (UNLIKELY(!prototype)) {
206         throwVMTypeError(state, throwScope);
207         return false;
208     }
209     // Shadowing a built-in constructor
210     return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
211 }
212
213 static inline JSValue jsTestSerializationFirstStringAttributeGetter(ExecState& state, JSTestSerialization& thisObject, ThrowScope& throwScope)
214 {
215     UNUSED_PARAM(throwScope);
216     UNUSED_PARAM(state);
217     auto& impl = thisObject.wrapped();
218     JSValue result = toJS<IDLDOMString>(state, throwScope, impl.firstStringAttribute());
219     return result;
220 }
221
222 EncodedJSValue jsTestSerializationFirstStringAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName)
223 {
224     return IDLAttribute<JSTestSerialization>::get<jsTestSerializationFirstStringAttributeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "firstStringAttribute");
225 }
226
227 static inline bool setJSTestSerializationFirstStringAttributeSetter(ExecState& state, JSTestSerialization& thisObject, JSValue value, ThrowScope& throwScope)
228 {
229     UNUSED_PARAM(throwScope);
230     auto& impl = thisObject.wrapped();
231     auto nativeValue = convert<IDLDOMString>(state, value);
232     RETURN_IF_EXCEPTION(throwScope, false);
233     AttributeSetter::call(state, throwScope, [&] {
234         return impl.setFirstStringAttribute(WTFMove(nativeValue));
235     });
236     return true;
237 }
238
239 bool setJSTestSerializationFirstStringAttribute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
240 {
241     return IDLAttribute<JSTestSerialization>::set<setJSTestSerializationFirstStringAttributeSetter>(*state, thisValue, encodedValue, "firstStringAttribute");
242 }
243
244 static inline JSValue jsTestSerializationSecondLongAttributeGetter(ExecState& state, JSTestSerialization& thisObject, ThrowScope& throwScope)
245 {
246     UNUSED_PARAM(throwScope);
247     UNUSED_PARAM(state);
248     auto& impl = thisObject.wrapped();
249     JSValue result = toJS<IDLLong>(state, throwScope, impl.secondLongAttribute());
250     return result;
251 }
252
253 EncodedJSValue jsTestSerializationSecondLongAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName)
254 {
255     return IDLAttribute<JSTestSerialization>::get<jsTestSerializationSecondLongAttributeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "secondLongAttribute");
256 }
257
258 static inline bool setJSTestSerializationSecondLongAttributeSetter(ExecState& state, JSTestSerialization& thisObject, JSValue value, ThrowScope& throwScope)
259 {
260     UNUSED_PARAM(throwScope);
261     auto& impl = thisObject.wrapped();
262     auto nativeValue = convert<IDLLong>(state, value);
263     RETURN_IF_EXCEPTION(throwScope, false);
264     AttributeSetter::call(state, throwScope, [&] {
265         return impl.setSecondLongAttribute(WTFMove(nativeValue));
266     });
267     return true;
268 }
269
270 bool setJSTestSerializationSecondLongAttribute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
271 {
272     return IDLAttribute<JSTestSerialization>::set<setJSTestSerializationSecondLongAttributeSetter>(*state, thisValue, encodedValue, "secondLongAttribute");
273 }
274
275 static inline JSValue jsTestSerializationThirdUnserializableAttributeGetter(ExecState& state, JSTestSerialization& thisObject, ThrowScope& throwScope)
276 {
277     UNUSED_PARAM(throwScope);
278     UNUSED_PARAM(state);
279     auto& impl = thisObject.wrapped();
280     JSValue result = toJS<IDLInterface<TestException>>(state, *thisObject.globalObject(), throwScope, impl.thirdUnserializableAttribute());
281     return result;
282 }
283
284 EncodedJSValue jsTestSerializationThirdUnserializableAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName)
285 {
286     return IDLAttribute<JSTestSerialization>::get<jsTestSerializationThirdUnserializableAttributeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "thirdUnserializableAttribute");
287 }
288
289 static inline bool setJSTestSerializationThirdUnserializableAttributeSetter(ExecState& state, JSTestSerialization& thisObject, JSValue value, ThrowScope& throwScope)
290 {
291     UNUSED_PARAM(throwScope);
292     auto& impl = thisObject.wrapped();
293     auto nativeValue = convert<IDLInterface<TestException>>(state, value, [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwAttributeTypeError(state, scope, "TestSerialization", "thirdUnserializableAttribute", "TestException"); });
294     RETURN_IF_EXCEPTION(throwScope, false);
295     AttributeSetter::call(state, throwScope, [&] {
296         return impl.setThirdUnserializableAttribute(*nativeValue);
297     });
298     return true;
299 }
300
301 bool setJSTestSerializationThirdUnserializableAttribute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
302 {
303     return IDLAttribute<JSTestSerialization>::set<setJSTestSerializationThirdUnserializableAttributeSetter>(*state, thisValue, encodedValue, "thirdUnserializableAttribute");
304 }
305
306 static inline JSValue jsTestSerializationFourthUnrestrictedDoubleAttributeGetter(ExecState& state, JSTestSerialization& thisObject, ThrowScope& throwScope)
307 {
308     UNUSED_PARAM(throwScope);
309     UNUSED_PARAM(state);
310     auto& impl = thisObject.wrapped();
311     JSValue result = toJS<IDLUnrestrictedDouble>(state, throwScope, impl.fourthUnrestrictedDoubleAttribute());
312     return result;
313 }
314
315 EncodedJSValue jsTestSerializationFourthUnrestrictedDoubleAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName)
316 {
317     return IDLAttribute<JSTestSerialization>::get<jsTestSerializationFourthUnrestrictedDoubleAttributeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "fourthUnrestrictedDoubleAttribute");
318 }
319
320 static inline bool setJSTestSerializationFourthUnrestrictedDoubleAttributeSetter(ExecState& state, JSTestSerialization& thisObject, JSValue value, ThrowScope& throwScope)
321 {
322     UNUSED_PARAM(throwScope);
323     auto& impl = thisObject.wrapped();
324     auto nativeValue = convert<IDLUnrestrictedDouble>(state, value);
325     RETURN_IF_EXCEPTION(throwScope, false);
326     AttributeSetter::call(state, throwScope, [&] {
327         return impl.setFourthUnrestrictedDoubleAttribute(WTFMove(nativeValue));
328     });
329     return true;
330 }
331
332 bool setJSTestSerializationFourthUnrestrictedDoubleAttribute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
333 {
334     return IDLAttribute<JSTestSerialization>::set<setJSTestSerializationFourthUnrestrictedDoubleAttributeSetter>(*state, thisValue, encodedValue, "fourthUnrestrictedDoubleAttribute");
335 }
336
337 static inline JSValue jsTestSerializationFifthLongAttributeGetter(ExecState& state, JSTestSerialization& thisObject, ThrowScope& throwScope)
338 {
339     UNUSED_PARAM(throwScope);
340     UNUSED_PARAM(state);
341     auto& impl = thisObject.wrapped();
342     JSValue result = toJS<IDLLong>(state, throwScope, impl.fifthLongAttribute());
343     return result;
344 }
345
346 EncodedJSValue jsTestSerializationFifthLongAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName)
347 {
348     return IDLAttribute<JSTestSerialization>::get<jsTestSerializationFifthLongAttributeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "fifthLongAttribute");
349 }
350
351 static inline bool setJSTestSerializationFifthLongAttributeSetter(ExecState& state, JSTestSerialization& thisObject, JSValue value, ThrowScope& throwScope)
352 {
353     UNUSED_PARAM(throwScope);
354     auto& impl = thisObject.wrapped();
355     auto nativeValue = convert<IDLLong>(state, value);
356     RETURN_IF_EXCEPTION(throwScope, false);
357     AttributeSetter::call(state, throwScope, [&] {
358         return impl.setFifthLongAttribute(WTFMove(nativeValue));
359     });
360     return true;
361 }
362
363 bool setJSTestSerializationFifthLongAttribute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
364 {
365     return IDLAttribute<JSTestSerialization>::set<setJSTestSerializationFifthLongAttributeSetter>(*state, thisValue, encodedValue, "fifthLongAttribute");
366 }
367
368 static inline JSValue jsTestSerializationSixthTypedefAttributeGetter(ExecState& state, JSTestSerialization& thisObject, ThrowScope& throwScope)
369 {
370     UNUSED_PARAM(throwScope);
371     UNUSED_PARAM(state);
372     auto& impl = thisObject.wrapped();
373     JSValue result = toJS<IDLDouble>(state, throwScope, impl.sixthTypedefAttribute());
374     return result;
375 }
376
377 EncodedJSValue jsTestSerializationSixthTypedefAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName)
378 {
379     return IDLAttribute<JSTestSerialization>::get<jsTestSerializationSixthTypedefAttributeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "sixthTypedefAttribute");
380 }
381
382 static inline bool setJSTestSerializationSixthTypedefAttributeSetter(ExecState& state, JSTestSerialization& thisObject, JSValue value, ThrowScope& throwScope)
383 {
384     UNUSED_PARAM(throwScope);
385     auto& impl = thisObject.wrapped();
386     auto nativeValue = convert<IDLDouble>(state, value);
387     RETURN_IF_EXCEPTION(throwScope, false);
388     AttributeSetter::call(state, throwScope, [&] {
389         return impl.setSixthTypedefAttribute(WTFMove(nativeValue));
390     });
391     return true;
392 }
393
394 bool setJSTestSerializationSixthTypedefAttribute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
395 {
396     return IDLAttribute<JSTestSerialization>::set<setJSTestSerializationSixthTypedefAttributeSetter>(*state, thisValue, encodedValue, "sixthTypedefAttribute");
397 }
398
399 static inline JSValue jsTestSerializationSeventhDirectlySerializableAttributeGetter(ExecState& state, JSTestSerialization& thisObject, ThrowScope& throwScope)
400 {
401     UNUSED_PARAM(throwScope);
402     UNUSED_PARAM(state);
403     auto& impl = thisObject.wrapped();
404     JSValue result = toJS<IDLInterface<TestSerializationInheritFinal>>(state, *thisObject.globalObject(), throwScope, impl.seventhDirectlySerializableAttribute());
405     return result;
406 }
407
408 EncodedJSValue jsTestSerializationSeventhDirectlySerializableAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName)
409 {
410     return IDLAttribute<JSTestSerialization>::get<jsTestSerializationSeventhDirectlySerializableAttributeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "seventhDirectlySerializableAttribute");
411 }
412
413 static inline bool setJSTestSerializationSeventhDirectlySerializableAttributeSetter(ExecState& state, JSTestSerialization& thisObject, JSValue value, ThrowScope& throwScope)
414 {
415     UNUSED_PARAM(throwScope);
416     auto& impl = thisObject.wrapped();
417     auto nativeValue = convert<IDLInterface<TestSerializationInheritFinal>>(state, value, [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwAttributeTypeError(state, scope, "TestSerialization", "seventhDirectlySerializableAttribute", "TestSerializationInheritFinal"); });
418     RETURN_IF_EXCEPTION(throwScope, false);
419     AttributeSetter::call(state, throwScope, [&] {
420         return impl.setSeventhDirectlySerializableAttribute(*nativeValue);
421     });
422     return true;
423 }
424
425 bool setJSTestSerializationSeventhDirectlySerializableAttribute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
426 {
427     return IDLAttribute<JSTestSerialization>::set<setJSTestSerializationSeventhDirectlySerializableAttributeSetter>(*state, thisValue, encodedValue, "seventhDirectlySerializableAttribute");
428 }
429
430 static inline JSValue jsTestSerializationEighthIndirectlyAttributeGetter(ExecState& state, JSTestSerialization& thisObject, ThrowScope& throwScope)
431 {
432     UNUSED_PARAM(throwScope);
433     UNUSED_PARAM(state);
434     auto& impl = thisObject.wrapped();
435     JSValue result = toJS<IDLInterface<TestSerializationIndirectInheritance>>(state, *thisObject.globalObject(), throwScope, impl.eighthIndirectlyAttribute());
436     return result;
437 }
438
439 EncodedJSValue jsTestSerializationEighthIndirectlyAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName)
440 {
441     return IDLAttribute<JSTestSerialization>::get<jsTestSerializationEighthIndirectlyAttributeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "eighthIndirectlyAttribute");
442 }
443
444 static inline bool setJSTestSerializationEighthIndirectlyAttributeSetter(ExecState& state, JSTestSerialization& thisObject, JSValue value, ThrowScope& throwScope)
445 {
446     UNUSED_PARAM(throwScope);
447     auto& impl = thisObject.wrapped();
448     auto nativeValue = convert<IDLInterface<TestSerializationIndirectInheritance>>(state, value, [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwAttributeTypeError(state, scope, "TestSerialization", "eighthIndirectlyAttribute", "TestSerializationIndirectInheritance"); });
449     RETURN_IF_EXCEPTION(throwScope, false);
450     AttributeSetter::call(state, throwScope, [&] {
451         return impl.setEighthIndirectlyAttribute(*nativeValue);
452     });
453     return true;
454 }
455
456 bool setJSTestSerializationEighthIndirectlyAttribute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
457 {
458     return IDLAttribute<JSTestSerialization>::set<setJSTestSerializationEighthIndirectlyAttributeSetter>(*state, thisValue, encodedValue, "eighthIndirectlyAttribute");
459 }
460
461 static inline JSValue jsTestSerializationNinthOptionalDirectlySerializableAttributeGetter(ExecState& state, JSTestSerialization& thisObject, ThrowScope& throwScope)
462 {
463     UNUSED_PARAM(throwScope);
464     UNUSED_PARAM(state);
465     auto& impl = thisObject.wrapped();
466     JSValue result = toJS<IDLNullable<IDLInterface<TestSerializationInheritFinal>>>(state, *thisObject.globalObject(), throwScope, impl.ninthOptionalDirectlySerializableAttribute());
467     return result;
468 }
469
470 EncodedJSValue jsTestSerializationNinthOptionalDirectlySerializableAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName)
471 {
472     return IDLAttribute<JSTestSerialization>::get<jsTestSerializationNinthOptionalDirectlySerializableAttributeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "ninthOptionalDirectlySerializableAttribute");
473 }
474
475 static inline bool setJSTestSerializationNinthOptionalDirectlySerializableAttributeSetter(ExecState& state, JSTestSerialization& thisObject, JSValue value, ThrowScope& throwScope)
476 {
477     UNUSED_PARAM(throwScope);
478     auto& impl = thisObject.wrapped();
479     auto nativeValue = convert<IDLNullable<IDLInterface<TestSerializationInheritFinal>>>(state, value, [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwAttributeTypeError(state, scope, "TestSerialization", "ninthOptionalDirectlySerializableAttribute", "TestSerializationInheritFinal"); });
480     RETURN_IF_EXCEPTION(throwScope, false);
481     AttributeSetter::call(state, throwScope, [&] {
482         return impl.setNinthOptionalDirectlySerializableAttribute(WTFMove(nativeValue));
483     });
484     return true;
485 }
486
487 bool setJSTestSerializationNinthOptionalDirectlySerializableAttribute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
488 {
489     return IDLAttribute<JSTestSerialization>::set<setJSTestSerializationNinthOptionalDirectlySerializableAttributeSetter>(*state, thisValue, encodedValue, "ninthOptionalDirectlySerializableAttribute");
490 }
491
492 JSC::JSObject* JSTestSerialization::serialize(ExecState& state, JSTestSerialization& thisObject, JSDOMGlobalObject& globalObject, ThrowScope& throwScope)
493 {
494     auto& vm = state.vm();
495     auto* result = constructEmptyObject(&state, globalObject.objectPrototype());
496
497     auto firstStringAttributeValue = jsTestSerializationFirstStringAttributeGetter(state, thisObject, throwScope);
498     throwScope.assertNoException();
499     result->putDirect(vm, Identifier::fromString(&vm, "firstStringAttribute"), firstStringAttributeValue);
500
501     auto secondLongAttributeValue = jsTestSerializationSecondLongAttributeGetter(state, thisObject, throwScope);
502     throwScope.assertNoException();
503     result->putDirect(vm, Identifier::fromString(&vm, "secondLongAttribute"), secondLongAttributeValue);
504
505     auto fourthUnrestrictedDoubleAttributeValue = jsTestSerializationFourthUnrestrictedDoubleAttributeGetter(state, thisObject, throwScope);
506     throwScope.assertNoException();
507     result->putDirect(vm, Identifier::fromString(&vm, "fourthUnrestrictedDoubleAttribute"), fourthUnrestrictedDoubleAttributeValue);
508
509     auto fifthLongAttributeValue = jsTestSerializationFifthLongAttributeGetter(state, thisObject, throwScope);
510     throwScope.assertNoException();
511     result->putDirect(vm, Identifier::fromString(&vm, "fifthLongAttribute"), fifthLongAttributeValue);
512
513     auto sixthTypedefAttributeValue = jsTestSerializationSixthTypedefAttributeGetter(state, thisObject, throwScope);
514     throwScope.assertNoException();
515     result->putDirect(vm, Identifier::fromString(&vm, "sixthTypedefAttribute"), sixthTypedefAttributeValue);
516
517     auto seventhDirectlySerializableAttributeValue = jsTestSerializationSeventhDirectlySerializableAttributeGetter(state, thisObject, throwScope);
518     throwScope.assertNoException();
519     auto* seventhDirectlySerializableAttributeSerializedValue = JSTestSerializationInheritFinal::serialize(state, *jsCast<JSTestSerializationInheritFinal*>(seventhDirectlySerializableAttributeValue), globalObject, throwScope);
520     result->putDirect(vm, Identifier::fromString(&vm, "seventhDirectlySerializableAttribute"), seventhDirectlySerializableAttributeSerializedValue);
521
522     auto eighthIndirectlyAttributeValue = jsTestSerializationEighthIndirectlyAttributeGetter(state, thisObject, throwScope);
523     throwScope.assertNoException();
524     auto* eighthIndirectlyAttributeSerializedValue = JSTestSerializationIndirectInheritance::serialize(state, *jsCast<JSTestSerializationIndirectInheritance*>(eighthIndirectlyAttributeValue), globalObject, throwScope);
525     result->putDirect(vm, Identifier::fromString(&vm, "eighthIndirectlyAttribute"), eighthIndirectlyAttributeSerializedValue);
526
527     auto ninthOptionalDirectlySerializableAttributeValue = jsTestSerializationNinthOptionalDirectlySerializableAttributeGetter(state, thisObject, throwScope);
528     throwScope.assertNoException();
529     if (!ninthOptionalDirectlySerializableAttributeValue.isNull()) {
530         auto* ninthOptionalDirectlySerializableAttributeSerializedValue = JSTestSerializationInheritFinal::serialize(state, *jsCast<JSTestSerializationInheritFinal*>(ninthOptionalDirectlySerializableAttributeValue), globalObject, throwScope);
531         result->putDirect(vm, Identifier::fromString(&vm, "ninthOptionalDirectlySerializableAttribute"), ninthOptionalDirectlySerializableAttributeSerializedValue);
532     } else
533         result->putDirect(vm, Identifier::fromString(&vm, "ninthOptionalDirectlySerializableAttribute"), ninthOptionalDirectlySerializableAttributeValue);
534
535     return result;
536 }
537
538 static inline EncodedJSValue jsTestSerializationPrototypeFunctionToJSONBody(ExecState* state, JSTestSerialization* thisObject, JSC::ThrowScope& throwScope)
539 {
540     return JSValue::encode(JSTestSerialization::serialize(*state, *thisObject, *thisObject->globalObject(), throwScope));
541 }
542
543 EncodedJSValue JSC_HOST_CALL jsTestSerializationPrototypeFunctionToJSON(ExecState* state)
544 {
545     return IDLOperation<JSTestSerialization>::call<jsTestSerializationPrototypeFunctionToJSONBody>(*state, "toJSON");
546 }
547
548 void JSTestSerialization::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
549 {
550     auto* thisObject = jsCast<JSTestSerialization*>(cell);
551     builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
552     if (thisObject->scriptExecutionContext())
553         builder.setLabelForCell(cell, String::format("url %s", thisObject->scriptExecutionContext()->url().string().utf8().data()));
554     Base::heapSnapshot(cell, builder);
555 }
556
557 bool JSTestSerializationOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
558 {
559     UNUSED_PARAM(handle);
560     UNUSED_PARAM(visitor);
561     UNUSED_PARAM(reason);
562     return false;
563 }
564
565 void JSTestSerializationOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
566 {
567     auto* jsTestSerialization = static_cast<JSTestSerialization*>(handle.slot()->asCell());
568     auto& world = *static_cast<DOMWrapperWorld*>(context);
569     uncacheWrapper(world, &jsTestSerialization->wrapped(), jsTestSerialization);
570 }
571
572 #if ENABLE(BINDING_INTEGRITY)
573 #if PLATFORM(WIN)
574 #pragma warning(disable: 4483)
575 extern "C" { extern void (*const __identifier("??_7TestSerialization@WebCore@@6B@")[])(); }
576 #else
577 extern "C" { extern void* _ZTVN7WebCore17TestSerializationE[]; }
578 #endif
579 #endif
580
581 JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<TestSerialization>&& impl)
582 {
583
584 #if ENABLE(BINDING_INTEGRITY)
585     void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
586 #if PLATFORM(WIN)
587     void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7TestSerialization@WebCore@@6B@"));
588 #else
589     void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore17TestSerializationE[2]);
590 #endif
591
592     // If this fails TestSerialization does not have a vtable, so you need to add the
593     // ImplementationLacksVTable attribute to the interface definition
594     static_assert(std::is_polymorphic<TestSerialization>::value, "TestSerialization is not polymorphic");
595
596     // If you hit this assertion you either have a use after free bug, or
597     // TestSerialization has subclasses. If TestSerialization has subclasses that get passed
598     // to toJS() we currently require TestSerialization you to opt out of binding hardening
599     // by adding the SkipVTableValidation attribute to the interface IDL definition
600     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
601 #endif
602     return createWrapper<TestSerialization>(globalObject, WTFMove(impl));
603 }
604
605 JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, TestSerialization& impl)
606 {
607     return wrap(state, globalObject, impl);
608 }
609
610 TestSerialization* JSTestSerialization::toWrapped(JSC::VM& vm, JSC::JSValue value)
611 {
612     if (auto* wrapper = jsDynamicCast<JSTestSerialization*>(vm, value))
613         return &wrapper->wrapped();
614     return nullptr;
615 }
616
617 }