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