0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-16 15:00:51 +01:00

ircd::js: Add and use calls for current_compartment().

This commit is contained in:
Jason Volk 2016-10-28 20:45:35 -07:00
parent 639dd7903b
commit 5e81c26fdf
2 changed files with 15 additions and 1 deletions

View file

@ -113,6 +113,8 @@ void priv(context &, privdata *const &);
// Misc
inline auto running(const context &c) { return JS_IsRunning(c); }
inline auto version(const context &c) { return version(JS_GetVersion(c)); }
JSCompartment *current_compartment(context &);
JSCompartment *current_compartment();
JSObject *current_global(context &c);
JSObject *current_global(); // thread_local

View file

@ -1790,7 +1790,7 @@ ircd::js::compartment::compartment(JSObject *const &obj,
context &c)
:c{&c}
,prev{JS_EnterCompartment(c, obj)}
,ours{::js::GetContextCompartment(c)}
,ours{current_compartment(c)}
,cprev{static_cast<compartment *>(JS_GetCompartmentPrivate(ours))}
{
JS_SetCompartmentPrivate(ours, this);
@ -2114,6 +2114,18 @@ ircd::js::set(context &c,
JS_SetGCParameter(c.runtime(), key, val);
}
JSCompartment *
ircd::js::current_compartment()
{
return current_compartment(*cx);
}
JSCompartment *
ircd::js::current_compartment(context &c)
{
return ::js::GetContextCompartment(c);
}
///////////////////////////////////////////////////////////////////////////////
//
// ircd/js/timer.h