From 72eb8ff8da721a5f08031a51e68b979df2ddd2d1 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 27 Oct 2016 22:01:00 -0700 Subject: [PATCH] ircd::js: Add conversions for JS::Heap<> type to handle types. --- include/ircd/js/root.h | 44 ++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/include/ircd/js/root.h b/include/ircd/js/root.h index 672e308ea..56c417464 100644 --- a/include/ircd/js/root.h +++ b/include/ircd/js/root.h @@ -93,6 +93,23 @@ struct root root &operator=(const root &) = delete; }; +// This conversion is missing in the jsapi. Is this object not gc rooted? Can it not have a handle? +template +JS::Handle +operator&(const JS::Heap &h) +{ + return JS::Handle::fromMarkedLocation(h.address()); +} + +// This conversion is missing in the jsapi. Is this object not gc rooted? Can it not have a handle? +template +JS::MutableHandle +operator&(JS::Heap &h) +{ + const auto ptr(const_cast(h.address())); + return JS::MutableHandle::fromMarkedLocation(ptr); +} + template struct root :JS::Heap @@ -112,16 +129,6 @@ struct root return JS::MutableHandle::fromMarkedLocation(ptr); } - auto operator&() const - { - return static_cast(*this); - } - - auto operator&() - { - return static_cast(*this); - } - root(const handle &h) :JS::Heap{h} { @@ -154,6 +161,23 @@ struct root root &operator=(const root &) = default; }; +// This conversion is missing in the jsapi. Is this object not gc rooted? Can it not have a handle? +template +JS::Handle +operator&(const JS::TenuredHeap &h) +{ + return JS::Handle::fromMarkedLocation(h.address()); +} + +// This conversion is missing in the jsapi. Is this object not gc rooted? Can it not have a handle? +template +JS::MutableHandle +operator&(JS::TenuredHeap &h) +{ + const auto ptr(const_cast(h.address())); + return JS::MutableHandle::fromMarkedLocation(ptr); +} + template struct root :JS::TenuredHeap