6e66849f033191c183f17421342dcf15c0a1e290
[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 ASSERT_CLASS_FITS_IN_CELL(JSTestActiveDOMObject);
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->globalData());
64     ASSERT(inherits(&s_info));
65     putDirect(exec->globalData(), exec->propertyNames().prototype, JSTestActiveDOMObjectPrototype::self(exec, globalObject), DontDelete | ReadOnly);
66 }
67
68 bool JSTestActiveDOMObjectConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
69 {
70     return getStaticValueSlot<JSTestActiveDOMObjectConstructor, JSDOMWrapper>(exec, &JSTestActiveDOMObjectConstructorTable, static_cast<JSTestActiveDOMObjectConstructor*>(cell), propertyName, slot);
71 }
72
73 bool JSTestActiveDOMObjectConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
74 {
75     return getStaticValueDescriptor<JSTestActiveDOMObjectConstructor, JSDOMWrapper>(exec, &JSTestActiveDOMObjectConstructorTable, static_cast<JSTestActiveDOMObjectConstructor*>(object), propertyName, descriptor);
76 }
77
78 /* Hash table for prototype */
79
80 static const HashTableValue JSTestActiveDOMObjectPrototypeTableValues[] =
81 {
82     { "excitingFunction", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestActiveDOMObjectPrototypeFunctionExcitingFunction), (intptr_t)1, NoIntrinsic },
83     { "postMessage", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestActiveDOMObjectPrototypeFunctionPostMessage), (intptr_t)1, NoIntrinsic },
84     { 0, 0, 0, 0, NoIntrinsic }
85 };
86
87 static const HashTable JSTestActiveDOMObjectPrototypeTable = { 4, 3, JSTestActiveDOMObjectPrototypeTableValues, 0 };
88 const ClassInfo JSTestActiveDOMObjectPrototype::s_info = { "TestActiveDOMObjectPrototype", &Base::s_info, &JSTestActiveDOMObjectPrototypeTable, 0, CREATE_METHOD_TABLE(JSTestActiveDOMObjectPrototype) };
89
90 JSObject* JSTestActiveDOMObjectPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
91 {
92     return getDOMPrototype<JSTestActiveDOMObject>(exec, globalObject);
93 }
94
95 bool JSTestActiveDOMObjectPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
96 {
97     JSTestActiveDOMObjectPrototype* thisObject = jsCast<JSTestActiveDOMObjectPrototype*>(cell);
98     return getStaticFunctionSlot<JSObject>(exec, &JSTestActiveDOMObjectPrototypeTable, thisObject, propertyName, slot);
99 }
100
101 bool JSTestActiveDOMObjectPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
102 {
103     JSTestActiveDOMObjectPrototype* thisObject = jsCast<JSTestActiveDOMObjectPrototype*>(object);
104     return getStaticFunctionDescriptor<JSObject>(exec, &JSTestActiveDOMObjectPrototypeTable, thisObject, propertyName, descriptor);
105 }
106
107 const ClassInfo JSTestActiveDOMObject::s_info = { "TestActiveDOMObject", &Base::s_info, &JSTestActiveDOMObjectTable, 0 , CREATE_METHOD_TABLE(JSTestActiveDOMObject) };
108
109 JSTestActiveDOMObject::JSTestActiveDOMObject(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestActiveDOMObject> impl)
110     : JSDOMWrapper(structure, globalObject)
111     , m_impl(impl.leakRef())
112 {
113 }
114
115 void JSTestActiveDOMObject::finishCreation(JSGlobalData& globalData)
116 {
117     Base::finishCreation(globalData);
118     ASSERT(inherits(&s_info));
119 }
120
121 JSObject* JSTestActiveDOMObject::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
122 {
123     return JSTestActiveDOMObjectPrototype::create(exec->globalData(), globalObject, JSTestActiveDOMObjectPrototype::createStructure(globalObject->globalData(), globalObject, globalObject->objectPrototype()));
124 }
125
126 void JSTestActiveDOMObject::destroy(JSC::JSCell* cell)
127 {
128     JSTestActiveDOMObject* thisObject = jsCast<JSTestActiveDOMObject*>(cell);
129     thisObject->JSTestActiveDOMObject::~JSTestActiveDOMObject();
130 }
131
132 JSTestActiveDOMObject::~JSTestActiveDOMObject()
133 {
134     releaseImplIfNotNull();
135 }
136
137 bool JSTestActiveDOMObject::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
138 {
139     JSTestActiveDOMObject* thisObject = jsCast<JSTestActiveDOMObject*>(cell);
140     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
141     return getStaticValueSlot<JSTestActiveDOMObject, Base>(exec, &JSTestActiveDOMObjectTable, thisObject, propertyName, slot);
142 }
143
144 bool JSTestActiveDOMObject::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
145 {
146     JSTestActiveDOMObject* thisObject = jsCast<JSTestActiveDOMObject*>(object);
147     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
148     if (!shouldAllowAccessToFrame(exec, thisObject->impl()->frame()))
149         return false;
150     return getStaticValueDescriptor<JSTestActiveDOMObject, Base>(exec, &JSTestActiveDOMObjectTable, thisObject, propertyName, descriptor);
151 }
152
153 JSValue jsTestActiveDOMObjectExcitingAttr(ExecState* exec, JSValue slotBase, const Identifier&)
154 {
155     JSTestActiveDOMObject* castedThis = static_cast<JSTestActiveDOMObject*>(asObject(slotBase));
156     if (!castedThis->allowsAccessFrom(exec))
157         return jsUndefined();
158     UNUSED_PARAM(exec);
159     TestActiveDOMObject* impl = static_cast<TestActiveDOMObject*>(castedThis->impl());
160     JSValue result = jsNumber(impl->excitingAttr());
161     return result;
162 }
163
164
165 JSValue jsTestActiveDOMObjectConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
166 {
167     JSTestActiveDOMObject* domObject = static_cast<JSTestActiveDOMObject*>(asObject(slotBase));
168     if (!domObject->allowsAccessFrom(exec))
169         return jsUndefined();
170     return JSTestActiveDOMObject::getConstructor(exec, domObject->globalObject());
171 }
172
173 JSValue JSTestActiveDOMObject::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
174 {
175     return getDOMConstructor<JSTestActiveDOMObjectConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
176 }
177
178 EncodedJSValue JSC_HOST_CALL jsTestActiveDOMObjectPrototypeFunctionExcitingFunction(ExecState* exec)
179 {
180     JSValue thisValue = exec->hostThisValue();
181     if (!thisValue.inherits(&JSTestActiveDOMObject::s_info))
182         return throwVMTypeError(exec);
183     JSTestActiveDOMObject* castedThis = static_cast<JSTestActiveDOMObject*>(asObject(thisValue));
184     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestActiveDOMObject::s_info);
185     if (!castedThis->allowsAccessFrom(exec))
186         return JSValue::encode(jsUndefined());
187     TestActiveDOMObject* impl = static_cast<TestActiveDOMObject*>(castedThis->impl());
188     if (exec->argumentCount() < 1)
189         return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
190     Node* nextChild(toNode(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
191     if (exec->hadException())
192         return JSValue::encode(jsUndefined());
193     impl->excitingFunction(nextChild);
194     return JSValue::encode(jsUndefined());
195 }
196
197 EncodedJSValue JSC_HOST_CALL jsTestActiveDOMObjectPrototypeFunctionPostMessage(ExecState* exec)
198 {
199     JSValue thisValue = exec->hostThisValue();
200     if (!thisValue.inherits(&JSTestActiveDOMObject::s_info))
201         return throwVMTypeError(exec);
202     JSTestActiveDOMObject* castedThis = static_cast<JSTestActiveDOMObject*>(asObject(thisValue));
203     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestActiveDOMObject::s_info);
204     TestActiveDOMObject* impl = static_cast<TestActiveDOMObject*>(castedThis->impl());
205     if (exec->argumentCount() < 1)
206         return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
207     const String& message(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toString(exec)->value(exec)));
208     if (exec->hadException())
209         return JSValue::encode(jsUndefined());
210     impl->postMessage(message);
211     return JSValue::encode(jsUndefined());
212 }
213
214 static inline bool isObservable(JSTestActiveDOMObject* jsTestActiveDOMObject)
215 {
216     if (jsTestActiveDOMObject->hasCustomProperties())
217         return true;
218     return false;
219 }
220
221 bool JSTestActiveDOMObjectOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
222 {
223     JSTestActiveDOMObject* jsTestActiveDOMObject = static_cast<JSTestActiveDOMObject*>(handle.get().asCell());
224     if (!isObservable(jsTestActiveDOMObject))
225         return false;
226     UNUSED_PARAM(visitor);
227     return false;
228 }
229
230 void JSTestActiveDOMObjectOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
231 {
232     JSTestActiveDOMObject* jsTestActiveDOMObject = static_cast<JSTestActiveDOMObject*>(handle.get().asCell());
233     DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
234     uncacheWrapper(world, jsTestActiveDOMObject->impl(), jsTestActiveDOMObject);
235     jsTestActiveDOMObject->releaseImpl();
236 }
237
238 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestActiveDOMObject* impl)
239 {
240     return wrap<JSTestActiveDOMObject>(exec, globalObject, impl);
241 }
242
243 TestActiveDOMObject* toTestActiveDOMObject(JSC::JSValue value)
244 {
245     return value.inherits(&JSTestActiveDOMObject::s_info) ? static_cast<JSTestActiveDOMObject*>(asObject(value))->impl() : 0;
246 }
247
248 }