Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM ReadableStreamDefaultReader.webidl BY Codegen.py - DO NOT EDIT */
#ifndef DOM_READABLESTREAMDEFAULTREADERBINDING_H_
#define DOM_READABLESTREAMDEFAULTREADERBINDING_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/UnionMember.h"
namespace mozilla {
namespace dom {
struct NativePropertyHooks;
class OwningReadableStreamDefaultReaderOrReadableStreamBYOBReader;
class ProtoAndIfaceCache;
class ReadableStreamBYOBReader;
class ReadableStreamDefaultReader;
struct ReadableStreamReadResultAtoms;
} // namespace dom
} // namespace mozilla
namespace mozilla {
namespace dom {
enum class ReadableStreamType : uint8_t {
Bytes,
};
namespace binding_detail {
template <> struct EnumStrings<ReadableStreamType> {
static constexpr nsLiteralCString Values[1] {
"bytes"_ns,
};
};
} // namespace binding_detail
bool
ToJSValue(JSContext* aCx, ReadableStreamType aArgument, JS::MutableHandle<JS::Value> aValue);
void
ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningReadableStreamDefaultReaderOrReadableStreamBYOBReader& aUnion, const char* aName, uint32_t aFlags = 0);
void
ImplCycleCollectionUnlink(OwningReadableStreamDefaultReaderOrReadableStreamBYOBReader& aUnion);
class ReadableStreamDefaultReaderOrReadableStreamBYOBReader : public AllUnionBase
{
enum TypeOrUninit
{
eUninitialized,
eReadableStreamDefaultReader,
eReadableStreamBYOBReader
};
public:
enum class Type
{
eReadableStreamDefaultReader = TypeOrUninit::eReadableStreamDefaultReader,
eReadableStreamBYOBReader = TypeOrUninit::eReadableStreamBYOBReader
};
private:
union Value
{
UnionMember<NonNull<mozilla::dom::ReadableStreamDefaultReader> > mReadableStreamDefaultReader;
UnionMember<NonNull<mozilla::dom::ReadableStreamBYOBReader> > mReadableStreamBYOBReader;
};
TypeOrUninit mType;
Value mValue;
ReadableStreamDefaultReaderOrReadableStreamBYOBReader(const ReadableStreamDefaultReaderOrReadableStreamBYOBReader&) = delete;
ReadableStreamDefaultReaderOrReadableStreamBYOBReader& operator=(const ReadableStreamDefaultReaderOrReadableStreamBYOBReader&) = delete;
public:
explicit inline ReadableStreamDefaultReaderOrReadableStreamBYOBReader()
: mType(eUninitialized)
{
}
inline ~ReadableStreamDefaultReaderOrReadableStreamBYOBReader()
{
Uninit();
}
[[nodiscard]] inline NonNull<mozilla::dom::ReadableStreamDefaultReader>&
RawSetAsReadableStreamDefaultReader()
{
if (mType == eReadableStreamDefaultReader) {
return mValue.mReadableStreamDefaultReader.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eReadableStreamDefaultReader;
return mValue.mReadableStreamDefaultReader.SetValue();
}
[[nodiscard]] inline NonNull<mozilla::dom::ReadableStreamDefaultReader>&
SetAsReadableStreamDefaultReader()
{
if (mType == eReadableStreamDefaultReader) {
return mValue.mReadableStreamDefaultReader.Value();
}
Uninit();
mType = eReadableStreamDefaultReader;
return mValue.mReadableStreamDefaultReader.SetValue();
}
inline bool
IsReadableStreamDefaultReader() const
{
return mType == eReadableStreamDefaultReader;
}
inline NonNull<mozilla::dom::ReadableStreamDefaultReader>&
GetAsReadableStreamDefaultReader()
{
MOZ_RELEASE_ASSERT(IsReadableStreamDefaultReader(), "Wrong type!");
return mValue.mReadableStreamDefaultReader.Value();
}
inline mozilla::dom::ReadableStreamDefaultReader&
GetAsReadableStreamDefaultReader() const
{
MOZ_RELEASE_ASSERT(IsReadableStreamDefaultReader(), "Wrong type!");
return mValue.mReadableStreamDefaultReader.Value();
}
[[nodiscard]] inline NonNull<mozilla::dom::ReadableStreamBYOBReader>&
RawSetAsReadableStreamBYOBReader()
{
if (mType == eReadableStreamBYOBReader) {
return mValue.mReadableStreamBYOBReader.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eReadableStreamBYOBReader;
return mValue.mReadableStreamBYOBReader.SetValue();
}
[[nodiscard]] inline NonNull<mozilla::dom::ReadableStreamBYOBReader>&
SetAsReadableStreamBYOBReader()
{
if (mType == eReadableStreamBYOBReader) {
return mValue.mReadableStreamBYOBReader.Value();
}
Uninit();
mType = eReadableStreamBYOBReader;
return mValue.mReadableStreamBYOBReader.SetValue();
}
inline bool
IsReadableStreamBYOBReader() const
{
return mType == eReadableStreamBYOBReader;
}
inline NonNull<mozilla::dom::ReadableStreamBYOBReader>&
GetAsReadableStreamBYOBReader()
{
MOZ_RELEASE_ASSERT(IsReadableStreamBYOBReader(), "Wrong type!");
return mValue.mReadableStreamBYOBReader.Value();
}
inline mozilla::dom::ReadableStreamBYOBReader&
GetAsReadableStreamBYOBReader() const
{
MOZ_RELEASE_ASSERT(IsReadableStreamBYOBReader(), "Wrong type!");
return mValue.mReadableStreamBYOBReader.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 eReadableStreamDefaultReader: {
DestroyReadableStreamDefaultReader();
break;
}
case eReadableStreamBYOBReader: {
DestroyReadableStreamBYOBReader();
break;
}
}
}
bool
ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
private:
bool
TrySetToReadableStreamDefaultReader(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToReadableStreamDefaultReader(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyReadableStreamDefaultReader()
{
MOZ_RELEASE_ASSERT(IsReadableStreamDefaultReader(), "Wrong type!");
mValue.mReadableStreamDefaultReader.Destroy();
mType = eUninitialized;
}
bool
TrySetToReadableStreamBYOBReader(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToReadableStreamBYOBReader(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyReadableStreamBYOBReader()
{
MOZ_RELEASE_ASSERT(IsReadableStreamBYOBReader(), "Wrong type!");
mValue.mReadableStreamBYOBReader.Destroy();
mType = eUninitialized;
}
};
class OwningReadableStreamDefaultReaderOrReadableStreamBYOBReader : public AllOwningUnionBase
{
friend void ImplCycleCollectionUnlink(OwningReadableStreamDefaultReaderOrReadableStreamBYOBReader& aUnion);
enum TypeOrUninit
{
eUninitialized,
eReadableStreamDefaultReader,
eReadableStreamBYOBReader
};
public:
enum class Type
{
eReadableStreamDefaultReader = TypeOrUninit::eReadableStreamDefaultReader,
eReadableStreamBYOBReader = TypeOrUninit::eReadableStreamBYOBReader
};
private:
union Value
{
UnionMember<OwningNonNull<mozilla::dom::ReadableStreamDefaultReader> > mReadableStreamDefaultReader;
UnionMember<OwningNonNull<mozilla::dom::ReadableStreamBYOBReader> > mReadableStreamBYOBReader;
};
TypeOrUninit mType;
Value mValue;
public:
explicit inline OwningReadableStreamDefaultReaderOrReadableStreamBYOBReader()
: mType(eUninitialized)
{
}
OwningReadableStreamDefaultReaderOrReadableStreamBYOBReader(OwningReadableStreamDefaultReaderOrReadableStreamBYOBReader&& aOther);
explicit inline OwningReadableStreamDefaultReaderOrReadableStreamBYOBReader(const OwningReadableStreamDefaultReaderOrReadableStreamBYOBReader& aOther)
: mType(eUninitialized)
{
*this = aOther;
}
inline ~OwningReadableStreamDefaultReaderOrReadableStreamBYOBReader()
{
Uninit();
}
[[nodiscard]] OwningNonNull<mozilla::dom::ReadableStreamDefaultReader>&
RawSetAsReadableStreamDefaultReader();
[[nodiscard]] OwningNonNull<mozilla::dom::ReadableStreamDefaultReader>&
SetAsReadableStreamDefaultReader();
inline bool
IsReadableStreamDefaultReader() const
{
return mType == eReadableStreamDefaultReader;
}
inline OwningNonNull<mozilla::dom::ReadableStreamDefaultReader>&
GetAsReadableStreamDefaultReader()
{
MOZ_RELEASE_ASSERT(IsReadableStreamDefaultReader(), "Wrong type!");
return mValue.mReadableStreamDefaultReader.Value();
}
inline OwningNonNull<mozilla::dom::ReadableStreamDefaultReader> const &
GetAsReadableStreamDefaultReader() const
{
MOZ_RELEASE_ASSERT(IsReadableStreamDefaultReader(), "Wrong type!");
return mValue.mReadableStreamDefaultReader.Value();
}
[[nodiscard]] OwningNonNull<mozilla::dom::ReadableStreamBYOBReader>&
RawSetAsReadableStreamBYOBReader();
[[nodiscard]] OwningNonNull<mozilla::dom::ReadableStreamBYOBReader>&
SetAsReadableStreamBYOBReader();
inline bool
IsReadableStreamBYOBReader() const
{
return mType == eReadableStreamBYOBReader;
}
inline OwningNonNull<mozilla::dom::ReadableStreamBYOBReader>&
GetAsReadableStreamBYOBReader()
{
MOZ_RELEASE_ASSERT(IsReadableStreamBYOBReader(), "Wrong type!");
return mValue.mReadableStreamBYOBReader.Value();
}
inline OwningNonNull<mozilla::dom::ReadableStreamBYOBReader> const &
GetAsReadableStreamBYOBReader() const
{
MOZ_RELEASE_ASSERT(IsReadableStreamBYOBReader(), "Wrong type!");
return mValue.mReadableStreamBYOBReader.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;
OwningReadableStreamDefaultReaderOrReadableStreamBYOBReader&
operator=(OwningReadableStreamDefaultReaderOrReadableStreamBYOBReader&& aOther);
inline Type
GetType() const
{
MOZ_RELEASE_ASSERT(mType != eUninitialized);
return static_cast<Type>(mType);
}
OwningReadableStreamDefaultReaderOrReadableStreamBYOBReader&
operator=(const OwningReadableStreamDefaultReaderOrReadableStreamBYOBReader& aOther);
private:
bool
TrySetToReadableStreamDefaultReader(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToReadableStreamDefaultReader(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyReadableStreamDefaultReader();
bool
TrySetToReadableStreamBYOBReader(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToReadableStreamBYOBReader(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyReadableStreamBYOBReader();
};
struct ReadableStreamReadResult : public DictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR Optional<bool> mDone;
MOZ_INIT_OUTSIDE_CTOR JS::Value mValue;
ReadableStreamReadResult();
explicit inline ReadableStreamReadResult(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
ReadableStreamReadResult(ReadableStreamReadResult&& aOther) = default;
private:
ReadableStreamReadResult(const ReadableStreamReadResult&) = delete;
ReadableStreamReadResult& operator=(const ReadableStreamReadResult&) = delete;
static bool
InitIds(JSContext* cx, ReadableStreamReadResultAtoms* 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 FastReadableStreamReadResult : public ReadableStreamReadResult
{
inline FastReadableStreamReadResult()
: ReadableStreamReadResult(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
namespace ReadableStreamDefaultReader_Binding {
typedef mozilla::dom::ReadableStreamDefaultReader NativeType;
bool
Wrap(JSContext* aCx, mozilla::dom::ReadableStreamDefaultReader* 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::ReadableStreamDefaultReader,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace ReadableStreamDefaultReader_Binding
} // namespace dom
template <>
struct MaxContiguousEnumValue<dom::ReadableStreamType>
{
static constexpr dom::ReadableStreamType value = dom::ReadableStreamType::Bytes;
static_assert(static_cast<uint8_t>(dom::ReadableStreamType::Bytes) == 0,
"We rely on this in ContiguousEnumValues");
static_assert(std::size(dom::binding_detail::EnumStrings<dom::ReadableStreamType>::Values) - 1 == UnderlyingValue(value),
"Mismatch between enum strings and enum count");
};
} // namespace mozilla
#endif // DOM_READABLESTREAMDEFAULTREADERBINDING_H_