Unreviewed, rolling out r251040.
[WebKit-https.git] / Source / WebCore / bindings / scripts / test / JS / JSTestSerializedScriptValueInterface.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
23 #if ENABLE(Condition1) || ENABLE(Condition2)
24
25 #include "JSTestSerializedScriptValueInterface.h"
26
27 #include "JSDOMAttribute.h"
28 #include "JSDOMBinding.h"
29 #include "JSDOMConstructorNotConstructable.h"
30 #include "JSDOMConvertInterface.h"
31 #include "JSDOMConvertSequences.h"
32 #include "JSDOMConvertSerializedScriptValue.h"
33 #include "JSDOMExceptionHandling.h"
34 #include "JSDOMGlobalObject.h"
35 #include "JSDOMOperation.h"
36 #include "JSDOMWrapperCache.h"
37 #include "JSMessagePort.h"
38 #include "ScriptExecutionContext.h"
39 #include "SerializedScriptValue.h"
40 #include <JavaScriptCore/FunctionPrototype.h>
41 #include <JavaScriptCore/HeapAnalyzer.h>
42 #include <JavaScriptCore/JSArray.h>
43 #include <JavaScriptCore/JSCInlines.h>
44 #include <wtf/GetPtr.h>
45 #include <wtf/PointerPreparations.h>
46 #include <wtf/URL.h>
47
48
49 namespace WebCore {
50 using namespace JSC;
51
52 // Functions
53
54 JSC::EncodedJSValue JSC_HOST_CALL jsTestSerializedScriptValueInterfacePrototypeFunctionFunction(JSC::JSGlobalObject*, JSC::CallFrame*);
55 JSC::EncodedJSValue JSC_HOST_CALL jsTestSerializedScriptValueInterfacePrototypeFunctionFunctionReturning(JSC::JSGlobalObject*, JSC::CallFrame*);
56
57 // Attributes
58
59 JSC::EncodedJSValue jsTestSerializedScriptValueInterfaceConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
60 bool setJSTestSerializedScriptValueInterfaceConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
61 JSC::EncodedJSValue jsTestSerializedScriptValueInterfaceValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
62 bool setJSTestSerializedScriptValueInterfaceValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
63 JSC::EncodedJSValue jsTestSerializedScriptValueInterfaceReadonlyValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
64 JSC::EncodedJSValue jsTestSerializedScriptValueInterfaceCachedValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
65 bool setJSTestSerializedScriptValueInterfaceCachedValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
66 JSC::EncodedJSValue jsTestSerializedScriptValueInterfacePorts(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
67 JSC::EncodedJSValue jsTestSerializedScriptValueInterfaceCachedReadonlyValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
68
69 class JSTestSerializedScriptValueInterfacePrototype : public JSC::JSNonFinalObject {
70 public:
71     using Base = JSC::JSNonFinalObject;
72     static JSTestSerializedScriptValueInterfacePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
73     {
74         JSTestSerializedScriptValueInterfacePrototype* ptr = new (NotNull, JSC::allocateCell<JSTestSerializedScriptValueInterfacePrototype>(vm.heap)) JSTestSerializedScriptValueInterfacePrototype(vm, globalObject, structure);
75         ptr->finishCreation(vm);
76         return ptr;
77     }
78
79     DECLARE_INFO;
80     static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
81     {
82         return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
83     }
84
85 private:
86     JSTestSerializedScriptValueInterfacePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
87         : JSC::JSNonFinalObject(vm, structure)
88     {
89     }
90
91     void finishCreation(JSC::VM&);
92 };
93
94 using JSTestSerializedScriptValueInterfaceConstructor = JSDOMConstructorNotConstructable<JSTestSerializedScriptValueInterface>;
95
96 template<> JSValue JSTestSerializedScriptValueInterfaceConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
97 {
98     UNUSED_PARAM(vm);
99     return globalObject.functionPrototype();
100 }
101
102 template<> void JSTestSerializedScriptValueInterfaceConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
103 {
104     putDirect(vm, vm.propertyNames->prototype, JSTestSerializedScriptValueInterface::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
105     putDirect(vm, vm.propertyNames->name, jsNontrivialString(vm, String("TestSerializedScriptValueInterface"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
106     putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
107 }
108
109 template<> const ClassInfo JSTestSerializedScriptValueInterfaceConstructor::s_info = { "TestSerializedScriptValueInterface", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestSerializedScriptValueInterfaceConstructor) };
110
111 /* Hash table for prototype */
112
113 static const HashTableValue JSTestSerializedScriptValueInterfacePrototypeTableValues[] =
114 {
115     { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializedScriptValueInterfaceConstructor) } },
116     { "value", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializedScriptValueInterfaceValue) } },
117     { "readonlyValue", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceReadonlyValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
118     { "cachedValue", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceCachedValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializedScriptValueInterfaceCachedValue) } },
119     { "ports", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfacePorts), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
120     { "cachedReadonlyValue", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceCachedReadonlyValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
121     { "function", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestSerializedScriptValueInterfacePrototypeFunctionFunction), (intptr_t) (1) } },
122     { "functionReturning", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestSerializedScriptValueInterfacePrototypeFunctionFunctionReturning), (intptr_t) (0) } },
123 };
124
125 const ClassInfo JSTestSerializedScriptValueInterfacePrototype::s_info = { "TestSerializedScriptValueInterfacePrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestSerializedScriptValueInterfacePrototype) };
126
127 void JSTestSerializedScriptValueInterfacePrototype::finishCreation(VM& vm)
128 {
129     Base::finishCreation(vm);
130     reifyStaticProperties(vm, JSTestSerializedScriptValueInterface::info(), JSTestSerializedScriptValueInterfacePrototypeTableValues, *this);
131 }
132
133 const ClassInfo JSTestSerializedScriptValueInterface::s_info = { "TestSerializedScriptValueInterface", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestSerializedScriptValueInterface) };
134
135 JSTestSerializedScriptValueInterface::JSTestSerializedScriptValueInterface(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TestSerializedScriptValueInterface>&& impl)
136     : JSDOMWrapper<TestSerializedScriptValueInterface>(structure, globalObject, WTFMove(impl))
137 {
138 }
139
140 void JSTestSerializedScriptValueInterface::finishCreation(VM& vm)
141 {
142     Base::finishCreation(vm);
143     ASSERT(inherits(vm, info()));
144
145 }
146
147 JSObject* JSTestSerializedScriptValueInterface::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
148 {
149     return JSTestSerializedScriptValueInterfacePrototype::create(vm, &globalObject, JSTestSerializedScriptValueInterfacePrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
150 }
151
152 JSObject* JSTestSerializedScriptValueInterface::prototype(VM& vm, JSDOMGlobalObject& globalObject)
153 {
154     return getDOMPrototype<JSTestSerializedScriptValueInterface>(vm, globalObject);
155 }
156
157 JSValue JSTestSerializedScriptValueInterface::getConstructor(VM& vm, const JSGlobalObject* globalObject)
158 {
159     return getDOMConstructor<JSTestSerializedScriptValueInterfaceConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
160 }
161
162 void JSTestSerializedScriptValueInterface::destroy(JSC::JSCell* cell)
163 {
164     JSTestSerializedScriptValueInterface* thisObject = static_cast<JSTestSerializedScriptValueInterface*>(cell);
165     thisObject->JSTestSerializedScriptValueInterface::~JSTestSerializedScriptValueInterface();
166 }
167
168 template<> inline JSTestSerializedScriptValueInterface* IDLAttribute<JSTestSerializedScriptValueInterface>::cast(ExecState& state, EncodedJSValue thisValue)
169 {
170     return jsDynamicCast<JSTestSerializedScriptValueInterface*>(state.vm(), JSValue::decode(thisValue));
171 }
172
173 template<> inline JSTestSerializedScriptValueInterface* IDLOperation<JSTestSerializedScriptValueInterface>::cast(ExecState& state)
174 {
175     return jsDynamicCast<JSTestSerializedScriptValueInterface*>(state.vm(), state.thisValue());
176 }
177
178 EncodedJSValue jsTestSerializedScriptValueInterfaceConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
179 {
180     VM& vm = state->vm();
181     auto throwScope = DECLARE_THROW_SCOPE(vm);
182     auto* prototype = jsDynamicCast<JSTestSerializedScriptValueInterfacePrototype*>(vm, JSValue::decode(thisValue));
183     if (UNLIKELY(!prototype))
184         return throwVMTypeError(state, throwScope);
185     return JSValue::encode(JSTestSerializedScriptValueInterface::getConstructor(state->vm(), prototype->globalObject()));
186 }
187
188 bool setJSTestSerializedScriptValueInterfaceConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
189 {
190     VM& vm = state->vm();
191     auto throwScope = DECLARE_THROW_SCOPE(vm);
192     auto* prototype = jsDynamicCast<JSTestSerializedScriptValueInterfacePrototype*>(vm, JSValue::decode(thisValue));
193     if (UNLIKELY(!prototype)) {
194         throwVMTypeError(state, throwScope);
195         return false;
196     }
197     // Shadowing a built-in constructor
198     return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
199 }
200
201 static inline JSValue jsTestSerializedScriptValueInterfaceValueGetter(ExecState& state, JSTestSerializedScriptValueInterface& thisObject, ThrowScope& throwScope)
202 {
203     UNUSED_PARAM(throwScope);
204     UNUSED_PARAM(state);
205     auto& impl = thisObject.wrapped();
206     JSValue result = toJS<IDLSerializedScriptValue<SerializedScriptValue>>(state, *thisObject.globalObject(), throwScope, impl.value());
207     return result;
208 }
209
210 EncodedJSValue jsTestSerializedScriptValueInterfaceValue(ExecState* state, EncodedJSValue thisValue, PropertyName)
211 {
212     return IDLAttribute<JSTestSerializedScriptValueInterface>::get<jsTestSerializedScriptValueInterfaceValueGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "value");
213 }
214
215 static inline bool setJSTestSerializedScriptValueInterfaceValueSetter(ExecState& state, JSTestSerializedScriptValueInterface& thisObject, JSValue value, ThrowScope& throwScope)
216 {
217     UNUSED_PARAM(state);
218     UNUSED_PARAM(throwScope);
219     auto& impl = thisObject.wrapped();
220     auto nativeValue = convert<IDLSerializedScriptValue<SerializedScriptValue>>(state, value);
221     RETURN_IF_EXCEPTION(throwScope, false);
222     AttributeSetter::call(state, throwScope, [&] {
223         return impl.setValue(WTFMove(nativeValue));
224     });
225     return true;
226 }
227
228 bool setJSTestSerializedScriptValueInterfaceValue(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
229 {
230     return IDLAttribute<JSTestSerializedScriptValueInterface>::set<setJSTestSerializedScriptValueInterfaceValueSetter>(*state, thisValue, encodedValue, "value");
231 }
232
233 static inline JSValue jsTestSerializedScriptValueInterfaceReadonlyValueGetter(ExecState& state, JSTestSerializedScriptValueInterface& thisObject, ThrowScope& throwScope)
234 {
235     UNUSED_PARAM(throwScope);
236     UNUSED_PARAM(state);
237     auto& impl = thisObject.wrapped();
238     JSValue result = toJS<IDLSerializedScriptValue<SerializedScriptValue>>(state, *thisObject.globalObject(), throwScope, impl.readonlyValue());
239     return result;
240 }
241
242 EncodedJSValue jsTestSerializedScriptValueInterfaceReadonlyValue(ExecState* state, EncodedJSValue thisValue, PropertyName)
243 {
244     return IDLAttribute<JSTestSerializedScriptValueInterface>::get<jsTestSerializedScriptValueInterfaceReadonlyValueGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "readonlyValue");
245 }
246
247 static inline JSValue jsTestSerializedScriptValueInterfaceCachedValueGetter(ExecState& state, JSTestSerializedScriptValueInterface& thisObject, ThrowScope& throwScope)
248 {
249     UNUSED_PARAM(throwScope);
250     UNUSED_PARAM(state);
251     if (JSValue cachedValue = thisObject.m_cachedValue.get())
252         return cachedValue;
253     auto& impl = thisObject.wrapped();
254     JSValue result = toJS<IDLSerializedScriptValue<SerializedScriptValue>>(state, *thisObject.globalObject(), throwScope, impl.cachedValue());
255     thisObject.m_cachedValue.set(state.vm(), &thisObject, result);
256     return result;
257 }
258
259 EncodedJSValue jsTestSerializedScriptValueInterfaceCachedValue(ExecState* state, EncodedJSValue thisValue, PropertyName)
260 {
261     return IDLAttribute<JSTestSerializedScriptValueInterface>::get<jsTestSerializedScriptValueInterfaceCachedValueGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "cachedValue");
262 }
263
264 static inline bool setJSTestSerializedScriptValueInterfaceCachedValueSetter(ExecState& state, JSTestSerializedScriptValueInterface& thisObject, JSValue value, ThrowScope& throwScope)
265 {
266     UNUSED_PARAM(state);
267     UNUSED_PARAM(throwScope);
268     auto& impl = thisObject.wrapped();
269     auto nativeValue = convert<IDLSerializedScriptValue<SerializedScriptValue>>(state, value);
270     RETURN_IF_EXCEPTION(throwScope, false);
271     AttributeSetter::call(state, throwScope, [&] {
272         return impl.setCachedValue(WTFMove(nativeValue));
273     });
274     return true;
275 }
276
277 bool setJSTestSerializedScriptValueInterfaceCachedValue(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
278 {
279     return IDLAttribute<JSTestSerializedScriptValueInterface>::set<setJSTestSerializedScriptValueInterfaceCachedValueSetter>(*state, thisValue, encodedValue, "cachedValue");
280 }
281
282 static inline JSValue jsTestSerializedScriptValueInterfacePortsGetter(ExecState& state, JSTestSerializedScriptValueInterface& thisObject, ThrowScope& throwScope)
283 {
284     UNUSED_PARAM(throwScope);
285     UNUSED_PARAM(state);
286     auto& impl = thisObject.wrapped();
287     JSValue result = toJS<IDLSequence<IDLInterface<MessagePort>>>(state, *thisObject.globalObject(), throwScope, impl.ports());
288     return result;
289 }
290
291 EncodedJSValue jsTestSerializedScriptValueInterfacePorts(ExecState* state, EncodedJSValue thisValue, PropertyName)
292 {
293     return IDLAttribute<JSTestSerializedScriptValueInterface>::get<jsTestSerializedScriptValueInterfacePortsGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "ports");
294 }
295
296 static inline JSValue jsTestSerializedScriptValueInterfaceCachedReadonlyValueGetter(ExecState& state, JSTestSerializedScriptValueInterface& thisObject, ThrowScope& throwScope)
297 {
298     UNUSED_PARAM(throwScope);
299     UNUSED_PARAM(state);
300     if (JSValue cachedValue = thisObject.m_cachedReadonlyValue.get())
301         return cachedValue;
302     auto& impl = thisObject.wrapped();
303     JSValue result = toJS<IDLSerializedScriptValue<SerializedScriptValue>>(state, *thisObject.globalObject(), throwScope, impl.cachedReadonlyValue());
304     thisObject.m_cachedReadonlyValue.set(state.vm(), &thisObject, result);
305     return result;
306 }
307
308 EncodedJSValue jsTestSerializedScriptValueInterfaceCachedReadonlyValue(ExecState* state, EncodedJSValue thisValue, PropertyName)
309 {
310     return IDLAttribute<JSTestSerializedScriptValueInterface>::get<jsTestSerializedScriptValueInterfaceCachedReadonlyValueGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "cachedReadonlyValue");
311 }
312
313 static inline JSC::EncodedJSValue jsTestSerializedScriptValueInterfacePrototypeFunctionFunctionBody(JSC::ExecState* state, typename IDLOperation<JSTestSerializedScriptValueInterface>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
314 {
315     UNUSED_PARAM(state);
316     UNUSED_PARAM(throwScope);
317     auto& impl = castedThis->wrapped();
318     if (UNLIKELY(state->argumentCount() < 1))
319         return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
320     auto value = convert<IDLSerializedScriptValue<SerializedScriptValue>>(*state, state->uncheckedArgument(0));
321     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
322     impl.function(WTFMove(value));
323     return JSValue::encode(jsUndefined());
324 }
325
326 EncodedJSValue JSC_HOST_CALL jsTestSerializedScriptValueInterfacePrototypeFunctionFunction(JSGlobalObject* globalObject, CallFrame* state)
327 {
328     UNUSED_PARAM(globalObject);
329     return IDLOperation<JSTestSerializedScriptValueInterface>::call<jsTestSerializedScriptValueInterfacePrototypeFunctionFunctionBody>(*state, "function");
330 }
331
332 static inline JSC::EncodedJSValue jsTestSerializedScriptValueInterfacePrototypeFunctionFunctionReturningBody(JSC::ExecState* state, typename IDLOperation<JSTestSerializedScriptValueInterface>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
333 {
334     UNUSED_PARAM(state);
335     UNUSED_PARAM(throwScope);
336     auto& impl = castedThis->wrapped();
337     return JSValue::encode(toJS<IDLSerializedScriptValue<SerializedScriptValue>>(*state, *castedThis->globalObject(), impl.functionReturning()));
338 }
339
340 EncodedJSValue JSC_HOST_CALL jsTestSerializedScriptValueInterfacePrototypeFunctionFunctionReturning(JSGlobalObject* globalObject, CallFrame* state)
341 {
342     UNUSED_PARAM(globalObject);
343     return IDLOperation<JSTestSerializedScriptValueInterface>::call<jsTestSerializedScriptValueInterfacePrototypeFunctionFunctionReturningBody>(*state, "functionReturning");
344 }
345
346 void JSTestSerializedScriptValueInterface::visitChildren(JSCell* cell, SlotVisitor& visitor)
347 {
348     auto* thisObject = jsCast<JSTestSerializedScriptValueInterface*>(cell);
349     ASSERT_GC_OBJECT_INHERITS(thisObject, info());
350     Base::visitChildren(thisObject, visitor);
351     visitor.append(thisObject->m_cachedValue);
352     visitor.append(thisObject->m_cachedReadonlyValue);
353 }
354
355 void JSTestSerializedScriptValueInterface::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
356 {
357     auto* thisObject = jsCast<JSTestSerializedScriptValueInterface*>(cell);
358     analyzer.setWrappedObjectForCell(cell, &thisObject->wrapped());
359     if (thisObject->scriptExecutionContext())
360         analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
361     Base::analyzeHeap(cell, analyzer);
362 }
363
364 bool JSTestSerializedScriptValueInterfaceOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
365 {
366     UNUSED_PARAM(handle);
367     UNUSED_PARAM(visitor);
368     UNUSED_PARAM(reason);
369     return false;
370 }
371
372 void JSTestSerializedScriptValueInterfaceOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
373 {
374     auto* jsTestSerializedScriptValueInterface = static_cast<JSTestSerializedScriptValueInterface*>(handle.slot()->asCell());
375     auto& world = *static_cast<DOMWrapperWorld*>(context);
376     uncacheWrapper(world, &jsTestSerializedScriptValueInterface->wrapped(), jsTestSerializedScriptValueInterface);
377 }
378
379 #if ENABLE(BINDING_INTEGRITY)
380 #if PLATFORM(WIN)
381 #pragma warning(disable: 4483)
382 extern "C" { extern void (*const __identifier("??_7TestSerializedScriptValueInterface@WebCore@@6B@")[])(); }
383 #else
384 extern "C" { extern void* _ZTVN7WebCore34TestSerializedScriptValueInterfaceE[]; }
385 #endif
386 #endif
387
388 JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<TestSerializedScriptValueInterface>&& impl)
389 {
390
391 #if ENABLE(BINDING_INTEGRITY)
392     void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
393 #if PLATFORM(WIN)
394     void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7TestSerializedScriptValueInterface@WebCore@@6B@"));
395 #else
396     void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore34TestSerializedScriptValueInterfaceE[2]);
397 #endif
398
399     // If this fails TestSerializedScriptValueInterface does not have a vtable, so you need to add the
400     // ImplementationLacksVTable attribute to the interface definition
401     static_assert(std::is_polymorphic<TestSerializedScriptValueInterface>::value, "TestSerializedScriptValueInterface is not polymorphic");
402
403     // If you hit this assertion you either have a use after free bug, or
404     // TestSerializedScriptValueInterface has subclasses. If TestSerializedScriptValueInterface has subclasses that get passed
405     // to toJS() we currently require TestSerializedScriptValueInterface you to opt out of binding hardening
406     // by adding the SkipVTableValidation attribute to the interface IDL definition
407     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
408 #endif
409     return createWrapper<TestSerializedScriptValueInterface>(globalObject, WTFMove(impl));
410 }
411
412 JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, TestSerializedScriptValueInterface& impl)
413 {
414     return wrap(state, globalObject, impl);
415 }
416
417 TestSerializedScriptValueInterface* JSTestSerializedScriptValueInterface::toWrapped(JSC::VM& vm, JSC::JSValue value)
418 {
419     if (auto* wrapper = jsDynamicCast<JSTestSerializedScriptValueInterface*>(vm, value))
420         return &wrapper->wrapped();
421     return nullptr;
422 }
423
424 }
425
426 #endif // ENABLE(Condition1) || ENABLE(Condition2)