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