blob: c3fe98860b460f925b68f3b810b189b7680c15a2 [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(MEDIA_STREAM)
#include "JSMediaDevices.h"
#include "ExceptionCode.h"
#include "JSDOMBinding.h"
#include "JSDOMPromise.h"
#include "JSMediaTrackSupportedConstraints.h"
#include "MediaTrackSupportedConstraints.h"
#include "WebCoreJSClientData.h"
#include <runtime/Error.h>
#include <wtf/GetPtr.h>
using namespace JSC;
namespace WebCore {
// Functions
JSC::EncodedJSValue JSC_HOST_CALL jsMediaDevicesPrototypeFunctionGetSupportedConstraints(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsMediaDevicesPrototypeFunctionGetUserMedia(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsMediaDevicesPrototypeFunctionEnumerateDevices(JSC::ExecState*);
class JSMediaDevicesPrototype : public JSC::JSNonFinalObject {
public:
typedef JSC::JSNonFinalObject Base;
static JSMediaDevicesPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
{
JSMediaDevicesPrototype* ptr = new (NotNull, JSC::allocateCell<JSMediaDevicesPrototype>(vm.heap)) JSMediaDevicesPrototype(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:
JSMediaDevicesPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
: JSC::JSNonFinalObject(vm, structure)
{
}
void finishCreation(JSC::VM&);
};
/* Hash table for prototype */
static const HashTableValue JSMediaDevicesPrototypeTableValues[] =
{
{ "getSupportedConstraints", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsMediaDevicesPrototypeFunctionGetSupportedConstraints), (intptr_t) (0) } },
{ "getUserMedia", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsMediaDevicesPrototypeFunctionGetUserMedia), (intptr_t) (1) } },
{ "enumerateDevices", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsMediaDevicesPrototypeFunctionEnumerateDevices), (intptr_t) (0) } },
};
const ClassInfo JSMediaDevicesPrototype::s_info = { "MediaDevicesPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSMediaDevicesPrototype) };
void JSMediaDevicesPrototype::finishCreation(VM& vm)
{
Base::finishCreation(vm);
reifyStaticProperties(vm, JSMediaDevicesPrototypeTableValues, *this);
JSVMClientData& clientData = *static_cast<JSVMClientData*>(vm.clientData);
putDirect(vm, clientData.builtinNames().getUserMediaPrivateName(), JSFunction::create(vm, globalObject(), 0, String(), jsMediaDevicesPrototypeFunctionGetUserMedia), ReadOnly | DontEnum);
}
const ClassInfo JSMediaDevices::s_info = { "MediaDevices", &Base::s_info, 0, CREATE_METHOD_TABLE(JSMediaDevices) };
JSMediaDevices::JSMediaDevices(Structure* structure, JSDOMGlobalObject& globalObject, Ref<MediaDevices>&& impl)
: JSDOMWrapper<MediaDevices>(structure, globalObject, WTFMove(impl))
{
}
JSObject* JSMediaDevices::createPrototype(VM& vm, JSGlobalObject* globalObject)
{
return JSMediaDevicesPrototype::create(vm, globalObject, JSMediaDevicesPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
JSObject* JSMediaDevices::prototype(VM& vm, JSGlobalObject* globalObject)
{
return getDOMPrototype<JSMediaDevices>(vm, globalObject);
}
void JSMediaDevices::destroy(JSC::JSCell* cell)
{
JSMediaDevices* thisObject = static_cast<JSMediaDevices*>(cell);
thisObject->JSMediaDevices::~JSMediaDevices();
}
EncodedJSValue JSC_HOST_CALL jsMediaDevicesPrototypeFunctionGetSupportedConstraints(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSMediaDevices*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "MediaDevices", "getSupportedConstraints");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSMediaDevices::info());
auto& impl = castedThis->wrapped();
JSValue result = toJS(state, castedThis->globalObject(), impl.getSupportedConstraints());
return JSValue::encode(result);
}
EncodedJSValue JSC_HOST_CALL jsMediaDevicesPrototypeFunctionGetUserMedia(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSMediaDevices*>(thisValue);
if (UNLIKELY(!castedThis))
return createRejectedPromiseWithTypeError(*state, makeThisTypeErrorMessage("MediaDevices", "getUserMedia"));
ASSERT_GC_OBJECT_INHERITS(castedThis, JSMediaDevices::info());
return JSValue::encode(castedThis->getUserMedia(*state));
}
static EncodedJSValue jsMediaDevicesPrototypeFunctionEnumerateDevicesPromise(ExecState*, Ref<DeferredPromise>&&);
EncodedJSValue JSC_HOST_CALL jsMediaDevicesPrototypeFunctionEnumerateDevices(ExecState* state)
{
ASSERT(state);
return JSValue::encode(callPromiseFunction<jsMediaDevicesPrototypeFunctionEnumerateDevicesPromise, PromiseExecutionScope::WindowOnly>(*state));
}
static inline EncodedJSValue jsMediaDevicesPrototypeFunctionEnumerateDevicesPromise(ExecState* state, Ref<DeferredPromise>&& promise)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSMediaDevices*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "MediaDevices", "enumerateDevices");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSMediaDevices::info());
auto& impl = castedThis->wrapped();
ExceptionCode ec = 0;
impl.enumerateDevices(WTFMove(promise), ec);
setDOMException(state, throwScope, ec);
return JSValue::encode(jsUndefined());
}
bool JSMediaDevicesOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
{
UNUSED_PARAM(handle);
UNUSED_PARAM(visitor);
return false;
}
void JSMediaDevicesOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
{
auto* jsMediaDevices = jsCast<JSMediaDevices*>(handle.slot()->asCell());
auto& world = *static_cast<DOMWrapperWorld*>(context);
uncacheWrapper(world, &jsMediaDevices->wrapped(), jsMediaDevices);
}
#if ENABLE(BINDING_INTEGRITY)
#if PLATFORM(WIN)
#pragma warning(disable: 4483)
extern "C" { extern void (*const __identifier("??_7MediaDevices@WebCore@@6B@")[])(); }
#else
extern "C" { extern void* _ZTVN7WebCore12MediaDevicesE[]; }
#endif
#endif
JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<MediaDevices>&& impl)
{
#if ENABLE(BINDING_INTEGRITY)
void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
#if PLATFORM(WIN)
void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7MediaDevices@WebCore@@6B@"));
#else
void* expectedVTablePointer = &_ZTVN7WebCore12MediaDevicesE[2];
#if COMPILER(CLANG)
// If this fails MediaDevices does not have a vtable, so you need to add the
// ImplementationLacksVTable attribute to the interface definition
static_assert(__is_polymorphic(MediaDevices), "MediaDevices is not polymorphic");
#endif
#endif
// If you hit this assertion you either have a use after free bug, or
// MediaDevices has subclasses. If MediaDevices has subclasses that get passed
// to toJS() we currently require MediaDevices you to opt out of binding hardening
// by adding the SkipVTableValidation attribute to the interface IDL definition
RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
#endif
return createWrapper<MediaDevices>(globalObject, WTFMove(impl));
}
JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, MediaDevices& impl)
{
return wrap(state, globalObject, impl);
}
MediaDevices* JSMediaDevices::toWrapped(JSC::JSValue value)
{
if (auto* wrapper = jsDynamicCast<JSMediaDevices*>(value))
return &wrapper->wrapped();
return nullptr;
}
}
#endif // ENABLE(MEDIA_STREAM)