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