Copy as Markdown
Other Tools
/* THIS FILE IS AUTOGENERATED FROM Headers.webidl BY Codegen.py - DO NOT EDIT */
#ifndef DOM_HEADERSBINDING_H_
#define DOM_HEADERSBINDING_H_
#include "js/CallAndConstruct.h"
#include "js/RootingAPI.h"
#include "js/TypeDecls.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/Record.h"
#include "mozilla/dom/UnionMember.h"
namespace mozilla {
namespace dom {
class Headers;
struct NativePropertyHooks;
class ProtoAndIfaceCache;
} // namespace dom
} // namespace mozilla
namespace mozilla {
namespace dom {
enum class HeadersGuardEnum : uint8_t {
None,
Request,
Request_no_cors,
Response,
Immutable,
};
namespace binding_detail {
template <> struct EnumStrings<HeadersGuardEnum> {
static constexpr nsLiteralCString Values[5] {
"none"_ns,
"request"_ns,
"request-no-cors"_ns,
"response"_ns,
"immutable"_ns,
};
};
} // namespace binding_detail
bool
ToJSValue(JSContext* aCx, HeadersGuardEnum aArgument, JS::MutableHandle<JS::Value> aValue);
class ByteStringSequenceSequenceOrByteStringByteStringRecord : public AllUnionBase
{
enum TypeOrUninit
{
eUninitialized,
eByteStringSequenceSequence,
eByteStringByteStringRecord
};
public:
enum class Type
{
eByteStringSequenceSequence = TypeOrUninit::eByteStringSequenceSequence,
eByteStringByteStringRecord = TypeOrUninit::eByteStringByteStringRecord
};
private:
union Value
{
UnionMember<binding_detail::AutoSequence<Sequence<nsCString>> > mByteStringSequenceSequence;
UnionMember<Record<nsCString, nsCString> > mByteStringByteStringRecord;
};
TypeOrUninit mType;
Value mValue;
ByteStringSequenceSequenceOrByteStringByteStringRecord(const ByteStringSequenceSequenceOrByteStringByteStringRecord&) = delete;
ByteStringSequenceSequenceOrByteStringByteStringRecord& operator=(const ByteStringSequenceSequenceOrByteStringByteStringRecord&) = delete;
public:
explicit inline ByteStringSequenceSequenceOrByteStringByteStringRecord()
: mType(eUninitialized)
{
}
inline ~ByteStringSequenceSequenceOrByteStringByteStringRecord()
{
Uninit();
}
[[nodiscard]] inline binding_detail::AutoSequence<Sequence<nsCString>>&
RawSetAsByteStringSequenceSequence()
{
if (mType == eByteStringSequenceSequence) {
return mValue.mByteStringSequenceSequence.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eByteStringSequenceSequence;
return mValue.mByteStringSequenceSequence.SetValue();
}
[[nodiscard]] inline binding_detail::AutoSequence<Sequence<nsCString>>&
SetAsByteStringSequenceSequence()
{
if (mType == eByteStringSequenceSequence) {
return mValue.mByteStringSequenceSequence.Value();
}
Uninit();
mType = eByteStringSequenceSequence;
return mValue.mByteStringSequenceSequence.SetValue();
}
inline bool
IsByteStringSequenceSequence() const
{
return mType == eByteStringSequenceSequence;
}
inline binding_detail::AutoSequence<Sequence<nsCString>>&
GetAsByteStringSequenceSequence()
{
MOZ_RELEASE_ASSERT(IsByteStringSequenceSequence(), "Wrong type!");
return mValue.mByteStringSequenceSequence.Value();
}
inline const Sequence<Sequence<nsCString>>&
GetAsByteStringSequenceSequence() const
{
MOZ_RELEASE_ASSERT(IsByteStringSequenceSequence(), "Wrong type!");
return mValue.mByteStringSequenceSequence.Value();
}
[[nodiscard]] inline Record<nsCString, nsCString>&
RawSetAsByteStringByteStringRecord()
{
if (mType == eByteStringByteStringRecord) {
return mValue.mByteStringByteStringRecord.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eByteStringByteStringRecord;
return mValue.mByteStringByteStringRecord.SetValue();
}
[[nodiscard]] inline Record<nsCString, nsCString>&
SetAsByteStringByteStringRecord()
{
if (mType == eByteStringByteStringRecord) {
return mValue.mByteStringByteStringRecord.Value();
}
Uninit();
mType = eByteStringByteStringRecord;
return mValue.mByteStringByteStringRecord.SetValue();
}
inline bool
IsByteStringByteStringRecord() const
{
return mType == eByteStringByteStringRecord;
}
inline Record<nsCString, nsCString>&
GetAsByteStringByteStringRecord()
{
MOZ_RELEASE_ASSERT(IsByteStringByteStringRecord(), "Wrong type!");
return mValue.mByteStringByteStringRecord.Value();
}
inline const Record<nsCString, nsCString>&
GetAsByteStringByteStringRecord() const
{
MOZ_RELEASE_ASSERT(IsByteStringByteStringRecord(), "Wrong type!");
return mValue.mByteStringByteStringRecord.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 eByteStringSequenceSequence: {
DestroyByteStringSequenceSequence();
break;
}
case eByteStringByteStringRecord: {
DestroyByteStringByteStringRecord();
break;
}
}
}
bool
ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
private:
bool
TrySetToByteStringSequenceSequence(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToByteStringSequenceSequence(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyByteStringSequenceSequence()
{
MOZ_RELEASE_ASSERT(IsByteStringSequenceSequence(), "Wrong type!");
mValue.mByteStringSequenceSequence.Destroy();
mType = eUninitialized;
}
bool
TrySetToByteStringByteStringRecord(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToByteStringByteStringRecord(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyByteStringByteStringRecord()
{
MOZ_RELEASE_ASSERT(IsByteStringByteStringRecord(), "Wrong type!");
mValue.mByteStringByteStringRecord.Destroy();
mType = eUninitialized;
}
};
class OwningByteStringSequenceSequenceOrByteStringByteStringRecord : public AllOwningUnionBase
{
enum TypeOrUninit
{
eUninitialized,
eByteStringSequenceSequence,
eByteStringByteStringRecord
};
public:
enum class Type
{
eByteStringSequenceSequence = TypeOrUninit::eByteStringSequenceSequence,
eByteStringByteStringRecord = TypeOrUninit::eByteStringByteStringRecord
};
private:
union Value
{
UnionMember<Sequence<Sequence<nsCString>> > mByteStringSequenceSequence;
UnionMember<Record<nsCString, nsCString> > mByteStringByteStringRecord;
};
TypeOrUninit mType;
Value mValue;
OwningByteStringSequenceSequenceOrByteStringByteStringRecord(const OwningByteStringSequenceSequenceOrByteStringByteStringRecord&) = delete;
OwningByteStringSequenceSequenceOrByteStringByteStringRecord& operator=(const OwningByteStringSequenceSequenceOrByteStringByteStringRecord&) = delete;
public:
explicit inline OwningByteStringSequenceSequenceOrByteStringByteStringRecord()
: mType(eUninitialized)
{
}
OwningByteStringSequenceSequenceOrByteStringByteStringRecord(OwningByteStringSequenceSequenceOrByteStringByteStringRecord&& aOther);
inline ~OwningByteStringSequenceSequenceOrByteStringByteStringRecord()
{
Uninit();
}
[[nodiscard]] Sequence<Sequence<nsCString>>&
RawSetAsByteStringSequenceSequence();
[[nodiscard]] Sequence<Sequence<nsCString>>&
SetAsByteStringSequenceSequence();
inline bool
IsByteStringSequenceSequence() const
{
return mType == eByteStringSequenceSequence;
}
inline Sequence<Sequence<nsCString>>&
GetAsByteStringSequenceSequence()
{
MOZ_RELEASE_ASSERT(IsByteStringSequenceSequence(), "Wrong type!");
return mValue.mByteStringSequenceSequence.Value();
}
inline Sequence<Sequence<nsCString>> const &
GetAsByteStringSequenceSequence() const
{
MOZ_RELEASE_ASSERT(IsByteStringSequenceSequence(), "Wrong type!");
return mValue.mByteStringSequenceSequence.Value();
}
[[nodiscard]] Record<nsCString, nsCString>&
RawSetAsByteStringByteStringRecord();
[[nodiscard]] Record<nsCString, nsCString>&
SetAsByteStringByteStringRecord();
inline bool
IsByteStringByteStringRecord() const
{
return mType == eByteStringByteStringRecord;
}
inline Record<nsCString, nsCString>&
GetAsByteStringByteStringRecord()
{
MOZ_RELEASE_ASSERT(IsByteStringByteStringRecord(), "Wrong type!");
return mValue.mByteStringByteStringRecord.Value();
}
inline Record<nsCString, nsCString> const &
GetAsByteStringByteStringRecord() const
{
MOZ_RELEASE_ASSERT(IsByteStringByteStringRecord(), "Wrong type!");
return mValue.mByteStringByteStringRecord.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;
OwningByteStringSequenceSequenceOrByteStringByteStringRecord&
operator=(OwningByteStringSequenceSequenceOrByteStringByteStringRecord&& aOther);
inline Type
GetType() const
{
MOZ_RELEASE_ASSERT(mType != eUninitialized);
return static_cast<Type>(mType);
}
private:
bool
TrySetToByteStringSequenceSequence(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToByteStringSequenceSequence(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyByteStringSequenceSequence();
bool
TrySetToByteStringByteStringRecord(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToByteStringByteStringRecord(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyByteStringByteStringRecord();
};
namespace Headers_Binding {
typedef mozilla::dom::Headers NativeType;
bool
Wrap(JSContext* aCx, mozilla::dom::Headers* 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::Headers,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace Headers_Binding
} // namespace dom
template <>
struct MaxContiguousEnumValue<dom::HeadersGuardEnum>
{
static constexpr dom::HeadersGuardEnum value = dom::HeadersGuardEnum::Immutable;
static_assert(static_cast<uint8_t>(dom::HeadersGuardEnum::None) == 0,
"We rely on this in ContiguousEnumValues");
static_assert(std::size(dom::binding_detail::EnumStrings<dom::HeadersGuardEnum>::Values) - 1 == UnderlyingValue(value),
"Mismatch between enum strings and enum count");
};
} // namespace mozilla
#endif // DOM_HEADERSBINDING_H_