1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 20:37:34 +00:00

LibJS: Add Value(GCPtr<T>) and Value(NonnullGCPtr<T>) constructors

Let's avoid reaching for ptr() as much as possible.
This commit is contained in:
Linus Groh 2022-10-02 11:38:52 +01:00
parent c2326ec95a
commit d3b7c06712

View file

@ -18,6 +18,7 @@
#include <AK/String.h>
#include <AK/Types.h>
#include <LibJS/Forward.h>
#include <LibJS/Heap/GCPtr.h>
#include <LibJS/Runtime/BigInt.h>
#include <LibJS/Runtime/Utf16String.h>
#include <math.h>
@ -275,6 +276,18 @@ public:
{
}
template<typename T>
Value(GCPtr<T> ptr)
: Value(ptr.ptr())
{
}
template<typename T>
Value(NonnullGCPtr<T> ptr)
: Value(ptr.ptr())
{
}
double as_double() const
{
VERIFY(is_number());