[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: "Hidden" data in Lua objects
- From: Dirk Laurie <dpl@...>
- Date: Tue, 21 Dec 2010 18:34:37 +0200
On Tue, Dec 21, 2010 at 05:59:09PM +0200, Marc Balmer wrote:
> In Lua, I create a hierarchy of "objects" (Lua tables) that finally
> represent a GUI widget hierarchy.
>
> Now I want to somehow store C data in these objects, or link them with
> such information.
>
> E.g. I have to store the Widget pointer (a C lightuserdata value) for
> each widget represented in the hierarchy.
>
> What is a good way to do this? My adventourous approach at the moment
> is to create an additional table when an object is created, store my
> values in this additional table and add it as metatable to the created
> object...
>
You could also create just one table and index it with the objects:
C_data={}
C_data[this_widget]={...}
That way, a routine to which you pass this_widget will not automatically
know its C data.
Dirk