www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Runtime Reflection using Compile Time Reflection

reply Daniel Ribeiro Maciel <danielmaciel gmail.com> writes:
Heya ppl!

I was wondering if is there anyone working on a Runtime Reflection
library using __traits.
I am working on one myself, but hey, if someone is already doing it,
why reinvent the wheel, right?

Best Regads,
Daniel
Apr 04 2010
parent reply "Adam D. Ruppe" <destructionator gmail.com> writes:
On Sun, Apr 04, 2010 at 05:37:00PM +0000, Daniel Ribeiro Maciel wrote:
 Heya ppl!
 
 I was wondering if is there anyone working on a Runtime Reflection
 library using __traits.
The best we have now in Phobos (as far as I know, anyway) is std.traits: http://dpldocs.info/std.traits -- Adam D. Ruppe http://arsdnet.net
Apr 04 2010
parent reply Daniel Ribeiro Maciel <danielmaciel gmail.com> writes:
Cool.

I was thinking about something like:

auto foo = new Foo();
auto mo = new MetaObject!Foo( foo );
auto returnValue = mo.invoke( "aMethodName", "a param", "more params",
10, 20 );

Best Regards,
Daniel
Apr 04 2010
parent "Adam D. Ruppe" <destructionator gmail.com> writes:
On Sun, Apr 04, 2010 at 06:08:26PM +0000, Daniel Ribeiro Maciel wrote:
 I was thinking about something like:
 
 auto foo = new Foo();
 auto mo = new MetaObject!Foo( foo );
 auto returnValue = mo.invoke( "aMethodName", "a param", "more params",
 10, 20 );
I don't quite have that, but I do have a kind of starting point in my D2 port/extension of dmdscript. http://arsdnet.net/dcode/dmdscript_d2.zip Specifically, take a look inside the file pretty.d for the addFunction template (line 99 for the main one, and line and 64 for a helper method). It takes an array of dynamically typed Values from the script world, and uses them to call a given D function, with the help of a wrapper template. I haven't gotten wrapping classes to work yet. Probably not terribly useful to you on its own, but maybe as a starting point or to see how I solved a few problems that came up. -- Adam D. Ruppe http://arsdnet.net
Apr 04 2010