Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM MediaKeysRequestStatus.webidl BY Codegen.py - DO NOT EDIT */
#include <type_traits>
#include "AtomList.h"
#include "MainThreadUtils.h"
#include "MediaKeysRequestStatusBinding.h"
#include "js/CallAndConstruct.h"
#include "js/Exception.h"
#include "js/MapAndSet.h"
#include "js/Object.h"
#include "js/PropertyAndElement.h"
#include "js/PropertyDescriptor.h"
#include "js/experimental/JitInfo.h"
#include "jsapi.h"
#include "mozilla/OwningNonNull.h"
#include "mozilla/dom/BindingCallContext.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/NonRefcountedDOMObject.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/SimpleGlobalObject.h"
namespace mozilla {
namespace dom {
namespace binding_detail {}; // Just to make sure it's known as a namespace
using namespace mozilla::dom::binding_detail;
namespace binding_detail {
const nsLiteralCString EnumStrings<MediaKeySystemStatus>::Values[6] = {
"available"_ns,
"api-disabled"_ns,
"cdm-disabled"_ns,
"cdm-not-supported"_ns,
"cdm-not-installed"_ns,
"cdm-created"_ns,
};
} // namespace binding_detail
bool
ToJSValue(JSContext* aCx, MediaKeySystemStatus aArgument, JS::MutableHandle<JS::Value> aValue)
{
MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(binding_detail::EnumStrings<MediaKeySystemStatus>::Values));
JSString* resultStr =
JS_NewStringCopyN(aCx, binding_detail::EnumStrings<MediaKeySystemStatus>::Values[uint32_t(aArgument)].BeginReading(),
binding_detail::EnumStrings<MediaKeySystemStatus>::Values[uint32_t(aArgument)].Length());
if (!resultStr) {
return false;
}
aValue.setString(resultStr);
return true;
}
RequestMediaKeySystemAccessNotification::RequestMediaKeySystemAccessNotification()
{
// Safe to pass a null context if we pass a null value
Init();
}
bool
RequestMediaKeySystemAccessNotification::InitIds(JSContext* cx, RequestMediaKeySystemAccessNotificationAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->status_id.init(cx, "status") ||
!atomsCache->keySystem_id.init(cx, "keySystem")) {
return false;
}
return true;
}
bool
RequestMediaKeySystemAccessNotification::Init(const char* sourceDescription, bool passedToJSImpl)
{
return true;
}
bool
RequestMediaKeySystemAccessNotification::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
RequestMediaKeySystemAccessNotificationAtoms* atomsCache = GetAtomCache<RequestMediaKeySystemAccessNotificationAtoms>(cx);
if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
!InitIds(cx, atomsCache)) {
return false;
}
JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
if (!obj) {
return false;
}
rval.set(JS::ObjectValue(*obj));
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mKeySystem;
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->keySystem_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
MediaKeySystemStatus const & currentValue = mStatus;
if (!ToJSValue(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->status_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
return true;
}
bool
RequestMediaKeySystemAccessNotification::ToJSON(nsAString& aJSON) const
{
AutoJSAPI jsapi;
jsapi.Init();
JSContext *cx = jsapi.cx();
// It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
// because we'll only be creating objects, in ways that have no
// side-effects, followed by a call to JS::ToJSONMaybeSafely,
// which likewise guarantees no side-effects for the sorts of
// things we will pass it.
JSObject* scope = UnprivilegedJunkScopeOrWorkerGlobal(fallible);
if (!scope) {
JS_ReportOutOfMemory(cx);
return false;
}
JSAutoRealm ar(cx, scope);
JS::Rooted<JS::Value> val(cx);
if (!ToObjectInternal(cx, &val)) {
return false;
}
JS::Rooted<JSObject*> obj(cx, &val.toObject());
return StringifyToJSON(cx, obj, aJSON);
}
void
RequestMediaKeySystemAccessNotification::TraceDictionary(JSTracer* trc)
{
}
RequestMediaKeySystemAccessNotification&
RequestMediaKeySystemAccessNotification::operator=(const RequestMediaKeySystemAccessNotification& aOther)
{
DictionaryBase::operator=(aOther);
mKeySystem = aOther.mKeySystem;
mStatus = aOther.mStatus;
return *this;
}
} // namespace dom
} // namespace mozilla