|
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(WEB_SOCKETS) |
|
24 |
|
25 #include "JSWebSocket.h" |
|
26 |
|
27 #include "Event.h" |
|
28 #include "EventListener.h" |
|
29 #include "JSEvent.h" |
|
30 #include "JSEventListener.h" |
|
31 #include "KURL.h" |
|
32 #include "RegisteredEventListener.h" |
|
33 #include "WebSocket.h" |
|
34 #include <runtime/Error.h> |
|
35 #include <runtime/JSNumberCell.h> |
|
36 #include <runtime/JSString.h> |
|
37 #include <wtf/GetPtr.h> |
|
38 |
|
39 using namespace JSC; |
|
40 |
|
41 namespace WebCore { |
|
42 |
|
43 ASSERT_CLASS_FITS_IN_CELL(JSWebSocket); |
|
44 |
|
45 /* Hash table */ |
|
46 #if ENABLE(JIT) |
|
47 #define THUNK_GENERATOR(generator) , generator |
|
48 #else |
|
49 #define THUNK_GENERATOR(generator) |
|
50 #endif |
|
51 |
|
52 static const HashTableValue JSWebSocketTableValues[9] = |
|
53 { |
|
54 { "URL", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWebSocketURL), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
55 { "readyState", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWebSocketReadyState), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
56 { "bufferedAmount", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWebSocketBufferedAmount), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
57 { "onopen", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWebSocketOnopen), (intptr_t)setJSWebSocketOnopen THUNK_GENERATOR(0) }, |
|
58 { "onmessage", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWebSocketOnmessage), (intptr_t)setJSWebSocketOnmessage THUNK_GENERATOR(0) }, |
|
59 { "onerror", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWebSocketOnerror), (intptr_t)setJSWebSocketOnerror THUNK_GENERATOR(0) }, |
|
60 { "onclose", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWebSocketOnclose), (intptr_t)setJSWebSocketOnclose THUNK_GENERATOR(0) }, |
|
61 { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWebSocketConstructor), (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 JSWebSocketTable = { 17, 15, JSWebSocketTableValues, 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 JSWebSocketConstructorTableValues[4] = |
|
75 { |
|
76 { "CONNECTING", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWebSocketCONNECTING), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
77 { "OPEN", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWebSocketOPEN), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
78 { "CLOSED", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWebSocketCLOSED), (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 JSWebSocketConstructorTable = { 8, 7, JSWebSocketConstructorTableValues, 0 }; |
|
84 |
|
85 COMPILE_ASSERT(0 == WebSocket::CONNECTING, WebSocketEnumCONNECTINGIsWrongUseDontCheckEnums); |
|
86 COMPILE_ASSERT(1 == WebSocket::OPEN, WebSocketEnumOPENIsWrongUseDontCheckEnums); |
|
87 COMPILE_ASSERT(2 == WebSocket::CLOSED, WebSocketEnumCLOSEDIsWrongUseDontCheckEnums); |
|
88 |
|
89 const ClassInfo JSWebSocketConstructor::s_info = { "WebSocketConstructor", 0, &JSWebSocketConstructorTable, 0 }; |
|
90 |
|
91 JSWebSocketConstructor::JSWebSocketConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) |
|
92 : DOMConstructorObject(JSWebSocketConstructor::createStructure(globalObject->objectPrototype()), globalObject) |
|
93 { |
|
94 putDirect(exec->propertyNames().prototype, JSWebSocketPrototype::self(exec, globalObject), DontDelete | ReadOnly); |
|
95 putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontDelete | DontEnum); |
|
96 } |
|
97 |
|
98 bool JSWebSocketConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
99 { |
|
100 return getStaticValueSlot<JSWebSocketConstructor, DOMObject>(exec, &JSWebSocketConstructorTable, this, propertyName, slot); |
|
101 } |
|
102 |
|
103 bool JSWebSocketConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) |
|
104 { |
|
105 return getStaticValueDescriptor<JSWebSocketConstructor, DOMObject>(exec, &JSWebSocketConstructorTable, this, propertyName, descriptor); |
|
106 } |
|
107 |
|
108 ConstructType JSWebSocketConstructor::getConstructData(ConstructData& constructData) |
|
109 { |
|
110 constructData.native.function = constructJSWebSocket; |
|
111 return ConstructTypeHost; |
|
112 } |
|
113 |
|
114 /* Hash table for prototype */ |
|
115 #if ENABLE(JIT) |
|
116 #define THUNK_GENERATOR(generator) , generator |
|
117 #else |
|
118 #define THUNK_GENERATOR(generator) |
|
119 #endif |
|
120 |
|
121 static const HashTableValue JSWebSocketPrototypeTableValues[9] = |
|
122 { |
|
123 { "CONNECTING", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWebSocketCONNECTING), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
124 { "OPEN", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWebSocketOPEN), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
125 { "CLOSED", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWebSocketCLOSED), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
126 { "send", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsWebSocketPrototypeFunctionSend), (intptr_t)1 THUNK_GENERATOR(0) }, |
|
127 { "close", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsWebSocketPrototypeFunctionClose), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
128 { "addEventListener", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsWebSocketPrototypeFunctionAddEventListener), (intptr_t)3 THUNK_GENERATOR(0) }, |
|
129 { "removeEventListener", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsWebSocketPrototypeFunctionRemoveEventListener), (intptr_t)3 THUNK_GENERATOR(0) }, |
|
130 { "dispatchEvent", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsWebSocketPrototypeFunctionDispatchEvent), (intptr_t)1 THUNK_GENERATOR(0) }, |
|
131 { 0, 0, 0, 0 THUNK_GENERATOR(0) } |
|
132 }; |
|
133 |
|
134 #undef THUNK_GENERATOR |
|
135 static JSC_CONST_HASHTABLE HashTable JSWebSocketPrototypeTable = { 17, 15, JSWebSocketPrototypeTableValues, 0 }; |
|
136 static const HashTable* getJSWebSocketPrototypeTable(ExecState* exec) |
|
137 { |
|
138 return getHashTableForGlobalData(exec->globalData(), &JSWebSocketPrototypeTable); |
|
139 } |
|
140 const ClassInfo JSWebSocketPrototype::s_info = { "WebSocketPrototype", 0, 0, getJSWebSocketPrototypeTable }; |
|
141 |
|
142 JSObject* JSWebSocketPrototype::self(ExecState* exec, JSGlobalObject* globalObject) |
|
143 { |
|
144 return getDOMPrototype<JSWebSocket>(exec, globalObject); |
|
145 } |
|
146 |
|
147 bool JSWebSocketPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
148 { |
|
149 return getStaticPropertySlot<JSWebSocketPrototype, JSObject>(exec, getJSWebSocketPrototypeTable(exec), this, propertyName, slot); |
|
150 } |
|
151 |
|
152 bool JSWebSocketPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) |
|
153 { |
|
154 return getStaticPropertyDescriptor<JSWebSocketPrototype, JSObject>(exec, getJSWebSocketPrototypeTable(exec), this, propertyName, descriptor); |
|
155 } |
|
156 |
|
157 static const HashTable* getJSWebSocketTable(ExecState* exec) |
|
158 { |
|
159 return getHashTableForGlobalData(exec->globalData(), &JSWebSocketTable); |
|
160 } |
|
161 const ClassInfo JSWebSocket::s_info = { "WebSocket", 0, 0, getJSWebSocketTable }; |
|
162 |
|
163 JSWebSocket::JSWebSocket(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<WebSocket> impl) |
|
164 : DOMObjectWithGlobalPointer(structure, globalObject) |
|
165 , m_impl(impl) |
|
166 { |
|
167 } |
|
168 |
|
169 JSWebSocket::~JSWebSocket() |
|
170 { |
|
171 impl()->invalidateJSEventListeners(this); |
|
172 forgetDOMObject(this, impl()); |
|
173 } |
|
174 |
|
175 void JSWebSocket::markChildren(MarkStack& markStack) |
|
176 { |
|
177 Base::markChildren(markStack); |
|
178 impl()->markJSEventListeners(markStack); |
|
179 } |
|
180 |
|
181 JSObject* JSWebSocket::createPrototype(ExecState* exec, JSGlobalObject* globalObject) |
|
182 { |
|
183 return new (exec) JSWebSocketPrototype(globalObject, JSWebSocketPrototype::createStructure(globalObject->objectPrototype())); |
|
184 } |
|
185 |
|
186 bool JSWebSocket::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
187 { |
|
188 return getStaticValueSlot<JSWebSocket, Base>(exec, getJSWebSocketTable(exec), this, propertyName, slot); |
|
189 } |
|
190 |
|
191 bool JSWebSocket::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) |
|
192 { |
|
193 return getStaticValueDescriptor<JSWebSocket, Base>(exec, getJSWebSocketTable(exec), this, propertyName, descriptor); |
|
194 } |
|
195 |
|
196 JSValue jsWebSocketURL(ExecState* exec, JSValue slotBase, const Identifier&) |
|
197 { |
|
198 JSWebSocket* castedThis = static_cast<JSWebSocket*>(asObject(slotBase)); |
|
199 UNUSED_PARAM(exec); |
|
200 WebSocket* imp = static_cast<WebSocket*>(castedThis->impl()); |
|
201 JSValue result = jsString(exec, imp->url()); |
|
202 return result; |
|
203 } |
|
204 |
|
205 JSValue jsWebSocketReadyState(ExecState* exec, JSValue slotBase, const Identifier&) |
|
206 { |
|
207 JSWebSocket* castedThis = static_cast<JSWebSocket*>(asObject(slotBase)); |
|
208 UNUSED_PARAM(exec); |
|
209 WebSocket* imp = static_cast<WebSocket*>(castedThis->impl()); |
|
210 JSValue result = jsNumber(exec, imp->readyState()); |
|
211 return result; |
|
212 } |
|
213 |
|
214 JSValue jsWebSocketBufferedAmount(ExecState* exec, JSValue slotBase, const Identifier&) |
|
215 { |
|
216 JSWebSocket* castedThis = static_cast<JSWebSocket*>(asObject(slotBase)); |
|
217 UNUSED_PARAM(exec); |
|
218 WebSocket* imp = static_cast<WebSocket*>(castedThis->impl()); |
|
219 JSValue result = jsNumber(exec, imp->bufferedAmount()); |
|
220 return result; |
|
221 } |
|
222 |
|
223 JSValue jsWebSocketOnopen(ExecState* exec, JSValue slotBase, const Identifier&) |
|
224 { |
|
225 JSWebSocket* castedThis = static_cast<JSWebSocket*>(asObject(slotBase)); |
|
226 UNUSED_PARAM(exec); |
|
227 WebSocket* imp = static_cast<WebSocket*>(castedThis->impl()); |
|
228 if (EventListener* listener = imp->onopen()) { |
|
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 jsWebSocketOnmessage(ExecState* exec, JSValue slotBase, const Identifier&) |
|
238 { |
|
239 JSWebSocket* castedThis = static_cast<JSWebSocket*>(asObject(slotBase)); |
|
240 UNUSED_PARAM(exec); |
|
241 WebSocket* imp = static_cast<WebSocket*>(castedThis->impl()); |
|
242 if (EventListener* listener = imp->onmessage()) { |
|
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 jsWebSocketOnerror(ExecState* exec, JSValue slotBase, const Identifier&) |
|
252 { |
|
253 JSWebSocket* castedThis = static_cast<JSWebSocket*>(asObject(slotBase)); |
|
254 UNUSED_PARAM(exec); |
|
255 WebSocket* imp = static_cast<WebSocket*>(castedThis->impl()); |
|
256 if (EventListener* listener = imp->onerror()) { |
|
257 if (const JSEventListener* jsListener = JSEventListener::cast(listener)) { |
|
258 if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext())) |
|
259 return jsFunction; |
|
260 } |
|
261 } |
|
262 return jsNull(); |
|
263 } |
|
264 |
|
265 JSValue jsWebSocketOnclose(ExecState* exec, JSValue slotBase, const Identifier&) |
|
266 { |
|
267 JSWebSocket* castedThis = static_cast<JSWebSocket*>(asObject(slotBase)); |
|
268 UNUSED_PARAM(exec); |
|
269 WebSocket* imp = static_cast<WebSocket*>(castedThis->impl()); |
|
270 if (EventListener* listener = imp->onclose()) { |
|
271 if (const JSEventListener* jsListener = JSEventListener::cast(listener)) { |
|
272 if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext())) |
|
273 return jsFunction; |
|
274 } |
|
275 } |
|
276 return jsNull(); |
|
277 } |
|
278 |
|
279 JSValue jsWebSocketConstructor(ExecState* exec, JSValue slotBase, const Identifier&) |
|
280 { |
|
281 JSWebSocket* domObject = static_cast<JSWebSocket*>(asObject(slotBase)); |
|
282 return JSWebSocket::getConstructor(exec, domObject->globalObject()); |
|
283 } |
|
284 void JSWebSocket::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) |
|
285 { |
|
286 lookupPut<JSWebSocket, Base>(exec, propertyName, value, getJSWebSocketTable(exec), this, slot); |
|
287 } |
|
288 |
|
289 void setJSWebSocketOnopen(ExecState* exec, JSObject* thisObject, JSValue value) |
|
290 { |
|
291 UNUSED_PARAM(exec); |
|
292 WebSocket* imp = static_cast<WebSocket*>(static_cast<JSWebSocket*>(thisObject)->impl()); |
|
293 imp->setOnopen(createJSAttributeEventListener(exec, value, thisObject)); |
|
294 } |
|
295 |
|
296 void setJSWebSocketOnmessage(ExecState* exec, JSObject* thisObject, JSValue value) |
|
297 { |
|
298 UNUSED_PARAM(exec); |
|
299 WebSocket* imp = static_cast<WebSocket*>(static_cast<JSWebSocket*>(thisObject)->impl()); |
|
300 imp->setOnmessage(createJSAttributeEventListener(exec, value, thisObject)); |
|
301 } |
|
302 |
|
303 void setJSWebSocketOnerror(ExecState* exec, JSObject* thisObject, JSValue value) |
|
304 { |
|
305 UNUSED_PARAM(exec); |
|
306 WebSocket* imp = static_cast<WebSocket*>(static_cast<JSWebSocket*>(thisObject)->impl()); |
|
307 imp->setOnerror(createJSAttributeEventListener(exec, value, thisObject)); |
|
308 } |
|
309 |
|
310 void setJSWebSocketOnclose(ExecState* exec, JSObject* thisObject, JSValue value) |
|
311 { |
|
312 UNUSED_PARAM(exec); |
|
313 WebSocket* imp = static_cast<WebSocket*>(static_cast<JSWebSocket*>(thisObject)->impl()); |
|
314 imp->setOnclose(createJSAttributeEventListener(exec, value, thisObject)); |
|
315 } |
|
316 |
|
317 JSValue JSWebSocket::getConstructor(ExecState* exec, JSGlobalObject* globalObject) |
|
318 { |
|
319 return getDOMConstructor<JSWebSocketConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject)); |
|
320 } |
|
321 |
|
322 EncodedJSValue JSC_HOST_CALL jsWebSocketPrototypeFunctionSend(ExecState* exec) |
|
323 { |
|
324 JSValue thisValue = exec->hostThisValue(); |
|
325 if (!thisValue.inherits(&JSWebSocket::s_info)) |
|
326 return throwVMTypeError(exec); |
|
327 JSWebSocket* castedThis = static_cast<JSWebSocket*>(asObject(thisValue)); |
|
328 WebSocket* imp = static_cast<WebSocket*>(castedThis->impl()); |
|
329 if (exec->argumentCount() < 1) |
|
330 return JSValue::encode(jsUndefined()); |
|
331 ExceptionCode ec = 0; |
|
332 const String& data = ustringToString(exec->argument(0).toString(exec)); |
|
333 |
|
334 |
|
335 JSC::JSValue result = jsBoolean(imp->send(data, ec)); |
|
336 setDOMException(exec, ec); |
|
337 return JSValue::encode(result); |
|
338 } |
|
339 |
|
340 EncodedJSValue JSC_HOST_CALL jsWebSocketPrototypeFunctionClose(ExecState* exec) |
|
341 { |
|
342 JSValue thisValue = exec->hostThisValue(); |
|
343 if (!thisValue.inherits(&JSWebSocket::s_info)) |
|
344 return throwVMTypeError(exec); |
|
345 JSWebSocket* castedThis = static_cast<JSWebSocket*>(asObject(thisValue)); |
|
346 WebSocket* imp = static_cast<WebSocket*>(castedThis->impl()); |
|
347 |
|
348 imp->close(); |
|
349 return JSValue::encode(jsUndefined()); |
|
350 } |
|
351 |
|
352 EncodedJSValue JSC_HOST_CALL jsWebSocketPrototypeFunctionAddEventListener(ExecState* exec) |
|
353 { |
|
354 JSValue thisValue = exec->hostThisValue(); |
|
355 if (!thisValue.inherits(&JSWebSocket::s_info)) |
|
356 return throwVMTypeError(exec); |
|
357 JSWebSocket* castedThis = static_cast<JSWebSocket*>(asObject(thisValue)); |
|
358 WebSocket* imp = static_cast<WebSocket*>(castedThis->impl()); |
|
359 JSValue listener = exec->argument(1); |
|
360 if (!listener.isObject()) |
|
361 return JSValue::encode(jsUndefined()); |
|
362 imp->addEventListener(ustringToAtomicString(exec->argument(0).toString(exec)), JSEventListener::create(asObject(listener), castedThis, false, currentWorld(exec)), exec->argument(2).toBoolean(exec)); |
|
363 return JSValue::encode(jsUndefined()); |
|
364 } |
|
365 |
|
366 EncodedJSValue JSC_HOST_CALL jsWebSocketPrototypeFunctionRemoveEventListener(ExecState* exec) |
|
367 { |
|
368 JSValue thisValue = exec->hostThisValue(); |
|
369 if (!thisValue.inherits(&JSWebSocket::s_info)) |
|
370 return throwVMTypeError(exec); |
|
371 JSWebSocket* castedThis = static_cast<JSWebSocket*>(asObject(thisValue)); |
|
372 WebSocket* imp = static_cast<WebSocket*>(castedThis->impl()); |
|
373 JSValue listener = exec->argument(1); |
|
374 if (!listener.isObject()) |
|
375 return JSValue::encode(jsUndefined()); |
|
376 imp->removeEventListener(ustringToAtomicString(exec->argument(0).toString(exec)), JSEventListener::create(asObject(listener), castedThis, false, currentWorld(exec)).get(), exec->argument(2).toBoolean(exec)); |
|
377 return JSValue::encode(jsUndefined()); |
|
378 } |
|
379 |
|
380 EncodedJSValue JSC_HOST_CALL jsWebSocketPrototypeFunctionDispatchEvent(ExecState* exec) |
|
381 { |
|
382 JSValue thisValue = exec->hostThisValue(); |
|
383 if (!thisValue.inherits(&JSWebSocket::s_info)) |
|
384 return throwVMTypeError(exec); |
|
385 JSWebSocket* castedThis = static_cast<JSWebSocket*>(asObject(thisValue)); |
|
386 WebSocket* imp = static_cast<WebSocket*>(castedThis->impl()); |
|
387 ExceptionCode ec = 0; |
|
388 Event* evt = toEvent(exec->argument(0)); |
|
389 |
|
390 |
|
391 JSC::JSValue result = jsBoolean(imp->dispatchEvent(evt, ec)); |
|
392 setDOMException(exec, ec); |
|
393 return JSValue::encode(result); |
|
394 } |
|
395 |
|
396 // Constant getters |
|
397 |
|
398 JSValue jsWebSocketCONNECTING(ExecState* exec, JSValue, const Identifier&) |
|
399 { |
|
400 return jsNumber(exec, static_cast<int>(0)); |
|
401 } |
|
402 |
|
403 JSValue jsWebSocketOPEN(ExecState* exec, JSValue, const Identifier&) |
|
404 { |
|
405 return jsNumber(exec, static_cast<int>(1)); |
|
406 } |
|
407 |
|
408 JSValue jsWebSocketCLOSED(ExecState* exec, JSValue, const Identifier&) |
|
409 { |
|
410 return jsNumber(exec, static_cast<int>(2)); |
|
411 } |
|
412 |
|
413 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, WebSocket* object) |
|
414 { |
|
415 return getDOMObjectWrapper<JSWebSocket>(exec, globalObject, object); |
|
416 } |
|
417 WebSocket* toWebSocket(JSC::JSValue value) |
|
418 { |
|
419 return value.inherits(&JSWebSocket::s_info) ? static_cast<JSWebSocket*>(asObject(value))->impl() : 0; |
|
420 } |
|
421 |
|
422 } |
|
423 |
|
424 #endif // ENABLE(WEB_SOCKETS) |