0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-10-01 21:28:53 +02:00

ircd::js: Add conversions for JS::Heap<> type to handle types.

This commit is contained in:
Jason Volk 2016-10-27 22:01:00 -07:00
parent 164f650a0f
commit 72eb8ff8da

View file

@ -93,6 +93,23 @@ struct root<T, lifetime::stack>
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<class T>
JS::Handle<T>
operator&(const JS::Heap<T> &h)
{
return JS::Handle<T>::fromMarkedLocation(h.address());
}
// This conversion is missing in the jsapi. Is this object not gc rooted? Can it not have a handle?
template<class T>
JS::MutableHandle<T>
operator&(JS::Heap<T> &h)
{
const auto ptr(const_cast<T *>(h.address()));
return JS::MutableHandle<T>::fromMarkedLocation(ptr);
}
template<class T>
struct root<T, lifetime::heap>
:JS::Heap<T>
@ -112,16 +129,6 @@ struct root<T, lifetime::heap>
return JS::MutableHandle<T>::fromMarkedLocation(ptr);
}
auto operator&() const
{
return static_cast<handle>(*this);
}
auto operator&()
{
return static_cast<handle_mutable>(*this);
}
root(const handle &h)
:JS::Heap<T>{h}
{
@ -154,6 +161,23 @@ struct root<T, lifetime::heap>
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<class T>
JS::Handle<T>
operator&(const JS::TenuredHeap<T> &h)
{
return JS::Handle<T>::fromMarkedLocation(h.address());
}
// This conversion is missing in the jsapi. Is this object not gc rooted? Can it not have a handle?
template<class T>
JS::MutableHandle<T>
operator&(JS::TenuredHeap<T> &h)
{
const auto ptr(const_cast<T *>(h.address()));
return JS::MutableHandle<T>::fromMarkedLocation(ptr);
}
template<class T>
struct root<T, lifetime::tenured>
:JS::TenuredHeap<T>