Finding class template instantiations via runtime reflection (for openmethods)

bitwise bitwise.pvt at gmail.com
Sat Sep 23 00:38:07 UTC 2017


On Thursday, 21 September 2017 at 20:32:38 UTC, Jean-Louis Leroy 
wrote:
>
> Neither 'Bar!int' nor 'BarInt' appear in 'localClasses'.
>
> Ideas?

The information you can retrieve through localClasses is limited.

AFAIK it only retrieves plain non-template classes declared 
directly in the module. Last I checked, non-template classes 
added via mixin were skipped as well.

I'm not sure how much work can be expected in this area. Things 
related to runtime reflection have slowly been getting removed 
from druntime and dmd. I don't think there's much left of it.

Your best bet is to scrape the info you need on your own using 
D's traits:

https://dlang.org/phobos/std_traits.html
https://dlang.org/spec/traits.html

I would recommend trying to work with std.traits first (as 
opposed to __traits).

If you need to scan entire modules at a time, then start with 
something like this:

foreach(m; __traits(allMembers, fully.qualified.modulename))
{
     // __traits(getMember, ... , ...)
}




More information about the Digitalmars-d mailing list