tizen beta release
[framework/web/webkit-efl.git] / DerivedSources / WebCore / JSTouchList.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
23 #if ENABLE(TOUCH_EVENTS)
24
25 #include "JSTouchList.h"
26
27 #include "ExceptionCode.h"
28 #include "JSDOMBinding.h"
29 #include "JSTouch.h"
30 #include "Touch.h"
31 #include "TouchList.h"
32 #include <runtime/Error.h>
33 #include <runtime/PropertyNameArray.h>
34 #include <wtf/GetPtr.h>
35
36 using namespace JSC;
37
38 namespace WebCore {
39
40 ASSERT_CLASS_FITS_IN_CELL(JSTouchList);
41
42 /* Hash table */
43 #if ENABLE(JIT)
44 #define THUNK_GENERATOR(generator) , generator
45 #else
46 #define THUNK_GENERATOR(generator)
47 #endif
48 #if ENABLE(DFG_JIT)
49 #define INTRINSIC(intrinsic) , intrinsic
50 #else
51 #define INTRINSIC(intrinsic)
52 #endif
53
54 static const HashTableValue JSTouchListTableValues[] =
55 {
56     { "length", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTouchListLength), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
57     { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTouchListConstructor), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
58     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
59 };
60
61 #undef THUNK_GENERATOR
62 static const HashTable JSTouchListTable = { 5, 3, JSTouchListTableValues, 0 };
63 /* Hash table for constructor */
64 #if ENABLE(JIT)
65 #define THUNK_GENERATOR(generator) , generator
66 #else
67 #define THUNK_GENERATOR(generator)
68 #endif
69 #if ENABLE(DFG_JIT)
70 #define INTRINSIC(intrinsic) , intrinsic
71 #else
72 #define INTRINSIC(intrinsic)
73 #endif
74
75 static const HashTableValue JSTouchListConstructorTableValues[] =
76 {
77     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
78 };
79
80 #undef THUNK_GENERATOR
81 static const HashTable JSTouchListConstructorTable = { 1, 0, JSTouchListConstructorTableValues, 0 };
82 const ClassInfo JSTouchListConstructor::s_info = { "TouchListConstructor", &DOMConstructorObject::s_info, &JSTouchListConstructorTable, 0, CREATE_METHOD_TABLE(JSTouchListConstructor) };
83
84 JSTouchListConstructor::JSTouchListConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
85     : DOMConstructorObject(structure, globalObject)
86 {
87 }
88
89 void JSTouchListConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
90 {
91     Base::finishCreation(exec->globalData());
92     ASSERT(inherits(&s_info));
93     putDirect(exec->globalData(), exec->propertyNames().prototype, JSTouchListPrototype::self(exec, globalObject), DontDelete | ReadOnly);
94 }
95
96 bool JSTouchListConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
97 {
98     return getStaticValueSlot<JSTouchListConstructor, JSDOMWrapper>(exec, &JSTouchListConstructorTable, static_cast<JSTouchListConstructor*>(cell), propertyName, slot);
99 }
100
101 bool JSTouchListConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
102 {
103     return getStaticValueDescriptor<JSTouchListConstructor, JSDOMWrapper>(exec, &JSTouchListConstructorTable, static_cast<JSTouchListConstructor*>(object), propertyName, descriptor);
104 }
105
106 /* Hash table for prototype */
107 #if ENABLE(JIT)
108 #define THUNK_GENERATOR(generator) , generator
109 #else
110 #define THUNK_GENERATOR(generator)
111 #endif
112 #if ENABLE(DFG_JIT)
113 #define INTRINSIC(intrinsic) , intrinsic
114 #else
115 #define INTRINSIC(intrinsic)
116 #endif
117
118 static const HashTableValue JSTouchListPrototypeTableValues[] =
119 {
120     { "item", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTouchListPrototypeFunctionItem), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
121     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
122 };
123
124 #undef THUNK_GENERATOR
125 static const HashTable JSTouchListPrototypeTable = { 2, 1, JSTouchListPrototypeTableValues, 0 };
126 const ClassInfo JSTouchListPrototype::s_info = { "TouchListPrototype", &JSC::JSNonFinalObject::s_info, &JSTouchListPrototypeTable, 0, CREATE_METHOD_TABLE(JSTouchListPrototype) };
127
128 JSObject* JSTouchListPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
129 {
130     return getDOMPrototype<JSTouchList>(exec, globalObject);
131 }
132
133 bool JSTouchListPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
134 {
135     JSTouchListPrototype* thisObject = jsCast<JSTouchListPrototype*>(cell);
136     return getStaticFunctionSlot<JSObject>(exec, &JSTouchListPrototypeTable, thisObject, propertyName, slot);
137 }
138
139 bool JSTouchListPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
140 {
141     JSTouchListPrototype* thisObject = jsCast<JSTouchListPrototype*>(object);
142     return getStaticFunctionDescriptor<JSObject>(exec, &JSTouchListPrototypeTable, thisObject, propertyName, descriptor);
143 }
144
145 const ClassInfo JSTouchList::s_info = { "TouchList", &JSDOMWrapper::s_info, &JSTouchListTable, 0 , CREATE_METHOD_TABLE(JSTouchList) };
146
147 JSTouchList::JSTouchList(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<TouchList> impl)
148     : JSDOMWrapper(structure, globalObject)
149     , m_impl(impl.leakRef())
150 {
151 }
152
153 void JSTouchList::finishCreation(JSGlobalData& globalData)
154 {
155     Base::finishCreation(globalData);
156     ASSERT(inherits(&s_info));
157 }
158
159 JSObject* JSTouchList::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
160 {
161     return JSTouchListPrototype::create(exec->globalData(), globalObject, JSTouchListPrototype::createStructure(globalObject->globalData(), globalObject, globalObject->objectPrototype()));
162 }
163
164 bool JSTouchList::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
165 {
166     JSTouchList* thisObject = jsCast<JSTouchList*>(cell);
167     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
168     const HashEntry* entry = JSTouchListTable.entry(exec, propertyName);
169     if (entry) {
170         slot.setCustom(thisObject, entry->propertyGetter());
171         return true;
172     }
173     bool ok;
174     unsigned index = propertyName.toUInt32(ok);
175     if (ok && index < static_cast<TouchList*>(thisObject->impl())->length()) {
176         slot.setCustomIndex(thisObject, index, indexGetter);
177         return true;
178     }
179     return getStaticValueSlot<JSTouchList, Base>(exec, &JSTouchListTable, thisObject, propertyName, slot);
180 }
181
182 bool JSTouchList::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
183 {
184     JSTouchList* thisObject = jsCast<JSTouchList*>(object);
185     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
186     const HashEntry* entry = JSTouchListTable.entry(exec, propertyName);
187     if (entry) {
188         PropertySlot slot;
189         slot.setCustom(thisObject, entry->propertyGetter());
190         descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());
191         return true;
192     }
193     bool ok;
194     unsigned index = propertyName.toUInt32(ok);
195     if (ok && index < static_cast<TouchList*>(thisObject->impl())->length()) {
196         PropertySlot slot;
197         slot.setCustomIndex(thisObject, index, indexGetter);
198         descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | ReadOnly);
199         return true;
200     }
201     return getStaticValueDescriptor<JSTouchList, Base>(exec, &JSTouchListTable, thisObject, propertyName, descriptor);
202 }
203
204 bool JSTouchList::getOwnPropertySlotByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, PropertySlot& slot)
205 {
206     JSTouchList* thisObject = jsCast<JSTouchList*>(cell);
207     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
208     if (propertyName < static_cast<TouchList*>(thisObject->impl())->length()) {
209         slot.setCustomIndex(thisObject, propertyName, thisObject->indexGetter);
210         return true;
211     }
212     return thisObject->methodTable()->getOwnPropertySlot(thisObject, exec, Identifier::from(exec, propertyName), slot);
213 }
214
215 JSValue jsTouchListLength(ExecState* exec, JSValue slotBase, const Identifier&)
216 {
217     JSTouchList* castedThis = static_cast<JSTouchList*>(asObject(slotBase));
218     UNUSED_PARAM(exec);
219     TouchList* imp = static_cast<TouchList*>(castedThis->impl());
220     JSValue result = jsNumber(imp->length());
221     return result;
222 }
223
224
225 JSValue jsTouchListConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
226 {
227     JSTouchList* domObject = static_cast<JSTouchList*>(asObject(slotBase));
228     return JSTouchList::getConstructor(exec, domObject->globalObject());
229 }
230
231 void JSTouchList::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
232 {
233     JSTouchList* thisObject = jsCast<JSTouchList*>(object);
234     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
235     for (unsigned i = 0; i < static_cast<TouchList*>(thisObject->impl())->length(); ++i)
236         propertyNames.add(Identifier::from(exec, i));
237      Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
238 }
239
240 JSValue JSTouchList::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
241 {
242     return getDOMConstructor<JSTouchListConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
243 }
244
245 EncodedJSValue JSC_HOST_CALL jsTouchListPrototypeFunctionItem(ExecState* exec)
246 {
247     JSValue thisValue = exec->hostThisValue();
248     if (!thisValue.inherits(&JSTouchList::s_info))
249         return throwVMTypeError(exec);
250     JSTouchList* castedThis = static_cast<JSTouchList*>(asObject(thisValue));
251     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTouchList::s_info);
252     TouchList* imp = static_cast<TouchList*>(castedThis->impl());
253     if (exec->argumentCount() < 1)
254         return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
255     unsigned index(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toUInt32(exec));
256     if (exec->hadException())
257         return JSValue::encode(jsUndefined());
258
259     JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->item(index)));
260     return JSValue::encode(result);
261 }
262
263
264 JSValue JSTouchList::indexGetter(ExecState* exec, JSValue slotBase, unsigned index)
265 {
266     JSTouchList* thisObj = static_cast<JSTouchList*>(asObject(slotBase));
267     ASSERT_GC_OBJECT_INHERITS(thisObj, &s_info);
268     return toJS(exec, thisObj->globalObject(), static_cast<TouchList*>(thisObj->impl())->item(index));
269 }
270
271 static inline bool isObservable(JSTouchList* jsTouchList)
272 {
273     if (jsTouchList->hasCustomProperties())
274         return true;
275     return false;
276 }
277
278 bool JSTouchListOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
279 {
280     JSTouchList* jsTouchList = static_cast<JSTouchList*>(handle.get().asCell());
281     if (!isObservable(jsTouchList))
282         return false;
283     UNUSED_PARAM(visitor);
284     return false;
285 }
286
287 void JSTouchListOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
288 {
289     JSTouchList* jsTouchList = static_cast<JSTouchList*>(handle.get().asCell());
290     DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
291     uncacheWrapper(world, jsTouchList->impl(), jsTouchList);
292     jsTouchList->releaseImpl();
293 }
294
295 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TouchList* impl)
296 {
297     return wrap<JSTouchList>(exec, globalObject, impl);
298 }
299
300 TouchList* toTouchList(JSC::JSValue value)
301 {
302     return value.inherits(&JSTouchList::s_info) ? static_cast<JSTouchList*>(asObject(value))->impl() : 0;
303 }
304
305 }
306
307 #endif // ENABLE(TOUCH_EVENTS)