A script environment.
More...
#include <Core.h>
|
std::unique_ptr< luabind::object > | NIL |
|
A script environment.
- Author
- Michael Imamura
HoverRace::Script::Core::Core |
( |
| ) |
|
HoverRace::Script::Core::Core |
( |
const Core & |
core | ) |
|
|
delete |
HoverRace::Script::Core::~Core |
( |
| ) |
|
|
virtual |
void HoverRace::Script::Core::ActivateSandbox |
( |
| ) |
|
Activate the security sandbox.
This guards against methods a script may use to access the filesystem or break out of the sandbox.
Core::OutHandle HoverRace::Script::Core::AddOutput |
( |
std::shared_ptr< std::ostream > |
out | ) |
|
Redirect output to a stream.
- Parameters
-
out | The output stream (wrapped in a shared pointer). May be NULL to use the system default. |
- Returns
- A handle for removing the stream later.
int HoverRace::Script::Core::Call |
( |
int |
numParams = 0 , |
|
|
Help::HelpHandler * |
helpHandler = nullptr |
|
) |
| |
Pop a function off the stack and execute it.
- Parameters
-
numParams | The number of params being passed to the function. |
helpHandler | Optional callback for when a script requests API help. |
- Returns
- The number of return values from the function that remain on the stack.
- Exceptions
-
ScriptExn | The code signaled an error while executing. |
void HoverRace::Script::Core::CallAndPrint |
( |
int |
numParams = 0 , |
|
|
Help::HelpHandler * |
helpHandler = nullptr |
|
) |
| |
|
inline |
void HoverRace::Script::Core::Compile |
( |
const Chunk & |
chunk | ) |
|
Compile a chunk of code.
Upon successful execution, the compiled chunk will be pushed to the stack.
- Parameters
-
chunk | The chunk to compile. |
- 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 failed to compile. |
int HoverRace::Script::Core::ErrorFunc |
( |
lua_State * |
L | ) |
|
|
staticprivate |
The error function for Luabind.
We use the default Lua function for non-Luabind calls.
- Parameters
-
- Returns
template<class ReturnPolicy = PrintReturn>
void HoverRace::Script::Core::Execute |
( |
const Chunk & |
chunk, |
|
|
Help::HelpHandler * |
helpHandler = nullptr , |
|
|
ReturnPolicy |
rp = ReturnPolicy() |
|
) |
| |
|
inline |
Safely compile and execute a chunk of code.
This is a convenience function.
- Parameters
-
chunk | The code to execute. |
helpHandler | Optional callback for when a script requests API help. |
rp | Optional policy to handle return values. |
- 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. |
lua_State* HoverRace::Script::Core::GetState |
( |
| ) |
const |
|
inline |
std::string HoverRace::Script::Core::GetVersionString |
( |
| ) |
const |
Retrieve the full scripting version string (name and version).
- Returns
- The string (never empty).
template<class ReturnPolicy = PrintReturn>
int HoverRace::Script::Core::Invoke |
( |
int |
numParams = 0 , |
|
|
Help::HelpHandler * |
helpHandler = nullptr , |
|
|
ReturnPolicy |
rp = ReturnPolicy() |
|
) |
| |
|
inline |
Pop a function off the stack and execute it, printing any return values.
- Parameters
-
numParams | The number of params being passed to the function. |
helpHandler | Optional callback for when a script requests API help. |
rp | Optional policy to handle return values. |
- Returns
- The number of return values remaining on the stack.
- Exceptions
-
ScriptExn | The code signaled an error while executing. |
void HoverRace::Script::Core::LoadClassHelp |
( |
const std::string & |
className | ) |
|
|
private |
int HoverRace::Script::Core::LPrint |
( |
lua_State * |
state | ) |
|
|
staticprivate |
int HoverRace::Script::Core::LSandboxedFunction |
( |
lua_State * |
state | ) |
|
|
staticprivate |
Core& HoverRace::Script::Core::operator= |
( |
const Core & |
| ) |
|
|
delete |
std::string HoverRace::Script::Core::PopError |
( |
lua_State * |
state | ) |
|
|
staticprivate |
Pop the error message off the stack.
Only call this if you KNOW that there is an error on the top of the stack.
- Parameters
-
- Returns
- The error as a string.
void HoverRace::Script::Core::Print |
( |
const std::string & |
s | ) |
|
Print a message to all registered output streams.
- Parameters
-
s | The message to broadcast (a newline will be appended automatically). |
void HoverRace::Script::Core::PrintFromStack |
( |
lua_State * |
state, |
|
|
int |
n |
|
) |
| |
|
staticprivate |
void HoverRace::Script::Core::PrintStack |
( |
| ) |
|
void HoverRace::Script::Core::RemoveOutput |
( |
const OutHandle & |
handle | ) |
|
void HoverRace::Script::Core::ReqHelp |
( |
const std::string & |
className | ) |
|
Request the documentation for a scripting API class.
This must only be called from a script peer as the result of a Lua invocation!
- Parameters
-
className | The name of the class (may not be blank). |
void HoverRace::Script::Core::ReqHelp |
( |
const std::string & |
className, |
|
|
const std::string & |
methodName |
|
) |
| |
Request the documentation for a scripting API class or method.
This must only be called from a script peer as the result of a Lua invocation!
- Parameters
-
className | The name of the class (may not be blank). |
methodName | The name of the method within the class (may be blank to retrieve the class documentation instead of the method documentation). |
Core * HoverRace::Script::Core::Reset |
( |
| ) |
|
|
virtual |
Reset changes to the global environment.
When creating a new instance, this member function must be called at least once before executing any scripts. This is used for fixing accidental changes to globals. Note that this will effectively deactivate the security sandbox. Call ActivateSandbox() to reactivate if necessary. The state returned by GetState() is otherwise unchanged.
- Returns
- The same instance.
Reimplemented in HoverRace::Client::HoverScript::ClientScriptCore.
const std::string HoverRace::Script::Core::DEFAULT_CHUNK_NAME |
|
static |
std::unique_ptr<luabind::object> HoverRace::Script::Core::NIL |
outs_t HoverRace::Script::Core::outs |
|
private |
lua_State* HoverRace::Script::Core::state |
|
private |
The documentation for this class was generated from the following files: