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