summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2022-10-02 11:38:52 +0100
committerLinus Groh <mail@linusgroh.de>2022-10-02 23:02:27 +0100
commitd3b7c06712f5fce11571f29578087695e5016836 (patch)
treeba364e95c1d3c4384dcad04c89cb30d9378685d5 /Userland/Libraries/LibJS
parentc2326ec95a994c2e2e93fd39371e77014d6c26be (diff)
downloadserenity-d3b7c06712f5fce11571f29578087695e5016836.zip
LibJS: Add Value(GCPtr<T>) and Value(NonnullGCPtr<T>) constructors
Let's avoid reaching for ptr() as much as possible.
Diffstat (limited to 'Userland/Libraries/LibJS')
-rw-r--r--Userland/Libraries/LibJS/Runtime/Value.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Value.h b/Userland/Libraries/LibJS/Runtime/Value.h
index aadf403302..b02f05b8f3 100644
--- a/Userland/Libraries/LibJS/Runtime/Value.h
+++ b/Userland/Libraries/LibJS/Runtime/Value.h
@@ -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());