Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/scriptinterface/ScriptInterface.cpp
Show First 20 Lines • Show All 424 Lines • ▼ Show 20 Lines | ScriptInterface::ScriptInterface(const char* nativeScopeName, const char* debugName, const shared_ptr<ScriptRuntime>& runtime) : | ||||
// 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); | ||||
} | } | ||||
Request rq(this); | Request rq(this); | ||||
m_CxPrivate.pScriptInterface = this; | m_CmptPrivate.pScriptInterface = this; | ||||
JS_SetContextPrivate(rq.cx, (void*)&m_CxPrivate); | JS_SetContextPrivate(rq.cx, (void*)&m_CmptPrivate); | ||||
} | } | ||||
ScriptInterface::~ScriptInterface() | ScriptInterface::~ScriptInterface() | ||||
{ | { | ||||
if (ThreadUtil::IsMainThread()) | if (ThreadUtil::IsMainThread()) | ||||
{ | { | ||||
if (g_ScriptStatsTable) | if (g_ScriptStatsTable) | ||||
g_ScriptStatsTable->Remove(this); | g_ScriptStatsTable->Remove(this); | ||||
} | } | ||||
} | } | ||||
void ScriptInterface::SetCallbackData(void* pCBData) | void ScriptInterface::SetCallbackData(void* pCBData) | ||||
{ | { | ||||
m_CxPrivate.pCBData = pCBData; | m_CmptPrivate.pCBData = pCBData; | ||||
} | } | ||||
ScriptInterface::CxPrivate* ScriptInterface::GetScriptInterfaceAndCBData(JSContext* cx) | ScriptInterface::CmptPrivate* ScriptInterface::GetScriptInterfaceAndCBData(JSContext* cx) | ||||
{ | { | ||||
CxPrivate* pCxPrivate = (CxPrivate*)JS_GetContextPrivate(cx); | CmptPrivate* pCmptPrivate = (CmptPrivate*)JS_GetContextPrivate(cx); | ||||
return pCxPrivate; | return pCmptPrivate; | ||||
} | } | ||||
bool ScriptInterface::LoadGlobalScripts() | bool ScriptInterface::LoadGlobalScripts() | ||||
{ | { | ||||
// Ignore this failure in tests | // Ignore this failure in tests | ||||
if (!g_VFS) | if (!g_VFS) | ||||
return false; | return false; | ||||
▲ Show 20 Lines • Show All 660 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator