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