tizen beta release
[profile/ivi/webkit-efl.git] / DerivedSources / WebCore / JSDOMTokenList.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 "JSDOMTokenList.h"
23
24 #include "DOMTokenList.h"
25 #include "ExceptionCode.h"
26 #include "JSDOMBinding.h"
27 #include "KURL.h"
28 #include <runtime/Error.h>
29 #include <runtime/JSString.h>
30 #include <runtime/PropertyNameArray.h>
31 #include <wtf/GetPtr.h>
32
33 using namespace JSC;
34
35 namespace WebCore {
36
37 ASSERT_CLASS_FITS_IN_CELL(JSDOMTokenList);
38
39 /* Hash table */
40 #if ENABLE(JIT)
41 #define THUNK_GENERATOR(generator) , generator
42 #else
43 #define THUNK_GENERATOR(generator)
44 #endif
45 #if ENABLE(DFG_JIT)
46 #define INTRINSIC(intrinsic) , intrinsic
47 #else
48 #define INTRINSIC(intrinsic)
49 #endif
50
51 static const HashTableValue JSDOMTokenListTableValues[] =
52 {
53     { "length", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMTokenListLength), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
54     { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMTokenListConstructor), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
55     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
56 };
57
58 #undef THUNK_GENERATOR
59 static const HashTable JSDOMTokenListTable = { 5, 3, JSDOMTokenListTableValues, 0 };
60 /* Hash table for constructor */
61 #if ENABLE(JIT)
62 #define THUNK_GENERATOR(generator) , generator
63 #else
64 #define THUNK_GENERATOR(generator)
65 #endif
66 #if ENABLE(DFG_JIT)
67 #define INTRINSIC(intrinsic) , intrinsic
68 #else
69 #define INTRINSIC(intrinsic)
70 #endif
71
72 static const HashTableValue JSDOMTokenListConstructorTableValues[] =
73 {
74     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
75 };
76
77 #undef THUNK_GENERATOR
78 static const HashTable JSDOMTokenListConstructorTable = { 1, 0, JSDOMTokenListConstructorTableValues, 0 };
79 const ClassInfo JSDOMTokenListConstructor::s_info = { "DOMTokenListConstructor", &DOMConstructorObject::s_info, &JSDOMTokenListConstructorTable, 0, CREATE_METHOD_TABLE(JSDOMTokenListConstructor) };
80
81 JSDOMTokenListConstructor::JSDOMTokenListConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
82     : DOMConstructorObject(structure, globalObject)
83 {
84 }
85
86 void JSDOMTokenListConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
87 {
88     Base::finishCreation(exec->globalData());
89     ASSERT(inherits(&s_info));
90     putDirect(exec->globalData(), exec->propertyNames().prototype, JSDOMTokenListPrototype::self(exec, globalObject), DontDelete | ReadOnly);
91 }
92
93 bool JSDOMTokenListConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
94 {
95     return getStaticValueSlot<JSDOMTokenListConstructor, JSDOMWrapper>(exec, &JSDOMTokenListConstructorTable, static_cast<JSDOMTokenListConstructor*>(cell), propertyName, slot);
96 }
97
98 bool JSDOMTokenListConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
99 {
100     return getStaticValueDescriptor<JSDOMTokenListConstructor, JSDOMWrapper>(exec, &JSDOMTokenListConstructorTable, static_cast<JSDOMTokenListConstructor*>(object), propertyName, descriptor);
101 }
102
103 /* Hash table for prototype */
104 #if ENABLE(JIT)
105 #define THUNK_GENERATOR(generator) , generator
106 #else
107 #define THUNK_GENERATOR(generator)
108 #endif
109 #if ENABLE(DFG_JIT)
110 #define INTRINSIC(intrinsic) , intrinsic
111 #else
112 #define INTRINSIC(intrinsic)
113 #endif
114
115 static const HashTableValue JSDOMTokenListPrototypeTableValues[] =
116 {
117     { "item", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMTokenListPrototypeFunctionItem), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
118     { "contains", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMTokenListPrototypeFunctionContains), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
119     { "add", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMTokenListPrototypeFunctionAdd), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
120     { "remove", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMTokenListPrototypeFunctionRemove), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
121     { "toggle", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMTokenListPrototypeFunctionToggle), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
122     { "toString", DontDelete | DontEnum | Function, (intptr_t)static_cast<NativeFunction>(jsDOMTokenListPrototypeFunctionToString), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
123     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
124 };
125
126 #undef THUNK_GENERATOR
127 static const HashTable JSDOMTokenListPrototypeTable = { 16, 15, JSDOMTokenListPrototypeTableValues, 0 };
128 const ClassInfo JSDOMTokenListPrototype::s_info = { "DOMTokenListPrototype", &JSC::JSNonFinalObject::s_info, &JSDOMTokenListPrototypeTable, 0, CREATE_METHOD_TABLE(JSDOMTokenListPrototype) };
129
130 JSObject* JSDOMTokenListPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
131 {
132     return getDOMPrototype<JSDOMTokenList>(exec, globalObject);
133 }
134
135 bool JSDOMTokenListPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
136 {
137     JSDOMTokenListPrototype* thisObject = jsCast<JSDOMTokenListPrototype*>(cell);
138     return getStaticFunctionSlot<JSObject>(exec, &JSDOMTokenListPrototypeTable, thisObject, propertyName, slot);
139 }
140
141 bool JSDOMTokenListPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
142 {
143     JSDOMTokenListPrototype* thisObject = jsCast<JSDOMTokenListPrototype*>(object);
144     return getStaticFunctionDescriptor<JSObject>(exec, &JSDOMTokenListPrototypeTable, thisObject, propertyName, descriptor);
145 }
146
147 const ClassInfo JSDOMTokenList::s_info = { "DOMTokenList", &JSDOMWrapper::s_info, &JSDOMTokenListTable, 0 , CREATE_METHOD_TABLE(JSDOMTokenList) };
148
149 JSDOMTokenList::JSDOMTokenList(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<DOMTokenList> impl)
150     : JSDOMWrapper(structure, globalObject)
151     , m_impl(impl.leakRef())
152 {
153 }
154
155 void JSDOMTokenList::finishCreation(JSGlobalData& globalData)
156 {
157     Base::finishCreation(globalData);
158     ASSERT(inherits(&s_info));
159 }
160
161 JSObject* JSDOMTokenList::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
162 {
163     return JSDOMTokenListPrototype::create(exec->globalData(), globalObject, JSDOMTokenListPrototype::createStructure(globalObject->globalData(), globalObject, globalObject->objectPrototype()));
164 }
165
166 bool JSDOMTokenList::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
167 {
168     JSDOMTokenList* thisObject = jsCast<JSDOMTokenList*>(cell);
169     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
170     const HashEntry* entry = JSDOMTokenListTable.entry(exec, propertyName);
171     if (entry) {
172         slot.setCustom(thisObject, entry->propertyGetter());
173         return true;
174     }
175     bool ok;
176     unsigned index = propertyName.toUInt32(ok);
177     if (ok) {
178         slot.setCustomIndex(thisObject, index, indexGetter);
179         return true;
180     }
181     return getStaticValueSlot<JSDOMTokenList, Base>(exec, &JSDOMTokenListTable, thisObject, propertyName, slot);
182 }
183
184 bool JSDOMTokenList::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
185 {
186     JSDOMTokenList* thisObject = jsCast<JSDOMTokenList*>(object);
187     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
188     const HashEntry* entry = JSDOMTokenListTable.entry(exec, propertyName);
189     if (entry) {
190         PropertySlot slot;
191         slot.setCustom(thisObject, entry->propertyGetter());
192         descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());
193         return true;
194     }
195     bool ok;
196     unsigned index = propertyName.toUInt32(ok);
197     if (ok && index < static_cast<DOMTokenList*>(thisObject->impl())->length()) {
198         PropertySlot slot;
199         slot.setCustomIndex(thisObject, index, indexGetter);
200         descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | ReadOnly);
201         return true;
202     }
203     return getStaticValueDescriptor<JSDOMTokenList, Base>(exec, &JSDOMTokenListTable, thisObject, propertyName, descriptor);
204 }
205
206 bool JSDOMTokenList::getOwnPropertySlotByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, PropertySlot& slot)
207 {
208     JSDOMTokenList* thisObject = jsCast<JSDOMTokenList*>(cell);
209     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
210     if (propertyName < static_cast<DOMTokenList*>(thisObject->impl())->length()) {
211         slot.setCustomIndex(thisObject, propertyName, thisObject->indexGetter);
212         return true;
213     }
214     return thisObject->methodTable()->getOwnPropertySlot(thisObject, exec, Identifier::from(exec, propertyName), slot);
215 }
216
217 JSValue jsDOMTokenListLength(ExecState* exec, JSValue slotBase, const Identifier&)
218 {
219     JSDOMTokenList* castedThis = static_cast<JSDOMTokenList*>(asObject(slotBase));
220     UNUSED_PARAM(exec);
221     DOMTokenList* imp = static_cast<DOMTokenList*>(castedThis->impl());
222     JSValue result = jsNumber(imp->length());
223     return result;
224 }
225
226
227 JSValue jsDOMTokenListConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
228 {
229     JSDOMTokenList* domObject = static_cast<JSDOMTokenList*>(asObject(slotBase));
230     return JSDOMTokenList::getConstructor(exec, domObject->globalObject());
231 }
232
233 void JSDOMTokenList::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
234 {
235     JSDOMTokenList* thisObject = jsCast<JSDOMTokenList*>(object);
236     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
237     for (unsigned i = 0; i < static_cast<DOMTokenList*>(thisObject->impl())->length(); ++i)
238         propertyNames.add(Identifier::from(exec, i));
239      Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
240 }
241
242 JSValue JSDOMTokenList::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
243 {
244     return getDOMConstructor<JSDOMTokenListConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
245 }
246
247 EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionItem(ExecState* exec)
248 {
249     JSValue thisValue = exec->hostThisValue();
250     if (!thisValue.inherits(&JSDOMTokenList::s_info))
251         return throwVMTypeError(exec);
252     JSDOMTokenList* castedThis = static_cast<JSDOMTokenList*>(asObject(thisValue));
253     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDOMTokenList::s_info);
254     DOMTokenList* imp = static_cast<DOMTokenList*>(castedThis->impl());
255     if (exec->argumentCount() < 1)
256         return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
257     unsigned index(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toUInt32(exec));
258     if (exec->hadException())
259         return JSValue::encode(jsUndefined());
260
261     JSC::JSValue result = jsStringOrNull(exec, imp->item(index));
262     return JSValue::encode(result);
263 }
264
265 EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionContains(ExecState* exec)
266 {
267     JSValue thisValue = exec->hostThisValue();
268     if (!thisValue.inherits(&JSDOMTokenList::s_info))
269         return throwVMTypeError(exec);
270     JSDOMTokenList* castedThis = static_cast<JSDOMTokenList*>(asObject(thisValue));
271     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDOMTokenList::s_info);
272     DOMTokenList* imp = static_cast<DOMTokenList*>(castedThis->impl());
273     if (exec->argumentCount() < 1)
274         return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
275     ExceptionCode ec = 0;
276     const String& token(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toString(exec)));
277     if (exec->hadException())
278         return JSValue::encode(jsUndefined());
279
280     JSC::JSValue result = jsBoolean(imp->contains(token, ec));
281     setDOMException(exec, ec);
282     return JSValue::encode(result);
283 }
284
285 EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionAdd(ExecState* exec)
286 {
287     JSValue thisValue = exec->hostThisValue();
288     if (!thisValue.inherits(&JSDOMTokenList::s_info))
289         return throwVMTypeError(exec);
290     JSDOMTokenList* castedThis = static_cast<JSDOMTokenList*>(asObject(thisValue));
291     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDOMTokenList::s_info);
292     DOMTokenList* imp = static_cast<DOMTokenList*>(castedThis->impl());
293     if (exec->argumentCount() < 1)
294         return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
295     ExceptionCode ec = 0;
296     const String& token(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toString(exec)));
297     if (exec->hadException())
298         return JSValue::encode(jsUndefined());
299     imp->add(token, ec);
300     setDOMException(exec, ec);
301     return JSValue::encode(jsUndefined());
302 }
303
304 EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionRemove(ExecState* exec)
305 {
306     JSValue thisValue = exec->hostThisValue();
307     if (!thisValue.inherits(&JSDOMTokenList::s_info))
308         return throwVMTypeError(exec);
309     JSDOMTokenList* castedThis = static_cast<JSDOMTokenList*>(asObject(thisValue));
310     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDOMTokenList::s_info);
311     DOMTokenList* imp = static_cast<DOMTokenList*>(castedThis->impl());
312     if (exec->argumentCount() < 1)
313         return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
314     ExceptionCode ec = 0;
315     const String& token(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toString(exec)));
316     if (exec->hadException())
317         return JSValue::encode(jsUndefined());
318     imp->remove(token, ec);
319     setDOMException(exec, ec);
320     return JSValue::encode(jsUndefined());
321 }
322
323 EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionToggle(ExecState* exec)
324 {
325     JSValue thisValue = exec->hostThisValue();
326     if (!thisValue.inherits(&JSDOMTokenList::s_info))
327         return throwVMTypeError(exec);
328     JSDOMTokenList* castedThis = static_cast<JSDOMTokenList*>(asObject(thisValue));
329     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDOMTokenList::s_info);
330     DOMTokenList* imp = static_cast<DOMTokenList*>(castedThis->impl());
331     if (exec->argumentCount() < 1)
332         return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
333     ExceptionCode ec = 0;
334     const String& token(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toString(exec)));
335     if (exec->hadException())
336         return JSValue::encode(jsUndefined());
337
338     JSC::JSValue result = jsBoolean(imp->toggle(token, ec));
339     setDOMException(exec, ec);
340     return JSValue::encode(result);
341 }
342
343 EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionToString(ExecState* exec)
344 {
345     JSValue thisValue = exec->hostThisValue();
346     if (!thisValue.inherits(&JSDOMTokenList::s_info))
347         return throwVMTypeError(exec);
348     JSDOMTokenList* castedThis = static_cast<JSDOMTokenList*>(asObject(thisValue));
349     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDOMTokenList::s_info);
350     DOMTokenList* imp = static_cast<DOMTokenList*>(castedThis->impl());
351
352     JSC::JSValue result = jsString(exec, imp->toString());
353     return JSValue::encode(result);
354 }
355
356
357 JSValue JSDOMTokenList::indexGetter(ExecState* exec, JSValue slotBase, unsigned index)
358 {
359     JSDOMTokenList* thisObj = static_cast<JSDOMTokenList*>(asObject(slotBase));
360     ASSERT_GC_OBJECT_INHERITS(thisObj, &s_info);
361     return jsStringOrNull(exec, thisObj->impl()->item(index));
362 }
363
364 static inline bool isObservable(JSDOMTokenList* jsDOMTokenList)
365 {
366     if (jsDOMTokenList->hasCustomProperties())
367         return true;
368     return false;
369 }
370
371 bool JSDOMTokenListOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
372 {
373     JSDOMTokenList* jsDOMTokenList = static_cast<JSDOMTokenList*>(handle.get().asCell());
374     if (!isObservable(jsDOMTokenList))
375         return false;
376     Element* element = jsDOMTokenList->impl()->element();
377     if (!element)
378         return false;
379     void* root = WebCore::root(element);
380     return visitor.containsOpaqueRoot(root);
381 }
382
383 void JSDOMTokenListOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
384 {
385     JSDOMTokenList* jsDOMTokenList = static_cast<JSDOMTokenList*>(handle.get().asCell());
386     DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
387     uncacheWrapper(world, jsDOMTokenList->impl(), jsDOMTokenList);
388     jsDOMTokenList->releaseImpl();
389 }
390
391 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, DOMTokenList* impl)
392 {
393     return wrap<JSDOMTokenList>(exec, globalObject, impl);
394 }
395
396 DOMTokenList* toDOMTokenList(JSC::JSValue value)
397 {
398     return value.inherits(&JSDOMTokenList::s_info) ? static_cast<JSDOMTokenList*>(asObject(value))->impl() : 0;
399 }
400
401 }