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

Lua support for cocos2d-x. More...

#include <CCLuaStack.h>

Inheritance diagram for CCLuaStack:
CCObject CCCopying

Public Member Functions

lua_StategetLuaState (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 void removeScriptObjectByCCObject (CCObject *pObj)
 Remove CCObject 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 pushBoolean (bool boolValue)
virtual void pushString (const char *stringValue)
virtual void pushString (const char *stringValue, int length)
virtual void pushNil (void)
virtual void pushCCObject (CCObject *objectValue, const char *typeName)
virtual void pushCCLuaValue (const CCLuaValue &value)
virtual void pushCCLuaValueDict (const CCLuaValueDict &dict)
virtual void pushCCLuaValueArray (const CCLuaValueArray &array)
virtual bool pushFunctionByHandler (int nHandler)
virtual int executeFunction (int numArgs)
virtual int executeFunctionByHandler (int nHandler, int numArgs)
virtual int executeFunctionReturnArray (int nHandler, int nNumArgs, int nNummResults, CCArray *pResultArray)
virtual bool handleAssert (const char *msg)
- Public Member Functions inherited from CCObject
 CCObject (void)
virtual ~CCObject (void)
void release (void)
void retain (void)
CCObjectautorelease (void)
CCObjectcopy (void)
bool isSingleReference (void) const
unsigned int retainCount (void) const
virtual bool isEqual (const CCObject *pObject)
virtual void acceptVisitor (CCDataVisitor &visitor)
virtual void update (float dt)
- Public Member Functions inherited from CCCopying
virtual CCObjectcopyWithZone (CCZone *pZone)

Static Public Member Functions

static CCLuaStackcreate (void)
static CCLuaStackattach (lua_State *L)

Protected Member Functions

 CCLuaStack (void)
bool init (void)
bool initWithLuaState (lua_State *L)

Protected Attributes

lua_Statem_state
int m_callFromLua
- Protected Attributes inherited from CCObject
unsigned int m_uReference
unsigned int m_uAutoReleaseCount

Additional Inherited Members

- Public Attributes inherited from CCObject
unsigned int m_uID
int m_nLuaID

Detailed Description

Lua support for cocos2d-x.

Constructor & Destructor Documentation

CCLuaStack ( 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 CCLuaStack* attach ( lua_State L)
static
virtual void clean ( void  )
virtual
static CCLuaStack* create ( void  )
static
virtual int executeFunction ( int  numArgs)
virtual
virtual int
executeFunctionByHandler
( int  nHandler,
int  numArgs 
)
virtual
virtual int
executeFunctionReturnArray
( int  nHandler,
int  nNumArgs,
int  nNummResults,
CCArray pResultArray 
)
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
virtual void pushBoolean ( bool  boolValue)
virtual
virtual void pushCCLuaValue ( const CCLuaValue value)
virtual
virtual void pushCCLuaValueArray ( const CCLuaValueArray array)
virtual
virtual void pushCCLuaValueDict ( const CCLuaValueDict dict)
virtual
virtual void pushCCObject ( CCObject objectValue,
const char *  typeName 
)
virtual
virtual void pushFloat ( float  floatValue)
virtual
virtual bool pushFunctionByHandler ( int  nHandler)
virtual
virtual void pushInt ( int  intValue)
virtual
virtual void pushNil ( void  )
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 void removeScriptHandler ( int  nHandler)
virtual

Remove Lua function reference.

virtual void
removeScriptObjectByCCObject
( CCObject pObj)
virtual

Remove CCObject from lua state.

Parameters
objectto remove

Member Data Documentation

int m_callFromLua
protected
lua_State* m_state
protected

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