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