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. More...
Inherits Ref.
Public Member Functions | |
virtual | ~LuaStack () |
Destructor. More... | |
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 index 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 with value intValue onto the stack. More... | |
virtual void | pushFloat (float floatValue) |
Pushes a float number with value floatValue onto the stack. More... | |
virtual void | pushLong (long longValue) |
Pushes a long number with value longValue onto the stack. More... | |
virtual void | pushBoolean (bool boolValue) |
Pushes a bool value with boolValue onto the stack. More... | |
virtual void | pushString (const char *stringValue) |
Pushes the zero-terminated string pointed to by stringValue onto the stack. More... | |
virtual void | pushString (const char *stringValue, int length) |
Pushes the string pointed to by stringValue with size length onto the stack. More... | |
virtual void | pushNil (void) |
Pushes a nil value onto the stack. | |
virtual void | pushObject (Ref *objectValue, const char *typeName) |
Pushes a Ref object onto the stack. More... | |
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 onto 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. More... | |
virtual int | executeFunction (int numArgs) |
Execute the lua function on the -(numArgs + 1) index on the stack by the numArgs variables passed. More... | |
virtual int | executeFunctionByHandler (int nHandler, int numArgs) |
Execute the lua function corresponding to the nHandler by the numArgs variables passed. More... | |
virtual int | executeFunctionReturnArray (int handler, int numArgs, int numResults, __Array &resultArray) |
Execute the lua function corresponding to the handler by the numArgs variables passed. More... | |
virtual int | executeFunction (int handler, int numArgs, int numResults, const std::function< void(lua_State *, int)> &func) |
Execute the lua function corresponding to the handler by the numArgs variables passed. 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 () |
free 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... | |
![]() | |
void | 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... | |
virtual | ~Ref () |
Destructor. More... | |
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 | |
![]() | |
unsigned int | _ID |
object id, ScriptSupport need public _ID | |
int | _luaID |
Lua reference id. | |
void * | _scriptObject |
scriptObject, support for swift | |
bool | _rooted |
When true, it means that the object was already rooted. | |
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.
In the current mechanism, there is only one lua_State in one LuaStack object.
|
virtual |
Destructor.
|
inline |
Method used to get a pointer to the lua_State that the script module is attached to.
|
virtual |
Add a path to find lua files in.
path | to be added to the Lua search path. |
|
virtual |
Add lua loader.
func | 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.
moduleFileName | String object holding the filename of the script file that is to be executed. |
|
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.
object | the key object to remove script object. |
|
virtual |
Remove Lua function reference by nHandler by setting toluafix_refid_function_mapping[nHandle] nil.
nHandler | the function reference index to find the corresponding Lua function pointer. |
|
virtual |
Reallocate Lua function reference index to the Lua function pointer to add reference.
nHandler | the function reference index to find the corresponding Lua function pointer. |
|
virtual |
Execute script code contained in the given string.
codes | holding the valid script code that should be executed. |
|
virtual |
Execute a script file.
filename | String object holding the filename of the script file that is to be executed. |
|
virtual |
Execute a scripted global function.
The function should not take any parameters and should return an integer.
functionName | String object holding the name of the function, in the global script environment, that is to be executed. |
|
virtual |
Pushes a integer number with value intValue onto the stack.
intValue | a integer number. |
|
virtual |
Pushes a float number with value floatValue onto the stack.
floatValue | a float number. |
|
virtual |
Pushes a long number with value longValue onto the stack.
longValue | a long number. |
|
virtual |
Pushes a bool value with boolValue onto the stack.
boolValue | a bool value. |
|
virtual |
Pushes the zero-terminated string pointed to by stringValue onto the stack.
stringValue | a pointer point to a zero-terminated string stringValue. |
|
virtual |
Pushes the string pointed to by stringValue with size length onto the stack.
stringValue | a pointer point to the string stringValue. |
length | the size. |
|
virtual |
Pushes a Ref object onto the stack.
|
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
value | a LuaValue object. |
|
virtual |
Pushes a lua table onto the stack.
The key of table is the key of LuaValueDict which is std::map. The value of table is according to the type of LuaValue of LuaValueDict by calling pushLuaValue,
dict | a LuaValueDict object. |
|
virtual |
Pushes a lua array table onto the stack.
The index of array table is begin at 1. The value of array table is according to the type of LuaValue of LuaValueDict by calling pushLuaValue,
|
virtual |
Get the lua function pointer from toluafix_refid_function_mapping table by giving nHanlder.
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.
|
virtual |
Execute the lua function on the -(numArgs + 1) index on the stack by the numArgs variables passed.
numArgs | the number of variables. |
|
virtual |
Execute the lua function corresponding to the nHandler by the numArgs variables passed.
nHandler | the index count corresponding to the lua function. |
numArgs | the number of variables. |
|
virtual |
Execute the lua function corresponding to the handler by the numArgs variables passed.
By calling this function, the number of return value is numResults(may be > 1). All the return values are stored in the resultArray.
handler | the index count corresponding to the lua function. |
numArgs | the number of variables. |
numResults | the number of return value. |
resultArray | a array used to store the return value. |
|
virtual |
Execute the lua function corresponding to the handler by the numArgs variables passed.
By calling this function, the number of return value is numResults(may be > 1). All the return values are used in the callback func.
handler | the index count corresponding to the lua function. |
numArgs | the number of variables. |
numResults | the number of return value. |
func | callback function which is called if the numResults > 0. |
|
virtual |
Handle the assert message.
|
virtual |
Set the key and sign for xxtea encryption algorithm.
key | a string pointer |
keyLen | the length of key |
sign | a string sign |
signLen | 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 it supports xxtea encryption algorithm, the chunk and the chunkSize would be processed by calling xxtea_decrypt to the real buffer and buffer size.
L | the current lua_State. |
chunk | the buffer pointer. |
chunkSize | the size of buffer. |
chunkName | the name of chunk pointer. |
int loadChunksFromZIP | ( | const char * | zipFilePath | ) |
Load the Lua chunks from the zip file.
zipFilePath | file path to zip file. |
int luaLoadChunksFromZIP | ( | lua_State * | L | ) |
Load the Lua chunks from current lua_State.
L | the current lua_State. |