All prototypes should call didBecomePrototype()
[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 "JSDOMBinding.h"
25 #include "JSDOMConstructor.h"
26 #include "JSDOMConvertInterface.h"
27 #include "JSDOMConvertSequences.h"
28 #include "JSDOMConvertStrings.h"
29 #include "JSDOMExceptionHandling.h"
30 #include "JSDOMWrapperCache.h"
31 #include "ScriptExecutionContext.h"
32 #include <JavaScriptCore/FunctionPrototype.h>
33 #include <JavaScriptCore/HeapSnapshotBuilder.h>
34 #include <JavaScriptCore/IteratorOperations.h>
35 #include <JavaScriptCore/JSArray.h>
36 #include <JavaScriptCore/JSCInlines.h>
37 #include <wtf/GetPtr.h>
38 #include <wtf/PointerPreparations.h>
39 #include <wtf/URL.h>
40
41
42 namespace WebCore {
43 using namespace JSC;
44
45 // Attributes
46
47 JSC::EncodedJSValue jsTestOverloadedConstructorsWithSequenceConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
48 bool setJSTestOverloadedConstructorsWithSequenceConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
49
50 class JSTestOverloadedConstructorsWithSequencePrototype : public JSC::JSNonFinalObject {
51 public:
52     using Base = JSC::JSNonFinalObject;
53     static JSTestOverloadedConstructorsWithSequencePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
54     {
55         JSTestOverloadedConstructorsWithSequencePrototype* ptr = new (NotNull, JSC::allocateCell<JSTestOverloadedConstructorsWithSequencePrototype>(vm.heap)) JSTestOverloadedConstructorsWithSequencePrototype(vm, globalObject, structure);
56         ptr->finishCreation(vm);
57         return ptr;
58     }
59
60     DECLARE_INFO;
61     static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
62     {
63         return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
64     }
65
66 private:
67     JSTestOverloadedConstructorsWithSequencePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
68         : JSC::JSNonFinalObject(vm, structure)
69     {
70         didBecomePrototype();
71     }
72
73     void finishCreation(JSC::VM&);
74 };
75
76 using JSTestOverloadedConstructorsWithSequenceConstructor = JSDOMConstructor<JSTestOverloadedConstructorsWithSequence>;
77
78 static inline EncodedJSValue constructJSTestOverloadedConstructorsWithSequence1(ExecState* state)
79 {
80     VM& vm = state->vm();
81     auto throwScope = DECLARE_THROW_SCOPE(vm);
82     UNUSED_PARAM(throwScope);
83     auto* castedThis = jsCast<JSTestOverloadedConstructorsWithSequenceConstructor*>(state->jsCallee());
84     ASSERT(castedThis);
85     auto sequenceOfStrings = state->argument(0).isUndefined() ? Converter<IDLSequence<IDLDOMString>>::ReturnType{ } : convert<IDLSequence<IDLDOMString>>(*state, state->uncheckedArgument(0));
86     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
87     auto object = TestOverloadedConstructorsWithSequence::create(WTFMove(sequenceOfStrings));
88     return JSValue::encode(toJSNewlyCreated<IDLInterface<TestOverloadedConstructorsWithSequence>>(*state, *castedThis->globalObject(), WTFMove(object)));
89 }
90
91 static inline EncodedJSValue constructJSTestOverloadedConstructorsWithSequence2(ExecState* state)
92 {
93     VM& vm = state->vm();
94     auto throwScope = DECLARE_THROW_SCOPE(vm);
95     UNUSED_PARAM(throwScope);
96     auto* castedThis = jsCast<JSTestOverloadedConstructorsWithSequenceConstructor*>(state->jsCallee());
97     ASSERT(castedThis);
98     auto string = convert<IDLDOMString>(*state, state->uncheckedArgument(0));
99     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
100     auto object = TestOverloadedConstructorsWithSequence::create(WTFMove(string));
101     return JSValue::encode(toJSNewlyCreated<IDLInterface<TestOverloadedConstructorsWithSequence>>(*state, *castedThis->globalObject(), WTFMove(object)));
102 }
103
104 template<> EncodedJSValue JSC_HOST_CALL JSTestOverloadedConstructorsWithSequenceConstructor::construct(ExecState* state)
105 {
106     VM& vm = state->vm();
107     auto throwScope = DECLARE_THROW_SCOPE(vm);
108     UNUSED_PARAM(throwScope);
109     size_t argsCount = std::min<size_t>(1, state->argumentCount());
110     if (argsCount == 0) {
111         return constructJSTestOverloadedConstructorsWithSequence1(state);
112     }
113     if (argsCount == 1) {
114         JSValue distinguishingArg = state->uncheckedArgument(0);
115         if (distinguishingArg.isUndefined())
116             return constructJSTestOverloadedConstructorsWithSequence1(state);
117         if (hasIteratorMethod(*state, distinguishingArg))
118             return constructJSTestOverloadedConstructorsWithSequence1(state);
119         return constructJSTestOverloadedConstructorsWithSequence2(state);
120     }
121     return throwVMTypeError(state, throwScope);
122 }
123
124 template<> JSValue JSTestOverloadedConstructorsWithSequenceConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
125 {
126     UNUSED_PARAM(vm);
127     return globalObject.functionPrototype();
128 }
129
130 template<> void JSTestOverloadedConstructorsWithSequenceConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
131 {
132     putDirect(vm, vm.propertyNames->prototype, JSTestOverloadedConstructorsWithSequence::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
133     putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("TestOverloadedConstructorsWithSequence"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
134     putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
135 }
136
137 template<> const ClassInfo JSTestOverloadedConstructorsWithSequenceConstructor::s_info = { "TestOverloadedConstructorsWithSequence", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestOverloadedConstructorsWithSequenceConstructor) };
138
139 /* Hash table for prototype */
140
141 static const HashTableValue JSTestOverloadedConstructorsWithSequencePrototypeTableValues[] =
142 {
143     { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestOverloadedConstructorsWithSequenceConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestOverloadedConstructorsWithSequenceConstructor) } },
144 };
145
146 const ClassInfo JSTestOverloadedConstructorsWithSequencePrototype::s_info = { "TestOverloadedConstructorsWithSequencePrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestOverloadedConstructorsWithSequencePrototype) };
147
148 void JSTestOverloadedConstructorsWithSequencePrototype::finishCreation(VM& vm)
149 {
150     Base::finishCreation(vm);
151     reifyStaticProperties(vm, JSTestOverloadedConstructorsWithSequence::info(), JSTestOverloadedConstructorsWithSequencePrototypeTableValues, *this);
152 }
153
154 const ClassInfo JSTestOverloadedConstructorsWithSequence::s_info = { "TestOverloadedConstructorsWithSequence", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestOverloadedConstructorsWithSequence) };
155
156 JSTestOverloadedConstructorsWithSequence::JSTestOverloadedConstructorsWithSequence(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TestOverloadedConstructorsWithSequence>&& impl)
157     : JSDOMWrapper<TestOverloadedConstructorsWithSequence>(structure, globalObject, WTFMove(impl))
158 {
159 }
160
161 void JSTestOverloadedConstructorsWithSequence::finishCreation(VM& vm)
162 {
163     Base::finishCreation(vm);
164     ASSERT(inherits(vm, info()));
165
166 }
167
168 JSObject* JSTestOverloadedConstructorsWithSequence::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
169 {
170     return JSTestOverloadedConstructorsWithSequencePrototype::create(vm, &globalObject, JSTestOverloadedConstructorsWithSequencePrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
171 }
172
173 JSObject* JSTestOverloadedConstructorsWithSequence::prototype(VM& vm, JSDOMGlobalObject& globalObject)
174 {
175     return getDOMPrototype<JSTestOverloadedConstructorsWithSequence>(vm, globalObject);
176 }
177
178 JSValue JSTestOverloadedConstructorsWithSequence::getConstructor(VM& vm, const JSGlobalObject* globalObject)
179 {
180     return getDOMConstructor<JSTestOverloadedConstructorsWithSequenceConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
181 }
182
183 void JSTestOverloadedConstructorsWithSequence::destroy(JSC::JSCell* cell)
184 {
185     JSTestOverloadedConstructorsWithSequence* thisObject = static_cast<JSTestOverloadedConstructorsWithSequence*>(cell);
186     thisObject->JSTestOverloadedConstructorsWithSequence::~JSTestOverloadedConstructorsWithSequence();
187 }
188
189 EncodedJSValue jsTestOverloadedConstructorsWithSequenceConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
190 {
191     VM& vm = state->vm();
192     auto throwScope = DECLARE_THROW_SCOPE(vm);
193     auto* prototype = jsDynamicCast<JSTestOverloadedConstructorsWithSequencePrototype*>(vm, JSValue::decode(thisValue));
194     if (UNLIKELY(!prototype))
195         return throwVMTypeError(state, throwScope);
196     return JSValue::encode(JSTestOverloadedConstructorsWithSequence::getConstructor(state->vm(), prototype->globalObject()));
197 }
198
199 bool setJSTestOverloadedConstructorsWithSequenceConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
200 {
201     VM& vm = state->vm();
202     auto throwScope = DECLARE_THROW_SCOPE(vm);
203     auto* prototype = jsDynamicCast<JSTestOverloadedConstructorsWithSequencePrototype*>(vm, JSValue::decode(thisValue));
204     if (UNLIKELY(!prototype)) {
205         throwVMTypeError(state, throwScope);
206         return false;
207     }
208     // Shadowing a built-in constructor
209     return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
210 }
211
212 void JSTestOverloadedConstructorsWithSequence::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
213 {
214     auto* thisObject = jsCast<JSTestOverloadedConstructorsWithSequence*>(cell);
215     builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
216     if (thisObject->scriptExecutionContext())
217         builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
218     Base::heapSnapshot(cell, builder);
219 }
220
221 bool JSTestOverloadedConstructorsWithSequenceOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
222 {
223     UNUSED_PARAM(handle);
224     UNUSED_PARAM(visitor);
225     UNUSED_PARAM(reason);
226     return false;
227 }
228
229 void JSTestOverloadedConstructorsWithSequenceOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
230 {
231     auto* jsTestOverloadedConstructorsWithSequence = static_cast<JSTestOverloadedConstructorsWithSequence*>(handle.slot()->asCell());
232     auto& world = *static_cast<DOMWrapperWorld*>(context);
233     uncacheWrapper(world, &jsTestOverloadedConstructorsWithSequence->wrapped(), jsTestOverloadedConstructorsWithSequence);
234 }
235
236 #if ENABLE(BINDING_INTEGRITY)
237 #if PLATFORM(WIN)
238 #pragma warning(disable: 4483)
239 extern "C" { extern void (*const __identifier("??_7TestOverloadedConstructorsWithSequence@WebCore@@6B@")[])(); }
240 #else
241 extern "C" { extern void* _ZTVN7WebCore38TestOverloadedConstructorsWithSequenceE[]; }
242 #endif
243 #endif
244
245 JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<TestOverloadedConstructorsWithSequence>&& impl)
246 {
247
248 #if ENABLE(BINDING_INTEGRITY)
249     void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
250 #if PLATFORM(WIN)
251     void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7TestOverloadedConstructorsWithSequence@WebCore@@6B@"));
252 #else
253     void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore38TestOverloadedConstructorsWithSequenceE[2]);
254 #endif
255
256     // If this fails TestOverloadedConstructorsWithSequence does not have a vtable, so you need to add the
257     // ImplementationLacksVTable attribute to the interface definition
258     static_assert(std::is_polymorphic<TestOverloadedConstructorsWithSequence>::value, "TestOverloadedConstructorsWithSequence is not polymorphic");
259
260     // If you hit this assertion you either have a use after free bug, or
261     // TestOverloadedConstructorsWithSequence has subclasses. If TestOverloadedConstructorsWithSequence has subclasses that get passed
262     // to toJS() we currently require TestOverloadedConstructorsWithSequence you to opt out of binding hardening
263     // by adding the SkipVTableValidation attribute to the interface IDL definition
264     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
265 #endif
266     return createWrapper<TestOverloadedConstructorsWithSequence>(globalObject, WTFMove(impl));
267 }
268
269 JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, TestOverloadedConstructorsWithSequence& impl)
270 {
271     return wrap(state, globalObject, impl);
272 }
273
274 TestOverloadedConstructorsWithSequence* JSTestOverloadedConstructorsWithSequence::toWrapped(JSC::VM& vm, JSC::JSValue value)
275 {
276     if (auto* wrapper = jsDynamicCast<JSTestOverloadedConstructorsWithSequence*>(vm, value))
277         return &wrapper->wrapped();
278     return nullptr;
279 }
280
281 }