[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Interfacing lua with C
- From: "jimmyp_gr <jimmyp@...>" <jimmyp@...>
- Date: Thu, 16 Jan 2003 13:19:55 -0000
> One way is to use a proxy table that is always empty and set
__index/__newindex
> metamethods to read/write from your table or C. Something like this:
>
> C={} -- proxy for C vars
>
> setmetatable{C,{
> __index = function (t,i) get and return C var i end
> __newindex = function (t,i,v) set C var i to v end
> })
>
> The same idea works for implementing the old gettable/settable tag
methods.
Then I'd have to use something like C.cvar=cval right?I was hoping on
making C and lua var access identical.So if I create(via C) a global
full userdata var,there's no way of having a C or lua routine run
every time my var gets read and written?Or everytime any var gets read
or written.I could check wether type()=="userdata" and if not imitate
the default action
I see now that __index also only works on uninitialized globals.Why is
that?Wouldn't it be possible to provide read,write,newread,newwrite
metamethods?