www.digitalmars.com         C & C++   DMDScript  

D - Reflection/RTTI?

reply Mike Hearn <mike theoretic.com> writes:
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
next sibling parent reply "Julio César Carrascal Urquijo" <adnoctum phreaker.net> writes:
Hi

 Does 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
parent Helmut Leitner <helmut.leitner chello.at> writes:
"Julio César Carrascal Urquijo" wrote:
 
 Hi
 
 Does 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
prev sibling parent LiuXuHong <LiuXuHong_member pathlink.com> writes:
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