Spinning Topp Logo BlackTopp Studios
inc
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Friends | List of all members
Mezzanine::Scripting::Lua::Lua51ScriptingEngine Class Reference

The workhorse of the Lua scripting system. All scripts come here to be executed. More...

#include <lua51scriptingengine.h>

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

Public Types

typedef Mezzanine::Trie< char, const Mezzanine::String * > CommandTrie
 A type for efficiently storing the kinds of Lexigraphical data aboutthe Lua runtime.
 
enum  Lua51Libraries {
  NoLib = 0, BaseLib = 1, PackageLib = 2, StringLib = 4,
  TableLib = 8, MathLib = 16, IOLib = 32, OSLib = 64,
  DebugLib = 128, MezzLib = 256, MezzSafeLib = 512, MezzXMLLib = 1024,
  MezzXMLSafeLib = 2048, MezzThreadingLib = 4096, MezzThreadingSafeLib = 8192, MezzPhysicsLib = 16384,
  MezzPhysicsSafeLib = 32768, MezzMathToolsLib = 65536, MezzMathToolsSafeLib = 131072, FirstLib = BaseLib,
  LastLib = MezzMathToolsSafeLib, DefaultLibs, AllLibs
}
 Intended only to make constructing an Lua51ScriptingEngine with the desired libraries open a little easier. More...
 
- Public Types inherited from Mezzanine::ManagerBase
enum  ManagerType {
  MT_Undefined = 0, MT_AudioManager = 1, MT_AnimationManager = 2, MT_CollisionShapeManager = 3,
  MT_CompositorManager = 4, MT_GraphicsManager = 5, MT_EventManager = 6, MT_InputManager = 7,
  MT_LogManager = 8, MT_MaterialManager = 9, MT_MeshManager = 10, MT_NetworkManager = 11,
  MT_ResourceManager = 12, MT_ScriptingManager = 13, MT_TextureManager = 14, MT_UIManager = 15,
  MT_ActorManager = 101, MT_AreaEffectManager = 102, MT_DebrisManager = 103, MT_PagingManager = 104,
  MT_PhysicsManager = 105, MT_SceneManager = 106, MT_SoundScapeManager = 107, MT_TerrainManager = 108,
  MT_VehicleManager = 109, MT_UserCreated = 512
}
 A listing of Manager Types. More...
 

Public Member Functions

 Lua51ScriptingEngine (Lua51Libraries LibrariesToOpen=DefaultLibs)
 Constructs a Scripting engine with a set of libraries preloaded. More...
 
 Lua51ScriptingEngine (const NameValuePairList &Params)
 Construct a from name value pairs. More...
 
 Lua51ScriptingEngine (const XML::Node &XMLNode)
 Construct by deserializing. More...
 
virtual ~Lua51ScriptingEngine ()
 Virtual Deconstructor.
 
virtual void AliasLibrary (const String &Base, const String &Sub, const String &Alias)
 Nest Lua modules to put libraries in more clean positions. More...
 
virtual CountedPtr< iScriptCompilableCompile (const String &SourceToCompile)
 Calls Compile(CountedPtr<iScriptCompilable>) and returns a CountedPtr to the script created. More...
 
virtual void Compile (CountedPtr< iScriptCompilable > &ScriptToCompile)
 Accepts an Counted ptr to a script and compiles it. More...
 
virtual void Compile (CountedPtr< Lua51Script > &ScriptToCompile)
 Compile a Lua51 script. More...
 
virtual void Compile (Lua51Script &ScriptToCompile)
 Performs the compilation on a script reference. More...
 
virtual void Compile (Lua51Script *ScriptToCompile)
 Performs the compilation on a raw pointer. More...
 
virtual CountedPtr< iScriptExecute (const String &ScriptSource)
 Compile and execute a passed string. More...
 
virtual void Execute (CountedPtr< iScript > &ScriptToRun)
 Implements a required for iScriptManager, Calls Execute(CountedPtr<Lua51Script>) More...
 
virtual void Execute (CountedPtr< Lua51Script > &ScriptToRun)
 This will execute the passed script, compiling it if not present. More...
 
virtual void Execute (Lua51Script &ScriptToRun)
 Performs the compilation on a script reference. More...
 
virtual void Execute (Lua51Script *ScriptToRun)
 Performs the compilation on a raw pointer. More...
 
virtual String GetImplementationTypeName () const
 This Allows any manager name to be sent to a stream. Primarily used for logging. More...
 
const StringGetLuaTypeString (int StackLocation)
 Get a human friendly string containing the type of the thing at the given stack location. More...
 
lua_State * GetRawLuaState ()
 Get the underlying Lua state that can be used with lua api calls directly. More...
 
int GetStackCount ()
 The stack is a specific part of the State relating to how data is passed between functions. How big is that? More...
 
CountedPtr< iScriptArgumentGetValue (const String &LuaIdentifier)
 Get the Value stored in a lua identifier. More...
 
virtual Boole IsLibraryOpen (Lua51Libraries LibToCheck)
 Check the Lua state to see if a table exists. More...
 
virtual void OpenAllLibraries ()
 Make all Mezzanine and Lua functionality. More...
 
