Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/simulation2/system/ComponentManager.cpp
Show All 37 Lines | |||||
{ | { | ||||
public: | public: | ||||
virtual int GetType() const { return mtid; } | virtual int GetType() const { return mtid; } | ||||
virtual const char* GetScriptHandlerName() const { return handlerName.c_str(); } | virtual const char* GetScriptHandlerName() const { return handlerName.c_str(); } | ||||
virtual const char* GetScriptGlobalHandlerName() const { return globalHandlerName.c_str(); } | virtual const char* GetScriptGlobalHandlerName() const { return globalHandlerName.c_str(); } | ||||
virtual JS::Value ToJSVal(const ScriptInterface& UNUSED(scriptInterface)) const { return msg.get(); } | virtual JS::Value ToJSVal(const ScriptInterface& UNUSED(scriptInterface)) const { return msg.get(); } | ||||
CMessageScripted(const ScriptInterface& scriptInterface, int mtid, const std::string& name, JS::HandleValue msg) : | CMessageScripted(const ScriptInterface& scriptInterface, int mtid, const std::string& name, JS::HandleValue msg) : | ||||
mtid(mtid), handlerName("On" + name), globalHandlerName("OnGlobal" + name), msg(scriptInterface.GetJSRuntime(), msg) | mtid(mtid), handlerName("On" + name), globalHandlerName("OnGlobal" + name), msg(scriptInterface.GetGeneralJSContext(), msg) | ||||
{ | { | ||||
} | } | ||||
int mtid; | int mtid; | ||||
std::string handlerName; | std::string handlerName; | ||||
std::string globalHandlerName; | std::string globalHandlerName; | ||||
JS::PersistentRootedValue msg; | JS::PersistentRootedValue msg; | ||||
}; | }; | ||||
CComponentManager::CComponentManager(CSimContext& context, shared_ptr<ScriptContext> rt, bool skipScriptFunctions) : | CComponentManager::CComponentManager(CSimContext& context, shared_ptr<ScriptContext> cx, bool skipScriptFunctions) : | ||||
m_NextScriptComponentTypeId(CID__LastNative), | m_NextScriptComponentTypeId(CID__LastNative), | ||||
m_ScriptInterface("Engine", "Simulation", rt), | m_ScriptInterface("Engine", "Simulation", cx), | ||||
m_SimContext(context), m_CurrentlyHotloading(false) | m_SimContext(context), m_CurrentlyHotloading(false) | ||||
{ | { | ||||
context.SetComponentManager(this); | context.SetComponentManager(this); | ||||
m_ScriptInterface.SetCallbackData(static_cast<void*> (this)); | m_ScriptInterface.SetCallbackData(static_cast<void*> (this)); | ||||
m_ScriptInterface.ReplaceNondeterministicRNG(m_RNG); | m_ScriptInterface.ReplaceNondeterministicRNG(m_RNG); | ||||
// For component script tests, the test system sets up its own scripted implementation of | // For component script tests, the test system sets up its own scripted implementation of | ||||
▲ Show 20 Lines • Show All 1,115 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator