Runtime reflection

Jascha Wetzel firstname at mainia.de
Wed Sep 19 12:00:00 PDT 2007


Jascha Wetzel wrote:
> Here is a simple way of adding __traits based runtime reflection to D 
> classes:
> 
> http://mainia.de/classinfoex.d
> (requires DMD 2.004)
> 
> It does not increase the class instance size.
> All extra info is stored statically.
> 
> See the doc-comment for details.

i have updated the file.
dynamic calls are now supported:

class A
{
     mixin Reflect;
     int foo() { return 1234; }
     void bar(string s) { writefln("%s", s); }
}

A o = new A;
call(o, "bar", null, "argument string");
Box retval;
call(o, "foo", &retval);
writefln("foo returned %s", retval);



More information about the Digitalmars-d-announce mailing list