| /* |
| 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 "JSRTCConfiguration.h" |
| |
| #include "JSDOMBinding.h" |
| #include "JSDOMConvert.h" |
| #include "JSRTCIceServer.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*, RTCConfiguration::IceTransportPolicy); |
| |
| JSString* jsStringWithCache(ExecState* state, RTCConfiguration::IceTransportPolicy enumerationValue) |
| { |
| static NeverDestroyed<const String> values[] = { |
| ASCIILiteral("relay"), |
| ASCIILiteral("all"), |
| }; |
| static_assert(static_cast<size_t>(RTCConfiguration::IceTransportPolicy::Relay) == 0, "RTCConfiguration::IceTransportPolicy::Relay is not 0 as expected"); |
| static_assert(static_cast<size_t>(RTCConfiguration::IceTransportPolicy::All) == 1, "RTCConfiguration::IceTransportPolicy::All is not 1 as expected"); |
| ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values)); |
| return jsStringWithCache(state, values[static_cast<size_t>(enumerationValue)]); |
| } |
| |
| template<> struct JSValueTraits<RTCConfiguration::IceTransportPolicy> { |
| static JSString* arrayJSValue(ExecState* state, JSDOMGlobalObject*, RTCConfiguration::IceTransportPolicy value) { return jsStringWithCache(state, value); } |
| }; |
| |
| template<> Optional<RTCConfiguration::IceTransportPolicy> parse<RTCConfiguration::IceTransportPolicy>(ExecState& state, JSValue value) |
| { |
| auto stringValue = value.toWTFString(&state); |
| if (stringValue == "relay") |
| return RTCConfiguration::IceTransportPolicy::Relay; |
| if (stringValue == "all") |
| return RTCConfiguration::IceTransportPolicy::All; |
| return Nullopt; |
| } |
| |
| template<> RTCConfiguration::IceTransportPolicy convert<RTCConfiguration::IceTransportPolicy>(ExecState& state, JSValue value) |
| { |
| VM& vm = state.vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| auto result = parse<RTCConfiguration::IceTransportPolicy>(state, value); |
| if (UNLIKELY(!result)) { |
| throwTypeError(&state, throwScope); |
| return { }; |
| } |
| return result.value(); |
| } |
| |
| template<> inline const char* expectedEnumerationValues<RTCConfiguration::IceTransportPolicy>() |
| { |
| return "\"relay\", \"all\""; |
| } |
| |
| JSString* jsStringWithCache(ExecState*, RTCConfiguration::BundlePolicy); |
| |
| JSString* jsStringWithCache(ExecState* state, RTCConfiguration::BundlePolicy enumerationValue) |
| { |
| static NeverDestroyed<const String> values[] = { |
| ASCIILiteral("balanced"), |
| ASCIILiteral("max-compat"), |
| ASCIILiteral("max-bundle"), |
| }; |
| static_assert(static_cast<size_t>(RTCConfiguration::BundlePolicy::Balanced) == 0, "RTCConfiguration::BundlePolicy::Balanced is not 0 as expected"); |
| static_assert(static_cast<size_t>(RTCConfiguration::BundlePolicy::MaxCompat) == 1, "RTCConfiguration::BundlePolicy::MaxCompat is not 1 as expected"); |
| static_assert(static_cast<size_t>(RTCConfiguration::BundlePolicy::MaxBundle) == 2, "RTCConfiguration::BundlePolicy::MaxBundle is not 2 as expected"); |
| ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values)); |
| return jsStringWithCache(state, values[static_cast<size_t>(enumerationValue)]); |
| } |
| |
| template<> struct JSValueTraits<RTCConfiguration::BundlePolicy> { |
| static JSString* arrayJSValue(ExecState* state, JSDOMGlobalObject*, RTCConfiguration::BundlePolicy value) { return jsStringWithCache(state, value); } |
| }; |
| |
| template<> Optional<RTCConfiguration::BundlePolicy> parse<RTCConfiguration::BundlePolicy>(ExecState& state, JSValue value) |
| { |
| auto stringValue = value.toWTFString(&state); |
| if (stringValue == "balanced") |
| return RTCConfiguration::BundlePolicy::Balanced; |
| if (stringValue == "max-compat") |
| return RTCConfiguration::BundlePolicy::MaxCompat; |
| if (stringValue == "max-bundle") |
| return RTCConfiguration::BundlePolicy::MaxBundle; |
| return Nullopt; |
| } |
| |
| template<> RTCConfiguration::BundlePolicy convert<RTCConfiguration::BundlePolicy>(ExecState& state, JSValue value) |
| { |
| VM& vm = state.vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| auto result = parse<RTCConfiguration::BundlePolicy>(state, value); |
| if (UNLIKELY(!result)) { |
| throwTypeError(&state, throwScope); |
| return { }; |
| } |
| return result.value(); |
| } |
| |
| template<> inline const char* expectedEnumerationValues<RTCConfiguration::BundlePolicy>() |
| { |
| return "\"balanced\", \"max-compat\", \"max-bundle\""; |
| } |
| |
| // Attributes |
| |
| JSC::EncodedJSValue jsRTCConfigurationIceServers(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsRTCConfigurationIceTransportPolicy(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsRTCConfigurationBundlePolicy(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSRTCConfigurationConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| |
| class JSRTCConfigurationPrototype : public JSC::JSNonFinalObject { |
| public: |
| typedef JSC::JSNonFinalObject Base; |
| static JSRTCConfigurationPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) |
| { |
| JSRTCConfigurationPrototype* ptr = new (NotNull, JSC::allocateCell<JSRTCConfigurationPrototype>(vm.heap)) JSRTCConfigurationPrototype(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: |
| JSRTCConfigurationPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| : JSC::JSNonFinalObject(vm, structure) |
| { |
| } |
| |
| void finishCreation(JSC::VM&); |
| }; |
| |
| /* Hash table for prototype */ |
| |
| static const HashTableValue JSRTCConfigurationPrototypeTableValues[] = |
| { |
| { "iceServers", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCConfigurationIceServers), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "iceTransportPolicy", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCConfigurationIceTransportPolicy), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "bundlePolicy", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCConfigurationBundlePolicy), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| }; |
| |
| const ClassInfo JSRTCConfigurationPrototype::s_info = { "RTCConfigurationPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSRTCConfigurationPrototype) }; |
| |
| void JSRTCConfigurationPrototype::finishCreation(VM& vm) |
| { |
| Base::finishCreation(vm); |
| reifyStaticProperties(vm, JSRTCConfigurationPrototypeTableValues, *this); |
| } |
| |
| const ClassInfo JSRTCConfiguration::s_info = { "RTCConfiguration", &Base::s_info, 0, CREATE_METHOD_TABLE(JSRTCConfiguration) }; |
| |
| JSRTCConfiguration::JSRTCConfiguration(Structure* structure, JSDOMGlobalObject& globalObject, Ref<RTCConfiguration>&& impl) |
| : JSDOMWrapper<RTCConfiguration>(structure, globalObject, WTFMove(impl)) |
| { |
| } |
| |
| JSObject* JSRTCConfiguration::createPrototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return JSRTCConfigurationPrototype::create(vm, globalObject, JSRTCConfigurationPrototype::createStructure(vm, globalObject, globalObject->objectPrototype())); |
| } |
| |
| JSObject* JSRTCConfiguration::prototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return getDOMPrototype<JSRTCConfiguration>(vm, globalObject); |
| } |
| |
| void JSRTCConfiguration::destroy(JSC::JSCell* cell) |
| { |
| JSRTCConfiguration* thisObject = static_cast<JSRTCConfiguration*>(cell); |
| thisObject->JSRTCConfiguration::~JSRTCConfiguration(); |
| } |
| |
| EncodedJSValue jsRTCConfigurationIceServers(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<JSRTCConfiguration*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "RTCConfiguration", "iceServers"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsArray(state, castedThis->globalObject(), impl.iceServers()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsRTCConfigurationIceTransportPolicy(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<JSRTCConfiguration*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "RTCConfiguration", "iceTransportPolicy"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.iceTransportPolicy()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsRTCConfigurationBundlePolicy(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<JSRTCConfiguration*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "RTCConfiguration", "bundlePolicy"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.bundlePolicy()); |
| return JSValue::encode(result); |
| } |
| |
| |
| bool setJSRTCConfigurationConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSValue value = JSValue::decode(encodedValue); |
| JSRTCConfigurationPrototype* domObject = jsDynamicCast<JSRTCConfigurationPrototype*>(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 JSRTCConfigurationOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) |
| { |
| UNUSED_PARAM(handle); |
| UNUSED_PARAM(visitor); |
| return false; |
| } |
| |
| void JSRTCConfigurationOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| { |
| auto* jsRTCConfiguration = jsCast<JSRTCConfiguration*>(handle.slot()->asCell()); |
| auto& world = *static_cast<DOMWrapperWorld*>(context); |
| uncacheWrapper(world, &jsRTCConfiguration->wrapped(), jsRTCConfiguration); |
| } |
| |
| #if ENABLE(BINDING_INTEGRITY) |
| #if PLATFORM(WIN) |
| #pragma warning(disable: 4483) |
| extern "C" { extern void (*const __identifier("??_7RTCConfiguration@WebCore@@6B@")[])(); } |
| #else |
| extern "C" { extern void* _ZTVN7WebCore16RTCConfigurationE[]; } |
| #endif |
| #endif |
| |
| JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<RTCConfiguration>&& impl) |
| { |
| |
| #if ENABLE(BINDING_INTEGRITY) |
| void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
| #if PLATFORM(WIN) |
| void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7RTCConfiguration@WebCore@@6B@")); |
| #else |
| void* expectedVTablePointer = &_ZTVN7WebCore16RTCConfigurationE[2]; |
| #if COMPILER(CLANG) |
| // If this fails RTCConfiguration does not have a vtable, so you need to add the |
| // ImplementationLacksVTable attribute to the interface definition |
| static_assert(__is_polymorphic(RTCConfiguration), "RTCConfiguration is not polymorphic"); |
| #endif |
| #endif |
| // If you hit this assertion you either have a use after free bug, or |
| // RTCConfiguration has subclasses. If RTCConfiguration has subclasses that get passed |
| // to toJS() we currently require RTCConfiguration you to opt out of binding hardening |
| // by adding the SkipVTableValidation attribute to the interface IDL definition |
| RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
| #endif |
| return createWrapper<RTCConfiguration>(globalObject, WTFMove(impl)); |
| } |
| |
| JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, RTCConfiguration& impl) |
| { |
| return wrap(state, globalObject, impl); |
| } |
| |
| RTCConfiguration* JSRTCConfiguration::toWrapped(JSC::JSValue value) |
| { |
| if (auto* wrapper = jsDynamicCast<JSRTCConfiguration*>(value)) |
| return &wrapper->wrapped(); |
| return nullptr; |
| } |
| |
| } |
| |
| #endif // ENABLE(WEB_RTC) |