| /* |
| This file is part of the WebKit open source project. |
| This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
| |
| This library is free software; you can redistribute it and/or |
| modify it under the terms of the GNU Library General Public |
| License as published by the Free Software Foundation; either |
| version 2 of the License, or (at your option) any later version. |
| |
| This library is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| Library General Public License for more details. |
| |
| You should have received a copy of the GNU Library General Public License |
| along with this library; see the file COPYING.LIB. If not, write to |
| the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| Boston, MA 02110-1301, USA. |
| */ |
| |
| #include "config.h" |
| |
| #if ENABLE(WEB_RTC) |
| |
| #include "JSRTCDataChannel.h" |
| |
| #include "EventNames.h" |
| #include "ExceptionCode.h" |
| #include "JSBlob.h" |
| #include "JSDOMBinding.h" |
| #include "JSEventListener.h" |
| #include "URL.h" |
| #include <runtime/Error.h> |
| #include <runtime/JSString.h> |
| #include <wtf/GetPtr.h> |
| |
| using namespace JSC; |
| |
| namespace WebCore { |
| |
| // Functions |
| |
| JSC::EncodedJSValue JSC_HOST_CALL jsRTCDataChannelPrototypeFunctionSend(JSC::ExecState*); |
| JSC::EncodedJSValue JSC_HOST_CALL jsRTCDataChannelPrototypeFunctionClose(JSC::ExecState*); |
| |
| // Attributes |
| |
| JSC::EncodedJSValue jsRTCDataChannelLabel(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsRTCDataChannelOrdered(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsRTCDataChannelMaxRetransmitTime(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsRTCDataChannelMaxRetransmits(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsRTCDataChannelProtocol(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsRTCDataChannelNegotiated(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsRTCDataChannelId(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsRTCDataChannelReadyState(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsRTCDataChannelBufferedAmount(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsRTCDataChannelBinaryType(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSRTCDataChannelBinaryType(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| JSC::EncodedJSValue jsRTCDataChannelOnopen(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSRTCDataChannelOnopen(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| JSC::EncodedJSValue jsRTCDataChannelOnerror(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSRTCDataChannelOnerror(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| JSC::EncodedJSValue jsRTCDataChannelOnclose(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSRTCDataChannelOnclose(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| JSC::EncodedJSValue jsRTCDataChannelOnmessage(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSRTCDataChannelOnmessage(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| bool setJSRTCDataChannelConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| |
| class JSRTCDataChannelPrototype : public JSC::JSNonFinalObject { |
| public: |
| typedef JSC::JSNonFinalObject Base; |
| static JSRTCDataChannelPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) |
| { |
| JSRTCDataChannelPrototype* ptr = new (NotNull, JSC::allocateCell<JSRTCDataChannelPrototype>(vm.heap)) JSRTCDataChannelPrototype(vm, globalObject, structure); |
| ptr->finishCreation(vm); |
| return ptr; |
| } |
| |
| DECLARE_INFO; |
| static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| { |
| return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| } |
| |
| private: |
| JSRTCDataChannelPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| : JSC::JSNonFinalObject(vm, structure) |
| { |
| } |
| |
| void finishCreation(JSC::VM&); |
| }; |
| |
| /* Hash table for prototype */ |
| |
| static const HashTableValue JSRTCDataChannelPrototypeTableValues[] = |
| { |
| { "label", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCDataChannelLabel), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "ordered", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCDataChannelOrdered), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "maxRetransmitTime", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCDataChannelMaxRetransmitTime), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "maxRetransmits", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCDataChannelMaxRetransmits), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "protocol", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCDataChannelProtocol), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "negotiated", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCDataChannelNegotiated), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "id", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCDataChannelId), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "readyState", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCDataChannelReadyState), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "bufferedAmount", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCDataChannelBufferedAmount), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "binaryType", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCDataChannelBinaryType), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRTCDataChannelBinaryType) } }, |
| { "onopen", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCDataChannelOnopen), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRTCDataChannelOnopen) } }, |
| { "onerror", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCDataChannelOnerror), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRTCDataChannelOnerror) } }, |
| { "onclose", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCDataChannelOnclose), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRTCDataChannelOnclose) } }, |
| { "onmessage", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCDataChannelOnmessage), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRTCDataChannelOnmessage) } }, |
| { "send", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsRTCDataChannelPrototypeFunctionSend), (intptr_t) (1) } }, |
| { "close", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsRTCDataChannelPrototypeFunctionClose), (intptr_t) (0) } }, |
| }; |
| |
| const ClassInfo JSRTCDataChannelPrototype::s_info = { "RTCDataChannelPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSRTCDataChannelPrototype) }; |
| |
| void JSRTCDataChannelPrototype::finishCreation(VM& vm) |
| { |
| Base::finishCreation(vm); |
| reifyStaticProperties(vm, JSRTCDataChannelPrototypeTableValues, *this); |
| } |
| |
| const ClassInfo JSRTCDataChannel::s_info = { "RTCDataChannel", &Base::s_info, 0, CREATE_METHOD_TABLE(JSRTCDataChannel) }; |
| |
| JSRTCDataChannel::JSRTCDataChannel(Structure* structure, JSDOMGlobalObject& globalObject, Ref<RTCDataChannel>&& impl) |
| : JSEventTarget(structure, globalObject, WTFMove(impl)) |
| { |
| } |
| |
| JSObject* JSRTCDataChannel::createPrototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return JSRTCDataChannelPrototype::create(vm, globalObject, JSRTCDataChannelPrototype::createStructure(vm, globalObject, JSEventTarget::prototype(vm, globalObject))); |
| } |
| |
| JSObject* JSRTCDataChannel::prototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return getDOMPrototype<JSRTCDataChannel>(vm, globalObject); |
| } |
| |
| EncodedJSValue jsRTCDataChannelLabel(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSRTCDataChannel*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "RTCDataChannel", "label"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.label()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsRTCDataChannelOrdered(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSRTCDataChannel*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "RTCDataChannel", "ordered"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsBoolean(impl.ordered()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsRTCDataChannelMaxRetransmitTime(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSRTCDataChannel*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "RTCDataChannel", "maxRetransmitTime"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsNumber(impl.maxRetransmitTime()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsRTCDataChannelMaxRetransmits(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSRTCDataChannel*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "RTCDataChannel", "maxRetransmits"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsNumber(impl.maxRetransmits()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsRTCDataChannelProtocol(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSRTCDataChannel*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "RTCDataChannel", "protocol"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.protocol()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsRTCDataChannelNegotiated(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSRTCDataChannel*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "RTCDataChannel", "negotiated"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsBoolean(impl.negotiated()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsRTCDataChannelId(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSRTCDataChannel*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "RTCDataChannel", "id"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsNumber(impl.id()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsRTCDataChannelReadyState(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSRTCDataChannel*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "RTCDataChannel", "readyState"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.readyState()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsRTCDataChannelBufferedAmount(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSRTCDataChannel*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "RTCDataChannel", "bufferedAmount"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsNumber(impl.bufferedAmount()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsRTCDataChannelBinaryType(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSRTCDataChannel*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "RTCDataChannel", "binaryType"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.binaryType()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsRTCDataChannelOnopen(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSRTCDataChannel*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "RTCDataChannel", "onopen"); |
| } |
| UNUSED_PARAM(state); |
| return JSValue::encode(eventHandlerAttribute(castedThis->wrapped(), eventNames().openEvent)); |
| } |
| |
| |
| EncodedJSValue jsRTCDataChannelOnerror(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSRTCDataChannel*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "RTCDataChannel", "onerror"); |
| } |
| UNUSED_PARAM(state); |
| return JSValue::encode(eventHandlerAttribute(castedThis->wrapped(), eventNames().errorEvent)); |
| } |
| |
| |
| EncodedJSValue jsRTCDataChannelOnclose(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSRTCDataChannel*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "RTCDataChannel", "onclose"); |
| } |
| UNUSED_PARAM(state); |
| return JSValue::encode(eventHandlerAttribute(castedThis->wrapped(), eventNames().closeEvent)); |
| } |
| |
| |
| EncodedJSValue jsRTCDataChannelOnmessage(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSRTCDataChannel*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "RTCDataChannel", "onmessage"); |
| } |
| UNUSED_PARAM(state); |
| return JSValue::encode(eventHandlerAttribute(castedThis->wrapped(), eventNames().messageEvent)); |
| } |
| |
| |
| bool setJSRTCDataChannelConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSValue value = JSValue::decode(encodedValue); |
| JSRTCDataChannelPrototype* domObject = jsDynamicCast<JSRTCDataChannelPrototype*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!domObject)) { |
| throwVMTypeError(state, throwScope); |
| return false; |
| } |
| // Shadowing a built-in constructor |
| return domObject->putDirect(state->vm(), state->propertyNames().constructor, value); |
| } |
| |
| bool setJSRTCDataChannelBinaryType(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue value = JSValue::decode(encodedValue); |
| UNUSED_PARAM(thisValue); |
| JSRTCDataChannel* castedThis = jsDynamicCast<JSRTCDataChannel*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!castedThis)) { |
| return throwSetterTypeError(*state, throwScope, "RTCDataChannel", "binaryType"); |
| } |
| auto& impl = castedThis->wrapped(); |
| ExceptionCode ec = 0; |
| auto nativeValue = value.toWTFString(state); |
| RETURN_IF_EXCEPTION(throwScope, false); |
| impl.setBinaryType(WTFMove(nativeValue), ec); |
| setDOMException(state, throwScope, ec); |
| return true; |
| } |
| |
| |
| bool setJSRTCDataChannelOnopen(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue value = JSValue::decode(encodedValue); |
| UNUSED_PARAM(thisValue); |
| JSRTCDataChannel* castedThis = jsDynamicCast<JSRTCDataChannel*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!castedThis)) { |
| return throwSetterTypeError(*state, throwScope, "RTCDataChannel", "onopen"); |
| } |
| setEventHandlerAttribute(*state, *castedThis, castedThis->wrapped(), eventNames().openEvent, value); |
| return true; |
| } |
| |
| |
| bool setJSRTCDataChannelOnerror(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue value = JSValue::decode(encodedValue); |
| UNUSED_PARAM(thisValue); |
| JSRTCDataChannel* castedThis = jsDynamicCast<JSRTCDataChannel*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!castedThis)) { |
| return throwSetterTypeError(*state, throwScope, "RTCDataChannel", "onerror"); |
| } |
| setEventHandlerAttribute(*state, *castedThis, castedThis->wrapped(), eventNames().errorEvent, value); |
| return true; |
| } |
| |
| |
| bool setJSRTCDataChannelOnclose(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue value = JSValue::decode(encodedValue); |
| UNUSED_PARAM(thisValue); |
| JSRTCDataChannel* castedThis = jsDynamicCast<JSRTCDataChannel*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!castedThis)) { |
| return throwSetterTypeError(*state, throwScope, "RTCDataChannel", "onclose"); |
| } |
| setEventHandlerAttribute(*state, *castedThis, castedThis->wrapped(), eventNames().closeEvent, value); |
| return true; |
| } |
| |
| |
| bool setJSRTCDataChannelOnmessage(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue value = JSValue::decode(encodedValue); |
| UNUSED_PARAM(thisValue); |
| JSRTCDataChannel* castedThis = jsDynamicCast<JSRTCDataChannel*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!castedThis)) { |
| return throwSetterTypeError(*state, throwScope, "RTCDataChannel", "onmessage"); |
| } |
| setEventHandlerAttribute(*state, *castedThis, castedThis->wrapped(), eventNames().messageEvent, value); |
| return true; |
| } |
| |
| |
| static inline EncodedJSValue jsRTCDataChannelPrototypeFunctionSend1(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSRTCDataChannel*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "RTCDataChannel", "send"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSRTCDataChannel::info()); |
| auto& impl = castedThis->wrapped(); |
| if (UNLIKELY(state->argumentCount() < 1)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| ExceptionCode ec = 0; |
| auto data = toArrayBuffer(state->uncheckedArgument(0)); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| if (UNLIKELY(!data)) |
| return throwArgumentTypeError(*state, throwScope, 0, "data", "RTCDataChannel", "send", "ArrayBuffer"); |
| impl.send(*data, ec); |
| setDOMException(state, throwScope, ec); |
| return JSValue::encode(jsUndefined()); |
| } |
| |
| static inline EncodedJSValue jsRTCDataChannelPrototypeFunctionSend2(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSRTCDataChannel*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "RTCDataChannel", "send"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSRTCDataChannel::info()); |
| auto& impl = castedThis->wrapped(); |
| if (UNLIKELY(state->argumentCount() < 1)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| ExceptionCode ec = 0; |
| auto data = toArrayBufferView(state->uncheckedArgument(0)); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| if (UNLIKELY(!data)) |
| return throwArgumentTypeError(*state, throwScope, 0, "data", "RTCDataChannel", "send", "ArrayBufferView"); |
| impl.send(data.releaseNonNull(), ec); |
| setDOMException(state, throwScope, ec); |
| return JSValue::encode(jsUndefined()); |
| } |
| |
| static inline EncodedJSValue jsRTCDataChannelPrototypeFunctionSend3(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSRTCDataChannel*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "RTCDataChannel", "send"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSRTCDataChannel::info()); |
| auto& impl = castedThis->wrapped(); |
| if (UNLIKELY(state->argumentCount() < 1)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| ExceptionCode ec = 0; |
| auto data = JSBlob::toWrapped(state->uncheckedArgument(0)); |
| if (UNLIKELY(!data)) |
| return throwArgumentTypeError(*state, throwScope, 0, "data", "RTCDataChannel", "send", "Blob"); |
| impl.send(*data, ec); |
| setDOMException(state, throwScope, ec); |
| return JSValue::encode(jsUndefined()); |
| } |
| |
| static inline EncodedJSValue jsRTCDataChannelPrototypeFunctionSend4(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSRTCDataChannel*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "RTCDataChannel", "send"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSRTCDataChannel::info()); |
| auto& impl = castedThis->wrapped(); |
| if (UNLIKELY(state->argumentCount() < 1)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| ExceptionCode ec = 0; |
| auto data = state->uncheckedArgument(0).toWTFString(state); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| impl.send(WTFMove(data), ec); |
| setDOMException(state, throwScope, ec); |
| return JSValue::encode(jsUndefined()); |
| } |
| |
| EncodedJSValue JSC_HOST_CALL jsRTCDataChannelPrototypeFunctionSend(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| size_t argsCount = std::min<size_t>(1, state->argumentCount()); |
| if (argsCount == 1) { |
| JSValue distinguishingArg = state->uncheckedArgument(0); |
| if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JSArrayBuffer::info())) |
| return jsRTCDataChannelPrototypeFunctionSend1(state); |
| if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JSArrayBufferView::info())) |
| return jsRTCDataChannelPrototypeFunctionSend2(state); |
| if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JSBlob::info())) |
| return jsRTCDataChannelPrototypeFunctionSend3(state); |
| return jsRTCDataChannelPrototypeFunctionSend4(state); |
| } |
| return argsCount < 1 ? throwVMError(state, throwScope, createNotEnoughArgumentsError(state)) : throwVMTypeError(state, throwScope); |
| } |
| |
| EncodedJSValue JSC_HOST_CALL jsRTCDataChannelPrototypeFunctionClose(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSRTCDataChannel*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "RTCDataChannel", "close"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSRTCDataChannel::info()); |
| auto& impl = castedThis->wrapped(); |
| impl.close(); |
| return JSValue::encode(jsUndefined()); |
| } |
| |
| void JSRTCDataChannel::visitChildren(JSCell* cell, SlotVisitor& visitor) |
| { |
| auto* thisObject = jsCast<JSRTCDataChannel*>(cell); |
| ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| Base::visitChildren(thisObject, visitor); |
| thisObject->wrapped().visitJSEventListeners(visitor); |
| } |
| |
| #if ENABLE(BINDING_INTEGRITY) |
| #if PLATFORM(WIN) |
| #pragma warning(disable: 4483) |
| extern "C" { extern void (*const __identifier("??_7RTCDataChannel@WebCore@@6B@")[])(); } |
| #else |
| extern "C" { extern void* _ZTVN7WebCore14RTCDataChannelE[]; } |
| #endif |
| #endif |
| |
| JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<RTCDataChannel>&& impl) |
| { |
| |
| #if ENABLE(BINDING_INTEGRITY) |
| void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
| #if PLATFORM(WIN) |
| void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7RTCDataChannel@WebCore@@6B@")); |
| #else |
| void* expectedVTablePointer = &_ZTVN7WebCore14RTCDataChannelE[2]; |
| #if COMPILER(CLANG) |
| // If this fails RTCDataChannel does not have a vtable, so you need to add the |
| // ImplementationLacksVTable attribute to the interface definition |
| static_assert(__is_polymorphic(RTCDataChannel), "RTCDataChannel is not polymorphic"); |
| #endif |
| #endif |
| // If you hit this assertion you either have a use after free bug, or |
| // RTCDataChannel has subclasses. If RTCDataChannel has subclasses that get passed |
| // to toJS() we currently require RTCDataChannel you to opt out of binding hardening |
| // by adding the SkipVTableValidation attribute to the interface IDL definition |
| RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
| #endif |
| return createWrapper<RTCDataChannel>(globalObject, WTFMove(impl)); |
| } |
| |
| JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, RTCDataChannel& impl) |
| { |
| return wrap(state, globalObject, impl); |
| } |
| |
| RTCDataChannel* JSRTCDataChannel::toWrapped(JSC::JSValue value) |
| { |
| if (auto* wrapper = jsDynamicCast<JSRTCDataChannel*>(value)) |
| return &wrapper->wrapped(); |
| return nullptr; |
| } |
| |
| } |
| |
| #endif // ENABLE(WEB_RTC) |