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

Build bridge between ObjC and Lua. More...

#include <CCLuaBridge.h>

Inheritance diagram for LuaBridge:
LuaObjcBridge

Static Public Member Functions

static LuaStackgetStack (void)
 Get the LuaStack of LuaEngine. More...
 
var getStack ()
 Get the LuaStack of LuaEngine. More...
 
static int pushLuaFunctionById (int functionId)
 Push the function pointer corresponding to functionId on the top of lua stack by searching the lua_bridge_function_id table. More...
 
var pushLuaFunctionById ( var functionId)
 Push the function pointer corresponding to functionId on the top of lua stack by searching the lua_bridge_function_id table. More...
 
static int retainLuaFunctionById (int functionId)
 The retain count would be increase by 1 corresponding to functionId in the lua_bridge_function_id_retain table if it could be found. More...
 
static int releaseLuaFunctionById (int functionId)
 The retain count woulde be reduced by 1 corresponding to functionId in the lua_bridge_function_id_retain table if it could be found. More...
 

Static Protected Member Functions

static int retainLuaFunction (lua_State *L, int functionIndex, int *retainCountReturn)

Static Protected Attributes

static lua_State * s_luaState
static int s_newFunctionId

Detailed Description

Build bridge between ObjC and Lua.

It makes Lua and ObjC can call each other conveniently.

Member Function Documentation

static LuaStack* getStack ( void  )
static

Get the LuaStack of LuaEngine.

Returns
the LuaStack object.
var getStack (   )
static

Get the LuaStack of LuaEngine.

Returns
the LuaStack object.
static int pushLuaFunctionById ( int  functionId)
static

Push the function pointer corresponding to functionId on the top of lua stack by searching the lua_bridge_function_id table.

If it don't find the function pointer corresponding to functionId, it will reset stack top index to the index before searching.

Parameters
functionIdthe value used to search the lua_bridge_function_id table.
var pushLuaFunctionById ( var  functionId)
static

Push the function pointer corresponding to functionId on the top of lua stack by searching the lua_bridge_function_id table.

If it don't find the function pointer corresponding to functionId, it will reset stack top index to the index before searching.

Parameters
functionIdthe value used to search the lua_bridge_function_id table.
static int releaseLuaFunctionById ( int  functionId)
static

The retain count woulde be reduced by 1 corresponding to functionId in the lua_bridge_function_id_retain table if it could be found.

If lua_bridge_function_id table or lua_bridge_function_id_retain aren't found, it would return 0. If the vaule of retain count is 0 after reducing, it would update the lua_bridge_function_id_retain table and lua_bridge_function_id_retain table to remove the reference corresponding to this functionId

Parameters
functionIdthe value used to search the lua_bridge_function_id table and lua_bridge_function_id table.
Returns
the retain count or 0
var releaseLuaFunctionById ( var  functionId)
static

The retain count woulde be reduced by 1 corresponding to functionId in the lua_bridge_function_id_retain table if it could be found.

If lua_bridge_function_id table or lua_bridge_function_id_retain aren't found, it would return 0. If the vaule of retain count is 0 after reducing, it would update the lua_bridge_function_id_retain table and lua_bridge_function_id_retain table to remove the reference corresponding to this functionId

Parameters
functionIdthe value used to search the lua_bridge_function_id table and lua_bridge_function_id table.
Returns
the retain count or 0
static int retainLuaFunction ( lua_State *  L,
int  functionIndex,
int *  retainCountReturn 
)
staticprotected
var retainLuaFunction ( var  L,
var  functionIndex,
var  retainCountReturn 
)
staticprotected
static int retainLuaFunctionById ( int  functionId)
static

The retain count would be increase by 1 corresponding to functionId in the lua_bridge_function_id_retain table if it could be found.

If lua_bridge_function_id_retain table is not existed or the type of lua_bridge_function_id_retain[functionId] isn't LUA_TNUMBER, It would return 0. The top index of lua stack the same as before calling this function.

Parameters
functionIdthe value used to search the lua_bridge_function_id_retain table.
Returns
the retain count or 0.
var retainLuaFunctionById ( var  functionId)
static

The retain count would be increase by 1 corresponding to functionId in the lua_bridge_function_id_retain table if it could be found.

If lua_bridge_function_id_retain table is not existed or the type of lua_bridge_function_id_retain[functionId] isn't LUA_TNUMBER, It would return 0. The top index of lua stack the same as before calling this function.

Parameters
functionIdthe value used to search the lua_bridge_function_id_retain table.
Returns
the retain count or 0.

Member Data Documentation

lua_State* s_luaState
staticprotected
int s_newFunctionId
staticprotected
var s_newFunctionId
staticprotected

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