Update bindings tests after r181001.
[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 "JSDOMBinding.h"
28 #include "JSMessagePort.h"
29 #include "MessagePort.h"
30 #include "ScriptExecutionContext.h"
31 #include "SerializedScriptValue.h"
32 #include "TestSerializedScriptValueInterface.h"
33 #include <runtime/JSArray.h>
34 #include <wtf/GetPtr.h>
35
36 using namespace JSC;
37
38 namespace WebCore {
39
40 // Attributes
41
42 JSC::EncodedJSValue jsTestSerializedScriptValueInterfaceValue(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName);
43 void setJSTestSerializedScriptValueInterfaceValue(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::EncodedJSValue);
44 JSC::EncodedJSValue jsTestSerializedScriptValueInterfaceReadonlyValue(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName);
45 JSC::EncodedJSValue jsTestSerializedScriptValueInterfaceCachedValue(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName);
46 void setJSTestSerializedScriptValueInterfaceCachedValue(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::EncodedJSValue);
47 JSC::EncodedJSValue jsTestSerializedScriptValueInterfacePorts(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName);
48 JSC::EncodedJSValue jsTestSerializedScriptValueInterfaceCachedReadonlyValue(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName);
49 JSC::EncodedJSValue jsTestSerializedScriptValueInterfaceConstructor(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName);
50
51 class JSTestSerializedScriptValueInterfacePrototype : public JSC::JSNonFinalObject {
52 public:
53     typedef JSC::JSNonFinalObject Base;
54     static JSTestSerializedScriptValueInterfacePrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
55     {
56         JSTestSerializedScriptValueInterfacePrototype* ptr = new (NotNull, JSC::allocateCell<JSTestSerializedScriptValueInterfacePrototype>(vm.heap)) JSTestSerializedScriptValueInterfacePrototype(vm, globalObject, structure);
57         ptr->finishCreation(vm);
58         return ptr;
59     }
60
61     DECLARE_INFO;
62     static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
63     {
64         return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
65     }
66
67 private:
68     JSTestSerializedScriptValueInterfacePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
69         : JSC::JSNonFinalObject(vm, structure)
70     {
71     }
72
73     void finishCreation(JSC::VM&);
74 };
75
76 class JSTestSerializedScriptValueInterfaceConstructor : public DOMConstructorObject {
77 private:
78     JSTestSerializedScriptValueInterfaceConstructor(JSC::Structure*, JSDOMGlobalObject*);
79     void finishCreation(JSC::VM&, JSDOMGlobalObject*);
80
81 public:
82     typedef DOMConstructorObject Base;
83     static JSTestSerializedScriptValueInterfaceConstructor* create(JSC::VM& vm, JSC::Structure* structure, JSDOMGlobalObject* globalObject)
84     {
85         JSTestSerializedScriptValueInterfaceConstructor* ptr = new (NotNull, JSC::allocateCell<JSTestSerializedScriptValueInterfaceConstructor>(vm.heap)) JSTestSerializedScriptValueInterfaceConstructor(structure, globalObject);
86         ptr->finishCreation(vm, globalObject);
87         return ptr;
88     }
89
90     DECLARE_INFO;
91     static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
92     {
93         return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
94     }
95 };
96
97 const ClassInfo JSTestSerializedScriptValueInterfaceConstructor::s_info = { "TestSerializedScriptValueInterfaceConstructor", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestSerializedScriptValueInterfaceConstructor) };
98
99 JSTestSerializedScriptValueInterfaceConstructor::JSTestSerializedScriptValueInterfaceConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
100     : DOMConstructorObject(structure, globalObject)
101 {
102 }
103
104 void JSTestSerializedScriptValueInterfaceConstructor::finishCreation(VM& vm, JSDOMGlobalObject* globalObject)
105 {
106     Base::finishCreation(vm);
107     ASSERT(inherits(info()));
108     putDirect(vm, vm.propertyNames->prototype, JSTestSerializedScriptValueInterface::getPrototype(vm, globalObject), DontDelete | ReadOnly);
109     putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
110 }
111
112 /* Hash table for prototype */
113
114 static const HashTableValue JSTestSerializedScriptValueInterfacePrototypeTableValues[] =
115 {
116     { "constructor", DontEnum | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
117     { "value", DontDelete | CustomAccessor, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializedScriptValueInterfaceValue) },
118     { "readonlyValue", DontDelete | ReadOnly | CustomAccessor, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceReadonlyValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
119     { "cachedValue", DontDelete | CustomAccessor, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceCachedValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializedScriptValueInterfaceCachedValue) },
120     { "ports", DontDelete | ReadOnly | CustomAccessor, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfacePorts), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
121     { "cachedReadonlyValue", DontDelete | ReadOnly | CustomAccessor, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceCachedReadonlyValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
122 };
123
124 const ClassInfo JSTestSerializedScriptValueInterfacePrototype::s_info = { "TestSerializedScriptValueInterfacePrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestSerializedScriptValueInterfacePrototype) };
125
126 void JSTestSerializedScriptValueInterfacePrototype::finishCreation(VM& vm)
127 {
128     Base::finishCreation(vm);
129     reifyStaticProperties(vm, JSTestSerializedScriptValueInterfacePrototypeTableValues, *this);
130 }
131
132 const ClassInfo JSTestSerializedScriptValueInterface::s_info = { "TestSerializedScriptValueInterface", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestSerializedScriptValueInterface) };
133
134 JSTestSerializedScriptValueInterface::JSTestSerializedScriptValueInterface(Structure* structure, JSDOMGlobalObject* globalObject, Ref<TestSerializedScriptValueInterface>&& impl)
135     : JSDOMWrapper(structure, globalObject)
136     , m_impl(&impl.leakRef())
137 {
138 }
139
140 JSObject* JSTestSerializedScriptValueInterface::createPrototype(VM& vm, JSGlobalObject* globalObject)
141 {
142     return JSTestSerializedScriptValueInterfacePrototype::create(vm, globalObject, JSTestSerializedScriptValueInterfacePrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
143 }
144
145 JSObject* JSTestSerializedScriptValueInterface::getPrototype(VM& vm, JSGlobalObject* globalObject)
146 {
147     return getDOMPrototype<JSTestSerializedScriptValueInterface>(vm, globalObject);
148 }
149
150 void JSTestSerializedScriptValueInterface::destroy(JSC::JSCell* cell)
151 {
152     JSTestSerializedScriptValueInterface* thisObject = static_cast<JSTestSerializedScriptValueInterface*>(cell);
153     thisObject->JSTestSerializedScriptValueInterface::~JSTestSerializedScriptValueInterface();
154 }
155
156 JSTestSerializedScriptValueInterface::~JSTestSerializedScriptValueInterface()
157 {
158     releaseImplIfNotNull();
159 }
160
161 EncodedJSValue jsTestSerializedScriptValueInterfaceValue(ExecState* exec, JSObject* slotBase, EncodedJSValue thisValue, PropertyName)
162 {
163     UNUSED_PARAM(exec);
164     UNUSED_PARAM(slotBase);
165     UNUSED_PARAM(thisValue);
166     JSTestSerializedScriptValueInterface* castedThis = jsDynamicCast<JSTestSerializedScriptValueInterface*>(JSValue::decode(thisValue));
167     if (UNLIKELY(!castedThis)) {
168         if (jsDynamicCast<JSTestSerializedScriptValueInterfacePrototype*>(slotBase))
169             return reportDeprecatedGetterError(*exec, "TestSerializedScriptValueInterface", "value");
170         return throwGetterTypeError(*exec, "TestSerializedScriptValueInterface", "value");
171     }
172     auto& impl = castedThis->impl();
173     JSValue result = impl.value() ? impl.value()->deserialize(exec, castedThis->globalObject(), 0) : jsNull();
174     return JSValue::encode(result);
175 }
176
177
178 EncodedJSValue jsTestSerializedScriptValueInterfaceReadonlyValue(ExecState* exec, JSObject* slotBase, EncodedJSValue thisValue, PropertyName)
179 {
180     UNUSED_PARAM(exec);
181     UNUSED_PARAM(slotBase);
182     UNUSED_PARAM(thisValue);
183     JSTestSerializedScriptValueInterface* castedThis = jsDynamicCast<JSTestSerializedScriptValueInterface*>(JSValue::decode(thisValue));
184     if (UNLIKELY(!castedThis)) {
185         if (jsDynamicCast<JSTestSerializedScriptValueInterfacePrototype*>(slotBase))
186             return reportDeprecatedGetterError(*exec, "TestSerializedScriptValueInterface", "readonlyValue");
187         return throwGetterTypeError(*exec, "TestSerializedScriptValueInterface", "readonlyValue");
188     }
189     auto& impl = castedThis->impl();
190     JSValue result = impl.readonlyValue() ? impl.readonlyValue()->deserialize(exec, castedThis->globalObject(), 0) : jsNull();
191     return JSValue::encode(result);
192 }
193
194
195 EncodedJSValue jsTestSerializedScriptValueInterfaceCachedValue(ExecState* exec, JSObject* slotBase, EncodedJSValue thisValue, PropertyName)
196 {
197     UNUSED_PARAM(exec);
198     UNUSED_PARAM(slotBase);
199     UNUSED_PARAM(thisValue);
200     JSTestSerializedScriptValueInterface* castedThis = jsDynamicCast<JSTestSerializedScriptValueInterface*>(JSValue::decode(thisValue));
201     if (UNLIKELY(!castedThis)) {
202         if (jsDynamicCast<JSTestSerializedScriptValueInterfacePrototype*>(slotBase))
203             return reportDeprecatedGetterError(*exec, "TestSerializedScriptValueInterface", "cachedValue");
204         return throwGetterTypeError(*exec, "TestSerializedScriptValueInterface", "cachedValue");
205     }
206     if (JSValue cachedValue = castedThis->m_cachedValue.get())
207         return JSValue::encode(cachedValue);
208     auto& impl = castedThis->impl();
209     JSValue result = impl.cachedValue() ? impl.cachedValue()->deserialize(exec, castedThis->globalObject(), 0) : jsNull();
210     castedThis->m_cachedValue.set(exec->vm(), castedThis, result);
211     return JSValue::encode(result);
212 }
213
214
215 EncodedJSValue jsTestSerializedScriptValueInterfacePorts(ExecState* exec, JSObject* slotBase, EncodedJSValue thisValue, PropertyName)
216 {
217     UNUSED_PARAM(exec);
218     UNUSED_PARAM(slotBase);
219     UNUSED_PARAM(thisValue);
220     JSTestSerializedScriptValueInterface* castedThis = jsDynamicCast<JSTestSerializedScriptValueInterface*>(JSValue::decode(thisValue));
221     if (UNLIKELY(!castedThis)) {
222         if (jsDynamicCast<JSTestSerializedScriptValueInterfacePrototype*>(slotBase))
223             return reportDeprecatedGetterError(*exec, "TestSerializedScriptValueInterface", "ports");
224         return throwGetterTypeError(*exec, "TestSerializedScriptValueInterface", "ports");
225     }
226     auto& impl = castedThis->impl();
227     JSValue result = jsArray(exec, castedThis->globalObject(), impl.ports());
228     return JSValue::encode(result);
229 }
230
231
232 EncodedJSValue jsTestSerializedScriptValueInterfaceCachedReadonlyValue(ExecState* exec, JSObject* slotBase, EncodedJSValue thisValue, PropertyName)
233 {
234     UNUSED_PARAM(exec);
235     UNUSED_PARAM(slotBase);
236     UNUSED_PARAM(thisValue);
237     JSTestSerializedScriptValueInterface* castedThis = jsDynamicCast<JSTestSerializedScriptValueInterface*>(JSValue::decode(thisValue));
238     if (UNLIKELY(!castedThis)) {
239         if (jsDynamicCast<JSTestSerializedScriptValueInterfacePrototype*>(slotBase))
240             return reportDeprecatedGetterError(*exec, "TestSerializedScriptValueInterface", "cachedReadonlyValue");
241         return throwGetterTypeError(*exec, "TestSerializedScriptValueInterface", "cachedReadonlyValue");
242     }
243     if (JSValue cachedValue = castedThis->m_cachedReadonlyValue.get())
244         return JSValue::encode(cachedValue);
245     auto& impl = castedThis->impl();
246     JSValue result = impl.cachedReadonlyValue() ? impl.cachedReadonlyValue()->deserialize(exec, castedThis->globalObject(), 0) : jsNull();
247     castedThis->m_cachedReadonlyValue.set(exec->vm(), castedThis, result);
248     return JSValue::encode(result);
249 }
250
251
252 EncodedJSValue jsTestSerializedScriptValueInterfaceConstructor(ExecState* exec, JSObject* baseValue, EncodedJSValue, PropertyName)
253 {
254     JSTestSerializedScriptValueInterfacePrototype* domObject = jsDynamicCast<JSTestSerializedScriptValueInterfacePrototype*>(baseValue);
255     if (!domObject)
256         return throwVMTypeError(exec);
257     return JSValue::encode(JSTestSerializedScriptValueInterface::getConstructor(exec->vm(), domObject->globalObject()));
258 }
259
260 void setJSTestSerializedScriptValueInterfaceValue(ExecState* exec, JSObject* baseObject, EncodedJSValue thisValue, EncodedJSValue encodedValue)
261 {
262     JSValue value = JSValue::decode(encodedValue);
263     UNUSED_PARAM(baseObject);
264     JSTestSerializedScriptValueInterface* castedThis = jsDynamicCast<JSTestSerializedScriptValueInterface*>(JSValue::decode(thisValue));
265     if (UNLIKELY(!castedThis)) {
266         if (jsDynamicCast<JSTestSerializedScriptValueInterfacePrototype*>(JSValue::decode(thisValue)))
267             reportDeprecatedSetterError(*exec, "TestSerializedScriptValueInterface", "value");
268         else
269             throwSetterTypeError(*exec, "TestSerializedScriptValueInterface", "value");
270         return;
271     }
272     auto& impl = castedThis->impl();
273     RefPtr<SerializedScriptValue> nativeValue(SerializedScriptValue::create(exec, value, 0, 0));
274     if (UNLIKELY(exec->hadException()))
275         return;
276     impl.setValue(nativeValue);
277 }
278
279
280 void setJSTestSerializedScriptValueInterfaceCachedValue(ExecState* exec, JSObject* baseObject, EncodedJSValue thisValue, EncodedJSValue encodedValue)
281 {
282     JSValue value = JSValue::decode(encodedValue);
283     UNUSED_PARAM(baseObject);
284     JSTestSerializedScriptValueInterface* castedThis = jsDynamicCast<JSTestSerializedScriptValueInterface*>(JSValue::decode(thisValue));
285     if (UNLIKELY(!castedThis)) {
286         if (jsDynamicCast<JSTestSerializedScriptValueInterfacePrototype*>(JSValue::decode(thisValue)))
287             reportDeprecatedSetterError(*exec, "TestSerializedScriptValueInterface", "cachedValue");
288         else
289             throwSetterTypeError(*exec, "TestSerializedScriptValueInterface", "cachedValue");
290         return;
291     }
292     auto& impl = castedThis->impl();
293     RefPtr<SerializedScriptValue> nativeValue(SerializedScriptValue::create(exec, value, 0, 0));
294     if (UNLIKELY(exec->hadException()))
295         return;
296     impl.setCachedValue(nativeValue);
297 }
298
299
300 JSValue JSTestSerializedScriptValueInterface::getConstructor(VM& vm, JSGlobalObject* globalObject)
301 {
302     return getDOMConstructor<JSTestSerializedScriptValueInterfaceConstructor>(vm, jsCast<JSDOMGlobalObject*>(globalObject));
303 }
304
305 void JSTestSerializedScriptValueInterface::visitChildren(JSCell* cell, SlotVisitor& visitor)
306 {
307     auto* thisObject = jsCast<JSTestSerializedScriptValueInterface*>(cell);
308     ASSERT_GC_OBJECT_INHERITS(thisObject, info());
309     Base::visitChildren(thisObject, visitor);
310     visitor.append(&thisObject->m_cachedValue);
311     visitor.append(&thisObject->m_cachedReadonlyValue);
312 }
313
314 bool JSTestSerializedScriptValueInterfaceOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
315 {
316     UNUSED_PARAM(handle);
317     UNUSED_PARAM(visitor);
318     return false;
319 }
320
321 void JSTestSerializedScriptValueInterfaceOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
322 {
323     auto* jsTestSerializedScriptValueInterface = jsCast<JSTestSerializedScriptValueInterface*>(handle.slot()->asCell());
324     auto& world = *static_cast<DOMWrapperWorld*>(context);
325     uncacheWrapper(world, &jsTestSerializedScriptValueInterface->impl(), jsTestSerializedScriptValueInterface);
326     jsTestSerializedScriptValueInterface->releaseImpl();
327 }
328
329 #if ENABLE(BINDING_INTEGRITY)
330 #if PLATFORM(WIN)
331 #pragma warning(disable: 4483)
332 extern "C" { extern void (*const __identifier("??_7TestSerializedScriptValueInterface@WebCore@@6B@")[])(); }
333 #else
334 extern "C" { extern void* _ZTVN7WebCore34TestSerializedScriptValueInterfaceE[]; }
335 #endif
336 #endif
337 JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject* globalObject, TestSerializedScriptValueInterface* impl)
338 {
339     if (!impl)
340         return jsNull();
341     if (JSValue result = getExistingWrapper<JSTestSerializedScriptValueInterface>(globalObject, impl))
342         return result;
343
344 #if ENABLE(BINDING_INTEGRITY)
345     void* actualVTablePointer = *(reinterpret_cast<void**>(impl));
346 #if PLATFORM(WIN)
347     void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7TestSerializedScriptValueInterface@WebCore@@6B@"));
348 #else
349     void* expectedVTablePointer = &_ZTVN7WebCore34TestSerializedScriptValueInterfaceE[2];
350 #if COMPILER(CLANG)
351     // If this fails TestSerializedScriptValueInterface does not have a vtable, so you need to add the
352     // ImplementationLacksVTable attribute to the interface definition
353     COMPILE_ASSERT(__is_polymorphic(TestSerializedScriptValueInterface), TestSerializedScriptValueInterface_is_not_polymorphic);
354 #endif
355 #endif
356     // If you hit this assertion you either have a use after free bug, or
357     // TestSerializedScriptValueInterface has subclasses. If TestSerializedScriptValueInterface has subclasses that get passed
358     // to toJS() we currently require TestSerializedScriptValueInterface you to opt out of binding hardening
359     // by adding the SkipVTableValidation attribute to the interface IDL definition
360     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
361 #endif
362     return createNewWrapper<JSTestSerializedScriptValueInterface>(globalObject, impl);
363 }
364
365 TestSerializedScriptValueInterface* JSTestSerializedScriptValueInterface::toWrapped(JSC::JSValue value)
366 {
367     if (auto* wrapper = jsDynamicCast<JSTestSerializedScriptValueInterface*>(value))
368         return &wrapper->impl();
369     return nullptr;
370 }
371
372 }
373
374 #endif // ENABLE(Condition1) || ENABLE(Condition2)