virtual void OpenBaseLibrary ()
 Make some eof the more core functionality available to lua scripts. More...
 
virtual void OpenDebugLibrary ()
 Enable Debugging Lua features. More...
 
virtual void OpenDefaultLibraries ()
 Prepare most Mezzanine and some Lua functionality for use in Lua scripts. More...
 
virtual void OpenIOLibrary ()
 Enable Input/Output in lua scripts for reading and writing files. More...
 
virtual void OpenLibraries (int LibrariesToOpen)
 Makes Lua function calls in Lua standard libraries available for use in Lua scripts. More...
 
virtual void OpenMathLibrary ()
 Enable Lua math and random number functionality. More...
 
virtual void OpenMezzanineLibrary ()
 Make everything in the Mezzanine Libary available for use in Lua51 scripts. More...
 
virtual void OpenMezzanineMathToolsLibrary ()
 Make the MathTools parts of the Mezzanine Libary available for use in Lua51 scripts.
 
virtual void OpenMezzanineMathToolsSafeLibrary ()
 Make the MathTools parts of the Mezzanine Libary available for use in Lua51 scripts. More...
 
virtual void OpenMezzaninePhysicsLibrary ()
 Make the Physics parts of the Mezzanine Libary available for use in Lua51 scripts. More...
 
virtual void OpenMezzaninePhysicsSafeLibrary ()
 Make the Physics parts of the Mezzanine Libary available for use in Lua51 scripts. More...
 
virtual void OpenMezzanineSafeLibrary ()
 Make a subset of the Mezzanine Library available for use in Lua51 scripts. More...
 
virtual void OpenMezzanineThreadingLibrary ()
 Make the Threading parts of the Mezzanine Libary available for use in Lua51 scripts. More...
 
virtual void OpenMezzanineThreadingSafeLibrary ()
 Make the Threading parts of the Mezzanine Libary available for use in Lua51 scripts. More...
 
virtual void OpenMezzanineXMLLibrary ()
 Make the XML parts of the Mezzanine Libary available for use in Lua51 scripts. More...
 
virtual void OpenMezzanineXMLSafeLibrary ()
 Make the XML parts of the Mezzanine Libary available for use in Lua51 scripts. More...
 
virtual void OpenOSLibrary ()
 EnableOS facilities in lua scriptsm such as file managements, time and shell execution. More...
 
virtual void OpenPackageLibrary ()
 Allow Lua scripts to load other libraries. More...
 
virtual void OpenStringLibrary ()
 Allow Lua scripts access to the Lua string manipulation libary. More...
 
virtual void OpenTableLibrary ()
 Enable Lua table manipulation functionality. More...
 
void PopulateTabCompletionTrie (CommandTrie &CommandGroup, const String &TableName="", std::vector< String > AlreadyDidTables=std::vector< String >())
 Populate a Trie with all the members and types in the current lua runtime. More...
 
- Public Member Functions inherited from Mezzanine::Scripting::iScriptCompilationManager
virtual ~iScriptCompilationManager ()
 Overidable deconstructor.
 
- Public Member Functions inherited from Mezzanine::Scripting::iScriptingManager
 iScriptingManager ()
 Class constructor. More...
 
virtual ~iScriptingManager ()
 Class destructor.
 
virtual void Deinitialize ()
 Removes this manager from any necessary configuration so it can be safely disposed of. More...
 
virtual ManagerType GetInterfaceType () const
 This returns the type of this manager. More...
 
virtual void Initialize ()
 Configures this manager for use prior to entering the main loop. More...
 
- Public Member Functions inherited from Mezzanine::EntresolManager
 EntresolManager ()
 Class constructor.
 
virtual ~EntresolManager ()
 Class destructor.
 
- Public Member Functions inherited from Mezzanine::ManagerBase
 ManagerBase ()
 Class constructor.
 
virtual ~ManagerBase ()
 Class destructor.
 
virtual String GetInterfaceTypeAsString () const
 Gets a string of the interface type of this manager. More...
 
Boole IsInitialized () const
 Gets whether or not this manager has been initialized. More...
 

Static Public Member Functions

static Lua51Libraries GetLibFromName (String Name)
 Convert a string similar to one of the names on the Lua51ScriptingEngine to number. More...
 
static const StringGetLibName (Lua51Libraries Lib)
 Convert a Lua51Libraries value to its name. More...
 
static const StringGetTableName (Lua51Libraries Lib)
 Convert a Lua51Libraries value to the name of a table it loads. More...
 
static bool IsValidCharInIdentifier (const char IdChar)
 Is the given character valid for is in a Lua Identifier. More...
 
static bool IsValidCharInTableIdentifier (const char IdChar)
 Is the given character valid for is in a Lua Identifier including tables leading up to it and scoping operators. More...
 
static bool IsValidCharStartIdentifier (const char IdChar)
 Is the given character valid for starting a Lua Identifier. More...
 
static bool IsValidIdentifier (const String &Id)
 Is a string a valid identifier in Lua. More...
 
