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