Copy as Markdown
Other Tools
/* THIS FILE IS AUTOGENERATED FROM Permissions.webidl BY Codegen.py - DO NOT EDIT */
#ifndef DOM_PERMISSIONSBINDING_H_
#define DOM_PERMISSIONSBINDING_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 MidiPermissionDescriptorAtoms;
struct NativePropertyHooks;
struct PermissionDescriptorAtoms;
class Permissions;
class ProtoAndIfaceCache;
} // namespace dom
} // namespace mozilla
namespace mozilla {
namespace dom {
enum class PermissionName : uint8_t {
Geolocation,
Notifications,
Push,
Persistent_storage,
Midi,
Storage_access,
Screen_wake_lock,
Camera,
Microphone,
};
namespace binding_detail {
template <> struct EnumStrings<PermissionName> {
static constexpr nsLiteralCString Values[9] {
"geolocation"_ns,
"notifications"_ns,
"push"_ns,
"persistent-storage"_ns,
"midi"_ns,
"storage-access"_ns,
"screen-wake-lock"_ns,
"camera"_ns,
"microphone"_ns,
};
};
} // namespace binding_detail
bool
ToJSValue(JSContext* aCx, PermissionName aArgument, JS::MutableHandle<JS::Value> aValue);
struct PermissionDescriptor : public DictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR PermissionName mName;
PermissionDescriptor();
explicit inline PermissionDescriptor(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
PermissionDescriptor(PermissionDescriptor&& aOther) = default;
explicit inline PermissionDescriptor(const PermissionDescriptor& 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);
PermissionDescriptor&
operator=(const PermissionDescriptor& aOther);
private:
static bool
InitIds(JSContext* cx, PermissionDescriptorAtoms* atomsCache);
};
namespace binding_detail {
struct FastPermissionDescriptor : public PermissionDescriptor
{
inline FastPermissionDescriptor()
: PermissionDescriptor(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
struct MidiPermissionDescriptor : public PermissionDescriptor
{
MOZ_INIT_OUTSIDE_CTOR bool mSysex;
MidiPermissionDescriptor();
explicit inline MidiPermissionDescriptor(const FastDictionaryInitializer& )
: PermissionDescriptor(FastDictionaryInitializer())
{
// Do nothing here; this is used by our "Fast" subclass
}
MidiPermissionDescriptor(MidiPermissionDescriptor&& aOther) = default;
explicit inline MidiPermissionDescriptor(const MidiPermissionDescriptor& aOther)
: PermissionDescriptor(FastDictionaryInitializer())
{
*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);
MidiPermissionDescriptor&
operator=(const MidiPermissionDescriptor& aOther);
private:
static bool
InitIds(JSContext* cx, MidiPermissionDescriptorAtoms* atomsCache);
};
namespace binding_detail {
struct FastMidiPermissionDescriptor : public MidiPermissionDescriptor
{
inline FastMidiPermissionDescriptor()
: MidiPermissionDescriptor(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
namespace Permissions_Binding {
typedef mozilla::dom::Permissions NativeType;
bool
Wrap(JSContext* aCx, mozilla::dom::Permissions* 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::Permissions,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace Permissions_Binding
} // namespace dom
template <>
struct MaxContiguousEnumValue<dom::PermissionName>
{
static constexpr dom::PermissionName value = dom::PermissionName::Microphone;
static_assert(static_cast<uint8_t>(dom::PermissionName::Geolocation) == 0,
"We rely on this in ContiguousEnumValues");
static_assert(std::size(dom::binding_detail::EnumStrings<dom::PermissionName>::Values) - 1 == UnderlyingValue(value),
"Mismatch between enum strings and enum count");
};
} // namespace mozilla
#endif // DOM_PERMISSIONSBINDING_H_