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