D - Reflection/RTTI?
- Mike Hearn <mike theoretic.com> Oct 02 2003
- "Julio César Carrascal Urquijo" <adnoctum phreaker.net> Oct 03 2003
- Helmut Leitner <helmut.leitner chello.at> Oct 03 2003
- LiuXuHong <LiuXuHong_member pathlink.com> Oct 25 2004
Hi, Does D support any form of reflection or RTTI? I didn't see any mention of this on the webpage. thanks -mike
Oct 02 2003
HiDoes D support any form of reflection or RTTI? I didn't see any mention of this on the webpage. thanks -mike
There's some support for it already. For any object you can allways get a ClassInfo structure and see the name of the class, wich class is it's parent and wich interfaces it implements: import stream; File f = File(); ClassInfo fci = ifile.classinfo; printf("Class name: %s\n", fci.name); printf("Base class name: %s\n", fci.base.name); There's a pointer to the vtable, contructors, destructor and invariant methods. What I'm missing the most is the capability to see a class' methods and read wich parameter types they need... but this seems quite difficult in a native code compiled language. You can see the ClassInfo source in /dmd/src/phobos/object.d
Oct 03 2003
"Julio César Carrascal Urquijo" wrote:HiDoes D support any form of reflection or RTTI? I didn't see any mention of this on the webpage. thanks -mike
There's some support for it already. For any object you can allways get a ClassInfo structure and see the name of the class, wich class is it's parent and wich interfaces it implements: import stream; File f = File(); ClassInfo fci = ifile.classinfo; printf("Class name: %s\n", fci.name); printf("Base class name: %s\n", fci.base.name); There's a pointer to the vtable, contructors, destructor and invariant methods. What I'm missing the most is the capability to see a class' methods and read wich parameter types they need... but this seems quite difficult in a native code compiled language. You can see the ClassInfo source in /dmd/src/phobos/object.d
Added to <http://www.prowiki.org/wiki4d/wiki.cgi?FaqRoadmap> -- Helmut Leitner leitner hls.via.at Graz, Austria www.hls-software.com
Oct 03 2003
printf("Class name: %s\n", fci.name);
printf("Base class name: %s\n", fci.base.name);
There's a pointer to the vtable, contructors, destructor and invariant
methods.
contructors is not available!!
Oct 25 2004









Helmut Leitner <helmut.leitner chello.at> 