lua-users home
lua-l archive

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

> As for the GC template I have an answer to your problem.
> The problem is that it is illegal to directly call destructors.
> You have to go through delete.

No, it's perfectly legal to explicitly call a destructor.  Ben's example
could read something like this:

template<typename T>
int GCMethod(lua_State *L)
    T *p = lua_userdata_cast(L, 1, T);
    if (p)

This destructs the instance while Lua takes care of freeing the memory.