www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23558] New: add __traits(getModuleClasses [, module name])

https://issues.dlang.org/show_bug.cgi?id=23558

          Issue ID: 23558
           Summary: add __traits(getModuleClasses [, module name])
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: bugzilla digitalmars.com

Since Object.factory() is being deprecated
https://github.com/dlang/dmd/pull/14681 a convenient replacement is necessary.

TraitsExpression:
    __traits ( getModuleClasses [, TraitsArgument] )

The TraitsArgument is the name of the module or a fully qualified import.

If the TraitsArgument is not specified, it defaults to the current module.

It returns a Tuple of strings representing the fully qualified classes defined
in the specified module.

For example:

    module test;
    import std.stdio;
    class C { }
    pragma(msg, __traits(getModuleClasses));
    pragma(msg, __traits(getModuleClasses, std.stdio);

prints:

    tuple("test.C")
    tuple("std.stdio.Stdio.Exception")

".classinfo" can be appended to those strings to get the classinfo for those
modules. See: https://dlang.org/spec/property.html#classinfo

--
Dec 14 2022