70c6fa5c6ab90ce55d04b6017614bf04d2286f5f
[WebKit-https.git] / Source / WebCore / bindings / scripts / test / JS / JSTestStringifierReadWriteAttribute.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 "JSTestStringifierReadWriteAttribute.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 "ScriptExecutionContext.h"
32 #include <JavaScriptCore/FunctionPrototype.h>
33 #include <JavaScriptCore/HeapAnalyzer.h>
34 #include <JavaScriptCore/JSCInlines.h>
35 #include <wtf/GetPtr.h>
36 #include <wtf/PointerPreparations.h>
37 #include <wtf/URL.h>
38
39
40 namespace WebCore {
41 using namespace JSC;
42
43 // Functions
44
45 JSC::EncodedJSValue JSC_HOST_CALL jsTestStringifierReadWriteAttributePrototypeFunctionToString(JSC::JSGlobalObject*, JSC::CallFrame*);
46
47 // Attributes
48
49 JSC::EncodedJSValue jsTestStringifierReadWriteAttributeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
50 bool setJSTestStringifierReadWriteAttributeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
51 JSC::EncodedJSValue jsTestStringifierReadWriteAttributeIdentifier(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
52 bool setJSTestStringifierReadWriteAttributeIdentifier(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
53
54 class JSTestStringifierReadWriteAttributePrototype : public JSC::JSNonFinalObject {
55 public:
56     using Base = JSC::JSNonFinalObject;
57     static JSTestStringifierReadWriteAttributePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
58     {
59         JSTestStringifierReadWriteAttributePrototype* ptr = new (NotNull, JSC::allocateCell<JSTestStringifierReadWriteAttributePrototype>(vm.heap)) JSTestStringifierReadWriteAttributePrototype(vm, globalObject, structure);
60         ptr->finishCreation(vm);
61         return ptr;
62     }
63
64     DECLARE_INFO;
65     static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
66     {
67         return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
68     }
69
70 private:
71     JSTestStringifierReadWriteAttributePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
72         : JSC::JSNonFinalObject(vm, structure)
73     {
74     }
75
76     void finishCreation(JSC::VM&);
77 };
78
79 using JSTestStringifierReadWriteAttributeConstructor = JSDOMConstructorNotConstructable<JSTestStringifierReadWriteAttribute>;
80
81 template<> JSValue JSTestStringifierReadWriteAttributeConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
82 {
83     UNUSED_PARAM(vm);
84     return globalObject.functionPrototype();
85 }
86
87 template<> void JSTestStringifierReadWriteAttributeConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
88 {
89     putDirect(vm, vm.propertyNames->prototype, JSTestStringifierReadWriteAttribute::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
90     putDirect(vm, vm.propertyNames->name, jsNontrivialString(vm, String("TestStringifierReadWriteAttribute"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
91     putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
92 }
93
94 template<> const ClassInfo JSTestStringifierReadWriteAttributeConstructor::s_info = { "TestStringifierReadWriteAttribute", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestStringifierReadWriteAttributeConstructor) };
95
96 /* Hash table for prototype */
97
98 static const HashTableValue JSTestStringifierReadWriteAttributePrototypeTableValues[] =
99 {
100     { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestStringifierReadWriteAttributeConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestStringifierReadWriteAttributeConstructor) } },
101     { "identifier", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestStringifierReadWriteAttributeIdentifier), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestStringifierReadWriteAttributeIdentifier) } },
102     { "toString", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestStringifierReadWriteAttributePrototypeFunctionToString), (intptr_t) (0) } },
103 };
104
105 const ClassInfo JSTestStringifierReadWriteAttributePrototype::s_info = { "TestStringifierReadWriteAttributePrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestStringifierReadWriteAttributePrototype) };
106
107 void JSTestStringifierReadWriteAttributePrototype::finishCreation(VM& vm)
108 {
109     Base::finishCreation(vm);
110     reifyStaticProperties(vm, JSTestStringifierReadWriteAttribute::info(), JSTestStringifierReadWriteAttributePrototypeTableValues, *this);
111 }
112
113 const ClassInfo JSTestStringifierReadWriteAttribute::s_info = { "TestStringifierReadWriteAttribute", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestStringifierReadWriteAttribute) };
114
115 JSTestStringifierReadWriteAttribute::JSTestStringifierReadWriteAttribute(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TestStringifierReadWriteAttribute>&& impl)
116     : JSDOMWrapper<TestStringifierReadWriteAttribute>(structure, globalObject, WTFMove(impl))
117 {
118 }
119
120 void JSTestStringifierReadWriteAttribute::finishCreation(VM& vm)
121 {
122     Base::finishCreation(vm);
123     ASSERT(inherits(vm, info()));
124
125 }
126
127 JSObject* JSTestStringifierReadWriteAttribute::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
128 {
129     return JSTestStringifierReadWriteAttributePrototype::create(vm, &globalObject, JSTestStringifierReadWriteAttributePrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
130 }
131
132 JSObject* JSTestStringifierReadWriteAttribute::prototype(VM& vm, JSDOMGlobalObject& globalObject)
133 {
134     return getDOMPrototype<JSTestStringifierReadWriteAttribute>(vm, globalObject);
135 }
136
137 JSValue JSTestStringifierReadWriteAttribute::getConstructor(VM& vm, const JSGlobalObject* globalObject)
138 {
139     return getDOMConstructor<JSTestStringifierReadWriteAttributeConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
140 }
141
142 void JSTestStringifierReadWriteAttribute::destroy(JSC::JSCell* cell)
143 {
144     JSTestStringifierReadWriteAttribute* thisObject = static_cast<JSTestStringifierReadWriteAttribute*>(cell);
145     thisObject->JSTestStringifierReadWriteAttribute::~JSTestStringifierReadWriteAttribute();
146 }
147
148 template<> inline JSTestStringifierReadWriteAttribute* IDLAttribute<JSTestStringifierReadWriteAttribute>::cast(ExecState& state, EncodedJSValue thisValue)
149 {
150     return jsDynamicCast<JSTestStringifierReadWriteAttribute*>(state.vm(), JSValue::decode(thisValue));
151 }
152
153 template<> inline JSTestStringifierReadWriteAttribute* IDLOperation<JSTestStringifierReadWriteAttribute>::cast(ExecState& state)
154 {
155     return jsDynamicCast<JSTestStringifierReadWriteAttribute*>(state.vm(), state.thisValue());
156 }
157
158 EncodedJSValue jsTestStringifierReadWriteAttributeConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
159 {
160     VM& vm = state->vm();
161     auto throwScope = DECLARE_THROW_SCOPE(vm);
162     auto* prototype = jsDynamicCast<JSTestStringifierReadWriteAttributePrototype*>(vm, JSValue::decode(thisValue));
163     if (UNLIKELY(!prototype))
164         return throwVMTypeError(state, throwScope);
165     return JSValue::encode(JSTestStringifierReadWriteAttribute::getConstructor(state->vm(), prototype->globalObject()));
166 }
167
168 bool setJSTestStringifierReadWriteAttributeConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
169 {
170     VM& vm = state->vm();
171     auto throwScope = DECLARE_THROW_SCOPE(vm);
172     auto* prototype = jsDynamicCast<JSTestStringifierReadWriteAttributePrototype*>(vm, JSValue::decode(thisValue));
173     if (UNLIKELY(!prototype)) {
174         throwVMTypeError(state, throwScope);
175         return false;
176     }
177     // Shadowing a built-in constructor
178     return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
179 }
180
181 static inline JSValue jsTestStringifierReadWriteAttributeIdentifierGetter(ExecState& state, JSTestStringifierReadWriteAttribute& thisObject, ThrowScope& throwScope)
182 {
183     UNUSED_PARAM(throwScope);
184     UNUSED_PARAM(state);
185     auto& impl = thisObject.wrapped();
186     JSValue result = toJS<IDLDOMString>(state, throwScope, impl.identifier());
187     return result;
188 }
189
190 EncodedJSValue jsTestStringifierReadWriteAttributeIdentifier(ExecState* state, EncodedJSValue thisValue, PropertyName)
191 {
192     return IDLAttribute<JSTestStringifierReadWriteAttribute>::get<jsTestStringifierReadWriteAttributeIdentifierGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "identifier");
193 }
194
195 static inline bool setJSTestStringifierReadWriteAttributeIdentifierSetter(ExecState& state, JSTestStringifierReadWriteAttribute& thisObject, JSValue value, ThrowScope& throwScope)
196 {
197     UNUSED_PARAM(state);
198     UNUSED_PARAM(throwScope);
199     auto& impl = thisObject.wrapped();
200     auto nativeValue = convert<IDLDOMString>(state, value);
201     RETURN_IF_EXCEPTION(throwScope, false);
202     AttributeSetter::call(state, throwScope, [&] {
203         return impl.setIdentifier(WTFMove(nativeValue));
204     });
205     return true;
206 }
207
208 bool setJSTestStringifierReadWriteAttributeIdentifier(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
209 {
210     return IDLAttribute<JSTestStringifierReadWriteAttribute>::set<setJSTestStringifierReadWriteAttributeIdentifierSetter>(*state, thisValue, encodedValue, "identifier");
211 }
212
213 static inline JSC::EncodedJSValue jsTestStringifierReadWriteAttributePrototypeFunctionToStringBody(JSC::ExecState* state, typename IDLOperation<JSTestStringifierReadWriteAttribute>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
214 {
215     UNUSED_PARAM(state);
216     UNUSED_PARAM(throwScope);
217     auto& impl = castedThis->wrapped();
218     return JSValue::encode(toJS<IDLDOMString>(*state, impl.identifier()));
219 }
220
221 EncodedJSValue JSC_HOST_CALL jsTestStringifierReadWriteAttributePrototypeFunctionToString(JSGlobalObject* globalObject, CallFrame* state)
222 {
223     UNUSED_PARAM(globalObject);
224     return IDLOperation<JSTestStringifierReadWriteAttribute>::call<jsTestStringifierReadWriteAttributePrototypeFunctionToStringBody>(*state, "toString");
225 }
226
227 void JSTestStringifierReadWriteAttribute::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
228 {
229     auto* thisObject = jsCast<JSTestStringifierReadWriteAttribute*>(cell);
230     analyzer.setWrappedObjectForCell(cell, &thisObject->wrapped());
231     if (thisObject->scriptExecutionContext())
232         analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
233     Base::analyzeHeap(cell, analyzer);
234 }
235
236 bool JSTestStringifierReadWriteAttributeOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
237 {
238     UNUSED_PARAM(handle);
239     UNUSED_PARAM(visitor);
240     UNUSED_PARAM(reason);
241     return false;
242 }
243
244 void JSTestStringifierReadWriteAttributeOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
245 {
246     auto* jsTestStringifierReadWriteAttribute = static_cast<JSTestStringifierReadWriteAttribute*>(handle.slot()->asCell());
247     auto& world = *static_cast<DOMWrapperWorld*>(context);
248     uncacheWrapper(world, &jsTestStringifierReadWriteAttribute->wrapped(), jsTestStringifierReadWriteAttribute);
249 }
250
251 #if ENABLE(BINDING_INTEGRITY)
252 #if PLATFORM(WIN)
253 #pragma warning(disable: 4483)
254 extern "C" { extern void (*const __identifier("??_7TestStringifierReadWriteAttribute@WebCore@@6B@")[])(); }
255 #else
256 extern "C" { extern void* _ZTVN7WebCore33TestStringifierReadWriteAttributeE[]; }
257 #endif
258 #endif
259
260 JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<TestStringifierReadWriteAttribute>&& impl)
261 {
262
263 #if ENABLE(BINDING_INTEGRITY)
264     void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
265 #if PLATFORM(WIN)
266     void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7TestStringifierReadWriteAttribute@WebCore@@6B@"));
267 #else
268     void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore33TestStringifierReadWriteAttributeE[2]);
269 #endif
270
271     // If this fails TestStringifierReadWriteAttribute does not have a vtable, so you need to add the
272     // ImplementationLacksVTable attribute to the interface definition
273     static_assert(std::is_polymorphic<TestStringifierReadWriteAttribute>::value, "TestStringifierReadWriteAttribute is not polymorphic");
274
275     // If you hit this assertion you either have a use after free bug, or
276     // TestStringifierReadWriteAttribute has subclasses. If TestStringifierReadWriteAttribute has subclasses that get passed
277     // to toJS() we currently require TestStringifierReadWriteAttribute you to opt out of binding hardening
278     // by adding the SkipVTableValidation attribute to the interface IDL definition
279     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
280 #endif
281     return createWrapper<TestStringifierReadWriteAttribute>(globalObject, WTFMove(impl));
282 }
283
284 JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, TestStringifierReadWriteAttribute& impl)
285 {
286     return wrap(state, globalObject, impl);
287 }
288
289 TestStringifierReadWriteAttribute* JSTestStringifierReadWriteAttribute::toWrapped(JSC::VM& vm, JSC::JSValue value)
290 {
291     if (auto* wrapper = jsDynamicCast<JSTestStringifierReadWriteAttribute*>(vm, value))
292         return &wrapper->wrapped();
293     return nullptr;
294 }
295
296 }