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