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