From 16fe54f4c78d38a4d9e8fe48a37c9765ff1ba116 Mon Sep 17 00:00:00 2001 From: Kelwan Date: Thu, 30 May 2024 17:39:13 -0700 Subject: [PATCH] feat: Accomodated overloads for other capabilities --- .../association/association.cc | 36 +++--- .../association/association.hh | 103 ++++++++---------- .../core/system_provider/basic/basic.cc | 27 +++-- .../system_provider/system_ctx_functions.cc | 30 ++--- .../system_provider/system_ctx_functions.hh | 13 ++- 5 files changed, 100 insertions(+), 109 deletions(-) diff --git a/rt_entt_codegen/core/system_provider/association/association.cc b/rt_entt_codegen/core/system_provider/association/association.cc index 5cc71d3..fd522d0 100644 --- a/rt_entt_codegen/core/system_provider/association/association.cc +++ b/rt_entt_codegen/core/system_provider/association/association.cc @@ -7,17 +7,16 @@ #include "rt_entt_codegen/shared/util.hh" #include "ecsact/runtime/meta.hh" #include "ecsact/cpp_codegen_plugin_util.hh" -#include "rt_entt_codegen/core/system_provider/system_ctx_functions.hh" - -using ecsact::rt_entt_codegen::provider::context_action_impl; -using ecsact::rt_entt_codegen::provider::context_add_impl; -using ecsact::rt_entt_codegen::provider::context_generate_impl; -using ecsact::rt_entt_codegen::provider::context_get_impl; -using ecsact::rt_entt_codegen::provider::context_has_impl; -using ecsact::rt_entt_codegen::provider::context_other_impl; -using ecsact::rt_entt_codegen::provider::context_parent_impl; -using ecsact::rt_entt_codegen::provider::context_remove_impl; -using ecsact::rt_entt_codegen::provider::context_update_impl; + +using ecsact::rt_entt_codegen::core::provider::context_action_impl; +using ecsact::rt_entt_codegen::core::provider::context_add_impl; +using ecsact::rt_entt_codegen::core::provider::context_generate_impl; +using ecsact::rt_entt_codegen::core::provider::context_get_impl; +using ecsact::rt_entt_codegen::core::provider::context_has_impl; +using ecsact::rt_entt_codegen::core::provider::context_other_impl; +using ecsact::rt_entt_codegen::core::provider::context_parent_impl; +using ecsact::rt_entt_codegen::core::provider::context_remove_impl; +using ecsact::rt_entt_codegen::core::provider::context_update_impl; using capability_t = std::unordered_map; @@ -210,8 +209,13 @@ auto ecsact::rt_entt_codegen::core::provider::association::print_other_contexts( ctx.write(std::format("{}_t* view;\n", view_type_name)); ctx.write("\n"); print_other_ctx_action(ctx); - print_other_ctx_add(ctx, other_details); - print_other_ctx_remove(ctx, other_details, view_type_name); + print_other_ctx_add(ctx, assoc_detail.capabilities, other_details); + print_other_ctx_remove( + ctx, + assoc_detail.capabilities, + other_details, + view_type_name + ); print_other_ctx_get(ctx, other_details, view_type_name); print_other_ctx_update(ctx, other_details, view_type_name); print_other_ctx_has(ctx, other_details); @@ -245,6 +249,7 @@ auto ecsact::rt_entt_codegen::core::provider::association:: auto ecsact::rt_entt_codegen::core::provider::association::print_other_ctx_add( ecsact::codegen_plugin_context& ctx, + const capability_t& other_caps, const ecsact::rt_entt_codegen::ecsact_entt_system_details& details ) -> void { auto printer = // @@ -253,12 +258,13 @@ auto ecsact::rt_entt_codegen::core::provider::association::print_other_ctx_add( .parameter("const void*", "component_data") .return_type("void final"); - context_add_impl(ctx, sys_like_id_variant); + context_add_impl(ctx, other_caps); } auto ecsact::rt_entt_codegen::core::provider::association:: print_other_ctx_remove( ecsact::codegen_plugin_context& ctx, + const capability_t& other_caps, const ecsact::rt_entt_codegen::ecsact_entt_system_details& details, const std::string& view_type_name ) -> void { @@ -267,7 +273,7 @@ auto ecsact::rt_entt_codegen::core::provider::association:: .parameter("ecsact_component_like_id", "component_id") .return_type("void final"); - context_remove_impl(ctx, sys_like_id_variant, details, view_type_name); + context_remove_impl(ctx, other_caps, details, view_type_name); } auto ecsact::rt_entt_codegen::core::provider::association::print_other_ctx_get( diff --git a/rt_entt_codegen/core/system_provider/association/association.hh b/rt_entt_codegen/core/system_provider/association/association.hh index 601e565..f1b28ec 100644 --- a/rt_entt_codegen/core/system_provider/association/association.hh +++ b/rt_entt_codegen/core/system_provider/association/association.hh @@ -5,6 +5,7 @@ #include "rt_entt_codegen/core/system_provider/system_provider.hh" #include "rt_entt_codegen/core/sys_exec/sys_exec.hh" +#include "rt_entt_codegen/core/system_provider/system_ctx_functions.hh" namespace ecsact::rt_entt_codegen::core::provider { class association : public system_provider { @@ -12,134 +13,115 @@ public: using system_provider::system_provider; auto initialization( - ecsact::codegen_plugin_context& ctx, - const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& - options + ecsact::codegen_plugin_context& ctx, + const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& names ) -> void { } auto before_make_view_or_group( - ecsact::codegen_plugin_context& ctx, - const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& - options, + ecsact::codegen_plugin_context& ctx, + const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& names, std::vector& additional_view_components ) -> void { } auto after_make_view_or_group( - ecsact::codegen_plugin_context& ctx, - const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& - options + ecsact::codegen_plugin_context& ctx, + const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& names ) -> void final; auto context_function_header( - ecsact::codegen_plugin_context& ctx, - const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& - options + ecsact::codegen_plugin_context& ctx, + const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& names ) -> void final; auto context_function_action( - ecsact::codegen_plugin_context& ctx, - const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& - options + ecsact::codegen_plugin_context& ctx, + const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& names ) -> handle_exclusive_provide { return NOT_HANDLED; } auto context_function_add( - ecsact::codegen_plugin_context& ctx, - const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& - options + ecsact::codegen_plugin_context& ctx, + const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& names ) -> handle_exclusive_provide { return NOT_HANDLED; } auto context_function_remove( - ecsact::codegen_plugin_context& ctx, - const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& - options + ecsact::codegen_plugin_context& ctx, + const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& names ) -> handle_exclusive_provide { return NOT_HANDLED; } auto context_function_get( - ecsact::codegen_plugin_context& ctx, - const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& - options + ecsact::codegen_plugin_context& ctx, + const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& names ) -> handle_exclusive_provide { return NOT_HANDLED; } auto context_function_update( - ecsact::codegen_plugin_context& ctx, - const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& - options + ecsact::codegen_plugin_context& ctx, + const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& names ) -> handle_exclusive_provide { return NOT_HANDLED; } auto context_function_has( - ecsact::codegen_plugin_context& ctx, - const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& - options + ecsact::codegen_plugin_context& ctx, + const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& names ) -> handle_exclusive_provide { return NOT_HANDLED; } auto context_function_generate( - ecsact::codegen_plugin_context& ctx, - const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& - options + ecsact::codegen_plugin_context& ctx, + const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& names ) -> handle_exclusive_provide { return NOT_HANDLED; } auto context_function_parent( - ecsact::codegen_plugin_context& ctx, - const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& - options + ecsact::codegen_plugin_context& ctx, + const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& names ) -> handle_exclusive_provide { return NOT_HANDLED; } auto context_function_other( - ecsact::codegen_plugin_context& ctx, - const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& - options + ecsact::codegen_plugin_context& ctx, + const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& names ) -> handle_exclusive_provide final; auto pre_entity_iteration( - ecsact::codegen_plugin_context& ctx, - const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& - options + ecsact::codegen_plugin_context& ctx, + const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& names ) -> void final; auto entity_iteration( - ecsact::codegen_plugin_context& ctx, - const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& - options + ecsact::codegen_plugin_context& ctx, + const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& names ) -> void { } auto pre_exec_system_impl( - ecsact::codegen_plugin_context& ctx, - const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& - options + ecsact::codegen_plugin_context& ctx, + const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& names ) -> void final; auto system_impl( - ecsact::codegen_plugin_context& ctx, - const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& - options + ecsact::codegen_plugin_context& ctx, + const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& names ) -> handle_exclusive_provide final; auto post_exec_system_impl( - ecsact::codegen_plugin_context& ctx, - const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& - options + ecsact::codegen_plugin_context& ctx, + const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& names ) -> void {}; auto post_iteration( - ecsact::codegen_plugin_context& ctx, - const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& - options + ecsact::codegen_plugin_context& ctx, + const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& names ) -> void {}; private: @@ -148,19 +130,20 @@ private: std::map components_with_entity_fields; auto print_other_contexts( - ecsact::codegen_plugin_context& ctx, - const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& - options + ecsact::codegen_plugin_context& ctx, + const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& names ) -> void; auto print_other_ctx_action(ecsact::codegen_plugin_context& ctx) -> void; auto print_other_ctx_add( ecsact::codegen_plugin_context& ctx, + const capability_t& other_caps, const ecsact::rt_entt_codegen::ecsact_entt_system_details& details ) -> void; auto print_other_ctx_remove( ecsact::codegen_plugin_context& ctx, + const capability_t& other_caps, const ecsact::rt_entt_codegen::ecsact_entt_system_details& details, const std::string& view_type_name ) -> void; diff --git a/rt_entt_codegen/core/system_provider/basic/basic.cc b/rt_entt_codegen/core/system_provider/basic/basic.cc index af735f0..e1c7092 100644 --- a/rt_entt_codegen/core/system_provider/basic/basic.cc +++ b/rt_entt_codegen/core/system_provider/basic/basic.cc @@ -6,14 +6,14 @@ #include "ecsact/cpp_codegen_plugin_util.hh" #include "rt_entt_codegen/core/system_provider/system_ctx_functions.hh" -using ecsact::rt_entt_codegen::provider::context_action_impl; -using ecsact::rt_entt_codegen::provider::context_add_impl; -using ecsact::rt_entt_codegen::provider::context_generate_impl; -using ecsact::rt_entt_codegen::provider::context_get_impl; -using ecsact::rt_entt_codegen::provider::context_has_impl; -using ecsact::rt_entt_codegen::provider::context_parent_impl; -using ecsact::rt_entt_codegen::provider::context_remove_impl; -using ecsact::rt_entt_codegen::provider::context_update_impl; +using ecsact::rt_entt_codegen::core::provider::context_action_impl; +using ecsact::rt_entt_codegen::core::provider::context_add_impl; +using ecsact::rt_entt_codegen::core::provider::context_generate_impl; +using ecsact::rt_entt_codegen::core::provider::context_get_impl; +using ecsact::rt_entt_codegen::core::provider::context_has_impl; +using ecsact::rt_entt_codegen::core::provider::context_parent_impl; +using ecsact::rt_entt_codegen::core::provider::context_remove_impl; +using ecsact::rt_entt_codegen::core::provider::context_update_impl; auto ecsact::rt_entt_codegen::core::provider::basic::initialization( ecsact::codegen_plugin_context& ctx, @@ -46,8 +46,10 @@ auto ecsact::rt_entt_codegen::core::provider::basic::context_function_add( ecsact::codegen_plugin_context& ctx, const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& names ) -> handle_exclusive_provide { - auto adds_comps = std::vector{}; - context_add_impl(ctx, sys_like_id_variant); + auto sys_caps = + ecsact::meta::system_capabilities(sys_like_id_variant.get_sys_like_id()); + + context_add_impl(ctx, sys_caps); return HANDLED; } @@ -55,7 +57,10 @@ auto ecsact::rt_entt_codegen::core::provider::basic::context_function_remove( ecsact::codegen_plugin_context& ctx, const ecsact::rt_entt_codegen::core::print_execute_systems_var_names& names ) -> handle_exclusive_provide { - context_remove_impl(ctx, sys_like_id_variant, system_details, view_type_name); + auto sys_caps = + ecsact::meta::system_capabilities(sys_like_id_variant.get_sys_like_id()); + + context_remove_impl(ctx, sys_caps, system_details, view_type_name); return HANDLED; } diff --git a/rt_entt_codegen/core/system_provider/system_ctx_functions.cc b/rt_entt_codegen/core/system_provider/system_ctx_functions.cc index 92198e9..f733d75 100644 --- a/rt_entt_codegen/core/system_provider/system_ctx_functions.cc +++ b/rt_entt_codegen/core/system_provider/system_ctx_functions.cc @@ -10,7 +10,7 @@ using ecsact::cpp_codegen_plugin_util::block; using ecsact::meta::decl_full_name; using ecsact::rt_entt_codegen::util::is_transient_component; -auto ecsact::rt_entt_codegen::provider::context_action_impl( +auto ecsact::rt_entt_codegen::core::provider::context_action_impl( ecsact::codegen_plugin_context& ctx, const system_like_id_variant& sys_like_id_variant ) -> void { @@ -31,15 +31,12 @@ auto ecsact::rt_entt_codegen::provider::context_action_impl( } } -auto ecsact::rt_entt_codegen::provider::context_add_impl( +auto ecsact::rt_entt_codegen::core::provider::context_add_impl( ecsact::codegen_plugin_context& ctx, - const system_like_id_variant& sys_like_id_variant + const capability_t& sys_caps ) -> void { auto adds_comps = std::vector{}; - auto sys_caps = - ecsact::meta::system_capabilities(sys_like_id_variant.get_sys_like_id()); - for(auto&& [comp_id, sys_cap] : sys_caps) { if(is_transient_component(ctx.package_id, comp_id)) { continue; @@ -92,17 +89,14 @@ auto ecsact::rt_entt_codegen::provider::context_add_impl( ctx.write("add_fns.at(component_id)(this, component_id, component_data);\n"); } -auto ecsact::rt_entt_codegen::provider::context_remove_impl( - ecsact::codegen_plugin_context& ctx, - const system_like_id_variant& sys_like_id_variant, +auto ecsact::rt_entt_codegen::core::provider::context_remove_impl( + ecsact::codegen_plugin_context& ctx, + const capability_t& sys_caps, const ecsact::rt_entt_codegen::ecsact_entt_system_details& details, const std::string& view_type_name ) -> void { auto remove_comps = std::vector{}; - auto sys_caps = - ecsact::meta::system_capabilities(sys_like_id_variant.get_sys_like_id()); - for(auto&& [comp_id, sys_cap] : sys_caps) { if(is_transient_component(ctx.package_id, comp_id)) { continue; @@ -158,7 +152,7 @@ auto ecsact::rt_entt_codegen::provider::context_remove_impl( ctx.write("();\n"); } -auto ecsact::rt_entt_codegen::provider::context_get_impl( +auto ecsact::rt_entt_codegen::core::provider::context_get_impl( ecsact::codegen_plugin_context& ctx, const system_like_id_variant& sys_like_id_variant, const ecsact::rt_entt_codegen::ecsact_entt_system_details& details, @@ -234,7 +228,7 @@ auto ecsact::rt_entt_codegen::provider::context_get_impl( ); } -auto ecsact::rt_entt_codegen::provider::context_update_impl( +auto ecsact::rt_entt_codegen::core::provider::context_update_impl( ecsact::codegen_plugin_context& ctx, const system_like_id_variant& sys_like_id_variant, const ecsact::rt_entt_codegen::ecsact_entt_system_details& details, @@ -292,7 +286,7 @@ auto ecsact::rt_entt_codegen::provider::context_update_impl( ); } -auto ecsact::rt_entt_codegen::provider::context_has_impl( +auto ecsact::rt_entt_codegen::core::provider::context_has_impl( ecsact::codegen_plugin_context& ctx, const system_like_id_variant& sys_like_id_variant, const ecsact::rt_entt_codegen::ecsact_entt_system_details& details @@ -336,7 +330,7 @@ auto ecsact::rt_entt_codegen::provider::context_has_impl( ctx.write("return has_fns.at(component_id)(this, component_id);\n"); } -auto ecsact::rt_entt_codegen::provider::context_generate_impl( +auto ecsact::rt_entt_codegen::core::provider::context_generate_impl( ecsact::codegen_plugin_context& ctx, const system_like_id_variant& sys_like_id_variant, const ecsact::rt_entt_codegen::ecsact_entt_system_details& details @@ -389,14 +383,14 @@ auto ecsact::rt_entt_codegen::provider::context_generate_impl( }); } -auto ecsact::rt_entt_codegen::provider::context_parent_impl( +auto ecsact::rt_entt_codegen::core::provider::context_parent_impl( ecsact::codegen_plugin_context& ctx, const system_like_id_variant& sys_like_id_variant ) -> void { ctx.write("return this->parent_ctx;\n"); } -auto ecsact::rt_entt_codegen::provider::context_other_impl( +auto ecsact::rt_entt_codegen::core::provider::context_other_impl( ecsact::codegen_plugin_context& ctx, const system_like_id_variant& sys_like_id_variant, const ecsact::rt_entt_codegen::ecsact_entt_system_details& details diff --git a/rt_entt_codegen/core/system_provider/system_ctx_functions.hh b/rt_entt_codegen/core/system_provider/system_ctx_functions.hh index a8d833d..3d3638b 100644 --- a/rt_entt_codegen/core/system_provider/system_ctx_functions.hh +++ b/rt_entt_codegen/core/system_provider/system_ctx_functions.hh @@ -4,18 +4,21 @@ #include "rt_entt_codegen/shared/ecsact_entt_details.hh" #include "rt_entt_codegen/shared/system_variant.hh" -namespace ecsact::rt_entt_codegen::provider { +namespace ecsact::rt_entt_codegen::core::provider { +using capability_t = + std::unordered_map; + auto context_action_impl( ecsact::codegen_plugin_context& ctx, const system_like_id_variant& sys_like_id_variant ) -> void; auto context_add_impl( ecsact::codegen_plugin_context& ctx, - const system_like_id_variant& sys_like_id_variant + const capability_t& sys_caps ) -> void; auto context_remove_impl( - ecsact::codegen_plugin_context& ctx, - const system_like_id_variant& sys_like_id_variant, + ecsact::codegen_plugin_context& ctx, + const capability_t& sys_caps, const ecsact::rt_entt_codegen::ecsact_entt_system_details& details, const std::string& view_type_name ) -> void; @@ -50,4 +53,4 @@ auto context_other_impl( const system_like_id_variant& sys_like_id_variant, const ecsact::rt_entt_codegen::ecsact_entt_system_details& details ) -> void; -} // namespace ecsact::rt_entt_codegen::provider +} // namespace ecsact::rt_entt_codegen::core::provider