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