DOM attributes on prototypes should be configurable
[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 "SerializedScriptValue.h"
31 #include "TestSerializedScriptValueInterface.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 class JSTestSerializedScriptValueInterfaceConstructor : public DOMConstructorObject {
76 private:
77     JSTestSerializedScriptValueInterfaceConstructor(JSC::Structure*, JSDOMGlobalObject*);
78     void finishCreation(JSC::VM&, JSDOMGlobalObject*);
79
80 public:
81     typedef DOMConstructorObject Base;
82     static JSTestSerializedScriptValueInterfaceConstructor* create(JSC::VM& vm, JSC::Structure* structure, JSDOMGlobalObject* globalObject)
83     {
84         JSTestSerializedScriptValueInterfaceConstructor* ptr = new (NotNull, JSC::allocateCell<JSTestSerializedScriptValueInterfaceConstructor>(vm.heap)) JSTestSerializedScriptValueInterfaceConstructor(structure, globalObject);
85         ptr->finishCreation(vm, globalObject);
86         return ptr;
87     }
88
89     DECLARE_INFO;
90     static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
91     {
92         return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
93     }
94 };
95
96 const ClassInfo JSTestSerializedScriptValueInterfaceConstructor::s_info = { "TestSerializedScriptValueInterfaceConstructor", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestSerializedScriptValueInterfaceConstructor) };
97
98 JSTestSerializedScriptValueInterfaceConstructor::JSTestSerializedScriptValueInterfaceConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
99     : DOMConstructorObject(structure, globalObject)
100 {
101 }
102
103 void JSTestSerializedScriptValueInterfaceConstructor::finishCreation(VM& vm, JSDOMGlobalObject* globalObject)
104 {
105     Base::finishCreation(vm);
106     ASSERT(inherits(info()));
107     putDirect(vm, vm.propertyNames->prototype, JSTestSerializedScriptValueInterface::getPrototype(vm, globalObject), DontDelete | ReadOnly | DontEnum);
108     putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("TestSerializedScriptValueInterface"))), ReadOnly | DontEnum);
109     putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum);
110 }
111
112 /* Hash table for prototype */
113
114 static const HashTableValue JSTestSerializedScriptValueInterfacePrototypeTableValues[] =
115 {
116     { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
117     { "value", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializedScriptValueInterfaceValue) } },
118     { "readonlyValue", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceReadonlyValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
119     { "cachedValue", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceCachedValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializedScriptValueInterfaceCachedValue) } },
120     { "ports", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfacePorts), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
121     { "cachedReadonlyValue", 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     releaseImpl();
159 }
160
161 EncodedJSValue jsTestSerializedScriptValueInterfaceValue(ExecState* state, JSObject* slotBase, EncodedJSValue thisValue, PropertyName)
162 {
163     UNUSED_PARAM(state);
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(*state, "TestSerializedScriptValueInterface", "value");
170         return throwGetterTypeError(*state, "TestSerializedScriptValueInterface", "value");
171     }
172     auto& impl = castedThis->impl();
173     JSValue result = impl.value() ? impl.value()->deserialize(state, castedThis->globalObject(), 0) : jsNull();
174     return JSValue::encode(result);
175 }
176
177
178 EncodedJSValue jsTestSerializedScriptValueInterfaceReadonlyValue(ExecState* state, JSObject* slotBase, EncodedJSValue thisValue, PropertyName)
179 {
180     UNUSED_PARAM(state);
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(*state, "TestSerializedScriptValueInterface", "readonlyValue");
187         return throwGetterTypeError(*state, "TestSerializedScriptValueInterface", "readonlyValue");
188     }
189     auto& impl = castedThis->impl();
190     JSValue result = impl.readonlyValue() ? impl.readonlyValue()->deserialize(state, castedThis->globalObject(), 0) : jsNull();
191     return JSValue::encode(result);
192 }
193
194
195 EncodedJSValue jsTestSerializedScriptValueInterfaceCachedValue(ExecState* state, JSObject* slotBase, EncodedJSValue thisValue, PropertyName)
196 {
197     UNUSED_PARAM(state);
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(*state, "TestSerializedScriptValueInterface", "cachedValue");
204         return throwGetterTypeError(*state, "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(state, castedThis->globalObject(), 0) : jsNull();
210     castedThis->m_cachedValue.set(state->vm(), castedThis, result);
211     return JSValue::encode(result);
212 }
213
214
215 EncodedJSValue jsTestSerializedScriptValueInterfacePorts(ExecState* state, JSObject* slotBase, EncodedJSValue thisValue, PropertyName)
216 {
217     UNUSED_PARAM(state);
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(*state, "TestSerializedScriptValueInterface", "ports");
224         return throwGetterTypeError(*state, "TestSerializedScriptValueInterface", "ports");
225     }
226     auto& impl = castedThis->impl();
227     JSValue result = jsArray(state, castedThis->globalObject(), impl.ports());
228     return JSValue::encode(result);
229 }
230
231
232 EncodedJSValue jsTestSerializedScriptValueInterfaceCachedReadonlyValue(ExecState* state, JSObject* slotBase, EncodedJSValue thisValue, PropertyName)
233 {
234     UNUSED_PARAM(state);
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(*state, "TestSerializedScriptValueInterface", "cachedReadonlyValue");
241         return throwGetterTypeError(*state, "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(state, castedThis->globalObject(), 0) : jsNull();
247     castedThis->m_cachedReadonlyValue.set(state->vm(), castedThis, result);
248     return JSValue::encode(result);
249 }
250
251
252 EncodedJSValue jsTestSerializedScriptValueInterfaceConstructor(ExecState* state, JSObject* baseValue, EncodedJSValue, PropertyName)
253 {
254     JSTestSerializedScriptValueInterfacePrototype* domObject = jsDynamicCast<JSTestSerializedScriptValueInterfacePrototype*>(baseValue);
255     if (!domObject)
256         return throwVMTypeError(state);
257     return JSValue::encode(JSTestSerializedScriptValueInterface::getConstructor(state->vm(), domObject->globalObject()));
258 }
259
260 void setJSTestSerializedScriptValueInterfaceValue(ExecState* state, 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(*state, "TestSerializedScriptValueInterface", "value");
268         else
269             throwSetterTypeError(*state, "TestSerializedScriptValueInterface", "value");
270         return;
271     }
272     auto& impl = castedThis->impl();
273     RefPtr<SerializedScriptValue> nativeValue = SerializedScriptValue::create(state, value, 0, 0);
274     if (UNLIKELY(state->hadException()))
275         return;
276     impl.setValue(nativeValue);
277 }
278
279
280 void setJSTestSerializedScriptValueInterfaceCachedValue(ExecState* state, 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(*state, "TestSerializedScriptValueInterface", "cachedValue");
288         else
289             throwSetterTypeError(*state, "TestSerializedScriptValueInterface", "cachedValue");
290         return;
291     }
292     auto& impl = castedThis->impl();
293     RefPtr<SerializedScriptValue> nativeValue = SerializedScriptValue::create(state, value, 0, 0);
294     if (UNLIKELY(state->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::JSCell& cell, void*, SlotVisitor& visitor)
315 {
316     UNUSED_PARAM(cell);
317     UNUSED_PARAM(visitor);
318     return false;
319 }
320
321 void JSTestSerializedScriptValueInterfaceOwner::finalize(JSC::JSCell*& cell, void* context)
322 {
323     auto& wrapper = jsCast<JSTestSerializedScriptValueInterface&>(*cell);
324     auto& world = *static_cast<DOMWrapperWorld*>(context);
325     uncacheWrapper(world, &wrapper.impl(), &wrapper);
326 }
327
328 #if ENABLE(BINDING_INTEGRITY)
329 #if PLATFORM(WIN)
330 #pragma warning(disable: 4483)
331 extern "C" { extern void (*const __identifier("??_7TestSerializedScriptValueInterface@WebCore@@6B@")[])(); }
332 #else
333 extern "C" { extern void* _ZTVN7WebCore34TestSerializedScriptValueInterfaceE[]; }
334 #endif
335 #endif
336
337 JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, TestSerializedScriptValueInterface* impl)
338 {
339     if (!impl)
340         return jsNull();
341     return createNewWrapper<JSTestSerializedScriptValueInterface>(globalObject, impl);
342 }
343
344 JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject* globalObject, TestSerializedScriptValueInterface* impl)
345 {
346     if (!impl)
347         return jsNull();
348     if (JSValue result = getExistingWrapper<JSTestSerializedScriptValueInterface>(globalObject, impl))
349         return result;
350
351 #if ENABLE(BINDING_INTEGRITY)
352     void* actualVTablePointer = *(reinterpret_cast<void**>(impl));
353 #if PLATFORM(WIN)
354     void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7TestSerializedScriptValueInterface@WebCore@@6B@"));
355 #else
356     void* expectedVTablePointer = &_ZTVN7WebCore34TestSerializedScriptValueInterfaceE[2];
357 #if COMPILER(CLANG)
358     // If this fails TestSerializedScriptValueInterface does not have a vtable, so you need to add the
359     // ImplementationLacksVTable attribute to the interface definition
360     COMPILE_ASSERT(__is_polymorphic(TestSerializedScriptValueInterface), TestSerializedScriptValueInterface_is_not_polymorphic);
361 #endif
362 #endif
363     // If you hit this assertion you either have a use after free bug, or
364     // TestSerializedScriptValueInterface has subclasses. If TestSerializedScriptValueInterface has subclasses that get passed
365     // to toJS() we currently require TestSerializedScriptValueInterface you to opt out of binding hardening
366     // by adding the SkipVTableValidation attribute to the interface IDL definition
367     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
368 #endif
369     return createNewWrapper<JSTestSerializedScriptValueInterface>(globalObject, impl);
370 }
371
372 TestSerializedScriptValueInterface* JSTestSerializedScriptValueInterface::toWrapped(JSC::JSValue value)
373 {
374     if (auto* wrapper = jsDynamicCast<JSTestSerializedScriptValueInterface*>(value))
375         return &wrapper->impl();
376     return nullptr;
377 }
378
379 }
380
381 #endif // ENABLE(Condition1) || ENABLE(Condition2)