how to iterate "in lua defined attributes" of an object

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

how to iterate "in lua defined attributes" of an object

Gregor Burger
hi,

i'm searching for this for a long time. i basically need the equivalent of
the python '__dict__' object for an object. i know there exists a class_info
class which has an 'attribute' table but this table doesn't seem to include
the attributes that were defined in the lua code.

i also tried some code of this[0] thread. the get_table and get_table all
seem to include the methods defined but not the objects attributes.

thanks

gregor

[0] http://sourceforge.net/mailarchive/message.php?msg_id=449AF0CB.3020805%40silentdreams.de

------------------------------------------------------------------------------
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: how to iterate "in lua defined attributes" of an object

Daniel Wallin
On Sun, Apr 25, 2010 at 05:50:14PM +0200, Gregor Burger wrote:
> hi,
>
> i'm searching for this for a long time. i basically need the equivalent of
> the python '__dict__' object for an object. i know there exists a class_info
> class which has an 'attribute' table but this table doesn't seem to include
> the attributes that were defined in the lua code.

There isn't currently any documented or supported way of doing this. I
have plans to include something like this for 1.0, but it hasn't been
done yet. If you want to produce a patch you can look at the code in
object_rep.cpp, more specifically the get_instance_value() function.

Basically the lookup for an instance member goes:

 1. Look in the environment for the object.
 2. If it isn't there, and the environment table has a metatable; look in
    that metatable.

HTH,
--
Daniel Wallin
BoostPro Computing
http://www.boostpro.com

------------------------------------------------------------------------------
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user