blob: ffd803070ee04acf1468aebf931bbbc248413a48 [file] [log] [blame]
/*
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 "JSRTCRtpTransceiver.h"
#include "ExceptionCode.h"
#include "JSDOMBinding.h"
#include "JSDOMConstructor.h"
#include "JSDOMConvert.h"
#include "JSRTCRtpReceiver.h"
#include "JSRTCRtpSender.h"
#include "URL.h"
#include <runtime/Error.h>
#include <runtime/FunctionPrototype.h>
#include <runtime/JSString.h>
#include <wtf/GetPtr.h>
using namespace JSC;
namespace WebCore {
template<typename T> Optional<T> parse(ExecState&, JSValue);
template<typename T> const char* expectedEnumerationValues();
JSString* jsStringWithCache(ExecState*, RTCRtpTransceiver::Direction);
JSString* jsStringWithCache(ExecState* state, RTCRtpTransceiver::Direction enumerationValue)
{
static NeverDestroyed<const String> values[] = {
ASCIILiteral("sendrecv"),
ASCIILiteral("sendonly"),
ASCIILiteral("recvonly"),
ASCIILiteral("inactive"),
};
static_assert(static_cast<size_t>(RTCRtpTransceiver::Direction::Sendrecv) == 0, "RTCRtpTransceiver::Direction::Sendrecv is not 0 as expected");
static_assert(static_cast<size_t>(RTCRtpTransceiver::Direction::Sendonly) == 1, "RTCRtpTransceiver::Direction::Sendonly is not 1 as expected");
static_assert(static_cast<size_t>(RTCRtpTransceiver::Direction::Recvonly) == 2, "RTCRtpTransceiver::Direction::Recvonly is not 2 as expected");
static_assert(static_cast<size_t>(RTCRtpTransceiver::Direction::Inactive) == 3, "RTCRtpTransceiver::Direction::Inactive is not 3 as expected");
ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));
return jsStringWithCache(state, values[static_cast<size_t>(enumerationValue)]);
}
template<> struct JSValueTraits<RTCRtpTransceiver::Direction> {
static JSString* arrayJSValue(ExecState* state, JSDOMGlobalObject*, RTCRtpTransceiver::Direction value) { return jsStringWithCache(state, value); }
};
template<> Optional<RTCRtpTransceiver::Direction> parse<RTCRtpTransceiver::Direction>(ExecState& state, JSValue value)
{
auto stringValue = value.toWTFString(&state);
if (stringValue == "sendrecv")
return RTCRtpTransceiver::Direction::Sendrecv;
if (stringValue == "sendonly")
return RTCRtpTransceiver::Direction::Sendonly;
if (stringValue == "recvonly")
return RTCRtpTransceiver::Direction::Recvonly;
if (stringValue == "inactive")
return RTCRtpTransceiver::Direction::Inactive;
return Nullopt;
}
template<> RTCRtpTransceiver::Direction convert<RTCRtpTransceiver::Direction>(ExecState& state, JSValue value)
{
VM& vm = state.vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
auto result = parse<RTCRtpTransceiver::Direction>(state, value);
if (UNLIKELY(!result)) {
throwTypeError(&state, throwScope);
return { };
}
return result.value();
}
template<> inline const char* expectedEnumerationValues<RTCRtpTransceiver::Direction>()
{
return "\"sendrecv\", \"sendonly\", \"recvonly\", \"inactive\"";
}
// Functions
JSC::EncodedJSValue JSC_HOST_CALL jsRTCRtpTransceiverPrototypeFunctionSetDirection(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsRTCRtpTransceiverPrototypeFunctionStop(JSC::ExecState*);
// Attributes
JSC::EncodedJSValue jsRTCRtpTransceiverMid(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsRTCRtpTransceiverSender(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsRTCRtpTransceiverReceiver(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsRTCRtpTransceiverStopped(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsRTCRtpTransceiverDirection(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsRTCRtpTransceiverConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSRTCRtpTransceiverConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
class JSRTCRtpTransceiverPrototype : public JSC::JSNonFinalObject {
public:
typedef JSC::JSNonFinalObject Base;
static JSRTCRtpTransceiverPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
{
JSRTCRtpTransceiverPrototype* ptr = new (NotNull, JSC::allocateCell<JSRTCRtpTransceiverPrototype>(vm.heap)) JSRTCRtpTransceiverPrototype(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:
JSRTCRtpTransceiverPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
: JSC::JSNonFinalObject(vm, structure)
{
}
void finishCreation(JSC::VM&);
};
typedef JSDOMConstructorNotConstructable<JSRTCRtpTransceiver> JSRTCRtpTransceiverConstructor;
template<> JSValue JSRTCRtpTransceiverConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
{
UNUSED_PARAM(vm);
return globalObject.functionPrototype();
}
template<> void JSRTCRtpTransceiverConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
{
putDirect(vm, vm.propertyNames->prototype, JSRTCRtpTransceiver::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("RTCRtpTransceiver"))), ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum);
}
template<> const ClassInfo JSRTCRtpTransceiverConstructor::s_info = { "RTCRtpTransceiver", &Base::s_info, 0, CREATE_METHOD_TABLE(JSRTCRtpTransceiverConstructor) };
/* Hash table for prototype */
static const HashTableValue JSRTCRtpTransceiverPrototypeTableValues[] =
{
{ "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCRtpTransceiverConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRTCRtpTransceiverConstructor) } },
{ "mid", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCRtpTransceiverMid), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "sender", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCRtpTransceiverSender), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "receiver", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCRtpTransceiverReceiver), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "stopped", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCRtpTransceiverStopped), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "direction", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCRtpTransceiverDirection), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "setDirection", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsRTCRtpTransceiverPrototypeFunctionSetDirection), (intptr_t) (1) } },
{ "stop", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsRTCRtpTransceiverPrototypeFunctionStop), (intptr_t) (0) } },
};
const ClassInfo JSRTCRtpTransceiverPrototype::s_info = { "RTCRtpTransceiverPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSRTCRtpTransceiverPrototype) };
void JSRTCRtpTransceiverPrototype::finishCreation(VM& vm)
{
Base::finishCreation(vm);
reifyStaticProperties(vm, JSRTCRtpTransceiverPrototypeTableValues, *this);
}
const ClassInfo JSRTCRtpTransceiver::s_info = { "RTCRtpTransceiver", &Base::s_info, 0, CREATE_METHOD_TABLE(JSRTCRtpTransceiver) };
JSRTCRtpTransceiver::JSRTCRtpTransceiver(Structure* structure, JSDOMGlobalObject& globalObject, Ref<RTCRtpTransceiver>&& impl)
: JSDOMWrapper<RTCRtpTransceiver>(structure, globalObject, WTFMove(impl))
{
}
JSObject* JSRTCRtpTransceiver::createPrototype(VM& vm, JSGlobalObject* globalObject)
{
return JSRTCRtpTransceiverPrototype::create(vm, globalObject, JSRTCRtpTransceiverPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
JSObject* JSRTCRtpTransceiver::prototype(VM& vm, JSGlobalObject* globalObject)
{
return getDOMPrototype<JSRTCRtpTransceiver>(vm, globalObject);
}
void JSRTCRtpTransceiver::destroy(JSC::JSCell* cell)
{
JSRTCRtpTransceiver* thisObject = static_cast<JSRTCRtpTransceiver*>(cell);
thisObject->JSRTCRtpTransceiver::~JSRTCRtpTransceiver();
}
EncodedJSValue jsRTCRtpTransceiverMid(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<JSRTCRtpTransceiver*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "RTCRtpTransceiver", "mid");
}
auto& impl = castedThis->wrapped();
JSValue result = jsStringOrNull(state, impl.mid());
return JSValue::encode(result);
}
EncodedJSValue jsRTCRtpTransceiverSender(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<JSRTCRtpTransceiver*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "RTCRtpTransceiver", "sender");
}
auto& impl = castedThis->wrapped();
JSValue result = toJS(state, castedThis->globalObject(), impl.sender());
return JSValue::encode(result);
}
EncodedJSValue jsRTCRtpTransceiverReceiver(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<JSRTCRtpTransceiver*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "RTCRtpTransceiver", "receiver");
}
auto& impl = castedThis->wrapped();
JSValue result = toJS(state, castedThis->globalObject(), impl.receiver());
return JSValue::encode(result);
}
EncodedJSValue jsRTCRtpTransceiverStopped(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<JSRTCRtpTransceiver*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "RTCRtpTransceiver", "stopped");
}
auto& impl = castedThis->wrapped();
JSValue result = jsBoolean(impl.stopped());
return JSValue::encode(result);
}
EncodedJSValue jsRTCRtpTransceiverDirection(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<JSRTCRtpTransceiver*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "RTCRtpTransceiver", "direction");
}
auto& impl = castedThis->wrapped();
JSValue result = jsStringWithCache(state, impl.direction());
return JSValue::encode(result);
}
EncodedJSValue jsRTCRtpTransceiverConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSRTCRtpTransceiverPrototype* domObject = jsDynamicCast<JSRTCRtpTransceiverPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!domObject))
return throwVMTypeError(state, throwScope);
return JSValue::encode(JSRTCRtpTransceiver::getConstructor(state->vm(), domObject->globalObject()));
}
bool setJSRTCRtpTransceiverConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSValue value = JSValue::decode(encodedValue);
JSRTCRtpTransceiverPrototype* domObject = jsDynamicCast<JSRTCRtpTransceiverPrototype*>(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);
}
JSValue JSRTCRtpTransceiver::getConstructor(VM& vm, const JSGlobalObject* globalObject)
{
return getDOMConstructor<JSRTCRtpTransceiverConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
}
EncodedJSValue JSC_HOST_CALL jsRTCRtpTransceiverPrototypeFunctionSetDirection(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSRTCRtpTransceiver*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "RTCRtpTransceiver", "setDirection");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSRTCRtpTransceiver::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 1))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
auto directionValue = state->uncheckedArgument(0);
RTCRtpTransceiver::Direction direction;
auto optionalValue = parse<RTCRtpTransceiver::Direction>(*state, directionValue);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
if (UNLIKELY(!optionalValue))
return throwArgumentMustBeEnumError(*state, throwScope, 0, "direction", "RTCRtpTransceiver", "setDirection", expectedEnumerationValues<RTCRtpTransceiver::Direction>());
direction = optionalValue.value();
impl.setDirection(direction);
return JSValue::encode(jsUndefined());
}
EncodedJSValue JSC_HOST_CALL jsRTCRtpTransceiverPrototypeFunctionStop(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSRTCRtpTransceiver*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "RTCRtpTransceiver", "stop");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSRTCRtpTransceiver::info());
auto& impl = castedThis->wrapped();
impl.stop();
return JSValue::encode(jsUndefined());
}
bool JSRTCRtpTransceiverOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
{
UNUSED_PARAM(handle);
UNUSED_PARAM(visitor);
return false;
}
void JSRTCRtpTransceiverOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
{
auto* jsRTCRtpTransceiver = jsCast<JSRTCRtpTransceiver*>(handle.slot()->asCell());
auto& world = *static_cast<DOMWrapperWorld*>(context);
uncacheWrapper(world, &jsRTCRtpTransceiver->wrapped(), jsRTCRtpTransceiver);
}
#if ENABLE(BINDING_INTEGRITY)
#if PLATFORM(WIN)
#pragma warning(disable: 4483)
extern "C" { extern void (*const __identifier("??_7RTCRtpTransceiver@WebCore@@6B@")[])(); }
#else
extern "C" { extern void* _ZTVN7WebCore17RTCRtpTransceiverE[]; }
#endif
#endif
JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<RTCRtpTransceiver>&& impl)
{
#if ENABLE(BINDING_INTEGRITY)
void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
#if PLATFORM(WIN)
void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7RTCRtpTransceiver@WebCore@@6B@"));
#else
void* expectedVTablePointer = &_ZTVN7WebCore17RTCRtpTransceiverE[2];
#if COMPILER(CLANG)
// If this fails RTCRtpTransceiver does not have a vtable, so you need to add the
// ImplementationLacksVTable attribute to the interface definition
static_assert(__is_polymorphic(RTCRtpTransceiver), "RTCRtpTransceiver is not polymorphic");
#endif
#endif
// If you hit this assertion you either have a use after free bug, or
// RTCRtpTransceiver has subclasses. If RTCRtpTransceiver has subclasses that get passed
// to toJS() we currently require RTCRtpTransceiver you to opt out of binding hardening
// by adding the SkipVTableValidation attribute to the interface IDL definition
RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
#endif
return createWrapper<RTCRtpTransceiver>(globalObject, WTFMove(impl));
}
JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, RTCRtpTransceiver& impl)
{
return wrap(state, globalObject, impl);
}
RTCRtpTransceiver* JSRTCRtpTransceiver::toWrapped(JSC::JSValue value)
{
if (auto* wrapper = jsDynamicCast<JSRTCRtpTransceiver*>(value))
return &wrapper->wrapped();
return nullptr;
}
}
#endif // ENABLE(WEB_RTC)