[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: __assign
- From: Jose L. Hidalgo Valiño -PpluX- <johiva@...>
- Date: Mon, 14 Jun 2004 17:19:12 +0200
you can use __newindex,__index like:
print("Getting value of "..k)
print("Setting value of "..k.."="..v)
Your C function must crate a metatable with "__index" and "__newindex"
functions, those functions will catch assignments. In fact, there's no reason
to carry a "prop" subtable, __index and __newindex could use your C-struct
directly if they are C-functions.
On Mon, Jun 14, 2004 at 10:48:02AM -0400, Dan East wrote:
> Is there some non-trivial implementation issue that prevents an __assign
> metatable event within Lua? Or is there some other mechanism already
> providing the same functionality?
> My C function pushes a table into Lua that represents a struct. If I
> could catch assignments to the table elements then I could easily allow
> intuitive (ie non Get / Set function oriented) writing to my structs. Of
> course __newindex doesn't work, because I need to know when existing
> elements are assigned new values, not when new indices are created.
> Dan East