Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM Fluent.webidl BY Codegen.py - DO NOT EDIT */
#ifndef DOM_FLUENTBINDING_H_
#define DOM_FLUENTBINDING_H_
#include "js/CallAndConstruct.h"
#include "js/RootingAPI.h"
#include "js/TypeDecls.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/FakeString.h"
#include "mozilla/dom/Nullable.h"
#include "mozilla/dom/PrototypeList.h"
#include "mozilla/dom/Record.h"
#include "mozilla/dom/UnionMember.h"
#include "mozilla/intl/FluentBundle.h"
namespace mozilla {
namespace dom {
struct FluentBundleAddResourceOptionsAtoms;
struct FluentBundleOptionsAtoms;
struct FluentMessageAtoms;
struct FluentTextElementItemAtoms;
struct NativePropertyHooks;
class ProtoAndIfaceCache;
} // namespace dom
namespace intl {
class FluentBundle;
class FluentPattern;
class FluentResource;
} // namespace intl
} // namespace mozilla
namespace mozilla::dom {
struct FluentBundleAddResourceOptions : public DictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR bool mAllowOverrides;
FluentBundleAddResourceOptions();
explicit inline FluentBundleAddResourceOptions(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
FluentBundleAddResourceOptions(FluentBundleAddResourceOptions&& aOther) = default;
explicit inline FluentBundleAddResourceOptions(const FluentBundleAddResourceOptions& 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);
FluentBundleAddResourceOptions&
operator=(const FluentBundleAddResourceOptions& aOther);
private:
static bool
InitIds(JSContext* cx, FluentBundleAddResourceOptionsAtoms* atomsCache);
};
namespace binding_detail {
struct FastFluentBundleAddResourceOptions : public FluentBundleAddResourceOptions
{
inline FastFluentBundleAddResourceOptions()
: FluentBundleAddResourceOptions(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
struct FluentBundleOptions : public DictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR Optional<nsCString> mPseudoStrategy;
MOZ_INIT_OUTSIDE_CTOR bool mUseIsolating;
FluentBundleOptions();
explicit inline FluentBundleOptions(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
FluentBundleOptions(FluentBundleOptions&& aOther) = default;
explicit inline FluentBundleOptions(const FluentBundleOptions& 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);
FluentBundleOptions&
operator=(const FluentBundleOptions& aOther);
private:
static bool
InitIds(JSContext* cx, FluentBundleOptionsAtoms* atomsCache);
};
namespace binding_detail {
struct FastFluentBundleOptions : public FluentBundleOptions
{
inline FastFluentBundleOptions()
: FluentBundleOptions(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
struct FluentMessage : public DictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR Record<nsCString, OwningNonNull<mozilla::intl::FluentPattern>> mAttributes;
MOZ_INIT_OUTSIDE_CTOR RefPtr<mozilla::intl::FluentPattern> mValue;
FluentMessage();
explicit inline FluentMessage(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
FluentMessage(FluentMessage&& aOther) = default;
private:
FluentMessage(const FluentMessage&) = delete;
FluentMessage& operator=(const FluentMessage&) = delete;
static bool
InitIds(JSContext* cx, FluentMessageAtoms* atomsCache);
public:
bool
Init(const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
void
TraceDictionary(JSTracer* trc);
};
namespace binding_detail {
struct FastFluentMessage : public FluentMessage
{
inline FastFluentMessage()
: FluentMessage(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
struct FluentTextElementItem : public DictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR Optional<nsCString> mAttr;
MOZ_INIT_OUTSIDE_CTOR Optional<nsCString> mId;
MOZ_INIT_OUTSIDE_CTOR Optional<nsCString> mText;
FluentTextElementItem();
explicit inline FluentTextElementItem(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
FluentTextElementItem(FluentTextElementItem&& aOther) = default;
explicit inline FluentTextElementItem(const FluentTextElementItem& 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);
FluentTextElementItem&
operator=(const FluentTextElementItem& aOther);
private:
static bool
InitIds(JSContext* cx, FluentTextElementItemAtoms* atomsCache);
};
namespace binding_detail {
struct FastFluentTextElementItem : public FluentTextElementItem
{
inline FastFluentTextElementItem()
: FluentTextElementItem(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
class UTF8StringOrDouble : public AllUnionBase
{
enum TypeOrUninit
{
eUninitialized,
eUTF8String,
eDouble
};
public:
enum class Type
{
eUTF8String = TypeOrUninit::eUTF8String,
eDouble = TypeOrUninit::eDouble
};
private:
union Value
{
UnionMember<binding_detail::FakeString<char> > mUTF8String;
UnionMember<double > mDouble;
};
TypeOrUninit mType;
Value mValue;
UTF8StringOrDouble(const UTF8StringOrDouble&) = delete;
UTF8StringOrDouble& operator=(const UTF8StringOrDouble&) = delete;
public:
explicit inline UTF8StringOrDouble()
: mType(eUninitialized)
{
}
inline ~UTF8StringOrDouble()
{
Uninit();
}
[[nodiscard]] inline binding_detail::FakeString<char>&
RawSetAsUTF8String()
{
if (mType == eUTF8String) {
return mValue.mUTF8String.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eUTF8String;
return mValue.mUTF8String.SetValue();
}
[[nodiscard]] inline binding_detail::FakeString<char>&
SetAsUTF8String()
{
if (mType == eUTF8String) {
return mValue.mUTF8String.Value();
}
Uninit();
mType = eUTF8String;
return mValue.mUTF8String.SetValue();
}
template <int N>
inline void
SetStringLiteral(const nsCString::char_type (&aData)[N])
{
RawSetAsUTF8String().AssignLiteral(aData);
}
inline bool
IsUTF8String() const
{
return mType == eUTF8String;
}
inline binding_detail::FakeString<char>&
GetAsUTF8String()
{
MOZ_RELEASE_ASSERT(IsUTF8String(), "Wrong type!");
return mValue.mUTF8String.Value();
}
inline const nsACString&
GetAsUTF8String() const
{
MOZ_RELEASE_ASSERT(IsUTF8String(), "Wrong type!");
return mValue.mUTF8String.Value();
}
[[nodiscard]] inline double&
RawSetAsDouble()
{
if (mType == eDouble) {
return mValue.mDouble.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eDouble;
return mValue.mDouble.SetValue();
}
[[nodiscard]] inline double&
SetAsDouble()
{
if (mType == eDouble) {
return mValue.mDouble.Value();
}
Uninit();
mType = eDouble;
return mValue.mDouble.SetValue();
}
inline bool
IsDouble() const
{
return mType == eDouble;
}
inline double&
GetAsDouble()
{
MOZ_RELEASE_ASSERT(IsDouble(), "Wrong type!");
return mValue.mDouble.Value();
}
inline double
GetAsDouble() const
{
MOZ_RELEASE_ASSERT(IsDouble(), "Wrong type!");
return mValue.mDouble.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 eUTF8String: {
DestroyUTF8String();
break;
}
case eDouble: {
DestroyDouble();
break;
}
}
}
bool
ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
private:
bool
TrySetToUTF8String(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyUTF8String()
{
MOZ_RELEASE_ASSERT(IsUTF8String(), "Wrong type!");
mValue.mUTF8String.Destroy();
mType = eUninitialized;
}
bool
TrySetToDouble(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToDouble(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyDouble()
{
MOZ_RELEASE_ASSERT(IsDouble(), "Wrong type!");
mValue.mDouble.Destroy();
mType = eUninitialized;
}
};
class OwningUTF8StringOrDouble : public AllOwningUnionBase
{
enum TypeOrUninit
{
eUninitialized,
eUTF8String,
eDouble
};
public:
enum class Type
{
eUTF8String = TypeOrUninit::eUTF8String,
eDouble = TypeOrUninit::eDouble
};
private:
union Value
{
UnionMember<nsCString > mUTF8String;
UnionMember<double > mDouble;
};
TypeOrUninit mType;
Value mValue;
public:
explicit inline OwningUTF8StringOrDouble()
: mType(eUninitialized)
{
}
OwningUTF8StringOrDouble(OwningUTF8StringOrDouble&& aOther);
explicit inline OwningUTF8StringOrDouble(const OwningUTF8StringOrDouble& aOther)
: mType(eUninitialized)
{
*this = aOther;
}
inline ~OwningUTF8StringOrDouble()
{
Uninit();
}
[[nodiscard]] nsCString&
RawSetAsUTF8String();
[[nodiscard]] nsCString&
SetAsUTF8String();
template <int N>
inline void
SetStringLiteral(const nsCString::char_type (&aData)[N])
{
RawSetAsUTF8String().AssignLiteral(aData);
}
inline bool
IsUTF8String() const
{
return mType == eUTF8String;
}
inline nsCString&
GetAsUTF8String()
{
MOZ_RELEASE_ASSERT(IsUTF8String(), "Wrong type!");
return mValue.mUTF8String.Value();
}
inline nsCString const &
GetAsUTF8String() const
{
MOZ_RELEASE_ASSERT(IsUTF8String(), "Wrong type!");
return mValue.mUTF8String.Value();
}
[[nodiscard]] double&
RawSetAsDouble();
[[nodiscard]] double&
SetAsDouble();
inline bool
IsDouble() const
{
return mType == eDouble;
}
inline double&
GetAsDouble()
{
MOZ_RELEASE_ASSERT(IsDouble(), "Wrong type!");
return mValue.mDouble.Value();
}
inline double const &
GetAsDouble() const
{
MOZ_RELEASE_ASSERT(IsDouble(), "Wrong type!");
return mValue.mDouble.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;
OwningUTF8StringOrDouble&
operator=(OwningUTF8StringOrDouble&& aOther);
inline Type
GetType() const
{
MOZ_RELEASE_ASSERT(mType != eUninitialized);
return static_cast<Type>(mType);
}
OwningUTF8StringOrDouble&
operator=(const OwningUTF8StringOrDouble& aOther);
private:
bool
TrySetToUTF8String(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyUTF8String();
bool
TrySetToDouble(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToDouble(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyDouble();
};
namespace FluentBundle_Binding {
typedef mozilla::intl::FluentBundle NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
bool
Wrap(JSContext* aCx, mozilla::intl::FluentBundle* 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
ClearCachedLocalesValue(mozilla::intl::FluentBundle* aObject);
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::FluentBundle,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace FluentBundle_Binding
namespace FluentPattern_Binding {
typedef mozilla::intl::FluentPattern NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
bool
Wrap(JSContext* aCx, mozilla::intl::FluentPattern* 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::FluentPattern,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace FluentPattern_Binding
namespace FluentResource_Binding {
typedef mozilla::intl::FluentResource NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
bool
Wrap(JSContext* aCx, mozilla::intl::FluentResource* 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::FluentResource,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace FluentResource_Binding
} // namespace mozilla::dom
#endif // DOM_FLUENTBINDING_H_