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