blob: e0ea91a21771ee1bb211c135d402fe7f2de05818 [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 "JSRTCSessionDescription.h"
#include "ExceptionCode.h"
#include "JSDOMBinding.h"
#include "JSDOMConstructor.h"
#include "JSDOMConvert.h"
#include "URL.h"
#include <runtime/Error.h>
#include <runtime/FunctionPrototype.h>
#include <runtime/JSString.h>
#include <wtf/GetPtr.h>
#if ENABLE(WEB_RTC)
#include "Dictionary.h"
#endif
using namespace JSC;
namespace WebCore {
template<typename T> Optional<T> parse(ExecState&, JSValue);
template<typename T> const char* expectedEnumerationValues();
JSString* jsStringWithCache(ExecState*, RTCSessionDescription::SdpType);
JSString* jsStringWithCache(ExecState* state, RTCSessionDescription::SdpType enumerationValue)
{
static NeverDestroyed<const String> values[] = {
ASCIILiteral("offer"),
ASCIILiteral("pranswer"),
ASCIILiteral("answer"),
ASCIILiteral("rollback"),
};
static_assert(static_cast<size_t>(RTCSessionDescription::SdpType::Offer) == 0, "RTCSessionDescription::SdpType::Offer is not 0 as expected");
static_assert(static_cast<size_t>(RTCSessionDescription::SdpType::Pranswer) == 1, "RTCSessionDescription::SdpType::Pranswer is not 1 as expected");
static_assert(static_cast<size_t>(RTCSessionDescription::SdpType::Answer) == 2, "RTCSessionDescription::SdpType::Answer is not 2 as expected");
static_assert(static_cast<size_t>(RTCSessionDescription::SdpType::Rollback) == 3, "RTCSessionDescription::SdpType::Rollback 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<RTCSessionDescription::SdpType> {
static JSString* arrayJSValue(ExecState* state, JSDOMGlobalObject*, RTCSessionDescription::SdpType value) { return jsStringWithCache(state, value); }
};
template<> Optional<RTCSessionDescription::SdpType> parse<RTCSessionDescription::SdpType>(ExecState& state, JSValue value)
{
auto stringValue = value.toWTFString(&state);
if (stringValue == "offer")
return RTCSessionDescription::SdpType::Offer;
if (stringValue == "pranswer")
return RTCSessionDescription::SdpType::Pranswer;
if (stringValue == "answer")
return RTCSessionDescription::SdpType::Answer;
if (stringValue == "rollback")
return RTCSessionDescription::SdpType::Rollback;
return Nullopt;
}
template<> RTCSessionDescription::SdpType convert<RTCSessionDescription::SdpType>(ExecState& state, JSValue value)
{
VM& vm = state.vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
auto result = parse<RTCSessionDescription::SdpType>(state, value);
if (UNLIKELY(!result)) {
throwTypeError(&state, throwScope);
return { };
}
return result.value();
}
template<> inline const char* expectedEnumerationValues<RTCSessionDescription::SdpType>()
{
return "\"offer\", \"pranswer\", \"answer\", \"rollback\"";
}
// Attributes
JSC::EncodedJSValue jsRTCSessionDescriptionType(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsRTCSessionDescriptionSdp(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsRTCSessionDescriptionConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSRTCSessionDescriptionConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
class JSRTCSessionDescriptionPrototype : public JSC::JSNonFinalObject {
public:
typedef JSC::JSNonFinalObject Base;
static JSRTCSessionDescriptionPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
{
JSRTCSessionDescriptionPrototype* ptr = new (NotNull, JSC::allocateCell<JSRTCSessionDescriptionPrototype>(vm.heap)) JSRTCSessionDescriptionPrototype(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:
JSRTCSessionDescriptionPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
: JSC::JSNonFinalObject(vm, structure)
{
}
void finishCreation(JSC::VM&);
};
typedef JSDOMConstructor<JSRTCSessionDescription> JSRTCSessionDescriptionConstructor;
template<> EncodedJSValue JSC_HOST_CALL JSRTCSessionDescriptionConstructor::construct(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
auto* castedThis = jsCast<JSRTCSessionDescriptionConstructor*>(state->callee());
ASSERT(castedThis);
if (UNLIKELY(state->argumentCount() < 1))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
ExceptionCode ec = 0;
auto dictionary = Dictionary(state, state->uncheckedArgument(0));
auto object = RTCSessionDescription::create(WTFMove(dictionary), ec);
if (UNLIKELY(ec)) {
setDOMException(state, throwScope, ec);
return JSValue::encode(JSValue());
}
return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));
}
template<> JSValue JSRTCSessionDescriptionConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
{
UNUSED_PARAM(vm);
return globalObject.functionPrototype();
}
template<> void JSRTCSessionDescriptionConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
{
putDirect(vm, vm.propertyNames->prototype, JSRTCSessionDescription::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("RTCSessionDescription"))), ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum);
}
template<> const ClassInfo JSRTCSessionDescriptionConstructor::s_info = { "RTCSessionDescription", &Base::s_info, 0, CREATE_METHOD_TABLE(JSRTCSessionDescriptionConstructor) };
/* Hash table for prototype */
static const HashTableValue JSRTCSessionDescriptionPrototypeTableValues[] =
{
{ "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCSessionDescriptionConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRTCSessionDescriptionConstructor) } },
{ "type", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCSessionDescriptionType), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "sdp", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCSessionDescriptionSdp), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
};
const ClassInfo JSRTCSessionDescriptionPrototype::s_info = { "RTCSessionDescriptionPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSRTCSessionDescriptionPrototype) };
void JSRTCSessionDescriptionPrototype::finishCreation(VM& vm)
{
Base::finishCreation(vm);
reifyStaticProperties(vm, JSRTCSessionDescriptionPrototypeTableValues, *this);
}
const ClassInfo JSRTCSessionDescription::s_info = { "RTCSessionDescription", &Base::s_info, 0, CREATE_METHOD_TABLE(JSRTCSessionDescription) };
JSRTCSessionDescription::JSRTCSessionDescription(Structure* structure, JSDOMGlobalObject& globalObject, Ref<RTCSessionDescription>&& impl)
: JSDOMWrapper<RTCSessionDescription>(structure, globalObject, WTFMove(impl))
{
}
JSObject* JSRTCSessionDescription::createPrototype(VM& vm, JSGlobalObject* globalObject)
{
return JSRTCSessionDescriptionPrototype::create(vm, globalObject, JSRTCSessionDescriptionPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
JSObject* JSRTCSessionDescription::prototype(VM& vm, JSGlobalObject* globalObject)
{
return getDOMPrototype<JSRTCSessionDescription>(vm, globalObject);
}
void JSRTCSessionDescription::destroy(JSC::JSCell* cell)
{
JSRTCSessionDescription* thisObject = static_cast<JSRTCSessionDescription*>(cell);
thisObject->JSRTCSessionDescription::~JSRTCSessionDescription();
}
EncodedJSValue jsRTCSessionDescriptionType(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<JSRTCSessionDescription*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "RTCSessionDescription", "type");
}
auto& impl = castedThis->wrapped();
JSValue result = jsStringWithCache(state, impl.type());
return JSValue::encode(result);
}
EncodedJSValue jsRTCSessionDescriptionSdp(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<JSRTCSessionDescription*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "RTCSessionDescription", "sdp");
}
auto& impl = castedThis->wrapped();
JSValue result = jsStringWithCache(state, impl.sdp());
return JSValue::encode(result);
}
EncodedJSValue jsRTCSessionDescriptionConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSRTCSessionDescriptionPrototype* domObject = jsDynamicCast<JSRTCSessionDescriptionPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!domObject))
return throwVMTypeError(state, throwScope);
return JSValue::encode(JSRTCSessionDescription::getConstructor(state->vm(), domObject->globalObject()));
}
bool setJSRTCSessionDescriptionConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSValue value = JSValue::decode(encodedValue);
JSRTCSessionDescriptionPrototype* domObject = jsDynamicCast<JSRTCSessionDescriptionPrototype*>(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 JSRTCSessionDescription::getConstructor(VM& vm, const JSGlobalObject* globalObject)
{
return getDOMConstructor<JSRTCSessionDescriptionConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
}
bool JSRTCSessionDescriptionOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
{
UNUSED_PARAM(handle);
UNUSED_PARAM(visitor);
return false;
}
void JSRTCSessionDescriptionOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
{
auto* jsRTCSessionDescription = jsCast<JSRTCSessionDescription*>(handle.slot()->asCell());
auto& world = *static_cast<DOMWrapperWorld*>(context);
uncacheWrapper(world, &jsRTCSessionDescription->wrapped(), jsRTCSessionDescription);
}
#if ENABLE(BINDING_INTEGRITY)
#if PLATFORM(WIN)
#pragma warning(disable: 4483)
extern "C" { extern void (*const __identifier("??_7RTCSessionDescription@WebCore@@6B@")[])(); }
#else
extern "C" { extern void* _ZTVN7WebCore21RTCSessionDescriptionE[]; }
#endif
#endif
JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<RTCSessionDescription>&& impl)
{
#if ENABLE(BINDING_INTEGRITY)
void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
#if PLATFORM(WIN)
void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7RTCSessionDescription@WebCore@@6B@"));
#else
void* expectedVTablePointer = &_ZTVN7WebCore21RTCSessionDescriptionE[2];
#if COMPILER(CLANG)
// If this fails RTCSessionDescription does not have a vtable, so you need to add the
// ImplementationLacksVTable attribute to the interface definition
static_assert(__is_polymorphic(RTCSessionDescription), "RTCSessionDescription is not polymorphic");
#endif
#endif
// If you hit this assertion you either have a use after free bug, or
// RTCSessionDescription has subclasses. If RTCSessionDescription has subclasses that get passed
// to toJS() we currently require RTCSessionDescription you to opt out of binding hardening
// by adding the SkipVTableValidation attribute to the interface IDL definition
RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
#endif
return createWrapper<RTCSessionDescription>(globalObject, WTFMove(impl));
}
JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, RTCSessionDescription& impl)
{
return wrap(state, globalObject, impl);
}
RTCSessionDescription* JSRTCSessionDescription::toWrapped(JSC::JSValue value)
{
if (auto* wrapper = jsDynamicCast<JSRTCSessionDescription*>(value))
return &wrapper->wrapped();
return nullptr;
}
}
#endif // ENABLE(WEB_RTC)