HoverRace
2.0
|
Limited environment for defining rulebooks. More...
#include <RulebookEnv.h>
Public Member Functions | |
RulebookEnv (Script::Core &scripting, const Util::OS::path_t &basePath, Rulebook &rulebook) | |
Constructor. More... | |
virtual | ~RulebookEnv () |
void | DefineRulebook (const std::string &name, const luabind::object &defn) |
bool | RunRulebookScript () |
Run the boot script for a rulebook. More... | |
Public Member Functions inherited from HoverRace::Client::HoverScript::RuntimeEnv | |
RuntimeEnv (Script::Core &scripting) | |
virtual | ~RuntimeEnv () |
Public Member Functions inherited from HoverRace::Script::Env | |
Env (Core &scripting) | |
Constructor. More... | |
Env (const Env &)=delete | |
virtual | ~Env () |
Env & | operator= (const Env &)=delete |
bool | RunScript (const Util::OS::path_t &filename) |
Execute a script from a file. More... | |
Static Public Member Functions | |
static int | LPlayer (lua_State *L) |
static int | LRequire (lua_State *L) |
static int | LRulebookStage1 (lua_State *L) |
static int | LRulebookStage2 (lua_State *L) |
static int | LSession (lua_State *L) |
Protected Member Functions | |
void | InitCFn (const char *name, lua_CFunction fn) |
Register a member function in a table. More... | |
virtual void | InitEnv () |
Initialize the environment in which scripts will run in. More... | |
Protected Member Functions inherited from HoverRace::Script::Env | |
void | CopyGlobals () |
Copy the global environment into the current table at the top of the stack. More... | |
template<class ReturnPolicy = Core::PrintReturn> | |
int | Execute (const Core::Chunk &chunk, ReturnPolicy rp=ReturnPolicy()) |
Execute a chunk of code in the current environment. More... | |
Core & | GetScripting () const |
lua_State * | GetState () const |
void | LogScriptError (const Script::ScriptExn &ex) |
void | PushEnv () |
Push the environment onto the stack. More... | |
void | SetHelpHandler (Help::HelpHandler *helpHandler) |
Private Types | |
using | SUPER = RuntimeEnv |
Private Member Functions | |
void | DefineRules (const luabind::object &rulesObj) |
Static Private Member Functions | |
static int | GenerateSubclass (lua_State *L, const std::string &base, const std::string &name) |
Generate a Lua subclass of a native class. More... | |
Private Attributes | |
Util::OS::path_t | basePath |
Script::RegistryRef | requireCache |
Rulebook & | rulebook |
Additional Inherited Members | |
Static Protected Member Functions inherited from HoverRace::Script::Env | |
static Core::Chunk | LoadChunkFromFile (const Util::OS::path_t &filename) |
Load a chunk from a file. More... | |
Limited environment for defining rulebooks.
|
private |
HoverRace::Client::HoverScript::RulebookEnv::RulebookEnv | ( | Script::Core & | scripting, |
const Util::OS::path_t & | basePath, | ||
Rulebook & | rulebook | ||
) |
Constructor.
The root directory of the rulebook is where the rulebook scripts will be found; a rulebook is not allowed to access any scripts outside of its root directory.
scripting | The scripting context. |
basePath | The root directory of the rulebook. |
rulebook | The rulebook bound to this environment. |
|
virtual |
void HoverRace::Client::HoverScript::RulebookEnv::DefineRulebook | ( | const std::string & | name, |
const luabind::object & | defn | ||
) |
|
private |
|
staticprivate |
Generate a Lua subclass of a native class.
L | The Lua state. |
base | The name of the native base class. |
name | The name of the function (in Lua) generating the class, used in error messages. |
|
protected |
Register a member function in a table.
This is expected to be called from InitEnv() to add global functions to the environment.
The top of the Lua stack must be the destination table.
The function being registered will receive a single upvalue, which is the this
pointer.
name | The Lua name of the function. |
fn | The function to register. |
|
protectedvirtual |
Initialize the environment in which scripts will run in.
Upon entry, the Lua stack will have at least one entry, the table which represents the environment. Implementing functions will fill this table with the globals which will be available to the functions which are run in this environment. Upon return, this same table must be at the top of the stack.
Implements HoverRace::Script::Env.
|
static |
|
static |
|
static |
|
static |
|
static |
bool HoverRace::Client::HoverScript::RulebookEnv::RunRulebookScript | ( | ) |
Run the boot script for a rulebook.
|
private |
|
private |
|
private |