在C++中输出一个模块的步骤,如cc.Node
static void extendNode(lua_State* tolua_S)
{
lua_pushstring(tolua_S,"cc.Node");
lua_rawget(tolua_S,LUA_REGISTRYINDEX);
if (lua_istable(tolua_S,-1))
{
lua_pushstring(tolua_S,"registerScriptHandler");
lua_pushcfunction(tolua_S,tolua_cocos2d_Node_registerScriptHandler);
lua_rawset(tolua_S,-3);
lua_pushstring(tolua_S,"unregisterScriptHandler");
lua_pushcfunction(tolua_S,tolua_cocos2d_Node_unregisterScriptHandler);
lua_rawset(tolua_S, -3);
lua_pushstring(tolua_S,"scheduleUpdateWithPriorityLua");
lua_pushcfunction(tolua_S,tolua_Cocos2d_Node_scheduleUpdateWithPriorityLua);
lua_rawset(tolua_S, -3);
lua_pushstring(tolua_S,"unscheduleUpdate");
lua_pushcfunction(tolua_S,tolua_cocos2d_Node_unscheduleUpdate);
lua_rawset(tolua_S, -3);
lua_pushstring(tolua_S,"getPosition");
lua_pushcfunction(tolua_S,tolua_cocos2d_Node_getPosition);
lua_rawset(tolua_S, -3);
lua_pushstring(tolua_S, "setContentSize");
lua_pushcfunction(tolua_S, tolua_cocos2d_Node_setContentSize);
lua_rawset(tolua_S, -3);
lua_pushstring(tolua_S, "setAnchorPoint");
lua_pushcfunction(tolua_S, tolua_cocos2d_Node_setAnchorPoint);
lua_rawset(tolua_S, -3);
lua_pushstring(tolua_S, "enumerateChildren");
lua_pushcfunction(tolua_S, lua_cocos2dx_Node_enumerateChildren);
lua_rawset(tolua_S, -3);
}
lua_pop(tolua_S, 1);
}
int lua_register_cocos2dx_Node(lua_State* tolua_S)
{
tolua_usertype(tolua_S,"cc.Node");
tolua_cclass(tolua_S,"Node","cc.Node","cc.Ref",nullptr);
tolua_beginmodule(tolua_S,"Node");
tolua_function(tolua_S,"addChild",lua_cocos2dx_Node_addChild);
tolua_function(tolua_S,"removeComponent",lua_cocos2dx_Node_removeComponent);