2 This file is part of the WebKit open source project.
3 This file has been generated by generate-bindings.pl. DO NOT MODIFY!
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.
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.
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.
22 #include "JSDOMTokenList.h"
24 #include "DOMTokenList.h"
25 #include "ExceptionCode.h"
26 #include "JSDOMBinding.h"
28 #include <runtime/Error.h>
29 #include <runtime/JSString.h>
30 #include <runtime/PropertyNameArray.h>
31 #include <wtf/GetPtr.h>
37 ASSERT_CLASS_FITS_IN_CELL(JSDOMTokenList);
41 #define THUNK_GENERATOR(generator) , generator
43 #define THUNK_GENERATOR(generator)
46 #define INTRINSIC(intrinsic) , intrinsic
48 #define INTRINSIC(intrinsic)
51 static const HashTableValue JSDOMTokenListTableValues[] =
53 { "length", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMTokenListLength), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
54 { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMTokenListConstructor), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
55 { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
58 #undef THUNK_GENERATOR
59 static const HashTable JSDOMTokenListTable = { 5, 3, JSDOMTokenListTableValues, 0 };
60 /* Hash table for constructor */
62 #define THUNK_GENERATOR(generator) , generator
64 #define THUNK_GENERATOR(generator)
67 #define INTRINSIC(intrinsic) , intrinsic
69 #define INTRINSIC(intrinsic)
72 static const HashTableValue JSDOMTokenListConstructorTableValues[] =
74 { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
77 #undef THUNK_GENERATOR
78 static const HashTable JSDOMTokenListConstructorTable = { 1, 0, JSDOMTokenListConstructorTableValues, 0 };
79 const ClassInfo JSDOMTokenListConstructor::s_info = { "DOMTokenListConstructor", &DOMConstructorObject::s_info, &JSDOMTokenListConstructorTable, 0, CREATE_METHOD_TABLE(JSDOMTokenListConstructor) };
81 JSDOMTokenListConstructor::JSDOMTokenListConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
82 : DOMConstructorObject(structure, globalObject)
86 void JSDOMTokenListConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
88 Base::finishCreation(exec->globalData());
89 ASSERT(inherits(&s_info));
90 putDirect(exec->globalData(), exec->propertyNames().prototype, JSDOMTokenListPrototype::self(exec, globalObject), DontDelete | ReadOnly);
93 bool JSDOMTokenListConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
95 return getStaticValueSlot<JSDOMTokenListConstructor, JSDOMWrapper>(exec, &JSDOMTokenListConstructorTable, static_cast<JSDOMTokenListConstructor*>(cell), propertyName, slot);
98 bool JSDOMTokenListConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
100 return getStaticValueDescriptor<JSDOMTokenListConstructor, JSDOMWrapper>(exec, &JSDOMTokenListConstructorTable, static_cast<JSDOMTokenListConstructor*>(object), propertyName, descriptor);
103 /* Hash table for prototype */
105 #define THUNK_GENERATOR(generator) , generator
107 #define THUNK_GENERATOR(generator)
110 #define INTRINSIC(intrinsic) , intrinsic
112 #define INTRINSIC(intrinsic)
115 static const HashTableValue JSDOMTokenListPrototypeTableValues[] =
117 { "item", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMTokenListPrototypeFunctionItem), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
118 { "contains", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMTokenListPrototypeFunctionContains), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
119 { "add", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMTokenListPrototypeFunctionAdd), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
120 { "remove", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMTokenListPrototypeFunctionRemove), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
121 { "toggle", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMTokenListPrototypeFunctionToggle), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
122 { "toString", DontDelete | DontEnum | Function, (intptr_t)static_cast<NativeFunction>(jsDOMTokenListPrototypeFunctionToString), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
123 { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
126 #undef THUNK_GENERATOR
127 static const HashTable JSDOMTokenListPrototypeTable = { 16, 15, JSDOMTokenListPrototypeTableValues, 0 };
128 const ClassInfo JSDOMTokenListPrototype::s_info = { "DOMTokenListPrototype", &JSC::JSNonFinalObject::s_info, &JSDOMTokenListPrototypeTable, 0, CREATE_METHOD_TABLE(JSDOMTokenListPrototype) };
130 JSObject* JSDOMTokenListPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
132 return getDOMPrototype<JSDOMTokenList>(exec, globalObject);
135 bool JSDOMTokenListPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
137 JSDOMTokenListPrototype* thisObject = jsCast<JSDOMTokenListPrototype*>(cell);
138 return getStaticFunctionSlot<JSObject>(exec, &JSDOMTokenListPrototypeTable, thisObject, propertyName, slot);
141 bool JSDOMTokenListPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
143 JSDOMTokenListPrototype* thisObject = jsCast<JSDOMTokenListPrototype*>(object);
144 return getStaticFunctionDescriptor<JSObject>(exec, &JSDOMTokenListPrototypeTable, thisObject, propertyName, descriptor);
147 const ClassInfo JSDOMTokenList::s_info = { "DOMTokenList", &JSDOMWrapper::s_info, &JSDOMTokenListTable, 0 , CREATE_METHOD_TABLE(JSDOMTokenList) };
149 JSDOMTokenList::JSDOMTokenList(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<DOMTokenList> impl)
150 : JSDOMWrapper(structure, globalObject)
151 , m_impl(impl.leakRef())
155 void JSDOMTokenList::finishCreation(JSGlobalData& globalData)
157 Base::finishCreation(globalData);
158 ASSERT(inherits(&s_info));
161 JSObject* JSDOMTokenList::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
163 return JSDOMTokenListPrototype::create(exec->globalData(), globalObject, JSDOMTokenListPrototype::createStructure(globalObject->globalData(), globalObject, globalObject->objectPrototype()));
166 bool JSDOMTokenList::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
168 JSDOMTokenList* thisObject = jsCast<JSDOMTokenList*>(cell);
169 ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
170 const HashEntry* entry = JSDOMTokenListTable.entry(exec, propertyName);
172 slot.setCustom(thisObject, entry->propertyGetter());
176 unsigned index = propertyName.toUInt32(ok);
178 slot.setCustomIndex(thisObject, index, indexGetter);
181 return getStaticValueSlot<JSDOMTokenList, Base>(exec, &JSDOMTokenListTable, thisObject, propertyName, slot);
184 bool JSDOMTokenList::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
186 JSDOMTokenList* thisObject = jsCast<JSDOMTokenList*>(object);
187 ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
188 const HashEntry* entry = JSDOMTokenListTable.entry(exec, propertyName);
191 slot.setCustom(thisObject, entry->propertyGetter());
192 descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());
196 unsigned index = propertyName.toUInt32(ok);
197 if (ok && index < static_cast<DOMTokenList*>(thisObject->impl())->length()) {
199 slot.setCustomIndex(thisObject, index, indexGetter);
200 descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | ReadOnly);
203 return getStaticValueDescriptor<JSDOMTokenList, Base>(exec, &JSDOMTokenListTable, thisObject, propertyName, descriptor);
206 bool JSDOMTokenList::getOwnPropertySlotByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, PropertySlot& slot)
208 JSDOMTokenList* thisObject = jsCast<JSDOMTokenList*>(cell);
209 ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
210 if (propertyName < static_cast<DOMTokenList*>(thisObject->impl())->length()) {
211 slot.setCustomIndex(thisObject, propertyName, thisObject->indexGetter);
214 return thisObject->methodTable()->getOwnPropertySlot(thisObject, exec, Identifier::from(exec, propertyName), slot);
217 JSValue jsDOMTokenListLength(ExecState* exec, JSValue slotBase, const Identifier&)
219 JSDOMTokenList* castedThis = static_cast<JSDOMTokenList*>(asObject(slotBase));
221 DOMTokenList* imp = static_cast<DOMTokenList*>(castedThis->impl());
222 JSValue result = jsNumber(imp->length());
227 JSValue jsDOMTokenListConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
229 JSDOMTokenList* domObject = static_cast<JSDOMTokenList*>(asObject(slotBase));
230 return JSDOMTokenList::getConstructor(exec, domObject->globalObject());
233 void JSDOMTokenList::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
235 JSDOMTokenList* thisObject = jsCast<JSDOMTokenList*>(object);
236 ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
237 for (unsigned i = 0; i < static_cast<DOMTokenList*>(thisObject->impl())->length(); ++i)
238 propertyNames.add(Identifier::from(exec, i));
239 Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
242 JSValue JSDOMTokenList::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
244 return getDOMConstructor<JSDOMTokenListConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
247 EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionItem(ExecState* exec)
249 JSValue thisValue = exec->hostThisValue();
250 if (!thisValue.inherits(&JSDOMTokenList::s_info))
251 return throwVMTypeError(exec);
252 JSDOMTokenList* castedThis = static_cast<JSDOMTokenList*>(asObject(thisValue));
253 ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDOMTokenList::s_info);
254 DOMTokenList* imp = static_cast<DOMTokenList*>(castedThis->impl());
255 if (exec->argumentCount() < 1)
256 return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
257 unsigned index(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toUInt32(exec));
258 if (exec->hadException())
259 return JSValue::encode(jsUndefined());
261 JSC::JSValue result = jsStringOrNull(exec, imp->item(index));
262 return JSValue::encode(result);
265 EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionContains(ExecState* exec)
267 JSValue thisValue = exec->hostThisValue();
268 if (!thisValue.inherits(&JSDOMTokenList::s_info))
269 return throwVMTypeError(exec);
270 JSDOMTokenList* castedThis = static_cast<JSDOMTokenList*>(asObject(thisValue));
271 ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDOMTokenList::s_info);
272 DOMTokenList* imp = static_cast<DOMTokenList*>(castedThis->impl());
273 if (exec->argumentCount() < 1)
274 return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
275 ExceptionCode ec = 0;
276 const String& token(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toString(exec)));
277 if (exec->hadException())
278 return JSValue::encode(jsUndefined());
280 JSC::JSValue result = jsBoolean(imp->contains(token, ec));
281 setDOMException(exec, ec);
282 return JSValue::encode(result);
285 EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionAdd(ExecState* exec)
287 JSValue thisValue = exec->hostThisValue();
288 if (!thisValue.inherits(&JSDOMTokenList::s_info))
289 return throwVMTypeError(exec);
290 JSDOMTokenList* castedThis = static_cast<JSDOMTokenList*>(asObject(thisValue));
291 ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDOMTokenList::s_info);
292 DOMTokenList* imp = static_cast<DOMTokenList*>(castedThis->impl());
293 if (exec->argumentCount() < 1)
294 return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
295 ExceptionCode ec = 0;
296 const String& token(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toString(exec)));
297 if (exec->hadException())
298 return JSValue::encode(jsUndefined());
300 setDOMException(exec, ec);
301 return JSValue::encode(jsUndefined());
304 EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionRemove(ExecState* exec)
306 JSValue thisValue = exec->hostThisValue();
307 if (!thisValue.inherits(&JSDOMTokenList::s_info))
308 return throwVMTypeError(exec);
309 JSDOMTokenList* castedThis = static_cast<JSDOMTokenList*>(asObject(thisValue));
310 ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDOMTokenList::s_info);
311 DOMTokenList* imp = static_cast<DOMTokenList*>(castedThis->impl());
312 if (exec->argumentCount() < 1)
313 return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
314 ExceptionCode ec = 0;
315 const String& token(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toString(exec)));
316 if (exec->hadException())
317 return JSValue::encode(jsUndefined());
318 imp->remove(token, ec);
319 setDOMException(exec, ec);
320 return JSValue::encode(jsUndefined());
323 EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionToggle(ExecState* exec)
325 JSValue thisValue = exec->hostThisValue();
326 if (!thisValue.inherits(&JSDOMTokenList::s_info))
327 return throwVMTypeError(exec);
328 JSDOMTokenList* castedThis = static_cast<JSDOMTokenList*>(asObject(thisValue));
329 ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDOMTokenList::s_info);
330 DOMTokenList* imp = static_cast<DOMTokenList*>(castedThis->impl());
331 if (exec->argumentCount() < 1)
332 return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
333 ExceptionCode ec = 0;
334 const String& token(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toString(exec)));
335 if (exec->hadException())
336 return JSValue::encode(jsUndefined());
338 JSC::JSValue result = jsBoolean(imp->toggle(token, ec));
339 setDOMException(exec, ec);
340 return JSValue::encode(result);
343 EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionToString(ExecState* exec)
345 JSValue thisValue = exec->hostThisValue();
346 if (!thisValue.inherits(&JSDOMTokenList::s_info))
347 return throwVMTypeError(exec);
348 JSDOMTokenList* castedThis = static_cast<JSDOMTokenList*>(asObject(thisValue));
349 ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDOMTokenList::s_info);
350 DOMTokenList* imp = static_cast<DOMTokenList*>(castedThis->impl());
352 JSC::JSValue result = jsString(exec, imp->toString());
353 return JSValue::encode(result);
357 JSValue JSDOMTokenList::indexGetter(ExecState* exec, JSValue slotBase, unsigned index)
359 JSDOMTokenList* thisObj = static_cast<JSDOMTokenList*>(asObject(slotBase));
360 ASSERT_GC_OBJECT_INHERITS(thisObj, &s_info);
361 return jsStringOrNull(exec, thisObj->impl()->item(index));
364 static inline bool isObservable(JSDOMTokenList* jsDOMTokenList)
366 if (jsDOMTokenList->hasCustomProperties())
371 bool JSDOMTokenListOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
373 JSDOMTokenList* jsDOMTokenList = static_cast<JSDOMTokenList*>(handle.get().asCell());
374 if (!isObservable(jsDOMTokenList))
376 Element* element = jsDOMTokenList->impl()->element();
379 void* root = WebCore::root(element);
380 return visitor.containsOpaqueRoot(root);
383 void JSDOMTokenListOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
385 JSDOMTokenList* jsDOMTokenList = static_cast<JSDOMTokenList*>(handle.get().asCell());
386 DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
387 uncacheWrapper(world, jsDOMTokenList->impl(), jsDOMTokenList);
388 jsDOMTokenList->releaseImpl();
391 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, DOMTokenList* impl)
393 return wrap<JSDOMTokenList>(exec, globalObject, impl);
396 DOMTokenList* toDOMTokenList(JSC::JSValue value)
398 return value.inherits(&JSDOMTokenList::s_info) ? static_cast<JSDOMTokenList*>(asObject(value))->impl() : 0;