Copy as Markdown
Other Tools
/* THIS FILE IS AUTOGENERATED FROM PushEvent.webidl BY Codegen.py - DO NOT EDIT */
#ifndef DOM_PUSHEVENTBINDING_H_
#define DOM_PUSHEVENTBINDING_H_
#include "ExtendableEventBinding.h"
#include "js/CallAndConstruct.h"
#include "js/RootingAPI.h"
#include "js/TypeDecls.h"
#include "js/Value.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/FakeString.h"
#include "mozilla/dom/Nullable.h"
#include "mozilla/dom/PrototypeList.h"
#include "mozilla/dom/TypedArray.h"
#include "mozilla/dom/UnionMember.h"
namespace mozilla {
namespace dom {
class ArrayBufferViewOrArrayBufferOrUSVString;
struct NativePropertyHooks;
class OwningArrayBufferViewOrArrayBufferOrUSVString;
class ProtoAndIfaceCache;
class PushEvent;
struct PushEventInitAtoms;
} // namespace dom
} // namespace mozilla
namespace mozilla::dom {
class ArrayBufferViewOrArrayBufferOrUSVString : public AllUnionBase,
public UnionWithTypedArraysBase
{
public:
using ApplyToTypedArrays = binding_detail::ApplyToTypedArraysHelper<ArrayBufferViewOrArrayBufferOrUSVString, true, ArrayBufferView, ArrayBuffer>;
private:
enum TypeOrUninit
{
eUninitialized,
eArrayBufferView,
eArrayBuffer,
eUSVString
};
public:
enum class Type
{
eArrayBufferView = TypeOrUninit::eArrayBufferView,
eArrayBuffer = TypeOrUninit::eArrayBuffer,
eUSVString = TypeOrUninit::eUSVString
};
private:
union Value
{
UnionMember<RootedSpiderMonkeyInterface<ArrayBufferView> > mArrayBufferView;
UnionMember<RootedSpiderMonkeyInterface<ArrayBuffer> > mArrayBuffer;
UnionMember<binding_detail::FakeString<char16_t> > mUSVString;
};
TypeOrUninit mType;
Value mValue;
ArrayBufferViewOrArrayBufferOrUSVString(const ArrayBufferViewOrArrayBufferOrUSVString&) = delete;
ArrayBufferViewOrArrayBufferOrUSVString& operator=(const ArrayBufferViewOrArrayBufferOrUSVString&) = delete;
public:
explicit inline ArrayBufferViewOrArrayBufferOrUSVString()
: mType(eUninitialized)
{
}
inline ~ArrayBufferViewOrArrayBufferOrUSVString()
{
Uninit();
}
[[nodiscard]] inline RootedSpiderMonkeyInterface<ArrayBufferView>&
RawSetAsArrayBufferView(JSContext* cx)
{
if (mType == eArrayBufferView) {
return mValue.mArrayBufferView.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eArrayBufferView;
return mValue.mArrayBufferView.SetValue(cx);
}
[[nodiscard]] inline RootedSpiderMonkeyInterface<ArrayBufferView>&
SetAsArrayBufferView(JSContext* cx)
{
if (mType == eArrayBufferView) {
return mValue.mArrayBufferView.Value();
}
Uninit();
mType = eArrayBufferView;
return mValue.mArrayBufferView.SetValue(cx);
}
inline bool
IsArrayBufferView() const
{
return mType == eArrayBufferView;
}
inline RootedSpiderMonkeyInterface<ArrayBufferView>&
GetAsArrayBufferView()
{
MOZ_RELEASE_ASSERT(IsArrayBufferView(), "Wrong type!");
return mValue.mArrayBufferView.Value();
}
inline ArrayBufferView const &
GetAsArrayBufferView() const
{
MOZ_RELEASE_ASSERT(IsArrayBufferView(), "Wrong type!");
return mValue.mArrayBufferView.Value();
}
[[nodiscard]] inline RootedSpiderMonkeyInterface<ArrayBuffer>&
RawSetAsArrayBuffer(JSContext* cx)
{
if (mType == eArrayBuffer) {
return mValue.mArrayBuffer.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eArrayBuffer;
return mValue.mArrayBuffer.SetValue(cx);
}
[[nodiscard]] inline RootedSpiderMonkeyInterface<ArrayBuffer>&
SetAsArrayBuffer(JSContext* cx)
{
if (mType == eArrayBuffer) {
return mValue.mArrayBuffer.Value();
}
Uninit();
mType = eArrayBuffer;
return mValue.mArrayBuffer.SetValue(cx);
}
inline bool
IsArrayBuffer() const
{
return mType == eArrayBuffer;
}
inline RootedSpiderMonkeyInterface<ArrayBuffer>&
GetAsArrayBuffer()
{
MOZ_RELEASE_ASSERT(IsArrayBuffer(), "Wrong type!");
return mValue.mArrayBuffer.Value();
}
inline ArrayBuffer const &
GetAsArrayBuffer() const
{
MOZ_RELEASE_ASSERT(IsArrayBuffer(), "Wrong type!");
return mValue.mArrayBuffer.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 eArrayBufferView: {
DestroyArrayBufferView();
break;
}
case eArrayBuffer: {
DestroyArrayBuffer();
break;
}
case eUSVString: {
DestroyUSVString();
break;
}
}
}
bool
ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
private:
bool
TrySetToArrayBufferView(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToArrayBufferView(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyArrayBufferView()
{
MOZ_RELEASE_ASSERT(IsArrayBufferView(), "Wrong type!");
mValue.mArrayBufferView.Destroy();
mType = eUninitialized;
}
bool
TrySetToArrayBuffer(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToArrayBuffer(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyArrayBuffer()
{
MOZ_RELEASE_ASSERT(IsArrayBuffer(), "Wrong type!");
mValue.mArrayBuffer.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 OwningArrayBufferViewOrArrayBufferOrUSVString : public AllOwningUnionBase,
public UnionWithTypedArraysBase
{
public:
using ApplyToTypedArrays = binding_detail::ApplyToTypedArraysHelper<OwningArrayBufferViewOrArrayBufferOrUSVString, true, ArrayBufferView, ArrayBuffer>;
private:
enum TypeOrUninit
{
eUninitialized,
eArrayBufferView,
eArrayBuffer,
eUSVString
};
public:
enum class Type
{
eArrayBufferView = TypeOrUninit::eArrayBufferView,
eArrayBuffer = TypeOrUninit::eArrayBuffer,
eUSVString = TypeOrUninit::eUSVString
};
private:
union Value
{
UnionMember<ArrayBufferView > mArrayBufferView;
UnionMember<ArrayBuffer > mArrayBuffer;
UnionMember<nsString > mUSVString;
};
TypeOrUninit mType;
Value mValue;
OwningArrayBufferViewOrArrayBufferOrUSVString(const OwningArrayBufferViewOrArrayBufferOrUSVString&) = delete;
OwningArrayBufferViewOrArrayBufferOrUSVString& operator=(const OwningArrayBufferViewOrArrayBufferOrUSVString&) = delete;
public:
explicit inline OwningArrayBufferViewOrArrayBufferOrUSVString()
: mType(eUninitialized)
{
}
OwningArrayBufferViewOrArrayBufferOrUSVString(OwningArrayBufferViewOrArrayBufferOrUSVString&& aOther);
inline ~OwningArrayBufferViewOrArrayBufferOrUSVString()
{
Uninit();
}
[[nodiscard]] ArrayBufferView&
RawSetAsArrayBufferView();
[[nodiscard]] ArrayBufferView&
SetAsArrayBufferView();
inline bool
IsArrayBufferView() const
{
return mType == eArrayBufferView;
}
inline ArrayBufferView&
GetAsArrayBufferView()
{
MOZ_RELEASE_ASSERT(IsArrayBufferView(), "Wrong type!");
return mValue.mArrayBufferView.Value();
}
inline ArrayBufferView const &
GetAsArrayBufferView() const
{
MOZ_RELEASE_ASSERT(IsArrayBufferView(), "Wrong type!");
return mValue.mArrayBufferView.Value();
}
[[nodiscard]] ArrayBuffer&
RawSetAsArrayBuffer();
[[nodiscard]] ArrayBuffer&
SetAsArrayBuffer();
inline bool
IsArrayBuffer() const
{
return mType == eArrayBuffer;
}
inline ArrayBuffer&
GetAsArrayBuffer()
{
MOZ_RELEASE_ASSERT(IsArrayBuffer(), "Wrong type!");
return mValue.mArrayBuffer.Value();
}
inline ArrayBuffer const &
GetAsArrayBuffer() const
{
MOZ_RELEASE_ASSERT(IsArrayBuffer(), "Wrong type!");
return mValue.mArrayBuffer.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;
void
TraceUnion(JSTracer* trc);
OwningArrayBufferViewOrArrayBufferOrUSVString&
operator=(OwningArrayBufferViewOrArrayBufferOrUSVString&& aOther);
inline Type
GetType() const
{
MOZ_RELEASE_ASSERT(mType != eUninitialized);
return static_cast<Type>(mType);
}
private:
bool
TrySetToArrayBufferView(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToArrayBufferView(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyArrayBufferView();
bool
TrySetToArrayBuffer(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToArrayBuffer(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyArrayBuffer();
bool
TrySetToUSVString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyUSVString();
};
struct PushEventInit : public ExtendableEventInit
{
MOZ_INIT_OUTSIDE_CTOR Optional<OwningArrayBufferViewOrArrayBufferOrUSVString> mData;
PushEventInit();
explicit inline PushEventInit(const FastDictionaryInitializer& )
: ExtendableEventInit(FastDictionaryInitializer())
{
// Do nothing here; this is used by our "Fast" subclass
}
PushEventInit(PushEventInit&& aOther) = default;
private:
PushEventInit(const PushEventInit&) = delete;
PushEventInit& operator=(const PushEventInit&) = delete;
static bool
InitIds(JSContext* cx, PushEventInitAtoms* 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);
void
TraceDictionary(JSTracer* trc);
};
namespace binding_detail {
struct FastPushEventInit : public PushEventInit
{
inline FastPushEventInit()
: PushEventInit(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
namespace PushEvent_Binding {
typedef mozilla::dom::PushEvent NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
bool
Wrap(JSContext* aCx, mozilla::dom::PushEvent* 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::PushEvent,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace PushEvent_Binding
} // namespace mozilla::dom
#endif // DOM_PUSHEVENTBINDING_H_