今天发现tolua对c++的重载函数也做了导出,先贴在这里,回头整理一下.
c++代码是:
class CPoint : public C3_POS { public: CPoint(); CPoint(int cx, int cy); CPoint(float cx, float cy); CPoint(C3_POS initPt); CPoint(C3_SIZE initSize);
胶水代码是这样:
/* method: new of class CPoint */ #ifndef TOLUA_DISABLE_tolua_LuaTqFramework_CPoint_new00 static int tolua_LuaTqFramework_CPoint_new00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"CPoint",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { { CPoint* tolua_ret = (CPoint*) Mtolua_new((CPoint)()); tolua_pushusertype(tolua_S,(void*)tolua_ret,"CPoint"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: new_local of class CPoint */ #ifndef TOLUA_DISABLE_tolua_LuaTqFramework_CPoint_new00_local static int tolua_LuaTqFramework_CPoint_new00_local(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"CPoint",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { { CPoint* tolua_ret = (CPoint*) Mtolua_new((CPoint)()); tolua_pushusertype(tolua_S,(void*)tolua_ret,"CPoint"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: new of class CPoint */ #ifndef TOLUA_DISABLE_tolua_LuaTqFramework_CPoint_new01 static int tolua_LuaTqFramework_CPoint_new01(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"CPoint",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else { int cx = ((int) tolua_tonumber(tolua_S,2,0)); int cy = ((int) tolua_tonumber(tolua_S,3,0)); { CPoint* tolua_ret = (CPoint*) Mtolua_new((CPoint)(cx,cy)); tolua_pushusertype(tolua_S,(void*)tolua_ret,"CPoint"); } } return 1; tolua_lerror: return tolua_LuaTqFramework_CPoint_new00(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: new_local of class CPoint */ #ifndef TOLUA_DISABLE_tolua_LuaTqFramework_CPoint_new01_local static int tolua_LuaTqFramework_CPoint_new01_local(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"CPoint",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else { int cx = ((int) tolua_tonumber(tolua_S,2,0)); int cy = ((int) tolua_tonumber(tolua_S,3,0)); { CPoint* tolua_ret = (CPoint*) Mtolua_new((CPoint)(cx,cy)); tolua_pushusertype(tolua_S,(void*)tolua_ret,"CPoint"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } } return 1; tolua_lerror: return tolua_LuaTqFramework_CPoint_new00_local(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: new of class CPoint */ #ifndef TOLUA_DISABLE_tolua_LuaTqFramework_CPoint_new02 static int tolua_LuaTqFramework_CPoint_new02(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"CPoint",0,&tolua_err) || (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"CPoint",0,&tolua_err)) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else { CPoint initPt = *((CPoint*) tolua_tousertype(tolua_S,2,0)); { CPoint* tolua_ret = (CPoint*) Mtolua_new((CPoint)(initPt)); tolua_pushusertype(tolua_S,(void*)tolua_ret,"CPoint"); } } return 1; tolua_lerror: return tolua_LuaTqFramework_CPoint_new01(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: new_local of class CPoint */ #ifndef TOLUA_DISABLE_tolua_LuaTqFramework_CPoint_new02_local static int tolua_LuaTqFramework_CPoint_new02_local(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"CPoint",0,&tolua_err) || (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"CPoint",0,&tolua_err)) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else { CPoint initPt = *((CPoint*) tolua_tousertype(tolua_S,2,0)); { CPoint* tolua_ret = (CPoint*) Mtolua_new((CPoint)(initPt)); tolua_pushusertype(tolua_S,(void*)tolua_ret,"CPoint"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } } return 1; tolua_lerror: return tolua_LuaTqFramework_CPoint_new01_local(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: new of class CPoint */ #ifndef TOLUA_DISABLE_tolua_LuaTqFramework_CPoint_new03 static int tolua_LuaTqFramework_CPoint_new03(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"CPoint",0,&tolua_err) || (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"CSize",0,&tolua_err)) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else { CSize initSize = *((CSize*) tolua_tousertype(tolua_S,2,0)); { CPoint* tolua_ret = (CPoint*) Mtolua_new((CPoint)(initSize)); tolua_pushusertype(tolua_S,(void*)tolua_ret,"CPoint"); } } return 1; tolua_lerror: return tolua_LuaTqFramework_CPoint_new02(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: new_local of class CPoint */ #ifndef TOLUA_DISABLE_tolua_LuaTqFramework_CPoint_new03_local static int tolua_LuaTqFramework_CPoint_new03_local(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"CPoint",0,&tolua_err) || (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"CSize",0,&tolua_err)) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else { CSize initSize = *((CSize*) tolua_tousertype(tolua_S,2,0)); { CPoint* tolua_ret = (CPoint*) Mtolua_new((CPoint)(initSize)); tolua_pushusertype(tolua_S,(void*)tolua_ret,"CPoint"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } } return 1; tolua_lerror: return tolua_LuaTqFramework_CPoint_new02_local(tolua_S); } #endif //#ifndef TOLUA_DISABLE