From cbff6575c142bf1e2a4c792694d9ac115fb86f77 Mon Sep 17 00:00:00 2001 From: Javier Peletier Date: Wed, 4 Dec 2024 22:57:32 +0100 Subject: [PATCH] fix quirks (1) --- distr/flecs.h | 159 +++++++++--------- include/flecs.h | 62 +++---- include/flecs/addons/cpp/component.hpp | 54 +++++- .../cpp/mixins/meta/untyped_component.inl | 43 ----- 4 files changed, 160 insertions(+), 158 deletions(-) diff --git a/distr/flecs.h b/distr/flecs.h index 03c01497b2..901a6b5f8d 100644 --- a/distr/flecs.h +++ b/distr/flecs.h @@ -3543,44 +3543,44 @@ struct ecs_observer_t { */ /* Flags that can be used to check which hooks a type has set */ -static const ecs_flags32_t ECS_TYPE_HOOK_CTOR = (1 << 0); -static const ecs_flags32_t ECS_TYPE_HOOK_DTOR = (1 << 1); -static const ecs_flags32_t ECS_TYPE_HOOK_COPY = (1 << 2); -static const ecs_flags32_t ECS_TYPE_HOOK_MOVE = (1 << 3); -static const ecs_flags32_t ECS_TYPE_HOOK_COPY_CTOR = (1 << 4); -static const ecs_flags32_t ECS_TYPE_HOOK_MOVE_CTOR = (1 << 5); -static const ecs_flags32_t ECS_TYPE_HOOK_CTOR_MOVE_DTOR = (1 << 6); -static const ecs_flags32_t ECS_TYPE_HOOK_MOVE_DTOR = (1 << 7); -static const ecs_flags32_t ECS_TYPE_HOOK_CMP = (1 << 8); -static const ecs_flags32_t ECS_TYPE_HOOK_EQUALS = (1 << 9); +#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)) /* Flags that can be used to set/check which hooks of a type are invalid */ -static const ecs_flags32_t ECS_TYPE_HOOK_CTOR_ILLEGAL = (1 << 10); -static const ecs_flags32_t ECS_TYPE_HOOK_DTOR_ILLEGAL = (1 << 12); -static const ecs_flags32_t ECS_TYPE_HOOK_COPY_ILLEGAL = (1 << 13); -static const ecs_flags32_t ECS_TYPE_HOOK_MOVE_ILLEGAL = (1 << 14); -static const ecs_flags32_t ECS_TYPE_HOOK_COPY_CTOR_ILLEGAL = (1 << 15); -static const ecs_flags32_t ECS_TYPE_HOOK_MOVE_CTOR_ILLEGAL = (1 << 16); -static const ecs_flags32_t ECS_TYPE_HOOK_CTOR_MOVE_DTOR_ILLEGAL= (1 << 17); -static const ecs_flags32_t ECS_TYPE_HOOK_MOVE_DTOR_ILLEGAL = (1 << 18); -static const ecs_flags32_t ECS_TYPE_HOOK_CMP_ILLEGAL = (1 << 19); -static const ecs_flags32_t ECS_TYPE_HOOK_EQUALS_ILLEGAL = (1 << 20); +#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)) /* All valid hook flags */ -static const ecs_flags32_t ECS_TYPE_HOOKS = (ECS_TYPE_HOOK_CTOR|ECS_TYPE_HOOK_DTOR| - ECS_TYPE_HOOK_COPY|ECS_TYPE_HOOK_MOVE|ECS_TYPE_HOOK_COPY_CTOR| - ECS_TYPE_HOOK_MOVE_CTOR|ECS_TYPE_HOOK_CTOR_MOVE_DTOR| - ECS_TYPE_HOOK_MOVE_DTOR|ECS_TYPE_HOOK_CMP|ECS_TYPE_HOOK_EQUALS); -/* All invalid hook flags */ -static const ecs_flags32_t ECS_TYPE_HOOKS_ILLEGAL = (ECS_TYPE_HOOK_CTOR_ILLEGAL| - ECS_TYPE_HOOK_DTOR_ILLEGAL|ECS_TYPE_HOOK_COPY_ILLEGAL| - ECS_TYPE_HOOK_MOVE_ILLEGAL|ECS_TYPE_HOOK_COPY_CTOR_ILLEGAL| - ECS_TYPE_HOOK_MOVE_CTOR_ILLEGAL|ECS_TYPE_HOOK_CTOR_MOVE_DTOR_ILLEGAL| - ECS_TYPE_HOOK_MOVE_DTOR_ILLEGAL|ECS_TYPE_HOOK_CMP_ILLEGAL | - ECS_TYPE_HOOK_EQUALS_ILLEGAL); +#define ECS_TYPE_HOOKS (ECS_TYPE_HOOK_CTOR|ECS_TYPE_HOOK_DTOR|\ + ECS_TYPE_HOOK_COPY|ECS_TYPE_HOOK_MOVE|ECS_TYPE_HOOK_COPY_CTOR|\ + ECS_TYPE_HOOK_MOVE_CTOR|ECS_TYPE_HOOK_CTOR_MOVE_DTOR|\ + ECS_TYPE_HOOK_MOVE_DTOR|ECS_TYPE_HOOK_CMP|ECS_TYPE_HOOK_EQUALS) +/* All invalid hook flags */ +#define ECS_TYPE_HOOKS_ILLEGAL (ECS_TYPE_HOOK_CTOR_ILLEGAL|\ + ECS_TYPE_HOOK_DTOR_ILLEGAL|ECS_TYPE_HOOK_COPY_ILLEGAL|\ + ECS_TYPE_HOOK_MOVE_ILLEGAL|ECS_TYPE_HOOK_COPY_CTOR_ILLEGAL|\ + ECS_TYPE_HOOK_MOVE_CTOR_ILLEGAL|ECS_TYPE_HOOK_CTOR_MOVE_DTOR_ILLEGAL|\ + ECS_TYPE_HOOK_MOVE_DTOR_ILLEGAL|ECS_TYPE_HOOK_CMP_ILLEGAL|\ + ECS_TYPE_HOOK_EQUALS_ILLEGAL) struct ecs_type_hooks_t { ecs_xtor_t ctor; /**< ctor */ ecs_xtor_t dtor; /**< dtor */ @@ -27004,8 +27004,8 @@ template::value == true >* = nullptr> void register_lifecycle_actions( - ecs_world_t *world, - ecs_entity_t component) {} + 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. @@ -27268,6 +27268,50 @@ struct type::value >> struct untyped_component : entity { using entity::entity; +protected: + +flecs::type_hooks_t get_hooks() const { + const flecs::type_hooks_t* h = ecs_get_hooks_id(world_, id_); + if (h) { + return *h; + } else { + return {}; + } +} + +void set_hooks(flecs::type_hooks_t &h) { + h.flags &= ECS_TYPE_HOOKS_ILLEGAL; + ecs_set_hooks_id(world_, id_, &h); +} + +public: + +untyped_component& op_compare( + ecs_cmp_t compare_callback) +{ + ecs_assert(compare_callback, ECS_INVALID_PARAMETER, NULL); + flecs::type_hooks_t h = get_hooks(); + 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.equals = NULL; + } + set_hooks(h); + return *this; +} + +untyped_component& op_equals( + ecs_equals_t equals_callback) +{ + ecs_assert(equals_callback, ECS_INVALID_PARAMETER, NULL); + flecs::type_hooks_t h = get_hooks(); + h.equals = equals_callback; + h.flags &= ~ECS_TYPE_HOOK_EQUALS_ILLEGAL; + set_hooks(h); + return *this; +} + # ifdef FLECS_META /** * @file addons/cpp/mixins/meta/untyped_component.inl @@ -27311,22 +27355,6 @@ untyped_component& internal_member( return *this; } -protected: - -flecs::type_hooks_t get_hooks() const { - const flecs::type_hooks_t* h = ecs_get_hooks_id(world_, id_); - if (h) { - return *h; - } else { - return {}; - } -} - -void set_hooks(flecs::type_hooks_t &h) { - h.flags &= ECS_TYPE_HOOKS_ILLEGAL; - ecs_set_hooks_id(world_, id_, &h); -} - public: /** Add member with unit. */ @@ -27593,33 +27621,6 @@ untyped_component& error_range( return *this; } -untyped_component& op_compare( - ecs_cmp_t compare_callback) -{ - ecs_assert(compare_callback, ECS_INVALID_PARAMETER, NULL); - flecs::type_hooks_t h = get_hooks(); - 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.equals = NULL; - } - set_hooks(h); - return *this; -} - -untyped_component& op_equals( - ecs_equals_t equals_callback) -{ - ecs_assert(equals_callback, ECS_INVALID_PARAMETER, NULL); - flecs::type_hooks_t h = get_hooks(); - h.equals = equals_callback; - h.flags &= ~ECS_TYPE_HOOK_EQUALS_ILLEGAL; - set_hooks(h); - return *this; -} - - /** @} */ # endif @@ -27756,7 +27757,7 @@ struct component : untyped_component { template component& on_add(Func&& func) { using Delegate = typename _::each_delegate::type, T>; - flecs::type_hooks_t h = get_hooks(); + flecs::type_hooks_t h = this->get_hooks(); ecs_assert(h.on_add == nullptr, ECS_INVALID_OPERATION, "on_add hook is already set"); BindingCtx *ctx = get_binding_ctx(h); @@ -27772,7 +27773,7 @@ struct component : untyped_component { component& on_remove(Func&& func) { using Delegate = typename _::each_delegate< typename std::decay::type, T>; - flecs::type_hooks_t h = get_hooks(); + flecs::type_hooks_t h = this->get_hooks(); ecs_assert(h.on_remove == nullptr, ECS_INVALID_OPERATION, "on_remove hook is already set"); BindingCtx *ctx = get_binding_ctx(h); @@ -27788,7 +27789,7 @@ struct component : untyped_component { component& on_set(Func&& func) { using Delegate = typename _::each_delegate< typename std::decay::type, T>; - flecs::type_hooks_t h = get_hooks(); + flecs::type_hooks_t h = this->get_hooks(); ecs_assert(h.on_set == nullptr, ECS_INVALID_OPERATION, "on_set hook is already set"); BindingCtx *ctx = get_binding_ctx(h); diff --git a/include/flecs.h b/include/flecs.h index ff40ec7ce9..2dc2266853 100644 --- a/include/flecs.h +++ b/include/flecs.h @@ -875,44 +875,44 @@ struct ecs_observer_t { */ /* Flags that can be used to check which hooks a type has set */ -static const ecs_flags32_t ECS_TYPE_HOOK_CTOR = (1 << 0); -static const ecs_flags32_t ECS_TYPE_HOOK_DTOR = (1 << 1); -static const ecs_flags32_t ECS_TYPE_HOOK_COPY = (1 << 2); -static const ecs_flags32_t ECS_TYPE_HOOK_MOVE = (1 << 3); -static const ecs_flags32_t ECS_TYPE_HOOK_COPY_CTOR = (1 << 4); -static const ecs_flags32_t ECS_TYPE_HOOK_MOVE_CTOR = (1 << 5); -static const ecs_flags32_t ECS_TYPE_HOOK_CTOR_MOVE_DTOR = (1 << 6); -static const ecs_flags32_t ECS_TYPE_HOOK_MOVE_DTOR = (1 << 7); -static const ecs_flags32_t ECS_TYPE_HOOK_CMP = (1 << 8); -static const ecs_flags32_t ECS_TYPE_HOOK_EQUALS = (1 << 9); +#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)) /* Flags that can be used to set/check which hooks of a type are invalid */ -static const ecs_flags32_t ECS_TYPE_HOOK_CTOR_ILLEGAL = (1 << 10); -static const ecs_flags32_t ECS_TYPE_HOOK_DTOR_ILLEGAL = (1 << 12); -static const ecs_flags32_t ECS_TYPE_HOOK_COPY_ILLEGAL = (1 << 13); -static const ecs_flags32_t ECS_TYPE_HOOK_MOVE_ILLEGAL = (1 << 14); -static const ecs_flags32_t ECS_TYPE_HOOK_COPY_CTOR_ILLEGAL = (1 << 15); -static const ecs_flags32_t ECS_TYPE_HOOK_MOVE_CTOR_ILLEGAL = (1 << 16); -static const ecs_flags32_t ECS_TYPE_HOOK_CTOR_MOVE_DTOR_ILLEGAL= (1 << 17); -static const ecs_flags32_t ECS_TYPE_HOOK_MOVE_DTOR_ILLEGAL = (1 << 18); -static const ecs_flags32_t ECS_TYPE_HOOK_CMP_ILLEGAL = (1 << 19); -static const ecs_flags32_t ECS_TYPE_HOOK_EQUALS_ILLEGAL = (1 << 20); +#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)) /* All valid hook flags */ -static const ecs_flags32_t ECS_TYPE_HOOKS = (ECS_TYPE_HOOK_CTOR|ECS_TYPE_HOOK_DTOR| - ECS_TYPE_HOOK_COPY|ECS_TYPE_HOOK_MOVE|ECS_TYPE_HOOK_COPY_CTOR| - ECS_TYPE_HOOK_MOVE_CTOR|ECS_TYPE_HOOK_CTOR_MOVE_DTOR| - ECS_TYPE_HOOK_MOVE_DTOR|ECS_TYPE_HOOK_CMP|ECS_TYPE_HOOK_EQUALS); -/* All invalid hook flags */ -static const ecs_flags32_t ECS_TYPE_HOOKS_ILLEGAL = (ECS_TYPE_HOOK_CTOR_ILLEGAL| - ECS_TYPE_HOOK_DTOR_ILLEGAL|ECS_TYPE_HOOK_COPY_ILLEGAL| - ECS_TYPE_HOOK_MOVE_ILLEGAL|ECS_TYPE_HOOK_COPY_CTOR_ILLEGAL| - ECS_TYPE_HOOK_MOVE_CTOR_ILLEGAL|ECS_TYPE_HOOK_CTOR_MOVE_DTOR_ILLEGAL| - ECS_TYPE_HOOK_MOVE_DTOR_ILLEGAL|ECS_TYPE_HOOK_CMP_ILLEGAL | - ECS_TYPE_HOOK_EQUALS_ILLEGAL); +#define ECS_TYPE_HOOKS (ECS_TYPE_HOOK_CTOR|ECS_TYPE_HOOK_DTOR|\ + ECS_TYPE_HOOK_COPY|ECS_TYPE_HOOK_MOVE|ECS_TYPE_HOOK_COPY_CTOR|\ + ECS_TYPE_HOOK_MOVE_CTOR|ECS_TYPE_HOOK_CTOR_MOVE_DTOR|\ + ECS_TYPE_HOOK_MOVE_DTOR|ECS_TYPE_HOOK_CMP|ECS_TYPE_HOOK_EQUALS) +/* All invalid hook flags */ +#define ECS_TYPE_HOOKS_ILLEGAL (ECS_TYPE_HOOK_CTOR_ILLEGAL|\ + ECS_TYPE_HOOK_DTOR_ILLEGAL|ECS_TYPE_HOOK_COPY_ILLEGAL|\ + ECS_TYPE_HOOK_MOVE_ILLEGAL|ECS_TYPE_HOOK_COPY_CTOR_ILLEGAL|\ + ECS_TYPE_HOOK_MOVE_CTOR_ILLEGAL|ECS_TYPE_HOOK_CTOR_MOVE_DTOR_ILLEGAL|\ + ECS_TYPE_HOOK_MOVE_DTOR_ILLEGAL|ECS_TYPE_HOOK_CMP_ILLEGAL|\ + ECS_TYPE_HOOK_EQUALS_ILLEGAL) struct ecs_type_hooks_t { ecs_xtor_t ctor; /**< ctor */ ecs_xtor_t dtor; /**< dtor */ diff --git a/include/flecs/addons/cpp/component.hpp b/include/flecs/addons/cpp/component.hpp index bc4edcb339..1ecf630abe 100644 --- a/include/flecs/addons/cpp/component.hpp +++ b/include/flecs/addons/cpp/component.hpp @@ -90,8 +90,8 @@ template::value == true >* = nullptr> void register_lifecycle_actions( - ecs_world_t *world, - ecs_entity_t component) {} + 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. @@ -354,6 +354,50 @@ struct type::value >> struct untyped_component : entity { using entity::entity; +protected: + +flecs::type_hooks_t get_hooks() const { + const flecs::type_hooks_t* h = ecs_get_hooks_id(world_, id_); + if (h) { + return *h; + } else { + return {}; + } +} + +void set_hooks(flecs::type_hooks_t &h) { + h.flags &= ECS_TYPE_HOOKS_ILLEGAL; + ecs_set_hooks_id(world_, id_, &h); +} + +public: + +untyped_component& op_compare( + ecs_cmp_t compare_callback) +{ + ecs_assert(compare_callback, ECS_INVALID_PARAMETER, NULL); + flecs::type_hooks_t h = get_hooks(); + 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.equals = NULL; + } + set_hooks(h); + return *this; +} + +untyped_component& op_equals( + ecs_equals_t equals_callback) +{ + ecs_assert(equals_callback, ECS_INVALID_PARAMETER, NULL); + flecs::type_hooks_t h = get_hooks(); + h.equals = equals_callback; + h.flags &= ~ECS_TYPE_HOOK_EQUALS_ILLEGAL; + set_hooks(h); + return *this; +} + # ifdef FLECS_META # include "mixins/meta/untyped_component.inl" # endif @@ -457,7 +501,7 @@ struct component : untyped_component { template component& on_add(Func&& func) { using Delegate = typename _::each_delegate::type, T>; - flecs::type_hooks_t h = get_hooks(); + flecs::type_hooks_t h = this->get_hooks(); ecs_assert(h.on_add == nullptr, ECS_INVALID_OPERATION, "on_add hook is already set"); BindingCtx *ctx = get_binding_ctx(h); @@ -473,7 +517,7 @@ struct component : untyped_component { component& on_remove(Func&& func) { using Delegate = typename _::each_delegate< typename std::decay::type, T>; - flecs::type_hooks_t h = get_hooks(); + flecs::type_hooks_t h = this->get_hooks(); ecs_assert(h.on_remove == nullptr, ECS_INVALID_OPERATION, "on_remove hook is already set"); BindingCtx *ctx = get_binding_ctx(h); @@ -489,7 +533,7 @@ struct component : untyped_component { component& on_set(Func&& func) { using Delegate = typename _::each_delegate< typename std::decay::type, T>; - flecs::type_hooks_t h = get_hooks(); + flecs::type_hooks_t h = this->get_hooks(); ecs_assert(h.on_set == nullptr, ECS_INVALID_OPERATION, "on_set hook is already set"); BindingCtx *ctx = get_binding_ctx(h); diff --git a/include/flecs/addons/cpp/mixins/meta/untyped_component.inl b/include/flecs/addons/cpp/mixins/meta/untyped_component.inl index 1cb75e61d5..6c1df49db4 100644 --- a/include/flecs/addons/cpp/mixins/meta/untyped_component.inl +++ b/include/flecs/addons/cpp/mixins/meta/untyped_component.inl @@ -40,22 +40,6 @@ untyped_component& internal_member( return *this; } -protected: - -flecs::type_hooks_t get_hooks() const { - const flecs::type_hooks_t* h = ecs_get_hooks_id(world_, id_); - if (h) { - return *h; - } else { - return {}; - } -} - -void set_hooks(flecs::type_hooks_t &h) { - h.flags &= ECS_TYPE_HOOKS_ILLEGAL; - ecs_set_hooks_id(world_, id_, &h); -} - public: /** Add member with unit. */ @@ -322,31 +306,4 @@ untyped_component& error_range( return *this; } -untyped_component& op_compare( - ecs_cmp_t compare_callback) -{ - ecs_assert(compare_callback, ECS_INVALID_PARAMETER, NULL); - flecs::type_hooks_t h = get_hooks(); - 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.equals = NULL; - } - set_hooks(h); - return *this; -} - -untyped_component& op_equals( - ecs_equals_t equals_callback) -{ - ecs_assert(equals_callback, ECS_INVALID_PARAMETER, NULL); - flecs::type_hooks_t h = get_hooks(); - h.equals = equals_callback; - h.flags &= ~ECS_TYPE_HOOK_EQUALS_ILLEGAL; - set_hooks(h); - return *this; -} - - /** @} */