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