Copy as Markdown
Other Tools
/* THIS FILE IS AUTOGENERATED FROM IDBRequest.webidl BY Codegen.py - DO NOT EDIT */
#ifndef DOM_IDBREQUESTBINDING_H_
#define DOM_IDBREQUESTBINDING_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 {
class IDBCursor;
class IDBIndex;
class IDBObjectStore;
class IDBRequest;
struct NativePropertyHooks;
class OwningIDBObjectStoreOrIDBIndexOrIDBCursor;
class ProtoAndIfaceCache;
} // namespace dom
} // namespace mozilla
namespace mozilla {
namespace dom {
enum class IDBRequestReadyState : uint8_t {
Pending,
Done,
};
namespace binding_detail {
template <> struct EnumStrings<IDBRequestReadyState> {
static constexpr nsLiteralCString Values[2] {
"pending"_ns,
"done"_ns,
};
};
} // namespace binding_detail
bool
ToJSValue(JSContext* aCx, IDBRequestReadyState aArgument, JS::MutableHandle<JS::Value> aValue);
void
ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningIDBObjectStoreOrIDBIndexOrIDBCursor& aUnion, const char* aName, uint32_t aFlags = 0);
void
ImplCycleCollectionUnlink(OwningIDBObjectStoreOrIDBIndexOrIDBCursor& aUnion);
class IDBObjectStoreOrIDBIndexOrIDBCursor : public AllUnionBase
{
enum TypeOrUninit
{
eUninitialized,
eIDBObjectStore,
eIDBIndex,
eIDBCursor
};
public:
enum class Type
{
eIDBObjectStore = TypeOrUninit::eIDBObjectStore,
eIDBIndex = TypeOrUninit::eIDBIndex,
eIDBCursor = TypeOrUninit::eIDBCursor
};
private:
union Value
{
UnionMember<NonNull<mozilla::dom::IDBObjectStore> > mIDBObjectStore;
UnionMember<NonNull<mozilla::dom::IDBIndex> > mIDBIndex;
UnionMember<NonNull<mozilla::dom::IDBCursor> > mIDBCursor;
};
TypeOrUninit mType;
Value mValue;
IDBObjectStoreOrIDBIndexOrIDBCursor(const IDBObjectStoreOrIDBIndexOrIDBCursor&) = delete;
IDBObjectStoreOrIDBIndexOrIDBCursor& operator=(const IDBObjectStoreOrIDBIndexOrIDBCursor&) = delete;
public:
explicit inline IDBObjectStoreOrIDBIndexOrIDBCursor()
: mType(eUninitialized)
{
}
inline ~IDBObjectStoreOrIDBIndexOrIDBCursor()
{
Uninit();
}
[[nodiscard]] inline NonNull<mozilla::dom::IDBObjectStore>&
RawSetAsIDBObjectStore()
{
if (mType == eIDBObjectStore) {
return mValue.mIDBObjectStore.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eIDBObjectStore;
return mValue.mIDBObjectStore.SetValue();
}
[[nodiscard]] inline NonNull<mozilla::dom::IDBObjectStore>&
SetAsIDBObjectStore()
{
if (mType == eIDBObjectStore) {
return mValue.mIDBObjectStore.Value();
}
Uninit();
mType = eIDBObjectStore;
return mValue.mIDBObjectStore.SetValue();
}
inline bool
IsIDBObjectStore() const
{
return mType == eIDBObjectStore;
}
inline NonNull<mozilla::dom::IDBObjectStore>&
GetAsIDBObjectStore()
{
MOZ_RELEASE_ASSERT(IsIDBObjectStore(), "Wrong type!");
return mValue.mIDBObjectStore.Value();
}
inline mozilla::dom::IDBObjectStore&
GetAsIDBObjectStore() const
{
MOZ_RELEASE_ASSERT(IsIDBObjectStore(), "Wrong type!");
return mValue.mIDBObjectStore.Value();
}
[[nodiscard]] inline NonNull<mozilla::dom::IDBIndex>&
RawSetAsIDBIndex()
{
if (mType == eIDBIndex) {
return mValue.mIDBIndex.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eIDBIndex;
return mValue.mIDBIndex.SetValue();
}
[[nodiscard]] inline NonNull<mozilla::dom::IDBIndex>&
SetAsIDBIndex()
{
if (mType == eIDBIndex) {
return mValue.mIDBIndex.Value();
}
Uninit();
mType = eIDBIndex;
return mValue.mIDBIndex.SetValue();
}
inline bool
IsIDBIndex() const
{
return mType == eIDBIndex;
}
inline NonNull<mozilla::dom::IDBIndex>&
GetAsIDBIndex()
{
MOZ_RELEASE_ASSERT(IsIDBIndex(), "Wrong type!");
return mValue.mIDBIndex.Value();
}
inline mozilla::dom::IDBIndex&
GetAsIDBIndex() const
{
MOZ_RELEASE_ASSERT(IsIDBIndex(), "Wrong type!");
return mValue.mIDBIndex.Value();
}
[[nodiscard]] inline NonNull<mozilla::dom::IDBCursor>&
RawSetAsIDBCursor()
{
if (mType == eIDBCursor) {
return mValue.mIDBCursor.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eIDBCursor;
return mValue.mIDBCursor.SetValue();
}
[[nodiscard]] inline NonNull<mozilla::dom::IDBCursor>&
SetAsIDBCursor()
{
if (mType == eIDBCursor) {
return mValue.mIDBCursor.Value();
}
Uninit();
mType = eIDBCursor;
return mValue.mIDBCursor.SetValue();
}
inline bool
IsIDBCursor() const
{
return mType == eIDBCursor;
}
inline NonNull<mozilla::dom::IDBCursor>&
GetAsIDBCursor()
{
MOZ_RELEASE_ASSERT(IsIDBCursor(), "Wrong type!");
return mValue.mIDBCursor.Value();
}
inline mozilla::dom::IDBCursor&
GetAsIDBCursor() const
{
MOZ_RELEASE_ASSERT(IsIDBCursor(), "Wrong type!");
return mValue.mIDBCursor.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 eIDBObjectStore: {
DestroyIDBObjectStore();
break;
}
case eIDBIndex: {
DestroyIDBIndex();
break;
}
case eIDBCursor: {
DestroyIDBCursor();
break;
}
}
}
bool
ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
private:
bool
TrySetToIDBObjectStore(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToIDBObjectStore(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyIDBObjectStore()
{
MOZ_RELEASE_ASSERT(IsIDBObjectStore(), "Wrong type!");
mValue.mIDBObjectStore.Destroy();
mType = eUninitialized;
}
bool
TrySetToIDBIndex(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToIDBIndex(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyIDBIndex()
{
MOZ_RELEASE_ASSERT(IsIDBIndex(), "Wrong type!");
mValue.mIDBIndex.Destroy();
mType = eUninitialized;
}
bool
TrySetToIDBCursor(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToIDBCursor(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyIDBCursor()
{
MOZ_RELEASE_ASSERT(IsIDBCursor(), "Wrong type!");
mValue.mIDBCursor.Destroy();
mType = eUninitialized;
}
};
class OwningIDBObjectStoreOrIDBIndexOrIDBCursor : public AllOwningUnionBase
{
friend void ImplCycleCollectionUnlink(OwningIDBObjectStoreOrIDBIndexOrIDBCursor& aUnion);
enum TypeOrUninit
{
eUninitialized,
eIDBObjectStore,
eIDBIndex,
eIDBCursor
};
public:
enum class Type
{
eIDBObjectStore = TypeOrUninit::eIDBObjectStore,
eIDBIndex = TypeOrUninit::eIDBIndex,
eIDBCursor = TypeOrUninit::eIDBCursor
};
private:
union Value
{
UnionMember<OwningNonNull<mozilla::dom::IDBObjectStore> > mIDBObjectStore;
UnionMember<OwningNonNull<mozilla::dom::IDBIndex> > mIDBIndex;
UnionMember<OwningNonNull<mozilla::dom::IDBCursor> > mIDBCursor;
};
TypeOrUninit mType;
Value mValue;
public:
explicit inline OwningIDBObjectStoreOrIDBIndexOrIDBCursor()
: mType(eUninitialized)
{
}
OwningIDBObjectStoreOrIDBIndexOrIDBCursor(OwningIDBObjectStoreOrIDBIndexOrIDBCursor&& aOther);
explicit inline OwningIDBObjectStoreOrIDBIndexOrIDBCursor(const OwningIDBObjectStoreOrIDBIndexOrIDBCursor& aOther)
: mType(eUninitialized)
{
*this = aOther;
}
inline ~OwningIDBObjectStoreOrIDBIndexOrIDBCursor()
{
Uninit();
}
[[nodiscard]] OwningNonNull<mozilla::dom::IDBObjectStore>&
RawSetAsIDBObjectStore();
[[nodiscard]] OwningNonNull<mozilla::dom::IDBObjectStore>&
SetAsIDBObjectStore();
inline bool
IsIDBObjectStore() const
{
return mType == eIDBObjectStore;
}
inline OwningNonNull<mozilla::dom::IDBObjectStore>&
GetAsIDBObjectStore()
{
MOZ_RELEASE_ASSERT(IsIDBObjectStore(), "Wrong type!");
return mValue.mIDBObjectStore.Value();
}
inline OwningNonNull<mozilla::dom::IDBObjectStore> const &
GetAsIDBObjectStore() const
{
MOZ_RELEASE_ASSERT(IsIDBObjectStore(), "Wrong type!");
return mValue.mIDBObjectStore.Value();
}
[[nodiscard]] OwningNonNull<mozilla::dom::IDBIndex>&
RawSetAsIDBIndex();
[[nodiscard]] OwningNonNull<mozilla::dom::IDBIndex>&
SetAsIDBIndex();
inline bool
IsIDBIndex() const
{
return mType == eIDBIndex;
}
inline OwningNonNull<mozilla::dom::IDBIndex>&
GetAsIDBIndex()
{
MOZ_RELEASE_ASSERT(IsIDBIndex(), "Wrong type!");
return mValue.mIDBIndex.Value();
}
inline OwningNonNull<mozilla::dom::IDBIndex> const &
GetAsIDBIndex() const
{
MOZ_RELEASE_ASSERT(IsIDBIndex(), "Wrong type!");
return mValue.mIDBIndex.Value();
}
[[nodiscard]] OwningNonNull<mozilla::dom::IDBCursor>&
RawSetAsIDBCursor();
[[nodiscard]] OwningNonNull<mozilla::dom::IDBCursor>&
SetAsIDBCursor();
inline bool
IsIDBCursor() const
{
return mType == eIDBCursor;
}
inline OwningNonNull<mozilla::dom::IDBCursor>&
GetAsIDBCursor()
{
MOZ_RELEASE_ASSERT(IsIDBCursor(), "Wrong type!");
return mValue.mIDBCursor.Value();
}
inline OwningNonNull<mozilla::dom::IDBCursor> const &
GetAsIDBCursor() const
{
MOZ_RELEASE_ASSERT(IsIDBCursor(), "Wrong type!");
return mValue.mIDBCursor.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;
OwningIDBObjectStoreOrIDBIndexOrIDBCursor&
operator=(OwningIDBObjectStoreOrIDBIndexOrIDBCursor&& aOther);
inline Type
GetType() const
{
MOZ_RELEASE_ASSERT(mType != eUninitialized);
return static_cast<Type>(mType);
}
OwningIDBObjectStoreOrIDBIndexOrIDBCursor&
operator=(const OwningIDBObjectStoreOrIDBIndexOrIDBCursor& aOther);
private:
bool
TrySetToIDBObjectStore(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToIDBObjectStore(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyIDBObjectStore();
bool
TrySetToIDBIndex(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToIDBIndex(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyIDBIndex();
bool
TrySetToIDBCursor(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToIDBCursor(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyIDBCursor();
};
namespace IDBRequest_Binding {
typedef mozilla::dom::IDBRequest NativeType;
bool
Wrap(JSContext* aCx, mozilla::dom::IDBRequest* 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*>
GetProtoObjectHandle(JSContext* aCx);
JSObject*
GetProtoObject(JSContext* aCx);
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::IDBRequest,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace IDBRequest_Binding
} // namespace dom
template <>
struct MaxContiguousEnumValue<dom::IDBRequestReadyState>
{
static constexpr dom::IDBRequestReadyState value = dom::IDBRequestReadyState::Done;
static_assert(static_cast<uint8_t>(dom::IDBRequestReadyState::Pending) == 0,
"We rely on this in ContiguousEnumValues");
static_assert(std::size(dom::binding_detail::EnumStrings<dom::IDBRequestReadyState>::Values) - 1 == UnderlyingValue(value),
"Mismatch between enum strings and enum count");
};
} // namespace mozilla
#endif // DOM_IDBREQUESTBINDING_H_