This class is used to store a Lua script and in its source and compiled state. More...
#include <lua51script.h>
Public Member Functions | |
Lua51Script () | |
Simple constructor, creates a script that executes a no-op. | |
Lua51Script (const String &InitialSourceCode, Lua51ScriptingEngine *Compiler=0, Boole JustAFunctionCall=false, String ScriptName="?") | |
Compiling Constructor. More... | |
Lua51Script (const String &InitialSourceCode, Lua51ScriptingEngine &Compiler, Boole JustAFunctionCall=false, String ScriptName="?") | |
Compiling Cosntructor without pointer. More... | |
virtual | ~Lua51Script () |
Virtual destructor. | |
virtual void | AddArgument (CountedPtr< iScriptArgument > Arg) |
This adds an argument to be passed to the script. More... | |
virtual void | AddArgument (Lua51IntegerArgument Arg) |
Another overload to make adding arguments easier. More... | |
virtual void | AddArgument (Lua51RealArgument Arg) |
Another overload to make adding arguments easier. More... | |
virtual void | AddArgument (Lua51WholeArgument Arg) |
Another overload to make adding arguments easier. More... | |
virtual void | AddArgument (Lua51StringArgument Arg) |
Another overload to make adding arguments easier. More... | |
virtual void | AddArgument (Lua51BoolArgument Arg) |
Another overload to make adding arguments easier. More... | |
virtual void | AddArgument (Lua51NilArgument Arg) |
Another overload to make adding arguments easier. More... | |
virtual void | AddArgument (Integer Arg) |
Another overload to make adding arguments easier, This one adds a Lua51IntegerArgument. More... | |
virtual void | AddArgument (Real Arg) |
Another overload to make adding arguments easier, This one adds a Lua51RealArgument. More... | |
virtual void | AddArgument (Whole Arg) |
Another overload to make adding arguments easier, This one adds a Lua51WholeArgument. More... | |
virtual void | AddArgument (String Arg) |
Another overload to make adding arguments easier, This one adds a Lua51StringArgument. More... | |
virtual void | AddArgument (Char8 *Arg) |
Another overload to make adding arguments easier, This one adds a Lua51StringArgument. More... | |
virtual void | AddArgument (Boole Arg) |
Another overload to make adding arguments easier, This one adds a Lua51BoolArgument. More... | |
virtual void | AddArgument () |
When called with no arguments this inserts a Lua51nil. | |
virtual void | AddReturn (CountedPtr< iScriptArgument > ReturnArg) |
Add another value to be returned. More... | |
virtual void | ClearArguments () |
Remove all the ARGs!!! http://imgur.com/DJhw7. More... | |
void | Compile (Lua51ScriptingEngine *Compiler) |
This will compile the Lua script. More... | |
void | Compile (Lua51ScriptingEngine &Compiler) |
This will compile the Lua script. More... | |
virtual ArgumentGroup | GetAllReturns () const |
Get the returns from the last exection of the script. More... | |
virtual CountedPtr< iScriptArgument > | GetArgument (Whole ArgNumber) const |
Retrieve a argument previously passed in. More... | |
virtual Whole | GetArgumentCount () const |
How many arguments have been attached to this script? More... | |
virtual BinaryTools::BinaryBuffer | GetByteCode () const |
Get the compiled version of the code if it is available. More... | |
virtual FlaggedBuffer & | GetByteCodeReference () |
Get a reference to bytecode instead of a copy. More... | |
virtual Lua51Script * | GetMostDerived () |
Get a pointer to the most Derived type of this class. More... | |
String | GetName () const |
Get the name of the current Script. More... | |
virtual CountedPtr< iScriptArgument > | GetReturn (Whole ReturnNumber) const |
Retrieve a value returned from a script. More... | |
virtual Whole | GetReturnCount () const |
How many values are being returned. More... | |
virtual String | GetSourceCode () const |
If present this returns the code of script. More... | |
virtual bool | IsCompiled () const |
Has this script already been compiled into a bytecode. More... | |
virtual void | RemoveArgument (CountedPtr< iScriptArgument > Arg) |
Remove an argument based on a CountedPtr to the script. More... | |
virtual void | RemoveArgument (Whole ArgNumber) |
Remove an argument based on a CountedPtr to the script. More... | |
virtual void | SetByteCode (BinaryTools::BinaryBuffer Code) |
Set the bytecode used when this script is executed. More... | |
void | SetName (const String &NewName) |
change the name of the Script More... | |
virtual void | SetSourceCode (const String &Code) |
Sets the string version of the script. More... | |
virtual void | SetSourceCode (const String &Code, CountedPtr< iScriptArgument > Return1) |
Sets the string version of the script. More... | |
Public Member Functions inherited from Mezzanine::Scripting::iScriptCompilable | |
virtual iScriptCompilable * | GetAsScriptCompilable () |
If your only handle to this is a pointer of type iScript this can be called to get a pointer to an iScriptCompilable if it would be valid. More... | |
virtual bool | IsCompilable () const |
Any script implementing this class is compilable. More... | |
Public Member Functions inherited from Mezzanine::Scripting::iScript | |
iScript () | |
default constructor More... | |
virtual bool | CanReturnMultples () |
Does this script support multiple return values. More... | |
Whole | DecrementReferenceCount () |
Decrease the reference count by one and return the updated count. More... | |
virtual iScriptCompilable * | GetAsScriptCompilable () const |
If your only handle to this is a pointer of type iScript this can be called to get a pointer to an iScriptCompilable if it would be valid. More... | |
Whole | GetReferenceCount () |
Get the current amount of references. More... | |
virtual iScript * | GetReferenceCountTargetAsPointer () |
Gets the actual pointer to the target. More... | |
Whole | IncrementReferenceCount () |
Increase the reference count by one and return the updated count. More... | |
Public Member Functions inherited from Mezzanine::Scripting::iScriptMultipleReturn | |
virtual bool | CanReturnMultples () const |
Does this script support multiple return values. More... | |
virtual iScriptMultipleReturn * | GetAsiScriptMultipleReturn () |
If your only handle to this is a pointer of type iScript this can be called to get a pointer to an iScriptMultipleReturn if it would be valid. More... | |
Friends | |
class | Lua51ScriptingEngine |
Makes passing internal data much easier and all Lua51 are logically encapsulated as a single system still. | |
Additional Inherited Members | |
Protected Attributes inherited from Mezzanine::Scripting::iScript | |
Whole | RefCount |
This is the Counter that stores how many references exist. | |
This class is used to store a Lua script and in its source and compiled state.
To execute this script use LuaScriptingEngine::Compile
Definition at line 94 of file lua51script.h.
Mezzanine::Scripting::Lua::Lua51Script::Lua51Script | ( | const String & | InitialSourceCode, |
Lua51ScriptingEngine * | Compiler = 0 , |
||
Boole | JustAFunctionCall = false , |
||
String | ScriptName = "?" |
||
) |
Compiling Constructor.
InitialSourceCode | The source of the script to be used in this. |
Compiler | Defaults to a null pointer. If passed a null pointer this does nothing. If passed a valid LuaScriptingEngine then that engine is used to compile (but not run) this script. |
JustAFunctionCall | Defaults to false, when true this optimizes the calling process and simply calls a function. |
ScriptName | For tracking and recalling scripts by name, defaults to "?" |
Definition at line 80 of file lua51script.cpp.
Mezzanine::Scripting::Lua::Lua51Script::Lua51Script | ( | const String & | InitialSourceCode, |
Lua51ScriptingEngine & | Compiler, | ||
Boole | JustAFunctionCall = false , |
||
String | ScriptName = "?" |
||
) |
Compiling Cosntructor without pointer.
InitialSourceCode | The source of the script to be used in this. |
Compiler | A reference to a valid LuaScriptingEngine then that engine is used to compile (but not run) this script. |
JustAFunctionCall | Defaults to false, when true this optimizes the calling process and simply calls a function. |
ScriptName | For tracking and recalling scripts by name, defaults to "?" |
Definition at line 89 of file lua51script.cpp.
|
virtual |
This adds an argument to be passed to the script.
All arguments added with this are passed in FIFO order to the Script during or just before execution. This should normally run in constant time. Some scripting implementations may change the order arguments are passed if doing it another way mays more sense.
Arg | This accepts a CountedPtr to a script argument and The script shares responsibility with caller for deleting the argument. |
Implements Mezzanine::Scripting::iScript.
Definition at line 103 of file lua51script.cpp.
|
virtual |
Another overload to make adding arguments easier.
Arg | A Lua51IntegerArgument to pass into the script |
Definition at line 106 of file lua51script.cpp.
|
virtual |
Another overload to make adding arguments easier.
Arg | A Lua51RealArgument to pass into the script |
Definition at line 109 of file lua51script.cpp.
|
virtual |
Another overload to make adding arguments easier.
Arg | A Lua51WholeArgument to pass into the script |
Definition at line 112 of file lua51script.cpp.
|
virtual |
Another overload to make adding arguments easier.
Arg | A Lua51StringArgument to pass into the script |
Definition at line 115 of file lua51script.cpp.
|
virtual |
Another overload to make adding arguments easier.
Arg | A Lua51BoolArgument to pass into the script |
Definition at line 118 of file lua51script.cpp.
|
virtual |
Another overload to make adding arguments easier.
Arg | A Lua51NilArgument to pass into the script |
Definition at line 121 of file lua51script.cpp.
|
virtual |
Another overload to make adding arguments easier, This one adds a Lua51IntegerArgument.
Arg | An Integer to pass into the script |
Definition at line 124 of file lua51script.cpp.
|
virtual |
Another overload to make adding arguments easier, This one adds a Lua51RealArgument.
Arg | An Real to pass into the script |
Definition at line 127 of file lua51script.cpp.
|
virtual |
Another overload to make adding arguments easier, This one adds a Lua51WholeArgument.
Arg | An Whole to pass into the script |
Definition at line 130 of file lua51script.cpp.
|
virtual |
Another overload to make adding arguments easier, This one adds a Lua51StringArgument.
Arg | An String to pass into the script |
Definition at line 133 of file lua51script.cpp.
|
virtual |
Another overload to make adding arguments easier, This one adds a Lua51StringArgument.
Arg | An Char8* to pass into the script |
Definition at line 136 of file lua51script.cpp.
|
virtual |
Another overload to make adding arguments easier, This one adds a Lua51BoolArgument.
Arg | An Bool to pass into the script |
Definition at line 139 of file lua51script.cpp.
|
virtual |
Add another value to be returned.
ReturnArg | A copy assignable script argument that conveys type information to the specific language runtime |
Some scripting languages (Lua51) require knowledge of the return types of the scripts in order to extract them from the language runtime. Pointers to classes derived from iScriptArgument should convey that typing information to such language runtimes.
Implements Mezzanine::Scripting::iScriptMultipleReturn.
Definition at line 209 of file lua51script.cpp.
|
virtual |
Remove all the ARGs!!! http://imgur.com/DJhw7.
This should run in constant time. It still might be slower than removing and readding just one a few arguments in simple cases
Implements Mezzanine::Scripting::iScript.
Definition at line 154 of file lua51script.cpp.
void Mezzanine::Scripting::Lua::Lua51Script::Compile | ( | Lua51ScriptingEngine * | Compiler | ) |
This will compile the Lua script.
Compiler | This will be used to compile the script, no safety checks are performed. |
Definition at line 190 of file lua51script.cpp.
void Mezzanine::Scripting::Lua::Lua51Script::Compile | ( | Lua51ScriptingEngine & | Compiler | ) |
This will compile the Lua script.
Compiler | This will be used to compile the script, no safety checks are performed. |
Definition at line 193 of file lua51script.cpp.
|
virtual |
Get the returns from the last exection of the script.
Implements Mezzanine::Scripting::iScriptMultipleReturn.
Definition at line 212 of file lua51script.cpp.
|
virtual |
Retrieve a argument previously passed in.
ArgNumber | The index of the passed parameter to retrun. |
Implements Mezzanine::Scripting::iScript.
Definition at line 157 of file lua51script.cpp.
|
virtual |
How many arguments have been attached to this script?
Implements Mezzanine::Scripting::iScript.
Definition at line 151 of file lua51script.cpp.
|
virtual |
Get the compiled version of the code if it is available.
Implements Mezzanine::Scripting::iScriptCompilable.
Definition at line 181 of file lua51script.cpp.
|
virtual |
Get a reference to bytecode instead of a copy.
Definition at line 184 of file lua51script.cpp.
|
inlinevirtual |
Get a pointer to the most Derived type of this class.
Reimplemented from Mezzanine::Scripting::iScriptCompilable.
Definition at line 294 of file lua51script.h.
String Mezzanine::Scripting::Lua::Lua51Script::GetName | ( | ) | const |
Get the name of the current Script.
Definition at line 198 of file lua51script.cpp.
|
virtual |
Retrieve a value returned from a script.
ReturnNumber | The index of the return to return. |
Implements Mezzanine::Scripting::iScriptMultipleReturn.
Definition at line 215 of file lua51script.cpp.
|
virtual |
How many values are being returned.
Implements Mezzanine::Scripting::iScriptMultipleReturn.
Definition at line 206 of file lua51script.cpp.
|
virtual |
If present this returns the code of script.
Implements Mezzanine::Scripting::iScript.
Definition at line 175 of file lua51script.cpp.
|
virtual |
Has this script already been compiled into a bytecode.
Implements Mezzanine::Scripting::iScriptCompilable.
Definition at line 187 of file lua51script.cpp.
|
virtual |
Remove an argument based on a CountedPtr to the script.
This searches through the internal list and removes the first entry it finds matching this. This should be treated as taking linear time, relative to the total count of arguments assigned to this script, to run. This can be used with AddArgument to re-order the way parameters are passed into a script
Arg | A CountedPtr matching the one to be removed |
Implements Mezzanine::Scripting::iScript.
Definition at line 145 of file lua51script.cpp.
|
virtual |
Remove an argument based on a CountedPtr to the script.
This searches through the internal list and removes the first entry it finds matching this. This should be treated as taking linear time, relative to the total count of arguments assigned to this script, to run. This can be used with AddArgument to re-order the way parameters are passed into a script
Arg | A CountedPtr matching the one to be removed |
Implements Mezzanine::Scripting::iScript.
Definition at line 148 of file lua51script.cpp.
|
virtual |
Set the bytecode used when this script is executed.
Code | The Binary version of the script |
This is what will be executed. No reverse compiling support is provided, so it is advisable that implementations of this either clear the source code or set it to the source that matches the compiled binary.
Implements Mezzanine::Scripting::iScriptCompilable.
Definition at line 178 of file lua51script.cpp.
void Mezzanine::Scripting::Lua::Lua51Script::SetName | ( | const String & | NewName | ) |
change the name of the Script
NewName | The new value for the scripts name |
Definition at line 201 of file lua51script.cpp.
|
virtual |
Sets the string version of the script.
Code | A string that defines the source code to be executed or compiled whne running the script. |
It is recomended that when this is called that implentors clear any bytecode or any other compiled version of the script. This will prevent issues with mismatched version of source and bytecode.
Implements Mezzanine::Scripting::iScript.
Definition at line 162 of file lua51script.cpp.
|
virtual |
Sets the string version of the script.
Code | A string that defines the source code to be executed or compiled whne running the script. |
It is recomended that when this is called that implentors clear any bytecode or any other compiled version of the script. This will prevent issues with mismatched version of source and bytecode.
Return1 | Something for containing the return from the script |
Definition at line 168 of file lua51script.cpp.