cocos2d-x  3.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
LuaStack Class Reference

#include <CCLuaStack.h>

Inheritance diagram for LuaStack:
Ref

Public Member Functions

virtual ~LuaStack ()
 
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, now it is used on android. More...
 
virtual int reload (const char *moduleFileName)
 reload script code contained in the given string. More...
 
virtual void removeScriptObjectByObject (Ref *object)
 Remove Object from lua state. More...
 
virtual void removeScriptHandler (int nHandler)
 Remove Lua function reference. More...
 
virtual int reallocateScriptHandler (int nHandler)
 Remove Lua function 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)
 
virtual void pushInt (int intValue)
 
virtual void pushFloat (float floatValue)
 
virtual void pushLong (long longValue)
 
virtual void pushBoolean (bool boolValue)
 
virtual void pushString (const char *stringValue)
 
virtual void pushString (const char *stringValue, int length)
 
virtual void pushNil (void)
 
virtual void pushObject (Ref *objectValue, const char *typeName)
 
virtual void pushLuaValue (const LuaValue &value)
 
virtual void pushLuaValueDict (const LuaValueDict &dict)
 
virtual void pushLuaValueArray (const LuaValueArray &array)
 
virtual bool pushFunctionByHandler (int nHandler)
 
virtual int executeFunction (int numArgs)
 
virtual int executeFunctionByHandler (int nHandler, int numArgs)
 
virtual int executeFunctionReturnArray (int handler, int numArgs, int numResults, __Array &resultArray)
 
virtual int executeFunction (int handler, int numArgs, int numResults, const std::function< void(lua_State *, int)> &func)
 
virtual bool handleAssert (const char *msg)
 
virtual void setXXTEAKeyAndSign (const char *key, int keyLen, const char *sign, int signLen)
 
virtual void cleanupXXTEAKeyAndSign ()
 
int luaLoadBuffer (lua_State *L, const char *chunk, int chunkSize, const char *chunkName)
 
int loadChunksFromZIP (const char *zipFilePath)
 
int luaLoadChunksFromZIP (lua_State *L)
 
- Public Member Functions inherited from Ref
void retain ()
 Retains the ownership. More...
 
void release ()
 Releases the ownership immediately. More...
 
Refautorelease ()
 Releases the ownership sometime soon automatically. More...
 
unsigned int getReferenceCount () const
 Returns the Ref's current reference count. More...
 
virtual ~Ref ()
 NA NA More...
 

Static Public Member Functions

static LuaStackcreate (void)
 
static LuaStackattach (lua_State *L)
 

Protected Member Functions

 LuaStack (void)
 
bool init (void)
 
bool initWithLuaState (lua_State *L)
 
- Protected Member Functions inherited from Ref
 Ref ()
 Constructor. More...
 

Protected Attributes

lua_State * _state
 
int _callFromLua
 
bool _xxteaEnabled
 
char * _xxteaKey
 
int _xxteaKeyLen
 
char * _xxteaSign
 
int _xxteaSignLen
 
- Protected Attributes inherited from Ref
unsigned int _referenceCount
 count of references More...
 

Constructor & Destructor Documentation

virtual ~LuaStack ( )
virtual
LuaStack ( void  )
inlineprotected

Member Function Documentation

virtual void addLuaLoader ( lua_CFunction  func)
virtual

Add lua loader, now it is used on android.

virtual void addSearchPath ( const char *  path)
virtual

Add a path to find lua files in.

Parameters
pathto be added to the Lua path
static LuaStack* attach ( lua_State *  L)
static
virtual void clean ( void  )
virtual
virtual void cleanupXXTEAKeyAndSign ( )
virtual
static LuaStack* create ( void  )
static
virtual int executeFunction ( int  numArgs)
virtual
virtual int executeFunction ( int  handler,
int  numArgs,
int  numResults,
const std::function< void(lua_State *, int)> &  func 
)
virtual
virtual int executeFunctionByHandler ( int  nHandler,
int  numArgs 
)
virtual
virtual int executeFunctionReturnArray ( int  handler,
int  numArgs,
int  numResults,
__Array resultArray 
)
virtual
virtual int executeGlobalFunction ( const char *  functionName)
virtual

Execute a scripted global function.

The function should not take any parameters and should return an integer.

Parameters
functionNameString object holding the name of the function, in the global script environment, that is to be executed.
Returns
The integer value returned from the script function.
virtual int executeScriptFile ( const char *  filename)
virtual

Execute a script file.

Parameters
filenameString object holding the filename of the script file that is to be executed
virtual int executeString ( const char *  codes)
virtual

Execute script code contained in the given string.

Parameters
codesholding the valid script code that should be executed.
Returns
0 if the string is excuted correctly.
other if the string is excuted wrongly.
lua_State* getLuaState ( void  )
inline

Method used to get a pointer to the lua_State that the script module is attached to.

Returns
A pointer to the lua_State that the script module is attached to.
virtual bool handleAssert ( const char *  msg)
virtual
bool init ( void  )
protected
bool initWithLuaState ( lua_State *  L)
protected
int loadChunksFromZIP ( const char *  zipFilePath)
int luaLoadBuffer ( lua_State *  L,
const char *  chunk,
int  chunkSize,
const char *  chunkName 
)
int luaLoadChunksFromZIP ( lua_State *  L)
virtual void pushBoolean ( bool  boolValue)
virtual
virtual void pushFloat ( float  floatValue)
virtual
virtual bool pushFunctionByHandler ( int  nHandler)
virtual
virtual void pushInt ( int  intValue)
virtual
virtual void pushLong ( long  longValue)
virtual
virtual void pushLuaValue ( const LuaValue value)
virtual
virtual void pushLuaValueArray ( const LuaValueArray array)
virtual
virtual void pushLuaValueDict ( const LuaValueDict dict)
virtual
virtual void pushNil ( void  )
virtual
virtual void pushObject ( Ref objectValue,
const char *  typeName 
)
virtual
virtual void pushString ( const char *  stringValue)
virtual
virtual void pushString ( const char *  stringValue,
int  length 
)
virtual
virtual int reallocateScriptHandler ( int  nHandler)
virtual

Remove Lua function reference.

virtual int reload ( const char *  moduleFileName)
virtual

reload script code contained in the given string.

Parameters
moduleFileNameString object holding the filename of the script file that is to be executed
Returns
0 if the string is excuted correctly.
other if the string is excuted wrongly.
virtual void removeScriptHandler ( int  nHandler)
virtual

Remove Lua function reference.

virtual void removeScriptObjectByObject ( Ref object)
virtual

Remove Object from lua state.

Parameters
objectThe object to be removed.
virtual void setXXTEAKeyAndSign ( const char *  key,
int  keyLen,
const char *  sign,
int  signLen 
)
virtual

Member Data Documentation

int _callFromLua
protected
lua_State* _state
protected
bool _xxteaEnabled
protected
char* _xxteaKey
protected
int _xxteaKeyLen
protected
char* _xxteaSign
protected
int _xxteaSignLen
protected

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