[WebIDL] Replace use of __is_polymorphic with standard std::is_polymorphic<>::value
[WebKit.git] / Source / WebCore / bindings / scripts / test / JS / JSTestPromiseRejectionEvent.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 "JSTestPromiseRejectionEvent.h"
23
24 #include "JSDOMAttribute.h"
25 #include "JSDOMBinding.h"
26 #include "JSDOMConstructor.h"
27 #include "JSDOMConvertAny.h"
28 #include "JSDOMConvertBoolean.h"
29 #include "JSDOMConvertInterface.h"
30 #include "JSDOMConvertPromise.h"
31 #include "JSDOMConvertStrings.h"
32 #include "JSDOMExceptionHandling.h"
33 #include "JSDOMPromise.h"
34 #include "JSDOMWrapperCache.h"
35 #include <runtime/JSCInlines.h>
36 #include <wtf/GetPtr.h>
37
38 using namespace JSC;
39
40 namespace WebCore {
41
42 template<> TestPromiseRejectionEvent::Init convertDictionary<TestPromiseRejectionEvent::Init>(ExecState& state, JSValue value)
43 {
44     VM& vm = state.vm();
45     auto throwScope = DECLARE_THROW_SCOPE(vm);
46     bool isNullOrUndefined = value.isUndefinedOrNull();
47     auto* object = isNullOrUndefined ? nullptr : value.getObject();
48     if (UNLIKELY(!isNullOrUndefined && !object)) {
49         throwTypeError(&state, throwScope);
50         return { };
51     }
52     if (UNLIKELY(object && object->type() == RegExpObjectType)) {
53         throwTypeError(&state, throwScope);
54         return { };
55     }
56     TestPromiseRejectionEvent::Init result;
57     JSValue bubblesValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "bubbles"));
58     if (!bubblesValue.isUndefined()) {
59         result.bubbles = convert<IDLBoolean>(state, bubblesValue);
60         RETURN_IF_EXCEPTION(throwScope, { });
61     } else
62         result.bubbles = false;
63     JSValue cancelableValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "cancelable"));
64     if (!cancelableValue.isUndefined()) {
65         result.cancelable = convert<IDLBoolean>(state, cancelableValue);
66         RETURN_IF_EXCEPTION(throwScope, { });
67     } else
68         result.cancelable = false;
69     JSValue composedValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "composed"));
70     if (!composedValue.isUndefined()) {
71         result.composed = convert<IDLBoolean>(state, composedValue);
72         RETURN_IF_EXCEPTION(throwScope, { });
73     } else
74         result.composed = false;
75     JSValue promiseValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "promise"));
76     if (!promiseValue.isUndefined()) {
77         result.promise = convert<IDLPromise<IDLAny>>(state, promiseValue);
78         RETURN_IF_EXCEPTION(throwScope, { });
79     } else {
80         throwRequiredMemberTypeError(state, throwScope, "promise", "TestPromiseRejectionEventInit", "Promise");
81         return { };
82     }
83     JSValue reasonValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "reason"));
84     if (!reasonValue.isUndefined()) {
85         result.reason = convert<IDLAny>(state, reasonValue);
86         RETURN_IF_EXCEPTION(throwScope, { });
87     } else
88         result.reason = jsUndefined();
89     return result;
90 }
91
92 // Attributes
93
94 JSC::EncodedJSValue jsTestPromiseRejectionEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
95 bool setJSTestPromiseRejectionEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
96 JSC::EncodedJSValue jsTestPromiseRejectionEventPromise(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
97 JSC::EncodedJSValue jsTestPromiseRejectionEventReason(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
98
99 class JSTestPromiseRejectionEventPrototype : public JSC::JSNonFinalObject {
100 public:
101     using Base = JSC::JSNonFinalObject;
102     static JSTestPromiseRejectionEventPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
103     {
104         JSTestPromiseRejectionEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSTestPromiseRejectionEventPrototype>(vm.heap)) JSTestPromiseRejectionEventPrototype(vm, globalObject, structure);
105         ptr->finishCreation(vm);
106         return ptr;
107     }
108
109     DECLARE_INFO;
110     static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
111     {
112         return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
113     }
114
115 private:
116     JSTestPromiseRejectionEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
117         : JSC::JSNonFinalObject(vm, structure)
118     {
119     }
120
121     void finishCreation(JSC::VM&);
122 };
123
124 using JSTestPromiseRejectionEventConstructor = JSDOMConstructor<JSTestPromiseRejectionEvent>;
125
126 template<> EncodedJSValue JSC_HOST_CALL JSTestPromiseRejectionEventConstructor::construct(ExecState* state)
127 {
128     VM& vm = state->vm();
129     auto throwScope = DECLARE_THROW_SCOPE(vm);
130     UNUSED_PARAM(throwScope);
131     auto* castedThis = jsCast<JSTestPromiseRejectionEventConstructor*>(state->jsCallee());
132     ASSERT(castedThis);
133     if (UNLIKELY(state->argumentCount() < 2))
134         return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
135     auto type = convert<IDLDOMString>(*state, state->uncheckedArgument(0));
136     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
137     auto eventInitDict = convert<IDLDictionary<TestPromiseRejectionEvent::Init>>(*state, state->uncheckedArgument(1));
138     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
139     auto object = TestPromiseRejectionEvent::create(*state, WTFMove(type), WTFMove(eventInitDict));
140     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
141     return JSValue::encode(toJSNewlyCreated<IDLInterface<TestPromiseRejectionEvent>>(*state, *castedThis->globalObject(), WTFMove(object)));
142 }
143
144 template<> JSValue JSTestPromiseRejectionEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
145 {
146     return JSEvent::getConstructor(vm, &globalObject);
147 }
148
149 template<> void JSTestPromiseRejectionEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
150 {
151     putDirect(vm, vm.propertyNames->prototype, JSTestPromiseRejectionEvent::prototype(vm, globalObject), DontDelete | ReadOnly | DontEnum);
152     putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("TestPromiseRejectionEvent"))), ReadOnly | DontEnum);
153     putDirect(vm, vm.propertyNames->length, jsNumber(2), ReadOnly | DontEnum);
154 }
155
156 template<> const ClassInfo JSTestPromiseRejectionEventConstructor::s_info = { "TestPromiseRejectionEvent", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestPromiseRejectionEventConstructor) };
157
158 /* Hash table for prototype */
159
160 static const HashTableValue JSTestPromiseRejectionEventPrototypeTableValues[] =
161 {
162     { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestPromiseRejectionEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestPromiseRejectionEventConstructor) } },
163     { "promise", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestPromiseRejectionEventPromise), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
164     { "reason", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestPromiseRejectionEventReason), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
165 };
166
167 const ClassInfo JSTestPromiseRejectionEventPrototype::s_info = { "TestPromiseRejectionEventPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestPromiseRejectionEventPrototype) };
168
169 void JSTestPromiseRejectionEventPrototype::finishCreation(VM& vm)
170 {
171     Base::finishCreation(vm);
172     reifyStaticProperties(vm, JSTestPromiseRejectionEventPrototypeTableValues, *this);
173 }
174
175 const ClassInfo JSTestPromiseRejectionEvent::s_info = { "TestPromiseRejectionEvent", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestPromiseRejectionEvent) };
176
177 JSTestPromiseRejectionEvent::JSTestPromiseRejectionEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TestPromiseRejectionEvent>&& impl)
178     : JSEvent(structure, globalObject, WTFMove(impl))
179 {
180 }
181
182 void JSTestPromiseRejectionEvent::finishCreation(VM& vm)
183 {
184     Base::finishCreation(vm);
185     ASSERT(inherits(vm, info()));
186
187 }
188
189 JSObject* JSTestPromiseRejectionEvent::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
190 {
191     return JSTestPromiseRejectionEventPrototype::create(vm, &globalObject, JSTestPromiseRejectionEventPrototype::createStructure(vm, &globalObject, JSEvent::prototype(vm, globalObject)));
192 }
193
194 JSObject* JSTestPromiseRejectionEvent::prototype(VM& vm, JSDOMGlobalObject& globalObject)
195 {
196     return getDOMPrototype<JSTestPromiseRejectionEvent>(vm, globalObject);
197 }
198
199 JSValue JSTestPromiseRejectionEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject)
200 {
201     return getDOMConstructor<JSTestPromiseRejectionEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
202 }
203
204 template<> inline JSTestPromiseRejectionEvent* IDLAttribute<JSTestPromiseRejectionEvent>::cast(ExecState& state, EncodedJSValue thisValue)
205 {
206     return jsDynamicDowncast<JSTestPromiseRejectionEvent*>(state.vm(), JSValue::decode(thisValue));
207 }
208
209 EncodedJSValue jsTestPromiseRejectionEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
210 {
211     VM& vm = state->vm();
212     auto throwScope = DECLARE_THROW_SCOPE(vm);
213     auto* prototype = jsDynamicDowncast<JSTestPromiseRejectionEventPrototype*>(vm, JSValue::decode(thisValue));
214     if (UNLIKELY(!prototype))
215         return throwVMTypeError(state, throwScope);
216     return JSValue::encode(JSTestPromiseRejectionEvent::getConstructor(state->vm(), prototype->globalObject()));
217 }
218
219 bool setJSTestPromiseRejectionEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
220 {
221     VM& vm = state->vm();
222     auto throwScope = DECLARE_THROW_SCOPE(vm);
223     auto* prototype = jsDynamicDowncast<JSTestPromiseRejectionEventPrototype*>(vm, JSValue::decode(thisValue));
224     if (UNLIKELY(!prototype)) {
225         throwVMTypeError(state, throwScope);
226         return false;
227     }
228     // Shadowing a built-in constructor
229     return prototype->putDirect(state->vm(), state->propertyNames().constructor, JSValue::decode(encodedValue));
230 }
231
232 static inline JSValue jsTestPromiseRejectionEventPromiseGetter(ExecState& state, JSTestPromiseRejectionEvent& thisObject, ThrowScope& throwScope)
233 {
234     UNUSED_PARAM(throwScope);
235     UNUSED_PARAM(state);
236     auto& impl = thisObject.wrapped();
237     JSValue result = toJS<IDLPromise<IDLAny>>(impl.promise());
238     return result;
239 }
240
241 EncodedJSValue jsTestPromiseRejectionEventPromise(ExecState* state, EncodedJSValue thisValue, PropertyName)
242 {
243     return IDLAttribute<JSTestPromiseRejectionEvent>::get<jsTestPromiseRejectionEventPromiseGetter, CastedThisErrorBehavior::RejectPromise>(*state, thisValue, "promise");
244 }
245
246 static inline JSValue jsTestPromiseRejectionEventReasonGetter(ExecState& state, JSTestPromiseRejectionEvent& thisObject, ThrowScope& throwScope)
247 {
248     UNUSED_PARAM(throwScope);
249     UNUSED_PARAM(state);
250     auto& impl = thisObject.wrapped();
251     JSValue result = toJS<IDLAny>(impl.reason());
252     return result;
253 }
254
255 EncodedJSValue jsTestPromiseRejectionEventReason(ExecState* state, EncodedJSValue thisValue, PropertyName)
256 {
257     return IDLAttribute<JSTestPromiseRejectionEvent>::get<jsTestPromiseRejectionEventReasonGetter>(*state, thisValue, "reason");
258 }
259
260 #if ENABLE(BINDING_INTEGRITY)
261 #if PLATFORM(WIN)
262 #pragma warning(disable: 4483)
263 extern "C" { extern void (*const __identifier("??_7TestPromiseRejectionEvent@WebCore@@6B@")[])(); }
264 #else
265 extern "C" { extern void* _ZTVN7WebCore25TestPromiseRejectionEventE[]; }
266 #endif
267 #endif
268
269 JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<TestPromiseRejectionEvent>&& impl)
270 {
271
272 #if ENABLE(BINDING_INTEGRITY)
273     void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
274 #if PLATFORM(WIN)
275     void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7TestPromiseRejectionEvent@WebCore@@6B@"));
276 #else
277     void* expectedVTablePointer = &_ZTVN7WebCore25TestPromiseRejectionEventE[2];
278 #endif
279
280     // If this fails TestPromiseRejectionEvent does not have a vtable, so you need to add the
281     // ImplementationLacksVTable attribute to the interface definition
282     static_assert(std::is_polymorphic<TestPromiseRejectionEvent>::value, "TestPromiseRejectionEvent is not polymorphic");
283
284     // If you hit this assertion you either have a use after free bug, or
285     // TestPromiseRejectionEvent has subclasses. If TestPromiseRejectionEvent has subclasses that get passed
286     // to toJS() we currently require TestPromiseRejectionEvent you to opt out of binding hardening
287     // by adding the SkipVTableValidation attribute to the interface IDL definition
288     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
289 #endif
290     return createWrapper<TestPromiseRejectionEvent>(globalObject, WTFMove(impl));
291 }
292
293 JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, TestPromiseRejectionEvent& impl)
294 {
295     return wrap(state, globalObject, impl);
296 }
297
298
299 }