| 1 | /* |
| 2 | This file is part of the WebKit open source project. |
| 3 | This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
| 4 | |
| 5 | This library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Library General Public |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2 of the License, or (at your option) any later version. |
| 9 | |
| 10 | This library is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | Library General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Library General Public License |
| 16 | along with this library; see the file COPYING.LIB. If not, write to |
| 17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 | Boston, MA 02110-1301, USA. |
| 19 | */ |
| 20 | |
| 21 | #include "config.h" |
| 22 | |
| 23 | #if ENABLE(WEB_RTC) |
| 24 | |
| 25 | #include "JSRTCSessionDescription.h" |
| 26 | |
| 27 | #include "JSDOMAttribute.h" |
| 28 | #include "JSDOMBinding.h" |
| 29 | #include "JSDOMConstructor.h" |
| 30 | #include "JSDOMConvertInterface.h" |
| 31 | #include "JSDOMConvertStrings.h" |
| 32 | #include "JSDOMExceptionHandling.h" |
| 33 | #include "JSDOMGlobalObject.h" |
| 34 | #include "JSDOMOperation.h" |
| 35 | #include "JSDOMWrapperCache.h" |
| 36 | #include "ScriptExecutionContext.h" |
| 37 | #include <JavaScriptCore/FunctionPrototype.h> |
| 38 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 39 | #include <JavaScriptCore/JSCInlines.h> |
| 40 | #include <JavaScriptCore/JSString.h> |
| 41 | #include <JavaScriptCore/ObjectConstructor.h> |
| 42 | #include <wtf/GetPtr.h> |
| 43 | #include <wtf/PointerPreparations.h> |
| 44 | #include <wtf/URL.h> |
| 45 | |
| 46 | |
| 47 | namespace WebCore { |
| 48 | using namespace JSC; |
| 49 | |
| 50 | #if ENABLE(WEB_RTC) |
| 51 | |
| 52 | String convertEnumerationToString(RTCSdpType enumerationValue) |
| 53 | { |
| 54 | static const NeverDestroyed<String> values[] = { |
| 55 | MAKE_STATIC_STRING_IMPL("offer" ), |
| 56 | MAKE_STATIC_STRING_IMPL("pranswer" ), |
| 57 | MAKE_STATIC_STRING_IMPL("answer" ), |
| 58 | MAKE_STATIC_STRING_IMPL("rollback" ), |
| 59 | }; |
| 60 | static_assert(static_cast<size_t>(RTCSdpType::Offer) == 0, "RTCSdpType::Offer is not 0 as expected" ); |
| 61 | static_assert(static_cast<size_t>(RTCSdpType::Pranswer) == 1, "RTCSdpType::Pranswer is not 1 as expected" ); |
| 62 | static_assert(static_cast<size_t>(RTCSdpType::Answer) == 2, "RTCSdpType::Answer is not 2 as expected" ); |
| 63 | static_assert(static_cast<size_t>(RTCSdpType::Rollback) == 3, "RTCSdpType::Rollback is not 3 as expected" ); |
| 64 | ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values)); |
| 65 | return values[static_cast<size_t>(enumerationValue)]; |
| 66 | } |
| 67 | |
| 68 | template<> JSString* convertEnumerationToJS(ExecState& state, RTCSdpType enumerationValue) |
| 69 | { |
| 70 | return jsStringWithCache(&state, convertEnumerationToString(enumerationValue)); |
| 71 | } |
| 72 | |
| 73 | template<> Optional<RTCSdpType> parseEnumeration<RTCSdpType>(ExecState& state, JSValue value) |
| 74 | { |
| 75 | auto stringValue = value.toWTFString(&state); |
| 76 | if (stringValue == "offer" ) |
| 77 | return RTCSdpType::Offer; |
| 78 | if (stringValue == "pranswer" ) |
| 79 | return RTCSdpType::Pranswer; |
| 80 | if (stringValue == "answer" ) |
| 81 | return RTCSdpType::Answer; |
| 82 | if (stringValue == "rollback" ) |
| 83 | return RTCSdpType::Rollback; |
| 84 | return WTF::nullopt; |
| 85 | } |
| 86 | |
| 87 | template<> const char* expectedEnumerationValues<RTCSdpType>() |
| 88 | { |
| 89 | return "\"offer\", \"pranswer\", \"answer\", \"rollback\"" ; |
| 90 | } |
| 91 | |
| 92 | #endif |
| 93 | |
| 94 | #if ENABLE(WEB_RTC) |
| 95 | |
| 96 | template<> RTCSessionDescription::Init convertDictionary<RTCSessionDescription::Init>(ExecState& state, JSValue value) |
| 97 | { |
| 98 | VM& vm = state.vm(); |
| 99 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 100 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
| 101 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
| 102 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
| 103 | throwTypeError(&state, throwScope); |
| 104 | return { }; |
| 105 | } |
| 106 | RTCSessionDescription::Init result; |
| 107 | JSValue sdpValue; |
| 108 | if (isNullOrUndefined) |
| 109 | sdpValue = jsUndefined(); |
| 110 | else { |
| 111 | sdpValue = object->get(&state, Identifier::fromString(&state, "sdp" )); |
| 112 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 113 | } |
| 114 | if (!sdpValue.isUndefined()) { |
| 115 | result.sdp = convert<IDLDOMString>(state, sdpValue); |
| 116 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 117 | } else |
| 118 | result.sdp = emptyString(); |
| 119 | JSValue typeValue; |
| 120 | if (isNullOrUndefined) |
| 121 | typeValue = jsUndefined(); |
| 122 | else { |
| 123 | typeValue = object->get(&state, Identifier::fromString(&state, "type" )); |
| 124 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 125 | } |
| 126 | if (!typeValue.isUndefined()) { |
| 127 | result.type = convert<IDLEnumeration<RTCSdpType>>(state, typeValue); |
| 128 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 129 | } else { |
| 130 | throwRequiredMemberTypeError(state, throwScope, "type" , "RTCSessionDescriptionInit" , "RTCSdpType" ); |
| 131 | return { }; |
| 132 | } |
| 133 | return result; |
| 134 | } |
| 135 | |
| 136 | JSC::JSObject* convertDictionaryToJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const RTCSessionDescription::Init& dictionary) |
| 137 | { |
| 138 | auto& vm = state.vm(); |
| 139 | |
| 140 | auto result = constructEmptyObject(&state, globalObject.objectPrototype()); |
| 141 | |
| 142 | auto sdpValue = toJS<IDLDOMString>(state, dictionary.sdp); |
| 143 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "sdp" ), sdpValue); |
| 144 | auto typeValue = toJS<IDLEnumeration<RTCSdpType>>(state, dictionary.type); |
| 145 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "type" ), typeValue); |
| 146 | return result; |
| 147 | } |
| 148 | |
| 149 | #endif |
| 150 | |
| 151 | // Functions |
| 152 | |
| 153 | JSC::EncodedJSValue JSC_HOST_CALL jsRTCSessionDescriptionPrototypeFunctionToJSON(JSC::ExecState*); |
| 154 | |
| 155 | // Attributes |
| 156 | |
| 157 | JSC::EncodedJSValue jsRTCSessionDescriptionConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 158 | bool setJSRTCSessionDescriptionConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 159 | JSC::EncodedJSValue jsRTCSessionDescriptionType(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 160 | JSC::EncodedJSValue jsRTCSessionDescriptionSdp(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 161 | |
| 162 | class JSRTCSessionDescriptionPrototype : public JSC::JSNonFinalObject { |
| 163 | public: |
| 164 | using Base = JSC::JSNonFinalObject; |
| 165 | static JSRTCSessionDescriptionPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 166 | { |
| 167 | JSRTCSessionDescriptionPrototype* ptr = new (NotNull, JSC::allocateCell<JSRTCSessionDescriptionPrototype>(vm.heap)) JSRTCSessionDescriptionPrototype(vm, globalObject, structure); |
| 168 | ptr->finishCreation(vm); |
| 169 | return ptr; |
| 170 | } |
| 171 | |
| 172 | DECLARE_INFO; |
| 173 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 174 | { |
| 175 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 176 | } |
| 177 | |
| 178 | private: |
| 179 | JSRTCSessionDescriptionPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 180 | : JSC::JSNonFinalObject(vm, structure) |
| 181 | { |
| 182 | } |
| 183 | |
| 184 | void finishCreation(JSC::VM&); |
| 185 | }; |
| 186 | |
| 187 | using JSRTCSessionDescriptionConstructor = JSDOMConstructor<JSRTCSessionDescription>; |
| 188 | |
| 189 | template<> EncodedJSValue JSC_HOST_CALL JSRTCSessionDescriptionConstructor::construct(ExecState* state) |
| 190 | { |
| 191 | VM& vm = state->vm(); |
| 192 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 193 | UNUSED_PARAM(throwScope); |
| 194 | auto* castedThis = jsCast<JSRTCSessionDescriptionConstructor*>(state->jsCallee()); |
| 195 | ASSERT(castedThis); |
| 196 | if (UNLIKELY(state->argumentCount() < 1)) |
| 197 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 198 | auto descriptionInitDict = convert<IDLDictionary<RTCSessionDescription::Init>>(*state, state->uncheckedArgument(0)); |
| 199 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 200 | auto object = RTCSessionDescription::create(WTFMove(descriptionInitDict)); |
| 201 | return JSValue::encode(toJSNewlyCreated<IDLInterface<RTCSessionDescription>>(*state, *castedThis->globalObject(), WTFMove(object))); |
| 202 | } |
| 203 | |
| 204 | template<> JSValue JSRTCSessionDescriptionConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 205 | { |
| 206 | UNUSED_PARAM(vm); |
| 207 | return globalObject.functionPrototype(); |
| 208 | } |
| 209 | |
| 210 | template<> void JSRTCSessionDescriptionConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 211 | { |
| 212 | putDirect(vm, vm.propertyNames->prototype, JSRTCSessionDescription::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 213 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("RTCSessionDescription"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 214 | putDirect(vm, vm.propertyNames->length, jsNumber(1), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 215 | } |
| 216 | |
| 217 | template<> const ClassInfo JSRTCSessionDescriptionConstructor::s_info = { "RTCSessionDescription" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRTCSessionDescriptionConstructor) }; |
| 218 | |
| 219 | /* Hash table for prototype */ |
| 220 | |
| 221 | static const HashTableValue JSRTCSessionDescriptionPrototypeTableValues[] = |
| 222 | { |
| 223 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCSessionDescriptionConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRTCSessionDescriptionConstructor) } }, |
| 224 | { "type" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCSessionDescriptionType), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 225 | { "sdp" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCSessionDescriptionSdp), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 226 | { "toJSON" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRTCSessionDescriptionPrototypeFunctionToJSON), (intptr_t) (0) } }, |
| 227 | }; |
| 228 | |
| 229 | const ClassInfo JSRTCSessionDescriptionPrototype::s_info = { "RTCSessionDescriptionPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRTCSessionDescriptionPrototype) }; |
| 230 | |
| 231 | void JSRTCSessionDescriptionPrototype::finishCreation(VM& vm) |
| 232 | { |
| 233 | Base::finishCreation(vm); |
| 234 | reifyStaticProperties(vm, JSRTCSessionDescription::info(), JSRTCSessionDescriptionPrototypeTableValues, *this); |
| 235 | } |
| 236 | |
| 237 | const ClassInfo JSRTCSessionDescription::s_info = { "RTCSessionDescription" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRTCSessionDescription) }; |
| 238 | |
| 239 | JSRTCSessionDescription::JSRTCSessionDescription(Structure* structure, JSDOMGlobalObject& globalObject, Ref<RTCSessionDescription>&& impl) |
| 240 | : JSDOMWrapper<RTCSessionDescription>(structure, globalObject, WTFMove(impl)) |
| 241 | { |
| 242 | } |
| 243 | |
| 244 | void JSRTCSessionDescription::finishCreation(VM& vm) |
| 245 | { |
| 246 | Base::finishCreation(vm); |
| 247 | ASSERT(inherits(vm, info())); |
| 248 | |
| 249 | } |
| 250 | |
| 251 | JSObject* JSRTCSessionDescription::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 252 | { |
| 253 | return JSRTCSessionDescriptionPrototype::create(vm, &globalObject, JSRTCSessionDescriptionPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
| 254 | } |
| 255 | |
| 256 | JSObject* JSRTCSessionDescription::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 257 | { |
| 258 | return getDOMPrototype<JSRTCSessionDescription>(vm, globalObject); |
| 259 | } |
| 260 | |
| 261 | JSValue JSRTCSessionDescription::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 262 | { |
| 263 | return getDOMConstructor<JSRTCSessionDescriptionConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 264 | } |
| 265 | |
| 266 | void JSRTCSessionDescription::destroy(JSC::JSCell* cell) |
| 267 | { |
| 268 | JSRTCSessionDescription* thisObject = static_cast<JSRTCSessionDescription*>(cell); |
| 269 | thisObject->JSRTCSessionDescription::~JSRTCSessionDescription(); |
| 270 | } |
| 271 | |
| 272 | template<> inline JSRTCSessionDescription* IDLAttribute<JSRTCSessionDescription>::cast(ExecState& state, EncodedJSValue thisValue) |
| 273 | { |
| 274 | return jsDynamicCast<JSRTCSessionDescription*>(state.vm(), JSValue::decode(thisValue)); |
| 275 | } |
| 276 | |
| 277 | template<> inline JSRTCSessionDescription* IDLOperation<JSRTCSessionDescription>::cast(ExecState& state) |
| 278 | { |
| 279 | return jsDynamicCast<JSRTCSessionDescription*>(state.vm(), state.thisValue()); |
| 280 | } |
| 281 | |
| 282 | EncodedJSValue jsRTCSessionDescriptionConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 283 | { |
| 284 | VM& vm = state->vm(); |
| 285 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 286 | auto* prototype = jsDynamicCast<JSRTCSessionDescriptionPrototype*>(vm, JSValue::decode(thisValue)); |
| 287 | if (UNLIKELY(!prototype)) |
| 288 | return throwVMTypeError(state, throwScope); |
| 289 | return JSValue::encode(JSRTCSessionDescription::getConstructor(state->vm(), prototype->globalObject())); |
| 290 | } |
| 291 | |
| 292 | bool setJSRTCSessionDescriptionConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 293 | { |
| 294 | VM& vm = state->vm(); |
| 295 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 296 | auto* prototype = jsDynamicCast<JSRTCSessionDescriptionPrototype*>(vm, JSValue::decode(thisValue)); |
| 297 | if (UNLIKELY(!prototype)) { |
| 298 | throwVMTypeError(state, throwScope); |
| 299 | return false; |
| 300 | } |
| 301 | // Shadowing a built-in constructor |
| 302 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 303 | } |
| 304 | |
| 305 | static inline JSValue jsRTCSessionDescriptionTypeGetter(ExecState& state, JSRTCSessionDescription& thisObject, ThrowScope& throwScope) |
| 306 | { |
| 307 | UNUSED_PARAM(throwScope); |
| 308 | UNUSED_PARAM(state); |
| 309 | auto& impl = thisObject.wrapped(); |
| 310 | JSValue result = toJS<IDLEnumeration<RTCSdpType>>(state, throwScope, impl.type()); |
| 311 | return result; |
| 312 | } |
| 313 | |
| 314 | EncodedJSValue jsRTCSessionDescriptionType(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 315 | { |
| 316 | return IDLAttribute<JSRTCSessionDescription>::get<jsRTCSessionDescriptionTypeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "type" ); |
| 317 | } |
| 318 | |
| 319 | static inline JSValue jsRTCSessionDescriptionSdpGetter(ExecState& state, JSRTCSessionDescription& thisObject, ThrowScope& throwScope) |
| 320 | { |
| 321 | UNUSED_PARAM(throwScope); |
| 322 | UNUSED_PARAM(state); |
| 323 | auto& impl = thisObject.wrapped(); |
| 324 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.sdp()); |
| 325 | return result; |
| 326 | } |
| 327 | |
| 328 | EncodedJSValue jsRTCSessionDescriptionSdp(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 329 | { |
| 330 | return IDLAttribute<JSRTCSessionDescription>::get<jsRTCSessionDescriptionSdpGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "sdp" ); |
| 331 | } |
| 332 | |
| 333 | JSC::JSObject* JSRTCSessionDescription::serialize(ExecState& state, JSRTCSessionDescription& thisObject, JSDOMGlobalObject& globalObject, ThrowScope& throwScope) |
| 334 | { |
| 335 | auto& vm = state.vm(); |
| 336 | auto* result = constructEmptyObject(&state, globalObject.objectPrototype()); |
| 337 | |
| 338 | auto typeValue = jsRTCSessionDescriptionTypeGetter(state, thisObject, throwScope); |
| 339 | throwScope.assertNoException(); |
| 340 | result->putDirect(vm, Identifier::fromString(&vm, "type" ), typeValue); |
| 341 | |
| 342 | auto sdpValue = jsRTCSessionDescriptionSdpGetter(state, thisObject, throwScope); |
| 343 | throwScope.assertNoException(); |
| 344 | result->putDirect(vm, Identifier::fromString(&vm, "sdp" ), sdpValue); |
| 345 | |
| 346 | return result; |
| 347 | } |
| 348 | |
| 349 | static inline EncodedJSValue jsRTCSessionDescriptionPrototypeFunctionToJSONBody(ExecState* state, JSRTCSessionDescription* thisObject, JSC::ThrowScope& throwScope) |
| 350 | { |
| 351 | return JSValue::encode(JSRTCSessionDescription::serialize(*state, *thisObject, *thisObject->globalObject(), throwScope)); |
| 352 | } |
| 353 | |
| 354 | EncodedJSValue JSC_HOST_CALL jsRTCSessionDescriptionPrototypeFunctionToJSON(ExecState* state) |
| 355 | { |
| 356 | return IDLOperation<JSRTCSessionDescription>::call<jsRTCSessionDescriptionPrototypeFunctionToJSONBody>(*state, "toJSON" ); |
| 357 | } |
| 358 | |
| 359 | void JSRTCSessionDescription::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 360 | { |
| 361 | auto* thisObject = jsCast<JSRTCSessionDescription*>(cell); |
| 362 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 363 | if (thisObject->scriptExecutionContext()) |
| 364 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 365 | Base::heapSnapshot(cell, builder); |
| 366 | } |
| 367 | |
| 368 | bool JSRTCSessionDescriptionOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
| 369 | { |
| 370 | UNUSED_PARAM(handle); |
| 371 | UNUSED_PARAM(visitor); |
| 372 | UNUSED_PARAM(reason); |
| 373 | return false; |
| 374 | } |
| 375 | |
| 376 | void JSRTCSessionDescriptionOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 377 | { |
| 378 | auto* jsRTCSessionDescription = static_cast<JSRTCSessionDescription*>(handle.slot()->asCell()); |
| 379 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 380 | uncacheWrapper(world, &jsRTCSessionDescription->wrapped(), jsRTCSessionDescription); |
| 381 | } |
| 382 | |
| 383 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<RTCSessionDescription>&& impl) |
| 384 | { |
| 385 | // If you hit this failure the interface definition has the ImplementationLacksVTable |
| 386 | // attribute. You should remove that attribute. If the class has subclasses |
| 387 | // that may be passed through this toJS() function you should use the SkipVTableValidation |
| 388 | // attribute to RTCSessionDescription. |
| 389 | static_assert(!std::is_polymorphic<RTCSessionDescription>::value, "RTCSessionDescription is polymorphic but the IDL claims it is not" ); |
| 390 | return createWrapper<RTCSessionDescription>(globalObject, WTFMove(impl)); |
| 391 | } |
| 392 | |
| 393 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, RTCSessionDescription& impl) |
| 394 | { |
| 395 | return wrap(state, globalObject, impl); |
| 396 | } |
| 397 | |
| 398 | RTCSessionDescription* JSRTCSessionDescription::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 399 | { |
| 400 | if (auto* wrapper = jsDynamicCast<JSRTCSessionDescription*>(vm, value)) |
| 401 | return &wrapper->wrapped(); |
| 402 | return nullptr; |
| 403 | } |
| 404 | |
| 405 | } |
| 406 | |
| 407 | #endif // ENABLE(WEB_RTC) |
| 408 | |