/* method: delete of class A */ static int tolua_tinheritance_A_delete00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"A",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { A* self = (A*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'delete'",NULL); #endif tolua_release(tolua_S,self); delete self; } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'delete'.",&tolua_err); return 0; #endif }
static int tolua_collect_B (lua_State* tolua_S) { B* self = (B*) tolua_tousertype(tolua_S,1,0); tolua_release(tolua_S,self); delete self; return 0; }
/* Release ** Function to be called by a Lua code that uses a function to explicitly ** release a mapped object. This function is automatically called by all ** destructors bound by tolua and by all collected objects. */ static int tolua_bnd_release (lua_State* L) { void* value = tolua_tousertype(L,1,NULL); if (value) tolua_release(L,value); return 1; }
static int class_gc_event (lua_State* L) { if (lua_type(L,1) == LUA_TUSERDATA) { int top = lua_gettop(L); void* u = *((void**)lua_touserdata(L,1)); lua_pushstring(L,"tolua_gc"); lua_rawget(L,LUA_REGISTRYINDEX); /* gc */ lua_pushlightuserdata(L,u); /* gc u */ lua_rawget(L,-2); /* gc func */ if (!lua_isnil(L, -1)) { /* remove entry from table */ lua_pushlightuserdata(L,u); lua_pushnil(L); lua_rawset(L,-4); if (lua_isfunction(L,-1)) { /* call collect function */ lua_pushvalue(L,1); /* tolua_gc tolua_gc.u(func) u */ lua_call(L,1,0); /* tolua_gc */ } else if (lua_isuserdata(L,-1) && *((void**)lua_touserdata(L,-1))==NULL) { /* free object */ free(u); tolua_release(L,u); /* unmap from tolua tables */ } } lua_settop(L,top); } return 0; }
static int tolua_collect_tstring (lua_State* tolua_S) { tstring* self = (tstring*) tolua_tousertype(tolua_S,1,0); tolua_release(tolua_S,self); delete self; return 0; }