Don't use ForeachType as it don't work if foreach type is not copyable. #25

Merged
mmcomando merged 2 commits from wasm_fixes into master 2022-10-06 19:01:51 +02:00
2 changed files with 20 additions and 7 deletions

View file

@ -55,15 +55,26 @@ add_project_link_arguments(link_args, language : 'd')
# Dependencies # Dependencies
threads_dep = dependency('threads') threads_dep = dependency('threads')
d_versions = []
deps = []
if host_machine.cpu_family() == 'wasm32'
d_versions += 'ECSEmscripten'
else
# meson incorectly adds "-s USE_PTHREADS=1" to ldc2 invocation whe pthreads is added as dependency
# add it for non wasm builds
deps += threads_dep
endif
ecs_lib = library('BubelECS', ecs_lib = library('BubelECS',
src, src,
d_module_versions : d_versions,
include_directories : [inc], include_directories : [inc],
) )
bubel_ecs_dep = declare_dependency( bubel_ecs_dep = declare_dependency(
include_directories : [inc], include_directories : [inc],
link_with : ecs_lib, link_with : ecs_lib,
dependencies : threads_dep, dependencies : deps,
) )
meson.override_dependency('bubel-ecs', bubel_ecs_dep) meson.override_dependency('bubel-ecs', bubel_ecs_dep)

View file

@ -465,7 +465,7 @@ export struct EntityManager
static if (isArray!MemberType) static if (isArray!MemberType)
{ // Workaround. This code is never called with: not an array type, but compiler prints an error { // Workaround. This code is never called with: not an array type, but compiler prints an error
// name = fullyQualifiedName!(Unqual!(ForeachType!MemberType));//.stringof; // name = fullyQualifiedName!(Unqual!(ForeachType!MemberType));//.stringof;
name = fullName!(Unqual!(ForeachType!MemberType)); name = fullName!(Unqual!(typeof(MemberType.init[0])));
} }
bool is_optional; bool is_optional;
@ -691,7 +691,7 @@ export struct EntityManager
static if (isArray!MemberType) static if (isArray!MemberType)
{ // Workaround. This code is never called with: not an array type, but compiler prints an error { // Workaround. This code is never called with: not an array type, but compiler prints an error
// name = fullyQualifiedName!(Unqual!(ForeachType!MemberType)); // name = fullyQualifiedName!(Unqual!(ForeachType!MemberType));
name = fullName!(Unqual!(ForeachType!MemberType)); name = fullName!(Unqual!(typeof(MemberType.init[0])));
//name = Unqual!(ForeachType!MemberType).stringof; //name = Unqual!(ForeachType!MemberType).stringof;
} }
@ -899,10 +899,12 @@ export struct EntityManager
static foreach (iii, comp_info; components_info.m_req[0 static foreach (iii, comp_info; components_info.m_req[0
.. components_info.m_req_counter]) .. components_info.m_req_counter])
{ {
__traits(getMember, input_data, comp_info.name) = (cast(ForeachType!(typeof(__traits(getMember, __traits(getMember, input_data, comp_info.name) = (
Sys.EntitiesData, comp_info.name)))*)( cast(typeof(
cast(void*) block + info.deltas[system.m_components[iii]]))[offset (typeof(__traits(getMember, Sys.EntitiesData, comp_info.name))).init[0]
.. entities_count]; )*)
(cast(void*) block + info.deltas[system.m_components[iii]])
)[offset .. entities_count];
} }
static foreach (iii, comp_info; components_info.m_optional[0 static foreach (iii, comp_info; components_info.m_optional[0