Spinning Topp Logo BlackTopp Studios
inc
Public Member Functions | Friends | List of all members
Mezzanine::Scripting::Lua::Lua51Script Class Reference

This class is used to store a Lua script and in its source and compiled state. More...

#include <lua51script.h>

+ Inheritance diagram for Mezzanine::Scripting::Lua::Lua51Script:
+ Collaboration diagram for Mezzanine::Scripting::Lua::Lua51Script:

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< iScriptArgumentGetArgument (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 FlaggedBufferGetByteCodeReference ()
 Get a reference to bytecode instead of a copy. More...
 
virtual Lua51ScriptGetMostDerived ()
 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< iScriptArgumentGetReturn (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 iScriptCompilableGetAsScriptCompilable ()
 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 iScriptCompilableGetAsScriptCompilable () 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 iScriptGetReferenceCountTargetAsPointer ()
 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 iScriptMultipleReturnGetAsiScriptMultipleReturn ()
 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.
 

Detailed Description

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.

Constructor & Destructor Documentation

Mezzanine::Scripting::Lua::Lua51Script::Lua51Script ( const String InitialSourceCode,
Lua51ScriptingEngine Compiler = 0,
Boole  JustAFunctionCall = false,
String  ScriptName = "?" 
)

Compiling Constructor.

Parameters
InitialSourceCodeThe source of the script to be used in this.
CompilerDefaults 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.
JustAFunctionCallDefaults to false, when true this optimizes the calling process and simply calls a function.
ScriptNameFor 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.

Parameters
InitialSourceCodeThe source of the script to be used in this.
CompilerA reference to a valid LuaScriptingEngine then that engine is used to compile (but not run) this script.
JustAFunctionCallDefaults to false, when true this optimizes the calling process and simply calls a function.
ScriptNameFor tracking and recalling scripts by name, defaults to "?"

Definition at line 89 of file lua51script.cpp.

Member Function Documentation

void Mezzanine::Scripting::Lua::Lua51Script::AddArgument ( CountedPtr< iScriptArgument Arg)
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.

Parameters
ArgThis 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.

void Mezzanine::Scripting::Lua::Lua51Script::AddArgument ( Lua51IntegerArgument  Arg)
virtual

Another overload to make adding arguments easier.

Parameters
ArgA Lua51IntegerArgument to pass into the script

Definition at line 106 of file lua51script.cpp.

void Mezzanine::Scripting::Lua::Lua51Script::AddArgument ( Lua51RealArgument  Arg)
virtual

Another overload to make adding arguments easier.

Parameters
ArgA Lua51RealArgument to pass into the script

Definition at line 109 of file lua51script.cpp.

void Mezzanine::Scripting::Lua::Lua51Script::AddArgument ( Lua51WholeArgument  Arg)
virtual

Another overload to make adding arguments easier.

Parameters
ArgA Lua51WholeArgument to pass into the script

Definition at line 112 of file lua51script.cpp.

void Mezzanine::Scripting::Lua::Lua51Script::AddArgument ( Lua51StringArgument  Arg)
virtual

Another overload to make adding arguments easier.

Parameters
ArgA Lua51StringArgument to pass into the script

Definition at line 115 of file lua51script.cpp.

void Mezzanine::Scripting::Lua::Lua51Script::AddArgument ( Lua51BoolArgument  Arg)
virtual

Another overload to make adding arguments easier.

Parameters
ArgA Lua51BoolArgument to pass into the script

Definition at line 118 of file lua51script.cpp.

void Mezzanine::Scripting::Lua::Lua51Script::AddArgument ( Lua51NilArgument  Arg)
virtual

Another overload to make adding arguments easier.

Parameters
ArgA Lua51NilArgument to pass into the script

Definition at line 121 of file lua51script.cpp.

void Mezzanine::Scripting::Lua::Lua51Script::AddArgument ( Integer  Arg)
virtual

Another overload to make adding arguments easier, This one adds a Lua51IntegerArgument.

Parameters
ArgAn Integer to pass into the script

Definition at line 124 of file lua51script.cpp.

void Mezzanine::Scripting::Lua::Lua51Script::AddArgument ( Real  Arg)
virtual

Another overload to make adding arguments easier, This one adds a Lua51RealArgument.

Parameters
ArgAn Real to pass into the script

Definition at line 127 of file lua51script.cpp.

void Mezzanine::Scripting::Lua::Lua51Script::AddArgument ( Whole  Arg)
virtual

Another overload to make adding arguments easier, This one adds a Lua51WholeArgument.

Parameters
ArgAn Whole to pass into the script

Definition at line 130 of file lua51script.cpp.

void Mezzanine::Scripting::Lua::Lua51Script::AddArgument ( String  Arg)
virtual

Another overload to make adding arguments easier, This one adds a Lua51StringArgument.

Parameters
ArgAn String to pass into the script

Definition at line 133 of file lua51script.cpp.

void Mezzanine::Scripting::Lua::Lua51Script::AddArgument ( Char8 Arg)
virtual

Another overload to make adding arguments easier, This one adds a Lua51StringArgument.

Parameters
ArgAn Char8* to pass into the script

Definition at line 136 of file lua51script.cpp.

void Mezzanine::Scripting::Lua::Lua51Script::AddArgument ( Boole  Arg)
virtual

Another overload to make adding arguments easier, This one adds a Lua51BoolArgument.

Parameters
ArgAn Bool to pass into the script

Definition at line 139 of file lua51script.cpp.

void Mezzanine::Scripting::Lua::Lua51Script::AddReturn ( CountedPtr< iScriptArgument ReturnArg)
virtual

Add another value to be returned.

Parameters
ReturnArgA 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.

void Mezzanine::Scripting::Lua::Lua51Script::ClearArguments ( )
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.

Parameters
CompilerThis 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.

Parameters
CompilerThis will be used to compile the script, no safety checks are performed.

Definition at line 193 of file lua51script.cpp.

ArgumentGroup Mezzanine::Scripting::Lua::Lua51Script::GetAllReturns ( ) const
virtual

Get the returns from the last exection of the script.

Returns
An ArgumentSet that can be iterated over to get all the values returned.

Implements Mezzanine::Scripting::iScriptMultipleReturn.

Definition at line 212 of file lua51script.cpp.

CountedPtr< iScriptArgument > Mezzanine::Scripting::Lua::Lua51Script::GetArgument ( Whole  ArgNumber) const
virtual

Retrieve a argument previously passed in.

Parameters
ArgNumberThe index of the passed parameter to retrun.
Returns
A reference counted pointer to a ScriptArgument.

Implements Mezzanine::Scripting::iScript.

Definition at line 157 of file lua51script.cpp.

Whole Mezzanine::Scripting::Lua::Lua51Script::GetArgumentCount ( ) const
virtual

How many arguments have been attached to this script?

Returns
A Whole containing the amount of arguments passed in so far.

Implements Mezzanine::Scripting::iScript.

Definition at line 151 of file lua51script.cpp.

BinaryTools::BinaryBuffer Mezzanine::Scripting::Lua::Lua51Script::GetByteCode ( ) const
virtual

Get the compiled version of the code if it is available.

Returns
If there is valid byte code this will retrieve that, otherwise this will return an empty bytecode.

Implements Mezzanine::Scripting::iScriptCompilable.

Definition at line 181 of file lua51script.cpp.

FlaggedBuffer & Mezzanine::Scripting::Lua::Lua51Script::GetByteCodeReference ( )
virtual

Get a reference to bytecode instead of a copy.

Returns
A BinaryTools::BinaryBuffer& containing either nothing or the Bytecode that would executed.

Definition at line 184 of file lua51script.cpp.

virtual Lua51Script* Mezzanine::Scripting::Lua::Lua51Script::GetMostDerived ( )
inlinevirtual

Get a pointer to the most Derived type of this class.

Returns
A pointer of the most derived pointing to this.

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.

Returns
A String containing the name

Definition at line 198 of file lua51script.cpp.

CountedPtr< iScriptArgument > Mezzanine::Scripting::Lua::Lua51Script::GetReturn ( Whole  ReturnNumber) const
virtual

Retrieve a value returned from a script.

Parameters
ReturnNumberThe index of the return to return.
Returns
A reference counted pointer to a ScriptArgument.

Implements Mezzanine::Scripting::iScriptMultipleReturn.

Definition at line 215 of file lua51script.cpp.

Whole Mezzanine::Scripting::Lua::Lua51Script::GetReturnCount ( ) const
virtual

How many values are being returned.

Returns
A Whole with the amount of items available to be returned now(from the last script call).

Implements Mezzanine::Scripting::iScriptMultipleReturn.

Definition at line 206 of file lua51script.cpp.

String Mezzanine::Scripting::Lua::Lua51Script::GetSourceCode ( ) const
virtual

If present this returns the code of script.

Returns
This will return either an empty String or the code. In cases where bytcode is set it is advised to clear this in implementations.

Implements Mezzanine::Scripting::iScript.

Definition at line 175 of file lua51script.cpp.

bool Mezzanine::Scripting::Lua::Lua51Script::IsCompiled ( ) const
virtual

Has this script already been compiled into a bytecode.

Returns
True if there is bytecode available false otherwise.

Implements Mezzanine::Scripting::iScriptCompilable.

Definition at line 187 of file lua51script.cpp.

void Mezzanine::Scripting::Lua::Lua51Script::RemoveArgument ( CountedPtr< iScriptArgument Arg)
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

Parameters
ArgA CountedPtr matching the one to be removed

Implements Mezzanine::Scripting::iScript.

Definition at line 145 of file lua51script.cpp.

void Mezzanine::Scripting::Lua::Lua51Script::RemoveArgument ( Whole  ArgNumber)
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

Parameters
ArgA CountedPtr matching the one to be removed

Implements Mezzanine::Scripting::iScript.

Definition at line 148 of file lua51script.cpp.

void Mezzanine::Scripting::Lua::Lua51Script::SetByteCode ( BinaryTools::BinaryBuffer  Code)
virtual

Set the bytecode used when this script is executed.

Parameters
CodeThe 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

Parameters
NewNameThe new value for the scripts name

Definition at line 201 of file lua51script.cpp.

void Mezzanine::Scripting::Lua::Lua51Script::SetSourceCode ( const String Code)
virtual

Sets the string version of the script.

Parameters
CodeA 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.

void Mezzanine::Scripting::Lua::Lua51Script::SetSourceCode ( const String Code,
CountedPtr< iScriptArgument Return1 
)
virtual

Sets the string version of the script.

Parameters
CodeA 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.

Parameters
Return1Something for containing the return from the script

Definition at line 168 of file lua51script.cpp.


The documentation for this class was generated from the following files: