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