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