Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM DecoderDoctorNotification.webidl BY Codegen.py - DO NOT EDIT */
#include <type_traits>
#include "AtomList.h"
#include "DecoderDoctorNotificationBinding.h"
#include "MainThreadUtils.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/PrimitiveConversions.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<DecoderDoctorNotificationType>::Values[7] = {
"cannot-play"_ns,
"platform-decoder-not-found"_ns,
"can-play-but-some-missing-decoders"_ns,
"cannot-initialize-pulseaudio"_ns,
"unsupported-libavcodec"_ns,
"decode-error"_ns,
"decode-warning"_ns,
};
} // namespace binding_detail
bool
ToJSValue(JSContext* aCx, DecoderDoctorNotificationType aArgument, JS::MutableHandle<JS::Value> aValue)
{
MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(binding_detail::EnumStrings<DecoderDoctorNotificationType>::Values));
JSString* resultStr =
JS_NewStringCopyN(aCx, binding_detail::EnumStrings<DecoderDoctorNotificationType>::Values[uint32_t(aArgument)].BeginReading(),
binding_detail::EnumStrings<DecoderDoctorNotificationType>::Values[uint32_t(aArgument)].Length());
if (!resultStr) {
return false;
}
aValue.setString(resultStr);
return true;
}
namespace binding_detail {
const nsLiteralCString EnumStrings<DecoderDoctorReportType>::Values[9] = {
"mediawidevinenowmf"_ns,
"mediawmfneeded"_ns,
"mediaplatformdecodernotfound"_ns,
"mediacannotplaynodecoders"_ns,
"medianodecoders"_ns,
"mediacannotinitializepulseaudio"_ns,
"mediaunsupportedlibavcodec"_ns,
"mediadecodeerror"_ns,
"mediadecodewarning"_ns,
};
} // namespace binding_detail
bool
ToJSValue(JSContext* aCx, DecoderDoctorReportType aArgument, JS::MutableHandle<JS::Value> aValue)
{
MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(binding_detail::EnumStrings<DecoderDoctorReportType>::Values));
JSString* resultStr =
JS_NewStringCopyN(aCx, binding_detail::EnumStrings<DecoderDoctorReportType>::Values[uint32_t(aArgument)].BeginReading(),
binding_detail::EnumStrings<DecoderDoctorReportType>::Values[uint32_t(aArgument)].Length());
if (!resultStr) {
return false;
}
aValue.setString(resultStr);
return true;
}
DecoderDoctorNotification::DecoderDoctorNotification()
{
// Safe to pass a null context if we pass a null value
Init();
}
bool
DecoderDoctorNotification::InitIds(JSContext* cx, DecoderDoctorNotificationAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->type_id.init(cx, "type") ||
!atomsCache->resourceURL_id.init(cx, "resourceURL") ||
!atomsCache->isSolved_id.init(cx, "isSolved") ||
!atomsCache->formats_id.init(cx, "formats") ||
!atomsCache->docURL_id.init(cx, "docURL") ||
!atomsCache->decoderDoctorReportId_id.init(cx, "decoderDoctorReportId") ||
!atomsCache->decodeIssue_id.init(cx, "decodeIssue")) {
return false;
}
return true;
}
bool
DecoderDoctorNotification::Init(const char* sourceDescription, bool passedToJSImpl)
{
return true;
}
bool
DecoderDoctorNotification::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
DecoderDoctorNotificationAtoms* atomsCache = GetAtomCache<DecoderDoctorNotificationAtoms>(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));
if (mDecodeIssue.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mDecodeIssue.InternalValue();
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->decodeIssue_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);
nsString const & currentValue = mDecoderDoctorReportId;
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->decoderDoctorReportId_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
if (mDocURL.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mDocURL.InternalValue();
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->docURL_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mFormats.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mFormats.InternalValue();
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->formats_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);
bool const & currentValue = mIsSolved;
temp.setBoolean(currentValue);
if (!JS_DefinePropertyById(cx, obj, atomsCache->isSolved_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
if (mResourceURL.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsString const & currentValue = mResourceURL.InternalValue();
if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->resourceURL_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);
DecoderDoctorNotificationType const & currentValue = mType;
if (!ToJSValue(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->type_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
return true;
}
bool
DecoderDoctorNotification::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
DecoderDoctorNotification::TraceDictionary(JSTracer* trc)
{
}
DecoderDoctorNotification&
DecoderDoctorNotification::operator=(const DecoderDoctorNotification& aOther)
{
DictionaryBase::operator=(aOther);
mDecodeIssue.Reset();
if (aOther.mDecodeIssue.WasPassed()) {
mDecodeIssue.Construct(aOther.mDecodeIssue.Value());
}
mDecoderDoctorReportId = aOther.mDecoderDoctorReportId;
mDocURL.Reset();
if (aOther.mDocURL.WasPassed()) {
mDocURL.Construct(aOther.mDocURL.Value());
}
mFormats.Reset();
if (aOther.mFormats.WasPassed()) {
mFormats.Construct(aOther.mFormats.Value());
}
mIsSolved = aOther.mIsSolved;
mResourceURL.Reset();
if (aOther.mResourceURL.WasPassed()) {
mResourceURL.Construct(aOther.mResourceURL.Value());
}
mType = aOther.mType;
return *this;
}
} // namespace dom
} // namespace mozilla