Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM FormData.webidl BY Codegen.py - DO NOT EDIT */
#ifndef DOM_FORMDATABINDING_H_
#define DOM_FORMDATABINDING_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 {
class Blob;
class BlobOrDirectoryOrUSVString;
class Directory;
class FormData;
struct NativePropertyHooks;
class OwningBlobOrDirectoryOrUSVString;
class ProtoAndIfaceCache;
} // namespace dom
} // namespace mozilla
namespace mozilla::dom {
void
ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningBlobOrDirectoryOrUSVString& aUnion, const char* aName, uint32_t aFlags = 0);
void
ImplCycleCollectionUnlink(OwningBlobOrDirectoryOrUSVString& aUnion);
class BlobOrDirectoryOrUSVString : public AllUnionBase
{
enum TypeOrUninit
{
eUninitialized,
eBlob,
eDirectory,
eUSVString
};
public:
enum class Type
{
eBlob = TypeOrUninit::eBlob,
eDirectory = TypeOrUninit::eDirectory,
eUSVString = TypeOrUninit::eUSVString
};
private:
union Value
{
UnionMember<NonNull<mozilla::dom::Blob> > mBlob;
UnionMember<NonNull<mozilla::dom::Directory> > mDirectory;
UnionMember<binding_detail::FakeString<char16_t> > mUSVString;
};
TypeOrUninit mType;
Value mValue;
BlobOrDirectoryOrUSVString(const BlobOrDirectoryOrUSVString&) = delete;
BlobOrDirectoryOrUSVString& operator=(const BlobOrDirectoryOrUSVString&) = delete;
public:
explicit inline BlobOrDirectoryOrUSVString()
: mType(eUninitialized)
{
}
inline ~BlobOrDirectoryOrUSVString()
{
Uninit();
}
[[nodiscard]] inline NonNull<mozilla::dom::Blob>&
RawSetAsBlob()
{
if (mType == eBlob) {
return mValue.mBlob.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eBlob;
return mValue.mBlob.SetValue();
}
[[nodiscard]] inline NonNull<mozilla::dom::Blob>&
SetAsBlob()
{
if (mType == eBlob) {
return mValue.mBlob.Value();
}
Uninit();
mType = eBlob;
return mValue.mBlob.SetValue();
}
inline bool
IsBlob() const
{
return mType == eBlob;
}
inline NonNull<mozilla::dom::Blob>&
GetAsBlob()
{
MOZ_RELEASE_ASSERT(IsBlob(), "Wrong type!");
return mValue.mBlob.Value();
}
inline mozilla::dom::Blob&
GetAsBlob() const
{
MOZ_RELEASE_ASSERT(IsBlob(), "Wrong type!");
return mValue.mBlob.Value();
}
[[nodiscard]] inline NonNull<mozilla::dom::Directory>&
RawSetAsDirectory()
{
if (mType == eDirectory) {
return mValue.mDirectory.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eDirectory;
return mValue.mDirectory.SetValue();
}
[[nodiscard]] inline NonNull<mozilla::dom::Directory>&
SetAsDirectory()
{
if (mType == eDirectory) {
return mValue.mDirectory.Value();
}
Uninit();
mType = eDirectory;
return mValue.mDirectory.SetValue();
}
inline bool
IsDirectory() const
{
return mType == eDirectory;
}
inline NonNull<mozilla::dom::Directory>&
GetAsDirectory()
{
MOZ_RELEASE_ASSERT(IsDirectory(), "Wrong type!");
return mValue.mDirectory.Value();
}
inline mozilla::dom::Directory&
GetAsDirectory() const
{
MOZ_RELEASE_ASSERT(IsDirectory(), "Wrong type!");
return mValue.mDirectory.Value();
}
[[nodiscard]] inline binding_detail::FakeString<char16_t>&
RawSetAsUSVString()
{
if (mType == eUSVString) {
return mValue.mUSVString.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eUSVString;
return mValue.mUSVString.SetValue();
}
[[nodiscard]] inline binding_detail::FakeString<char16_t>&
SetAsUSVString()
{
if (mType == eUSVString) {
return mValue.mUSVString.Value();
}
Uninit();
mType = eUSVString;
return mValue.mUSVString.SetValue();
}
template <int N>
inline void
SetStringLiteral(const nsString::char_type (&aData)[N])
{
RawSetAsUSVString().AssignLiteral(aData);
}
inline bool
IsUSVString() const
{
return mType == eUSVString;
}
inline binding_detail::FakeString<char16_t>&
GetAsUSVString()
{
MOZ_RELEASE_ASSERT(IsUSVString(), "Wrong type!");
return mValue.mUSVString.Value();
}
inline const nsAString&
GetAsUSVString() const
{
MOZ_RELEASE_ASSERT(IsUSVString(), "Wrong type!");
return mValue.mUSVString.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 eBlob: {
DestroyBlob();
break;
}
case eDirectory: {
DestroyDirectory();
break;
}
case eUSVString: {
DestroyUSVString();
break;
}
}
}
bool
ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
private:
bool
TrySetToBlob(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToBlob(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyBlob()
{
MOZ_RELEASE_ASSERT(IsBlob(), "Wrong type!");
mValue.mBlob.Destroy();
mType = eUninitialized;
}
bool
TrySetToDirectory(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToDirectory(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyDirectory()
{
MOZ_RELEASE_ASSERT(IsDirectory(), "Wrong type!");
mValue.mDirectory.Destroy();
mType = eUninitialized;
}
bool
TrySetToUSVString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyUSVString()
{
MOZ_RELEASE_ASSERT(IsUSVString(), "Wrong type!");
mValue.mUSVString.Destroy();
mType = eUninitialized;
}
};
class OwningBlobOrDirectoryOrUSVString : public AllOwningUnionBase
{
friend void ImplCycleCollectionUnlink(OwningBlobOrDirectoryOrUSVString& aUnion);
enum TypeOrUninit
{
eUninitialized,
eBlob,
eDirectory,
eUSVString
};
public:
enum class Type
{
eBlob = TypeOrUninit::eBlob,
eDirectory = TypeOrUninit::eDirectory,
eUSVString = TypeOrUninit::eUSVString
};
private:
union Value
{
UnionMember<OwningNonNull<mozilla::dom::Blob> > mBlob;
UnionMember<OwningNonNull<mozilla::dom::Directory> > mDirectory;
UnionMember<nsString > mUSVString;
};
TypeOrUninit mType;
Value mValue;
public:
explicit inline OwningBlobOrDirectoryOrUSVString()
: mType(eUninitialized)
{
}
OwningBlobOrDirectoryOrUSVString(OwningBlobOrDirectoryOrUSVString&& aOther);
explicit inline OwningBlobOrDirectoryOrUSVString(const OwningBlobOrDirectoryOrUSVString& aOther)
: mType(eUninitialized)
{
*this = aOther;
}
inline ~OwningBlobOrDirectoryOrUSVString()
{
Uninit();
}
[[nodiscard]] OwningNonNull<mozilla::dom::Blob>&
RawSetAsBlob();
[[nodiscard]] OwningNonNull<mozilla::dom::Blob>&
SetAsBlob();
inline bool
IsBlob() const
{
return mType == eBlob;
}
inline OwningNonNull<mozilla::dom::Blob>&
GetAsBlob()
{
MOZ_RELEASE_ASSERT(IsBlob(), "Wrong type!");
return mValue.mBlob.Value();
}
inline OwningNonNull<mozilla::dom::Blob> const &
GetAsBlob() const
{
MOZ_RELEASE_ASSERT(IsBlob(), "Wrong type!");
return mValue.mBlob.Value();
}
[[nodiscard]] OwningNonNull<mozilla::dom::Directory>&
RawSetAsDirectory();
[[nodiscard]] OwningNonNull<mozilla::dom::Directory>&
SetAsDirectory();
inline bool
IsDirectory() const
{
return mType == eDirectory;
}
inline OwningNonNull<mozilla::dom::Directory>&
GetAsDirectory()
{
MOZ_RELEASE_ASSERT(IsDirectory(), "Wrong type!");
return mValue.mDirectory.Value();
}
inline OwningNonNull<mozilla::dom::Directory> const &
GetAsDirectory() const
{
MOZ_RELEASE_ASSERT(IsDirectory(), "Wrong type!");
return mValue.mDirectory.Value();
}
[[nodiscard]] nsString&
RawSetAsUSVString();
[[nodiscard]] nsString&
SetAsUSVString();
template <int N>
inline void
SetStringLiteral(const nsString::char_type (&aData)[N])
{
RawSetAsUSVString().AssignLiteral(aData);
}
inline bool
IsUSVString() const
{
return mType == eUSVString;
}
inline nsString&
GetAsUSVString()
{
MOZ_RELEASE_ASSERT(IsUSVString(), "Wrong type!");
return mValue.mUSVString.Value();
}
inline nsString const &
GetAsUSVString() const
{
MOZ_RELEASE_ASSERT(IsUSVString(), "Wrong type!");
return mValue.mUSVString.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;
OwningBlobOrDirectoryOrUSVString&
operator=(OwningBlobOrDirectoryOrUSVString&& aOther);
inline Type
GetType() const
{
MOZ_RELEASE_ASSERT(mType != eUninitialized);
return static_cast<Type>(mType);
}
OwningBlobOrDirectoryOrUSVString&
operator=(const OwningBlobOrDirectoryOrUSVString& aOther);
private:
bool
TrySetToBlob(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToBlob(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyBlob();
bool
TrySetToDirectory(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToDirectory(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyDirectory();
bool
TrySetToUSVString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyUSVString();
};
namespace FormData_Binding {
typedef mozilla::dom::FormData NativeType;
bool
Wrap(JSContext* aCx, mozilla::dom::FormData* 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, bool aDefineOnGlobal);
inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx)
{
/* Get the interface prototype object for this class. This will create the
object as needed. */
return GetPerInterfaceObjectHandle(aCx, prototypes::id::FormData,
&CreateInterfaceObjects,
/* aDefineOnGlobal = */ true);
}
inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true)
{
/* Get the interface object for this class. This will create the object as
needed. */
return GetPerInterfaceObjectHandle(aCx, constructors::id::FormData,
&CreateInterfaceObjects,
aDefineOnGlobal);
}
JSObject*
GetConstructorObject(JSContext* aCx);
} // namespace FormData_Binding
} // namespace mozilla::dom
#endif // DOM_FORMDATABINDING_H_