|
So, skipping through liolib.c, in summary, in addition to deleting object boxed, my __gc method should: set the boxed pointer value to NULL and my type-checking code should: test for userdata, validate the userdata against the type (e.g. test metatable) validate that the boxed pointer is not NULL Setting the pointer to NULL, and testing for NULL, would not be necessary if __gc was not visible to Lua code, and if the lifetime of the object boxed is known to be equal to the lifetime of the userdata, a common case. I can't think of an example why you would want to call __gc from Lua code; that's why I'm surprised that it is visible at all. Even in liolib.c, where the object boxed (the file) is not necessarily concurrent in existence with the userdata, there is still no need to access __gc from Lua. On Mar 30, 2007, at 4:51 AM, Luiz Henrique de Figueiredo wrote:
grrr waaa www.grahamwakefield.net |