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