Unreviewed, rolling out r251040.
[WebKit-https.git] / Source / WebCore / bindings / scripts / test / JS / JSTestEventConstructor.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 "JSTestEventConstructor.h"
23
24 #include "JSDOMAttribute.h"
25 #include "JSDOMBinding.h"
26 #include "JSDOMConstructor.h"
27 #include "JSDOMConvertBoolean.h"
28 #include "JSDOMConvertInterface.h"
29 #include "JSDOMConvertStrings.h"
30 #include "JSDOMExceptionHandling.h"
31 #include "JSDOMWrapperCache.h"
32 #include "ScriptExecutionContext.h"
33 #include <JavaScriptCore/HeapAnalyzer.h>
34 #include <JavaScriptCore/JSCInlines.h>
35 #include <wtf/GetPtr.h>
36 #include <wtf/PointerPreparations.h>
37 #include <wtf/URL.h>
38
39
40 namespace WebCore {
41 using namespace JSC;
42
43 template<> TestEventConstructor::Init convertDictionary<TestEventConstructor::Init>(ExecState& state, JSValue value)
44 {
45     VM& vm = state.vm();
46     auto throwScope = DECLARE_THROW_SCOPE(vm);
47     bool isNullOrUndefined = value.isUndefinedOrNull();
48     auto* object = isNullOrUndefined ? nullptr : value.getObject();
49     if (UNLIKELY(!isNullOrUndefined && !object)) {
50         throwTypeError(&state, throwScope);
51         return { };
52     }
53     TestEventConstructor::Init result;
54     JSValue bubblesValue;
55     if (isNullOrUndefined)
56         bubblesValue = jsUndefined();
57     else {
58         bubblesValue = object->get(&state, Identifier::fromString(vm, "bubbles"));
59         RETURN_IF_EXCEPTION(throwScope, { });
60     }
61     if (!bubblesValue.isUndefined()) {
62         result.bubbles = convert<IDLBoolean>(state, bubblesValue);
63         RETURN_IF_EXCEPTION(throwScope, { });
64     } else
65         result.bubbles = false;
66     JSValue cancelableValue;
67     if (isNullOrUndefined)
68         cancelableValue = jsUndefined();
69     else {
70         cancelableValue = object->get(&state, Identifier::fromString(vm, "cancelable"));
71         RETURN_IF_EXCEPTION(throwScope, { });
72     }
73     if (!cancelableValue.isUndefined()) {
74         result.cancelable = convert<IDLBoolean>(state, cancelableValue);
75         RETURN_IF_EXCEPTION(throwScope, { });
76     } else
77         result.cancelable = false;
78     JSValue composedValue;
79     if (isNullOrUndefined)
80         composedValue = jsUndefined();
81     else {
82         composedValue = object->get(&state, Identifier::fromString(vm, "composed"));
83         RETURN_IF_EXCEPTION(throwScope, { });
84     }
85     if (!composedValue.isUndefined()) {
86         result.composed = convert<IDLBoolean>(state, composedValue);
87         RETURN_IF_EXCEPTION(throwScope, { });
88     } else
89         result.composed = false;
90     JSValue attr2Value;
91     if (isNullOrUndefined)
92         attr2Value = jsUndefined();
93     else {
94         attr2Value = object->get(&state, Identifier::fromString(vm, "attr2"));
95         RETURN_IF_EXCEPTION(throwScope, { });
96     }
97     if (!attr2Value.isUndefined()) {
98         result.attr2 = convert<IDLDOMString>(state, attr2Value);
99         RETURN_IF_EXCEPTION(throwScope, { });
100     } else
101         result.attr2 = emptyString();
102 #if ENABLE(SPECIAL_EVENT)
103     JSValue attr3Value;
104     if (isNullOrUndefined)
105         attr3Value = jsUndefined();
106     else {
107         attr3Value = object->get(&state, Identifier::fromString(vm, "attr3"));
108         RETURN_IF_EXCEPTION(throwScope, { });
109     }
110     if (!attr3Value.isUndefined()) {
111         result.attr3 = convert<IDLDOMString>(state, attr3Value);
112         RETURN_IF_EXCEPTION(throwScope, { });
113     } else
114         result.attr3 = emptyString();
115 #endif
116     return result;
117 }
118
119 // Attributes
120
121 JSC::EncodedJSValue jsTestEventConstructorConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
122 bool setJSTestEventConstructorConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
123 JSC::EncodedJSValue jsTestEventConstructorAttr1(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
124 JSC::EncodedJSValue jsTestEventConstructorAttr2(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
125 #if ENABLE(SPECIAL_EVENT)
126 JSC::EncodedJSValue jsTestEventConstructorAttr3(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
127 #endif
128
129 class JSTestEventConstructorPrototype : public JSC::JSNonFinalObject {
130 public:
131     using Base = JSC::JSNonFinalObject;
132     static JSTestEventConstructorPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
133     {
134         JSTestEventConstructorPrototype* ptr = new (NotNull, JSC::allocateCell<JSTestEventConstructorPrototype>(vm.heap)) JSTestEventConstructorPrototype(vm, globalObject, structure);
135         ptr->finishCreation(vm);
136         return ptr;
137     }
138
139     DECLARE_INFO;
140     static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
141     {
142         return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
143     }
144
145 private:
146     JSTestEventConstructorPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
147         : JSC::JSNonFinalObject(vm, structure)
148     {
149     }
150
151     void finishCreation(JSC::VM&);
152 };
153
154 using JSTestEventConstructorConstructor = JSDOMConstructor<JSTestEventConstructor>;
155
156 template<> EncodedJSValue JSC_HOST_CALL JSTestEventConstructorConstructor::construct(JSGlobalObject* globalObject, CallFrame* state)
157 {
158     VM& vm = globalObject->vm();
159     auto throwScope = DECLARE_THROW_SCOPE(vm);
160     UNUSED_PARAM(throwScope);
161     auto* castedThis = jsCast<JSTestEventConstructorConstructor*>(state->jsCallee());
162     ASSERT(castedThis);
163     if (UNLIKELY(state->argumentCount() < 1))
164         return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
165     auto type = convert<IDLDOMString>(*state, state->uncheckedArgument(0));
166     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
167     auto eventInitDict = convert<IDLDictionary<TestEventConstructor::Init>>(*state, state->argument(1));
168     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
169     auto object = TestEventConstructor::create(WTFMove(type), WTFMove(eventInitDict));
170     return JSValue::encode(toJSNewlyCreated<IDLInterface<TestEventConstructor>>(*state, *castedThis->globalObject(), WTFMove(object)));
171 }
172
173 template<> JSValue JSTestEventConstructorConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
174 {
175     return JSEvent::getConstructor(vm, &globalObject);
176 }
177
178 template<> void JSTestEventConstructorConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
179 {
180     putDirect(vm, vm.propertyNames->prototype, JSTestEventConstructor::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
181     putDirect(vm, vm.propertyNames->name, jsNontrivialString(vm, String("TestEventConstructor"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
182     putDirect(vm, vm.propertyNames->length, jsNumber(1), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
183 }
184
185 template<> const ClassInfo JSTestEventConstructorConstructor::s_info = { "TestEventConstructor", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestEventConstructorConstructor) };
186
187 /* Hash table for prototype */
188
189 static const HashTableValue JSTestEventConstructorPrototypeTableValues[] =
190 {
191     { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestEventConstructorConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestEventConstructorConstructor) } },
192     { "attr1", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestEventConstructorAttr1), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
193     { "attr2", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestEventConstructorAttr2), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
194 #if ENABLE(SPECIAL_EVENT)
195     { "attr3", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestEventConstructorAttr3), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
196 #else
197     { 0, 0, NoIntrinsic, { 0, 0 } },
198 #endif
199 };
200
201 const ClassInfo JSTestEventConstructorPrototype::s_info = { "TestEventConstructorPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestEventConstructorPrototype) };
202
203 void JSTestEventConstructorPrototype::finishCreation(VM& vm)
204 {
205     Base::finishCreation(vm);
206     reifyStaticProperties(vm, JSTestEventConstructor::info(), JSTestEventConstructorPrototypeTableValues, *this);
207 }
208
209 const ClassInfo JSTestEventConstructor::s_info = { "TestEventConstructor", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestEventConstructor) };
210
211 JSTestEventConstructor::JSTestEventConstructor(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TestEventConstructor>&& impl)
212     : JSEvent(structure, globalObject, WTFMove(impl))
213 {
214 }
215
216 void JSTestEventConstructor::finishCreation(VM& vm)
217 {
218     Base::finishCreation(vm);
219     ASSERT(inherits(vm, info()));
220
221 }
222
223 JSObject* JSTestEventConstructor::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
224 {
225     return JSTestEventConstructorPrototype::create(vm, &globalObject, JSTestEventConstructorPrototype::createStructure(vm, &globalObject, JSEvent::prototype(vm, globalObject)));
226 }
227
228 JSObject* JSTestEventConstructor::prototype(VM& vm, JSDOMGlobalObject& globalObject)
229 {
230     return getDOMPrototype<JSTestEventConstructor>(vm, globalObject);
231 }
232
233 JSValue JSTestEventConstructor::getConstructor(VM& vm, const JSGlobalObject* globalObject)
234 {
235     return getDOMConstructor<JSTestEventConstructorConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
236 }
237
238 template<> inline JSTestEventConstructor* IDLAttribute<JSTestEventConstructor>::cast(ExecState& state, EncodedJSValue thisValue)
239 {
240     return jsDynamicCast<JSTestEventConstructor*>(state.vm(), JSValue::decode(thisValue));
241 }
242
243 EncodedJSValue jsTestEventConstructorConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
244 {
245     VM& vm = state->vm();
246     auto throwScope = DECLARE_THROW_SCOPE(vm);
247     auto* prototype = jsDynamicCast<JSTestEventConstructorPrototype*>(vm, JSValue::decode(thisValue));
248     if (UNLIKELY(!prototype))
249         return throwVMTypeError(state, throwScope);
250     return JSValue::encode(JSTestEventConstructor::getConstructor(state->vm(), prototype->globalObject()));
251 }
252
253 bool setJSTestEventConstructorConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
254 {
255     VM& vm = state->vm();
256     auto throwScope = DECLARE_THROW_SCOPE(vm);
257     auto* prototype = jsDynamicCast<JSTestEventConstructorPrototype*>(vm, JSValue::decode(thisValue));
258     if (UNLIKELY(!prototype)) {
259         throwVMTypeError(state, throwScope);
260         return false;
261     }
262     // Shadowing a built-in constructor
263     return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
264 }
265
266 static inline JSValue jsTestEventConstructorAttr1Getter(ExecState& state, JSTestEventConstructor& thisObject, ThrowScope& throwScope)
267 {
268     UNUSED_PARAM(throwScope);
269     UNUSED_PARAM(state);
270     auto& impl = thisObject.wrapped();
271     JSValue result = toJS<IDLDOMString>(state, throwScope, impl.attr1());
272     return result;
273 }
274
275 EncodedJSValue jsTestEventConstructorAttr1(ExecState* state, EncodedJSValue thisValue, PropertyName)
276 {
277     return IDLAttribute<JSTestEventConstructor>::get<jsTestEventConstructorAttr1Getter, CastedThisErrorBehavior::Assert>(*state, thisValue, "attr1");
278 }
279
280 static inline JSValue jsTestEventConstructorAttr2Getter(ExecState& state, JSTestEventConstructor& thisObject, ThrowScope& throwScope)
281 {
282     UNUSED_PARAM(throwScope);
283     UNUSED_PARAM(state);
284     auto& impl = thisObject.wrapped();
285     JSValue result = toJS<IDLDOMString>(state, throwScope, impl.attr2());
286     return result;
287 }
288
289 EncodedJSValue jsTestEventConstructorAttr2(ExecState* state, EncodedJSValue thisValue, PropertyName)
290 {
291     return IDLAttribute<JSTestEventConstructor>::get<jsTestEventConstructorAttr2Getter, CastedThisErrorBehavior::Assert>(*state, thisValue, "attr2");
292 }
293
294 #if ENABLE(SPECIAL_EVENT)
295 static inline JSValue jsTestEventConstructorAttr3Getter(ExecState& state, JSTestEventConstructor& thisObject, ThrowScope& throwScope)
296 {
297     UNUSED_PARAM(throwScope);
298     UNUSED_PARAM(state);
299     auto& impl = thisObject.wrapped();
300     JSValue result = toJS<IDLDOMString>(state, throwScope, impl.attr3());
301     return result;
302 }
303
304 EncodedJSValue jsTestEventConstructorAttr3(ExecState* state, EncodedJSValue thisValue, PropertyName)
305 {
306     return IDLAttribute<JSTestEventConstructor>::get<jsTestEventConstructorAttr3Getter, CastedThisErrorBehavior::Assert>(*state, thisValue, "attr3");
307 }
308
309 #endif
310
311 void JSTestEventConstructor::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
312 {
313     auto* thisObject = jsCast<JSTestEventConstructor*>(cell);
314     analyzer.setWrappedObjectForCell(cell, &thisObject->wrapped());
315     if (thisObject->scriptExecutionContext())
316         analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
317     Base::analyzeHeap(cell, analyzer);
318 }
319
320 #if ENABLE(BINDING_INTEGRITY)
321 #if PLATFORM(WIN)
322 #pragma warning(disable: 4483)
323 extern "C" { extern void (*const __identifier("??_7TestEventConstructor@WebCore@@6B@")[])(); }
324 #else
325 extern "C" { extern void* _ZTVN7WebCore20TestEventConstructorE[]; }
326 #endif
327 #endif
328
329 JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<TestEventConstructor>&& impl)
330 {
331
332 #if ENABLE(BINDING_INTEGRITY)
333     void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
334 #if PLATFORM(WIN)
335     void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7TestEventConstructor@WebCore@@6B@"));
336 #else
337     void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore20TestEventConstructorE[2]);
338 #endif
339
340     // If this fails TestEventConstructor does not have a vtable, so you need to add the
341     // ImplementationLacksVTable attribute to the interface definition
342     static_assert(std::is_polymorphic<TestEventConstructor>::value, "TestEventConstructor is not polymorphic");
343
344     // If you hit this assertion you either have a use after free bug, or
345     // TestEventConstructor has subclasses. If TestEventConstructor has subclasses that get passed
346     // to toJS() we currently require TestEventConstructor you to opt out of binding hardening
347     // by adding the SkipVTableValidation attribute to the interface IDL definition
348     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
349 #endif
350     return createWrapper<TestEventConstructor>(globalObject, WTFMove(impl));
351 }
352
353 JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, TestEventConstructor& impl)
354 {
355     return wrap(state, globalObject, impl);
356 }
357
358
359 }