- Static Public Member Functions inherited from Mezzanine::ManagerBase
static String GetTypeAsString (const ManagerType &ManagerType)
 Gets the string form of the type of manager. More...
 
static ManagerType GetTypeFromString (const String &ManagerName)
 Gets the type of manager requested from a string. More...
 

Static Public Attributes

static const String AllLibsName = "All"
 The name used to identify the set of all libraries, "All".
 
static const String BaseLibName = "Base"
 The name used to identify the Base library, "Base".
 
static const String BaseTableName = "coroutine"
 The name used to identify a table loaded by the Base library, "coroutine".
 
static const String DebugLibName = "Debug"
 The name used to identify the Debug library, "Debug".
 
static const String DebugTableName = "debug"
 The name used to identify a table loaded by the Debug library, "debug".
 
static const String DefaultLibsName = "Default"
 The name used to identify the Default set of libraries, "Default".
 
static const String GlobalTableName = "_G"
 The place Lua keeps all the identifiers in a single Lua State.
 
static const ManagerBase::ManagerType InterfaceType = ManagerBase::MT_ScriptingManager
 The type of functionality this manager provides. For ManagerBase compatibility.
 
static const String IOLibName = "IO"
 The name used to identify the IO library, "IO".
 
static const String IOTableName = "io"
 The name used to identify a table loaded by the IO library, "io".
 
static const String MathLibName = "Math"
 The name used to identify the Math library, "Math".
 
static const String MathTableName = "math"
 The name used to identify a table loaded by the Math library, "math".
 
static const String MezzLibName = "Mezzanine"
 The name used to identify the Mezzanine library, "Mezzanine".
 
static const String MezzMathToolsLibName = "MezzanineMathTools"
 The name used to identify the MezzanineMathTools library, "MezzanineMathTools".
 
static const String MezzMathToolsSafeLibName = "MezzanineMathToolsSafe"
 The name used to identify the MezzanineMathToolsSafe library, "MezzanineMathToolsSafe".
 
static const String MezzMathToolsSafeTableName = "MezzanineMathToolsSafe"
 The name used to identify a table loaded by the MezzanineMathToolsSafe library, "MezzanineMathToolsSafe".
 
static const String MezzMathToolsTableName = "MezzanineMathTools"
 The name used to identify a table loaded by the MezzanineMathTools library, "MezzanineMathTools".
 
static const String MezzPhysicsLibName = "MezzaninePhysics"
 The name used to identify the MezzaninePhysics library, "MezzaninePhysics".
 
static const String MezzPhysicsSafeLibName = "MezzaninePhysicsSafe"
 The name used to identify the MezzaninePhysicsSafe library, "MezzaninePhysicsSafe".
 
static const String MezzPhysicsSafeTableName = "MezzaninePhysicsSafe"
 The name used to identify a table loaded by the MezzaninePhysicsSafe library, "MezzaninePhysicsSafe".
 
static const String MezzPhysicsTableName = "MezzaninePhysics"
 The name used to identify a table loaded by the MezzaninePhysics library, "MezzaninePhysics".
 
static const String MezzSafeLibName = "MezzanineSafe"
 The name used to identify the MezzanineSafe library, "MezzanineSafe".
 
static const String MezzSafeTableName = "MezzanineSafe"
 The name used to identify a table loaded by the MezzanineSafe library, "MezzanineSafe".
 
static const String MezzTableName = "Mezzanine"
 The name used to identify a table loaded by the Mezzanine library, "Mezzanine".
 
static const String MezzThreadingLibName = "MezzanineThreading"
 The name used to identify the MezzanineThreading library, "MezzanineThreading".
 
static const String MezzThreadingSafeLibName = "MezzanineThreadingSafe"
 The name used to identify the MezzanineThreadingSafe library, "MezzanineThreadingSafe".
 
static const String MezzThreadingSafeTableName = "MezzanineThreadingSafe"
 The name used to identify a table loaded by the MezzanineThreadingSafe library, "MezzanineThreadingSafe".
 
static const String MezzThreadingTableName = "MezzanineThreading"
 The name used to identify a table loaded by the MezzanineThreading library, "MezzanineThreading".
 
static const String MezzXMLLibName = "MezzanineXML"
 The name used to identify the MezzanineXML library, "MezzanineXML".
 
static const String MezzXMLSafeLibName = "MezzanineXMLSafe"
 The name used to identify the MezzanineXMLSafe library, "MezzanineXMLSafe".
 
static const String MezzXMLSafeTableName = "MezzanineXMLSafe"
 The name used to identify a table loaded by the MezzanineXMLSafe library, "MezzanineXMLSafe".
 
static const String MezzXMLTableName = "MezzanineXML"
 The name used to identify a table loaded by the MezzanineXML library, "MezzanineXML".
 
static const String NoLibName = "None"
 The name used to identify No libraries, "None".
 
static const String OSLibName = "OS"
 The name used to identify the OS library, "OS".
 
static const String OSTableName = "os"
 The name used to identify a table loaded by the OS library, "os".
 
static const String PackageLibName = "Package"
 The name used to identify the Package library, "Package".
 
static const String PackageTableName = "package"
 The name used to identify a table loaded by the Package library, "package".
 
