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