Fix the binding generator after r190785
[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 <wtf/GetPtr.h>
26
27 using namespace JSC;
28
29 namespace WebCore {
30
31 // Attributes
32
33 JSC::EncodedJSValue jsTestCustomConstructorWithNoInterfaceObjectConstructor(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName);
34
35 class JSTestCustomConstructorWithNoInterfaceObjectPrototype : public JSC::JSNonFinalObject {
36 public:
37     typedef JSC::JSNonFinalObject Base;
38     static JSTestCustomConstructorWithNoInterfaceObjectPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
39     {
40         JSTestCustomConstructorWithNoInterfaceObjectPrototype* ptr = new (NotNull, JSC::allocateCell<JSTestCustomConstructorWithNoInterfaceObjectPrototype>(vm.heap)) JSTestCustomConstructorWithNoInterfaceObjectPrototype(vm, globalObject, structure);
41         ptr->finishCreation(vm);
42         return ptr;
43     }
44
45     DECLARE_INFO;
46     static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
47     {
48         return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
49     }
50
51 private:
52     JSTestCustomConstructorWithNoInterfaceObjectPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
53         : JSC::JSNonFinalObject(vm, structure)
54     {
55     }
56
57     void finishCreation(JSC::VM&);
58 };
59
60 class JSTestCustomConstructorWithNoInterfaceObjectConstructor : public DOMConstructorObject {
61 private:
62     JSTestCustomConstructorWithNoInterfaceObjectConstructor(JSC::Structure*, JSDOMGlobalObject&);
63     void finishCreation(JSC::VM&, JSDOMGlobalObject&);
64
65 public:
66     typedef DOMConstructorObject Base;
67     static JSTestCustomConstructorWithNoInterfaceObjectConstructor* create(JSC::VM& vm, JSC::Structure* structure, JSDOMGlobalObject& globalObject)
68     {
69         JSTestCustomConstructorWithNoInterfaceObjectConstructor* ptr = new (NotNull, JSC::allocateCell<JSTestCustomConstructorWithNoInterfaceObjectConstructor>(vm.heap)) JSTestCustomConstructorWithNoInterfaceObjectConstructor(structure, globalObject);
70         ptr->finishCreation(vm, globalObject);
71         return ptr;
72     }
73
74     DECLARE_INFO;
75     static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject& globalObject, JSC::JSValue prototype)
76     {
77         return JSC::Structure::create(vm, &globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
78     }
79 protected:
80     static JSC::EncodedJSValue JSC_HOST_CALL construct(JSC::ExecState*);
81     static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&);
82 };
83
84 JSC::EncodedJSValue JSC_HOST_CALL JSTestCustomConstructorWithNoInterfaceObjectConstructor::construct(JSC::ExecState* state)
85 {
86     return constructJSTestCustomConstructorWithNoInterfaceObject(state);
87 }
88
89 const ClassInfo JSTestCustomConstructorWithNoInterfaceObjectConstructor::s_info = { "TestCustomConstructorWithNoInterfaceObjectConstructor", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestCustomConstructorWithNoInterfaceObjectConstructor) };
90
91 JSTestCustomConstructorWithNoInterfaceObjectConstructor::JSTestCustomConstructorWithNoInterfaceObjectConstructor(Structure* structure, JSDOMGlobalObject& globalObject)
92     : Base(structure, globalObject)
93 {
94 }
95
96 void JSTestCustomConstructorWithNoInterfaceObjectConstructor::finishCreation(VM& vm, JSDOMGlobalObject& globalObject)
97 {
98     Base::finishCreation(vm);
99     ASSERT(inherits(info()));
100     putDirect(vm, vm.propertyNames->prototype, JSTestCustomConstructorWithNoInterfaceObject::getPrototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum);
101     putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("TestCustomConstructorWithNoInterfaceObject"))), ReadOnly | DontEnum);
102     putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum);
103 }
104
105 ConstructType JSTestCustomConstructorWithNoInterfaceObjectConstructor::getConstructData(JSCell* cell, ConstructData& constructData)
106 {
107     UNUSED_PARAM(cell);
108     constructData.native.function = construct;
109     return ConstructTypeHost;
110 }
111
112 /* Hash table for prototype */
113
114 static const HashTableValue JSTestCustomConstructorWithNoInterfaceObjectPrototypeTableValues[] =
115 {
116     { "constructor", DontEnum | ReadOnly, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestCustomConstructorWithNoInterfaceObjectConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
117 };
118
119 const ClassInfo JSTestCustomConstructorWithNoInterfaceObjectPrototype::s_info = { "TestCustomConstructorWithNoInterfaceObjectPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestCustomConstructorWithNoInterfaceObjectPrototype) };
120
121 void JSTestCustomConstructorWithNoInterfaceObjectPrototype::finishCreation(VM& vm)
122 {
123     Base::finishCreation(vm);
124     reifyStaticProperties(vm, JSTestCustomConstructorWithNoInterfaceObjectPrototypeTableValues, *this);
125 }
126
127 const ClassInfo JSTestCustomConstructorWithNoInterfaceObject::s_info = { "TestCustomConstructorWithNoInterfaceObject", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestCustomConstructorWithNoInterfaceObject) };
128
129 JSTestCustomConstructorWithNoInterfaceObject::JSTestCustomConstructorWithNoInterfaceObject(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TestCustomConstructorWithNoInterfaceObject>&& impl)
130     : JSDOMWrapperWithImplementation<TestCustomConstructorWithNoInterfaceObject>(structure, globalObject, WTF::move(impl))
131 {
132 }
133
134 JSObject* JSTestCustomConstructorWithNoInterfaceObject::createPrototype(VM& vm, JSGlobalObject* globalObject)
135 {
136     return JSTestCustomConstructorWithNoInterfaceObjectPrototype::create(vm, globalObject, JSTestCustomConstructorWithNoInterfaceObjectPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
137 }
138
139 JSObject* JSTestCustomConstructorWithNoInterfaceObject::getPrototype(VM& vm, JSGlobalObject* globalObject)
140 {
141     return getDOMPrototype<JSTestCustomConstructorWithNoInterfaceObject>(vm, globalObject);
142 }
143
144 void JSTestCustomConstructorWithNoInterfaceObject::destroy(JSC::JSCell* cell)
145 {
146     JSTestCustomConstructorWithNoInterfaceObject* thisObject = static_cast<JSTestCustomConstructorWithNoInterfaceObject*>(cell);
147     thisObject->JSTestCustomConstructorWithNoInterfaceObject::~JSTestCustomConstructorWithNoInterfaceObject();
148 }
149
150 EncodedJSValue jsTestCustomConstructorWithNoInterfaceObjectConstructor(ExecState* state, JSObject* baseValue, EncodedJSValue, PropertyName)
151 {
152     JSTestCustomConstructorWithNoInterfaceObjectPrototype* domObject = jsDynamicCast<JSTestCustomConstructorWithNoInterfaceObjectPrototype*>(baseValue);
153     if (!domObject)
154         return throwVMTypeError(state);
155     JSValue constructor = JSTestCustomConstructorWithNoInterfaceObjectConstructor::create(state->vm(), JSTestCustomConstructorWithNoInterfaceObjectConstructor::createStructure(state->vm(), *domObject->globalObject(), domObject->globalObject()->objectPrototype()), *jsCast<JSDOMGlobalObject*>(domObject->globalObject()));
156     // Shadowing constructor property to ensure reusing the same constructor object
157     domObject->putDirect(state->vm(), state->propertyNames().constructor, constructor, DontEnum | ReadOnly);
158     return JSValue::encode(constructor);
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 = jsCast<JSTestCustomConstructorWithNoInterfaceObject*>(handle.slot()->asCell());
171     auto& world = *static_cast<DOMWrapperWorld*>(context);
172     uncacheWrapper(world, &jsTestCustomConstructorWithNoInterfaceObject->impl(), 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, TestCustomConstructorWithNoInterfaceObject* impl)
185 {
186     if (!impl)
187         return jsNull();
188     return createNewWrapper<JSTestCustomConstructorWithNoInterfaceObject>(globalObject, impl);
189 }
190
191 JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject* globalObject, TestCustomConstructorWithNoInterfaceObject* impl)
192 {
193     if (!impl)
194         return jsNull();
195     if (JSValue result = getExistingWrapper<JSTestCustomConstructorWithNoInterfaceObject>(globalObject, impl))
196         return result;
197
198 #if ENABLE(BINDING_INTEGRITY)
199     void* actualVTablePointer = *(reinterpret_cast<void**>(impl));
200 #if PLATFORM(WIN)
201     void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7TestCustomConstructorWithNoInterfaceObject@WebCore@@6B@"));
202 #else
203     void* expectedVTablePointer = &_ZTVN7WebCore42TestCustomConstructorWithNoInterfaceObjectE[2];
204 #if COMPILER(CLANG)
205     // If this fails TestCustomConstructorWithNoInterfaceObject does not have a vtable, so you need to add the
206     // ImplementationLacksVTable attribute to the interface definition
207     COMPILE_ASSERT(__is_polymorphic(TestCustomConstructorWithNoInterfaceObject), TestCustomConstructorWithNoInterfaceObject_is_not_polymorphic);
208 #endif
209 #endif
210     // If you hit this assertion you either have a use after free bug, or
211     // TestCustomConstructorWithNoInterfaceObject has subclasses. If TestCustomConstructorWithNoInterfaceObject has subclasses that get passed
212     // to toJS() we currently require TestCustomConstructorWithNoInterfaceObject you to opt out of binding hardening
213     // by adding the SkipVTableValidation attribute to the interface IDL definition
214     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
215 #endif
216     return createNewWrapper<JSTestCustomConstructorWithNoInterfaceObject>(globalObject, impl);
217 }
218
219 TestCustomConstructorWithNoInterfaceObject* JSTestCustomConstructorWithNoInterfaceObject::toWrapped(JSC::JSValue value)
220 {
221     if (auto* wrapper = jsDynamicCast<JSTestCustomConstructorWithNoInterfaceObject*>(value))
222         return &wrapper->impl();
223     return nullptr;
224 }
225
226 }