Skip to content

Commit

Permalink
Ensure units module is imported by monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderMertens committed Nov 26, 2023
1 parent b4c31ec commit 2f8ad57
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
3 changes: 3 additions & 0 deletions flecs.c
Original file line number Diff line number Diff line change
Expand Up @@ -30287,6 +30287,9 @@ void FlecsMonitorImport(
#ifdef FLECS_META
ECS_IMPORT(world, FlecsMeta);
#endif
#ifdef FLECS_UNITS
ECS_IMPORT(world, FlecsUnits);
#endif

ecs_set_name_prefix(world, "Ecs");

Expand Down
3 changes: 3 additions & 0 deletions src/addons/monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,9 @@ void FlecsMonitorImport(
#ifdef FLECS_META
ECS_IMPORT(world, FlecsMeta);
#endif
#ifdef FLECS_UNITS
ECS_IMPORT(world, FlecsUnits);
#endif

ecs_set_name_prefix(world, "Ecs");

Expand Down
3 changes: 2 additions & 1 deletion test/cpp_api/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,8 @@
"module_in_namespace_w_root_name",
"module_as_entity",
"module_as_component",
"module_with_core_name"
"module_with_core_name",
"import_addons_two_worlds"
]
}, {
"id": "ImplicitComponents",
Expand Down
13 changes: 13 additions & 0 deletions test/cpp_api/src/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,3 +276,16 @@ void Module_module_with_core_name(void) {
test_str(pos.path().c_str(), "::Module::Position");
test_assert(pos == world.id<Position>());
}

void Module_import_addons_two_worlds(void) {
flecs::world a;
auto m1 = a.import<flecs::monitor>();
auto u1 = a.import<flecs::units>();

flecs::world b;
auto m2 = b.import<flecs::monitor>();
auto u2 = b.import<flecs::units>();

test_assert(m1 == m2);
test_assert(u1 == u2);
}
7 changes: 6 additions & 1 deletion test/cpp_api/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,7 @@ void Module_module_in_namespace_w_root_name(void);
void Module_module_as_entity(void);
void Module_module_as_component(void);
void Module_module_with_core_name(void);
void Module_import_addons_two_worlds(void);

// Testsuite 'ImplicitComponents'
void ImplicitComponents_add(void);
Expand Down Expand Up @@ -5220,6 +5221,10 @@ bake_test_case Module_testcases[] = {
{
"module_with_core_name",
Module_module_with_core_name
},
{
"import_addons_two_worlds",
Module_import_addons_two_worlds
}
};

Expand Down Expand Up @@ -6625,7 +6630,7 @@ static bake_test_suite suites[] = {
"Module",
NULL,
NULL,
12,
13,
Module_testcases
},
{
Expand Down

0 comments on commit 2f8ad57

Please sign in to comment.