REGRESSION (r133705): Layout Test js/dom/webidl-type-mapping.html is failing
[WebKit-https.git] / Source / WebCore / bindings / scripts / test / JS / JSTestActiveDOMObject.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 "JSTestActiveDOMObject.h"
23
24 #include "ExceptionCode.h"
25 #include "JSDOMBinding.h"
26 #include "JSNode.h"
27 #include "ScriptExecutionContext.h"
28 #include "TestActiveDOMObject.h"
29 #include <runtime/Error.h>
30 #include <wtf/GetPtr.h>
31
32 using namespace JSC;
33
34 namespace WebCore {
35
36 /* Hash table */
37
38 static const struct CompactHashIndex JSTestActiveDOMObjectTableIndex[4] = {
39     { 1, -1 },
40     { 0, -1 },
41     { -1, -1 },
42     { -1, -1 },
43 };
44
45
46 static const HashTableValue JSTestActiveDOMObjectTableValues[] =
47 {
48     { "constructor", DontEnum | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestActiveDOMObjectConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
49     { "excitingAttr", DontDelete | ReadOnly | CustomAccessor, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestActiveDOMObjectExcitingAttr), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
50 };
51
52 static const HashTable JSTestActiveDOMObjectTable = { 2, 3, true, JSTestActiveDOMObjectTableValues, 0, JSTestActiveDOMObjectTableIndex };
53 /* Hash table for constructor */
54
55 static const struct CompactHashIndex JSTestActiveDOMObjectConstructorTableIndex[1] = {
56     { -1, -1 },
57 };
58
59
60 static const HashTableValue JSTestActiveDOMObjectConstructorTableValues[] =
61 {
62     { 0, 0, NoIntrinsic, 0, 0 }
63 };
64
65 static const HashTable JSTestActiveDOMObjectConstructorTable = { 0, 0, false, JSTestActiveDOMObjectConstructorTableValues, 0, JSTestActiveDOMObjectConstructorTableIndex };
66 const ClassInfo JSTestActiveDOMObjectConstructor::s_info = { "TestActiveDOMObjectConstructor", &Base::s_info, &JSTestActiveDOMObjectConstructorTable, 0, CREATE_METHOD_TABLE(JSTestActiveDOMObjectConstructor) };
67
68 JSTestActiveDOMObjectConstructor::JSTestActiveDOMObjectConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
69     : DOMConstructorObject(structure, globalObject)
70 {
71 }
72
73 void JSTestActiveDOMObjectConstructor::finishCreation(VM& vm, JSDOMGlobalObject* globalObject)
74 {
75     Base::finishCreation(vm);
76     ASSERT(inherits(info()));
77     putDirect(vm, vm.propertyNames->prototype, JSTestActiveDOMObjectPrototype::self(vm, globalObject), DontDelete | ReadOnly);
78     putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
79 }
80
81 bool JSTestActiveDOMObjectConstructor::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
82 {
83     return getStaticValueSlot<JSTestActiveDOMObjectConstructor, JSDOMWrapper>(exec, JSTestActiveDOMObjectConstructorTable, jsCast<JSTestActiveDOMObjectConstructor*>(object), propertyName, slot);
84 }
85
86 /* Hash table for prototype */
87
88 static const struct CompactHashIndex JSTestActiveDOMObjectPrototypeTableIndex[4] = {
89     { 0, -1 },
90     { 1, -1 },
91     { -1, -1 },
92     { -1, -1 },
93 };
94
95
96 static const HashTableValue JSTestActiveDOMObjectPrototypeTableValues[] =
97 {
98     { "excitingFunction", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestActiveDOMObjectPrototypeFunctionExcitingFunction), (intptr_t) (1) },
99     { "postMessage", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestActiveDOMObjectPrototypeFunctionPostMessage), (intptr_t) (1) },
100 };
101
102 static const HashTable JSTestActiveDOMObjectPrototypeTable = { 2, 3, false, JSTestActiveDOMObjectPrototypeTableValues, 0, JSTestActiveDOMObjectPrototypeTableIndex };
103 const ClassInfo JSTestActiveDOMObjectPrototype::s_info = { "TestActiveDOMObjectPrototype", &Base::s_info, &JSTestActiveDOMObjectPrototypeTable, 0, CREATE_METHOD_TABLE(JSTestActiveDOMObjectPrototype) };
104
105 JSObject* JSTestActiveDOMObjectPrototype::self(VM& vm, JSGlobalObject* globalObject)
106 {
107     return getDOMPrototype<JSTestActiveDOMObject>(vm, globalObject);
108 }
109
110 void JSTestActiveDOMObjectPrototype::finishCreation(VM& vm)
111 {
112     Base::finishCreation(vm);
113     reifyStaticProperties(vm, JSTestActiveDOMObjectPrototypeTableValues, *this);
114 }
115
116 const ClassInfo JSTestActiveDOMObject::s_info = { "TestActiveDOMObject", &Base::s_info, &JSTestActiveDOMObjectTable, 0 , CREATE_METHOD_TABLE(JSTestActiveDOMObject) };
117
118 JSTestActiveDOMObject::JSTestActiveDOMObject(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestActiveDOMObject> impl)
119     : JSDOMWrapper(structure, globalObject)
120     , m_impl(impl.leakRef())
121 {
122 }
123
124 JSObject* JSTestActiveDOMObject::createPrototype(VM& vm, JSGlobalObject* globalObject)
125 {
126     return JSTestActiveDOMObjectPrototype::create(vm, globalObject, JSTestActiveDOMObjectPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
127 }
128
129 void JSTestActiveDOMObject::destroy(JSC::JSCell* cell)
130 {
131     JSTestActiveDOMObject* thisObject = static_cast<JSTestActiveDOMObject*>(cell);
132     thisObject->JSTestActiveDOMObject::~JSTestActiveDOMObject();
133 }
134
135 JSTestActiveDOMObject::~JSTestActiveDOMObject()
136 {
137     releaseImplIfNotNull();
138 }
139
140 bool JSTestActiveDOMObject::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
141 {
142     JSTestActiveDOMObject* thisObject = jsCast<JSTestActiveDOMObject*>(object);
143     ASSERT_GC_OBJECT_INHERITS(thisObject, info());
144     return getStaticValueSlot<JSTestActiveDOMObject, Base>(exec, JSTestActiveDOMObjectTable, thisObject, propertyName, slot);
145 }
146
147 EncodedJSValue jsTestActiveDOMObjectExcitingAttr(ExecState* exec, JSObject* slotBase, EncodedJSValue thisValue, PropertyName)
148 {
149     UNUSED_PARAM(exec);
150     UNUSED_PARAM(slotBase);
151     UNUSED_PARAM(thisValue);
152     JSTestActiveDOMObject* castedThis = jsCast<JSTestActiveDOMObject*>(slotBase);
153     if (!BindingSecurity::shouldAllowAccessToDOMWindow(exec, castedThis->impl()))
154         return JSValue::encode(jsUndefined());
155     TestActiveDOMObject& impl = castedThis->impl();
156     JSValue result = jsNumber(impl.excitingAttr());
157     return JSValue::encode(result);
158 }
159
160
161 EncodedJSValue jsTestActiveDOMObjectConstructor(ExecState* exec, JSObject*, EncodedJSValue thisValue, PropertyName)
162 {
163     JSTestActiveDOMObject* domObject = jsDynamicCast<JSTestActiveDOMObject*>(JSValue::decode(thisValue));
164     if (!domObject)
165         return throwVMTypeError(exec);
166     if (!BindingSecurity::shouldAllowAccessToDOMWindow(exec, domObject->impl()))
167         return JSValue::encode(jsUndefined());
168     return JSValue::encode(JSTestActiveDOMObject::getConstructor(exec->vm(), domObject->globalObject()));
169 }
170
171 JSValue JSTestActiveDOMObject::getConstructor(VM& vm, JSGlobalObject* globalObject)
172 {
173     return getDOMConstructor<JSTestActiveDOMObjectConstructor>(vm, jsCast<JSDOMGlobalObject*>(globalObject));
174 }
175
176 EncodedJSValue JSC_HOST_CALL jsTestActiveDOMObjectPrototypeFunctionExcitingFunction(ExecState* exec)
177 {
178     JSValue thisValue = exec->thisValue();
179     JSTestActiveDOMObject* castedThis = jsDynamicCast<JSTestActiveDOMObject*>(thisValue);
180     if (UNLIKELY(!castedThis))
181         return throwThisTypeError(*exec, "TestActiveDOMObject", "excitingFunction");
182     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestActiveDOMObject::info());
183     if (!BindingSecurity::shouldAllowAccessToDOMWindow(exec, castedThis->impl()))
184         return JSValue::encode(jsUndefined());
185     TestActiveDOMObject& impl = castedThis->impl();
186     if (exec->argumentCount() < 1)
187         return throwVMError(exec, createNotEnoughArgumentsError(exec));
188     Node* nextChild(toNode(exec->argument(0)));
189     if (UNLIKELY(exec->hadException()))
190         return JSValue::encode(jsUndefined());
191     impl.excitingFunction(nextChild);
192     return JSValue::encode(jsUndefined());
193 }
194
195 EncodedJSValue JSC_HOST_CALL jsTestActiveDOMObjectPrototypeFunctionPostMessage(ExecState* exec)
196 {
197     JSValue thisValue = exec->thisValue();
198     JSTestActiveDOMObject* castedThis = jsDynamicCast<JSTestActiveDOMObject*>(thisValue);
199     if (UNLIKELY(!castedThis))
200         return throwThisTypeError(*exec, "TestActiveDOMObject", "postMessage");
201     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestActiveDOMObject::info());
202     TestActiveDOMObject& impl = castedThis->impl();
203     if (exec->argumentCount() < 1)
204         return throwVMError(exec, createNotEnoughArgumentsError(exec));
205     const String& message(exec->argument(0).isEmpty() ? String() : exec->argument(0).toString(exec)->value(exec));
206     if (UNLIKELY(exec->hadException()))
207         return JSValue::encode(jsUndefined());
208     impl.postMessage(message);
209     return JSValue::encode(jsUndefined());
210 }
211
212 bool JSTestActiveDOMObjectOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
213 {
214     UNUSED_PARAM(handle);
215     UNUSED_PARAM(visitor);
216     return false;
217 }
218
219 void JSTestActiveDOMObjectOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
220 {
221     JSTestActiveDOMObject* jsTestActiveDOMObject = jsCast<JSTestActiveDOMObject*>(handle.slot()->asCell());
222     DOMWrapperWorld& world = *static_cast<DOMWrapperWorld*>(context);
223     uncacheWrapper(world, &jsTestActiveDOMObject->impl(), jsTestActiveDOMObject);
224     jsTestActiveDOMObject->releaseImpl();
225 }
226
227 #if ENABLE(BINDING_INTEGRITY)
228 #if PLATFORM(WIN)
229 #pragma warning(disable: 4483)
230 extern "C" { extern void (*const __identifier("??_7TestActiveDOMObject@WebCore@@6B@")[])(); }
231 #else
232 extern "C" { extern void* _ZTVN7WebCore19TestActiveDOMObjectE[]; }
233 #endif
234 #endif
235 JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject* globalObject, TestActiveDOMObject* impl)
236 {
237     if (!impl)
238         return jsNull();
239     if (JSValue result = getExistingWrapper<JSTestActiveDOMObject>(globalObject, impl))
240         return result;
241
242 #if ENABLE(BINDING_INTEGRITY)
243     void* actualVTablePointer = *(reinterpret_cast<void**>(impl));
244 #if PLATFORM(WIN)
245     void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7TestActiveDOMObject@WebCore@@6B@"));
246 #else
247     void* expectedVTablePointer = &_ZTVN7WebCore19TestActiveDOMObjectE[2];
248 #if COMPILER(CLANG)
249     // If this fails TestActiveDOMObject does not have a vtable, so you need to add the
250     // ImplementationLacksVTable attribute to the interface definition
251     COMPILE_ASSERT(__is_polymorphic(TestActiveDOMObject), TestActiveDOMObject_is_not_polymorphic);
252 #endif
253 #endif
254     // If you hit this assertion you either have a use after free bug, or
255     // TestActiveDOMObject has subclasses. If TestActiveDOMObject has subclasses that get passed
256     // to toJS() we currently require TestActiveDOMObject you to opt out of binding hardening
257     // by adding the SkipVTableValidation attribute to the interface IDL definition
258     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
259 #endif
260     return createNewWrapper<JSTestActiveDOMObject>(globalObject, impl);
261 }
262
263 TestActiveDOMObject* toTestActiveDOMObject(JSC::JSValue value)
264 {
265     if (auto* wrapper = jsDynamicCast<JSTestActiveDOMObject*>(value))
266         return &wrapper->impl();
267     return nullptr;
268 }
269
270 }