Need reflection facilities

Thomas Kuehne thomas-dloop at kuehne.cn
Wed Jan 3 15:57:24 PST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dave Woldrich schrieb am 2007-01-03:
>> Addendum:  Kirk is right on the money about the Don's Meta library.  You
>> might be able to put something together that works via explicit
>> registration of classes like so:
>> DeeFitRegister!(MyClass);
>> That said, Meta is a work of Template Ninjitsu that is hard to top.
>> Tuples and the rest of D's meta programming capabilities should help you
>> decompose classes and structs from there.
>> But if you need to answer questions like Class.nameof("Foobar"), then
>> you've already out-stripped what can be done at compile-time. :)
>
> Yeah, for fit implementations, I need something like Java's "Object
> Class.forName(String clazz)", "Field Class.getField(String name)", and "Method
> Class.getMethod(String name, Class[] parameterTypes)"  :(  So maybe I'm asking for
> too much, but I hope not since I can mostly get what I want in C++ and that's
> nearly a full letter less than D.  :)

Flectioned should be able to solve your problems, it is however currently
rudimental and only available for linux.

http://svn.dsource.org/projects/flectioned/downloads/flectioned.zip

Class.forName:
	cast(Class) cn.kuehne.flectioned.types["fully.qualified.name"]

Class.getField:
	that is impossible without template foo

Class.getMethod
	should be available at the end of the week

Unpack and have a try:
1) gcc -m32 -c elf.c
2) dmd flectioned.d sample.d elf.o -ofsample
3) ./sample

Thomas


-----BEGIN PGP SIGNATURE-----

iD8DBQFFnE+hLK5blCcjpWoRAvnRAJ9ImMXiLr2waf9/26agv0Dd2WwbgQCfXubs
eqow1r9IUc/u3Uxd3ROkeHM=
=v2pw
-----END PGP SIGNATURE-----



More information about the Digitalmars-d mailing list