static const String ScriptEngineName = "Lua51ScriptingEngine"
 The name of this scripting engine for inspection purposes, "Lua51ScriptingEngine".
 
static const String StringLibName = "String"
 The name used to identify the String library, "String".
 
static const String StringTableName = "string"
 The name used to identify a table loaded by the String library, "string".
 
static const String TableLibName = "Table"
 The name used to identify the Table library, "Table".
 
static const String TableTableName = "table"
 The name used to identify a table loaded by the Table library, "table".
 
static const String TypeNameBoolean = "Boolean"
 A human friendly representation of the Lua type boolean.
 
static const String TypeNameFunction = "Function"
 A human friendly representation of the Lua type function.
 
static const String TypeNameLightUserData = "Light User Data"
 A human friendly representation of the Lua type light user data.
 
static const String TypeNameNil = "Nil"
 A human friendly representation of the Lua type nil.
 
static const String TypeNameNumber = "Number"
 A human friendly representation of the Lua type number.
 
static const String TypeNameString = "String"
 A human friendly representation of the Lua type string.
 
static const String TypeNameTable = "Table"
 A human friendly representation of the Lua type table.
 
static const String TypeNameThread = "Thread"
 A human friendly representation of the Lua type thread.
 
static const String TypeNameUserData = "User Data"
 A human friendly representation of the Lua type user data.
 

Protected Member Functions

void CheckLuaStateAfterConstruction () const
 Checks the internal Lua to see if memory was correctly allocated during its creation. More...
 
CountedPtr< iScriptArgumentScriptArgFromStack ()
 Get the top value of the Lua stack. More...
 
Whole ScriptArgsFromStack (Lua51Script *ScriptWasRun, Integer PreviousStackSize)
 Remove Scripts from Lua stack and put them into arguments on the passed script. More...
 
void ScriptArgsOntoStack (Lua51Script *ScriptToLoad)
 Put the arguments in a script onto the stack. More...
 
void ScriptOntoStack (Lua51Script *ScriptToLoad)
 Put a lua script onto the stack, compiling it if needed. More...
 
void SetMathTools ()
 Set The MezzanineMathTools library as the MathTools member of the Mezzanine library or fail silently.
 
void SetMathToolsSafe ()
 Set The MezzanineMathToolsSafe library as the MathTools member of the MezzanineSafe library or fail silently.
 
void SetPhysics ()
 Set The MezzaninePhysics library as the Physics member of the Mezzanine library or fail silently.
 
void SetPhysicsSafe ()
 Set The MezzaninePhysicsSafe library as the Physics member of the MezzanineSafe library or fail silently.
 
void SetThreading ()
 Set The MezzanineThreading library as the Threading member of the Mezzanine library or fail silently.
 
void SetThreadingSafe ()
 Set The MezzanineThreadingSafe library as the Threading member of the MezzanineSafe library or fail silently.
 
void SetXML ()
 Set The MezzanineXML library as the XML member of the Mezzanine library or fail silently.
 
void SetXMLSafe ()
 Set The MezzanineXMLSafe library as the XML member of the MezzanineSafe library or fail silently.
 
void StackExecute (Whole ArgumentCount)
 Execute a thing on the top of the stack with arguments already put there. More...
 
virtual void ThrowFromLuaErrorCode (int LuaReturn)
 This will throw an exception. More...
 

Friends

class Lua51Script
 

Additional Inherited Members

- Protected Attributes inherited from Mezzanine::ManagerBase
Boole Initialized
 Simple Boole indicating whether or not this manager has been initialized. More...
 
EntresolTheEntresol
 The actual pointer to the Entresol core class. More...
 

Detailed Description

The workhorse of the Lua scripting system. All scripts come here to be executed.

Definition at line 96 of file lua51scriptingengine.h.

Member Enumeration Documentation

Intended only to make constructing an Lua51ScriptingEngine with the desired libraries open a little easier.

Enumerator
NoLib 

No libraries.

BaseLib 

Correlates to Lua51ScriptingEngine::OpenBaseLibrary.

PackageLib 

Correlates to Lua51ScriptingEngine::OpenPackageLibrary.

StringLib 

Correlates to Lua51ScriptingEngine::OpenStringLibrary.

TableLib 

Correlates to Lua51ScriptingEngine::OpenTableLibrary.

MathLib 

Correlates to Lua51ScriptingEngine::OpenMathLibrary.

IOLib 

Correlates to Lua51ScriptingEngine::OpenIOLibrary.

OSLib 

Correlates to Lua51ScriptingEngine::OpenOSLibrary.

DebugLib 

Correlates to Lua51ScriptingEngine::OpenDebugLibrary.

MezzLib 

Correlates to Lua51ScriptingEngine::OpenMezzanineLibrary.

MezzSafeLib 

Correlates to Lua51ScriptingEngine::OpenMezzanineSafeLibrary.

MezzXMLLib 

Correlates to Lua51ScriptingEngine::OpenMezzanineXMLLibrary.

MezzXMLSafeLib 

Correlates to Lua51ScriptingEngine::OpenMezzanineXMLSafeLibrary.

