Changeset 895
- Timestamp:
- 03/07/10 22:44:42 (5 months ago)
- Location:
- trunk
- Files:
-
- 6 modified
- 2 moved
-
client/Game2/Console.cpp (modified) (4 diffs)
-
client/Game2/Console.h (modified) (3 diffs)
-
client/Game2/HighConsole.cpp (modified) (2 diffs)
-
client/Game2/SysConsole.cpp (modified) (3 diffs)
-
client/Game2/SysConsole.h (modified) (1 diff)
-
engine/engine.vcproj (modified) (1 diff)
-
engine/Script/Core.cpp (moved) (moved from trunk/engine/Script/Env.cpp) (14 diffs)
-
engine/Script/Core.h (moved) (moved from trunk/engine/Script/Env.h) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/client/Game2/Console.cpp
r893 r895 23 23 #include "StdAfx.h" 24 24 25 #include "../../engine/Script/ Env.h"25 #include "../../engine/Script/Core.h" 26 26 27 27 #include "Console.h" … … 74 74 void Console::Init() 75 75 { 76 scripting = new Env();76 scripting = new Core(); 77 77 InitEnv(scripting); 78 78 InitGlobals(scripting); … … 83 83 * @param scripting The environment to initialize (may not be @c NULL). 84 84 */ 85 void Console::InitEnv(Script:: Env*scripting)85 void Console::InitEnv(Script::Core *scripting) 86 86 { 87 87 scripting->AddOutput(logStream); … … 92 92 * @param scripting The environment to initialize (may not be @c NULL). 93 93 */ 94 void Console::InitGlobals(Script:: Env*scripting)94 void Console::InitGlobals(Script::Core *scripting) 95 95 { 96 96 lua_State *state = scripting->GetState(); -
trunk/client/Game2/Console.h
r879 r895 30 30 31 31 namespace Script { 32 class Env;32 class Core; 33 33 } 34 34 … … 46 46 void Init(); 47 47 protected: 48 Script:: Env*GetScripting() const { return scripting; }49 virtual void InitEnv(Script:: Env*scripting);50 virtual void InitGlobals(Script:: Env*scripting);48 Script::Core *GetScripting() const { return scripting; } 49 virtual void InitEnv(Script::Core *scripting); 50 virtual void InitGlobals(Script::Core *scripting); 51 51 52 52 virtual void Cleanup(); … … 78 78 79 79 private: 80 Script:: Env*scripting;81 typedef std::list<Script:: Env*> oldScriptings_t;80 Script::Core *scripting; 81 typedef std::list<Script::Core*> oldScriptings_t; 82 82 oldScriptings_t oldScriptings; 83 83 boost::shared_ptr<std::ostream> logStream; -
trunk/client/Game2/HighConsole.cpp
r674 r895 27 27 #include <boost/thread/locks.hpp> 28 28 29 #include "../../engine/Script/ Env.h"29 #include "../../engine/Script/Core.h" 30 30 #include "../../engine/Util/Config.h" 31 31 #include "../../engine/VideoServices/2DViewPort.h" … … 101 101 Font("Arial", 20, true), 0x0a); 102 102 103 Script:: Env*env = GetScripting();103 Script::Core *env = GetScripting(); 104 104 std::string intro = env->GetVersionString(); 105 105 intro += " :: Console active."; -
trunk/client/Game2/SysConsole.cpp
r892 r895 29 29 #include <boost/format.hpp> 30 30 31 #include "../../engine/Script/ Env.h"31 #include "../../engine/Script/Core.h" 32 32 33 33 #include "SysConsole.h" … … 52 52 } 53 53 54 void SysConsole::InitEnv(Script:: Env*scripting)54 void SysConsole::InitEnv(Script::Core *scripting) 55 55 { 56 56 SUPER::InitEnv(scripting); … … 58 58 } 59 59 60 void SysConsole::InitGlobals(Script:: Env*scripting)60 void SysConsole::InitGlobals(Script::Core *scripting) 61 61 { 62 62 SUPER::InitGlobals(scripting); -
trunk/client/Game2/SysConsole.h
r892 r895 37 37 38 38 protected: 39 virtual void InitEnv(Script:: Env*scripting);40 virtual void InitGlobals(Script:: Env*scripting);39 virtual void InitEnv(Script::Core *scripting); 40 virtual void InitGlobals(Script::Core *scripting); 41 41 42 42 public: -
trunk/engine/engine.vcproj
r850 r895 808 808 > 809 809 <File 810 RelativePath=".\Script\ Env.cpp"811 > 812 </File> 813 <File 814 RelativePath=".\Script\ Env.h"810 RelativePath=".\Script\Core.cpp" 811 > 812 </File> 813 <File 814 RelativePath=".\Script\Core.h" 815 815 > 816 816 </File> -
trunk/engine/Script/Core.cpp
r894 r895 1 1 2 // Env.cpp2 // Core.cpp 3 3 // Scripting support. 4 4 // … … 29 29 #include "../Util/OS.h" 30 30 31 #include " Env.h"31 #include "Core.h" 32 32 33 33 using namespace HoverRace::Script; … … 45 45 #define DISALLOW_LUA_GLOBAL(state, name) \ 46 46 lua_pushstring((state), (name)); \ 47 lua_pushcclosure((state), Env::LSandboxedFunction, 1); \47 lua_pushcclosure((state), Core::LSandboxedFunction, 1); \ 48 48 lua_setglobal((state), (name)) 49 49 50 Env::Env()50 Core::Core() 51 51 { 52 52 state = luaL_newstate(); … … 57 57 } 58 58 59 Env::~Env()59 Core::~Core() 60 60 { 61 61 lua_close(state); … … 69 69 * The state returned by GetState() is otherwise unchanged. 70 70 */ 71 void Env::Reset()71 void Core::Reset() 72 72 { 73 73 // Register a "safe" set of standard libraries. … … 79 79 // Override the print function so we can reroute the output. 80 80 lua_pushlightuserdata(state, this); 81 lua_pushcclosure(state, Env::LPrint, 1);81 lua_pushcclosure(state, Core::LPrint, 1); 82 82 lua_setglobal(state, "print"); 83 83 … … 96 96 * or break out of the sandbox. 97 97 */ 98 void Env::ActivateSandbox()98 void Core::ActivateSandbox() 99 99 { 100 100 if (!lua_checkstack(state, 2)) … … 147 147 * @return A handle for removing the stream later. 148 148 */ 149 Env::OutHandle Env::AddOutput(boost::shared_ptr<std::ostream> out)149 Core::OutHandle Core::AddOutput(boost::shared_ptr<std::ostream> out) 150 150 { 151 151 outs.push_back(out); … … 153 153 } 154 154 155 void Env::RemoveOutput(const OutHandle &handle)155 void Core::RemoveOutput(const OutHandle &handle) 156 156 { 157 157 outs.erase(handle); … … 162 162 * @return The string (never empty). 163 163 */ 164 std::string Env::GetVersionString() const164 std::string Core::GetVersionString() const 165 165 { 166 166 return LUA_VERSION; … … 176 176 * while executing. 177 177 */ 178 void Env::Execute(const std::string &chunk)178 void Core::Execute(const std::string &chunk) 179 179 { 180 180 // Compile the chunk. … … 218 218 * @return The error as a string. 219 219 */ 220 std::string Env::PopError()220 std::string Core::PopError() 221 221 { 222 222 size_t len; … … 227 227 } 228 228 229 int Env::LPrint(lua_State *state)230 { 231 Env *self = static_cast<Env*>(lua_touserdata(state, lua_upvalueindex(1)));229 int Core::LPrint(lua_State *state) 230 { 231 Core *self = static_cast<Core*>(lua_touserdata(state, lua_upvalueindex(1))); 232 232 233 233 int numParams = lua_gettop(state); … … 267 267 } 268 268 269 int Env::LSandboxedFunction(lua_State *state)269 int Core::LSandboxedFunction(lua_State *state) 270 270 { 271 271 const char *name = lua_tostring(state, lua_upvalueindex(1)); -
trunk/engine/Script/Core.h
r893 r895 1 1 2 // Env.h2 // Core.h 3 3 // Header for the scripting engine environment. 4 4 // … … 54 54 * @author Michael Imamura 55 55 */ 56 class MR_DllDeclare Env56 class MR_DllDeclare Core 57 57 { 58 58 public: 59 Env();60 ~ Env();59 Core(); 60 ~Core(); 61 61 62 62 public:
