Skip to content

Commit 9647395

Browse files
committed
Allow world::entity and world::component to be used to retrieve module ids
1 parent 7837410 commit 9647395

File tree

8 files changed

+40
-10
lines changed

8 files changed

+40
-10
lines changed

flecs.h

+3-4
Original file line numberDiff line numberDiff line change
@@ -16289,7 +16289,7 @@ struct world {
1628916289

1629016290
/** Get current tick.
1629116291
*/
16292-
int32_t tick() const {
16292+
int64_t tick() const {
1629316293
const ecs_world_info_t *stats = ecs_get_world_info(m_world);
1629416294
return stats->frame_count_total;
1629516295
}
@@ -17205,7 +17205,7 @@ ecs_ftime_t get_time_scale() const;
1720517205
/** Get tick
1720617206
* @return Monotonically increasing frame count.
1720717207
*/
17208-
int32_t get_tick() const;
17208+
int64_t get_tick() const;
1720917209

1721017210
/** Set target FPS
1721117211
* @see ecs_set_target_fps
@@ -20941,7 +20941,6 @@ struct cpp_type_impl {
2094120941
ecs_assert(world != nullptr, ECS_COMPONENT_NOT_REGISTERED, name);
2094220942
} else {
2094320943
ecs_assert(!id || s_id == id, ECS_INCONSISTENT_COMPONENT_ID, NULL);
20944-
ecs_assert(s_allow_tag == allow_tag, ECS_INVALID_PARAMETER, NULL);
2094520944
}
2094620945

2094720946
// If no id has been registered yet for the component (indicating the
@@ -24069,7 +24068,7 @@ inline ecs_ftime_t world::get_time_scale() const {
2406924068
return stats->time_scale;
2407024069
}
2407124070

24072-
inline int32_t world::get_tick() const {
24071+
inline int64_t world::get_tick() const {
2407324072
const ecs_world_info_t *stats = ecs_get_world_info(m_world);
2407424073
return stats->frame_count_total;
2407524074
}

include/flecs/addons/cpp/component.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ struct cpp_type_impl {
157157
ecs_assert(world != nullptr, ECS_COMPONENT_NOT_REGISTERED, name);
158158
} else {
159159
ecs_assert(!id || s_id == id, ECS_INCONSISTENT_COMPONENT_ID, NULL);
160-
ecs_assert(s_allow_tag == allow_tag, ECS_INVALID_PARAMETER, NULL);
161160
}
162161

163162
// If no id has been registered yet for the component (indicating the

include/flecs/addons/cpp/mixins/pipeline/impl.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ inline ecs_ftime_t world::get_time_scale() const {
6060
return stats->time_scale;
6161
}
6262

63-
inline int32_t world::get_tick() const {
63+
inline int64_t world::get_tick() const {
6464
const ecs_world_info_t *stats = ecs_get_world_info(m_world);
6565
return stats->frame_count_total;
6666
}

include/flecs/addons/cpp/mixins/pipeline/mixin.inl

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ ecs_ftime_t get_time_scale() const;
5252
/** Get tick
5353
* @return Monotonically increasing frame count.
5454
*/
55-
int32_t get_tick() const;
55+
int64_t get_tick() const;
5656

5757
/** Set target FPS
5858
* @see ecs_set_target_fps

include/flecs/addons/cpp/world.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ struct world {
162162

163163
/** Get current tick.
164164
*/
165-
int32_t tick() const {
165+
int64_t tick() const {
166166
const ecs_world_info_t *stats = ecs_get_world_info(m_world);
167167
return stats->frame_count_total;
168168
}

test/cpp_api/project.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,9 @@
876876
"module_tag_on_namespace",
877877
"dtor_on_fini",
878878
"implicit_module",
879-
"module_in_namespace_w_root_name"
879+
"module_in_namespace_w_root_name",
880+
"module_as_entity",
881+
"module_as_component"
880882
]
881883
}, {
882884
"id": "ImplicitComponents",

test/cpp_api/src/Module.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -236,3 +236,23 @@ void Module_module_in_namespace_w_root_name() {
236236
test_assert(p != 0);
237237
test_assert(p == p_lookup);
238238
}
239+
240+
void Module_module_as_entity() {
241+
flecs::world world;
242+
243+
auto m = world.import<ns::SimpleModule>();
244+
test_assert(m != 0);
245+
246+
auto e = world.entity<ns::SimpleModule>();
247+
test_assert(m == e);
248+
}
249+
250+
void Module_module_as_component() {
251+
flecs::world world;
252+
253+
auto m = world.import<ns::SimpleModule>();
254+
test_assert(m != 0);
255+
256+
auto e = world.component<ns::SimpleModule>();
257+
test_assert(m == e);
258+
}

test/cpp_api/src/main.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,8 @@ void Module_module_tag_on_namespace(void);
837837
void Module_dtor_on_fini(void);
838838
void Module_implicit_module(void);
839839
void Module_module_in_namespace_w_root_name(void);
840+
void Module_module_as_entity(void);
841+
void Module_module_as_component(void);
840842

841843
// Testsuite 'ImplicitComponents'
842844
void ImplicitComponents_add(void);
@@ -4265,6 +4267,14 @@ bake_test_case Module_testcases[] = {
42654267
{
42664268
"module_in_namespace_w_root_name",
42674269
Module_module_in_namespace_w_root_name
4270+
},
4271+
{
4272+
"module_as_entity",
4273+
Module_module_as_entity
4274+
},
4275+
{
4276+
"module_as_component",
4277+
Module_module_as_component
42684278
}
42694279
};
42704280

@@ -5143,7 +5153,7 @@ static bake_test_suite suites[] = {
51435153
"Module",
51445154
NULL,
51455155
NULL,
5146-
9,
5156+
11,
51475157
Module_testcases
51485158
},
51495159
{

0 commit comments

Comments
 (0)