lua-users home
lua-l archive

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


Hi all,

I'm trying to work with objects in both lua and c++, and am playing with creating a table from c++ with static methods from c++ linked into table functions, and a pointer to the c++ object stored in the table with some appropriate name (this, for instance). Then, when a table method is called with the : operator, the table is passed, I can extract the pointer, and everything is groovy then to call the object from c++.

I want to control the garbage collection on the object, though, since at present it leaks terribly because the garbage collector doesn't fire on the lightuserdata I'm storing the pointer as.

I can make it a userdata, and specifically create it and add a metatable to it for __gc, but I'd rather not have to.

Is there anyway I can control destruction of a table (appears not from the manual)? Perhaps people can very quickly say I'm simply a fool for thinking of managing things in the manner I've set out ... ?



Rob