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