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