Generated file

Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM Nimbus.webidl BY Codegen.py - DO NOT EDIT */
#include <type_traits>
#include "AtomList.h"
#include "MainThreadUtils.h"
#include "NimbusBinding.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 "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::dom {
namespace binding_detail {}; // Just to make sure it's known as a namespace
using namespace mozilla::dom::binding_detail;
CachedNimbusExperimentBranch::CachedNimbusExperimentBranch()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
CachedNimbusExperimentBranch::InitIds(JSContext* cx, CachedNimbusExperimentBranchAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->slug_id.init(cx, "slug")) {
return false;
}
return true;
}
bool
CachedNimbusExperimentBranch::Init(BindingCallContext& cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
{
// Passing a null JSContext is OK only if we're initing from null,
// Since in that case we will not have to do any property gets
// Also evaluate isNullOrUndefined in order to avoid false-positive
// checkers by static analysis tools
MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
CachedNimbusExperimentBranchAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<CachedNimbusExperimentBranchAtoms>(cx);
if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
!InitIds(cx, atomsCache)) {
return false;
}
}
if (!IsConvertibleToDictionary(val)) {
return cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>(sourceDescription, "dictionary");
}
bool isNull = val.isNullOrUndefined();
// We only need these if !isNull, in which case we have |cx|.
Maybe<JS::Rooted<JSObject *> > object;
Maybe<JS::Rooted<JS::Value> > temp;
if (!isNull) {
MOZ_ASSERT(cx);
object.emplace(cx, &val.toObject());
temp.emplace(cx);
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->slug_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mSlug)) {
return false;
}
mIsAnyMemberPresent = true;
} else if (cx) {
// Don't error out if we have no cx. In that
// situation the caller is default-constructing us and we'll
// just assume they know what they're doing.
return cx.ThrowErrorMessage<MSG_MISSING_REQUIRED_DICTIONARY_MEMBER>("'slug' member of CachedNimbusExperimentBranch");
}
return true;
}
bool
CachedNimbusExperimentBranch::Init(JSContext* cx_, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
{
// We don't want to use sourceDescription for our context here;
// that's not really what it's formatted for.
BindingCallContext cx(cx_, nullptr);
return Init(cx, val, sourceDescription, passedToJSImpl);
}
bool
CachedNimbusExperimentBranch::Init(const nsAString& aJSON)
{
AutoJSAPI jsapi;
JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
if (!cleanGlobal) {
return false;
}
if (!jsapi.Init(cleanGlobal)) {
return false;
}
JSContext* cx = jsapi.cx();
JS::Rooted<JS::Value> json(cx);
bool ok = ParseJSON(cx, aJSON, &json);
NS_ENSURE_TRUE(ok, false);
return Init(cx, json);
}
bool
CachedNimbusExperimentBranch::Init(const nsACString& aJSON)
{
AutoJSAPI jsapi;
JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
if (!cleanGlobal) {
return false;
}
if (!jsapi.Init(cleanGlobal)) {
return false;
}
JSContext* cx = jsapi.cx();
JS::Rooted<JS::Value> json(cx);
bool ok = ParseJSON(cx, aJSON, &json);
NS_ENSURE_TRUE(ok, false);
return Init(cx, json);
}
void
CachedNimbusExperimentBranch::TraceDictionary(JSTracer* trc)
{
}
CachedNimbusExperimentBranch&
CachedNimbusExperimentBranch::operator=(const CachedNimbusExperimentBranch& aOther)
{
MaybeEmptyDictionaryBase::operator=(aOther);
mSlug = aOther.mSlug;
return *this;
}
CachedNimbusExperimentMetadata::CachedNimbusExperimentMetadata()
: mBranch(FastDictionaryInitializer())
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
CachedNimbusExperimentMetadata::InitIds(JSContext* cx, CachedNimbusExperimentMetadataAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->slug_id.init(cx, "slug") ||
!atomsCache->branch_id.init(cx, "branch")) {
return false;
}
return true;
}
bool
CachedNimbusExperimentMetadata::Init(BindingCallContext& cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
{
// Passing a null JSContext is OK only if we're initing from null,
// Since in that case we will not have to do any property gets
// Also evaluate isNullOrUndefined in order to avoid false-positive
// checkers by static analysis tools
MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
CachedNimbusExperimentMetadataAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<CachedNimbusExperimentMetadataAtoms>(cx);
if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
!InitIds(cx, atomsCache)) {
return false;
}
}
if (!IsConvertibleToDictionary(val)) {
return cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>(sourceDescription, "dictionary");
}
bool isNull = val.isNullOrUndefined();
// We only need these if !isNull, in which case we have |cx|.
Maybe<JS::Rooted<JSObject *> > object;
Maybe<JS::Rooted<JS::Value> > temp;
if (!isNull) {
MOZ_ASSERT(cx);
object.emplace(cx, &val.toObject());
temp.emplace(cx);
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->branch_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!mBranch.Init(cx, temp.ref(), "'branch' member of CachedNimbusExperimentMetadata", passedToJSImpl)) {
return false;
}
mIsAnyMemberPresent = true;
} else if (cx) {
// Don't error out if we have no cx. In that
// situation the caller is default-constructing us and we'll
// just assume they know what they're doing.
return cx.ThrowErrorMessage<MSG_MISSING_REQUIRED_DICTIONARY_MEMBER>("'branch' member of CachedNimbusExperimentMetadata");
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->slug_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mSlug)) {
return false;
}
mIsAnyMemberPresent = true;
} else if (cx) {
// Don't error out if we have no cx. In that
// situation the caller is default-constructing us and we'll
// just assume they know what they're doing.
return cx.ThrowErrorMessage<MSG_MISSING_REQUIRED_DICTIONARY_MEMBER>("'slug' member of CachedNimbusExperimentMetadata");
}
return true;
}
bool
CachedNimbusExperimentMetadata::Init(JSContext* cx_, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
{
// We don't want to use sourceDescription for our context here;
// that's not really what it's formatted for.
BindingCallContext cx(cx_, nullptr);
return Init(cx, val, sourceDescription, passedToJSImpl);
}
bool
CachedNimbusExperimentMetadata::Init(const nsAString& aJSON)
{
AutoJSAPI jsapi;
JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
if (!cleanGlobal) {
return false;
}
if (!jsapi.Init(cleanGlobal)) {
return false;
}
JSContext* cx = jsapi.cx();
JS::Rooted<JS::Value> json(cx);
bool ok = ParseJSON(cx, aJSON, &json);
NS_ENSURE_TRUE(ok, false);
return Init(cx, json);
}
bool
CachedNimbusExperimentMetadata::Init(const nsACString& aJSON)
{
AutoJSAPI jsapi;
JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
if (!cleanGlobal) {
return false;
}
if (!jsapi.Init(cleanGlobal)) {
return false;
}
JSContext* cx = jsapi.cx();
JS::Rooted<JS::Value> json(cx);
bool ok = ParseJSON(cx, aJSON, &json);
NS_ENSURE_TRUE(ok, false);
return Init(cx, json);
}
void
CachedNimbusExperimentMetadata::TraceDictionary(JSTracer* trc)
{
}
CachedNimbusExperimentMetadata&
CachedNimbusExperimentMetadata::operator=(const CachedNimbusExperimentMetadata& aOther)
{
MaybeEmptyDictionaryBase::operator=(aOther);
mBranch = aOther.mBranch;
mSlug = aOther.mSlug;
return *this;
}
} // namespace mozilla::dom