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