tizen beta release
[profile/ivi/webkit-efl.git] / DerivedSources / WebCore / JSFileList.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 "JSFileList.h"
23
24 #include "ExceptionCode.h"
25 #include "File.h"
26 #include "FileList.h"
27 #include "JSDOMBinding.h"
28 #include "JSFile.h"
29 #include <runtime/Error.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(JSFileList);
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 JSFileListTableValues[] =
52 {
53     { "length", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileListLength), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
54     { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileListConstructor), (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 JSFileListTable = { 5, 3, JSFileListTableValues, 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 JSFileListConstructorTableValues[] =
73 {
74     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
75 };
76
77 #undef THUNK_GENERATOR
78 static const HashTable JSFileListConstructorTable = { 1, 0, JSFileListConstructorTableValues, 0 };
79 const ClassInfo JSFileListConstructor::s_info = { "FileListConstructor", &DOMConstructorObject::s_info, &JSFileListConstructorTable, 0, CREATE_METHOD_TABLE(JSFileListConstructor) };
80
81 JSFileListConstructor::JSFileListConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
82     : DOMConstructorObject(structure, globalObject)
83 {
84 }
85
86 void JSFileListConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
87 {
88     Base::finishCreation(exec->globalData());
89     ASSERT(inherits(&s_info));
90     putDirect(exec->globalData(), exec->propertyNames().prototype, JSFileListPrototype::self(exec, globalObject), DontDelete | ReadOnly);
91 }
92
93 bool JSFileListConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
94 {
95     return getStaticValueSlot<JSFileListConstructor, JSDOMWrapper>(exec, &JSFileListConstructorTable, static_cast<JSFileListConstructor*>(cell), propertyName, slot);
96 }
97
98 bool JSFileListConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
99 {
100     return getStaticValueDescriptor<JSFileListConstructor, JSDOMWrapper>(exec, &JSFileListConstructorTable, static_cast<JSFileListConstructor*>(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 JSFileListPrototypeTableValues[] =
116 {
117     { "item", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsFileListPrototypeFunctionItem), (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 JSFileListPrototypeTable = { 2, 1, JSFileListPrototypeTableValues, 0 };
123 static const HashTable* getJSFileListPrototypeTable(ExecState* exec)
124 {
125     return getHashTableForGlobalData(exec->globalData(), &JSFileListPrototypeTable);
126 }
127
128 const ClassInfo JSFileListPrototype::s_info = { "FileListPrototype", &JSC::JSNonFinalObject::s_info, 0, getJSFileListPrototypeTable, CREATE_METHOD_TABLE(JSFileListPrototype) };
129
130 JSObject* JSFileListPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
131 {
132     return getDOMPrototype<JSFileList>(exec, globalObject);
133 }
134
135 bool JSFileListPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
136 {
137     JSFileListPrototype* thisObject = jsCast<JSFileListPrototype*>(cell);
138     return getStaticFunctionSlot<JSObject>(exec, getJSFileListPrototypeTable(exec), thisObject, propertyName, slot);
139 }
140
141 bool JSFileListPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
142 {
143     JSFileListPrototype* thisObject = jsCast<JSFileListPrototype*>(object);
144     return getStaticFunctionDescriptor<JSObject>(exec, getJSFileListPrototypeTable(exec), thisObject, propertyName, descriptor);
145 }
146
147 static const HashTable* getJSFileListTable(ExecState* exec)
148 {
149     return getHashTableForGlobalData(exec->globalData(), &JSFileListTable);
150 }
151
152 const ClassInfo JSFileList::s_info = { "FileList", &JSDOMWrapper::s_info, 0, getJSFileListTable , CREATE_METHOD_TABLE(JSFileList) };
153
154 JSFileList::JSFileList(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<FileList> impl)
155     : JSDOMWrapper(structure, globalObject)
156     , m_impl(impl.leakRef())
157 {
158 }
159
160 void JSFileList::finishCreation(JSGlobalData& globalData)
161 {
162     Base::finishCreation(globalData);
163     ASSERT(inherits(&s_info));
164 }
165
166 JSObject* JSFileList::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
167 {
168     return JSFileListPrototype::create(exec->globalData(), globalObject, JSFileListPrototype::createStructure(globalObject->globalData(), globalObject, globalObject->objectPrototype()));
169 }
170
171 bool JSFileList::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
172 {
173     JSFileList* thisObject = jsCast<JSFileList*>(cell);
174     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
175     const HashEntry* entry = JSFileListTable.entry(exec, propertyName);
176     if (entry) {
177         slot.setCustom(thisObject, entry->propertyGetter());
178         return true;
179     }
180     bool ok;
181     unsigned index = propertyName.toUInt32(ok);
182     if (ok && index < static_cast<FileList*>(thisObject->impl())->length()) {
183         slot.setCustomIndex(thisObject, index, indexGetter);
184         return true;
185     }
186     return getStaticValueSlot<JSFileList, Base>(exec, getJSFileListTable(exec), thisObject, propertyName, slot);
187 }
188
189 bool JSFileList::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
190 {
191     JSFileList* thisObject = jsCast<JSFileList*>(object);
192     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
193     const HashEntry* entry = JSFileListTable.entry(exec, propertyName);
194     if (entry) {
195         PropertySlot slot;
196         slot.setCustom(thisObject, entry->propertyGetter());
197         descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());
198         return true;
199     }
200     bool ok;
201     unsigned index = propertyName.toUInt32(ok);
202     if (ok && index < static_cast<FileList*>(thisObject->impl())->length()) {
203         PropertySlot slot;
204         slot.setCustomIndex(thisObject, index, indexGetter);
205         descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | ReadOnly);
206         return true;
207     }
208     return getStaticValueDescriptor<JSFileList, Base>(exec, getJSFileListTable(exec), thisObject, propertyName, descriptor);
209 }
210
211 bool JSFileList::getOwnPropertySlotByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, PropertySlot& slot)
212 {
213     JSFileList* thisObject = jsCast<JSFileList*>(cell);
214     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
215     if (propertyName < static_cast<FileList*>(thisObject->impl())->length()) {
216         slot.setCustomIndex(thisObject, propertyName, thisObject->indexGetter);
217         return true;
218     }
219     return thisObject->methodTable()->getOwnPropertySlot(thisObject, exec, Identifier::from(exec, propertyName), slot);
220 }
221
222 JSValue jsFileListLength(ExecState* exec, JSValue slotBase, const Identifier&)
223 {
224     JSFileList* castedThis = static_cast<JSFileList*>(asObject(slotBase));
225     UNUSED_PARAM(exec);
226     FileList* imp = static_cast<FileList*>(castedThis->impl());
227     JSValue result = jsNumber(imp->length());
228     return result;
229 }
230
231
232 JSValue jsFileListConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
233 {
234     JSFileList* domObject = static_cast<JSFileList*>(asObject(slotBase));
235     return JSFileList::getConstructor(exec, domObject->globalObject());
236 }
237
238 void JSFileList::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
239 {
240     JSFileList* thisObject = jsCast<JSFileList*>(object);
241     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
242     for (unsigned i = 0; i < static_cast<FileList*>(thisObject->impl())->length(); ++i)
243         propertyNames.add(Identifier::from(exec, i));
244      Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
245 }
246
247 JSValue JSFileList::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
248 {
249     return getDOMConstructor<JSFileListConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
250 }
251
252 EncodedJSValue JSC_HOST_CALL jsFileListPrototypeFunctionItem(ExecState* exec)
253 {
254     JSValue thisValue = exec->hostThisValue();
255     if (!thisValue.inherits(&JSFileList::s_info))
256         return throwVMTypeError(exec);
257     JSFileList* castedThis = static_cast<JSFileList*>(asObject(thisValue));
258     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSFileList::s_info);
259     FileList* imp = static_cast<FileList*>(castedThis->impl());
260     if (exec->argumentCount() < 1)
261         return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
262     int index(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toUInt32(exec));
263     if (index < 0) {
264         setDOMException(exec, INDEX_SIZE_ERR);
265         return JSValue::encode(jsUndefined());
266     }
267     if (exec->hadException())
268         return JSValue::encode(jsUndefined());
269
270     JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->item(index)));
271     return JSValue::encode(result);
272 }
273
274
275 JSValue JSFileList::indexGetter(ExecState* exec, JSValue slotBase, unsigned index)
276 {
277     JSFileList* thisObj = static_cast<JSFileList*>(asObject(slotBase));
278     ASSERT_GC_OBJECT_INHERITS(thisObj, &s_info);
279     return toJS(exec, thisObj->globalObject(), static_cast<FileList*>(thisObj->impl())->item(index));
280 }
281
282 static inline bool isObservable(JSFileList* jsFileList)
283 {
284     if (jsFileList->hasCustomProperties())
285         return true;
286     return false;
287 }
288
289 bool JSFileListOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
290 {
291     JSFileList* jsFileList = static_cast<JSFileList*>(handle.get().asCell());
292     if (!isObservable(jsFileList))
293         return false;
294     UNUSED_PARAM(visitor);
295     return false;
296 }
297
298 void JSFileListOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
299 {
300     JSFileList* jsFileList = static_cast<JSFileList*>(handle.get().asCell());
301     DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
302     uncacheWrapper(world, jsFileList->impl(), jsFileList);
303     jsFileList->releaseImpl();
304 }
305
306 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, FileList* impl)
307 {
308     return wrap<JSFileList>(exec, globalObject, impl);
309 }
310
311 FileList* toFileList(JSC::JSValue value)
312 {
313     return value.inherits(&JSFileList::s_info) ? static_cast<JSFileList*>(asObject(value))->impl() : 0;
314 }
315
316 }