LibJS: Support Value::as_if for JS::Object
This commit is contained in:
parent
b20d14970f
commit
bc0cff8a59
1 changed files with 11 additions and 3 deletions
|
|
@ -157,7 +157,7 @@ public:
|
|||
template<DerivedFrom<Object> T>
|
||||
[[nodiscard]] ALWAYS_INLINE bool is() const
|
||||
{
|
||||
return is_object() && ::is<T>(as_object());
|
||||
return as_if<T>() != nullptr;
|
||||
}
|
||||
|
||||
template<DerivedFrom<Object> T>
|
||||
|
|
@ -165,7 +165,11 @@ public:
|
|||
{
|
||||
if (!is_object())
|
||||
return nullptr;
|
||||
return ::as_if<T>(as_object());
|
||||
if constexpr (IsSame<T, Object>) {
|
||||
return as_object();
|
||||
} else {
|
||||
return ::as_if<T>(as_object());
|
||||
}
|
||||
}
|
||||
|
||||
template<DerivedFrom<Object> T>
|
||||
|
|
@ -173,7 +177,11 @@ public:
|
|||
{
|
||||
if (!is_object())
|
||||
return nullptr;
|
||||
return ::as_if<T>(as_object());
|
||||
if constexpr (IsSame<T, Object>) {
|
||||
return as_object();
|
||||
} else {
|
||||
return ::as_if<T>(as_object());
|
||||
}
|
||||
}
|
||||
|
||||
constexpr Value()
|
||||
|
|
|
|||
Loading…
Reference in a new issue