|
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 |
|
23 #if ENABLE(INDEXED_DATABASE) |
|
24 |
|
25 #include "JSIDBRequest.h" |
|
26 |
|
27 #include "Event.h" |
|
28 #include "EventListener.h" |
|
29 #include "IDBAny.h" |
|
30 #include "IDBDatabaseError.h" |
|
31 #include "IDBRequest.h" |
|
32 #include "JSEvent.h" |
|
33 #include "JSEventListener.h" |
|
34 #include "JSIDBAny.h" |
|
35 #include "JSIDBDatabaseError.h" |
|
36 #include "RegisteredEventListener.h" |
|
37 #include <runtime/Error.h> |
|
38 #include <runtime/JSNumberCell.h> |
|
39 #include <wtf/GetPtr.h> |
|
40 |
|
41 using namespace JSC; |
|
42 |
|
43 namespace WebCore { |
|
44 |
|
45 ASSERT_CLASS_FITS_IN_CELL(JSIDBRequest); |
|
46 |
|
47 /* Hash table */ |
|
48 #if ENABLE(JIT) |
|
49 #define THUNK_GENERATOR(generator) , generator |
|
50 #else |
|
51 #define THUNK_GENERATOR(generator) |
|
52 #endif |
|
53 |
|
54 static const HashTableValue JSIDBRequestTableValues[7] = |
|
55 { |
|
56 { "readyState", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBRequestReadyState), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
57 { "error", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBRequestError), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
58 { "result", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBRequestResult), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
59 { "onsuccess", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBRequestOnsuccess), (intptr_t)setJSIDBRequestOnsuccess THUNK_GENERATOR(0) }, |
|
60 { "onerror", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBRequestOnerror), (intptr_t)setJSIDBRequestOnerror THUNK_GENERATOR(0) }, |
|
61 { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBRequestConstructor), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
62 { 0, 0, 0, 0 THUNK_GENERATOR(0) } |
|
63 }; |
|
64 |
|
65 #undef THUNK_GENERATOR |
|
66 static JSC_CONST_HASHTABLE HashTable JSIDBRequestTable = { 17, 15, JSIDBRequestTableValues, 0 }; |
|
67 /* Hash table for constructor */ |
|
68 #if ENABLE(JIT) |
|
69 #define THUNK_GENERATOR(generator) , generator |
|
70 #else |
|
71 #define THUNK_GENERATOR(generator) |
|
72 #endif |
|
73 |
|
74 static const HashTableValue JSIDBRequestConstructorTableValues[4] = |
|
75 { |
|
76 { "INITIAL", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBRequestINITIAL), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
77 { "LOADING", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBRequestLOADING), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
78 { "DONE", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBRequestDONE), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
79 { 0, 0, 0, 0 THUNK_GENERATOR(0) } |
|
80 }; |
|
81 |
|
82 #undef THUNK_GENERATOR |
|
83 static JSC_CONST_HASHTABLE HashTable JSIDBRequestConstructorTable = { 9, 7, JSIDBRequestConstructorTableValues, 0 }; |
|
84 |
|
85 COMPILE_ASSERT(0 == IDBRequest::INITIAL, IDBRequestEnumINITIALIsWrongUseDontCheckEnums); |
|
86 COMPILE_ASSERT(1 == IDBRequest::LOADING, IDBRequestEnumLOADINGIsWrongUseDontCheckEnums); |
|
87 COMPILE_ASSERT(2 == IDBRequest::DONE, IDBRequestEnumDONEIsWrongUseDontCheckEnums); |
|
88 |
|
89 class JSIDBRequestConstructor : public DOMConstructorObject { |
|
90 public: |
|
91 JSIDBRequestConstructor(JSC::ExecState*, JSDOMGlobalObject*); |
|
92 |
|
93 virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); |
|
94 virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); |
|
95 virtual const JSC::ClassInfo* classInfo() const { return &s_info; } |
|
96 static const JSC::ClassInfo s_info; |
|
97 static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) |
|
98 { |
|
99 return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); |
|
100 } |
|
101 protected: |
|
102 static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; |
|
103 }; |
|
104 |
|
105 const ClassInfo JSIDBRequestConstructor::s_info = { "IDBRequestConstructor", 0, &JSIDBRequestConstructorTable, 0 }; |
|
106 |
|
107 JSIDBRequestConstructor::JSIDBRequestConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) |
|
108 : DOMConstructorObject(JSIDBRequestConstructor::createStructure(globalObject->objectPrototype()), globalObject) |
|
109 { |
|
110 putDirect(exec->propertyNames().prototype, JSIDBRequestPrototype::self(exec, globalObject), DontDelete | ReadOnly); |
|
111 } |
|
112 |
|
113 bool JSIDBRequestConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
114 { |
|
115 return getStaticValueSlot<JSIDBRequestConstructor, DOMObject>(exec, &JSIDBRequestConstructorTable, this, propertyName, slot); |
|
116 } |
|
117 |
|
118 bool JSIDBRequestConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) |
|
119 { |
|
120 return getStaticValueDescriptor<JSIDBRequestConstructor, DOMObject>(exec, &JSIDBRequestConstructorTable, this, propertyName, descriptor); |
|
121 } |
|
122 |
|
123 /* Hash table for prototype */ |
|
124 #if ENABLE(JIT) |
|
125 #define THUNK_GENERATOR(generator) , generator |
|
126 #else |
|
127 #define THUNK_GENERATOR(generator) |
|
128 #endif |
|
129 |
|
130 static const HashTableValue JSIDBRequestPrototypeTableValues[8] = |
|
131 { |
|
132 { "INITIAL", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBRequestINITIAL), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
133 { "LOADING", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBRequestLOADING), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
134 { "DONE", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBRequestDONE), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
135 { "abort", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsIDBRequestPrototypeFunctionAbort), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
136 { "addEventListener", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsIDBRequestPrototypeFunctionAddEventListener), (intptr_t)3 THUNK_GENERATOR(0) }, |
|
137 { "removeEventListener", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsIDBRequestPrototypeFunctionRemoveEventListener), (intptr_t)3 THUNK_GENERATOR(0) }, |
|
138 { "dispatchEvent", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsIDBRequestPrototypeFunctionDispatchEvent), (intptr_t)1 THUNK_GENERATOR(0) }, |
|
139 { 0, 0, 0, 0 THUNK_GENERATOR(0) } |
|
140 }; |
|
141 |
|
142 #undef THUNK_GENERATOR |
|
143 static JSC_CONST_HASHTABLE HashTable JSIDBRequestPrototypeTable = { 17, 15, JSIDBRequestPrototypeTableValues, 0 }; |
|
144 const ClassInfo JSIDBRequestPrototype::s_info = { "IDBRequestPrototype", 0, &JSIDBRequestPrototypeTable, 0 }; |
|
145 |
|
146 JSObject* JSIDBRequestPrototype::self(ExecState* exec, JSGlobalObject* globalObject) |
|
147 { |
|
148 return getDOMPrototype<JSIDBRequest>(exec, globalObject); |
|
149 } |
|
150 |
|
151 bool JSIDBRequestPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
152 { |
|
153 return getStaticPropertySlot<JSIDBRequestPrototype, JSObject>(exec, &JSIDBRequestPrototypeTable, this, propertyName, slot); |
|
154 } |
|
155 |
|
156 bool JSIDBRequestPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) |
|
157 { |
|
158 return getStaticPropertyDescriptor<JSIDBRequestPrototype, JSObject>(exec, &JSIDBRequestPrototypeTable, this, propertyName, descriptor); |
|
159 } |
|
160 |
|
161 const ClassInfo JSIDBRequest::s_info = { "IDBRequest", 0, &JSIDBRequestTable, 0 }; |
|
162 |
|
163 JSIDBRequest::JSIDBRequest(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<IDBRequest> impl) |
|
164 : DOMObjectWithGlobalPointer(structure, globalObject) |
|
165 , m_impl(impl) |
|
166 { |
|
167 } |
|
168 |
|
169 JSIDBRequest::~JSIDBRequest() |
|
170 { |
|
171 impl()->invalidateJSEventListeners(this); |
|
172 forgetDOMObject(this, impl()); |
|
173 } |
|
174 |
|
175 void JSIDBRequest::markChildren(MarkStack& markStack) |
|
176 { |
|
177 Base::markChildren(markStack); |
|
178 impl()->markJSEventListeners(markStack); |
|
179 } |
|
180 |
|
181 JSObject* JSIDBRequest::createPrototype(ExecState* exec, JSGlobalObject* globalObject) |
|
182 { |
|
183 return new (exec) JSIDBRequestPrototype(globalObject, JSIDBRequestPrototype::createStructure(globalObject->objectPrototype())); |
|
184 } |
|
185 |
|
186 bool JSIDBRequest::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
187 { |
|
188 return getStaticValueSlot<JSIDBRequest, Base>(exec, &JSIDBRequestTable, this, propertyName, slot); |
|
189 } |
|
190 |
|
191 bool JSIDBRequest::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) |
|
192 { |
|
193 return getStaticValueDescriptor<JSIDBRequest, Base>(exec, &JSIDBRequestTable, this, propertyName, descriptor); |
|
194 } |
|
195 |
|
196 JSValue jsIDBRequestReadyState(ExecState* exec, JSValue slotBase, const Identifier&) |
|
197 { |
|
198 JSIDBRequest* castedThis = static_cast<JSIDBRequest*>(asObject(slotBase)); |
|
199 UNUSED_PARAM(exec); |
|
200 IDBRequest* imp = static_cast<IDBRequest*>(castedThis->impl()); |
|
201 JSValue result = jsNumber(exec, imp->readyState()); |
|
202 return result; |
|
203 } |
|
204 |
|
205 JSValue jsIDBRequestError(ExecState* exec, JSValue slotBase, const Identifier&) |
|
206 { |
|
207 JSIDBRequest* castedThis = static_cast<JSIDBRequest*>(asObject(slotBase)); |
|
208 UNUSED_PARAM(exec); |
|
209 IDBRequest* imp = static_cast<IDBRequest*>(castedThis->impl()); |
|
210 JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->error())); |
|
211 return result; |
|
212 } |
|
213 |
|
214 JSValue jsIDBRequestResult(ExecState* exec, JSValue slotBase, const Identifier&) |
|
215 { |
|
216 JSIDBRequest* castedThis = static_cast<JSIDBRequest*>(asObject(slotBase)); |
|
217 UNUSED_PARAM(exec); |
|
218 IDBRequest* imp = static_cast<IDBRequest*>(castedThis->impl()); |
|
219 JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->result())); |
|
220 return result; |
|
221 } |
|
222 |
|
223 JSValue jsIDBRequestOnsuccess(ExecState* exec, JSValue slotBase, const Identifier&) |
|
224 { |
|
225 JSIDBRequest* castedThis = static_cast<JSIDBRequest*>(asObject(slotBase)); |
|
226 UNUSED_PARAM(exec); |
|
227 IDBRequest* imp = static_cast<IDBRequest*>(castedThis->impl()); |
|
228 if (EventListener* listener = imp->onsuccess()) { |
|
229 if (const JSEventListener* jsListener = JSEventListener::cast(listener)) { |
|
230 if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext())) |
|
231 return jsFunction; |
|
232 } |
|
233 } |
|
234 return jsNull(); |
|
235 } |
|
236 |
|
237 JSValue jsIDBRequestOnerror(ExecState* exec, JSValue slotBase, const Identifier&) |
|
238 { |
|
239 JSIDBRequest* castedThis = static_cast<JSIDBRequest*>(asObject(slotBase)); |
|
240 UNUSED_PARAM(exec); |
|
241 IDBRequest* imp = static_cast<IDBRequest*>(castedThis->impl()); |
|
242 if (EventListener* listener = imp->onerror()) { |
|
243 if (const JSEventListener* jsListener = JSEventListener::cast(listener)) { |
|
244 if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext())) |
|
245 return jsFunction; |
|
246 } |
|
247 } |
|
248 return jsNull(); |
|
249 } |
|
250 |
|
251 JSValue jsIDBRequestConstructor(ExecState* exec, JSValue slotBase, const Identifier&) |
|
252 { |
|
253 JSIDBRequest* domObject = static_cast<JSIDBRequest*>(asObject(slotBase)); |
|
254 return JSIDBRequest::getConstructor(exec, domObject->globalObject()); |
|
255 } |
|
256 void JSIDBRequest::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) |
|
257 { |
|
258 lookupPut<JSIDBRequest, Base>(exec, propertyName, value, &JSIDBRequestTable, this, slot); |
|
259 } |
|
260 |
|
261 void setJSIDBRequestOnsuccess(ExecState* exec, JSObject* thisObject, JSValue value) |
|
262 { |
|
263 UNUSED_PARAM(exec); |
|
264 IDBRequest* imp = static_cast<IDBRequest*>(static_cast<JSIDBRequest*>(thisObject)->impl()); |
|
265 imp->setOnsuccess(createJSAttributeEventListener(exec, value, thisObject)); |
|
266 } |
|
267 |
|
268 void setJSIDBRequestOnerror(ExecState* exec, JSObject* thisObject, JSValue value) |
|
269 { |
|
270 UNUSED_PARAM(exec); |
|
271 IDBRequest* imp = static_cast<IDBRequest*>(static_cast<JSIDBRequest*>(thisObject)->impl()); |
|
272 imp->setOnerror(createJSAttributeEventListener(exec, value, thisObject)); |
|
273 } |
|
274 |
|
275 JSValue JSIDBRequest::getConstructor(ExecState* exec, JSGlobalObject* globalObject) |
|
276 { |
|
277 return getDOMConstructor<JSIDBRequestConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject)); |
|
278 } |
|
279 |
|
280 EncodedJSValue JSC_HOST_CALL jsIDBRequestPrototypeFunctionAbort(ExecState* exec) |
|
281 { |
|
282 JSValue thisValue = exec->hostThisValue(); |
|
283 if (!thisValue.inherits(&JSIDBRequest::s_info)) |
|
284 return throwVMTypeError(exec); |
|
285 JSIDBRequest* castedThis = static_cast<JSIDBRequest*>(asObject(thisValue)); |
|
286 IDBRequest* imp = static_cast<IDBRequest*>(castedThis->impl()); |
|
287 |
|
288 imp->abort(); |
|
289 return JSValue::encode(jsUndefined()); |
|
290 } |
|
291 |
|
292 EncodedJSValue JSC_HOST_CALL jsIDBRequestPrototypeFunctionAddEventListener(ExecState* exec) |
|
293 { |
|
294 JSValue thisValue = exec->hostThisValue(); |
|
295 if (!thisValue.inherits(&JSIDBRequest::s_info)) |
|
296 return throwVMTypeError(exec); |
|
297 JSIDBRequest* castedThis = static_cast<JSIDBRequest*>(asObject(thisValue)); |
|
298 IDBRequest* imp = static_cast<IDBRequest*>(castedThis->impl()); |
|
299 JSValue listener = exec->argument(1); |
|
300 if (!listener.isObject()) |
|
301 return JSValue::encode(jsUndefined()); |
|
302 imp->addEventListener(ustringToAtomicString(exec->argument(0).toString(exec)), JSEventListener::create(asObject(listener), castedThis, false, currentWorld(exec)), exec->argument(2).toBoolean(exec)); |
|
303 return JSValue::encode(jsUndefined()); |
|
304 } |
|
305 |
|
306 EncodedJSValue JSC_HOST_CALL jsIDBRequestPrototypeFunctionRemoveEventListener(ExecState* exec) |
|
307 { |
|
308 JSValue thisValue = exec->hostThisValue(); |
|
309 if (!thisValue.inherits(&JSIDBRequest::s_info)) |
|
310 return throwVMTypeError(exec); |
|
311 JSIDBRequest* castedThis = static_cast<JSIDBRequest*>(asObject(thisValue)); |
|
312 IDBRequest* imp = static_cast<IDBRequest*>(castedThis->impl()); |
|
313 JSValue listener = exec->argument(1); |
|
314 if (!listener.isObject()) |
|
315 return JSValue::encode(jsUndefined()); |
|
316 imp->removeEventListener(ustringToAtomicString(exec->argument(0).toString(exec)), JSEventListener::create(asObject(listener), castedThis, false, currentWorld(exec)).get(), exec->argument(2).toBoolean(exec)); |
|
317 return JSValue::encode(jsUndefined()); |
|
318 } |
|
319 |
|
320 EncodedJSValue JSC_HOST_CALL jsIDBRequestPrototypeFunctionDispatchEvent(ExecState* exec) |
|
321 { |
|
322 JSValue thisValue = exec->hostThisValue(); |
|
323 if (!thisValue.inherits(&JSIDBRequest::s_info)) |
|
324 return throwVMTypeError(exec); |
|
325 JSIDBRequest* castedThis = static_cast<JSIDBRequest*>(asObject(thisValue)); |
|
326 IDBRequest* imp = static_cast<IDBRequest*>(castedThis->impl()); |
|
327 ExceptionCode ec = 0; |
|
328 Event* evt = toEvent(exec->argument(0)); |
|
329 |
|
330 |
|
331 JSC::JSValue result = jsBoolean(imp->dispatchEvent(evt, ec)); |
|
332 setDOMException(exec, ec); |
|
333 return JSValue::encode(result); |
|
334 } |
|
335 |
|
336 // Constant getters |
|
337 |
|
338 JSValue jsIDBRequestINITIAL(ExecState* exec, JSValue, const Identifier&) |
|
339 { |
|
340 return jsNumber(exec, static_cast<int>(0)); |
|
341 } |
|
342 |
|
343 JSValue jsIDBRequestLOADING(ExecState* exec, JSValue, const Identifier&) |
|
344 { |
|
345 return jsNumber(exec, static_cast<int>(1)); |
|
346 } |
|
347 |
|
348 JSValue jsIDBRequestDONE(ExecState* exec, JSValue, const Identifier&) |
|
349 { |
|
350 return jsNumber(exec, static_cast<int>(2)); |
|
351 } |
|
352 |
|
353 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, IDBRequest* object) |
|
354 { |
|
355 return getDOMObjectWrapper<JSIDBRequest>(exec, globalObject, object); |
|
356 } |
|
357 IDBRequest* toIDBRequest(JSC::JSValue value) |
|
358 { |
|
359 return value.inherits(&JSIDBRequest::s_info) ? static_cast<JSIDBRequest*>(asObject(value))->impl() : 0; |
|
360 } |
|
361 |
|
362 } |
|
363 |
|
364 #endif // ENABLE(INDEXED_DATABASE) |