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