derelict-sdl2 automatically stripping the SDL_ prefix from names
ProgramGamer
miguel.arseneault at paulequipment.com
Mon Nov 26 16:03:45 UTC 2018
Hi,
I attempted to use a combination of traits and mixins to
automatically create aliases of names in SDL2 without the SDL_
prefix for convenience. However, I was only able to achieve this
for functions in the module, and not for types nor enum values.
How could I go about achieving the desired result? Here is the
code I'm using in an intermediate "sdl_stripped" module:
import std.regex;
import std.array;
public import derelict.sdl2.sdl;
string StripSDLPrefix() {
auto members = [__traits(allMembers, derelict.sdl2.internal)];
foreach(ref member; members) {
if (member.length > 4 && member[0..4] == "SDL_") {
member = "alias " ~ member[4..$] ~ " = " ~ member ~
";\n";
}
else {
member = "";
}
}
return members.join();
}
mixin(StripSDLPrefix());
// I added this to print the list of generated names for
debugging purposes.
static if (false) {
pragma(msg, StripSDLPrefix());
}
More information about the Digitalmars-d-learn
mailing list