Syntax '*ptr = Structure.init' requires opAssign operator, get rid of this requirement by using malloc.

This is useful when component is defined in another shared library and we use '-fvisibility=hidden', in that case opAssign is hidden and we will get 'undefined symbol'
This commit is contained in:
Michał Masiukiewicz 2022-10-27 23:29:50 +02:00
parent a8d48f1218
commit c0246ce2af

View file

@ -1307,7 +1307,8 @@ export struct EntityManager
info.size = Comp.sizeof; info.size = Comp.sizeof;
info.alignment = Comp.alignof; //8; info.alignment = Comp.alignof; //8;
info.init_data = Mallocator.makeArray!ubyte(Comp.sizeof); info.init_data = Mallocator.makeArray!ubyte(Comp.sizeof);
*cast(Comp*) info.init_data.ptr = Comp.init; // = Comp(); __gshared Comp init_memory;
memcpy(info.init_data.ptr, &init_memory, Comp.sizeof);
ushort comp_id = components_map.get(cast(char[]) ComponentName, ushort.max); ushort comp_id = components_map.get(cast(char[]) ComponentName, ushort.max);
if (comp_id < components.length) if (comp_id < components.length)