Thread overview | ||||||
---|---|---|---|---|---|---|
|
October 02, 2003 Reflection/RTTI? | ||||
---|---|---|---|---|
| ||||
Hi, Does D support any form of reflection or RTTI? I didn't see any mention of this on the webpage. thanks -mike |
October 03, 2003 Re: Reflection/RTTI? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Hearn | 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
|
October 03, 2003 Re: Reflection/RTTI? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Julio César Carrascal Urquijo | "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 |
October 26, 2004 Re: Reflection/RTTI? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Hearn | 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!! |
Copyright © 1999-2021 by the D Language Foundation