diff --git a/source/bubel/ecs/manager.d b/source/bubel/ecs/manager.d index d6fae94..26db180 100644 --- a/source/bubel/ecs/manager.d +++ b/source/bubel/ecs/manager.d @@ -386,6 +386,7 @@ export struct EntityManager else assert(pass < passes.length, "Update pass (ID " ~ pass.to!string ~ ") doesn't exist."); + // enum SystemName = __traits(fullyQualifiedName,Sys); // enum SystemName = fullyQualifiedName!Sys; enum SystemName = fullName!Sys; //enum SystemName = Sys.stringof; @@ -427,7 +428,8 @@ export struct EntityManager { alias EventParamType = Params[1]; enum EventName = fullName!(Unqual!(EventParamType)); - // enum EventName = fullyQualifiedName!(Unqual!(EventParamType));//.stringof; + // enum EventName = __traits(fullyQualifiedName,Unqual!(EventParamType)); + // enum EventName = fullyQualifiedName!(Unqual!(EventParamType)); ushort evt = events_map.get(cast(char[]) EventName, ushort.max); assert(evt != ushort.max, "Can't register system \"" ~ SystemName @@ -489,8 +491,10 @@ export struct EntityManager string name; static if (isArray!MemberType) { // Workaround. This code is never called with: not an array type, but compiler prints an error - // name = fullyQualifiedName!(Unqual!(ForeachType!MemberType));//.stringof; - name = fullName!(Unqual!(typeof(MemberType.init[0]))); + // name = __traits(fullyQualifiedName,Unqual!(ForeachType!MemberType)); + // name = fullyQualifiedName!(Unqual!(ForeachType!MemberType)); + // name = fullName!(Unqual!(typeof(MemberType.init[0]))); + name = fullName!(Unqual!(Unqual!(ForeachType!MemberType))); } bool is_optional; @@ -715,8 +719,9 @@ export struct EntityManager string name; static if (isArray!MemberType) { // Workaround. This code is never called with: not an array type, but compiler prints an error + // name = __traits(fullyQualifiedName,Unqual!(ForeachType!MemberType)); // name = fullyQualifiedName!(Unqual!(ForeachType!MemberType)); - name = fullName!(Unqual!(typeof(MemberType.init[0]))); + name = fullName!(Unqual!(ForeachType!MemberType)); //name = Unqual!(ForeachType!MemberType).stringof; } @@ -1296,6 +1301,7 @@ export struct EntityManager { ComponentInfo info; + // enum ComponentName = __traits(fullyQualifiedName,Comp); // enum ComponentName = fullyQualifiedName!Comp; enum ComponentName = fullName!Comp; // enum ComponentName = Comp.stringof; diff --git a/source/bubel/ecs/traits.d b/source/bubel/ecs/traits.d index e18f656..24bc698 100644 --- a/source/bubel/ecs/traits.d +++ b/source/bubel/ecs/traits.d @@ -69,6 +69,17 @@ template fullName(alias T : X!A, alias X, A...) enum fullName = fullName!parent ~ '.' ~ __traits(identifier, X) ~ "!(" ~ fullName!A ~ ")"; } +template fullName(T...) +{ + static if(__traits(compiles, __traits(parent, T[0]))) + { + alias parent = __traits(parent, T[0]); + enum fullName = fullName!parent ~ '.' ~ __traits(identifier, T[0]) ~ ", " ~ fullName!(T[1 .. $]); + } + else static if(__traits(compiles, __traits(identifier, T[0])))enum fullName = __traits(identifier, T[0]) ~ ", " ~ fullName!(T[1 .. $]); + else enum fullName = T[0].stringof ~ ", " ~ fullName!(T[1 .. $]); +} + template fullName(alias T) { static if(__traits(compiles, __traits(parent, T))) diff --git a/tests/bugs.d b/tests/bugs.d index 9b59973..5eaa8aa 100644 --- a/tests/bugs.d +++ b/tests/bugs.d @@ -177,6 +177,7 @@ unittest @("3-template-system-compilation-file") unittest { + struct TemplateSystem(T) { struct EntitiesData @@ -184,14 +185,31 @@ unittest uint length; } - uint a; - uint b; + T a; + } + + struct TemplateSystem2(T, T2, T3) + { + struct EntitiesData + { + uint length; + } + + T a; + T2 b; + T3 c; } struct TempalteComponent(T) { T parameter; } + + struct TempalteComponent2(T, T2) + { + T parameter; + T2 parameter2; + } gEntityManager.initialize(0); @@ -199,7 +217,9 @@ unittest gEntityManager.registerComponent!CInt; gEntityManager.registerComponent!(TempalteComponent!uint); + gEntityManager.registerComponent!(TempalteComponent2!(float,int)); gEntityManager.registerSystem!(TemplateSystem!CInt)(0); + gEntityManager.registerSystem!(TemplateSystem2!(CInt, uint, float))(0); gEntityManager.endRegister();