1
0
forked from mirrors/0ad

Split ScriptRequest in its own header.

We often only need to include ScriptRequest.h and not the full
ScriptInterface.h

Differential Revision: https://code.wildfiregames.com/D3920
This was SVN commit r25366.
This commit is contained in:
wraitii
2021-05-03 16:07:26 +00:00
parent 0406c4dfde
commit 34b1920e7b
20 changed files with 127 additions and 62 deletions
+9 -6
View File
@@ -71,11 +71,18 @@ struct ScriptInterface_impl
JS::PersistentRootedObject m_nativeScope; // native function scope object
};
/**
* Constructor for ScriptRequest - here because it needs access into ScriptInterface_impl.
*/
ScriptRequest::ScriptRequest(const ScriptInterface& scriptInterface) :
cx(scriptInterface.m->m_cx), nativeScope(scriptInterface.m->m_nativeScope)
cx(scriptInterface.m->m_cx), glob(scriptInterface.m->m_glob), nativeScope(scriptInterface.m->m_nativeScope)
{
m_formerRealm = JS::EnterRealm(cx, scriptInterface.m->m_glob);
glob = JS::CurrentGlobalOrNull(cx);
}
ScriptRequest::~ScriptRequest()
{
JS::LeaveRealm(cx, m_formerRealm);
}
JS::Value ScriptRequest::globalValue() const
@@ -83,10 +90,6 @@ JS::Value ScriptRequest::globalValue() const
return JS::ObjectValue(*glob);
}
ScriptRequest::~ScriptRequest()
{
JS::LeaveRealm(cx, m_formerRealm);
}
namespace
{