MezzThreadingLib 

Correlates to Lua51ScriptingEngine::OpenMezzanineThreadingLibrary.

MezzThreadingSafeLib 

Correlates to Lua51ScriptingEngine::OpenMezzanineThreadingSafeLibrary.

MezzPhysicsLib 

Correlates to Lua51ScriptingEngine::OpenMezzaninePhysicsLibrary.

MezzPhysicsSafeLib 

Correlates to Lua51ScriptingEngine::OpenMezzaninePhysicsSafeLibrary.

MezzMathToolsLib 

Correlates to Lua51ScriptingEngine::OpenMezzanineMathToolsLibrary.

MezzMathToolsSafeLib 

Correlates to Lua51ScriptingEngine::OpenMezzanineMathToolsSafeLibrary.

FirstLib 

Useful for math based ways to work with libraries, This is equal to the numerically lowest lib.

LastLib 

Useful for math based ways to work with libraries, This is equal to the numerically highest lib.

DefaultLibs 

A quick way to refer to all the libraries opened by Lua51ScriptingEngine::OpenDefaultLibraries.

AllLibs 

A quick way to refer to all the libraries opened by Lua51ScriptingEngine::OpenAllLibraries.

Definition at line 148 of file lua51scriptingengine.h.

Constructor & Destructor Documentation

Mezzanine::Scripting::Lua::Lua51ScriptingEngine::Lua51ScriptingEngine ( Lua51Libraries  LibrariesToOpen = DefaultLibs)
explicit

Constructs a Scripting engine with a set of libraries preloaded.

Parameters
LibrariesToOpenA Lua51Libraries bitmap indicating which libraries to load, this defaults to DefaultLibs

Definition at line 483 of file lua51scriptingengine.cpp.

Mezzanine::Scripting::Lua::Lua51ScriptingEngine::Lua51ScriptingEngine ( const NameValuePairList Params)
explicit

Construct a from name value pairs.

Parameters
ParamsA collection of name value pairs indicating what to load and not load.

Each name can be the name of a libname (except None) and the value can either be "Load" or "Unload". To indicate whether or not a library will be loaded or not during instantation.

Definition at line 489 of file lua51scriptingengine.cpp.

Mezzanine::Scripting::Lua::Lua51ScriptingEngine::Lua51ScriptingEngine ( const XML::Node XMLNode)
explicit

Construct by deserializing.

Parameters
XMLNodeAn XML::Node That contains an A valid lua scripting engine.

Definition at line 514 of file lua51scriptingengine.cpp.

Member Function Documentation

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::AliasLibrary ( const String Base,
const String Sub,
const String Alias 
)
virtual

Nest Lua modules to put libraries in more clean positions.

this is used to create the syntax "Mezzanine.XML.Document()" for example. "Mezzanine" is the base, "MezzanineXML" another module in the root lua environment is the Sub and "XML" is the Alias. This does not "move" the library/module, this Simply creates a reference with a new name and location.

To ensure Tab completion works this also creates an alias/reference in the global table. In this above example this will also incidentally create the syntax "XML.Document()"

Parameters
BaseThe libary that will have another nested in it.
SubThe library to be nest into another.
AliasThe new name of the library when referenced from its nested location.
Warning
If this fails this fails silently.

Definition at line 658 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::CheckLuaStateAfterConstruction ( ) const
protected

Checks the internal Lua to see if memory was correctly allocated during its creation.

Exceptions
IfLua could not get enouugh memory this throws an Exception::MM_OUT_OF_MEMORY_EXCEPTION

Definition at line 239 of file lua51scriptingengine.cpp.

CountedPtr< iScriptCompilable > Mezzanine::Scripting::Lua::Lua51ScriptingEngine::Compile ( const String SourceToCompile)
virtual

Calls Compile(CountedPtr<iScriptCompilable>) and returns a CountedPtr to the script created.

Parameters
SourceToCompileA string Containing valid lua source code.
Returns
A CountedPtr<iScriptCompilable> pointing to a created Script object that contains the source and compile binary.

Implements Mezzanine::Scripting::iScriptCompilationManager.

Definition at line 562 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::Compile ( CountedPtr< iScriptCompilable > &  ScriptToCompile)
virtual

Accepts an Counted ptr to a script and compiles it.

Parameters
ScriptToCompileThe CountedPtr to compile

The ByteCode member on the passed script is erased, if present, and sets it to corresponding lua binary.

Exceptions
Ifan invalid script is passed this throws ParametersCastException.

Implements Mezzanine::Scripting::iScriptCompilationManager.

Definition at line 570 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::Compile ( CountedPtr< Lua51Script > &  ScriptToCompile)
virtual

Compile a Lua51 script.

Parameters
ScriptToCompileA CountedPtr to a Lua51Script.

Compiles the source code present in ScriptToCompile and puts the results back in the ByteCode member on the script.

Definition at line 581 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::Compile ( Lua51Script ScriptToCompile)
virtual

Performs the compilation on a script reference.

Parameters
ScriptToCompileA reference to the Lua51Script to compile.

Definition at line 584 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::Compile ( Lua51Script ScriptToCompile)
virtual

