JSValue jsWebSocketBufferedAmount(ExecState* exec, const Identifier&, const PropertySlot& slot) { JSWebSocket* castedThis = static_cast<JSWebSocket*>(asObject(slot.slotBase())); UNUSED_PARAM(exec); WebSocket* imp = static_cast<WebSocket*>(castedThis->impl()); return jsNumber(exec, imp->bufferedAmount()); }
void setJSWebSocketOnclose(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); JSWebSocket* castedThis = static_cast<JSWebSocket*>(thisObject); WebSocket* imp = static_cast<WebSocket*>(castedThis->impl()); imp->setOnclose(createJSAttributeEventListener(exec, value, thisObject)); }
JSValue JSC_HOST_CALL jsWebSocketPrototypeFunctionRemoveEventListener(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.inherits(&JSWebSocket::s_info)) return throwError(exec, TypeError); JSWebSocket* castedThisObj = static_cast<JSWebSocket*>(asObject(thisValue)); return castedThisObj->removeEventListener(exec, args); }
JSValue jsWebSocketBufferedAmount(ExecState* exec, JSValue slotBase, const Identifier&) { JSWebSocket* castedThis = static_cast<JSWebSocket*>(asObject(slotBase)); UNUSED_PARAM(exec); WebSocket* imp = static_cast<WebSocket*>(castedThis->impl()); JSValue result = jsNumber(imp->bufferedAmount()); return result; }
JSValue jsWebSocketURL(ExecState* exec, JSValue slotBase, const Identifier&) { JSWebSocket* castedThis = static_cast<JSWebSocket*>(asObject(slotBase)); UNUSED_PARAM(exec); WebSocket* imp = static_cast<WebSocket*>(castedThis->impl()); JSValue result = jsString(exec, imp->url()); return result; }
bool JSWebSocketOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) { JSWebSocket* jsWebSocket = static_cast<JSWebSocket*>(handle.get().asCell()); if (jsWebSocket->impl()->hasPendingActivity()) return true; if (!isObservable(jsWebSocket)) return false; UNUSED_PARAM(visitor); return false; }
JSValue JSC_HOST_CALL jsWebSocketPrototypeFunctionClose(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.inherits(&JSWebSocket::s_info)) return throwError(exec, TypeError); JSWebSocket* castedThisObj = static_cast<JSWebSocket*>(asObject(thisValue)); WebSocket* imp = static_cast<WebSocket*>(castedThisObj->impl()); imp->close(); return jsUndefined(); }
JSValue jsWebSocketOnclose(ExecState* exec, const Identifier&, const PropertySlot& slot) { JSWebSocket* castedThis = static_cast<JSWebSocket*>(asObject(slot.slotBase())); UNUSED_PARAM(exec); WebSocket* imp = static_cast<WebSocket*>(castedThis->impl()); if (EventListener* listener = imp->onclose()) { if (JSObject* jsFunction = listener->jsFunction(imp->scriptExecutionContext())) return jsFunction; } return jsNull(); }
EncodedJSValue JSC_HOST_CALL jsWebSocketPrototypeFunctionClose(ExecState* exec) { JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSWebSocket::s_info)) return throwVMTypeError(exec); JSWebSocket* castedThis = static_cast<JSWebSocket*>(asObject(thisValue)); WebSocket* imp = static_cast<WebSocket*>(castedThis->impl()); imp->close(); return JSValue::encode(jsUndefined()); }
EncodedJSValue JSC_HOST_CALL jsWebSocketPrototypeFunctionRemoveEventListener(ExecState* exec) { JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSWebSocket::s_info)) return throwVMTypeError(exec); JSWebSocket* castedThis = static_cast<JSWebSocket*>(asObject(thisValue)); WebSocket* imp = static_cast<WebSocket*>(castedThis->impl()); JSValue listener = exec->argument(1); if (!listener.isObject()) return JSValue::encode(jsUndefined()); imp->removeEventListener(ustringToAtomicString(exec->argument(0).toString(exec)), JSEventListener::create(asObject(listener), castedThis, false, currentWorld(exec)).get(), exec->argument(2).toBoolean(exec)); return JSValue::encode(jsUndefined()); }
JSValue jsWebSocketOnclose(ExecState* exec, JSValue slotBase, const Identifier&) { JSWebSocket* castedThis = static_cast<JSWebSocket*>(asObject(slotBase)); UNUSED_PARAM(exec); WebSocket* imp = static_cast<WebSocket*>(castedThis->impl()); if (EventListener* listener = imp->onclose()) { if (const JSEventListener* jsListener = JSEventListener::cast(listener)) { if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext())) return jsFunction; } } return jsNull(); }
JSValue JSC_HOST_CALL jsWebSocketPrototypeFunctionDispatchEvent(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.inherits(&JSWebSocket::s_info)) return throwError(exec, TypeError); JSWebSocket* castedThisObj = static_cast<JSWebSocket*>(asObject(thisValue)); WebSocket* imp = static_cast<WebSocket*>(castedThisObj->impl()); ExceptionCode ec = 0; Event* evt = toEvent(args.at(0)); JSC::JSValue result = jsBoolean(imp->dispatchEvent(evt, ec)); setDOMException(exec, ec); return result; }
EncodedJSValue JSC_HOST_CALL jsWebSocketPrototypeFunctionDispatchEvent(ExecState* exec) { JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSWebSocket::s_info)) return throwVMTypeError(exec); JSWebSocket* castedThis = static_cast<JSWebSocket*>(asObject(thisValue)); WebSocket* imp = static_cast<WebSocket*>(castedThis->impl()); ExceptionCode ec = 0; Event* evt(toEvent(exec->argument(0))); if (exec->hadException()) return JSValue::encode(jsUndefined()); JSC::JSValue result = jsBoolean(imp->dispatchEvent(evt, ec)); setDOMException(exec, ec); return JSValue::encode(result); }
EncodedJSValue JSC_HOST_CALL jsWebSocketPrototypeFunctionSend(ExecState* exec) { JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSWebSocket::s_info)) return throwVMTypeError(exec); JSWebSocket* castedThis = static_cast<JSWebSocket*>(asObject(thisValue)); WebSocket* imp = static_cast<WebSocket*>(castedThis->impl()); if (exec->argumentCount() < 1) return JSValue::encode(jsUndefined()); ExceptionCode ec = 0; const String& data(ustringToString(exec->argument(0).toString(exec))); if (exec->hadException()) return JSValue::encode(jsUndefined()); JSC::JSValue result = jsBoolean(imp->send(data, ec)); setDOMException(exec, ec); return JSValue::encode(result); }
void JSWebSocketOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) { JSWebSocket* jsWebSocket = static_cast<JSWebSocket*>(handle.get().asCell()); DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context); uncacheWrapper(world, jsWebSocket->impl(), jsWebSocket); }
JSValue jsWebSocketConstructor(ExecState* exec, JSValue slotBase, const Identifier&) { JSWebSocket* domObject = static_cast<JSWebSocket*>(asObject(slotBase)); return JSWebSocket::getConstructor(exec, domObject->globalObject()); }