/* THIS FILE IS AUTOGENERATED FROM Glean.webidl BY Codegen.py - DO NOT EDIT */
#ifndef DOM_GLEANBINDING_H_
#define DOM_GLEANBINDING_H_
#include "GleanMetricsBinding.h"
#include "js/CallAndConstruct.h"
#include "js/RootingAPI.h"
#include "js/TypeDecls.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/FakeString.h"
#include "mozilla/dom/Nullable.h"
#include "mozilla/dom/PrototypeList.h"
#include "mozilla/dom/UnionMember.h"
namespace mozilla {
namespace dom {
struct NativePropertyHooks;
class ProtoAndIfaceCache;
} // namespace dom
namespace glean {
class Category;
class Glean;
class GleanLabeled;
} // namespace glean
} // namespace mozilla
namespace mozilla::dom {
class BooleanOrUnsignedLongLongOrUTF8StringOrGleanDistributionData : public AllUnionBase
{
enum TypeOrUninit
{
eUninitialized,
eBoolean,
eUnsignedLongLong,
eUTF8String,
eGleanDistributionData
};
public:
enum class Type
{
eBoolean = TypeOrUninit::eBoolean,
eUnsignedLongLong = TypeOrUninit::eUnsignedLongLong,
eUTF8String = TypeOrUninit::eUTF8String,
eGleanDistributionData = TypeOrUninit::eGleanDistributionData
};
private:
union Value
{
UnionMember<bool > mBoolean;
UnionMember<uint64_t > mUnsignedLongLong;
UnionMember<binding_detail::FakeString<char> > mUTF8String;
UnionMember<binding_detail::FastGleanDistributionData > mGleanDistributionData;
};
TypeOrUninit mType;
Value mValue;
BooleanOrUnsignedLongLongOrUTF8StringOrGleanDistributionData(const BooleanOrUnsignedLongLongOrUTF8StringOrGleanDistributionData&) = delete;
BooleanOrUnsignedLongLongOrUTF8StringOrGleanDistributionData& operator=(const BooleanOrUnsignedLongLongOrUTF8StringOrGleanDistributionData&) = delete;
public:
explicit inline BooleanOrUnsignedLongLongOrUTF8StringOrGleanDistributionData()
: mType(eUninitialized)
{
}
inline ~BooleanOrUnsignedLongLongOrUTF8StringOrGleanDistributionData()
{
Uninit();
}
[[nodiscard]] inline bool&
RawSetAsBoolean()
{
if (mType == eBoolean) {
return mValue.mBoolean.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eBoolean;
return mValue.mBoolean.SetValue();
}
[[nodiscard]] inline bool&
SetAsBoolean()
{
if (mType == eBoolean) {
return mValue.mBoolean.Value();
}
Uninit();
mType = eBoolean;
return mValue.mBoolean.SetValue();
}
inline bool
IsBoolean() const
{
return mType == eBoolean;
}
inline bool&
GetAsBoolean()
{
MOZ_RELEASE_ASSERT(IsBoolean(), "Wrong type!");
return mValue.mBoolean.Value();
}
inline bool
GetAsBoolean() const
{
MOZ_RELEASE_ASSERT(IsBoolean(), "Wrong type!");
return mValue.mBoolean.Value();
}
[[nodiscard]] inline uint64_t&
RawSetAsUnsignedLongLong()
{
if (mType == eUnsignedLongLong) {
return mValue.mUnsignedLongLong.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eUnsignedLongLong;
return mValue.mUnsignedLongLong.SetValue();
}
[[nodiscard]] inline uint64_t&
SetAsUnsignedLongLong()
{
if (mType == eUnsignedLongLong) {
return mValue.mUnsignedLongLong.Value();
}
Uninit();
mType = eUnsignedLongLong;
return mValue.mUnsignedLongLong.SetValue();
}
inline bool
IsUnsignedLongLong() const
{
return mType == eUnsignedLongLong;
}
inline uint64_t&
GetAsUnsignedLongLong()
{
MOZ_RELEASE_ASSERT(IsUnsignedLongLong(), "Wrong type!");
return mValue.mUnsignedLongLong.Value();
}
inline uint64_t
GetAsUnsignedLongLong() const
{
MOZ_RELEASE_ASSERT(IsUnsignedLongLong(), "Wrong type!");
return mValue.mUnsignedLongLong.Value();
}
[[nodiscard]] inline binding_detail::FakeString<char>&
RawSetAsUTF8String()
{
if (mType == eUTF8String) {
return mValue.mUTF8String.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eUTF8String;
return mValue.mUTF8String.SetValue();
}
[[nodiscard]] inline binding_detail::FakeString<char>&
SetAsUTF8String()
{
if (mType == eUTF8String) {
return mValue.mUTF8String.Value();
}
Uninit();
mType = eUTF8String;
return mValue.mUTF8String.SetValue();
}
template <int N>
inline void
SetStringLiteral(const nsCString::char_type (&aData)[N])
{
RawSetAsUTF8String().AssignLiteral(aData);
}
inline bool
IsUTF8String() const
{
return mType == eUTF8String;
}
inline binding_detail::FakeString<char>&
GetAsUTF8String()
{
MOZ_RELEASE_ASSERT(IsUTF8String(), "Wrong type!");
return mValue.mUTF8String.Value();
}
inline const nsACString&
GetAsUTF8String() const
{
MOZ_RELEASE_ASSERT(IsUTF8String(), "Wrong type!");
return mValue.mUTF8String.Value();
}
[[nodiscard]] inline binding_detail::FastGleanDistributionData&
RawSetAsGleanDistributionData()
{
if (mType == eGleanDistributionData) {
return mValue.mGleanDistributionData.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eGleanDistributionData;
return mValue.mGleanDistributionData.SetValue();
}
[[nodiscard]] inline binding_detail::FastGleanDistributionData&
SetAsGleanDistributionData()
{
if (mType == eGleanDistributionData) {
return mValue.mGleanDistributionData.Value();
}
Uninit();
mType = eGleanDistributionData;
return mValue.mGleanDistributionData.SetValue();
}
inline bool
IsGleanDistributionData() const
{
return mType == eGleanDistributionData;
}
inline binding_detail::FastGleanDistributionData&
GetAsGleanDistributionData()
{
MOZ_RELEASE_ASSERT(IsGleanDistributionData(), "Wrong type!");
return mValue.mGleanDistributionData.Value();
}
inline const GleanDistributionData&
GetAsGleanDistributionData() const
{
MOZ_RELEASE_ASSERT(IsGleanDistributionData(), "Wrong type!");
return mValue.mGleanDistributionData.Value();
}
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> value, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> value, const char* sourceDescription = "Value", bool passedToJSImpl = false);
inline void
Uninit()
{
switch (mType) {
case eUninitialized: {
break;
}
case eBoolean: {
DestroyBoolean();
break;
}
case eUnsignedLongLong: {
DestroyUnsignedLongLong();
break;
}
case eUTF8String: {
DestroyUTF8String();
break;
}
case eGleanDistributionData: {
DestroyGleanDistributionData();
break;
}
}
}
bool
ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
private:
bool
TrySetToBoolean(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyBoolean()
{
MOZ_RELEASE_ASSERT(IsBoolean(), "Wrong type!");
mValue.mBoolean.Destroy();
mType = eUninitialized;
}
bool
TrySetToUnsignedLongLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyUnsignedLongLong()
{
MOZ_RELEASE_ASSERT(IsUnsignedLongLong(), "Wrong type!");
mValue.mUnsignedLongLong.Destroy();
mType = eUninitialized;
}
bool
TrySetToUTF8String(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyUTF8String()
{
MOZ_RELEASE_ASSERT(IsUTF8String(), "Wrong type!");
mValue.mUTF8String.Destroy();
mType = eUninitialized;
}
bool
TrySetToGleanDistributionData(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToGleanDistributionData(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyGleanDistributionData()
{
MOZ_RELEASE_ASSERT(IsGleanDistributionData(), "Wrong type!");
mValue.mGleanDistributionData.Destroy();
mType = eUninitialized;
}
};
class OwningBooleanOrUnsignedLongLongOrUTF8StringOrGleanDistributionData : public AllOwningUnionBase
{
enum TypeOrUninit
{
eUninitialized,
eBoolean,
eUnsignedLongLong,
eUTF8String,
eGleanDistributionData
};
public:
enum class Type
{
eBoolean = TypeOrUninit::eBoolean,
eUnsignedLongLong = TypeOrUninit::eUnsignedLongLong,
eUTF8String = TypeOrUninit::eUTF8String,
eGleanDistributionData = TypeOrUninit::eGleanDistributionData
};
private:
union Value
{
UnionMember<bool > mBoolean;
UnionMember<uint64_t > mUnsignedLongLong;
UnionMember<nsCString > mUTF8String;
UnionMember<GleanDistributionData > mGleanDistributionData;
};
TypeOrUninit mType;
Value mValue;
OwningBooleanOrUnsignedLongLongOrUTF8StringOrGleanDistributionData(const OwningBooleanOrUnsignedLongLongOrUTF8StringOrGleanDistributionData&) = delete;
OwningBooleanOrUnsignedLongLongOrUTF8StringOrGleanDistributionData& operator=(const OwningBooleanOrUnsignedLongLongOrUTF8StringOrGleanDistributionData&) = delete;
public:
explicit inline OwningBooleanOrUnsignedLongLongOrUTF8StringOrGleanDistributionData()
: mType(eUninitialized)
{
}
OwningBooleanOrUnsignedLongLongOrUTF8StringOrGleanDistributionData(OwningBooleanOrUnsignedLongLongOrUTF8StringOrGleanDistributionData&& aOther);
inline ~OwningBooleanOrUnsignedLongLongOrUTF8StringOrGleanDistributionData()
{
Uninit();
}
[[nodiscard]] bool&
RawSetAsBoolean();
[[nodiscard]] bool&
SetAsBoolean();
inline bool
IsBoolean() const
{
return mType == eBoolean;
}
inline bool&
GetAsBoolean()
{
MOZ_RELEASE_ASSERT(IsBoolean(), "Wrong type!");
return mValue.mBoolean.Value();
}
inline bool const &
GetAsBoolean() const
{
MOZ_RELEASE_ASSERT(IsBoolean(), "Wrong type!");
return mValue.mBoolean.Value();
}
[[nodiscard]] uint64_t&
RawSetAsUnsignedLongLong();
[[nodiscard]] uint64_t&
SetAsUnsignedLongLong();
inline bool
IsUnsignedLongLong() const
{
return mType == eUnsignedLongLong;
}
inline uint64_t&
GetAsUnsignedLongLong()
{
MOZ_RELEASE_ASSERT(IsUnsignedLongLong(), "Wrong type!");
return mValue.mUnsignedLongLong.Value();
}
inline uint64_t const &
GetAsUnsignedLongLong() const
{
MOZ_RELEASE_ASSERT(IsUnsignedLongLong(), "Wrong type!");
return mValue.mUnsignedLongLong.Value();
}
[[nodiscard]] nsCString&
RawSetAsUTF8String();
[[nodiscard]] nsCString&
SetAsUTF8String();
template <int N>
inline void
SetStringLiteral(const nsCString::char_type (&aData)[N])
{
RawSetAsUTF8String().AssignLiteral(aData);
}
inline bool
IsUTF8String() const
{
return mType == eUTF8String;
}
inline nsCString&
GetAsUTF8String()
{
MOZ_RELEASE_ASSERT(IsUTF8String(), "Wrong type!");
return mValue.mUTF8String.Value();
}
inline nsCString const &
GetAsUTF8String() const
{
MOZ_RELEASE_ASSERT(IsUTF8String(), "Wrong type!");
return mValue.mUTF8String.Value();
}
[[nodiscard]] GleanDistributionData&
RawSetAsGleanDistributionData();
[[nodiscard]] GleanDistributionData&
SetAsGleanDistributionData();
inline bool
IsGleanDistributionData() const
{
return mType == eGleanDistributionData;
}
inline GleanDistributionData&
GetAsGleanDistributionData()
{
MOZ_RELEASE_ASSERT(IsGleanDistributionData(), "Wrong type!");
return mValue.mGleanDistributionData.Value();
}
inline GleanDistributionData const &
GetAsGleanDistributionData() const
{
MOZ_RELEASE_ASSERT(IsGleanDistributionData(), "Wrong type!");
return mValue.mGleanDistributionData.Value();
}
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> value, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> value, const char* sourceDescription = "Value", bool passedToJSImpl = false);
void
Uninit();
bool
ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
OwningBooleanOrUnsignedLongLongOrUTF8StringOrGleanDistributionData&
operator=(OwningBooleanOrUnsignedLongLongOrUTF8StringOrGleanDistributionData&& aOther);
inline Type
GetType() const
{
MOZ_RELEASE_ASSERT(mType != eUninitialized);
return static_cast<Type>(mType);
}
private:
bool
TrySetToBoolean(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyBoolean();
bool
TrySetToUnsignedLongLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyUnsignedLongLong();
bool
TrySetToUTF8String(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyUTF8String();
bool
TrySetToGleanDistributionData(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToGleanDistributionData(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyGleanDistributionData();
};
namespace GleanCategory_Binding {
typedef mozilla::glean::Category NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
bool
Wrap(JSContext* aCx, mozilla::glean::Category* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
template <class T>
inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
{
JS::Rooted<JSObject*> reflector(aCx);
return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
}
void
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, DefineInterfaceProperty aDefineOnGlobal);
JS::Handle<JSObject*>
GetConstructorObjectHandle(JSContext* aCx);
inline bool CreateAndDefineOnGlobal(JSContext* aCx)
{
// Get the interface or namespace object for this class. This will
// create the object as needed and always define the properties for
// it on the global. The caller should make sure the interface or
// namespace is exposed on the global before calling this.
return GetPerInterfaceObjectHandle(aCx, constructors::id::GleanCategory,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace GleanCategory_Binding
namespace GleanImpl_Binding {
typedef mozilla::glean::Glean NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
bool
Wrap(JSContext* aCx, mozilla::glean::Glean* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
template <class T>
inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
{
JS::Rooted<JSObject*> reflector(aCx);
return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
}
void
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, DefineInterfaceProperty aDefineOnGlobal);
JS::Handle<JSObject*>
GetConstructorObjectHandle(JSContext* aCx);
inline bool CreateAndDefineOnGlobal(JSContext* aCx)
{
// Get the interface or namespace object for this class. This will
// create the object as needed and always define the properties for
// it on the global. The caller should make sure the interface or
// namespace is exposed on the global before calling this.
return GetPerInterfaceObjectHandle(aCx, constructors::id::GleanImpl,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace GleanImpl_Binding
namespace GleanLabeled_Binding {
typedef mozilla::glean::GleanLabeled NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
bool
Wrap(JSContext* aCx, mozilla::glean::GleanLabeled* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
template <class T>
inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
{
JS::Rooted<JSObject*> reflector(aCx);
return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
}
void
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, DefineInterfaceProperty aDefineOnGlobal);
JS::Handle<JSObject*>
GetConstructorObjectHandle(JSContext* aCx);
inline bool CreateAndDefineOnGlobal(JSContext* aCx)
{
// Get the interface or namespace object for this class. This will
// create the object as needed and always define the properties for
// it on the global. The caller should make sure the interface or
// namespace is exposed on the global before calling this.
return GetPerInterfaceObjectHandle(aCx, constructors::id::GleanLabeled,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace GleanLabeled_Binding
} // namespace mozilla::dom
#endif // DOM_GLEANBINDING_H_