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