Skip to content

Commit

Permalink
thisModule -> extModule and fix pre/postInit
Browse files Browse the repository at this point in the history
  • Loading branch information
John-Colvin committed Jul 4, 2015
1 parent b750dbd commit 23ad538
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions ppyd.d
Original file line number Diff line number Diff line change
Expand Up @@ -181,31 +181,31 @@ void registerModuleScopeSymbol(string mem, alias parent)()
else pragma(msg, "not registered");
}

void registerAll(alias thisModule)()
void registerAll(alias extModule)()
{
//Horrible hacks because typeinfo init seems be both there and not there,
//depending on when you look
import std.algorithm : startsWith, canFind, endsWith;
alias membersAll = Alias!(__traits(allMembers, thisModule));
alias membersAll = Alias!(__traits(allMembers, extModule));
enum isNotTypeInfoInit(string a) = !(a.startsWith("_")
&& a.canFind("TypeInfo") && a.endsWith("__initZ"));
alias members = Filter!(isNotTypeInfoInit, membersAll);
foreach(mem; members)
{
static if(mixin(`isCallable!(thisModule.`~mem~')'))
registerFunction!(thisModule, mem)();
static if(mixin(`isCallable!(extModule.`~mem~')'))
registerFunction!(extModule, mem)();
}
static if(__traits(hasMember, thisModule, "preInit"))
preInit();
static if(__traits(hasMember, extModule, "preInit"))
extModule.preInit();

module_init();

foreach(mem; members)
{
static if(mixin(`!isCallable!(thisModule.`~mem~')'))
registerModuleScopeSymbol!(mem, thisModule)();
static if(mixin(`!isCallable!(extModule.`~mem~')'))
registerModuleScopeSymbol!(mem, extModule)();
}

static if(__traits(hasMember, thisModule, "postInit"))
postInit();
static if(__traits(hasMember, extModule, "postInit"))
extModule.postInit();
}

0 comments on commit 23ad538

Please sign in to comment.