|
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 "AtomicString.h" |
|
25 #include "DOMPlugin.h" |
|
26 #include "DOMPluginArray.h" |
|
27 #include "JSDOMPlugin.h" |
|
28 #include <runtime/Error.h> |
|
29 #include <runtime/JSNumberCell.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(JSDOMPluginArray); |
|
38 |
|
39 /* Hash table */ |
|
40 #if ENABLE(JIT) |
|
41 #define THUNK_GENERATOR(generator) , generator |
|
42 #else |
|
43 #define THUNK_GENERATOR(generator) |
|
44 #endif |
|
45 |
|
46 static const HashTableValue JSDOMPluginArrayTableValues[3] = |
|
47 { |
|
48 { "length", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMPluginArrayLength), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
49 { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMPluginArrayConstructor), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
50 { 0, 0, 0, 0 THUNK_GENERATOR(0) } |
|
51 }; |
|
52 |
|
53 #undef THUNK_GENERATOR |
|
54 static JSC_CONST_HASHTABLE HashTable JSDOMPluginArrayTable = { 5, 3, JSDOMPluginArrayTableValues, 0 }; |
|
55 /* Hash table for constructor */ |
|
56 #if ENABLE(JIT) |
|
57 #define THUNK_GENERATOR(generator) , generator |
|
58 #else |
|
59 #define THUNK_GENERATOR(generator) |
|
60 #endif |
|
61 |
|
62 static const HashTableValue JSDOMPluginArrayConstructorTableValues[1] = |
|
63 { |
|
64 { 0, 0, 0, 0 THUNK_GENERATOR(0) } |
|
65 }; |
|
66 |
|
67 #undef THUNK_GENERATOR |
|
68 static JSC_CONST_HASHTABLE HashTable JSDOMPluginArrayConstructorTable = { 1, 0, JSDOMPluginArrayConstructorTableValues, 0 }; |
|
69 class JSDOMPluginArrayConstructor : public DOMConstructorObject { |
|
70 public: |
|
71 JSDOMPluginArrayConstructor(JSC::ExecState*, JSDOMGlobalObject*); |
|
72 |
|
73 virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); |
|
74 virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); |
|
75 virtual const JSC::ClassInfo* classInfo() const { return &s_info; } |
|
76 static const JSC::ClassInfo s_info; |
|
77 static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) |
|
78 { |
|
79 return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); |
|
80 } |
|
81 protected: |
|
82 static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; |
|
83 }; |
|
84 |
|
85 const ClassInfo JSDOMPluginArrayConstructor::s_info = { "PluginArrayConstructor", 0, &JSDOMPluginArrayConstructorTable, 0 }; |
|
86 |
|
87 JSDOMPluginArrayConstructor::JSDOMPluginArrayConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) |
|
88 : DOMConstructorObject(JSDOMPluginArrayConstructor::createStructure(globalObject->objectPrototype()), globalObject) |
|
89 { |
|
90 putDirect(exec->propertyNames().prototype, JSDOMPluginArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly); |
|
91 } |
|
92 |
|
93 bool JSDOMPluginArrayConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
94 { |
|
95 return getStaticValueSlot<JSDOMPluginArrayConstructor, DOMObject>(exec, &JSDOMPluginArrayConstructorTable, this, propertyName, slot); |
|
96 } |
|
97 |
|
98 bool JSDOMPluginArrayConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) |
|
99 { |
|
100 return getStaticValueDescriptor<JSDOMPluginArrayConstructor, DOMObject>(exec, &JSDOMPluginArrayConstructorTable, this, 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 |
|
110 static const HashTableValue JSDOMPluginArrayPrototypeTableValues[4] = |
|
111 { |
|
112 { "item", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMPluginArrayPrototypeFunctionItem), (intptr_t)1 THUNK_GENERATOR(0) }, |
|
113 { "namedItem", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMPluginArrayPrototypeFunctionNamedItem), (intptr_t)1 THUNK_GENERATOR(0) }, |
|
114 { "refresh", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMPluginArrayPrototypeFunctionRefresh), (intptr_t)1 THUNK_GENERATOR(0) }, |
|
115 { 0, 0, 0, 0 THUNK_GENERATOR(0) } |
|
116 }; |
|
117 |
|
118 #undef THUNK_GENERATOR |
|
119 static JSC_CONST_HASHTABLE HashTable JSDOMPluginArrayPrototypeTable = { 8, 7, JSDOMPluginArrayPrototypeTableValues, 0 }; |
|
120 const ClassInfo JSDOMPluginArrayPrototype::s_info = { "PluginArrayPrototype", 0, &JSDOMPluginArrayPrototypeTable, 0 }; |
|
121 |
|
122 JSObject* JSDOMPluginArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject) |
|
123 { |
|
124 return getDOMPrototype<JSDOMPluginArray>(exec, globalObject); |
|
125 } |
|
126 |
|
127 bool JSDOMPluginArrayPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
128 { |
|
129 return getStaticFunctionSlot<JSObject>(exec, &JSDOMPluginArrayPrototypeTable, this, propertyName, slot); |
|
130 } |
|
131 |
|
132 bool JSDOMPluginArrayPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) |
|
133 { |
|
134 return getStaticFunctionDescriptor<JSObject>(exec, &JSDOMPluginArrayPrototypeTable, this, propertyName, descriptor); |
|
135 } |
|
136 |
|
137 const ClassInfo JSDOMPluginArray::s_info = { "PluginArray", 0, &JSDOMPluginArrayTable, 0 }; |
|
138 |
|
139 JSDOMPluginArray::JSDOMPluginArray(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<DOMPluginArray> impl) |
|
140 : DOMObjectWithGlobalPointer(structure, globalObject) |
|
141 , m_impl(impl) |
|
142 { |
|
143 } |
|
144 |
|
145 JSDOMPluginArray::~JSDOMPluginArray() |
|
146 { |
|
147 forgetDOMObject(this, impl()); |
|
148 } |
|
149 |
|
150 JSObject* JSDOMPluginArray::createPrototype(ExecState* exec, JSGlobalObject* globalObject) |
|
151 { |
|
152 return new (exec) JSDOMPluginArrayPrototype(globalObject, JSDOMPluginArrayPrototype::createStructure(globalObject->objectPrototype())); |
|
153 } |
|
154 |
|
155 bool JSDOMPluginArray::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
156 { |
|
157 const HashEntry* entry = JSDOMPluginArrayTable.entry(exec, propertyName); |
|
158 if (entry) { |
|
159 slot.setCustom(this, entry->propertyGetter()); |
|
160 return true; |
|
161 } |
|
162 bool ok; |
|
163 unsigned index = propertyName.toUInt32(&ok, false); |
|
164 if (ok && index < static_cast<DOMPluginArray*>(impl())->length()) { |
|
165 slot.setCustomIndex(this, index, indexGetter); |
|
166 return true; |
|
167 } |
|
168 if (canGetItemsForName(exec, static_cast<DOMPluginArray*>(impl()), propertyName)) { |
|
169 slot.setCustom(this, nameGetter); |
|
170 return true; |
|
171 } |
|
172 return getStaticValueSlot<JSDOMPluginArray, Base>(exec, &JSDOMPluginArrayTable, this, propertyName, slot); |
|
173 } |
|
174 |
|
175 bool JSDOMPluginArray::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) |
|
176 { |
|
177 const HashEntry* entry = JSDOMPluginArrayTable.entry(exec, propertyName); |
|
178 if (entry) { |
|
179 PropertySlot slot; |
|
180 slot.setCustom(this, entry->propertyGetter()); |
|
181 descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes()); |
|
182 return true; |
|
183 } |
|
184 bool ok; |
|
185 unsigned index = propertyName.toUInt32(&ok, false); |
|
186 if (ok && index < static_cast<DOMPluginArray*>(impl())->length()) { |
|
187 PropertySlot slot; |
|
188 slot.setCustomIndex(this, index, indexGetter); |
|
189 descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | ReadOnly); |
|
190 return true; |
|
191 } |
|
192 if (canGetItemsForName(exec, static_cast<DOMPluginArray*>(impl()), propertyName)) { |
|
193 PropertySlot slot; |
|
194 slot.setCustom(this, nameGetter); |
|
195 descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum); |
|
196 return true; |
|
197 } |
|
198 return getStaticValueDescriptor<JSDOMPluginArray, Base>(exec, &JSDOMPluginArrayTable, this, propertyName, descriptor); |
|
199 } |
|
200 |
|
201 bool JSDOMPluginArray::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot) |
|
202 { |
|
203 if (propertyName < static_cast<DOMPluginArray*>(impl())->length()) { |
|
204 slot.setCustomIndex(this, propertyName, indexGetter); |
|
205 return true; |
|
206 } |
|
207 return getOwnPropertySlot(exec, Identifier::from(exec, propertyName), slot); |
|
208 } |
|
209 |
|
210 JSValue jsDOMPluginArrayLength(ExecState* exec, JSValue slotBase, const Identifier&) |
|
211 { |
|
212 JSDOMPluginArray* castedThis = static_cast<JSDOMPluginArray*>(asObject(slotBase)); |
|
213 UNUSED_PARAM(exec); |
|
214 DOMPluginArray* imp = static_cast<DOMPluginArray*>(castedThis->impl()); |
|
215 JSValue result = jsNumber(exec, imp->length()); |
|
216 return result; |
|
217 } |
|
218 |
|
219 JSValue jsDOMPluginArrayConstructor(ExecState* exec, JSValue slotBase, const Identifier&) |
|
220 { |
|
221 JSDOMPluginArray* domObject = static_cast<JSDOMPluginArray*>(asObject(slotBase)); |
|
222 return JSDOMPluginArray::getConstructor(exec, domObject->globalObject()); |
|
223 } |
|
224 void JSDOMPluginArray::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) |
|
225 { |
|
226 for (unsigned i = 0; i < static_cast<DOMPluginArray*>(impl())->length(); ++i) |
|
227 propertyNames.add(Identifier::from(exec, i)); |
|
228 Base::getOwnPropertyNames(exec, propertyNames, mode); |
|
229 } |
|
230 |
|
231 JSValue JSDOMPluginArray::getConstructor(ExecState* exec, JSGlobalObject* globalObject) |
|
232 { |
|
233 return getDOMConstructor<JSDOMPluginArrayConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject)); |
|
234 } |
|
235 |
|
236 EncodedJSValue JSC_HOST_CALL jsDOMPluginArrayPrototypeFunctionItem(ExecState* exec) |
|
237 { |
|
238 JSValue thisValue = exec->hostThisValue(); |
|
239 if (!thisValue.inherits(&JSDOMPluginArray::s_info)) |
|
240 return throwVMTypeError(exec); |
|
241 JSDOMPluginArray* castedThis = static_cast<JSDOMPluginArray*>(asObject(thisValue)); |
|
242 DOMPluginArray* imp = static_cast<DOMPluginArray*>(castedThis->impl()); |
|
243 unsigned index = exec->argument(0).toInt32(exec); |
|
244 |
|
245 |
|
246 JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->item(index))); |
|
247 return JSValue::encode(result); |
|
248 } |
|
249 |
|
250 EncodedJSValue JSC_HOST_CALL jsDOMPluginArrayPrototypeFunctionNamedItem(ExecState* exec) |
|
251 { |
|
252 JSValue thisValue = exec->hostThisValue(); |
|
253 if (!thisValue.inherits(&JSDOMPluginArray::s_info)) |
|
254 return throwVMTypeError(exec); |
|
255 JSDOMPluginArray* castedThis = static_cast<JSDOMPluginArray*>(asObject(thisValue)); |
|
256 DOMPluginArray* imp = static_cast<DOMPluginArray*>(castedThis->impl()); |
|
257 const String& name = ustringToString(exec->argument(0).toString(exec)); |
|
258 |
|
259 |
|
260 JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->namedItem(name))); |
|
261 return JSValue::encode(result); |
|
262 } |
|
263 |
|
264 EncodedJSValue JSC_HOST_CALL jsDOMPluginArrayPrototypeFunctionRefresh(ExecState* exec) |
|
265 { |
|
266 JSValue thisValue = exec->hostThisValue(); |
|
267 if (!thisValue.inherits(&JSDOMPluginArray::s_info)) |
|
268 return throwVMTypeError(exec); |
|
269 JSDOMPluginArray* castedThis = static_cast<JSDOMPluginArray*>(asObject(thisValue)); |
|
270 DOMPluginArray* imp = static_cast<DOMPluginArray*>(castedThis->impl()); |
|
271 bool reload = exec->argument(0).toBoolean(exec); |
|
272 |
|
273 imp->refresh(reload); |
|
274 return JSValue::encode(jsUndefined()); |
|
275 } |
|
276 |
|
277 |
|
278 JSValue JSDOMPluginArray::indexGetter(ExecState* exec, JSValue slotBase, unsigned index) |
|
279 { |
|
280 JSDOMPluginArray* thisObj = static_cast<JSDOMPluginArray*>(asObject(slotBase)); |
|
281 return toJS(exec, thisObj->globalObject(), static_cast<DOMPluginArray*>(thisObj->impl())->item(index)); |
|
282 } |
|
283 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, DOMPluginArray* object) |
|
284 { |
|
285 return getDOMObjectWrapper<JSDOMPluginArray>(exec, globalObject, object); |
|
286 } |
|
287 DOMPluginArray* toDOMPluginArray(JSC::JSValue value) |
|
288 { |
|
289 return value.inherits(&JSDOMPluginArray::s_info) ? static_cast<JSDOMPluginArray*>(asObject(value))->impl() : 0; |
|
290 } |
|
291 |
|
292 } |