Skip to content

Commit

Permalink
#778 regression issue where components in C++ weren't created with lo…
Browse files Browse the repository at this point in the history
…w ids
  • Loading branch information
SanderMertens committed Aug 1, 2022
1 parent 74fe4ba commit 020672f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
6 changes: 4 additions & 2 deletions flecs.c
Original file line number Diff line number Diff line change
Expand Up @@ -16824,7 +16824,8 @@ ecs_entity_t ecs_cpp_component_register_explicit(
.name = name,
.sep = "::",
.root_sep = "::",
.symbol = symbol
.symbol = symbol,
.use_low_id = true
}),
.type.size = flecs_uto(int32_t, size),
.type.alignment = flecs_uto(int32_t, alignment)
Expand All @@ -16835,7 +16836,8 @@ ecs_entity_t ecs_cpp_component_register_explicit(
.name = name,
.sep = "::",
.root_sep = "::",
.symbol = symbol
.symbol = symbol,
.use_low_id = true
});
}

Expand Down
6 changes: 4 additions & 2 deletions src/addons/flecs_cpp.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,8 @@ ecs_entity_t ecs_cpp_component_register_explicit(
.name = name,
.sep = "::",
.root_sep = "::",
.symbol = symbol
.symbol = symbol,
.use_low_id = true
}),
.type.size = flecs_uto(int32_t, size),
.type.alignment = flecs_uto(int32_t, alignment)
Expand All @@ -369,7 +370,8 @@ ecs_entity_t ecs_cpp_component_register_explicit(
.name = name,
.sep = "::",
.root_sep = "::",
.symbol = symbol
.symbol = symbol,
.use_low_id = true
});
}

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 @@ -964,7 +964,8 @@
"register_w_root_name",
"register_nested_w_root_name",
"set_lookup_path",
"run_post_frame"
"run_post_frame",
"component_w_low_id"
]
}, {
"id": "Singleton",
Expand Down
8 changes: 8 additions & 0 deletions test/cpp_api/src/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1584,3 +1584,11 @@ void World_run_post_frame() {

test_int(ctx, 11);
}

void World_component_w_low_id() {
flecs::world ecs;

flecs::entity p = ecs.component<Position>();

test_assert(p.id() < ECS_HI_COMPONENT_ID);
}
7 changes: 6 additions & 1 deletion test/cpp_api/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,7 @@ void World_register_w_root_name(void);
void World_register_nested_w_root_name(void);
void World_set_lookup_path(void);
void World_run_post_frame(void);
void World_component_w_low_id(void);

// Testsuite 'Singleton'
void Singleton_set_get_singleton(void);
Expand Down Expand Up @@ -4505,6 +4506,10 @@ bake_test_case World_testcases[] = {
{
"run_post_frame",
World_run_post_frame
},
{
"component_w_low_id",
World_component_w_low_id
}
};

Expand Down Expand Up @@ -4871,7 +4876,7 @@ static bake_test_suite suites[] = {
"World",
NULL,
NULL,
88,
89,
World_testcases
},
{
Expand Down

0 comments on commit 020672f

Please sign in to comment.