Copy as Markdown
Other Tools
/* THIS FILE IS AUTOGENERATED FROM CSSKeywordValue.webidl BY Codegen.py - DO NOT EDIT */
#ifndef DOM_CSSKEYWORDVALUEBINDING_H_
#define DOM_CSSKEYWORDVALUEBINDING_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/UnionMember.h"
namespace mozilla {
namespace dom {
class CSSKeywordValue;
struct NativePropertyHooks;
class OwningUTF8StringOrCSSKeywordValue;
class ProtoAndIfaceCache;
} // namespace dom
} // namespace mozilla
namespace mozilla::dom {
void
ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningUTF8StringOrCSSKeywordValue& aUnion, const char* aName, uint32_t aFlags = 0);
void
ImplCycleCollectionUnlink(OwningUTF8StringOrCSSKeywordValue& aUnion);
class UTF8StringOrCSSKeywordValue : public AllUnionBase
{
enum TypeOrUninit
{
eUninitialized,
eUTF8String,
eCSSKeywordValue
};
public:
enum class Type
{
eUTF8String = TypeOrUninit::eUTF8String,
eCSSKeywordValue = TypeOrUninit::eCSSKeywordValue
};
private:
union Value
{
UnionMember<binding_detail::FakeString<char> > mUTF8String;
UnionMember<NonNull<mozilla::dom::CSSKeywordValue> > mCSSKeywordValue;
};
TypeOrUninit mType;
Value mValue;
UTF8StringOrCSSKeywordValue(const UTF8StringOrCSSKeywordValue&) = delete;
UTF8StringOrCSSKeywordValue& operator=(const UTF8StringOrCSSKeywordValue&) = delete;
public:
explicit inline UTF8StringOrCSSKeywordValue()
: mType(eUninitialized)
{
}
inline ~UTF8StringOrCSSKeywordValue()
{
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 NonNull<mozilla::dom::CSSKeywordValue>&
RawSetAsCSSKeywordValue()
{
if (mType == eCSSKeywordValue) {
return mValue.mCSSKeywordValue.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eCSSKeywordValue;
return mValue.mCSSKeywordValue.SetValue();
}
[[nodiscard]] inline NonNull<mozilla::dom::CSSKeywordValue>&
SetAsCSSKeywordValue()
{
if (mType == eCSSKeywordValue) {
return mValue.mCSSKeywordValue.Value();
}
Uninit();
mType = eCSSKeywordValue;
return mValue.mCSSKeywordValue.SetValue();
}
inline bool
IsCSSKeywordValue() const
{
return mType == eCSSKeywordValue;
}
inline NonNull<mozilla::dom::CSSKeywordValue>&
GetAsCSSKeywordValue()
{
MOZ_RELEASE_ASSERT(IsCSSKeywordValue(), "Wrong type!");
return mValue.mCSSKeywordValue.Value();
}
inline mozilla::dom::CSSKeywordValue&
GetAsCSSKeywordValue() const
{
MOZ_RELEASE_ASSERT(IsCSSKeywordValue(), "Wrong type!");
return mValue.mCSSKeywordValue.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 eCSSKeywordValue: {
DestroyCSSKeywordValue();
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
TrySetToCSSKeywordValue(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToCSSKeywordValue(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyCSSKeywordValue()
{
MOZ_RELEASE_ASSERT(IsCSSKeywordValue(), "Wrong type!");
mValue.mCSSKeywordValue.Destroy();
mType = eUninitialized;
}
};
class OwningUTF8StringOrCSSKeywordValue : public AllOwningUnionBase
{
friend void ImplCycleCollectionUnlink(OwningUTF8StringOrCSSKeywordValue& aUnion);
enum TypeOrUninit
{
eUninitialized,
eUTF8String,
eCSSKeywordValue
};
public:
enum class Type
{
eUTF8String = TypeOrUninit::eUTF8String,
eCSSKeywordValue = TypeOrUninit::eCSSKeywordValue
};
private:
union Value
{
UnionMember<nsCString > mUTF8String;
UnionMember<OwningNonNull<mozilla::dom::CSSKeywordValue> > mCSSKeywordValue;
};
TypeOrUninit mType;
Value mValue;
public:
explicit inline OwningUTF8StringOrCSSKeywordValue()
: mType(eUninitialized)
{
}
OwningUTF8StringOrCSSKeywordValue(OwningUTF8StringOrCSSKeywordValue&& aOther);
explicit inline OwningUTF8StringOrCSSKeywordValue(const OwningUTF8StringOrCSSKeywordValue& aOther)
: mType(eUninitialized)
{
*this = aOther;
}
inline ~OwningUTF8StringOrCSSKeywordValue()
{
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]] OwningNonNull<mozilla::dom::CSSKeywordValue>&
RawSetAsCSSKeywordValue();
[[nodiscard]] OwningNonNull<mozilla::dom::CSSKeywordValue>&
SetAsCSSKeywordValue();
inline bool
IsCSSKeywordValue() const
{
return mType == eCSSKeywordValue;
}
inline OwningNonNull<mozilla::dom::CSSKeywordValue>&
GetAsCSSKeywordValue()
{
MOZ_RELEASE_ASSERT(IsCSSKeywordValue(), "Wrong type!");
return mValue.mCSSKeywordValue.Value();
}
inline OwningNonNull<mozilla::dom::CSSKeywordValue> const &
GetAsCSSKeywordValue() const
{
MOZ_RELEASE_ASSERT(IsCSSKeywordValue(), "Wrong type!");
return mValue.mCSSKeywordValue.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;
OwningUTF8StringOrCSSKeywordValue&
operator=(OwningUTF8StringOrCSSKeywordValue&& aOther);
inline Type
GetType() const
{
MOZ_RELEASE_ASSERT(mType != eUninitialized);
return static_cast<Type>(mType);
}
OwningUTF8StringOrCSSKeywordValue&
operator=(const OwningUTF8StringOrCSSKeywordValue& aOther);
private:
bool
TrySetToUTF8String(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyUTF8String();
bool
TrySetToCSSKeywordValue(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToCSSKeywordValue(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyCSSKeywordValue();
};
namespace CSSKeywordValue_Binding {
typedef mozilla::dom::CSSKeywordValue NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
bool
Wrap(JSContext* aCx, mozilla::dom::CSSKeywordValue* 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::CSSKeywordValue,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace CSSKeywordValue_Binding
} // namespace mozilla::dom
#endif // DOM_CSSKEYWORDVALUEBINDING_H_