[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: user data with pointer template
- From: "Panagiotis Vossos" <pavossos@...>
- Date: Fri, 19 Oct 2007 09:30:14 +0300
On 10/18/07, Graham Wakefield <firstname.lastname@example.org> wrote:
> Seems like the gc method isn't registered in the metatable. Are you
> expecting it to be passed in with the luaL_reg?
Yes, because the default gc method might not be appropriate in all
cases, so I leave it up to the caller to fill it in luaL_reg.
> Might also want to use your check() function inside your gc() function,
> since the __gc metamethod itself will be exposed to Lua (yes, this surprised
> me too):
> local a = Udata1.new()
> local b = Udata2.new()
> local gc = getmetatable(a).__gc
> gc(b) -- nasty!
This is nasty indeed, I will fix my code. Thanks for the suggestion.