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