LuaStack is used to manager the operation on the lua_State,eg., push data onto the lua_State, execute the function depended on the lua_State, and so on. More...
Inherits Ref.
Public Member Functions | |
virtual | ~LuaStack () |
Destructor. | |
lua_State * | getLuaState (void) |
Method used to get a pointer to the lua_State that the script module is attached to. More... | |
virtual void | addSearchPath (const char *path) |
Add a path to find lua files in. More... | |
virtual void | addLuaLoader (lua_CFunction func) |
Add lua loader. More... | |
virtual int | reload (const char *moduleFileName) |
Reload script code corresponding to moduleFileName. More... | |
virtual void | removeScriptObjectByObject (Ref *object) |
Remove the related reference about the Ref object stored in the Lua table by set the value of corresponding key nil: The related Lua tables are toluafix_refid_ptr_mapping,toluafix_refid_type_mapping,tolua_value_root and object_Metatable["tolua_ubox"] or tolua_ubox. More... | |
virtual void | removeScriptHandler (int nHandler) |
Remove Lua function reference by nHandler by setting toluafix_refid_function_mapping[nHandle] nil. More... | |
virtual int | reallocateScriptHandler (int nHandler) |
Reallocate Lua function reference id to the Lua function pointer to add reference. More... | |
virtual int | executeString (const char *codes) |
Execute script code contained in the given string. More... | |
virtual int | executeScriptFile (const char *filename) |
Execute a script file. More... | |
virtual int | executeGlobalFunction (const char *functionName) |
Execute a scripted global function. More... | |
virtual void | clean (void) |
Set the stack top index 0. | |
virtual void | pushInt (int intValue) |
Pushes a integer number into the stack. More... | |
virtual void | pushFloat (float floatValue) |
Pushes a float number into the stack. More... | |
virtual void | pushLong (long longValue) |
Pushes a long number into the stack. More... | |
virtual void | pushBoolean (bool boolValue) |
Pushes a bool value into the stack. More... | |
virtual void | pushString (const char *stringValue) |
Pushes the zero-terminated string pointed into the stack. More... | |
virtual void | pushString (const char *stringValue, int length) |
Pushes the string pointed to stringValue with size length into the stack. More... | |
virtual void | pushNil (void) |
Pushes a nil value into the stack. | |
virtual void | pushObject (Ref *objectValue, const char *typeName) |
Pushes a Ref object into the stack,please refer to toluafix_pushusertype_ccobject for detail information. | |
virtual void | pushLuaValue (const LuaValue &value) |
According to the type of LuaValue, it would called the other push function in the internal. More... | |
virtual void | pushLuaValueDict (const LuaValueDict &dict) |
Pushes a Lua table into the stack. More... | |
virtual void | pushLuaValueArray (const LuaValueArray &array) |
Pushes a Lua array table onto the stack. More... | |
virtual bool | pushFunctionByHandler (int nHandler) |
Get the Lua function pointer from toluafix_refid_function_mapping table by giving nHanlder,then push it into the Lua stack. More... | |
virtual int | executeFunction (int numArgs) |
Find and execute the Lua function on the -(numArgs + 1) index on the stack,the function has numArgs variables. More... | |
virtual int | executeFunctionByHandler (int nHandler, int numArgs) |
Find and execute the Lua function corresponding to the nHandler,the function has numArgs variables. More... | |
virtual int | executeFunctionReturnArray (int handler, int numArgs, int numResults, __Array &resultArray) |
Find and execute the Lua function corresponding to the handler,the function has numArgs variables. More... | |
virtual int | executeFunction (int handler, int numArgs, int numResults, const std::function< void(lua_State *, int)> &func) |
Find and execute the Lua function corresponding to the handler,the function has numArgs variables. More... | |
virtual bool | handleAssert (const char *msg) |
Handle the assert message. More... | |
virtual void | setXXTEAKeyAndSign (const char *key, int keyLen, const char *sign, int signLen) |
Set the key and sign for xxtea encryption algorithm. More... | |
virtual void | cleanupXXTEAKeyAndSign () |
Cleanup the key and sign for xxtea encryption algorithm. | |
int | luaLoadBuffer (lua_State *L, const char *chunk, int chunkSize, const char *chunkName) |
Loads a buffer as a Lua chunk.This function uses lua_load to load the Lua chunk in the buffer pointed to by chunk with size chunkSize. More... | |
int | loadChunksFromZIP (const char *zipFilePath) |
Load the Lua chunks from the zip file. More... | |
int | luaLoadChunksFromZIP (lua_State *L) |
Load the Lua chunks from current lua_State. More... | |
Public Member Functions inherited from Ref | |
void | retain () |
Retains the ownership. More... | |
local | retain () |
Retains the ownership. More... | |
void | release () |
Releases the ownership immediately. More... | |
Ref * | autorelease () |
Releases the ownership sometime soon automatically. More... | |
unsigned int | getReferenceCount () const |
Returns the Ref's current reference count. More... | |
local | getReferenceCount () |
Returns the Ref's current reference count. More... | |
virtual | ~Ref () |
Destructor. | |
Static Public Member Functions | |
static LuaStack * | create (void) |
Create a LuaStack object, it will new a lua_State. | |
static LuaStack * | attach (lua_State *L) |
Create a LuaStack object with the existed lua_State. | |
Additional Inherited Members | |
Public Attributes inherited from Ref | |
unsigned int | _ID |
object id, ScriptSupport need public _ID | |
local | _ID |
object id, ScriptSupport need public _ID | |
int | _luaID |
Lua reference id. | |
local | _luaID |
Lua reference id. | |
void * | _scriptObject |
scriptObject, support for swift | |
local | _scriptObject |
scriptObject, support for swift | |
bool | _rooted |
When true, it means that the object was already rooted. | |
local | _rooted |
When true, it means that the object was already rooted. | |
bool | _scriptOwned |
The life of the object is scrolled by the scripting engine. More... | |
local | _scriptOwned |
The life of the object is scrolled by the scripting engine. More... | |
LuaStack is used to manager the operation on the lua_State,eg., push data onto the lua_State, execute the function depended on the lua_State, and so on.
In the current mechanism, there is only one lua_State in one LuaStack object.
|
inline |
Method used to get a pointer to the lua_State that the script module is attached to.
A pointer to the lua_State that the script module is attached to.
|
virtual |
Add a path to find lua files in.
to be added to the Lua search path.
|
virtual |
Add lua loader.
a function pointer point to the loader function.
|
virtual |
Reload script code corresponding to moduleFileName.
If value of package["loaded"][moduleFileName] is existed, it would set the value nil.Then,it calls executeString function.
String object holding the filename of the script file that is to be reloaded. 0 if the string is excuted correctly or other if the string is excuted wrongly.
|
virtual |
Remove the related reference about the Ref object stored in the Lua table by set the value of corresponding key nil: The related Lua tables are toluafix_refid_ptr_mapping,toluafix_refid_type_mapping,tolua_value_root and object_Metatable["tolua_ubox"] or tolua_ubox.
Meanwhile set the corresponding userdata nullptr and remove the all the lua function reference corresponding to this object.
In current mechanism, this function is called in the destructor of Ref object, developer don't call this functions.
the key object to remove script object.
|
virtual |
Remove Lua function reference by nHandler by setting toluafix_refid_function_mapping[nHandle] nil.
the function reference id to find the correspoinding Lua function pointer.
|
virtual |
Reallocate Lua function reference id to the Lua function pointer to add reference.
the reference id to find the correspoinding Lua function pointer.
|
virtual |
Execute script code contained in the given string.
holding the valid script code that should be executed. 0 if the string is excuted correctly,other if the string is excuted wrongly.
|
virtual |
Execute a script file.
String object holding the filename of the script file that is to be executed. the return values by calling executeFunction.
|
virtual |
Execute a scripted global function.
The function should not take any parameters and should return an integer.
String object holding the name of the function, in the global script environment, that is to be executed. The integer value returned from the script function.
|
virtual |
Pushes a integer number into the stack.
a integer number.
|
virtual |
Pushes a float number into the stack.
a float number.
|
virtual |
Pushes a long number into the stack.
a long number.
|
virtual |
Pushes a bool value into the stack.
a bool value.
|
virtual |
Pushes the zero-terminated string pointed into the stack.
a pointer point to a zero-terminated string.
|
virtual |
Pushes the string pointed to stringValue with size length into the stack.
a pointer point to the string stringValue. the size.
|
virtual |
According to the type of LuaValue, it would called the other push function in the internal.
type function LuaValueTypeInt pushInt LuaValueTypeFloat pushFloat LuaValueTypeBoolean pushBoolean LuaValueTypeString pushString LuaValueTypeDict pushLuaValueDict LuaValueTypeArray pushLuaValueArray LuaValueTypeObject pushObject
a LuaValue object.
|
virtual |
Pushes a Lua table into the stack.
The key of table is string. The value of table is got by calling pushLuaValue,
|
virtual |
Pushes a Lua array table onto the stack.
The index of array table is begin at 1. The value of array table is got by calling pushLuaValue,
|
virtual |
Get the Lua function pointer from toluafix_refid_function_mapping table by giving nHanlder,then push it into the Lua stack.
If the Lua function pointer corresponding to the nHanlder isn't found, it would push nil on the top index of stack, then it would output the error log in the debug model.
true if get the no-null function pointer otherwise false.
|
virtual |
Find and execute the Lua function on the -(numArgs + 1) index on the stack,the function has numArgs variables.
the number of variables. 0 if it happen the error or it hasn't return value, otherwise it return the value by calling the Lua function,integer type or boolean type.
|
virtual |
Find and execute the Lua function corresponding to the nHandler,the function has numArgs variables.
the reference id to the Lua function. the number of variables. the return value is the same as executeFunction,please
|
virtual |
Find and execute the Lua function corresponding to the handler,the function has numArgs variables.
By calling this function, the number of return values is numResults(may be > 1). All the return values are stored in the resultArray.
the reference id corresponding to the Lua function. the number of function parameters. the number of return values. a array used to store the return value. 0 if it happen error or it hasn't return value, otherwise return 1.
|
virtual |
Find and execute the Lua function corresponding to the handler,the function has numArgs variables.
By calling this function, the number of return values is numResults(may be > 1). All the return values are used in the callback func.
the reference id corresponding to the lua function. the number of function parameters. the number of return values. callback function which is called if the numResults > 0. 0 if it happen error or it hasn't return value, otherwise return 1.
|
virtual |
Handle the assert message.
the assert message string. return true if current _callFromLua is not equal to 0 otherwise return false.
|
virtual |
Set the key and sign for xxtea encryption algorithm.
a string pointer point to key the length of key a string pointer point to sign the length of sign
int luaLoadBuffer | ( | lua_State * | L, |
const char * | chunk, | ||
int | chunkSize, | ||
const char * | chunkName | ||
) |
Loads a buffer as a Lua chunk.This function uses lua_load to load the Lua chunk in the buffer pointed to by chunk with size chunkSize.
if current stack enable the xxtea encryption algorithm and the the beginner of the chunk has the sign, the chunk should be decrypt first.
the current lua_State. the chunk pointer. the size of buffer. the name of chunk pointer. 0, LUA_ERRSYNTAX or LUA_ERRMEM:.
int loadChunksFromZIP | ( | const char * | zipFilePath | ) |
Load the Lua chunks from the zip file.
file path to zip file. 1 if load sucessfully otherwise 0.
int luaLoadChunksFromZIP | ( | lua_State * | L | ) |
Load the Lua chunks from current lua_State.
the current lua_State. 1 if load sucessfully otherwise 0.