Generated file

Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM Serial.webidl BY Codegen.py - DO NOT EDIT */
#ifndef DOM_SERIALBINDING_H_
#define DOM_SERIALBINDING_H_
#include "js/CallAndConstruct.h"
#include "js/RootingAPI.h"
#include "js/TypeDecls.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/Nullable.h"
#include "mozilla/dom/PrototypeList.h"
#include "mozilla/dom/UnionMember.h"
namespace mozilla {
namespace dom {
struct NativePropertyHooks;
class OwningStringOrUnsignedLong;
class ProtoAndIfaceCache;
class Serial;
struct SerialPortFilter;
struct SerialPortFilterAtoms;
struct SerialPortRequestOptionsAtoms;
class StringOrUnsignedLong;
} // namespace dom
} // namespace mozilla
namespace mozilla::dom {
class StringOrUnsignedLong : public AllUnionBase
{
enum TypeOrUninit
{
eUninitialized,
eString,
eUnsignedLong
};
public:
enum class Type
{
eString = TypeOrUninit::eString,
eUnsignedLong = TypeOrUninit::eUnsignedLong
};
private:
union Value
{
UnionMember<nsAutoString > mString;
UnionMember<uint32_t > mUnsignedLong;
};
TypeOrUninit mType;
Value mValue;
StringOrUnsignedLong(const StringOrUnsignedLong&) = delete;
StringOrUnsignedLong& operator=(const StringOrUnsignedLong&) = delete;
public:
explicit inline StringOrUnsignedLong()
: mType(eUninitialized)
{
}
inline ~StringOrUnsignedLong()
{
Uninit();
}
[[nodiscard]] inline nsAutoString&
RawSetAsString()
{
if (mType == eString) {
return mValue.mString.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eString;
return mValue.mString.SetValue();
}
[[nodiscard]] inline nsAutoString&
SetAsString()
{
if (mType == eString) {
return mValue.mString.Value();
}
Uninit();
mType = eString;
return mValue.mString.SetValue();
}
template <int N>
inline void
SetStringLiteral(const nsString::char_type (&aData)[N])
{
RawSetAsString().AssignLiteral(aData);
}
inline bool
IsString() const
{
return mType == eString;
}
inline nsAutoString&
GetAsString()
{
MOZ_RELEASE_ASSERT(IsString(), "Wrong type!");
return mValue.mString.Value();
}
inline const nsAString&
GetAsString() const
{
MOZ_RELEASE_ASSERT(IsString(), "Wrong type!");
return mValue.mString.Value();
}
[[nodiscard]] inline uint32_t&
RawSetAsUnsignedLong()
{
if (mType == eUnsignedLong) {
return mValue.mUnsignedLong.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eUnsignedLong;
return mValue.mUnsignedLong.SetValue();
}
[[nodiscard]] inline uint32_t&
SetAsUnsignedLong()
{
if (mType == eUnsignedLong) {
return mValue.mUnsignedLong.Value();
}
Uninit();
mType = eUnsignedLong;
return mValue.mUnsignedLong.SetValue();
}
inline bool
IsUnsignedLong() const
{
return mType == eUnsignedLong;
}
inline uint32_t&
GetAsUnsignedLong()
{
MOZ_RELEASE_ASSERT(IsUnsignedLong(), "Wrong type!");
return mValue.mUnsignedLong.Value();
}
inline uint32_t
GetAsUnsignedLong() const
{
MOZ_RELEASE_ASSERT(IsUnsignedLong(), "Wrong type!");
return mValue.mUnsignedLong.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 eString: {
DestroyString();
break;
}
case eUnsignedLong: {
DestroyUnsignedLong();
break;
}
}
}
bool
ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
private:
bool
TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyString()
{
MOZ_RELEASE_ASSERT(IsString(), "Wrong type!");
mValue.mString.Destroy();
mType = eUninitialized;
}
bool
TrySetToUnsignedLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyUnsignedLong()
{
MOZ_RELEASE_ASSERT(IsUnsignedLong(), "Wrong type!");
mValue.mUnsignedLong.Destroy();
mType = eUninitialized;
}
};
class OwningStringOrUnsignedLong : public AllOwningUnionBase
{
enum TypeOrUninit
{
eUninitialized,
eString,
eUnsignedLong
};
public:
enum class Type
{
eString = TypeOrUninit::eString,
eUnsignedLong = TypeOrUninit::eUnsignedLong
};
private:
union Value
{
UnionMember<nsString > mString;
UnionMember<uint32_t > mUnsignedLong;
};
TypeOrUninit mType;
Value mValue;
public:
explicit inline OwningStringOrUnsignedLong()
: mType(eUninitialized)
{
}
OwningStringOrUnsignedLong(OwningStringOrUnsignedLong&& aOther);
explicit inline OwningStringOrUnsignedLong(const OwningStringOrUnsignedLong& aOther)
: mType(eUninitialized)
{
*this = aOther;
}
inline ~OwningStringOrUnsignedLong()
{
Uninit();
}
[[nodiscard]] nsString&
RawSetAsString();
[[nodiscard]] nsString&
SetAsString();
template <int N>
inline void
SetStringLiteral(const nsString::char_type (&aData)[N])
{
RawSetAsString().AssignLiteral(aData);
}
inline bool
IsString() const
{
return mType == eString;
}
inline nsString&
GetAsString()
{
MOZ_RELEASE_ASSERT(IsString(), "Wrong type!");
return mValue.mString.Value();
}
inline nsString const &
GetAsString() const
{
MOZ_RELEASE_ASSERT(IsString(), "Wrong type!");
return mValue.mString.Value();
}
[[nodiscard]] uint32_t&
RawSetAsUnsignedLong();
[[nodiscard]] uint32_t&
SetAsUnsignedLong();
inline bool
IsUnsignedLong() const
{
return mType == eUnsignedLong;
}
inline uint32_t&
GetAsUnsignedLong()
{
MOZ_RELEASE_ASSERT(IsUnsignedLong(), "Wrong type!");
return mValue.mUnsignedLong.Value();
}
inline uint32_t const &
GetAsUnsignedLong() const
{
MOZ_RELEASE_ASSERT(IsUnsignedLong(), "Wrong type!");
return mValue.mUnsignedLong.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;
OwningStringOrUnsignedLong&
operator=(OwningStringOrUnsignedLong&& aOther);
inline Type
GetType() const
{
MOZ_RELEASE_ASSERT(mType != eUninitialized);
return static_cast<Type>(mType);
}
OwningStringOrUnsignedLong&
operator=(const OwningStringOrUnsignedLong& aOther);
private:
bool
TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyString();
bool
TrySetToUnsignedLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyUnsignedLong();
};
struct SerialPortFilter : public MaybeEmptyDictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR Optional<OwningStringOrUnsignedLong> mBluetoothServiceClassId;
MOZ_INIT_OUTSIDE_CTOR Optional<uint16_t> mUsbProductId;
MOZ_INIT_OUTSIDE_CTOR Optional<uint16_t> mUsbVendorId;
SerialPortFilter();
explicit inline SerialPortFilter(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
SerialPortFilter(SerialPortFilter&& aOther) = default;
explicit inline SerialPortFilter(const SerialPortFilter& aOther)
{
*this = aOther;
}
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);
SerialPortFilter&
operator=(const SerialPortFilter& aOther);
private:
static bool
InitIds(JSContext* cx, SerialPortFilterAtoms* atomsCache);
};
namespace binding_detail {
struct FastSerialPortFilter : public SerialPortFilter
{
inline FastSerialPortFilter()
: SerialPortFilter(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
struct SerialPortRequestOptions : public MaybeEmptyDictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR Optional<Sequence<OwningStringOrUnsignedLong>> mAllowedBluetoothServiceClassIds;
MOZ_INIT_OUTSIDE_CTOR Optional<Sequence<SerialPortFilter>> mFilters;
SerialPortRequestOptions();
explicit inline SerialPortRequestOptions(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
SerialPortRequestOptions(SerialPortRequestOptions&& aOther) = default;
explicit inline SerialPortRequestOptions(const SerialPortRequestOptions& aOther)
{
*this = aOther;
}
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);
SerialPortRequestOptions&
operator=(const SerialPortRequestOptions& aOther);
private:
static bool
InitIds(JSContext* cx, SerialPortRequestOptionsAtoms* atomsCache);
};
namespace binding_detail {
struct FastSerialPortRequestOptions : public SerialPortRequestOptions
{
inline FastSerialPortRequestOptions()
: SerialPortRequestOptions(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
namespace Serial_Binding {
typedef mozilla::dom::Serial NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
bool
Wrap(JSContext* aCx, mozilla::dom::Serial* 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::Serial,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace Serial_Binding
} // namespace mozilla::dom
#endif // DOM_SERIALBINDING_H_