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