* bindings/scripts/test/JS/JSTestOverloadedConstructorsWithSequence.cpp:
[WebKit-https.git] / Source / WebCore / bindings / scripts / test / JS / JSTestOverloadedConstructorsWithSequence.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 "JSTestOverloadedConstructorsWithSequence.h"
23
24 #include "ExceptionCode.h"
25 #include "JSDOMBinding.h"
26 #include "JSDOMConstructor.h"
27 #include <runtime/Error.h>
28 #include <runtime/FunctionPrototype.h>
29 #include <wtf/GetPtr.h>
30
31 using namespace JSC;
32
33 namespace WebCore {
34
35 // Attributes
36
37 JSC::EncodedJSValue jsTestOverloadedConstructorsWithSequenceConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
38 bool setJSTestOverloadedConstructorsWithSequenceConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
39
40 class JSTestOverloadedConstructorsWithSequencePrototype : public JSC::JSNonFinalObject {
41 public:
42     typedef JSC::JSNonFinalObject Base;
43     static JSTestOverloadedConstructorsWithSequencePrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
44     {
45         JSTestOverloadedConstructorsWithSequencePrototype* ptr = new (NotNull, JSC::allocateCell<JSTestOverloadedConstructorsWithSequencePrototype>(vm.heap)) JSTestOverloadedConstructorsWithSequencePrototype(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     JSTestOverloadedConstructorsWithSequencePrototype(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<JSTestOverloadedConstructorsWithSequence> JSTestOverloadedConstructorsWithSequenceConstructor;
66
67 static inline EncodedJSValue constructJSTestOverloadedConstructorsWithSequence1(ExecState* state)
68 {
69     auto* castedThis = jsCast<JSTestOverloadedConstructorsWithSequenceConstructor*>(state->callee());
70     auto sequenceOfStrings = state->argument(0).isUndefined() ? Vector<String>() : toNativeArray<String>(*state, state->uncheckedArgument(0));
71     if (UNLIKELY(state->hadException()))
72         return JSValue::encode(jsUndefined());
73     auto object = TestOverloadedConstructorsWithSequence::create(WTFMove(sequenceOfStrings));
74     return JSValue::encode(asObject(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object))));
75 }
76
77 static inline EncodedJSValue constructJSTestOverloadedConstructorsWithSequence2(ExecState* state)
78 {
79     auto* castedThis = jsCast<JSTestOverloadedConstructorsWithSequenceConstructor*>(state->callee());
80     if (UNLIKELY(state->argumentCount() < 1))
81         return throwVMError(state, createNotEnoughArgumentsError(state));
82     auto string = state->argument(0).toWTFString(state);
83     if (UNLIKELY(state->hadException()))
84         return JSValue::encode(jsUndefined());
85     auto object = TestOverloadedConstructorsWithSequence::create(WTFMove(string));
86     return JSValue::encode(asObject(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object))));
87 }
88
89 template<> EncodedJSValue JSC_HOST_CALL JSTestOverloadedConstructorsWithSequenceConstructor::construct(ExecState* state)
90 {
91     size_t argsCount = std::min<size_t>(1, state->argumentCount());
92     if (argsCount == 0) {
93         return constructJSTestOverloadedConstructorsWithSequence1(state);
94     }
95     if (argsCount == 1) {
96         JSValue distinguishingArg = state->uncheckedArgument(0);
97         if (distinguishingArg.isUndefined())
98             return constructJSTestOverloadedConstructorsWithSequence1(state);
99         if (hasIteratorMethod(*state, distinguishingArg))
100             return constructJSTestOverloadedConstructorsWithSequence1(state);
101         return constructJSTestOverloadedConstructorsWithSequence2(state);
102     }
103     return throwVMTypeError(state);
104 }
105
106 template<> JSValue JSTestOverloadedConstructorsWithSequenceConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
107 {
108     UNUSED_PARAM(vm);
109     return globalObject.functionPrototype();
110 }
111
112 template<> void JSTestOverloadedConstructorsWithSequenceConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
113 {
114     putDirect(vm, vm.propertyNames->prototype, JSTestOverloadedConstructorsWithSequence::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum);
115     putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("TestOverloadedConstructorsWithSequence"))), ReadOnly | DontEnum);
116     putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum);
117 }
118
119 template<> const ClassInfo JSTestOverloadedConstructorsWithSequenceConstructor::s_info = { "TestOverloadedConstructorsWithSequence", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestOverloadedConstructorsWithSequenceConstructor) };
120
121 /* Hash table for prototype */
122
123 static const HashTableValue JSTestOverloadedConstructorsWithSequencePrototypeTableValues[] =
124 {
125     { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestOverloadedConstructorsWithSequenceConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestOverloadedConstructorsWithSequenceConstructor) } },
126 };
127
128 const ClassInfo JSTestOverloadedConstructorsWithSequencePrototype::s_info = { "TestOverloadedConstructorsWithSequencePrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestOverloadedConstructorsWithSequencePrototype) };
129
130 void JSTestOverloadedConstructorsWithSequencePrototype::finishCreation(VM& vm)
131 {
132     Base::finishCreation(vm);
133     reifyStaticProperties(vm, JSTestOverloadedConstructorsWithSequencePrototypeTableValues, *this);
134 }
135
136 const ClassInfo JSTestOverloadedConstructorsWithSequence::s_info = { "TestOverloadedConstructorsWithSequence", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestOverloadedConstructorsWithSequence) };
137
138 JSTestOverloadedConstructorsWithSequence::JSTestOverloadedConstructorsWithSequence(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TestOverloadedConstructorsWithSequence>&& impl)
139     : JSDOMWrapper<TestOverloadedConstructorsWithSequence>(structure, globalObject, WTFMove(impl))
140 {
141 }
142
143 JSObject* JSTestOverloadedConstructorsWithSequence::createPrototype(VM& vm, JSGlobalObject* globalObject)
144 {
145     return JSTestOverloadedConstructorsWithSequencePrototype::create(vm, globalObject, JSTestOverloadedConstructorsWithSequencePrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
146 }
147
148 JSObject* JSTestOverloadedConstructorsWithSequence::prototype(VM& vm, JSGlobalObject* globalObject)
149 {
150     return getDOMPrototype<JSTestOverloadedConstructorsWithSequence>(vm, globalObject);
151 }
152
153 void JSTestOverloadedConstructorsWithSequence::destroy(JSC::JSCell* cell)
154 {
155     JSTestOverloadedConstructorsWithSequence* thisObject = static_cast<JSTestOverloadedConstructorsWithSequence*>(cell);
156     thisObject->JSTestOverloadedConstructorsWithSequence::~JSTestOverloadedConstructorsWithSequence();
157 }
158
159 EncodedJSValue jsTestOverloadedConstructorsWithSequenceConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
160 {
161     JSTestOverloadedConstructorsWithSequencePrototype* domObject = jsDynamicCast<JSTestOverloadedConstructorsWithSequencePrototype*>(JSValue::decode(thisValue));
162     if (UNLIKELY(!domObject))
163         return throwVMTypeError(state);
164     return JSValue::encode(JSTestOverloadedConstructorsWithSequence::getConstructor(state->vm(), domObject->globalObject()));
165 }
166
167 bool setJSTestOverloadedConstructorsWithSequenceConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
168 {
169     JSValue value = JSValue::decode(encodedValue);
170     JSTestOverloadedConstructorsWithSequencePrototype* domObject = jsDynamicCast<JSTestOverloadedConstructorsWithSequencePrototype*>(JSValue::decode(thisValue));
171     if (UNLIKELY(!domObject)) {
172         throwVMTypeError(state);
173         return false;
174     }
175     // Shadowing a built-in constructor
176     return domObject->putDirect(state->vm(), state->propertyNames().constructor, value);
177 }
178
179 JSValue JSTestOverloadedConstructorsWithSequence::getConstructor(VM& vm, const JSGlobalObject* globalObject)
180 {
181     return getDOMConstructor<JSTestOverloadedConstructorsWithSequenceConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
182 }
183
184 bool JSTestOverloadedConstructorsWithSequenceOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
185 {
186     UNUSED_PARAM(handle);
187     UNUSED_PARAM(visitor);
188     return false;
189 }
190
191 void JSTestOverloadedConstructorsWithSequenceOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
192 {
193     auto* jsTestOverloadedConstructorsWithSequence = jsCast<JSTestOverloadedConstructorsWithSequence*>(handle.slot()->asCell());
194     auto& world = *static_cast<DOMWrapperWorld*>(context);
195     uncacheWrapper(world, &jsTestOverloadedConstructorsWithSequence->wrapped(), jsTestOverloadedConstructorsWithSequence);
196 }
197
198 #if ENABLE(BINDING_INTEGRITY)
199 #if PLATFORM(WIN)
200 #pragma warning(disable: 4483)
201 extern "C" { extern void (*const __identifier("??_7TestOverloadedConstructorsWithSequence@WebCore@@6B@")[])(); }
202 #else
203 extern "C" { extern void* _ZTVN7WebCore38TestOverloadedConstructorsWithSequenceE[]; }
204 #endif
205 #endif
206
207 JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<TestOverloadedConstructorsWithSequence>&& impl)
208 {
209
210 #if ENABLE(BINDING_INTEGRITY)
211     void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
212 #if PLATFORM(WIN)
213     void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7TestOverloadedConstructorsWithSequence@WebCore@@6B@"));
214 #else
215     void* expectedVTablePointer = &_ZTVN7WebCore38TestOverloadedConstructorsWithSequenceE[2];
216 #if COMPILER(CLANG)
217     // If this fails TestOverloadedConstructorsWithSequence does not have a vtable, so you need to add the
218     // ImplementationLacksVTable attribute to the interface definition
219     static_assert(__is_polymorphic(TestOverloadedConstructorsWithSequence), "TestOverloadedConstructorsWithSequence is not polymorphic");
220 #endif
221 #endif
222     // If you hit this assertion you either have a use after free bug, or
223     // TestOverloadedConstructorsWithSequence has subclasses. If TestOverloadedConstructorsWithSequence has subclasses that get passed
224     // to toJS() we currently require TestOverloadedConstructorsWithSequence you to opt out of binding hardening
225     // by adding the SkipVTableValidation attribute to the interface IDL definition
226     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
227 #endif
228     return createWrapper<JSTestOverloadedConstructorsWithSequence, TestOverloadedConstructorsWithSequence>(globalObject, WTFMove(impl));
229 }
230
231 JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, TestOverloadedConstructorsWithSequence& impl)
232 {
233     return wrap(state, globalObject, impl);
234 }
235
236 TestOverloadedConstructorsWithSequence* JSTestOverloadedConstructorsWithSequence::toWrapped(JSC::JSValue value)
237 {
238     if (auto* wrapper = jsDynamicCast<JSTestOverloadedConstructorsWithSequence*>(value))
239         return &wrapper->wrapped();
240     return nullptr;
241 }
242
243 }