[WebIDL] Add IDLType based toJS conversion
[WebKit-https.git] / Source / WebCore / bindings / scripts / test / JS / JSTestCEReactions.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 #include "JSTestCEReactions.h"
23
24 #include "CustomElementReactionQueue.h"
25 #include "ExceptionCode.h"
26 #include "HTMLNames.h"
27 #include "JSDOMBinding.h"
28 #include "JSDOMConstructor.h"
29 #include "JSDOMConvert.h"
30 #include "JSTestCEReactionsStringifier.h"
31 #include <runtime/Error.h>
32 #include <runtime/FunctionPrototype.h>
33 #include <wtf/GetPtr.h>
34
35 using namespace JSC;
36
37 namespace WebCore {
38
39 // Functions
40
41 JSC::EncodedJSValue JSC_HOST_CALL jsTestCEReactionsPrototypeFunctionMethodWithCEReactions(JSC::ExecState*);
42
43 // Attributes
44
45 JSC::EncodedJSValue jsTestCEReactionsAttributeWithCEReactions(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
46 bool setJSTestCEReactionsAttributeWithCEReactions(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
47 JSC::EncodedJSValue jsTestCEReactionsReflectAttributeWithCEReactions(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
48 bool setJSTestCEReactionsReflectAttributeWithCEReactions(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
49 JSC::EncodedJSValue jsTestCEReactionsStringifierAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
50 bool setJSTestCEReactionsStringifierAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
51 JSC::EncodedJSValue jsTestCEReactionsConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
52 bool setJSTestCEReactionsConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
53
54 class JSTestCEReactionsPrototype : public JSC::JSNonFinalObject {
55 public:
56     using Base = JSC::JSNonFinalObject;
57     static JSTestCEReactionsPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
58     {
59         JSTestCEReactionsPrototype* ptr = new (NotNull, JSC::allocateCell<JSTestCEReactionsPrototype>(vm.heap)) JSTestCEReactionsPrototype(vm, globalObject, structure);
60         ptr->finishCreation(vm);
61         return ptr;
62     }
63
64     DECLARE_INFO;
65     static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
66     {
67         return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
68     }
69
70 private:
71     JSTestCEReactionsPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
72         : JSC::JSNonFinalObject(vm, structure)
73     {
74     }
75
76     void finishCreation(JSC::VM&);
77 };
78
79 using JSTestCEReactionsConstructor = JSDOMConstructorNotConstructable<JSTestCEReactions>;
80
81 template<> JSValue JSTestCEReactionsConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
82 {
83     UNUSED_PARAM(vm);
84     return globalObject.functionPrototype();
85 }
86
87 template<> void JSTestCEReactionsConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
88 {
89     putDirect(vm, vm.propertyNames->prototype, JSTestCEReactions::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum);
90     putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("TestCEReactions"))), ReadOnly | DontEnum);
91     putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum);
92 }
93
94 template<> const ClassInfo JSTestCEReactionsConstructor::s_info = { "TestCEReactions", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestCEReactionsConstructor) };
95
96 /* Hash table for prototype */
97
98 static const HashTableValue JSTestCEReactionsPrototypeTableValues[] =
99 {
100     { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestCEReactionsConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestCEReactionsConstructor) } },
101     { "attributeWithCEReactions", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestCEReactionsAttributeWithCEReactions), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestCEReactionsAttributeWithCEReactions) } },
102     { "reflectAttributeWithCEReactions", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestCEReactionsReflectAttributeWithCEReactions), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestCEReactionsReflectAttributeWithCEReactions) } },
103     { "stringifierAttribute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestCEReactionsStringifierAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestCEReactionsStringifierAttribute) } },
104     { "methodWithCEReactions", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestCEReactionsPrototypeFunctionMethodWithCEReactions), (intptr_t) (0) } },
105 };
106
107 const ClassInfo JSTestCEReactionsPrototype::s_info = { "TestCEReactionsPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestCEReactionsPrototype) };
108
109 void JSTestCEReactionsPrototype::finishCreation(VM& vm)
110 {
111     Base::finishCreation(vm);
112     reifyStaticProperties(vm, JSTestCEReactionsPrototypeTableValues, *this);
113 }
114
115 const ClassInfo JSTestCEReactions::s_info = { "TestCEReactions", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestCEReactions) };
116
117 JSTestCEReactions::JSTestCEReactions(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TestCEReactions>&& impl)
118     : JSDOMWrapper<TestCEReactions>(structure, globalObject, WTFMove(impl))
119 {
120 }
121
122 JSObject* JSTestCEReactions::createPrototype(VM& vm, JSGlobalObject* globalObject)
123 {
124     return JSTestCEReactionsPrototype::create(vm, globalObject, JSTestCEReactionsPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
125 }
126
127 JSObject* JSTestCEReactions::prototype(VM& vm, JSGlobalObject* globalObject)
128 {
129     return getDOMPrototype<JSTestCEReactions>(vm, globalObject);
130 }
131
132 void JSTestCEReactions::destroy(JSC::JSCell* cell)
133 {
134     JSTestCEReactions* thisObject = static_cast<JSTestCEReactions*>(cell);
135     thisObject->JSTestCEReactions::~JSTestCEReactions();
136 }
137
138 template<> inline JSTestCEReactions* BindingCaller<JSTestCEReactions>::castForAttribute(ExecState&, EncodedJSValue thisValue)
139 {
140     return jsDynamicCast<JSTestCEReactions*>(JSValue::decode(thisValue));
141 }
142
143 template<> inline JSTestCEReactions* BindingCaller<JSTestCEReactions>::castForOperation(ExecState& state)
144 {
145     return jsDynamicCast<JSTestCEReactions*>(state.thisValue());
146 }
147
148 static inline JSValue jsTestCEReactionsAttributeWithCEReactionsGetter(ExecState&, JSTestCEReactions&, ThrowScope& throwScope);
149
150 EncodedJSValue jsTestCEReactionsAttributeWithCEReactions(ExecState* state, EncodedJSValue thisValue, PropertyName)
151 {
152     return BindingCaller<JSTestCEReactions>::attribute<jsTestCEReactionsAttributeWithCEReactionsGetter>(state, thisValue, "attributeWithCEReactions");
153 }
154
155 static inline JSValue jsTestCEReactionsAttributeWithCEReactionsGetter(ExecState& state, JSTestCEReactions& thisObject, ThrowScope& throwScope)
156 {
157     UNUSED_PARAM(throwScope);
158     UNUSED_PARAM(state);
159     auto& impl = thisObject.wrapped();
160     JSValue result = toJS<IDLDOMString>(state, impl.attributeWithCEReactions());
161     return result;
162 }
163
164 static inline JSValue jsTestCEReactionsReflectAttributeWithCEReactionsGetter(ExecState&, JSTestCEReactions&, ThrowScope& throwScope);
165
166 EncodedJSValue jsTestCEReactionsReflectAttributeWithCEReactions(ExecState* state, EncodedJSValue thisValue, PropertyName)
167 {
168     return BindingCaller<JSTestCEReactions>::attribute<jsTestCEReactionsReflectAttributeWithCEReactionsGetter>(state, thisValue, "reflectAttributeWithCEReactions");
169 }
170
171 static inline JSValue jsTestCEReactionsReflectAttributeWithCEReactionsGetter(ExecState& state, JSTestCEReactions& thisObject, ThrowScope& throwScope)
172 {
173     UNUSED_PARAM(throwScope);
174     UNUSED_PARAM(state);
175     auto& impl = thisObject.wrapped();
176     JSValue result = toJS<IDLDOMString>(state, impl.attributeWithoutSynchronization(WebCore::HTMLNames::reflectattributewithcereactionsAttr));
177     return result;
178 }
179
180 static inline JSValue jsTestCEReactionsStringifierAttributeGetter(ExecState&, JSTestCEReactions&, ThrowScope& throwScope);
181
182 EncodedJSValue jsTestCEReactionsStringifierAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName)
183 {
184     return BindingCaller<JSTestCEReactions>::attribute<jsTestCEReactionsStringifierAttributeGetter>(state, thisValue, "stringifierAttribute");
185 }
186
187 static inline JSValue jsTestCEReactionsStringifierAttributeGetter(ExecState& state, JSTestCEReactions& thisObject, ThrowScope& throwScope)
188 {
189     UNUSED_PARAM(throwScope);
190     UNUSED_PARAM(state);
191     auto& impl = thisObject.wrapped();
192     JSValue result = toJS(&state, thisObject.globalObject(), impl.stringifierAttribute());
193     return result;
194 }
195
196 EncodedJSValue jsTestCEReactionsConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
197 {
198     VM& vm = state->vm();
199     auto throwScope = DECLARE_THROW_SCOPE(vm);
200     JSTestCEReactionsPrototype* domObject = jsDynamicCast<JSTestCEReactionsPrototype*>(JSValue::decode(thisValue));
201     if (UNLIKELY(!domObject))
202         return throwVMTypeError(state, throwScope);
203     return JSValue::encode(JSTestCEReactions::getConstructor(state->vm(), domObject->globalObject()));
204 }
205
206 bool setJSTestCEReactionsConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
207 {
208     VM& vm = state->vm();
209     auto throwScope = DECLARE_THROW_SCOPE(vm);
210     JSValue value = JSValue::decode(encodedValue);
211     JSTestCEReactionsPrototype* domObject = jsDynamicCast<JSTestCEReactionsPrototype*>(JSValue::decode(thisValue));
212     if (UNLIKELY(!domObject)) {
213         throwVMTypeError(state, throwScope);
214         return false;
215     }
216     // Shadowing a built-in constructor
217     return domObject->putDirect(state->vm(), state->propertyNames().constructor, value);
218 }
219
220 static inline bool setJSTestCEReactionsAttributeWithCEReactionsFunction(ExecState&, JSTestCEReactions&, JSValue, ThrowScope&);
221
222 bool setJSTestCEReactionsAttributeWithCEReactions(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
223 {
224     return BindingCaller<JSTestCEReactions>::setAttribute<setJSTestCEReactionsAttributeWithCEReactionsFunction>(state, thisValue, encodedValue, "attributeWithCEReactions");
225 }
226
227 static inline bool setJSTestCEReactionsAttributeWithCEReactionsFunction(ExecState& state, JSTestCEReactions& thisObject, JSValue value, ThrowScope& throwScope)
228 {
229     UNUSED_PARAM(state);
230     UNUSED_PARAM(throwScope);
231 #if ENABLE(CUSTOM_ELEMENTS)
232     CustomElementReactionStack customElementReactionStack;
233 #endif
234     auto& impl = thisObject.wrapped();
235     auto nativeValue = value.toWTFString(&state);
236     RETURN_IF_EXCEPTION(throwScope, false);
237     impl.setAttributeWithCEReactions(WTFMove(nativeValue));
238     return true;
239 }
240
241
242 static inline bool setJSTestCEReactionsReflectAttributeWithCEReactionsFunction(ExecState&, JSTestCEReactions&, JSValue, ThrowScope&);
243
244 bool setJSTestCEReactionsReflectAttributeWithCEReactions(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
245 {
246     return BindingCaller<JSTestCEReactions>::setAttribute<setJSTestCEReactionsReflectAttributeWithCEReactionsFunction>(state, thisValue, encodedValue, "reflectAttributeWithCEReactions");
247 }
248
249 static inline bool setJSTestCEReactionsReflectAttributeWithCEReactionsFunction(ExecState& state, JSTestCEReactions& thisObject, JSValue value, ThrowScope& throwScope)
250 {
251     UNUSED_PARAM(state);
252     UNUSED_PARAM(throwScope);
253 #if ENABLE(CUSTOM_ELEMENTS)
254     CustomElementReactionStack customElementReactionStack;
255 #endif
256     auto& impl = thisObject.wrapped();
257     auto nativeValue = value.toWTFString(&state);
258     RETURN_IF_EXCEPTION(throwScope, false);
259     impl.setAttributeWithoutSynchronization(WebCore::HTMLNames::reflectattributewithcereactionsAttr, WTFMove(nativeValue));
260     return true;
261 }
262
263
264 static inline bool setJSTestCEReactionsStringifierAttributeFunction(ExecState&, JSTestCEReactions&, JSValue, ThrowScope&);
265
266 bool setJSTestCEReactionsStringifierAttribute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
267 {
268     return BindingCaller<JSTestCEReactions>::setAttribute<setJSTestCEReactionsStringifierAttributeFunction>(state, thisValue, encodedValue, "stringifierAttribute");
269 }
270
271 static inline bool setJSTestCEReactionsStringifierAttributeFunction(ExecState& state, JSTestCEReactions& thisObject, JSValue value, ThrowScope& throwScope)
272 {
273     UNUSED_PARAM(state);
274     UNUSED_PARAM(throwScope);
275 #if ENABLE(CUSTOM_ELEMENTS)
276     CustomElementReactionStack customElementReactionStack;
277 #endif
278     Ref<TestCEReactionsStringifier> forwardedImpl = thisObject.wrapped().stringifierAttribute();
279     auto& impl = forwardedImpl.get();
280     auto nativeValue = value.toWTFString(&state);
281     RETURN_IF_EXCEPTION(throwScope, false);
282     impl.setValue(WTFMove(nativeValue));
283     return true;
284 }
285
286
287 JSValue JSTestCEReactions::getConstructor(VM& vm, const JSGlobalObject* globalObject)
288 {
289     return getDOMConstructor<JSTestCEReactionsConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
290 }
291
292 static inline JSC::EncodedJSValue jsTestCEReactionsPrototypeFunctionMethodWithCEReactionsCaller(JSC::ExecState*, JSTestCEReactions*, JSC::ThrowScope&);
293
294 EncodedJSValue JSC_HOST_CALL jsTestCEReactionsPrototypeFunctionMethodWithCEReactions(ExecState* state)
295 {
296 #if ENABLE(CUSTOM_ELEMENTS)
297     CustomElementReactionStack customElementReactionStack;
298 #endif
299     return BindingCaller<JSTestCEReactions>::callOperation<jsTestCEReactionsPrototypeFunctionMethodWithCEReactionsCaller>(state, "methodWithCEReactions");
300 }
301
302 static inline JSC::EncodedJSValue jsTestCEReactionsPrototypeFunctionMethodWithCEReactionsCaller(JSC::ExecState* state, JSTestCEReactions* castedThis, JSC::ThrowScope& throwScope)
303 {
304     UNUSED_PARAM(state);
305     UNUSED_PARAM(throwScope);
306     auto& impl = castedThis->wrapped();
307     impl.methodWithCEReactions();
308     return JSValue::encode(jsUndefined());
309 }
310
311 bool JSTestCEReactionsOwner::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 JSTestCEReactionsOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
319 {
320     auto* jsTestCEReactions = jsCast<JSTestCEReactions*>(handle.slot()->asCell());
321     auto& world = *static_cast<DOMWrapperWorld*>(context);
322     uncacheWrapper(world, &jsTestCEReactions->wrapped(), jsTestCEReactions);
323 }
324
325 #if ENABLE(BINDING_INTEGRITY)
326 #if PLATFORM(WIN)
327 #pragma warning(disable: 4483)
328 extern "C" { extern void (*const __identifier("??_7TestCEReactions@WebCore@@6B@")[])(); }
329 #else
330 extern "C" { extern void* _ZTVN7WebCore15TestCEReactionsE[]; }
331 #endif
332 #endif
333
334 JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<TestCEReactions>&& 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("??_7TestCEReactions@WebCore@@6B@"));
341 #else
342     void* expectedVTablePointer = &_ZTVN7WebCore15TestCEReactionsE[2];
343 #if COMPILER(CLANG)
344     // If this fails TestCEReactions does not have a vtable, so you need to add the
345     // ImplementationLacksVTable attribute to the interface definition
346     static_assert(__is_polymorphic(TestCEReactions), "TestCEReactions is not polymorphic");
347 #endif
348 #endif
349     // If you hit this assertion you either have a use after free bug, or
350     // TestCEReactions has subclasses. If TestCEReactions has subclasses that get passed
351     // to toJS() we currently require TestCEReactions 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<TestCEReactions>(globalObject, WTFMove(impl));
356 }
357
358 JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, TestCEReactions& impl)
359 {
360     return wrap(state, globalObject, impl);
361 }
362
363 TestCEReactions* JSTestCEReactions::toWrapped(JSC::JSValue value)
364 {
365     if (auto* wrapper = jsDynamicCast<JSTestCEReactions*>(value))
366         return &wrapper->wrapped();
367     return nullptr;
368 }
369
370 }