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