/* THIS FILE IS AUTOGENERATED FROM SerialPort.webidl BY Codegen.py - DO NOT EDIT */
#ifndef DOM_SERIALPORTBINDING_H_
#define DOM_SERIALPORTBINDING_H_
#include "SerialBinding.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/Nullable.h"
#include "mozilla/dom/PrototypeList.h"
namespace mozilla {
namespace dom {
struct NativePropertyHooks;
class OwningStringOrUnsignedLong;
class ProtoAndIfaceCache;
struct SerialInputSignalsAtoms;
struct SerialOptionsAtoms;
struct SerialOutputSignalsAtoms;
class SerialPort;
struct SerialPortInfoAtoms;
class StringOrUnsignedLong;
} // namespace dom
} // namespace mozilla
namespace mozilla {
namespace dom {
enum class ParityType : uint8_t {
None,
Even,
Odd,
};
namespace binding_detail {
template <> struct EnumStrings<ParityType> {
static constexpr nsLiteralCString Values[3] {
"none"_ns,
"even"_ns,
"odd"_ns,
};
};
} // namespace binding_detail
bool
ToJSValue(JSContext* aCx, ParityType aArgument, JS::MutableHandle<JS::Value> aValue);
enum class FlowControlType : uint8_t {
None,
Hardware,
};
namespace binding_detail {
template <> struct EnumStrings<FlowControlType> {
static constexpr nsLiteralCString Values[2] {
"none"_ns,
"hardware"_ns,
};
};
} // namespace binding_detail
bool
ToJSValue(JSContext* aCx, FlowControlType aArgument, JS::MutableHandle<JS::Value> aValue);
struct SerialInputSignals : public DictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR bool mClearToSend;
MOZ_INIT_OUTSIDE_CTOR bool mDataCarrierDetect;
MOZ_INIT_OUTSIDE_CTOR bool mDataSetReady;
MOZ_INIT_OUTSIDE_CTOR bool mRingIndicator;
SerialInputSignals();
explicit inline SerialInputSignals(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
SerialInputSignals(SerialInputSignals&& aOther) = default;
explicit inline SerialInputSignals(const SerialInputSignals& aOther)
{
*this = aOther;
}
bool
Init(const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
void
TraceDictionary(JSTracer* trc);
SerialInputSignals&
operator=(const SerialInputSignals& aOther);
private:
static bool
InitIds(JSContext* cx, SerialInputSignalsAtoms* atomsCache);
};
namespace binding_detail {
struct FastSerialInputSignals : public SerialInputSignals
{
inline FastSerialInputSignals()
: SerialInputSignals(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
struct SerialOptions : public MaybeEmptyDictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR uint32_t mBaudRate;
uint32_t mBufferSize = 255U;
uint8_t mDataBits = 8;
MOZ_INIT_OUTSIDE_CTOR FlowControlType mFlowControl;
MOZ_INIT_OUTSIDE_CTOR ParityType mParity;
uint8_t mStopBits = 1;
SerialOptions();
explicit inline SerialOptions(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
SerialOptions(SerialOptions&& aOther) = default;
explicit inline SerialOptions(const SerialOptions& 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);
SerialOptions&
operator=(const SerialOptions& aOther);
private:
static bool
InitIds(JSContext* cx, SerialOptionsAtoms* atomsCache);
};
namespace binding_detail {
struct FastSerialOptions : public SerialOptions
{
inline FastSerialOptions()
: SerialOptions(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
struct SerialOutputSignals : public MaybeEmptyDictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR Optional<bool> mBreak;
MOZ_INIT_OUTSIDE_CTOR Optional<bool> mDataTerminalReady;
MOZ_INIT_OUTSIDE_CTOR Optional<bool> mRequestToSend;
SerialOutputSignals();
explicit inline SerialOutputSignals(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
SerialOutputSignals(SerialOutputSignals&& aOther) = default;
explicit inline SerialOutputSignals(const SerialOutputSignals& 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);
SerialOutputSignals&
operator=(const SerialOutputSignals& aOther);
private:
static bool
InitIds(JSContext* cx, SerialOutputSignalsAtoms* atomsCache);
};
namespace binding_detail {
struct FastSerialOutputSignals : public SerialOutputSignals
{
inline FastSerialOutputSignals()
: SerialOutputSignals(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
struct SerialPortInfo : public DictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR Optional<OwningStringOrUnsignedLong> mBluetoothServiceClassId;
MOZ_INIT_OUTSIDE_CTOR Optional<uint16_t> mUsbProductId;
MOZ_INIT_OUTSIDE_CTOR Optional<uint16_t> mUsbVendorId;
SerialPortInfo();
explicit inline SerialPortInfo(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
SerialPortInfo(SerialPortInfo&& aOther) = default;
explicit inline SerialPortInfo(const SerialPortInfo& aOther)
{
*this = aOther;
}
bool
Init(const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
void
TraceDictionary(JSTracer* trc);
SerialPortInfo&
operator=(const SerialPortInfo& aOther);
private:
static bool
InitIds(JSContext* cx, SerialPortInfoAtoms* atomsCache);
};
namespace binding_detail {
struct FastSerialPortInfo : public SerialPortInfo
{
inline FastSerialPortInfo()
: SerialPortInfo(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
namespace SerialPort_Binding {
typedef mozilla::dom::SerialPort NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
bool
Wrap(JSContext* aCx, mozilla::dom::SerialPort* 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::SerialPort,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace SerialPort_Binding
} // namespace dom
template <>
struct MaxContiguousEnumValue<dom::ParityType>
{
static constexpr dom::ParityType value = dom::ParityType::Odd;
static_assert(static_cast<uint8_t>(dom::ParityType::None) == 0,
"We rely on this in ContiguousEnumValues");
static_assert(std::size(dom::binding_detail::EnumStrings<dom::ParityType>::Values) - 1 == UnderlyingValue(value),
"Mismatch between enum strings and enum count");
};
template <>
struct MaxContiguousEnumValue<dom::FlowControlType>
{
static constexpr dom::FlowControlType value = dom::FlowControlType::Hardware;
static_assert(static_cast<uint8_t>(dom::FlowControlType::None) == 0,
"We rely on this in ContiguousEnumValues");
static_assert(std::size(dom::binding_detail::EnumStrings<dom::FlowControlType>::Values) - 1 == UnderlyingValue(value),
"Mismatch between enum strings and enum count");
};
} // namespace mozilla
#endif // DOM_SERIALPORTBINDING_H_