Fix the binding generator after r190785
[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* cell, ConstructData& constructData)
181 {
182     UNUSED_PARAM(cell);
183     constructData.native.function = construct;
184     return ConstructTypeHost;
185 }
186
187 /* Hash table for prototype */
188
189 static const HashTableValue JSTestOverloadedConstructorsPrototypeTableValues[] =
190 {
191     { "constructor", DontEnum | ReadOnly, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestOverloadedConstructorsConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
192 };
193
194 const ClassInfo JSTestOverloadedConstructorsPrototype::s_info = { "TestOverloadedConstructorsPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestOverloadedConstructorsPrototype) };
195
196 void JSTestOverloadedConstructorsPrototype::finishCreation(VM& vm)
197 {
198     Base::finishCreation(vm);
199     reifyStaticProperties(vm, JSTestOverloadedConstructorsPrototypeTableValues, *this);
200 }
201
202 const ClassInfo JSTestOverloadedConstructors::s_info = { "TestOverloadedConstructors", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestOverloadedConstructors) };
203
204 JSTestOverloadedConstructors::JSTestOverloadedConstructors(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TestOverloadedConstructors>&& impl)
205     : JSDOMWrapperWithImplementation<TestOverloadedConstructors>(structure, globalObject, WTF::move(impl))
206 {
207 }
208
209 JSObject* JSTestOverloadedConstructors::createPrototype(VM& vm, JSGlobalObject* globalObject)
210 {
211     return JSTestOverloadedConstructorsPrototype::create(vm, globalObject, JSTestOverloadedConstructorsPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
212 }
213
214 JSObject* JSTestOverloadedConstructors::getPrototype(VM& vm, JSGlobalObject* globalObject)
215 {
216     return getDOMPrototype<JSTestOverloadedConstructors>(vm, globalObject);
217 }
218
219 void JSTestOverloadedConstructors::destroy(JSC::JSCell* cell)
220 {
221     JSTestOverloadedConstructors* thisObject = static_cast<JSTestOverloadedConstructors*>(cell);
222     thisObject->JSTestOverloadedConstructors::~JSTestOverloadedConstructors();
223 }
224
225 EncodedJSValue jsTestOverloadedConstructorsConstructor(ExecState* state, JSObject* baseValue, EncodedJSValue, PropertyName)
226 {
227     JSTestOverloadedConstructorsPrototype* domObject = jsDynamicCast<JSTestOverloadedConstructorsPrototype*>(baseValue);
228     if (!domObject)
229         return throwVMTypeError(state);
230     return JSValue::encode(JSTestOverloadedConstructors::getConstructor(state->vm(), domObject->globalObject()));
231 }
232
233 JSValue JSTestOverloadedConstructors::getConstructor(VM& vm, JSGlobalObject* globalObject)
234 {
235     return getDOMConstructor<JSTestOverloadedConstructorsConstructor>(vm, *jsCast<JSDOMGlobalObject*>(globalObject));
236 }
237
238 bool JSTestOverloadedConstructorsOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
239 {
240     UNUSED_PARAM(handle);
241     UNUSED_PARAM(visitor);
242     return false;
243 }
244
245 void JSTestOverloadedConstructorsOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
246 {
247     auto* jsTestOverloadedConstructors = jsCast<JSTestOverloadedConstructors*>(handle.slot()->asCell());
248     auto& world = *static_cast<DOMWrapperWorld*>(context);
249     uncacheWrapper(world, &jsTestOverloadedConstructors->impl(), jsTestOverloadedConstructors);
250 }
251
252 #if ENABLE(BINDING_INTEGRITY)
253 #if PLATFORM(WIN)
254 #pragma warning(disable: 4483)
255 extern "C" { extern void (*const __identifier("??_7TestOverloadedConstructors@WebCore@@6B@")[])(); }
256 #else
257 extern "C" { extern void* _ZTVN7WebCore26TestOverloadedConstructorsE[]; }
258 #endif
259 #endif
260
261 JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, TestOverloadedConstructors* impl)
262 {
263     if (!impl)
264         return jsNull();
265     return createNewWrapper<JSTestOverloadedConstructors>(globalObject, impl);
266 }
267
268 JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject* globalObject, TestOverloadedConstructors* impl)
269 {
270     if (!impl)
271         return jsNull();
272     if (JSValue result = getExistingWrapper<JSTestOverloadedConstructors>(globalObject, impl))
273         return result;
274
275 #if ENABLE(BINDING_INTEGRITY)
276     void* actualVTablePointer = *(reinterpret_cast<void**>(impl));
277 #if PLATFORM(WIN)
278     void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7TestOverloadedConstructors@WebCore@@6B@"));
279 #else
280     void* expectedVTablePointer = &_ZTVN7WebCore26TestOverloadedConstructorsE[2];
281 #if COMPILER(CLANG)
282     // If this fails TestOverloadedConstructors does not have a vtable, so you need to add the
283     // ImplementationLacksVTable attribute to the interface definition
284     COMPILE_ASSERT(__is_polymorphic(TestOverloadedConstructors), TestOverloadedConstructors_is_not_polymorphic);
285 #endif
286 #endif
287     // If you hit this assertion you either have a use after free bug, or
288     // TestOverloadedConstructors has subclasses. If TestOverloadedConstructors has subclasses that get passed
289     // to toJS() we currently require TestOverloadedConstructors you to opt out of binding hardening
290     // by adding the SkipVTableValidation attribute to the interface IDL definition
291     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
292 #endif
293     return createNewWrapper<JSTestOverloadedConstructors>(globalObject, impl);
294 }
295
296 TestOverloadedConstructors* JSTestOverloadedConstructors::toWrapped(JSC::JSValue value)
297 {
298     if (auto* wrapper = jsDynamicCast<JSTestOverloadedConstructors*>(value))
299         return &wrapper->impl();
300     return nullptr;
301 }
302
303 }