Performs the compilation on a raw pointer.

Parameters
ScriptToCompileA pointer to the Lua51Script to compile.

Definition at line 587 of file lua51scriptingengine.cpp.

CountedPtr< iScript > Mezzanine::Scripting::Lua::Lua51ScriptingEngine::Execute ( const String ScriptSource)
virtual

Compile and execute a passed string.

Parameters
ScriptSourceA String containing the source code to be executed.

This will create a CountPtr to a Lua51Script and assign both its Source and Byte code

Returns
A CountedPtr to the script executed. This lets the caller retain a pointer to the compiled script or this, whichever chooses to hold it longer and allow for more advance caching

Implements Mezzanine::Scripting::iScriptingManager.

Definition at line 525 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::Execute ( CountedPtr< iScript > &  ScriptToRun)
virtual

Implements a required for iScriptManager, Calls Execute(CountedPtr<Lua51Script>)

Parameters
ScriptToRunA CountedPtr<iScript> to be run. This is cast to an CountedPtr<Lua51Script> and called if possible.
Exceptions
Ifthis cannot be cast this throws a ParametersCastException.
Todo:
fill in the kind of exception thrown.

Implements Mezzanine::Scripting::iScriptingManager.

Definition at line 532 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::Execute ( CountedPtr< Lua51Script > &  ScriptToRun)
virtual

This will execute the passed script, compiling it if not present.

Parameters
ScriptToRunThe script to execute.

If a bytecode is present on ScriptToRun then it is executed. Otherwise the Source is compiled and the result is set as the bytecode and it is executed.

Definition at line 543 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::Execute ( Lua51Script ScriptToRun)
virtual

Performs the compilation on a script reference.

Parameters
ScriptToRunA reference to the Lua51Script to compile and run.

Definition at line 546 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::Execute ( Lua51Script ScriptToRun)
virtual

Performs the compilation on a raw pointer.

Parameters
ScriptToRunA pointer to the Lua51Script to compile and run.

Definition at line 548 of file lua51scriptingengine.cpp.

String Mezzanine::Scripting::Lua::Lua51ScriptingEngine::GetImplementationTypeName ( ) const
virtual

This Allows any manager name to be sent to a stream. Primarily used for logging.

Returns
This returns a String that contains the name.
A String containing "Lua51ScriptingEngine".

Implements Mezzanine::Scripting::iScriptingManager.

Definition at line 601 of file lua51scriptingengine.cpp.

Lua51ScriptingEngine::Lua51Libraries Mezzanine::Scripting::Lua::Lua51ScriptingEngine::GetLibFromName ( String  Name)
static

Convert a string similar to one of the names on the Lua51ScriptingEngine to number.

Parameters
NameA string containing a name of one of the libraries (without regard to case)
Returns
The correlating enumeration value for the passed name.

Definition at line 441 of file lua51scriptingengine.cpp.

const String & Mezzanine::Scripting::Lua::Lua51ScriptingEngine::GetLibName ( Lua51ScriptingEngine::Lua51Libraries  Lib)
static

Convert a Lua51Libraries value to its name.

Parameters
LibA number indicating what libraries a Lua51ScriptingEngine could load
Returns
A reference to one of the library names listed on the Lua51ScriptingEngine

Definition at line 386 of file lua51scriptingengine.cpp.

const String & Mezzanine::Scripting::Lua::Lua51ScriptingEngine::GetLuaTypeString ( int  StackLocation)

Get a human friendly string containing the type of the thing at the given stack location.

Parameters
StackLocationWhere to look in the Lua stack for item to inspect
Returns
A reference to a constant string on this class.

Definition at line 856 of file lua51scriptingengine.cpp.

lua_State * Mezzanine::Scripting::Lua::Lua51ScriptingEngine::GetRawLuaState ( )

Get the underlying Lua state that can be used with lua api calls directly.

Returns
The lua_State this uses.
Warning
Don't use this, this is exposed for troubleshooting and when used for other tasks can cause no end of headaches.

Definition at line 828 of file lua51scriptingengine.cpp.

int Mezzanine::Scripting::Lua::Lua51ScriptingEngine::GetStackCount ( )

The stack is a specific part of the State relating to how data is passed between functions. How big is that?

Returns

Definition at line 831 of file lua51scriptingengine.cpp.

const String & Mezzanine::Scripting::Lua::Lua51ScriptingEngine::GetTableName ( Lua51ScriptingEngine::Lua51Libraries  Lib)
static

Convert a Lua51Libraries value to the name of a table it loads.

Parameters
LibA number indicating what libraries a Lua51ScriptingEngine could load
Returns
A reference to one of the table names listed on the Lua51ScriptingEngine

Definition at line 415 of file lua51scriptingengine.cpp.

CountedPtr< iScriptArgument > Mezzanine::Scripting::Lua::Lua51ScriptingEngine::GetValue ( const String LuaIdentifier)

Get the Value stored in a lua identifier.

Parameters
LuaIdentifierThe name of the variable in lua to get the value from.
Returns
A counted pointer to an iScriptArgument to allow easy use of the "->GetString()", "->GetInteger()" and similar styles of syntax.

