Changeset 895 – HoverRace

Changeset 895

Show
Ignore:
Timestamp:
03/07/10 22:44:42 (5 months ago)
Author:
zoogie
Message:

Renamed Script::Env to Script::Core.

Script::Env will refer instead to a specific sandboxed environment within a Script::Core.

Location:
trunk
Files:
6 modified
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/client/Game2/Console.cpp

    r893 r895  
    2323#include "StdAfx.h" 
    2424 
    25 #include "../../engine/Script/Env.h" 
     25#include "../../engine/Script/Core.h" 
    2626 
    2727#include "Console.h" 
     
    7474void Console::Init() 
    7575{ 
    76     scripting = new Env(); 
     76    scripting = new Core(); 
    7777    InitEnv(scripting); 
    7878    InitGlobals(scripting); 
     
    8383 * @param scripting The environment to initialize (may not be @c NULL). 
    8484 */ 
    85 void Console::InitEnv(Script::Env *scripting) 
     85void Console::InitEnv(Script::Core *scripting) 
    8686{ 
    8787    scripting->AddOutput(logStream); 
     
    9292 * @param scripting The environment to initialize (may not be @c NULL). 
    9393 */ 
    94 void Console::InitGlobals(Script::Env *scripting) 
     94void Console::InitGlobals(Script::Core *scripting) 
    9595{ 
    9696    lua_State *state = scripting->GetState(); 
  • trunk/client/Game2/Console.h

    r879 r895  
    3030 
    3131namespace Script { 
    32     class Env; 
     32    class Core; 
    3333} 
    3434 
     
    4646        void Init(); 
    4747    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); 
    5151 
    5252        virtual void Cleanup(); 
     
    7878 
    7979    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; 
    8282        oldScriptings_t oldScriptings; 
    8383        boost::shared_ptr<std::ostream> logStream; 
  • trunk/client/Game2/HighConsole.cpp

    r674 r895  
    2727#include <boost/thread/locks.hpp> 
    2828 
    29 #include "../../engine/Script/Env.h" 
     29#include "../../engine/Script/Core.h" 
    3030#include "../../engine/Util/Config.h" 
    3131#include "../../engine/VideoServices/2DViewPort.h" 
     
    101101        Font("Arial", 20, true), 0x0a); 
    102102 
    103     Script::Env *env = GetScripting(); 
     103    Script::Core *env = GetScripting(); 
    104104    std::string intro = env->GetVersionString(); 
    105105    intro += " :: Console active."; 
  • trunk/client/Game2/SysConsole.cpp

    r892 r895  
    2929#include <boost/format.hpp> 
    3030 
    31 #include "../../engine/Script/Env.h" 
     31#include "../../engine/Script/Core.h" 
    3232 
    3333#include "SysConsole.h" 
     
    5252} 
    5353 
    54 void SysConsole::InitEnv(Script::Env *scripting) 
     54void SysConsole::InitEnv(Script::Core *scripting) 
    5555{ 
    5656    SUPER::InitEnv(scripting); 
     
    5858} 
    5959 
    60 void SysConsole::InitGlobals(Script::Env *scripting) 
     60void SysConsole::InitGlobals(Script::Core *scripting) 
    6161{ 
    6262    SUPER::InitGlobals(scripting); 
  • trunk/client/Game2/SysConsole.h

    r892 r895  
    3737 
    3838    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); 
    4141 
    4242    public: 
  • trunk/engine/engine.vcproj

    r850 r895  
    808808            > 
    809809            <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" 
    815815                > 
    816816            </File> 
  • trunk/engine/Script/Core.cpp

    r894 r895  
    11 
    2 // Env.cpp 
     2// Core.cpp 
    33// Scripting support. 
    44// 
     
    2929#include "../Util/OS.h" 
    3030 
    31 #include "Env.h" 
     31#include "Core.h" 
    3232 
    3333using namespace HoverRace::Script; 
     
    4545#define DISALLOW_LUA_GLOBAL(state, name) \ 
    4646    lua_pushstring((state), (name)); \ 
    47     lua_pushcclosure((state), Env::LSandboxedFunction, 1); \ 
     47    lua_pushcclosure((state), Core::LSandboxedFunction, 1); \ 
    4848    lua_setglobal((state), (name)) 
    4949 
    50 Env::Env() 
     50Core::Core() 
    5151{ 
    5252    state = luaL_newstate(); 
     
    5757} 
    5858 
    59 Env::~Env() 
     59Core::~Core() 
    6060{ 
    6161    lua_close(state); 
     
    6969 * The state returned by GetState() is otherwise unchanged. 
    7070 */ 
    71 void Env::Reset() 
     71void Core::Reset() 
    7272{ 
    7373    // Register a "safe" set of standard libraries. 
     
    7979    // Override the print function so we can reroute the output. 
    8080    lua_pushlightuserdata(state, this); 
    81     lua_pushcclosure(state, Env::LPrint, 1); 
     81    lua_pushcclosure(state, Core::LPrint, 1); 
    8282    lua_setglobal(state, "print"); 
    8383 
     
    9696 * or break out of the sandbox. 
    9797 */ 
    98 void Env::ActivateSandbox() 
     98void Core::ActivateSandbox() 
    9999{ 
    100100    if (!lua_checkstack(state, 2)) 
     
    147147 * @return A handle for removing the stream later. 
    148148 */ 
    149 Env::OutHandle Env::AddOutput(boost::shared_ptr<std::ostream> out) 
     149Core::OutHandle Core::AddOutput(boost::shared_ptr<std::ostream> out) 
    150150{ 
    151151    outs.push_back(out); 
     
    153153} 
    154154 
    155 void Env::RemoveOutput(const OutHandle &handle) 
     155void Core::RemoveOutput(const OutHandle &handle) 
    156156{ 
    157157    outs.erase(handle); 
     
    162162 * @return The string (never empty). 
    163163 */ 
    164 std::string Env::GetVersionString() const 
     164std::string Core::GetVersionString() const 
    165165{ 
    166166    return LUA_VERSION; 
     
    176176 *                  while executing. 
    177177 */ 
    178 void Env::Execute(const std::string &chunk) 
     178void Core::Execute(const std::string &chunk) 
    179179{ 
    180180    // Compile the chunk. 
     
    218218 * @return The error as a string. 
    219219 */ 
    220 std::string Env::PopError() 
     220std::string Core::PopError() 
    221221{ 
    222222    size_t len; 
     
    227227} 
    228228 
    229 int Env::LPrint(lua_State *state) 
    230 { 
    231     Env *self = static_cast<Env*>(lua_touserdata(state, lua_upvalueindex(1))); 
     229int Core::LPrint(lua_State *state) 
     230{ 
     231    Core *self = static_cast<Core*>(lua_touserdata(state, lua_upvalueindex(1))); 
    232232 
    233233    int numParams = lua_gettop(state); 
     
    267267} 
    268268 
    269 int Env::LSandboxedFunction(lua_State *state) 
     269int Core::LSandboxedFunction(lua_State *state) 
    270270{ 
    271271    const char *name = lua_tostring(state, lua_upvalueindex(1)); 
  • trunk/engine/Script/Core.h

    r893 r895  
    11 
    2 // Env.h 
     2// Core.h 
    33// Header for the scripting engine environment. 
    44// 
     
    5454 * @author Michael Imamura 
    5555 */ 
    56 class MR_DllDeclare Env 
     56class MR_DllDeclare Core 
    5757{ 
    5858    public: 
    59         Env(); 
    60         ~Env(); 
     59        Core(); 
     60        ~Core(); 
    6161 
    6262    public: