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