mirror of
https://github.com/matrix-construct/construct
synced 2024-11-19 08:21:09 +01:00
ircd::js: Add conversions for JS::Heap<> type to handle types.
This commit is contained in:
parent
164f650a0f
commit
72eb8ff8da
1 changed files with 34 additions and 10 deletions
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue