|
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 "JSNamedNodeMap.h" |
|
23 |
|
24 #include "AtomicString.h" |
|
25 #include "JSNode.h" |
|
26 #include "NamedNodeMap.h" |
|
27 #include "Node.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(JSNamedNodeMap); |
|
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 JSNamedNodeMapTableValues[3] = |
|
47 { |
|
48 { "length", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNamedNodeMapLength), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
49 { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNamedNodeMapConstructor), (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 JSNamedNodeMapTable = { 5, 3, JSNamedNodeMapTableValues, 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 JSNamedNodeMapConstructorTableValues[1] = |
|
63 { |
|
64 { 0, 0, 0, 0 THUNK_GENERATOR(0) } |
|
65 }; |
|
66 |
|
67 #undef THUNK_GENERATOR |
|
68 static JSC_CONST_HASHTABLE HashTable JSNamedNodeMapConstructorTable = { 1, 0, JSNamedNodeMapConstructorTableValues, 0 }; |
|
69 class JSNamedNodeMapConstructor : public DOMConstructorObject { |
|
70 public: |
|
71 JSNamedNodeMapConstructor(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 JSNamedNodeMapConstructor::s_info = { "NamedNodeMapConstructor", 0, &JSNamedNodeMapConstructorTable, 0 }; |
|
86 |
|
87 JSNamedNodeMapConstructor::JSNamedNodeMapConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) |
|
88 : DOMConstructorObject(JSNamedNodeMapConstructor::createStructure(globalObject->objectPrototype()), globalObject) |
|
89 { |
|
90 putDirect(exec->propertyNames().prototype, JSNamedNodeMapPrototype::self(exec, globalObject), DontDelete | ReadOnly); |
|
91 } |
|
92 |
|
93 bool JSNamedNodeMapConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
94 { |
|
95 return getStaticValueSlot<JSNamedNodeMapConstructor, DOMObject>(exec, &JSNamedNodeMapConstructorTable, this, propertyName, slot); |
|
96 } |
|
97 |
|
98 bool JSNamedNodeMapConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) |
|
99 { |
|
100 return getStaticValueDescriptor<JSNamedNodeMapConstructor, DOMObject>(exec, &JSNamedNodeMapConstructorTable, 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 JSNamedNodeMapPrototypeTableValues[8] = |
|
111 { |
|
112 { "getNamedItem", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsNamedNodeMapPrototypeFunctionGetNamedItem), (intptr_t)1 THUNK_GENERATOR(0) }, |
|
113 { "setNamedItem", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsNamedNodeMapPrototypeFunctionSetNamedItem), (intptr_t)1 THUNK_GENERATOR(0) }, |
|
114 { "removeNamedItem", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsNamedNodeMapPrototypeFunctionRemoveNamedItem), (intptr_t)1 THUNK_GENERATOR(0) }, |
|
115 { "item", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsNamedNodeMapPrototypeFunctionItem), (intptr_t)1 THUNK_GENERATOR(0) }, |
|
116 { "getNamedItemNS", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsNamedNodeMapPrototypeFunctionGetNamedItemNS), (intptr_t)2 THUNK_GENERATOR(0) }, |
|
117 { "setNamedItemNS", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsNamedNodeMapPrototypeFunctionSetNamedItemNS), (intptr_t)1 THUNK_GENERATOR(0) }, |
|
118 { "removeNamedItemNS", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsNamedNodeMapPrototypeFunctionRemoveNamedItemNS), (intptr_t)2 THUNK_GENERATOR(0) }, |
|
119 { 0, 0, 0, 0 THUNK_GENERATOR(0) } |
|
120 }; |
|
121 |
|
122 #undef THUNK_GENERATOR |
|
123 static JSC_CONST_HASHTABLE HashTable JSNamedNodeMapPrototypeTable = { 16, 15, JSNamedNodeMapPrototypeTableValues, 0 }; |
|
124 const ClassInfo JSNamedNodeMapPrototype::s_info = { "NamedNodeMapPrototype", 0, &JSNamedNodeMapPrototypeTable, 0 }; |
|
125 |
|
126 JSObject* JSNamedNodeMapPrototype::self(ExecState* exec, JSGlobalObject* globalObject) |
|
127 { |
|
128 return getDOMPrototype<JSNamedNodeMap>(exec, globalObject); |
|
129 } |
|
130 |
|
131 bool JSNamedNodeMapPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
132 { |
|
133 return getStaticFunctionSlot<JSObject>(exec, &JSNamedNodeMapPrototypeTable, this, propertyName, slot); |
|
134 } |
|
135 |
|
136 bool JSNamedNodeMapPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) |
|
137 { |
|
138 return getStaticFunctionDescriptor<JSObject>(exec, &JSNamedNodeMapPrototypeTable, this, propertyName, descriptor); |
|
139 } |
|
140 |
|
141 const ClassInfo JSNamedNodeMap::s_info = { "NamedNodeMap", 0, &JSNamedNodeMapTable, 0 }; |
|
142 |
|
143 JSNamedNodeMap::JSNamedNodeMap(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<NamedNodeMap> impl) |
|
144 : DOMObjectWithGlobalPointer(structure, globalObject) |
|
145 , m_impl(impl) |
|
146 { |
|
147 } |
|
148 |
|
149 JSNamedNodeMap::~JSNamedNodeMap() |
|
150 { |
|
151 forgetDOMObject(this, impl()); |
|
152 } |
|
153 |
|
154 JSObject* JSNamedNodeMap::createPrototype(ExecState* exec, JSGlobalObject* globalObject) |
|
155 { |
|
156 return new (exec) JSNamedNodeMapPrototype(globalObject, JSNamedNodeMapPrototype::createStructure(globalObject->objectPrototype())); |
|
157 } |
|
158 |
|
159 bool JSNamedNodeMap::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
160 { |
|
161 JSValue proto = prototype(); |
|
162 if (proto.isObject() && static_cast<JSObject*>(asObject(proto))->hasProperty(exec, propertyName)) |
|
163 return false; |
|
164 |
|
165 const HashEntry* entry = JSNamedNodeMapTable.entry(exec, propertyName); |
|
166 if (entry) { |
|
167 slot.setCustom(this, entry->propertyGetter()); |
|
168 return true; |
|
169 } |
|
170 bool ok; |
|
171 unsigned index = propertyName.toUInt32(&ok, false); |
|
172 if (ok && index < static_cast<NamedNodeMap*>(impl())->length()) { |
|
173 slot.setCustomIndex(this, index, indexGetter); |
|
174 return true; |
|
175 } |
|
176 if (canGetItemsForName(exec, static_cast<NamedNodeMap*>(impl()), propertyName)) { |
|
177 slot.setCustom(this, nameGetter); |
|
178 return true; |
|
179 } |
|
180 return getStaticValueSlot<JSNamedNodeMap, Base>(exec, &JSNamedNodeMapTable, this, propertyName, slot); |
|
181 } |
|
182 |
|
183 bool JSNamedNodeMap::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) |
|
184 { |
|
185 JSValue proto = prototype(); |
|
186 if (proto.isObject() && static_cast<JSObject*>(asObject(proto))->hasProperty(exec, propertyName)) |
|
187 return false; |
|
188 |
|
189 const HashEntry* entry = JSNamedNodeMapTable.entry(exec, propertyName); |
|
190 if (entry) { |
|
191 PropertySlot slot; |
|
192 slot.setCustom(this, entry->propertyGetter()); |
|
193 descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes()); |
|
194 return true; |
|
195 } |
|
196 bool ok; |
|
197 unsigned index = propertyName.toUInt32(&ok, false); |
|
198 if (ok && index < static_cast<NamedNodeMap*>(impl())->length()) { |
|
199 PropertySlot slot; |
|
200 slot.setCustomIndex(this, index, indexGetter); |
|
201 descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | ReadOnly); |
|
202 return true; |
|
203 } |
|
204 if (canGetItemsForName(exec, static_cast<NamedNodeMap*>(impl()), propertyName)) { |
|
205 PropertySlot slot; |
|
206 slot.setCustom(this, nameGetter); |
|
207 descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum); |
|
208 return true; |
|
209 } |
|
210 return getStaticValueDescriptor<JSNamedNodeMap, Base>(exec, &JSNamedNodeMapTable, this, propertyName, descriptor); |
|
211 } |
|
212 |
|
213 bool JSNamedNodeMap::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot) |
|
214 { |
|
215 if (propertyName < static_cast<NamedNodeMap*>(impl())->length()) { |
|
216 slot.setCustomIndex(this, propertyName, indexGetter); |
|
217 return true; |
|
218 } |
|
219 return getOwnPropertySlot(exec, Identifier::from(exec, propertyName), slot); |
|
220 } |
|
221 |
|
222 JSValue jsNamedNodeMapLength(ExecState* exec, JSValue slotBase, const Identifier&) |
|
223 { |
|
224 JSNamedNodeMap* castedThis = static_cast<JSNamedNodeMap*>(asObject(slotBase)); |
|
225 UNUSED_PARAM(exec); |
|
226 NamedNodeMap* imp = static_cast<NamedNodeMap*>(castedThis->impl()); |
|
227 JSValue result = jsNumber(exec, imp->length()); |
|
228 return result; |
|
229 } |
|
230 |
|
231 JSValue jsNamedNodeMapConstructor(ExecState* exec, JSValue slotBase, const Identifier&) |
|
232 { |
|
233 JSNamedNodeMap* domObject = static_cast<JSNamedNodeMap*>(asObject(slotBase)); |
|
234 return JSNamedNodeMap::getConstructor(exec, domObject->globalObject()); |
|
235 } |
|
236 void JSNamedNodeMap::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) |
|
237 { |
|
238 for (unsigned i = 0; i < static_cast<NamedNodeMap*>(impl())->length(); ++i) |
|
239 propertyNames.add(Identifier::from(exec, i)); |
|
240 Base::getOwnPropertyNames(exec, propertyNames, mode); |
|
241 } |
|
242 |
|
243 JSValue JSNamedNodeMap::getConstructor(ExecState* exec, JSGlobalObject* globalObject) |
|
244 { |
|
245 return getDOMConstructor<JSNamedNodeMapConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject)); |
|
246 } |
|
247 |
|
248 EncodedJSValue JSC_HOST_CALL jsNamedNodeMapPrototypeFunctionGetNamedItem(ExecState* exec) |
|
249 { |
|
250 JSValue thisValue = exec->hostThisValue(); |
|
251 if (!thisValue.inherits(&JSNamedNodeMap::s_info)) |
|
252 return throwVMTypeError(exec); |
|
253 JSNamedNodeMap* castedThis = static_cast<JSNamedNodeMap*>(asObject(thisValue)); |
|
254 NamedNodeMap* imp = static_cast<NamedNodeMap*>(castedThis->impl()); |
|
255 const String& name = ustringToString(exec->argument(0).toString(exec)); |
|
256 |
|
257 |
|
258 JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->getNamedItem(name))); |
|
259 return JSValue::encode(result); |
|
260 } |
|
261 |
|
262 EncodedJSValue JSC_HOST_CALL jsNamedNodeMapPrototypeFunctionSetNamedItem(ExecState* exec) |
|
263 { |
|
264 JSValue thisValue = exec->hostThisValue(); |
|
265 if (!thisValue.inherits(&JSNamedNodeMap::s_info)) |
|
266 return throwVMTypeError(exec); |
|
267 JSNamedNodeMap* castedThis = static_cast<JSNamedNodeMap*>(asObject(thisValue)); |
|
268 NamedNodeMap* imp = static_cast<NamedNodeMap*>(castedThis->impl()); |
|
269 ExceptionCode ec = 0; |
|
270 Node* node = toNode(exec->argument(0)); |
|
271 |
|
272 |
|
273 JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->setNamedItem(node, ec))); |
|
274 setDOMException(exec, ec); |
|
275 return JSValue::encode(result); |
|
276 } |
|
277 |
|
278 EncodedJSValue JSC_HOST_CALL jsNamedNodeMapPrototypeFunctionRemoveNamedItem(ExecState* exec) |
|
279 { |
|
280 JSValue thisValue = exec->hostThisValue(); |
|
281 if (!thisValue.inherits(&JSNamedNodeMap::s_info)) |
|
282 return throwVMTypeError(exec); |
|
283 JSNamedNodeMap* castedThis = static_cast<JSNamedNodeMap*>(asObject(thisValue)); |
|
284 NamedNodeMap* imp = static_cast<NamedNodeMap*>(castedThis->impl()); |
|
285 ExceptionCode ec = 0; |
|
286 const String& name = ustringToString(exec->argument(0).toString(exec)); |
|
287 |
|
288 |
|
289 JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->removeNamedItem(name, ec))); |
|
290 setDOMException(exec, ec); |
|
291 return JSValue::encode(result); |
|
292 } |
|
293 |
|
294 EncodedJSValue JSC_HOST_CALL jsNamedNodeMapPrototypeFunctionItem(ExecState* exec) |
|
295 { |
|
296 JSValue thisValue = exec->hostThisValue(); |
|
297 if (!thisValue.inherits(&JSNamedNodeMap::s_info)) |
|
298 return throwVMTypeError(exec); |
|
299 JSNamedNodeMap* castedThis = static_cast<JSNamedNodeMap*>(asObject(thisValue)); |
|
300 NamedNodeMap* imp = static_cast<NamedNodeMap*>(castedThis->impl()); |
|
301 unsigned index = exec->argument(0).toInt32(exec); |
|
302 |
|
303 |
|
304 JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->item(index))); |
|
305 return JSValue::encode(result); |
|
306 } |
|
307 |
|
308 EncodedJSValue JSC_HOST_CALL jsNamedNodeMapPrototypeFunctionGetNamedItemNS(ExecState* exec) |
|
309 { |
|
310 JSValue thisValue = exec->hostThisValue(); |
|
311 if (!thisValue.inherits(&JSNamedNodeMap::s_info)) |
|
312 return throwVMTypeError(exec); |
|
313 JSNamedNodeMap* castedThis = static_cast<JSNamedNodeMap*>(asObject(thisValue)); |
|
314 NamedNodeMap* imp = static_cast<NamedNodeMap*>(castedThis->impl()); |
|
315 const String& namespaceURI = valueToStringWithNullCheck(exec, exec->argument(0)); |
|
316 const String& localName = ustringToString(exec->argument(1).toString(exec)); |
|
317 |
|
318 |
|
319 JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->getNamedItemNS(namespaceURI, localName))); |
|
320 return JSValue::encode(result); |
|
321 } |
|
322 |
|
323 EncodedJSValue JSC_HOST_CALL jsNamedNodeMapPrototypeFunctionSetNamedItemNS(ExecState* exec) |
|
324 { |
|
325 JSValue thisValue = exec->hostThisValue(); |
|
326 if (!thisValue.inherits(&JSNamedNodeMap::s_info)) |
|
327 return throwVMTypeError(exec); |
|
328 JSNamedNodeMap* castedThis = static_cast<JSNamedNodeMap*>(asObject(thisValue)); |
|
329 NamedNodeMap* imp = static_cast<NamedNodeMap*>(castedThis->impl()); |
|
330 ExceptionCode ec = 0; |
|
331 Node* node = toNode(exec->argument(0)); |
|
332 |
|
333 |
|
334 JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->setNamedItemNS(node, ec))); |
|
335 setDOMException(exec, ec); |
|
336 return JSValue::encode(result); |
|
337 } |
|
338 |
|
339 EncodedJSValue JSC_HOST_CALL jsNamedNodeMapPrototypeFunctionRemoveNamedItemNS(ExecState* exec) |
|
340 { |
|
341 JSValue thisValue = exec->hostThisValue(); |
|
342 if (!thisValue.inherits(&JSNamedNodeMap::s_info)) |
|
343 return throwVMTypeError(exec); |
|
344 JSNamedNodeMap* castedThis = static_cast<JSNamedNodeMap*>(asObject(thisValue)); |
|
345 NamedNodeMap* imp = static_cast<NamedNodeMap*>(castedThis->impl()); |
|
346 ExceptionCode ec = 0; |
|
347 const String& namespaceURI = valueToStringWithNullCheck(exec, exec->argument(0)); |
|
348 const String& localName = ustringToString(exec->argument(1).toString(exec)); |
|
349 |
|
350 |
|
351 JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->removeNamedItemNS(namespaceURI, localName, ec))); |
|
352 setDOMException(exec, ec); |
|
353 return JSValue::encode(result); |
|
354 } |
|
355 |
|
356 |
|
357 JSValue JSNamedNodeMap::indexGetter(ExecState* exec, JSValue slotBase, unsigned index) |
|
358 { |
|
359 JSNamedNodeMap* thisObj = static_cast<JSNamedNodeMap*>(asObject(slotBase)); |
|
360 return toJS(exec, thisObj->globalObject(), static_cast<NamedNodeMap*>(thisObj->impl())->item(index)); |
|
361 } |
|
362 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, NamedNodeMap* object) |
|
363 { |
|
364 return getDOMObjectWrapper<JSNamedNodeMap>(exec, globalObject, object); |
|
365 } |
|
366 NamedNodeMap* toNamedNodeMap(JSC::JSValue value) |
|
367 { |
|
368 return value.inherits(&JSNamedNodeMap::s_info) ? static_cast<JSNamedNodeMap*>(asObject(value))->impl() : 0; |
|
369 } |
|
370 |
|
371 } |