lua-users home
lua-l archive

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


put the C/C++ part as a "private" (light) userdata member in a Lua object (i.e. a table). Then you can use plain Lua tables, metatables, functions etc. to decorate your Lua object system. Moreover, the (now

I am curious how you make the userdata private to the Lua object?

In my first cut at a Lua object system, I have a C factory method which creates a Lua table with a metatable of the object's methods. I maintain a weak-key table for the Lua to C mapping and a second fully weak table to map from C back to Lua (for events). Having these two association tables feels a bit wrong and slow(?) since I have to do this search for each method and attribute access on an object.

It seems like there should be a more direct way, but I was worried that scripting could 'disassociate' my C object by directly modifying the table.

Also, how do you handle GC? I thought light userdata and Lua tables can not have __gc methods.

Thx