Time for std.reflection

Andrej Mitrovic andrej.mitrovich at gmail.com
Sat Jul 21 17:46:59 PDT 2012


On 7/21/12, Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org> wrote:
> class ModuleInfo {
> @property:
>      string name();
>      ImportInfo[] imports();
>      DataInfo[] data();
>      FunctionInfo[] functions();
>      ClassInfo[] classes();
>      StructInfo[] structs(); // includes unions
>      TemplateInfo[] templates();
>      EnumInfo[] enums();
>      bool hasStaticCtor(), hasStaticDtor(),
>        hasSharedCtor(), hasSharedDtor();
> }

Are class/struct/function/etc templates going to be stored in the
templates field? Then you'd have to tag each template with a type,
e.g. "class template" vs "function template" to be able to filter them
out.

Otherwise classes/functions/etc could have an optional
"TemplateTypeInfo[] typeParams" field so you could filter out
templated from non-templated types by checking their typeParams field,
e.g.: auto tempClasses = filter!(a => !empty(a.typeParams)
)(modinfo.classes);

I use a similar structure to what you've defined for my code generator
and it worked out nicely for me.


More information about the Digitalmars-d mailing list