cocos2d-x  3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
tolua_fix.h File Reference
#include "tolua++.h"

Macros

#define TOLUA_REFID_PTR_MAPPING   "toluafix_refid_ptr_mapping"
#define TOLUA_REFID_TYPE_MAPPING   "toluafix_refid_type_mapping"
#define TOLUA_REFID_FUNCTION_MAPPING   "toluafix_refid_function_mapping"

Functions

TOLUA_API int NA. (lua_State *L, int uid, int *p_refid, void *ptr, const char *type)
 Push the userdata correspondings to the ptr on the top index of the Lua stack. More...
 
TOLUA_API int NA. (lua_State *L, int refid)
 Find the value of Ref object pointer in the Lua registry by the refid. More...
 
TOLUA_API int NA. (lua_State *L, int lo, int def)
 Get the refrence id of the Lua function at the given accepteable index lo of stack. More...
 
TOLUA_API void NA. (lua_State *L, int refid)
 Push the Lua function found by the refid in the toluafix_refid_function_mapping table in the Lua registry on the top index of the current stack. More...
 
TOLUA_API void NA. (lua_State *L, int refid)
 Remove the reference of the Lua function corresponding to the refid in the toluafix_refid_function_mapping table in the Lua registry. More...
 
TOLUA_API int NA. (lua_State *L, int lo, const char *type, int def, tolua_Error *err)
 Verify the value at the given acceptable index is a function or not. More...
 
TOLUA_API int NA. (lua_State *L, int lo, const char *type, int def, tolua_Error *err)
 Verify the value at the given acceptable index is a table or not. More...
 
TOLUA_API void NA. (lua_State *L, const char *label)
 Print all information of the stack from the top index. More...
 

Macro Definition Documentation

#define
TOLUA_REFID_FUNCTION_MAPPING   "toluafix_refid_function_mapping"
var TOLUA_REFID_FUNCTION_MAPPING   "toluafix_refid_function_mapping"
local TOLUA_REFID_FUNCTION_MAPPING   "toluafix_refid_function_mapping"
#define TOLUA_REFID_PTR_MAPPING   "toluafix_refid_ptr_mapping"
local TOLUA_REFID_PTR_MAPPING   "toluafix_refid_ptr_mapping"
#define TOLUA_REFID_TYPE_MAPPING   "toluafix_refid_type_mapping"

Function Documentation

TOLUA_API int
toluafix_pushusertype_ccobject
( lua_State *  L,
int  uid,
int *  p_refid,
void *  ptr,
const char *  type 
)

Push the userdata correspondings to the ptr on the top index of the Lua stack.

If the userdata correspondings to the ptr don't exist, it would call lua_newuserdata to new a userdata. If the userdata correspondings to the ptr exist,it would update the metatable information of the super. In addition, this function would update some table in the Lua registry,such as toluafix_refid_ptr_mapping, toluafix_refid_type_mapping,tolua_value_root,and so on. Meanwhile, Add a refrence about the userdata corresponding to the ptr in the tolua_ubox table. The ptr should be point to a Ref object.

Parameters
Lthe current lua_State.
uidthe object id of the ptr.
p_refidthe pointer points to the Lua reference id of the ptr.
ptrthe pointer points to the Ref object.
typethe type name of the ptr.
Returns
-1 if the p_refid equal to nullptr or ptr equal to nullptr, otherwise return 0.
var toluafix_pushusertype_ccobject ( var  L,
var  uid,
var  p_refid,
var  ptr,
var  type 
)

Push the userdata correspondings to the ptr on the top index of the Lua stack.

If the userdata correspondings to the ptr don't exist, it would call lua_newuserdata to new a userdata. If the userdata correspondings to the ptr exist,it would update the metatable information of the super. In addition, this function would update some table in the Lua registry,such as toluafix_refid_ptr_mapping, toluafix_refid_type_mapping,tolua_value_root,and so on. Meanwhile, Add a refrence about the userdata corresponding to the ptr in the tolua_ubox table. The ptr should be point to a Ref object.