Definition at line 883 of file lua51scriptingengine.cpp.

Boole Mezzanine::Scripting::Lua::Lua51ScriptingEngine::IsLibraryOpen ( Lua51Libraries  LibToCheck)
virtual

Check the Lua state to see if a table exists.

Parameters
LibToCheckIndicator of which library to check
Returns
True if the library is ready for use and false otherwise.

Definition at line 646 of file lua51scriptingengine.cpp.

bool Mezzanine::Scripting::Lua::Lua51ScriptingEngine::IsValidCharInIdentifier ( const char  IdChar)
static

Is the given character valid for is in a Lua Identifier.

Parameters
IdCharA Single character to check
Returns
True if IdChar can be used in a lua variable name false otherwise

Definition at line 837 of file lua51scriptingengine.cpp.

bool Mezzanine::Scripting::Lua::Lua51ScriptingEngine::IsValidCharInTableIdentifier ( const char  IdChar)
static

Is the given character valid for is in a Lua Identifier including tables leading up to it and scoping operators.

Parameters
IdCharA Single character to check
Returns
True if IdChar can be used in a lua variable name false otherwise

Definition at line 840 of file lua51scriptingengine.cpp.

bool Mezzanine::Scripting::Lua::Lua51ScriptingEngine::IsValidCharStartIdentifier ( const char  IdChar)
static

Is the given character valid for starting a Lua Identifier.

Parameters
IdCharA Single character to check
Returns
True if IdChar can be used to start a lua variable name false otherwise

Definition at line 834 of file lua51scriptingengine.cpp.

bool Mezzanine::Scripting::Lua::Lua51ScriptingEngine::IsValidIdentifier ( const String Id)
static

Is a string a valid identifier in Lua.

Parameters
IdThe identifier to check
Returns
True if Id is a valid Lua Indentifier

Definition at line 843 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::OpenAllLibraries ( )
virtual

Make all Mezzanine and Lua functionality.

Warning
This makes arbitrary execution of programs and file IO available to scripts. This is not suitable if untrusted scripts will be run.

Definition at line 681 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::OpenBaseLibrary ( )
virtual

Make some eof the more core functionality available to lua scripts.

See the Lua manual at http://www.lua.org/manual/5.1/manual.html#5.1 and http://www.lua.org/manual/5.1/manual.html#5.2 for further details on the functionality this enables.

Warning
This enables lua scripts to load and execute arbitrary Lua scripts.

Definition at line 684 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::OpenDebugLibrary ( )
virtual

Enable Debugging Lua features.

This is the only Lua library omitted from the Defaults for functionality rather than security reasons. This unimportant for most game uses and is primarily include for completeness. More details in the Lua manual at http://www.lua.org/manual/5.1/manual.html#5.9 .

Definition at line 726 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::OpenDefaultLibraries ( )
virtual

Prepare most Mezzanine and some Lua functionality for use in Lua scripts.

This will load a the Lua Base, String, Table and Math libraries. This will make Mezzanine functionality available that does not provide any arbitrary file output or execution abilities.

Warning
This enables lua scripts to load and execute arbitrary Lua scripts.

Definition at line 679 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::OpenIOLibrary ( )
virtual

Enable Input/Output in lua scripts for reading and writing files.

See http://www.lua.org/manual/5.1/manual.html#5.7 in the Lua manual for details

Warning
This makes file IO available to scripts. This is not suitable if untrusted scripts will be run.

Definition at line 714 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::OpenLibraries ( int  LibrariesToOpen)
virtual

Makes Lua function calls in Lua standard libraries available for use in Lua scripts.

Parameters
LibrariesToOpenA Lua51Libraries bitmap indicating which libraries to loads

Definition at line 606 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::OpenMathLibrary ( )
virtual

Enable Lua math and random number functionality.

The Lua manual at http://www.lua.org/manual/5.1/manual.html#5.6 as further details.

Definition at line 708 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::OpenMezzanineLibrary ( )
virtual

Make everything in the Mezzanine Libary available for use in Lua51 scripts.

Warning
This makes arbitrary execution of programs and file management available to scripts. This is not suitable if untrusted scripts will be run.

Definition at line 733 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::OpenMezzanineMathToolsSafeLibrary ( )
virtual

Make the MathTools parts of the Mezzanine Libary available for use in Lua51 scripts.

This should not allow access to any functions, methods or classes than can execute code or manage files or crash the client malicious ways.

Definition at line 800 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::OpenMezzaninePhysicsLibrary ( )
virtual

Make the Physics parts of the Mezzanine Libary available for use in Lua51 scripts.

Warning
This makes a number of powerful feature available that could cause Denial of Service if untrusted scripts are run.

Definition at line 778 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::OpenMezzaninePhysicsSafeLibrary ( )
virtual

Make the Physics parts of the Mezzanine Libary available for use in Lua51 scripts.

This should not allow access to any functions, methods or classes than can execute code or manage files or crash the client malicious ways.

Definition at line 785 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::OpenMezzanineSafeLibrary ( )
virtual

