A script environment.
More...
#include <Env.h>
|
void | SetupEnv () |
| Apply the environment to the function on the top of the stack. More...
|
|
A script environment.
- Author
- Michael Imamura
HoverRace::Script::Env::Env |
( |
Core & |
scripting | ) |
|
Constructor.
- Parameters
-
scripting | The scripting engine. |
HoverRace::Script::Env::Env |
( |
const Env & |
| ) |
|
|
delete |
virtual HoverRace::Script::Env::~Env |
( |
| ) |
|
|
inlinevirtual |
void HoverRace::Script::Env::CopyGlobals |
( |
| ) |
|
|
protected |
Copy the global environment into the current table at the top of the stack.
This is meant to be called from InitEnv() as a convenience.
template<class ReturnPolicy = Core::PrintReturn>
int HoverRace::Script::Env::Execute |
( |
const Core::Chunk & |
chunk, |
|
|
ReturnPolicy |
rp = ReturnPolicy() |
|
) |
| |
|
inlineprotected |
Execute a chunk of code in the current environment.
- Parameters
-
chunk | The code to execute. |
rp | Optional policy to handle return values. |
- Returns
- The number of return values remaining on the stack, determined by the ReturnPolicy.
- Exceptions
-
IncompleteExn | If the code does not complete a statement; i.e., expecting more tokens. Callers can catch this to keep reading more data to finish the statement. |
ScriptExn | The code either failed to compile or signaled an error while executing. |
Core& HoverRace::Script::Env::GetScripting |
( |
| ) |
const |
|
inlineprotected |
lua_State* HoverRace::Script::Env::GetState |
( |
| ) |
const |
|
inlineprotected |
void HoverRace::Script::Env::InitEnv |
( |
| ) |
|
|
protectedpure virtual |
Load a chunk from a file.
The chunk name will be based on the filename.
- Parameters
-
- Returns
- The loaded chunk, ready for compilation.
- Exceptions
-
Env& HoverRace::Script::Env::operator= |
( |
const Env & |
| ) |
|
|
delete |
void HoverRace::Script::Env::PushEnv |
( |
| ) |
|
|
protected |
Push the environment onto the stack.
InitEnv() will be called if the initial environment hasn't been set.
Execute a script from a file.
If there is an error executing the script, then the error message will be written to the error log and the function will return false
.
- Parameters
-
filename | The script filename (must be an absolute path). |
- Returns
true
if the script executed successfully, false
if there was an error.
void HoverRace::Script::Env::SetupEnv |
( |
| ) |
|
|
private |
Apply the environment to the function on the top of the stack.
The environment will be initialized for the first time if needed.
The function will remain on the stack afterwards.
bool HoverRace::Script::Env::initialized |
|
private |
Core& HoverRace::Script::Env::scripting |
|
private |
The documentation for this class was generated from the following files: