Rationalize JSXXConstructor class definition
[WebKit-https.git] / Source / WebCore / bindings / scripts / test / JS / JSTestOverloadedConstructors.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 "JSTestOverloadedConstructors.h"
23
24 #include "ExceptionCode.h"
25 #include "JSBlob.h"
26 #include "JSDOMBinding.h"
27 #include <runtime/Error.h>
28 #include <wtf/GetPtr.h>
29
30 using namespace JSC;
31
32 namespace WebCore {
33
34 // Attributes
35
36 JSC::EncodedJSValue jsTestOverloadedConstructorsConstructor(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName);
37
38 class JSTestOverloadedConstructorsPrototype : public JSC::JSNonFinalObject {
39 public:
40     typedef JSC::JSNonFinalObject Base;
41     static JSTestOverloadedConstructorsPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
42     {
43         JSTestOverloadedConstructorsPrototype* ptr = new (NotNull, JSC::allocateCell<JSTestOverloadedConstructorsPrototype>(vm.heap)) JSTestOverloadedConstructorsPrototype(vm, globalObject, structure);
44         ptr->finishCreation(vm);
45         return ptr;
46     }
47
48     DECLARE_INFO;
49     static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
50     {
51         return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
52     }
53
54 private:
55     JSTestOverloadedConstructorsPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
56         : JSC::JSNonFinalObject(vm, structure)
57     {
58     }
59
60     void finishCreation(JSC::VM&);
61 };
62
63 class JSTestOverloadedConstructorsConstructor : public DOMConstructorObject {
64 private:
65     JSTestOverloadedConstructorsConstructor(JSC::Structure*, JSDOMGlobalObject&);
66     void finishCreation(JSC::VM&, JSDOMGlobalObject&);
67
68 public:
69     typedef DOMConstructorObject Base;
70     static JSTestOverloadedConstructorsConstructor* create(JSC::VM& vm, JSC::Structure* structure, JSDOMGlobalObject& globalObject)
71     {
72         JSTestOverloadedConstructorsConstructor* ptr = new (NotNull, JSC::allocateCell<JSTestOverloadedConstructorsConstructor>(vm.heap)) JSTestOverloadedConstructorsConstructor(structure, globalObject);
73         ptr->finishCreation(vm, globalObject);
74         return ptr;
75     }
76
77     DECLARE_INFO;
78     static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject& globalObject, JSC::JSValue prototype)
79     {
80         return JSC::Structure::create(vm, &globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
81     }
82 protected:
83     static JSC::EncodedJSValue JSC_HOST_CALL construct(JSC::ExecState*);
84     static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&);
85 };
86
87 static inline EncodedJSValue constructJSTestOverloadedConstructors1(ExecState* state)
88 {
89     auto* castedThis = jsCast<JSTestOverloadedConstructorsConstructor*>(state->callee());
90     if (UNLIKELY(state->argumentCount() < 1))
91         return throwVMError(state, createNotEnoughArgumentsError(state));
92     ArrayBuffer* arrayBuffer = toArrayBuffer(state->argument(0));
93     if (UNLIKELY(state->hadException()))
94         return JSValue::encode(jsUndefined());
95     RefPtr<TestOverloadedConstructors> object = TestOverloadedConstructors::create(arrayBuffer);
96     return JSValue::encode(asObject(toJS(state, castedThis->globalObject(), object.get())));
97 }
98
99 static inline EncodedJSValue constructJSTestOverloadedConstructors2(ExecState* state)
100 {
101     auto* castedThis = jsCast<JSTestOverloadedConstructorsConstructor*>(state->callee());
102     if (UNLIKELY(state->argumentCount() < 1))
103         return throwVMError(state, createNotEnoughArgumentsError(state));
104     RefPtr<ArrayBufferView> arrayBufferView = toArrayBufferView(state->argument(0));
105     if (UNLIKELY(state->hadException()))
106         return JSValue::encode(jsUndefined());
107     RefPtr<TestOverloadedConstructors> object = TestOverloadedConstructors::create(arrayBufferView);
108     return JSValue::encode(asObject(toJS(state, castedThis->globalObject(), object.get())));
109 }
110
111 static inline EncodedJSValue constructJSTestOverloadedConstructors3(ExecState* state)
112 {
113     auto* castedThis = jsCast<JSTestOverloadedConstructorsConstructor*>(state->callee());
114     if (UNLIKELY(state->argumentCount() < 1))
115         return throwVMError(state, createNotEnoughArgumentsError(state));
116     Blob* blob = JSBlob::toWrapped(state->argument(0));
117     if (UNLIKELY(state->hadException()))
118         return JSValue::encode(jsUndefined());
119     RefPtr<TestOverloadedConstructors> object = TestOverloadedConstructors::create(blob);
120     return JSValue::encode(asObject(toJS(state, castedThis->globalObject(), object.get())));
121 }
122
123 static inline EncodedJSValue constructJSTestOverloadedConstructors4(ExecState* state)
124 {
125     auto* castedThis = jsCast<JSTestOverloadedConstructorsConstructor*>(state->callee());
126     if (UNLIKELY(state->argumentCount() < 1))
127         return throwVMError(state, createNotEnoughArgumentsError(state));
128     String string = state->argument(0).toString(state)->value(state);
129     if (UNLIKELY(state->hadException()))
130         return JSValue::encode(jsUndefined());
131     RefPtr<TestOverloadedConstructors> object = TestOverloadedConstructors::create(string);
132     return JSValue::encode(asObject(toJS(state, castedThis->globalObject(), object.get())));
133 }
134
135 static inline EncodedJSValue constructJSTestOverloadedConstructors5(ExecState* state)
136 {
137     auto* castedThis = jsCast<JSTestOverloadedConstructorsConstructor*>(state->callee());
138     Vector<int> longArgs = toNativeArguments<int>(state, 0);
139     if (UNLIKELY(state->hadException()))
140         return JSValue::encode(jsUndefined());
141     RefPtr<TestOverloadedConstructors> object = TestOverloadedConstructors::create(longArgs);
142     return JSValue::encode(asObject(toJS(state, castedThis->globalObject(), object.get())));
143 }
144
145 EncodedJSValue JSC_HOST_CALL JSTestOverloadedConstructorsConstructor::construct(ExecState* state)
146 {
147     size_t argsCount = std::min<size_t>(1, state->argumentCount());
148     JSValue arg0(state->argument(0));
149     if ((argsCount == 1 && ((arg0.isObject() && asObject(arg0)->inherits(JSArrayBuffer::info())))))
150         return constructJSTestOverloadedConstructors1(state);
151     if ((argsCount == 1 && ((arg0.isObject() && asObject(arg0)->inherits(JSArrayBufferView::info())))))
152         return constructJSTestOverloadedConstructors2(state);
153     if ((argsCount == 1 && ((arg0.isObject() && asObject(arg0)->inherits(JSBlob::info())))))
154         return constructJSTestOverloadedConstructors3(state);
155     if (argsCount == 1)
156         return constructJSTestOverloadedConstructors4(state);
157     if ()
158         return constructJSTestOverloadedConstructors5(state);
159     if (argsCount < 1)
160         return throwVMError(state, createNotEnoughArgumentsError(state));
161     return throwVMTypeError(state);
162 }
163
164 const ClassInfo JSTestOverloadedConstructorsConstructor::s_info = { "TestOverloadedConstructorsConstructor", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestOverloadedConstructorsConstructor) };
165
166 JSTestOverloadedConstructorsConstructor::JSTestOverloadedConstructorsConstructor(Structure* structure, JSDOMGlobalObject& globalObject)
167     : Base(structure, globalObject)
168 {
169 }
170
171 void JSTestOverloadedConstructorsConstructor::finishCreation(VM& vm, JSDOMGlobalObject& globalObject)
172 {
173     Base::finishCreation(vm);
174     ASSERT(inherits(info()));
175     putDirect(vm, vm.propertyNames->prototype, JSTestOverloadedConstructors::getPrototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum);
176     putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("TestOverloadedConstructors"))), ReadOnly | DontEnum);
177     putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum);
178 }
179
180 ConstructType JSTestOverloadedConstructorsConstructor::getConstructData(JSCell*, ConstructData& constructData)
181 {
182     constructData.native.function = construct;
183     return ConstructTypeHost;
184 }
185
186 /* Hash table for prototype */
187
188 static const HashTableValue JSTestOverloadedConstructorsPrototypeTableValues[] =
189 {
190     { "constructor", DontEnum | ReadOnly, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestOverloadedConstructorsConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
191 };
192
193 const ClassInfo JSTestOverloadedConstructorsPrototype::s_info = { "TestOverloadedConstructorsPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestOverloadedConstructorsPrototype) };
194
195 void JSTestOverloadedConstructorsPrototype::finishCreation(VM& vm)
196 {
197     Base::finishCreation(vm);
198     reifyStaticProperties(vm, JSTestOverloadedConstructorsPrototypeTableValues, *this);
199 }
200
201 const ClassInfo JSTestOverloadedConstructors::s_info = { "TestOverloadedConstructors", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestOverloadedConstructors) };
202
203 JSTestOverloadedConstructors::JSTestOverloadedConstructors(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TestOverloadedConstructors>&& impl)
204     : JSDOMWrapperWithImplementation<TestOverloadedConstructors>(structure, globalObject, WTF::move(impl))
205 {
206 }
207
208 JSObject* JSTestOverloadedConstructors::createPrototype(VM& vm, JSGlobalObject* globalObject)
209 {
210     return JSTestOverloadedConstructorsPrototype::create(vm, globalObject, JSTestOverloadedConstructorsPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
211 }
212
213 JSObject* JSTestOverloadedConstructors::getPrototype(VM& vm, JSGlobalObject* globalObject)
214 {
215     return getDOMPrototype<JSTestOverloadedConstructors>(vm, globalObject);
216 }
217
218 void JSTestOverloadedConstructors::destroy(JSC::JSCell* cell)
219 {
220     JSTestOverloadedConstructors* thisObject = static_cast<JSTestOverloadedConstructors*>(cell);
221     thisObject->JSTestOverloadedConstructors::~JSTestOverloadedConstructors();
222 }
223
224 EncodedJSValue jsTestOverloadedConstructorsConstructor(ExecState* state, JSObject* baseValue, EncodedJSValue, PropertyName)
225 {
226     JSTestOverloadedConstructorsPrototype* domObject = jsDynamicCast<JSTestOverloadedConstructorsPrototype*>(baseValue);
227     if (!domObject)
228         return throwVMTypeError(state);
229     return JSValue::encode(JSTestOverloadedConstructors::getConstructor(state->vm(), domObject->globalObject()));
230 }
231
232 JSValue JSTestOverloadedConstructors::getConstructor(VM& vm, JSGlobalObject* globalObject)
233 {
234     return getDOMConstructor<JSTestOverloadedConstructorsConstructor>(vm, *jsCast<JSDOMGlobalObject*>(globalObject));
235 }
236
237 bool JSTestOverloadedConstructorsOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
238 {
239     UNUSED_PARAM(handle);
240     UNUSED_PARAM(visitor);
241     return false;
242 }
243
244 void JSTestOverloadedConstructorsOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
245 {
246     auto* jsTestOverloadedConstructors = jsCast<JSTestOverloadedConstructors*>(handle.slot()->asCell());
247     auto& world = *static_cast<DOMWrapperWorld*>(context);
248     uncacheWrapper(world, &jsTestOverloadedConstructors->impl(), jsTestOverloadedConstructors);
249 }
250
251 #if ENABLE(BINDING_INTEGRITY)
252 #if PLATFORM(WIN)
253 #pragma warning(disable: 4483)
254 extern "C" { extern void (*const __identifier("??_7TestOverloadedConstructors@WebCore@@6B@")[])(); }
255 #else
256 extern "C" { extern void* _ZTVN7WebCore26TestOverloadedConstructorsE[]; }
257 #endif
258 #endif
259
260 JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, TestOverloadedConstructors* impl)
261 {
262     if (!impl)
263         return jsNull();
264     return createNewWrapper<JSTestOverloadedConstructors>(globalObject, impl);
265 }
266
267 JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject* globalObject, TestOverloadedConstructors* impl)
268 {
269     if (!impl)
270         return jsNull();
271     if (JSValue result = getExistingWrapper<JSTestOverloadedConstructors>(globalObject, impl))
272         return result;
273
274 #if ENABLE(BINDING_INTEGRITY)
275     void* actualVTablePointer = *(reinterpret_cast<void**>(impl));
276 #if PLATFORM(WIN)
277     void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7TestOverloadedConstructors@WebCore@@6B@"));
278 #else
279     void* expectedVTablePointer = &_ZTVN7WebCore26TestOverloadedConstructorsE[2];
280 #if COMPILER(CLANG)
281     // If this fails TestOverloadedConstructors does not have a vtable, so you need to add the
282     // ImplementationLacksVTable attribute to the interface definition
283     COMPILE_ASSERT(__is_polymorphic(TestOverloadedConstructors), TestOverloadedConstructors_is_not_polymorphic);
284 #endif
285 #endif
286     // If you hit this assertion you either have a use after free bug, or
287     // TestOverloadedConstructors has subclasses. If TestOverloadedConstructors has subclasses that get passed
288     // to toJS() we currently require TestOverloadedConstructors you to opt out of binding hardening
289     // by adding the SkipVTableValidation attribute to the interface IDL definition
290     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
291 #endif
292     return createNewWrapper<JSTestOverloadedConstructors>(globalObject, impl);
293 }
294
295 TestOverloadedConstructors* JSTestOverloadedConstructors::toWrapped(JSC::JSValue value)
296 {
297     if (auto* wrapper = jsDynamicCast<JSTestOverloadedConstructors*>(value))
298         return &wrapper->impl();
299     return nullptr;
300 }
301
302 }