Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM MLS.webidl BY Codegen.py - DO NOT EDIT */
#ifndef DOM_MLSBINDING_H_
#define DOM_MLSBINDING_H_
#include "js/CallAndConstruct.h"
#include "js/RootingAPI.h"
#include "js/TypeDecls.h"
#include "js/Value.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/EnumTypeTraits.h"
#include "mozilla/Span.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/FakeString.h"
#include "mozilla/dom/Nullable.h"
#include "mozilla/dom/PrototypeList.h"
#include "mozilla/dom/RootedDictionary.h"
#include "mozilla/dom/TypedArray.h"
#include "mozilla/dom/UnionMember.h"
namespace mozilla {
namespace dom {
class MLS;
struct MLSBytesAtoms;
struct MLSCommitOutput;
struct MLSCommitOutputAtoms;
struct MLSExporterOutputAtoms;
struct MLSGroupDetailsAtoms;
struct MLSGroupMember;
struct MLSGroupMemberAtoms;
class MLSGroupView;
struct MLSReceivedAtoms;
struct NativePropertyHooks;
class ProtoAndIfaceCache;
} // namespace dom
} // namespace mozilla
namespace mozilla {
namespace dom {
enum class MLSObjectType : uint8_t {
Group_epoch,
Group_identifier,
Group_info,
Client_identifier,
Credential_basic,
Key_package,
Proposal,
Commit_output,
Commit_processed,
Welcome,
Exporter_output,
Exporter_label,
Exporter_context,
Application_message_ciphertext,
Application_message_plaintext,
};
namespace binding_detail {
template <> struct EnumStrings<MLSObjectType> {
static constexpr nsLiteralCString Values[15] {
"group-epoch"_ns,
"group-identifier"_ns,
"group-info"_ns,
"client-identifier"_ns,
"credential-basic"_ns,
"key-package"_ns,
"proposal"_ns,
"commit-output"_ns,
"commit-processed"_ns,
"welcome"_ns,
"exporter-output"_ns,
"exporter-label"_ns,
"exporter-context"_ns,
"application-message-ciphertext"_ns,
"application-message-plaintext"_ns,
};
};
} // namespace binding_detail
bool
ToJSValue(JSContext* aCx, MLSObjectType aArgument, JS::MutableHandle<JS::Value> aValue);
struct MLSBytes : public DictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR Uint8Array mContent;
MOZ_INIT_OUTSIDE_CTOR MLSObjectType mType;
MLSBytes();
explicit inline MLSBytes(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
MLSBytes(MLSBytes&& aOther) = default;
private:
MLSBytes(const MLSBytes&) = delete;
MLSBytes& operator=(const MLSBytes&) = delete;
static bool
InitIds(JSContext* cx, MLSBytesAtoms* atomsCache);
public:
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
void
TraceDictionary(JSTracer* trc);
};
namespace binding_detail {
struct FastMLSBytes : public MLSBytes
{
inline FastMLSBytes()
: MLSBytes(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
struct MLSCommitOutput : public DictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR Optional<Uint8Array> mClientId;
MOZ_INIT_OUTSIDE_CTOR Uint8Array mCommit;
MOZ_INIT_OUTSIDE_CTOR Uint8Array mGroupId;
MOZ_INIT_OUTSIDE_CTOR Optional<Uint8Array> mGroupInfo;
MOZ_INIT_OUTSIDE_CTOR Optional<Uint8Array> mRatchetTree;
MOZ_INIT_OUTSIDE_CTOR MLSObjectType mType;
MOZ_INIT_OUTSIDE_CTOR Optional<Uint8Array> mWelcome;
MLSCommitOutput();
explicit inline MLSCommitOutput(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
MLSCommitOutput(MLSCommitOutput&& aOther) = default;
private:
MLSCommitOutput(const MLSCommitOutput&) = delete;
MLSCommitOutput& operator=(const MLSCommitOutput&) = delete;
static bool
InitIds(JSContext* cx, MLSCommitOutputAtoms* atomsCache);
public:
bool
Init(const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
void
TraceDictionary(JSTracer* trc);
};
namespace binding_detail {
struct FastMLSCommitOutput : public MLSCommitOutput
{
inline FastMLSCommitOutput()
: MLSCommitOutput(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
struct MLSExporterOutput : public DictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR Uint8Array mContext;
MOZ_INIT_OUTSIDE_CTOR Uint8Array mGroupEpoch;
MOZ_INIT_OUTSIDE_CTOR Uint8Array mGroupId;
MOZ_INIT_OUTSIDE_CTOR Uint8Array mLabel;
MOZ_INIT_OUTSIDE_CTOR Uint8Array mSecret;
MOZ_INIT_OUTSIDE_CTOR MLSObjectType mType;
MLSExporterOutput();
explicit inline MLSExporterOutput(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
MLSExporterOutput(MLSExporterOutput&& aOther) = default;
private:
MLSExporterOutput(const MLSExporterOutput&) = delete;
MLSExporterOutput& operator=(const MLSExporterOutput&) = delete;
static bool
InitIds(JSContext* cx, MLSExporterOutputAtoms* atomsCache);
public:
bool
Init(const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
void
TraceDictionary(JSTracer* trc);
};
namespace binding_detail {
struct FastMLSExporterOutput : public MLSExporterOutput
{
inline FastMLSExporterOutput()
: MLSExporterOutput(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
struct MLSGroupMember : public DictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR Uint8Array mClientId;
MOZ_INIT_OUTSIDE_CTOR Uint8Array mCredential;
MLSGroupMember();
explicit inline MLSGroupMember(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
MLSGroupMember(MLSGroupMember&& aOther) = default;
private:
MLSGroupMember(const MLSGroupMember&) = delete;
MLSGroupMember& operator=(const MLSGroupMember&) = delete;
static bool
InitIds(JSContext* cx, MLSGroupMemberAtoms* atomsCache);
public:
bool
Init(const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
void
TraceDictionary(JSTracer* trc);
};
namespace binding_detail {
struct FastMLSGroupMember : public MLSGroupMember
{
inline FastMLSGroupMember()
: MLSGroupMember(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
class MLSBytesOrUint8Array : public AllUnionBase,
public UnionWithTypedArraysBase
{
public:
using ApplyToTypedArrays = binding_detail::ApplyToTypedArraysHelper<MLSBytesOrUint8Array, true, Uint8Array>;
private:
enum TypeOrUninit
{
eUninitialized,
eMLSBytes,
eUint8Array
};
public:
enum class Type
{
eMLSBytes = TypeOrUninit::eMLSBytes,
eUint8Array = TypeOrUninit::eUint8Array
};
private:
union Value
{
UnionMember<RootedDictionary<binding_detail::FastMLSBytes> > mMLSBytes;
UnionMember<RootedSpiderMonkeyInterface<Uint8Array> > mUint8Array;
};
TypeOrUninit mType;
Value mValue;
MLSBytesOrUint8Array(const MLSBytesOrUint8Array&) = delete;
MLSBytesOrUint8Array& operator=(const MLSBytesOrUint8Array&) = delete;
public:
explicit inline MLSBytesOrUint8Array()
: mType(eUninitialized)
{
}
inline ~MLSBytesOrUint8Array()
{
Uninit();
}
[[nodiscard]] inline RootedDictionary<binding_detail::FastMLSBytes>&
RawSetAsMLSBytes(JSContext* cx)
{
if (mType == eMLSBytes) {
return mValue.mMLSBytes.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eMLSBytes;
return mValue.mMLSBytes.SetValue(cx);
}
[[nodiscard]] inline RootedDictionary<binding_detail::FastMLSBytes>&
SetAsMLSBytes(JSContext* cx)
{
if (mType == eMLSBytes) {
return mValue.mMLSBytes.Value();
}
Uninit();
mType = eMLSBytes;
return mValue.mMLSBytes.SetValue(cx);
}
inline bool
IsMLSBytes() const
{
return mType == eMLSBytes;
}
inline RootedDictionary<binding_detail::FastMLSBytes>&
GetAsMLSBytes()
{
MOZ_RELEASE_ASSERT(IsMLSBytes(), "Wrong type!");
return mValue.mMLSBytes.Value();
}
inline const MLSBytes&
GetAsMLSBytes() const
{
MOZ_RELEASE_ASSERT(IsMLSBytes(), "Wrong type!");
return mValue.mMLSBytes.Value();
}
[[nodiscard]] inline RootedSpiderMonkeyInterface<Uint8Array>&
RawSetAsUint8Array(JSContext* cx)
{
if (mType == eUint8Array) {
return mValue.mUint8Array.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eUint8Array;
return mValue.mUint8Array.SetValue(cx);
}
[[nodiscard]] inline RootedSpiderMonkeyInterface<Uint8Array>&
SetAsUint8Array(JSContext* cx)
{
if (mType == eUint8Array) {
return mValue.mUint8Array.Value();
}
Uninit();
mType = eUint8Array;
return mValue.mUint8Array.SetValue(cx);
}
inline bool
IsUint8Array() const
{
return mType == eUint8Array;
}
inline RootedSpiderMonkeyInterface<Uint8Array>&
GetAsUint8Array()
{
MOZ_RELEASE_ASSERT(IsUint8Array(), "Wrong type!");
return mValue.mUint8Array.Value();
}
inline Uint8Array const &
GetAsUint8Array() const
{
MOZ_RELEASE_ASSERT(IsUint8Array(), "Wrong type!");
return mValue.mUint8Array.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 eMLSBytes: {
DestroyMLSBytes();
break;
}
case eUint8Array: {
DestroyUint8Array();
break;
}
}
}
bool
ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
private:
bool
TrySetToMLSBytes(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToMLSBytes(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyMLSBytes()
{
MOZ_RELEASE_ASSERT(IsMLSBytes(), "Wrong type!");
mValue.mMLSBytes.Destroy();
mType = eUninitialized;
}
bool
TrySetToUint8Array(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToUint8Array(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyUint8Array()
{
MOZ_RELEASE_ASSERT(IsUint8Array(), "Wrong type!");
mValue.mUint8Array.Destroy();
mType = eUninitialized;
}
};
class OwningMLSBytesOrUint8Array : public AllOwningUnionBase,
public UnionWithTypedArraysBase
{
public:
using ApplyToTypedArrays = binding_detail::ApplyToTypedArraysHelper<OwningMLSBytesOrUint8Array, true, Uint8Array>;
private:
enum TypeOrUninit
{
eUninitialized,
eMLSBytes,
eUint8Array
};
public:
enum class Type
{
eMLSBytes = TypeOrUninit::eMLSBytes,
eUint8Array = TypeOrUninit::eUint8Array
};
private:
union Value
{
UnionMember<MLSBytes > mMLSBytes;
UnionMember<Uint8Array > mUint8Array;
};
TypeOrUninit mType;
Value mValue;
OwningMLSBytesOrUint8Array(const OwningMLSBytesOrUint8Array&) = delete;
OwningMLSBytesOrUint8Array& operator=(const OwningMLSBytesOrUint8Array&) = delete;
public:
explicit inline OwningMLSBytesOrUint8Array()
: mType(eUninitialized)
{
}
OwningMLSBytesOrUint8Array(OwningMLSBytesOrUint8Array&& aOther);
inline ~OwningMLSBytesOrUint8Array()
{
Uninit();
}
[[nodiscard]] MLSBytes&
RawSetAsMLSBytes();
[[nodiscard]] MLSBytes&
SetAsMLSBytes();
inline bool
IsMLSBytes() const
{
return mType == eMLSBytes;
}
inline MLSBytes&
GetAsMLSBytes()
{
MOZ_RELEASE_ASSERT(IsMLSBytes(), "Wrong type!");
return mValue.mMLSBytes.Value();
}
inline MLSBytes const &
GetAsMLSBytes() const
{
MOZ_RELEASE_ASSERT(IsMLSBytes(), "Wrong type!");
return mValue.mMLSBytes.Value();
}
[[nodiscard]] Uint8Array&
RawSetAsUint8Array();
[[nodiscard]] Uint8Array&
SetAsUint8Array();
inline bool
IsUint8Array() const
{
return mType == eUint8Array;
}
inline Uint8Array&
GetAsUint8Array()
{
MOZ_RELEASE_ASSERT(IsUint8Array(), "Wrong type!");
return mValue.mUint8Array.Value();
}
inline Uint8Array const &
GetAsUint8Array() const
{
MOZ_RELEASE_ASSERT(IsUint8Array(), "Wrong type!");
return mValue.mUint8Array.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;
void
TraceUnion(JSTracer* trc);
OwningMLSBytesOrUint8Array&
operator=(OwningMLSBytesOrUint8Array&& aOther);
inline Type
GetType() const
{
MOZ_RELEASE_ASSERT(mType != eUninitialized);
return static_cast<Type>(mType);
}
private:
bool
TrySetToMLSBytes(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToMLSBytes(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyMLSBytes();
bool
TrySetToUint8Array(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToUint8Array(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyUint8Array();
};
class MLSBytesOrUint8ArrayOrUTF8String : public AllUnionBase,
public UnionWithTypedArraysBase
{
public:
using ApplyToTypedArrays = binding_detail::ApplyToTypedArraysHelper<MLSBytesOrUint8ArrayOrUTF8String, true, Uint8Array>;
private:
enum TypeOrUninit
{
eUninitialized,
eMLSBytes,
eUint8Array,
eUTF8String
};
public:
enum class Type
{
eMLSBytes = TypeOrUninit::eMLSBytes,
eUint8Array = TypeOrUninit::eUint8Array,
eUTF8String = TypeOrUninit::eUTF8String
};
private:
union Value
{
UnionMember<RootedDictionary<binding_detail::FastMLSBytes> > mMLSBytes;
UnionMember<RootedSpiderMonkeyInterface<Uint8Array> > mUint8Array;
UnionMember<binding_detail::FakeString<char> > mUTF8String;
};
TypeOrUninit mType;
Value mValue;
MLSBytesOrUint8ArrayOrUTF8String(const MLSBytesOrUint8ArrayOrUTF8String&) = delete;
MLSBytesOrUint8ArrayOrUTF8String& operator=(const MLSBytesOrUint8ArrayOrUTF8String&) = delete;
public:
explicit inline MLSBytesOrUint8ArrayOrUTF8String()
: mType(eUninitialized)
{
}
inline ~MLSBytesOrUint8ArrayOrUTF8String()
{
Uninit();
}
[[nodiscard]] inline RootedDictionary<binding_detail::FastMLSBytes>&
RawSetAsMLSBytes(JSContext* cx)
{
if (mType == eMLSBytes) {
return mValue.mMLSBytes.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eMLSBytes;
return mValue.mMLSBytes.SetValue(cx);
}
[[nodiscard]] inline RootedDictionary<binding_detail::FastMLSBytes>&
SetAsMLSBytes(JSContext* cx)
{
if (mType == eMLSBytes) {
return mValue.mMLSBytes.Value();
}
Uninit();
mType = eMLSBytes;
return mValue.mMLSBytes.SetValue(cx);
}
inline bool
IsMLSBytes() const
{
return mType == eMLSBytes;
}
inline RootedDictionary<binding_detail::FastMLSBytes>&
GetAsMLSBytes()
{
MOZ_RELEASE_ASSERT(IsMLSBytes(), "Wrong type!");
return mValue.mMLSBytes.Value();
}
inline const MLSBytes&
GetAsMLSBytes() const
{
MOZ_RELEASE_ASSERT(IsMLSBytes(), "Wrong type!");
return mValue.mMLSBytes.Value();
}
[[nodiscard]] inline RootedSpiderMonkeyInterface<Uint8Array>&
RawSetAsUint8Array(JSContext* cx)
{
if (mType == eUint8Array) {
return mValue.mUint8Array.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eUint8Array;
return mValue.mUint8Array.SetValue(cx);
}
[[nodiscard]] inline RootedSpiderMonkeyInterface<Uint8Array>&
SetAsUint8Array(JSContext* cx)
{
if (mType == eUint8Array) {
return mValue.mUint8Array.Value();
}
Uninit();
mType = eUint8Array;
return mValue.mUint8Array.SetValue(cx);
}
inline bool
IsUint8Array() const
{
return mType == eUint8Array;
}
inline RootedSpiderMonkeyInterface<Uint8Array>&
GetAsUint8Array()
{
MOZ_RELEASE_ASSERT(IsUint8Array(), "Wrong type!");
return mValue.mUint8Array.Value();
}
inline Uint8Array const &
GetAsUint8Array() const
{
MOZ_RELEASE_ASSERT(IsUint8Array(), "Wrong type!");
return mValue.mUint8Array.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();
}
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 eMLSBytes: {
DestroyMLSBytes();
break;
}
case eUint8Array: {
DestroyUint8Array();
break;
}
case eUTF8String: {
DestroyUTF8String();
break;
}
}
}
bool
ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
private:
bool
TrySetToMLSBytes(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToMLSBytes(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyMLSBytes()
{
MOZ_RELEASE_ASSERT(IsMLSBytes(), "Wrong type!");
mValue.mMLSBytes.Destroy();
mType = eUninitialized;
}
bool
TrySetToUint8Array(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToUint8Array(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyUint8Array()
{
MOZ_RELEASE_ASSERT(IsUint8Array(), "Wrong type!");
mValue.mUint8Array.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;
}
};
class OwningMLSBytesOrUint8ArrayOrUTF8String : public AllOwningUnionBase,
public UnionWithTypedArraysBase
{
public:
using ApplyToTypedArrays = binding_detail::ApplyToTypedArraysHelper<OwningMLSBytesOrUint8ArrayOrUTF8String, true, Uint8Array>;
private:
enum TypeOrUninit
{
eUninitialized,
eMLSBytes,
eUint8Array,
eUTF8String
};
public:
enum class Type
{
eMLSBytes = TypeOrUninit::eMLSBytes,
eUint8Array = TypeOrUninit::eUint8Array,
eUTF8String = TypeOrUninit::eUTF8String
};
private:
union Value
{
UnionMember<MLSBytes > mMLSBytes;
UnionMember<Uint8Array > mUint8Array;
UnionMember<nsCString > mUTF8String;
};
TypeOrUninit mType;
Value mValue;
OwningMLSBytesOrUint8ArrayOrUTF8String(const OwningMLSBytesOrUint8ArrayOrUTF8String&) = delete;
OwningMLSBytesOrUint8ArrayOrUTF8String& operator=(const OwningMLSBytesOrUint8ArrayOrUTF8String&) = delete;
public:
explicit inline OwningMLSBytesOrUint8ArrayOrUTF8String()
: mType(eUninitialized)
{
}
OwningMLSBytesOrUint8ArrayOrUTF8String(OwningMLSBytesOrUint8ArrayOrUTF8String&& aOther);
inline ~OwningMLSBytesOrUint8ArrayOrUTF8String()
{
Uninit();
}
[[nodiscard]] MLSBytes&
RawSetAsMLSBytes();
[[nodiscard]] MLSBytes&
SetAsMLSBytes();
inline bool
IsMLSBytes() const
{
return mType == eMLSBytes;
}
inline MLSBytes&
GetAsMLSBytes()
{
MOZ_RELEASE_ASSERT(IsMLSBytes(), "Wrong type!");
return mValue.mMLSBytes.Value();
}
inline MLSBytes const &
GetAsMLSBytes() const
{
MOZ_RELEASE_ASSERT(IsMLSBytes(), "Wrong type!");
return mValue.mMLSBytes.Value();
}
[[nodiscard]] Uint8Array&
RawSetAsUint8Array();
[[nodiscard]] Uint8Array&
SetAsUint8Array();
inline bool
IsUint8Array() const
{
return mType == eUint8Array;
}
inline Uint8Array&
GetAsUint8Array()
{
MOZ_RELEASE_ASSERT(IsUint8Array(), "Wrong type!");
return mValue.mUint8Array.Value();
}
inline Uint8Array const &
GetAsUint8Array() const
{
MOZ_RELEASE_ASSERT(IsUint8Array(), "Wrong type!");
return mValue.mUint8Array.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();
}
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;
void
TraceUnion(JSTracer* trc);
OwningMLSBytesOrUint8ArrayOrUTF8String&
operator=(OwningMLSBytesOrUint8ArrayOrUTF8String&& aOther);
inline Type
GetType() const
{
MOZ_RELEASE_ASSERT(mType != eUninitialized);
return static_cast<Type>(mType);
}
private:
bool
TrySetToMLSBytes(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToMLSBytes(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyMLSBytes();
bool
TrySetToUint8Array(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToUint8Array(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyUint8Array();
bool
TrySetToUTF8String(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyUTF8String();
};
struct MLSGroupDetails : public DictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR Uint8Array mGroupEpoch;
MOZ_INIT_OUTSIDE_CTOR Uint8Array mGroupId;
MOZ_INIT_OUTSIDE_CTOR Sequence<MLSGroupMember> mMembers;
MOZ_INIT_OUTSIDE_CTOR MLSObjectType mType;
MLSGroupDetails();
explicit inline MLSGroupDetails(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
MLSGroupDetails(MLSGroupDetails&& aOther) = default;
private:
MLSGroupDetails(const MLSGroupDetails&) = delete;
MLSGroupDetails& operator=(const MLSGroupDetails&) = delete;
static bool
InitIds(JSContext* cx, MLSGroupDetailsAtoms* atomsCache);
public:
bool
Init(const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
void
TraceDictionary(JSTracer* trc);
};
namespace binding_detail {
struct FastMLSGroupDetails : public MLSGroupDetails
{
inline FastMLSGroupDetails()
: MLSGroupDetails(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
struct MLSReceived : public DictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR Optional<MLSCommitOutput> mCommitOutput;
MOZ_INIT_OUTSIDE_CTOR Optional<Uint8Array> mContent;
MOZ_INIT_OUTSIDE_CTOR Optional<Uint8Array> mGroupEpoch;
MOZ_INIT_OUTSIDE_CTOR Uint8Array mGroupId;
MOZ_INIT_OUTSIDE_CTOR MLSObjectType mType;
MLSReceived();
explicit inline MLSReceived(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
MLSReceived(MLSReceived&& aOther) = default;
private:
MLSReceived(const MLSReceived&) = delete;
MLSReceived& operator=(const MLSReceived&) = delete;
static bool
InitIds(JSContext* cx, MLSReceivedAtoms* atomsCache);
public:
bool
Init(const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
void
TraceDictionary(JSTracer* trc);
};
namespace binding_detail {
struct FastMLSReceived : public MLSReceived
{
inline FastMLSReceived()
: MLSReceived(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
namespace MLS_Binding {
typedef mozilla::dom::MLS NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
bool
Wrap(JSContext* aCx, mozilla::dom::MLS* 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::MLS,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace MLS_Binding
namespace MLSGroupView_Binding {
typedef mozilla::dom::MLSGroupView NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
bool
Wrap(JSContext* aCx, mozilla::dom::MLSGroupView* 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::MLSGroupView,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace MLSGroupView_Binding
} // namespace dom
template <>
struct MaxContiguousEnumValue<dom::MLSObjectType>
{
static constexpr dom::MLSObjectType value = dom::MLSObjectType::Application_message_plaintext;
static_assert(static_cast<uint8_t>(dom::MLSObjectType::Group_epoch) == 0,
"We rely on this in ContiguousEnumValues");
static_assert(std::size(dom::binding_detail::EnumStrings<dom::MLSObjectType>::Values) - 1 == UnderlyingValue(value),
"Mismatch between enum strings and enum count");
};
} // namespace mozilla
#endif // DOM_MLSBINDING_H_