derelict-sdl2 automatically stripping the SDL_ prefix from names

unDEFER undefer at gmail.com
Wed Nov 28 23:08:53 UTC 2018


Hello, as I know allMembers returns members not recursively. If 
you want to get really all members you need to make recursive 
function. In my program I used the next routine to print all 
members of module:

static void allMembersOfModule(string module_name, bool 
root=false)()
{
     static if (module_name != "object" &&
         module_name != __MODULE__)
     {
         mixin("import "~module_name~";");

         pragma(msg, module_name~":");

         foreach(member; __traits(allMembers, mixin(module_name)))
         {
             static if (__traits(compiles, mixin(member)) &&
                 (!__traits(compiles, __traits(getProtection, 
mixin(member))) ||
                 __traits(getProtection, mixin(member)) != 
"private" &&
                 __traits(getProtection, mixin(member)) != 
"package"))
                 pragma(msg, member);
         }

         static if (root || module_name == "std.algorithm" || 
module_name == "std.range")
         {
             import std.algorithm.searching: startsWith;

             foreach(member; __traits(allMembers, 
mixin(module_name)))
             {
                 static if (__traits(compiles, mixin(member)) &&
                     __traits(compiles, 
mixin(member).stringof.startsWith("module ")) &&
                     mixin(member).stringof.startsWith("module "))
                 {
                     allMembersOfModule!(member);
                 }
             }
         }
     }
}

As I know it worked good. Maybe it helps to you also.


More information about the Digitalmars-d-learn mailing list