Listing classes, properties and methods registered with luabind

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

Listing classes, properties and methods registered with luabind

Greg Santucci

At the lua repl, its possible to get a listing of all global symbols by issuing this command:

for k,v in pairs(_G) do print(k) end

I'd like to generate a listing of all the members of a class that have been registered with luabind in a similar way. How do I get to the lua table with this information?

Regards,
Greg Santucci


------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Listing classes, properties and methods registered with luabind

Nigel Atkinson-2
Here's what I do:

Add to uour C++ code:
#include <luabind/class_info.hpp>

and:
bind_class_info( L );

then in Lua:

function info( classInstance )
    local ci = class_info( classInstance )
    local str=''

    print( 'Name: '..ci.name )

    for k,v in pairs( ci.methods ) do
        str = str..' '..k
    end

    print( 'Methods:'..str )
    str=''

    for k,v in pairs( ci.attributes ) do
        str = str..' '..v
    end

    print( 'Attributes:'..str )
end

The trouble is that it works on instance's rather than the class, so you
have to know how to create one, to see how to use it.

Nigel

On Mon, 2010-03-01 at 15:52 +1100, Greg Santucci wrote:

>
> At the lua repl, its possible to get a listing of all global symbols
> by issuing this command:
>
> for k,v in pairs(_G) do print(k) end
>
> I'd like to generate a listing of all the members of a class that have
> been registered with luabind in a similar way. How do I get to the lua
> table with this information?
>
> Regards,
> Greg Santucci
>
> ------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________ luabind-user mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/luabind-user



------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Listing classes, properties and methods registered with luabind

Greg Santucci
Excellent! Thank you.

On Mon, Mar 1, 2010 at 4:33 PM, Nigel Atkinson <[hidden email]> wrote:
Here's what I do:

Add to uour C++ code:
#include <luabind/class_info.hpp>

and:
bind_class_info( L );

then in Lua:

function info( classInstance )
   local ci = class_info( classInstance )
   local str=''

   print( 'Name: '..ci.name )

   for k,v in pairs( ci.methods ) do
       str = str..' '..k
   end

   print( 'Methods:'..str )
   str=''

   for k,v in pairs( ci.attributes ) do
       str = str..' '..v
   end

   print( 'Attributes:'..str )
end

The trouble is that it works on instance's rather than the class, so you
have to know how to create one, to see how to use it.

Nigel

On Mon, 2010-03-01 at 15:52 +1100, Greg Santucci wrote:
>
> At the lua repl, its possible to get a listing of all global symbols
> by issuing this command:
>
> for k,v in pairs(_G) do print(k) end
>
> I'd like to generate a listing of all the members of a class that have
> been registered with luabind in a similar way. How do I get to the lua
> table with this information?
>
> Regards,
> Greg Santucci
>
> ------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________ luabind-user mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/luabind-user



------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user