Make a subset of the Mezzanine Library available for use in Lua51 scripts.

This should not allow access to any functions, methods or classes than can execute code or manage files.

Definition at line 740 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::OpenMezzanineThreadingLibrary ( )
virtual

Make the Threading parts of the Mezzanine Libary available for use in Lua51 scripts.

Warning
This makes a number of powerful feature available that could cause Denial of Service if untrusted scripts are run.

Definition at line 763 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::OpenMezzanineThreadingSafeLibrary ( )
virtual

Make the Threading parts of the Mezzanine Libary available for use in Lua51 scripts.

This should not allow access to any functions, methods or classes than can execute code or manage files or crash the client malicious ways.

Definition at line 770 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::OpenMezzanineXMLLibrary ( )
virtual

Make the XML parts of the Mezzanine Libary available for use in Lua51 scripts.

Warning
This makes arbitrary execution of programs and file management available to scripts. This is not suitable if untrusted scripts will be run.

Definition at line 748 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::OpenMezzanineXMLSafeLibrary ( )
virtual

Make the XML parts of the Mezzanine Libary available for use in Lua51 scripts.

This should not allow access to any functions, methods or classes than can execute code or manage files.

Definition at line 755 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::OpenOSLibrary ( )
virtual

EnableOS facilities in lua scriptsm such as file managements, time and shell execution.

See http://www.lua.org/manual/5.1/manual.html#5.7 in the Lua manual for details

Warning
This makes arbitrary execution of programs and file management available to scripts. This is not suitable if untrusted scripts will be run.

Definition at line 720 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::OpenPackageLibrary ( )
virtual

Allow Lua scripts to load other libraries.

see the Lua manual at http://www.lua.org/manual/5.1/manual.html#5.3 for details on what this enables. This does allow Lua scripts to load other libraries, inlcuding the IO or OS libraries.

Warning
This can makes full OS and file IO available to scripts. This is not suitable if untrusted scripts will be run.

Definition at line 690 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::OpenStringLibrary ( )
virtual

Allow Lua scripts access to the Lua string manipulation libary.

The details of what this enables can be read about in the Lua manual at http://www.lua.org/manual/5.1/manual.html#5.4 .

Definition at line 696 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::OpenTableLibrary ( )
virtual

Enable Lua table manipulation functionality.

See the Lua manual at http://www.lua.org/manual/5.1/manual.html#5.5 for details.

Definition at line 702 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::PopulateTabCompletionTrie ( CommandTrie CommandGroup,
const String TableName = "",
std::vector< String AlreadyDidTables = std::vector<String>() 
)

Populate a Trie with all the members and types in the current lua runtime.

Returns
The return value is provided in the CommandGroup argument.
Parameters
CommandGroupThe Trie to be populated.
TableNamethe name of the table to iterate over and populate the Trie with.
AlreadyDidTablesTo break cycles a list tables to skip descending into can be provided.
Warning
This is marked as internal because it does far too much and should be broken in many smaller functions

Definition at line 889 of file lua51scriptingengine.cpp.

CountedPtr< iScriptArgument > Mezzanine::Scripting::Lua::Lua51ScriptingEngine::ScriptArgFromStack ( )
protected

Get the top value of the Lua stack.

Returns
A Counter Pointer to an iScriptArgument.

Definition at line 303 of file lua51scriptingengine.cpp.

Whole Mezzanine::Scripting::Lua::Lua51ScriptingEngine::ScriptArgsFromStack ( Lua51Script ScriptWasRun,
Integer  PreviousStackSize 
)
protected

Remove Scripts from Lua stack and put them into arguments on the passed script.

Parameters
ScriptWasRunthe script was just run and needs to have its returns arguments loaded
PreviousStackSizeHow big was the stack before execution
Returns
The Amount of returns loaded into ScriptWasRun

Definition at line 284 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::ScriptArgsOntoStack ( Lua51Script ScriptToLoad)
protected

Put the arguments in a script onto the stack.

Parameters
ScriptToLoadA Script with 0 or more arguments to load.

Definition at line 262 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::ScriptOntoStack ( Lua51Script ScriptToLoad)
protected

Put a lua script onto the stack, compiling it if needed.

Parameters
ScriptToLoadA Script to put onto the lua stack.

This adds one item to the the Lua stack

Definition at line 245 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::StackExecute ( Whole  ArgumentCount)
protected

Execute a thing on the top of the stack with arguments already put there.

Parameters
ArgumentCountHow many args are onthe stack for the script

Definition at line 277 of file lua51scriptingengine.cpp.

void Mezzanine::Scripting::Lua::Lua51ScriptingEngine::ThrowFromLuaErrorCode ( int  LuaReturn)
protectedvirtual

This will throw an exception.

Parameters
LuaReturnThe return code from a Lua Compile or execution call
Exceptions
ThisThrows ScriptLuaYieldException, ScriptLuaRuntimeException, ScriptLuaRuntimeException, ScriptLuaErrErrException, SyntaxErrorLuaException, OutOfMemoryException, FileException, ScriptLuaException with as much precision as possible when thrown.

Definition at line 205 of file lua51scriptingengine.cpp.


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