GetValueFunc/PutValueFunc should not take both slotBase and thisValue
[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<> void JSTestOverloadedConstructorsConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
145 {
146     putDirect(vm, vm.propertyNames->prototype, JSTestOverloadedConstructors::getPrototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum);
147     putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("TestOverloadedConstructors"))), ReadOnly | DontEnum);
148     putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum);
149 }
150
151 template<> const ClassInfo JSTestOverloadedConstructorsConstructor::s_info = { "TestOverloadedConstructorsConstructor", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestOverloadedConstructorsConstructor) };
152
153 /* Hash table for prototype */
154
155 static const HashTableValue JSTestOverloadedConstructorsPrototypeTableValues[] =
156 {
157     { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestOverloadedConstructorsConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestOverloadedConstructorsConstructor) } },
158 };
159
160 const ClassInfo JSTestOverloadedConstructorsPrototype::s_info = { "TestOverloadedConstructorsPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestOverloadedConstructorsPrototype) };
161
162 void JSTestOverloadedConstructorsPrototype::finishCreation(VM& vm)
163 {
164     Base::finishCreation(vm);
165     reifyStaticProperties(vm, JSTestOverloadedConstructorsPrototypeTableValues, *this);
166 }
167
168 const ClassInfo JSTestOverloadedConstructors::s_info = { "TestOverloadedConstructors", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestOverloadedConstructors) };
169
170 JSTestOverloadedConstructors::JSTestOverloadedConstructors(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TestOverloadedConstructors>&& impl)
171     : JSDOMWrapper<TestOverloadedConstructors>(structure, globalObject, WTFMove(impl))
172 {
173 }
174
175 JSObject* JSTestOverloadedConstructors::createPrototype(VM& vm, JSGlobalObject* globalObject)
176 {
177     return JSTestOverloadedConstructorsPrototype::create(vm, globalObject, JSTestOverloadedConstructorsPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
178 }
179
180 JSObject* JSTestOverloadedConstructors::getPrototype(VM& vm, JSGlobalObject* globalObject)
181 {
182     return getDOMPrototype<JSTestOverloadedConstructors>(vm, globalObject);
183 }
184
185 void JSTestOverloadedConstructors::destroy(JSC::JSCell* cell)
186 {
187     JSTestOverloadedConstructors* thisObject = static_cast<JSTestOverloadedConstructors*>(cell);
188     thisObject->JSTestOverloadedConstructors::~JSTestOverloadedConstructors();
189 }
190
191 EncodedJSValue jsTestOverloadedConstructorsConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
192 {
193     JSTestOverloadedConstructorsPrototype* domObject = jsDynamicCast<JSTestOverloadedConstructorsPrototype*>(JSValue::decode(thisValue));
194     if (!domObject)
195         return throwVMTypeError(state);
196     return JSValue::encode(JSTestOverloadedConstructors::getConstructor(state->vm(), domObject->globalObject()));
197 }
198
199 void setJSTestOverloadedConstructorsConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
200 {
201     JSValue value = JSValue::decode(encodedValue);
202     JSTestOverloadedConstructorsPrototype* domObject = jsDynamicCast<JSTestOverloadedConstructorsPrototype*>(JSValue::decode(thisValue));
203     if (UNLIKELY(!domObject)) {
204         throwVMTypeError(state);
205         return;
206     }
207     // Shadowing a built-in constructor
208     domObject->putDirect(state->vm(), state->propertyNames().constructor, value);
209 }
210
211 JSValue JSTestOverloadedConstructors::getConstructor(VM& vm, JSGlobalObject* globalObject)
212 {
213     return getDOMConstructor<JSTestOverloadedConstructorsConstructor>(vm, *jsCast<JSDOMGlobalObject*>(globalObject));
214 }
215
216 bool JSTestOverloadedConstructorsOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
217 {
218     UNUSED_PARAM(handle);
219     UNUSED_PARAM(visitor);
220     return false;
221 }
222
223 void JSTestOverloadedConstructorsOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
224 {
225     auto* jsTestOverloadedConstructors = jsCast<JSTestOverloadedConstructors*>(handle.slot()->asCell());
226     auto& world = *static_cast<DOMWrapperWorld*>(context);
227     uncacheWrapper(world, &jsTestOverloadedConstructors->wrapped(), jsTestOverloadedConstructors);
228 }
229
230 #if ENABLE(BINDING_INTEGRITY)
231 #if PLATFORM(WIN)
232 #pragma warning(disable: 4483)
233 extern "C" { extern void (*const __identifier("??_7TestOverloadedConstructors@WebCore@@6B@")[])(); }
234 #else
235 extern "C" { extern void* _ZTVN7WebCore26TestOverloadedConstructorsE[]; }
236 #endif
237 #endif
238
239 JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, TestOverloadedConstructors* impl)
240 {
241     if (!impl)
242         return jsNull();
243     return createNewWrapper<JSTestOverloadedConstructors>(globalObject, impl);
244 }
245
246 JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject* globalObject, TestOverloadedConstructors* impl)
247 {
248     if (!impl)
249         return jsNull();
250     if (JSValue result = getExistingWrapper<JSTestOverloadedConstructors>(globalObject, impl))
251         return result;
252
253 #if ENABLE(BINDING_INTEGRITY)
254     void* actualVTablePointer = *(reinterpret_cast<void**>(impl));
255 #if PLATFORM(WIN)
256     void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7TestOverloadedConstructors@WebCore@@6B@"));
257 #else
258     void* expectedVTablePointer = &_ZTVN7WebCore26TestOverloadedConstructorsE[2];
259 #if COMPILER(CLANG)
260     // If this fails TestOverloadedConstructors does not have a vtable, so you need to add the
261     // ImplementationLacksVTable attribute to the interface definition
262     COMPILE_ASSERT(__is_polymorphic(TestOverloadedConstructors), TestOverloadedConstructors_is_not_polymorphic);
263 #endif
264 #endif
265     // If you hit this assertion you either have a use after free bug, or
266     // TestOverloadedConstructors has subclasses. If TestOverloadedConstructors has subclasses that get passed
267     // to toJS() we currently require TestOverloadedConstructors you to opt out of binding hardening
268     // by adding the SkipVTableValidation attribute to the interface IDL definition
269     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
270 #endif
271     return createNewWrapper<JSTestOverloadedConstructors>(globalObject, impl);
272 }
273
274 TestOverloadedConstructors* JSTestOverloadedConstructors::toWrapped(JSC::JSValue value)
275 {
276     if (auto* wrapper = jsDynamicCast<JSTestOverloadedConstructors*>(value))
277         return &wrapper->wrapped();
278     return nullptr;
279 }
280
281 }