lua-users home
lua-l archive

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


On Fri, Jan 7, 2011 at 3:20 PM, liam mail <liam.list@googlemail.com> wrote:
> If anyone knows of a method of obtaining references to tables and functions
> in C (remembering that they may not be named) then I would love to hear it
> because to hear (read) "the need for luaL_ref diminished a lot" I found
> quite shocking.

Depends what is driving the referal. For example, I often need to find
the lua userdata that corresponds to a C struct/c++ object, I use a
weak table mapping lightuserdata back to the userdata that wraps it.

Its been a while since I've used the ref system. It gives you a number
you then have to store in C somewhere, usually a struct, so I just use
the pointer to the struct as the key into lua, rather than an int
stored in the struct.

Cheers,
Sam