Parameters
Lthe current lua_State.
uidthe object id of the ptr.
p_refidthe pointer points to the Lua reference id of the ptr.
ptrthe pointer points to the Ref object.
typethe type name of the ptr.
Returns
-1 if the p_refid equal to nullptr or ptr equal to nullptr, otherwise return 0.
local
toluafix_pushusertype_ccobject
( local  L,
local  uid,
local  p_refid,
local  ptr,
local  type 
)

Push the userdata correspondings to the ptr on the top index of the Lua stack.

If the userdata correspondings to the ptr don't exist, it would call lua_newuserdata to new a userdata. If the userdata correspondings to the ptr exist,it would update the metatable information of the super. In addition, this function would update some table in the Lua registry,such as toluafix_refid_ptr_mapping, toluafix_refid_type_mapping,tolua_value_root,and so on. Meanwhile, Add a refrence about the userdata corresponding to the ptr in the tolua_ubox table. The ptr should be point to a Ref object.

Parameters
Lthe current lua_State.
uidthe object id of the ptr.
p_refidthe pointer points to the Lua reference id of the ptr.
ptrthe pointer points to the Ref object.
typethe type name of the ptr.
Returns
-1 if the p_refid equal to nullptr or ptr equal to nullptr, otherwise return 0.
TOLUA_API int
toluafix_remove_ccobject_by_refid
( lua_State *  L,
int  refid 
)

Find the value of Ref object pointer in the Lua registry by the refid.

Then, remove the corresponding refrence in some table in the Lua registry by refid, such as toluafix_refid_type_mapping, toluafix_refid_ptr_mapping,tolua_value_root,and so on. Set the value of userdata nullptr and remove the refrence of userdata in the tolua_ubox table. This function is called in the destructor of the Ref automatically.

Parameters
Lthe current lua_State.
refidthe value of the _luaID of a Ref object.
Returns
-1,if refid equals to 0 , type name found by refid equals to nil or corresponding userdata pointer equal to nullptr; return -2, if the Ref object pointer found by refid is nullptr; return 3, if the value corresponding to the Ref object pointer in the tolua_ubox is nil; otherwise return 0.
TOLUA_API int toluafix_ref_function ( lua_State *  L,
int  lo,
int  def 
)

Get the refrence id of the Lua function at the given accepteable index lo of stack.

Meanwhile add refrence about the Lua function through the toluafix_refid_function_mapping table in the Lua registry.

Parameters
Lthe current lua_State.
lothe given accepteable index lo of stack.
defuseless.
Returns
0 if the type of value at the given accepteable index lo of stack is not LUA_TFUNCTION; otherwise return the refrence id.
TOLUA_API void
toluafix_get_function_by_refid
( lua_State *  L,
int  refid 
)

Push the Lua function found by the refid in the toluafix_refid_function_mapping table in the Lua registry on the top index of the current stack.

Parameters
Lthe current lua_State.
refidreferenc id corresponding to the Lua function.
var toluafix_get_function_by_refid ( var  L,
var  refid 
)

Push the Lua function found by the refid in the toluafix_refid_function_mapping table in the Lua registry on the top index of the current stack.

Parameters
Lthe current lua_State.
refidreferenc id corresponding to the Lua function.
local
toluafix_get_function_by_refid
( local  L,
local  refid 
)

Push the Lua function found by the refid in the toluafix_refid_function_mapping table in the Lua registry on the top index of the current stack.

Parameters
Lthe current lua_State.
refidreferenc id corresponding to the Lua function.
TOLUA_API void
toluafix_remove_function_by_refid
( lua_State *  L,
int  refid 
)

Remove the reference of the Lua function corresponding to the refid in the toluafix_refid_function_mapping table in the Lua registry.

Parameters
Lthe current lua_State.
refidreferenc id corresponding to the Lua function.
var
toluafix_remove_function_by_refid
( var  L,
var  refid 
)

Remove the reference of the Lua function corresponding to the refid in the toluafix_refid_function_mapping table in the Lua registry.

