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