| 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(MEDIA_STREAM) |
| 24 | |
| 25 | #include "JSMediaDeviceInfo.h" |
| 26 | |
| 27 | #include "JSDOMAttribute.h" |
| 28 | #include "JSDOMBinding.h" |
| 29 | #include "JSDOMConstructorNotConstructable.h" |
| 30 | #include "JSDOMConvertStrings.h" |
| 31 | #include "JSDOMExceptionHandling.h" |
| 32 | #include "JSDOMOperation.h" |
| 33 | #include "JSDOMWrapperCache.h" |
| 34 | #include "ScriptExecutionContext.h" |
| 35 | #include <JavaScriptCore/FunctionPrototype.h> |
| 36 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 37 | #include <JavaScriptCore/JSCInlines.h> |
| 38 | #include <JavaScriptCore/JSString.h> |
| 39 | #include <JavaScriptCore/ObjectConstructor.h> |
| 40 | #include <wtf/GetPtr.h> |
| 41 | #include <wtf/PointerPreparations.h> |
| 42 | #include <wtf/URL.h> |
| 43 | |
| 44 | |
| 45 | namespace WebCore { |
| 46 | using namespace JSC; |
| 47 | |
| 48 | String convertEnumerationToString(MediaDeviceInfo::Kind enumerationValue) |
| 49 | { |
| 50 | static const NeverDestroyed<String> values[] = { |
| 51 | MAKE_STATIC_STRING_IMPL("audioinput" ), |
| 52 | MAKE_STATIC_STRING_IMPL("audiooutput" ), |
| 53 | MAKE_STATIC_STRING_IMPL("videoinput" ), |
| 54 | }; |
| 55 | static_assert(static_cast<size_t>(MediaDeviceInfo::Kind::Audioinput) == 0, "MediaDeviceInfo::Kind::Audioinput is not 0 as expected" ); |
| 56 | static_assert(static_cast<size_t>(MediaDeviceInfo::Kind::Audiooutput) == 1, "MediaDeviceInfo::Kind::Audiooutput is not 1 as expected" ); |
| 57 | static_assert(static_cast<size_t>(MediaDeviceInfo::Kind::Videoinput) == 2, "MediaDeviceInfo::Kind::Videoinput is not 2 as expected" ); |
| 58 | ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values)); |
| 59 | return values[static_cast<size_t>(enumerationValue)]; |
| 60 | } |
| 61 | |
| 62 | template<> JSString* convertEnumerationToJS(ExecState& state, MediaDeviceInfo::Kind enumerationValue) |
| 63 | { |
| 64 | return jsStringWithCache(&state, convertEnumerationToString(enumerationValue)); |
| 65 | } |
| 66 | |
| 67 | template<> Optional<MediaDeviceInfo::Kind> parseEnumeration<MediaDeviceInfo::Kind>(ExecState& state, JSValue value) |
| 68 | { |
| 69 | auto stringValue = value.toWTFString(&state); |
| 70 | if (stringValue == "audioinput" ) |
| 71 | return MediaDeviceInfo::Kind::Audioinput; |
| 72 | if (stringValue == "audiooutput" ) |
| 73 | return MediaDeviceInfo::Kind::Audiooutput; |
| 74 | if (stringValue == "videoinput" ) |
| 75 | return MediaDeviceInfo::Kind::Videoinput; |
| 76 | return WTF::nullopt; |
| 77 | } |
| 78 | |
| 79 | template<> const char* expectedEnumerationValues<MediaDeviceInfo::Kind>() |
| 80 | { |
| 81 | return "\"audioinput\", \"audiooutput\", \"videoinput\"" ; |
| 82 | } |
| 83 | |
| 84 | // Functions |
| 85 | |
| 86 | JSC::EncodedJSValue JSC_HOST_CALL jsMediaDeviceInfoPrototypeFunctionToJSON(JSC::ExecState*); |
| 87 | |
| 88 | // Attributes |
| 89 | |
| 90 | JSC::EncodedJSValue jsMediaDeviceInfoConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 91 | bool setJSMediaDeviceInfoConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 92 | JSC::EncodedJSValue jsMediaDeviceInfoDeviceId(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 93 | JSC::EncodedJSValue jsMediaDeviceInfoKind(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 94 | JSC::EncodedJSValue jsMediaDeviceInfoLabel(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 95 | JSC::EncodedJSValue jsMediaDeviceInfoGroupId(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 96 | |
| 97 | class JSMediaDeviceInfoPrototype : public JSC::JSNonFinalObject { |
| 98 | public: |
| 99 | using Base = JSC::JSNonFinalObject; |
| 100 | static JSMediaDeviceInfoPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 101 | { |
| 102 | JSMediaDeviceInfoPrototype* ptr = new (NotNull, JSC::allocateCell<JSMediaDeviceInfoPrototype>(vm.heap)) JSMediaDeviceInfoPrototype(vm, globalObject, structure); |
| 103 | ptr->finishCreation(vm); |
| 104 | return ptr; |
| 105 | } |
| 106 | |
| 107 | DECLARE_INFO; |
| 108 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 109 | { |
| 110 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 111 | } |
| 112 | |
| 113 | private: |
| 114 | JSMediaDeviceInfoPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 115 | : JSC::JSNonFinalObject(vm, structure) |
| 116 | { |
| 117 | } |
| 118 | |
| 119 | void finishCreation(JSC::VM&); |
| 120 | }; |
| 121 | |
| 122 | using JSMediaDeviceInfoConstructor = JSDOMConstructorNotConstructable<JSMediaDeviceInfo>; |
| 123 | |
| 124 | template<> JSValue JSMediaDeviceInfoConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 125 | { |
| 126 | UNUSED_PARAM(vm); |
| 127 | return globalObject.functionPrototype(); |
| 128 | } |
| 129 | |
| 130 | template<> void JSMediaDeviceInfoConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 131 | { |
| 132 | putDirect(vm, vm.propertyNames->prototype, JSMediaDeviceInfo::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 133 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("MediaDeviceInfo"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 134 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 135 | } |
| 136 | |
| 137 | template<> const ClassInfo JSMediaDeviceInfoConstructor::s_info = { "MediaDeviceInfo" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMediaDeviceInfoConstructor) }; |
| 138 | |
| 139 | /* Hash table for prototype */ |
| 140 | |
| 141 | static const HashTableValue JSMediaDeviceInfoPrototypeTableValues[] = |
| 142 | { |
| 143 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaDeviceInfoConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaDeviceInfoConstructor) } }, |
| 144 | { "deviceId" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaDeviceInfoDeviceId), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 145 | { "kind" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaDeviceInfoKind), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 146 | { "label" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaDeviceInfoLabel), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 147 | { "groupId" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaDeviceInfoGroupId), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 148 | { "toJSON" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMediaDeviceInfoPrototypeFunctionToJSON), (intptr_t) (0) } }, |
| 149 | }; |
| 150 | |
| 151 | const ClassInfo JSMediaDeviceInfoPrototype::s_info = { "MediaDeviceInfoPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMediaDeviceInfoPrototype) }; |
| 152 | |
| 153 | void JSMediaDeviceInfoPrototype::finishCreation(VM& vm) |
| 154 | { |
| 155 | Base::finishCreation(vm); |
| 156 | reifyStaticProperties(vm, JSMediaDeviceInfo::info(), JSMediaDeviceInfoPrototypeTableValues, *this); |
| 157 | } |
| 158 | |
| 159 | const ClassInfo JSMediaDeviceInfo::s_info = { "MediaDeviceInfo" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMediaDeviceInfo) }; |
| 160 | |
| 161 | JSMediaDeviceInfo::JSMediaDeviceInfo(Structure* structure, JSDOMGlobalObject& globalObject, Ref<MediaDeviceInfo>&& impl) |
| 162 | : JSDOMWrapper<MediaDeviceInfo>(structure, globalObject, WTFMove(impl)) |
| 163 | { |
| 164 | } |
| 165 | |
| 166 | void JSMediaDeviceInfo::finishCreation(VM& vm) |
| 167 | { |
| 168 | Base::finishCreation(vm); |
| 169 | ASSERT(inherits(vm, info())); |
| 170 | |
| 171 | } |
| 172 | |
| 173 | JSObject* JSMediaDeviceInfo::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 174 | { |
| 175 | return JSMediaDeviceInfoPrototype::create(vm, &globalObject, JSMediaDeviceInfoPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
| 176 | } |
| 177 | |
| 178 | JSObject* JSMediaDeviceInfo::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 179 | { |
| 180 | return getDOMPrototype<JSMediaDeviceInfo>(vm, globalObject); |
| 181 | } |
| 182 | |
| 183 | JSValue JSMediaDeviceInfo::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 184 | { |
| 185 | return getDOMConstructor<JSMediaDeviceInfoConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 186 | } |
| 187 | |
| 188 | void JSMediaDeviceInfo::destroy(JSC::JSCell* cell) |
| 189 | { |
| 190 | JSMediaDeviceInfo* thisObject = static_cast<JSMediaDeviceInfo*>(cell); |
| 191 | thisObject->JSMediaDeviceInfo::~JSMediaDeviceInfo(); |
| 192 | } |
| 193 | |
| 194 | template<> inline JSMediaDeviceInfo* IDLAttribute<JSMediaDeviceInfo>::cast(ExecState& state, EncodedJSValue thisValue) |
| 195 | { |
| 196 | return jsDynamicCast<JSMediaDeviceInfo*>(state.vm(), JSValue::decode(thisValue)); |
| 197 | } |
| 198 | |
| 199 | template<> inline JSMediaDeviceInfo* IDLOperation<JSMediaDeviceInfo>::cast(ExecState& state) |
| 200 | { |
| 201 | return jsDynamicCast<JSMediaDeviceInfo*>(state.vm(), state.thisValue()); |
| 202 | } |
| 203 | |
| 204 | EncodedJSValue jsMediaDeviceInfoConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 205 | { |
| 206 | VM& vm = state->vm(); |
| 207 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 208 | auto* prototype = jsDynamicCast<JSMediaDeviceInfoPrototype*>(vm, JSValue::decode(thisValue)); |
| 209 | if (UNLIKELY(!prototype)) |
| 210 | return throwVMTypeError(state, throwScope); |
| 211 | return JSValue::encode(JSMediaDeviceInfo::getConstructor(state->vm(), prototype->globalObject())); |
| 212 | } |
| 213 | |
| 214 | bool setJSMediaDeviceInfoConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 215 | { |
| 216 | VM& vm = state->vm(); |
| 217 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 218 | auto* prototype = jsDynamicCast<JSMediaDeviceInfoPrototype*>(vm, JSValue::decode(thisValue)); |
| 219 | if (UNLIKELY(!prototype)) { |
| 220 | throwVMTypeError(state, throwScope); |
| 221 | return false; |
| 222 | } |
| 223 | // Shadowing a built-in constructor |
| 224 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 225 | } |
| 226 | |
| 227 | static inline JSValue jsMediaDeviceInfoDeviceIdGetter(ExecState& state, JSMediaDeviceInfo& thisObject, ThrowScope& throwScope) |
| 228 | { |
| 229 | UNUSED_PARAM(throwScope); |
| 230 | UNUSED_PARAM(state); |
| 231 | auto& impl = thisObject.wrapped(); |
| 232 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.deviceId()); |
| 233 | return result; |
| 234 | } |
| 235 | |
| 236 | EncodedJSValue jsMediaDeviceInfoDeviceId(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 237 | { |
| 238 | return IDLAttribute<JSMediaDeviceInfo>::get<jsMediaDeviceInfoDeviceIdGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "deviceId" ); |
| 239 | } |
| 240 | |
| 241 | static inline JSValue jsMediaDeviceInfoKindGetter(ExecState& state, JSMediaDeviceInfo& thisObject, ThrowScope& throwScope) |
| 242 | { |
| 243 | UNUSED_PARAM(throwScope); |
| 244 | UNUSED_PARAM(state); |
| 245 | auto& impl = thisObject.wrapped(); |
| 246 | JSValue result = toJS<IDLEnumeration<MediaDeviceInfo::Kind>>(state, throwScope, impl.kind()); |
| 247 | return result; |
| 248 | } |
| 249 | |
| 250 | EncodedJSValue jsMediaDeviceInfoKind(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 251 | { |
| 252 | return IDLAttribute<JSMediaDeviceInfo>::get<jsMediaDeviceInfoKindGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "kind" ); |
| 253 | } |
| 254 | |
| 255 | static inline JSValue jsMediaDeviceInfoLabelGetter(ExecState& state, JSMediaDeviceInfo& thisObject, ThrowScope& throwScope) |
| 256 | { |
| 257 | UNUSED_PARAM(throwScope); |
| 258 | UNUSED_PARAM(state); |
| 259 | auto& impl = thisObject.wrapped(); |
| 260 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.label()); |
| 261 | return result; |
| 262 | } |
| 263 | |
| 264 | EncodedJSValue jsMediaDeviceInfoLabel(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 265 | { |
| 266 | return IDLAttribute<JSMediaDeviceInfo>::get<jsMediaDeviceInfoLabelGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "label" ); |
| 267 | } |
| 268 | |
| 269 | static inline JSValue jsMediaDeviceInfoGroupIdGetter(ExecState& state, JSMediaDeviceInfo& thisObject, ThrowScope& throwScope) |
| 270 | { |
| 271 | UNUSED_PARAM(throwScope); |
| 272 | UNUSED_PARAM(state); |
| 273 | auto& impl = thisObject.wrapped(); |
| 274 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.groupId()); |
| 275 | return result; |
| 276 | } |
| 277 | |
| 278 | EncodedJSValue jsMediaDeviceInfoGroupId(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 279 | { |
| 280 | return IDLAttribute<JSMediaDeviceInfo>::get<jsMediaDeviceInfoGroupIdGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "groupId" ); |
| 281 | } |
| 282 | |
| 283 | JSC::JSObject* JSMediaDeviceInfo::serialize(ExecState& state, JSMediaDeviceInfo& thisObject, JSDOMGlobalObject& globalObject, ThrowScope& throwScope) |
| 284 | { |
| 285 | auto& vm = state.vm(); |
| 286 | auto* result = constructEmptyObject(&state, globalObject.objectPrototype()); |
| 287 | |
| 288 | auto deviceIdValue = jsMediaDeviceInfoDeviceIdGetter(state, thisObject, throwScope); |
| 289 | throwScope.assertNoException(); |
| 290 | result->putDirect(vm, Identifier::fromString(&vm, "deviceId" ), deviceIdValue); |
| 291 | |
| 292 | auto kindValue = jsMediaDeviceInfoKindGetter(state, thisObject, throwScope); |
| 293 | throwScope.assertNoException(); |
| 294 | result->putDirect(vm, Identifier::fromString(&vm, "kind" ), kindValue); |
| 295 | |
| 296 | auto labelValue = jsMediaDeviceInfoLabelGetter(state, thisObject, throwScope); |
| 297 | throwScope.assertNoException(); |
| 298 | result->putDirect(vm, Identifier::fromString(&vm, "label" ), labelValue); |
| 299 | |
| 300 | auto groupIdValue = jsMediaDeviceInfoGroupIdGetter(state, thisObject, throwScope); |
| 301 | throwScope.assertNoException(); |
| 302 | result->putDirect(vm, Identifier::fromString(&vm, "groupId" ), groupIdValue); |
| 303 | |
| 304 | return result; |
| 305 | } |
| 306 | |
| 307 | static inline EncodedJSValue jsMediaDeviceInfoPrototypeFunctionToJSONBody(ExecState* state, JSMediaDeviceInfo* thisObject, JSC::ThrowScope& throwScope) |
| 308 | { |
| 309 | return JSValue::encode(JSMediaDeviceInfo::serialize(*state, *thisObject, *thisObject->globalObject(), throwScope)); |
| 310 | } |
| 311 | |
| 312 | EncodedJSValue JSC_HOST_CALL jsMediaDeviceInfoPrototypeFunctionToJSON(ExecState* state) |
| 313 | { |
| 314 | return IDLOperation<JSMediaDeviceInfo>::call<jsMediaDeviceInfoPrototypeFunctionToJSONBody>(*state, "toJSON" ); |
| 315 | } |
| 316 | |
| 317 | void JSMediaDeviceInfo::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 318 | { |
| 319 | auto* thisObject = jsCast<JSMediaDeviceInfo*>(cell); |
| 320 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 321 | if (thisObject->scriptExecutionContext()) |
| 322 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 323 | Base::heapSnapshot(cell, builder); |
| 324 | } |
| 325 | |
| 326 | bool JSMediaDeviceInfoOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
| 327 | { |
| 328 | UNUSED_PARAM(handle); |
| 329 | UNUSED_PARAM(visitor); |
| 330 | UNUSED_PARAM(reason); |
| 331 | return false; |
| 332 | } |
| 333 | |
| 334 | void JSMediaDeviceInfoOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 335 | { |
| 336 | auto* jsMediaDeviceInfo = static_cast<JSMediaDeviceInfo*>(handle.slot()->asCell()); |
| 337 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 338 | uncacheWrapper(world, &jsMediaDeviceInfo->wrapped(), jsMediaDeviceInfo); |
| 339 | } |
| 340 | |
| 341 | #if ENABLE(BINDING_INTEGRITY) |
| 342 | #if PLATFORM(WIN) |
| 343 | #pragma warning(disable: 4483) |
| 344 | extern "C" { extern void (*const __identifier("??_7MediaDeviceInfo@WebCore@@6B@" )[])(); } |
| 345 | #else |
| 346 | extern "C" { extern void* _ZTVN7WebCore15MediaDeviceInfoE[]; } |
| 347 | #endif |
| 348 | #endif |
| 349 | |
| 350 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<MediaDeviceInfo>&& impl) |
| 351 | { |
| 352 | |
| 353 | #if ENABLE(BINDING_INTEGRITY) |
| 354 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
| 355 | #if PLATFORM(WIN) |
| 356 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7MediaDeviceInfo@WebCore@@6B@" )); |
| 357 | #else |
| 358 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore15MediaDeviceInfoE[2]); |
| 359 | #endif |
| 360 | |
| 361 | // If this fails MediaDeviceInfo does not have a vtable, so you need to add the |
| 362 | // ImplementationLacksVTable attribute to the interface definition |
| 363 | static_assert(std::is_polymorphic<MediaDeviceInfo>::value, "MediaDeviceInfo is not polymorphic" ); |
| 364 | |
| 365 | // If you hit this assertion you either have a use after free bug, or |
| 366 | // MediaDeviceInfo has subclasses. If MediaDeviceInfo has subclasses that get passed |
| 367 | // to toJS() we currently require MediaDeviceInfo you to opt out of binding hardening |
| 368 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
| 369 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
| 370 | #endif |
| 371 | return createWrapper<MediaDeviceInfo>(globalObject, WTFMove(impl)); |
| 372 | } |
| 373 | |
| 374 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, MediaDeviceInfo& impl) |
| 375 | { |
| 376 | return wrap(state, globalObject, impl); |
| 377 | } |
| 378 | |
| 379 | MediaDeviceInfo* JSMediaDeviceInfo::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 380 | { |
| 381 | if (auto* wrapper = jsDynamicCast<JSMediaDeviceInfo*>(vm, value)) |
| 382 | return &wrapper->wrapped(); |
| 383 | return nullptr; |
| 384 | } |
| 385 | |
| 386 | } |
| 387 | |
| 388 | #endif // ENABLE(MEDIA_STREAM) |
| 389 | |