Add infrastructure for pointer preparation.
[WebKit-https.git] / Source / WebCore / bindings / scripts / test / JS / JSTestStringifierOperationImplementedAs.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 "JSTestStringifierOperationImplementedAs.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 jsTestStringifierOperationImplementedAsPrototypeFunctionIdentifier(JSC::ExecState*);
42 JSC::EncodedJSValue JSC_HOST_CALL jsTestStringifierOperationImplementedAsPrototypeFunctionToString(JSC::ExecState*);
43
44 // Attributes
45
46 JSC::EncodedJSValue jsTestStringifierOperationImplementedAsConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
47 bool setJSTestStringifierOperationImplementedAsConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
48
49 class JSTestStringifierOperationImplementedAsPrototype : public JSC::JSNonFinalObject {
50 public:
51     using Base = JSC::JSNonFinalObject;
52     static JSTestStringifierOperationImplementedAsPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
53     {
54         JSTestStringifierOperationImplementedAsPrototype* ptr = new (NotNull, JSC::allocateCell<JSTestStringifierOperationImplementedAsPrototype>(vm.heap)) JSTestStringifierOperationImplementedAsPrototype(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     JSTestStringifierOperationImplementedAsPrototype(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 JSTestStringifierOperationImplementedAsConstructor = JSDOMConstructorNotConstructable<JSTestStringifierOperationImplementedAs>;
75
76 template<> JSValue JSTestStringifierOperationImplementedAsConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
77 {
78     UNUSED_PARAM(vm);
79     return globalObject.functionPrototype();
80 }
81
82 template<> void JSTestStringifierOperationImplementedAsConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
83 {
84     putDirect(vm, vm.propertyNames->prototype, JSTestStringifierOperationImplementedAs::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
85     putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("TestStringifierOperationImplementedAs"))), 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 JSTestStringifierOperationImplementedAsConstructor::s_info = { "TestStringifierOperationImplementedAs", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestStringifierOperationImplementedAsConstructor) };
90
91 /* Hash table for prototype */
92
93 static const HashTableValue JSTestStringifierOperationImplementedAsPrototypeTableValues[] =
94 {
95     { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestStringifierOperationImplementedAsConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestStringifierOperationImplementedAsConstructor) } },
96     { "identifier", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestStringifierOperationImplementedAsPrototypeFunctionIdentifier), (intptr_t) (0) } },
97     { "toString", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestStringifierOperationImplementedAsPrototypeFunctionToString), (intptr_t) (0) } },
98 };
99
100 const ClassInfo JSTestStringifierOperationImplementedAsPrototype::s_info = { "TestStringifierOperationImplementedAsPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestStringifierOperationImplementedAsPrototype) };
101
102 void JSTestStringifierOperationImplementedAsPrototype::finishCreation(VM& vm)
103 {
104     Base::finishCreation(vm);
105     reifyStaticProperties(vm, JSTestStringifierOperationImplementedAs::info(), JSTestStringifierOperationImplementedAsPrototypeTableValues, *this);
106 }
107
108 const ClassInfo JSTestStringifierOperationImplementedAs::s_info = { "TestStringifierOperationImplementedAs", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestStringifierOperationImplementedAs) };
109
110 JSTestStringifierOperationImplementedAs::JSTestStringifierOperationImplementedAs(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TestStringifierOperationImplementedAs>&& impl)
111     : JSDOMWrapper<TestStringifierOperationImplementedAs>(structure, globalObject, WTFMove(impl))
112 {
113 }
114
115 void JSTestStringifierOperationImplementedAs::finishCreation(VM& vm)
116 {
117     Base::finishCreation(vm);
118     ASSERT(inherits(vm, info()));
119
120 }
121
122 JSObject* JSTestStringifierOperationImplementedAs::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
123 {
124     return JSTestStringifierOperationImplementedAsPrototype::create(vm, &globalObject, JSTestStringifierOperationImplementedAsPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
125 }
126
127 JSObject* JSTestStringifierOperationImplementedAs::prototype(VM& vm, JSDOMGlobalObject& globalObject)
128 {
129     return getDOMPrototype<JSTestStringifierOperationImplementedAs>(vm, globalObject);
130 }
131
132 JSValue JSTestStringifierOperationImplementedAs::getConstructor(VM& vm, const JSGlobalObject* globalObject)
133 {
134     return getDOMConstructor<JSTestStringifierOperationImplementedAsConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
135 }
136
137 void JSTestStringifierOperationImplementedAs::destroy(JSC::JSCell* cell)
138 {
139     JSTestStringifierOperationImplementedAs* thisObject = static_cast<JSTestStringifierOperationImplementedAs*>(cell);
140     thisObject->JSTestStringifierOperationImplementedAs::~JSTestStringifierOperationImplementedAs();
141 }
142
143 template<> inline JSTestStringifierOperationImplementedAs* IDLOperation<JSTestStringifierOperationImplementedAs>::cast(ExecState& state)
144 {
145     return jsDynamicDowncast<JSTestStringifierOperationImplementedAs*>(state.vm(), state.thisValue());
146 }
147
148 EncodedJSValue jsTestStringifierOperationImplementedAsConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
149 {
150     VM& vm = state->vm();
151     auto throwScope = DECLARE_THROW_SCOPE(vm);
152     auto* prototype = jsDynamicDowncast<JSTestStringifierOperationImplementedAsPrototype*>(vm, JSValue::decode(thisValue));
153     if (UNLIKELY(!prototype))
154         return throwVMTypeError(state, throwScope);
155     return JSValue::encode(JSTestStringifierOperationImplementedAs::getConstructor(state->vm(), prototype->globalObject()));
156 }
157
158 bool setJSTestStringifierOperationImplementedAsConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
159 {
160     VM& vm = state->vm();
161     auto throwScope = DECLARE_THROW_SCOPE(vm);
162     auto* prototype = jsDynamicDowncast<JSTestStringifierOperationImplementedAsPrototype*>(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 jsTestStringifierOperationImplementedAsPrototypeFunctionIdentifierBody(JSC::ExecState* state, typename IDLOperation<JSTestStringifierOperationImplementedAs>::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.alternateIdentifier()));
177 }
178
179 EncodedJSValue JSC_HOST_CALL jsTestStringifierOperationImplementedAsPrototypeFunctionIdentifier(ExecState* state)
180 {
181     return IDLOperation<JSTestStringifierOperationImplementedAs>::call<jsTestStringifierOperationImplementedAsPrototypeFunctionIdentifierBody>(*state, "identifier");
182 }
183
184 static inline JSC::EncodedJSValue jsTestStringifierOperationImplementedAsPrototypeFunctionToStringBody(JSC::ExecState* state, typename IDLOperation<JSTestStringifierOperationImplementedAs>::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.alternateIdentifier()));
190 }
191
192 EncodedJSValue JSC_HOST_CALL jsTestStringifierOperationImplementedAsPrototypeFunctionToString(ExecState* state)
193 {
194     return IDLOperation<JSTestStringifierOperationImplementedAs>::call<jsTestStringifierOperationImplementedAsPrototypeFunctionToStringBody>(*state, "toString");
195 }
196
197 bool JSTestStringifierOperationImplementedAsOwner::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 JSTestStringifierOperationImplementedAsOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
205 {
206     auto* jsTestStringifierOperationImplementedAs = static_cast<JSTestStringifierOperationImplementedAs*>(handle.slot()->asCell());
207     auto& world = *static_cast<DOMWrapperWorld*>(context);
208     uncacheWrapper(world, &jsTestStringifierOperationImplementedAs->wrapped(), jsTestStringifierOperationImplementedAs);
209 }
210
211 #if ENABLE(BINDING_INTEGRITY)
212 #if PLATFORM(WIN)
213 #pragma warning(disable: 4483)
214 extern "C" { extern void (*const __identifier("??_7TestStringifierOperationImplementedAs@WebCore@@6B@")[])(); }
215 #else
216 extern "C" { extern void* _ZTVN7WebCore37TestStringifierOperationImplementedAsE[]; }
217 #endif
218 #endif
219
220 JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<TestStringifierOperationImplementedAs>&& 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("??_7TestStringifierOperationImplementedAs@WebCore@@6B@"));
227 #else
228     void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore37TestStringifierOperationImplementedAsE[2]);
229 #endif
230
231     // If this fails TestStringifierOperationImplementedAs does not have a vtable, so you need to add the
232     // ImplementationLacksVTable attribute to the interface definition
233     static_assert(std::is_polymorphic<TestStringifierOperationImplementedAs>::value, "TestStringifierOperationImplementedAs is not polymorphic");
234
235     // If you hit this assertion you either have a use after free bug, or
236     // TestStringifierOperationImplementedAs has subclasses. If TestStringifierOperationImplementedAs has subclasses that get passed
237     // to toJS() we currently require TestStringifierOperationImplementedAs 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<TestStringifierOperationImplementedAs>(globalObject, WTFMove(impl));
242 }
243
244 JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, TestStringifierOperationImplementedAs& impl)
245 {
246     return wrap(state, globalObject, impl);
247 }
248
249 TestStringifierOperationImplementedAs* JSTestStringifierOperationImplementedAs::toWrapped(JSC::VM& vm, JSC::JSValue value)
250 {
251     if (auto* wrapper = jsDynamicDowncast<JSTestStringifierOperationImplementedAs*>(vm, value))
252         return &wrapper->wrapped();
253     return nullptr;
254 }
255
256 }