D - Reflection/RTTI?
- Mike Hearn (4/4) Oct 02 2003 Hi,
- Julio César Carrascal Urquijo (15/18) Oct 03 2003 There's some support for it already. For any object you can allways get ...
- Helmut Leitner (6/35) Oct 03 2003 Added to
- LiuXuHong (5/5) Oct 25 2004 printf("Class name: %s\n", fci.name);
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 -mikeThere'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:HiAdded to <http://www.prowiki.org/wiki4d/wiki.cgi?FaqRoadmap> -- Helmut Leitner leitner hls.via.at Graz, Austria www.hls-software.comDoes D support any form of reflection or RTTI? I didn't see any mention of this on the webpage. thanks -mikeThere'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
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