Changeset View
Changeset View
Standalone View
Standalone View
source/scriptinterface/ScriptInterface.cpp
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | private: | ||||
JS::PersistentRootedObject m_glob; // global scope object | JS::PersistentRootedObject m_glob; // global scope object | ||||
public: | public: | ||||
boost::rand48* m_rng; | boost::rand48* m_rng; | ||||
JS::PersistentRootedObject m_nativeScope; // native function scope object | JS::PersistentRootedObject m_nativeScope; // native function scope object | ||||
}; | }; | ||||
ScriptRequest::ScriptRequest(const ScriptInterface& scriptInterface) : | ScriptRequest::ScriptRequest(const ScriptInterface& scriptInterface) : | ||||
cx(scriptInterface.m->m_cx) | cx(scriptInterface.m->m_cx), funcScope(scriptInterface.m->m_nativeScope) | ||||
{ | { | ||||
m_formerRealm = JS::EnterRealm(cx, scriptInterface.m->m_glob); | m_formerRealm = JS::EnterRealm(cx, scriptInterface.m->m_glob); | ||||
glob = JS::CurrentGlobalOrNull(cx); | glob = JS::CurrentGlobalOrNull(cx); | ||||
} | } | ||||
JS::Value ScriptRequest::globalValue() const | JS::Value ScriptRequest::globalValue() const | ||||
{ | { | ||||
return JS::ObjectValue(*glob); | return JS::ObjectValue(*glob); | ||||
▲ Show 20 Lines • Show All 272 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
void ScriptInterface_impl::Register(const char* name, JSNative fptr, uint nargs) const | void ScriptInterface_impl::Register(const char* name, JSNative fptr, uint nargs) const | ||||
{ | { | ||||
JSAutoRealm autoRealm(m_cx, m_glob); | JSAutoRealm autoRealm(m_cx, m_glob); | ||||
JS::RootedObject nativeScope(m_cx, m_nativeScope); | JS::RootedObject nativeScope(m_cx, m_nativeScope); | ||||
JS::RootedFunction func(m_cx, JS_DefineFunction(m_cx, nativeScope, name, fptr, nargs, JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT)); | JS::RootedFunction func(m_cx, JS_DefineFunction(m_cx, nativeScope, name, fptr, nargs, JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT)); | ||||
} | } | ||||
wraitii: need to revert this change | |||||
Not Done Inline ActionsStill there :p Stan: Still there :p | |||||
ScriptInterface::ScriptInterface(const char* nativeScopeName, const char* debugName, const shared_ptr<ScriptContext>& context) : | ScriptInterface::ScriptInterface(const char* nativeScopeName, const char* debugName, const shared_ptr<ScriptContext>& context) : | ||||
m(new ScriptInterface_impl(nativeScopeName, context)) | m(new ScriptInterface_impl(nativeScopeName, context)) | ||||
{ | { | ||||
// Profiler stats table isn't thread-safe, so only enable this on the main thread | // Profiler stats table isn't thread-safe, so only enable this on the main thread | ||||
if (ThreadUtil::IsMainThread()) | if (ThreadUtil::IsMainThread()) | ||||
{ | { | ||||
if (g_ScriptStatsTable) | if (g_ScriptStatsTable) | ||||
g_ScriptStatsTable->Add(this, debugName); | g_ScriptStatsTable->Add(this, debugName); | ||||
▲ Show 20 Lines • Show All 646 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
need to revert this change