Fixed unittests and betterC compilation (after adding fullyQualifiedName instead of simple stringof)

-added new trait to get full name of structure (witho module and package, not tested on more nested packages)
-some small improvements (like adding const to function which need it)
This commit is contained in:
Mergul 2020-07-08 22:04:13 +02:00
parent b0b64b965f
commit a0efa4e67d
5 changed files with 53 additions and 15 deletions

View file

@ -37,3 +37,35 @@ static long getIndexOfTypeInEntitiesData(EntitiesData, Type)()
}
return index;
}
static string attachParentName(alias T, string str)()
{
alias parent = __traits(parent, T);
enum parent_str = parent.stringof;
static if(parent_str[0..7] == "module ")
{
static if(__traits(compiles, __traits(parent, parent)))
{
return attachParentName!(parent, parent_str[7 .. $] ~ '.' ~ str);
}
else return parent_str[8 .. $] ~ '.' ~ str;
}
else static if(parent_str[0..8] == "package ")
{
static if(__traits(compiles, __traits(parent, parent)))
{
return attachParentName!(parent, parent_str[8 .. $] ~ '.' ~ str);
}
else return parent_str[8 .. $] ~ '.' ~ str;
}
else static if(__traits(compiles, __traits(parent, parent)))
{
return attachParentName!(parent, parent_str ~ '.' ~ str);
}
else return parent_str ~ '.' ~ str;
}
static string fullName(T)()
{
return attachParentName!(T, T.stringof);
}