/* THIS FILE IS AUTOGENERATED FROM HWInference.webidl BY Codegen.py - DO NOT EDIT */
#ifndef DOM_HWINFERENCEBINDING_H_
#define DOM_HWINFERENCEBINDING_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 {
class HWInference;
struct HWInferenceDeviceAtoms;
struct HWInferencePlacementAtoms;
struct NativePropertyHooks;
class ProtoAndIfaceCache;
} // namespace dom
} // namespace mozilla
namespace mozilla {
namespace dom {
enum class HWInferenceDeviceKind : uint8_t {
Cpu,
Gpu,
Npu,
};
namespace binding_detail {
template <> struct EnumStrings<HWInferenceDeviceKind> {
static constexpr nsLiteralCString Values[3] {
"cpu"_ns,
"gpu"_ns,
"npu"_ns,
};
};
} // namespace binding_detail
bool
ToJSValue(JSContext* aCx, HWInferenceDeviceKind aArgument, JS::MutableHandle<JS::Value> aValue);
enum class HWInferenceBackend : uint8_t {
Llama_cpp,
};
namespace binding_detail {
template <> struct EnumStrings<HWInferenceBackend> {
static constexpr nsLiteralCString Values[1] {
"llama.cpp"_ns,
};
};
} // namespace binding_detail
bool
ToJSValue(JSContext* aCx, HWInferenceBackend aArgument, JS::MutableHandle<JS::Value> aValue);
struct MOZ_EMPTY_BASES HWInferenceDevice : public DictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR Sequence<HWInferenceBackend> mBackends;
MOZ_INIT_OUTSIDE_CTOR nsCString mDescription;
MOZ_INIT_OUTSIDE_CTOR nsCString mId;
HWInferenceDeviceKind mKind = {};
HWInferenceDevice();
explicit inline HWInferenceDevice(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
HWInferenceDevice(HWInferenceDevice&& aOther) = default;
explicit inline HWInferenceDevice(const HWInferenceDevice& 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);
HWInferenceDevice&
operator=(const HWInferenceDevice& aOther);
private:
static bool
InitIds(JSContext* cx, HWInferenceDeviceAtoms* atomsCache);
};
namespace binding_detail {
struct MOZ_EMPTY_BASES FastHWInferenceDevice : public HWInferenceDevice
{
inline FastHWInferenceDevice()
: HWInferenceDevice(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
struct MOZ_EMPTY_BASES HWInferencePlacement : public MaybeEmptyDictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR Sequence<nsCString> mDevices;
MOZ_INIT_OUTSIDE_CTOR Sequence<HWInferenceDeviceKind> mKinds;
HWInferencePlacement();
explicit inline HWInferencePlacement(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
HWInferencePlacement(HWInferencePlacement&& aOther) = default;
explicit inline HWInferencePlacement(const HWInferencePlacement& 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);
HWInferencePlacement&
operator=(const HWInferencePlacement& aOther);
private:
static bool
InitIds(JSContext* cx, HWInferencePlacementAtoms* atomsCache);
};
namespace binding_detail {
struct MOZ_EMPTY_BASES FastHWInferencePlacement : public HWInferencePlacement
{
inline FastHWInferencePlacement()
: HWInferencePlacement(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
namespace HWInference_Binding {
typedef mozilla::dom::HWInference NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
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::HWInference,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace HWInference_Binding
} // namespace dom
template <>
struct MaxContiguousEnumValue<dom::HWInferenceDeviceKind>
{
static constexpr dom::HWInferenceDeviceKind value = dom::HWInferenceDeviceKind::Npu;
static_assert(static_cast<uint8_t>(dom::HWInferenceDeviceKind::Cpu) == 0,
"We rely on this in ContiguousEnumValues");
static_assert(std::size(dom::binding_detail::EnumStrings<dom::HWInferenceDeviceKind>::Values) - 1 == UnderlyingValue(value),
"Mismatch between enum strings and enum count");
};
template <>
struct MaxContiguousEnumValue<dom::HWInferenceBackend>
{
static constexpr dom::HWInferenceBackend value = dom::HWInferenceBackend::Llama_cpp;
static_assert(static_cast<uint8_t>(dom::HWInferenceBackend::Llama_cpp) == 0,
"We rely on this in ContiguousEnumValues");
static_assert(std::size(dom::binding_detail::EnumStrings<dom::HWInferenceBackend>::Values) - 1 == UnderlyingValue(value),
"Mismatch between enum strings and enum count");
};
} // namespace mozilla
#endif // DOM_HWINFERENCEBINDING_H_