Skip to content

Commit

Permalink
fix cast error c/c++
Browse files Browse the repository at this point in the history
  • Loading branch information
jpeletier committed Dec 4, 2024
1 parent cbff657 commit 5f7fe2a
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 61 deletions.
52 changes: 22 additions & 30 deletions distr/flecs.h
Original file line number Diff line number Diff line change
Expand Up @@ -3543,29 +3543,29 @@ struct ecs_observer_t {
*/

/* Flags that can be used to check which hooks a type has set */
#define ECS_TYPE_HOOK_CTOR ((ecs_flags32_t)(1 << 0))
#define ECS_TYPE_HOOK_DTOR ((ecs_flags32_t)(1 << 1))
#define ECS_TYPE_HOOK_COPY ((ecs_flags32_t)(1 << 2))
#define ECS_TYPE_HOOK_MOVE ((ecs_flags32_t)(1 << 3))
#define ECS_TYPE_HOOK_COPY_CTOR ((ecs_flags32_t)(1 << 4))
#define ECS_TYPE_HOOK_MOVE_CTOR ((ecs_flags32_t)(1 << 5))
#define ECS_TYPE_HOOK_CTOR_MOVE_DTOR ((ecs_flags32_t)(1 << 6))
#define ECS_TYPE_HOOK_MOVE_DTOR ((ecs_flags32_t)(1 << 7))
#define ECS_TYPE_HOOK_CMP ((ecs_flags32_t)(1 << 8))
#define ECS_TYPE_HOOK_EQUALS ((ecs_flags32_t)(1 << 9))
#define ECS_TYPE_HOOK_CTOR ECS_CAST(ecs_flags32_t, 1 << 0)
#define ECS_TYPE_HOOK_DTOR ECS_CAST(ecs_flags32_t, 1 << 1)
#define ECS_TYPE_HOOK_COPY ECS_CAST(ecs_flags32_t, 1 << 2)
#define ECS_TYPE_HOOK_MOVE ECS_CAST(ecs_flags32_t, 1 << 3)
#define ECS_TYPE_HOOK_COPY_CTOR ECS_CAST(ecs_flags32_t, 1 << 4)
#define ECS_TYPE_HOOK_MOVE_CTOR ECS_CAST(ecs_flags32_t, 1 << 5)
#define ECS_TYPE_HOOK_CTOR_MOVE_DTOR ECS_CAST(ecs_flags32_t, 1 << 6)
#define ECS_TYPE_HOOK_MOVE_DTOR ECS_CAST(ecs_flags32_t, 1 << 7)
#define ECS_TYPE_HOOK_CMP ECS_CAST(ecs_flags32_t, 1 << 8)
#define ECS_TYPE_HOOK_EQUALS ECS_CAST(ecs_flags32_t, 1 << 9)


/* Flags that can be used to set/check which hooks of a type are invalid */
#define ECS_TYPE_HOOK_CTOR_ILLEGAL ((ecs_flags32_t)(1 << 10))
#define ECS_TYPE_HOOK_DTOR_ILLEGAL ((ecs_flags32_t)(1 << 12))
#define ECS_TYPE_HOOK_COPY_ILLEGAL ((ecs_flags32_t)(1 << 13))
#define ECS_TYPE_HOOK_MOVE_ILLEGAL ((ecs_flags32_t)(1 << 14))
#define ECS_TYPE_HOOK_COPY_CTOR_ILLEGAL ((ecs_flags32_t)(1 << 15))
#define ECS_TYPE_HOOK_MOVE_CTOR_ILLEGAL ((ecs_flags32_t)(1 << 16))
#define ECS_TYPE_HOOK_CTOR_MOVE_DTOR_ILLEGAL ((ecs_flags32_t)(1 << 17))
#define ECS_TYPE_HOOK_MOVE_DTOR_ILLEGAL ((ecs_flags32_t)(1 << 18))
#define ECS_TYPE_HOOK_CMP_ILLEGAL ((ecs_flags32_t)(1 << 19))
#define ECS_TYPE_HOOK_EQUALS_ILLEGAL ((ecs_flags32_t)(1 << 20))
#define ECS_TYPE_HOOK_CTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 10)
#define ECS_TYPE_HOOK_DTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 12)
#define ECS_TYPE_HOOK_COPY_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 13)
#define ECS_TYPE_HOOK_MOVE_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 14)
#define ECS_TYPE_HOOK_COPY_CTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 15)
#define ECS_TYPE_HOOK_MOVE_CTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 16)
#define ECS_TYPE_HOOK_CTOR_MOVE_DTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 17)
#define ECS_TYPE_HOOK_MOVE_DTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 18)
#define ECS_TYPE_HOOK_CMP_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 19)
#define ECS_TYPE_HOOK_EQUALS_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 20)


/* All valid hook flags */
Expand Down Expand Up @@ -27003,9 +27003,7 @@ template <> inline const char* symbol_name<double>() {
template<typename T, enable_if_t<
std::is_trivial<T>::value == true
>* = nullptr>
void register_lifecycle_actions(
ecs_world_t*,
ecs_entity_t) {}
void register_lifecycle_actions(ecs_world_t*, ecs_entity_t) { }

// If the component is non-trivial, register component lifecycle actions.
// Depending on the type not all callbacks may be available.
Expand Down Expand Up @@ -27294,7 +27292,7 @@ untyped_component& op_compare(
h.cmp = compare_callback;
h.flags &= ~ECS_TYPE_HOOK_CMP_ILLEGAL;
if(h.flags & ECS_TYPE_HOOK_EQUALS_ILLEGAL) {
h.flags &= ~(ECS_TYPE_HOOK_EQUALS_ILLEGAL);
h.flags &= ~ECS_TYPE_HOOK_EQUALS_ILLEGAL;
h.equals = NULL;
}
set_hooks(h);
Expand Down Expand Up @@ -27667,12 +27665,6 @@ untyped_component& metric(
*
* @ingroup cpp_components
*/

template <typename T>
int ttest() {
return 7;
}

template <typename T>
struct component : untyped_component {
/** Register a component.
Expand Down
40 changes: 20 additions & 20 deletions include/flecs.h
Original file line number Diff line number Diff line change
Expand Up @@ -875,29 +875,29 @@ struct ecs_observer_t {
*/

/* Flags that can be used to check which hooks a type has set */
#define ECS_TYPE_HOOK_CTOR ((ecs_flags32_t)(1 << 0))
#define ECS_TYPE_HOOK_DTOR ((ecs_flags32_t)(1 << 1))
#define ECS_TYPE_HOOK_COPY ((ecs_flags32_t)(1 << 2))
#define ECS_TYPE_HOOK_MOVE ((ecs_flags32_t)(1 << 3))
#define ECS_TYPE_HOOK_COPY_CTOR ((ecs_flags32_t)(1 << 4))
#define ECS_TYPE_HOOK_MOVE_CTOR ((ecs_flags32_t)(1 << 5))
#define ECS_TYPE_HOOK_CTOR_MOVE_DTOR ((ecs_flags32_t)(1 << 6))
#define ECS_TYPE_HOOK_MOVE_DTOR ((ecs_flags32_t)(1 << 7))
#define ECS_TYPE_HOOK_CMP ((ecs_flags32_t)(1 << 8))
#define ECS_TYPE_HOOK_EQUALS ((ecs_flags32_t)(1 << 9))
#define ECS_TYPE_HOOK_CTOR ECS_CAST(ecs_flags32_t, 1 << 0)
#define ECS_TYPE_HOOK_DTOR ECS_CAST(ecs_flags32_t, 1 << 1)
#define ECS_TYPE_HOOK_COPY ECS_CAST(ecs_flags32_t, 1 << 2)
#define ECS_TYPE_HOOK_MOVE ECS_CAST(ecs_flags32_t, 1 << 3)
#define ECS_TYPE_HOOK_COPY_CTOR ECS_CAST(ecs_flags32_t, 1 << 4)
#define ECS_TYPE_HOOK_MOVE_CTOR ECS_CAST(ecs_flags32_t, 1 << 5)
#define ECS_TYPE_HOOK_CTOR_MOVE_DTOR ECS_CAST(ecs_flags32_t, 1 << 6)
#define ECS_TYPE_HOOK_MOVE_DTOR ECS_CAST(ecs_flags32_t, 1 << 7)
#define ECS_TYPE_HOOK_CMP ECS_CAST(ecs_flags32_t, 1 << 8)
#define ECS_TYPE_HOOK_EQUALS ECS_CAST(ecs_flags32_t, 1 << 9)


/* Flags that can be used to set/check which hooks of a type are invalid */
#define ECS_TYPE_HOOK_CTOR_ILLEGAL ((ecs_flags32_t)(1 << 10))
#define ECS_TYPE_HOOK_DTOR_ILLEGAL ((ecs_flags32_t)(1 << 12))
#define ECS_TYPE_HOOK_COPY_ILLEGAL ((ecs_flags32_t)(1 << 13))
#define ECS_TYPE_HOOK_MOVE_ILLEGAL ((ecs_flags32_t)(1 << 14))
#define ECS_TYPE_HOOK_COPY_CTOR_ILLEGAL ((ecs_flags32_t)(1 << 15))
#define ECS_TYPE_HOOK_MOVE_CTOR_ILLEGAL ((ecs_flags32_t)(1 << 16))
#define ECS_TYPE_HOOK_CTOR_MOVE_DTOR_ILLEGAL ((ecs_flags32_t)(1 << 17))
#define ECS_TYPE_HOOK_MOVE_DTOR_ILLEGAL ((ecs_flags32_t)(1 << 18))
#define ECS_TYPE_HOOK_CMP_ILLEGAL ((ecs_flags32_t)(1 << 19))
#define ECS_TYPE_HOOK_EQUALS_ILLEGAL ((ecs_flags32_t)(1 << 20))
#define ECS_TYPE_HOOK_CTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 10)
#define ECS_TYPE_HOOK_DTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 12)
#define ECS_TYPE_HOOK_COPY_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 13)
#define ECS_TYPE_HOOK_MOVE_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 14)
#define ECS_TYPE_HOOK_COPY_CTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 15)
#define ECS_TYPE_HOOK_MOVE_CTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 16)
#define ECS_TYPE_HOOK_CTOR_MOVE_DTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 17)
#define ECS_TYPE_HOOK_MOVE_DTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 18)
#define ECS_TYPE_HOOK_CMP_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 19)
#define ECS_TYPE_HOOK_EQUALS_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 20)


/* All valid hook flags */
Expand Down
12 changes: 2 additions & 10 deletions include/flecs/addons/cpp/component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ template <> inline const char* symbol_name<double>() {
template<typename T, enable_if_t<
std::is_trivial<T>::value == true
>* = nullptr>
void register_lifecycle_actions(
ecs_world_t*,
ecs_entity_t) {}
void register_lifecycle_actions(ecs_world_t*, ecs_entity_t) { }

// If the component is non-trivial, register component lifecycle actions.
// Depending on the type not all callbacks may be available.
Expand Down Expand Up @@ -380,7 +378,7 @@ untyped_component& op_compare(
h.cmp = compare_callback;
h.flags &= ~ECS_TYPE_HOOK_CMP_ILLEGAL;
if(h.flags & ECS_TYPE_HOOK_EQUALS_ILLEGAL) {
h.flags &= ~(ECS_TYPE_HOOK_EQUALS_ILLEGAL);
h.flags &= ~ECS_TYPE_HOOK_EQUALS_ILLEGAL;
h.equals = NULL;
}
set_hooks(h);
Expand Down Expand Up @@ -411,12 +409,6 @@ untyped_component& op_equals(
*
* @ingroup cpp_components
*/

template <typename T>
int ttest() {
return 7;
}

template <typename T>
struct component : untyped_component {
/** Register a component.
Expand Down
1 change: 0 additions & 1 deletion src/world.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* @brief World-level API.
*/

#include "flecs.h"
#include "private_api.h"

/* Id flags */
Expand Down

0 comments on commit 5f7fe2a

Please sign in to comment.