|
Rici Lake wrote:
Lisa,I think what you are trying to do is semantically incoherent, so it is not surprising that it is difficult. It's semantically incoherent because it confuses values with references to values ("boxes").
Not so much confuses, as intentionally seeks to make the two semantically identical to the end user. The goal of the project is to, in so far as possible, seamlessly integrate the native elements with Lua.
It's quite straightforward to create a proxy object which represents a C structure (or C++ object); the proxy object can interpret get and set messages as it sees fit. One simple way of doing this is to create two tables of getter and setter methods for each class, and have the __index/__newindex metamethods look up the key in the associated getter/setter table for the class.
*snip*
Since the environment table is just a table, a similar technique can be used to dynamically add "global bindings" to C objects
This is exactly how those aspects of the system operate. The main issues occur when one is trying to proxy strings, integers, and non-global variables. Locals aren't bound to a table, and therefore aren't subject to __index and __newindex.
As regards of what to do if the entity already exists - the glue system is intended to be initialised before everything else, and proceeds to prevent the names of glued in entities from being used.
Hope that was at least interesting,
Thanks :) -- Lisa http://www.thecommune.org.uk/~lisa/