-removed next two mixins:
*catchFunc *catchEntityFunc
This commit is contained in:
parent
f39d5ab403
commit
eaf2d1581c
2 changed files with 48 additions and 50 deletions
|
|
@ -637,8 +637,7 @@ class EntityManager
|
||||||
assert(entities_count <= block.entities_count && offset <= block.entities_count);
|
assert(entities_count <= block.entities_count && offset <= block.entities_count);
|
||||||
|
|
||||||
fillInputData(input_data, info, block, offset, entities_count, system);
|
fillInputData(input_data, info, block, offset, entities_count, system);
|
||||||
//mixin(genFillInputData());
|
|
||||||
|
|
||||||
s.onUpdate(input_data);
|
s.onUpdate(input_data);
|
||||||
|
|
||||||
block = block.next_block;
|
block = block.next_block;
|
||||||
|
|
@ -650,66 +649,60 @@ class EntityManager
|
||||||
system.m_update = &callUpdate;
|
system.m_update = &callUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
static string catchFunc(RetType = void)(string member, string func)
|
static void catchFunction(string func_name, RetType = void)(void** member)
|
||||||
{
|
{
|
||||||
//dfmt off
|
static if(hasMember!(Sys,func_name))
|
||||||
static if(is(RetType == void))string ret_str = "";
|
|
||||||
else string ret_str = "return ";
|
|
||||||
string ret = "static if (hasMember!(Sys, \"" ~ func ~ "\") &&
|
|
||||||
Parameters!(Sys."~func~").length == 0 &&
|
|
||||||
is(ReturnType!(Sys."~func~") == "~RetType.stringof~"))
|
|
||||||
{
|
{
|
||||||
static "~RetType.stringof~" call" ~ func
|
foreach (func; __traits(getOverloads, Sys, func_name))
|
||||||
~ "(void* system_pointer)
|
|
||||||
{
|
{
|
||||||
Sys* s = cast(Sys*) system_pointer;
|
static if ((Parameters!(func)).length == 0 && is(ReturnType!(func) == RetType))
|
||||||
"~ret_str~"s." ~ func ~ "();
|
{
|
||||||
|
static RetType callFunc(void* system_pointer)
|
||||||
|
{
|
||||||
|
Sys* s = cast(Sys*) system_pointer;
|
||||||
|
static if(is(RetTyp == void))mixin("s."~func_name~"()");
|
||||||
|
else return mixin("s."~func_name~"()");
|
||||||
|
}
|
||||||
|
*member = cast(void*)&callFunc;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
system."
|
|
||||||
~ member ~ " = &call" ~ func ~ ";
|
|
||||||
}";
|
|
||||||
return ret;
|
|
||||||
//dfmt on
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static string catchEntityFunc(RetType = void)(string member, string func)
|
static void catchEntityFunction(string func_name, RetType = void)(void** member)
|
||||||
{
|
{
|
||||||
//dfmt off
|
static if(hasMember!(Sys,func_name))
|
||||||
|
|
||||||
static if(is(RetType == void))string ret_str = "";
|
|
||||||
else string ret_str = "return ";
|
|
||||||
string ret = "static if (hasMember!(Sys, \"" ~ func ~ "\") &&
|
|
||||||
Parameters!(Sys."~func~").length == 1 &&
|
|
||||||
is(Parameters!(Sys."~func~")[0] == Sys.EntitiesData) &&
|
|
||||||
is(ReturnType!(Sys."~func~") == "~RetType.stringof~"))
|
|
||||||
{
|
{
|
||||||
static "~RetType.stringof~" call" ~ func
|
foreach (func; __traits(getOverloads, Sys, func_name))
|
||||||
~ "(ref ListenerCallData data)
|
|
||||||
{
|
{
|
||||||
Sys* s = cast(Sys*) data.system.m_system_pointer;
|
static if ((Parameters!(func)).length == 1 && is(Parameters!(func)[0] == Sys.EntitiesData) && is(ReturnType!(func) == RetType))
|
||||||
Sys.EntitiesData input_data;
|
{
|
||||||
fillInputData(input_data, data.block.type_info, data.block, data.begin, data.end, data.system);
|
static RetType callFunc(ref ListenerCallData data)
|
||||||
"~ret_str~"s." ~ func ~ "(input_data);
|
{
|
||||||
|
Sys* s = cast(Sys*) data.system.m_system_pointer;
|
||||||
|
Sys.EntitiesData input_data;
|
||||||
|
fillInputData(input_data, data.block.type_info, data.block, data.begin, data.end, data.system);
|
||||||
|
static if(is(RetTyp == void))mixin("s."~func_name~"(input_data)");
|
||||||
|
else return mixin("s."~func_name~"(input_data)");
|
||||||
|
}
|
||||||
|
*member = cast(void*)&callFunc;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
system."
|
|
||||||
~ member ~ " = &call" ~ func ~ ";
|
|
||||||
}";
|
|
||||||
return ret;
|
|
||||||
//dfmt on
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mixin(catchFunc("m_enable", "onEnable"));
|
catchFunction!("onEnable")(&system.m_enable);
|
||||||
mixin(catchFunc("m_disable", "onDisable"));
|
catchFunction!("onDisable")(&system.m_disable);
|
||||||
mixin(catchFunc("m_create", "onCreate"));
|
catchFunction!("onCreate")(&system.m_create);
|
||||||
mixin(catchFunc("m_destroy", "onDestroy"));
|
catchFunction!("onDestroy")(&system.m_destroy);
|
||||||
mixin(catchFunc!(bool)("m_begin", "onBegin"));
|
catchFunction!("onBegin",bool)(&system.m_begin);
|
||||||
mixin(catchFunc("m_end", "onEnd"));
|
catchFunction!("onEnd")(&system.m_end);
|
||||||
|
|
||||||
mixin(catchEntityFunc("m_add_entity", "onAddEntity"));
|
catchEntityFunction!("onAddEntity")(&system.m_add_entity);
|
||||||
mixin(catchEntityFunc("m_remove_entity", "onRemoveEntity"));
|
catchEntityFunction!("onRemoveEntity")(&system.m_remove_entity);
|
||||||
mixin(catchEntityFunc("m_change_entity", "onChangeEntity"));
|
catchEntityFunction!("onChangeEntity")(&system.m_change_entity);
|
||||||
|
|
||||||
system.m_system_pointer = cast(void*) Mallocator.instance.make!Sys;
|
system.m_system_pointer = cast(void*) Mallocator.instance.make!Sys;
|
||||||
system.m_priority = priority;
|
system.m_priority = priority;
|
||||||
|
|
|
||||||
|
|
@ -124,6 +124,11 @@ struct ChangeTestSystem
|
||||||
writeln("On Change Test System create.");
|
writeln("On Change Test System create.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onCreate(int i)
|
||||||
|
{
|
||||||
|
writeln("On Change Test System create.");
|
||||||
|
}
|
||||||
|
|
||||||
void onDestroy()
|
void onDestroy()
|
||||||
{
|
{
|
||||||
writeln("On Change Test System destroy.");
|
writeln("On Change Test System destroy.");
|
||||||
|
|
@ -329,7 +334,7 @@ struct Sys3
|
||||||
|
|
||||||
void onUpdate(EntitiesData data)
|
void onUpdate(EntitiesData data)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue