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