lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I'm using tolua 4.0a and have few object that should be automaticly
garbage collected. This does not seem to work  though. I think I have
found the error, but I do not understand what the cause of it is, so if
sombeody could help me out on this one I would realy be happy.

When instansiating object that should be garbagecollected tolua genreates
the following code;

tolua_pushusertype(tolua_S,tolua_doclone(tolua_S,toluaI_clone,tolua_tag(tolua_S,"Action")),tolua_tag(tolua_S,"Action"));

The tolua_doclone(blabla):
void* tolua_doclone (lua_State* L, void* value, int tag)
{
 toluaI_getregistry(L,"tolua_tbl_clone");
 lua_pushuserdata(L,value);
 lua_pushnumber(L,tag);
 lua_settable(L,-3);
 lua_pop(L,1);
 return value;
}

The problem seems to appear in the toluaI_tm_undoclone(blabla). The
lua_isnumbers seems to always return false. I checked in the debugger and
the ttype of the object on stack checked for lua_isnumber(L,-1) seems to
be always 1, i.e. LUA_TNIL. The value of the object is also empty.

static void toluaI_tm_undoclone (lua_State* L, int tag, void* clone)
{
 toluaI_getregistry(L,"tolua_tbl_clone");
 lua_pushuserdata(L,clone);
 lua_gettable(L,-2);
 if (lua_isnumber(L,-1) && lua_tonumber(L,-1)==tag)
 {

..
..
..
 }
 lua_pop(L,2);  /* table and value */
}


Thanks for all the help I can get.

Jardar