Parameters
Lthe current lua_State.
refidreferenc id corresponding to the Lua function.
local
toluafix_remove_function_by_refid
( local  L,
local  refid 
)

Remove the reference of the Lua function corresponding to the refid in the toluafix_refid_function_mapping table in the Lua registry.

Parameters
Lthe current lua_State.
refidreferenc id corresponding to the Lua function.
TOLUA_API int toluafix_isfunction ( lua_State *  L,
int  lo,
const char *  type,
int  def,
tolua_Error *  err 
)

Verify the value at the given acceptable index is a function or not.

Parameters
Lthe current lua_State.
lothe given accepteable index lo of stack.
typeuseless.
defuseless.
errif triggger the error, record the error message to err.
Returns
1 if the value at the given acceptable index is a function, otherwise return 0.
var toluafix_isfunction ( var  L,
var  lo,
var  type,
var  def,
var  err 
)

Verify the value at the given acceptable index is a function or not.

Parameters
Lthe current lua_State.
lothe given accepteable index lo of stack.
typeuseless.
defuseless.
errif triggger the error, record the error message to err.
Returns
1 if the value at the given acceptable index is a function, otherwise return 0.
local toluafix_isfunction ( local  L,
local  lo,
local  type,
local  def,
local  err 
)

Verify the value at the given acceptable index is a function or not.

Parameters
Lthe current lua_State.
lothe given accepteable index lo of stack.
typeuseless.
defuseless.
errif triggger the error, record the error message to err.
Returns
1 if the value at the given acceptable index is a function, otherwise return 0.
TOLUA_API int toluafix_istable ( lua_State *  L,
int  lo,
const char *  type,
int  def,
tolua_Error *  err 
)

Verify the value at the given acceptable index is a table or not.

Parameters
Lthe current lua_State.
lothe given accepteable index lo of stack.
typeuseless.
defwhether has the default value.
errif triggger the error, record the error message to err.
Returns
1 if the value at the given acceptable index is a table or have def value is not 0, otherwise return 0.
var toluafix_istable ( var  L,
var  lo,
var  type,
var  def,
var  err 
)

Verify the value at the given acceptable index is a table or not.

Parameters
Lthe current lua_State.
lothe given accepteable index lo of stack.
typeuseless.
defwhether has the default value.
errif triggger the error, record the error message to err.
Returns
1 if the value at the given acceptable index is a table or have def value is not 0, otherwise return 0.
local toluafix_istable ( local  L,
local  lo,
local  type,
local  def,
local  err 
)

Verify the value at the given acceptable index is a table or not.

Parameters
Lthe current lua_State.
lothe given accepteable index lo of stack.
typeuseless.
defwhether has the default value.
errif triggger the error, record the error message to err.
Returns
1 if the value at the given acceptable index is a table or have def value is not 0, otherwise return 0.
TOLUA_API void toluafix_stack_dump ( lua_State *  L,
const char *  label 
)

Print all information of the stack from the top index.

If the type corresponding to the index of the stack is LUA_TSTRING, LUA_TBOOLEAN or LUA_TNUMBER, it would output the value of the index,otherwise output the type name of the index.

Parameters
Lthe current lua_State.
labelthe string pointer to define the label of the dump information.
var toluafix_stack_dump ( var  L,
var  label 
)

Print all information of the stack from the top index.

If the type corresponding to the index of the stack is LUA_TSTRING, LUA_TBOOLEAN or LUA_TNUMBER, it would output the value of the index,otherwise output the type name of the index.

Parameters
Lthe current lua_State.
labelthe string pointer to define the label of the dump information.
local toluafix_stack_dump ( local  L,
local  label 
)

Print all information of the stack from the top index.

If the type corresponding to the index of the stack is LUA_TSTRING, LUA_TBOOLEAN or LUA_TNUMBER, it would output the value of the index,otherwise output the type name of the index.

Parameters
Lthe current lua_State.
labelthe string pointer to define the label of the dump information.