diff --git a/develop/singles/headers/meta.hpp/meta_all.hpp b/develop/singles/headers/meta.hpp/meta_all.hpp index 9ccd8e4..9f54fc0 100644 --- a/develop/singles/headers/meta.hpp/meta_all.hpp +++ b/develop/singles/headers/meta.hpp/meta_all.hpp @@ -2616,11 +2616,11 @@ namespace meta_hpp [[nodiscard]] bool is_virtual_derived_from() const noexcept; [[nodiscard]] bool is_virtual_derived_from(const class_type& base) const noexcept; - [[nodiscard]] function get_function(std::string_view name) const noexcept; - [[nodiscard]] member get_member(std::string_view name) const noexcept; - [[nodiscard]] method get_method(std::string_view name) const noexcept; - [[nodiscard]] any_type get_typedef(std::string_view name) const noexcept; - [[nodiscard]] variable get_variable(std::string_view name) const noexcept; + [[nodiscard]] function get_function(std::string_view name, bool recursively = true) const noexcept; + [[nodiscard]] member get_member(std::string_view name, bool recursively = true) const noexcept; + [[nodiscard]] method get_method(std::string_view name, bool recursively = true) const noexcept; + [[nodiscard]] any_type get_typedef(std::string_view name, bool recursively = true) const noexcept; + [[nodiscard]] variable get_variable(std::string_view name, bool recursively = true) const noexcept; template < typename... Args > [[nodiscard]] constructor get_constructor_with() const noexcept; @@ -2632,18 +2632,56 @@ namespace meta_hpp [[nodiscard]] destructor get_destructor() const noexcept; template < typename... Args > - [[nodiscard]] function get_function_with(std::string_view name) const noexcept; + [[nodiscard]] function get_function_with( // + std::string_view name, + bool recursively = true + ) const noexcept; + template < typename Iter > - [[nodiscard]] function get_function_with(std::string_view name, Iter first, Iter last) const noexcept; - [[nodiscard]] function get_function_with(std::string_view name, std::span args) const noexcept; - [[nodiscard]] function get_function_with(std::string_view name, std::initializer_list args) const noexcept; + [[nodiscard]] function get_function_with( // + std::string_view name, + Iter first, + Iter last, + bool recursively = true + ) const noexcept; + + [[nodiscard]] function get_function_with( // + std::string_view name, + std::span args, + bool recursively = true + ) const noexcept; + + [[nodiscard]] function get_function_with( // + std::string_view name, + std::initializer_list args, + bool recursively = true + ) const noexcept; template < typename... Args > - [[nodiscard]] method get_method_with(std::string_view name) const noexcept; + [[nodiscard]] method get_method_with( // + std::string_view name, + bool recursively = true + ) const noexcept; + template < typename Iter > - [[nodiscard]] method get_method_with(std::string_view name, Iter first, Iter last) const noexcept; - [[nodiscard]] method get_method_with(std::string_view name, std::span args) const noexcept; - [[nodiscard]] method get_method_with(std::string_view name, std::initializer_list args) const noexcept; + [[nodiscard]] method get_method_with( // + std::string_view name, + Iter first, + Iter last, + bool recursively = true + ) const noexcept; + + [[nodiscard]] method get_method_with( // + std::string_view name, + std::span args, + bool recursively = true + ) const noexcept; + + [[nodiscard]] method get_method_with( // + std::string_view name, + std::initializer_list args, + bool recursively = true + ) const noexcept; }; class constructor_type final : public type_base { @@ -3828,11 +3866,26 @@ namespace meta_hpp [[nodiscard]] variable get_variable(std::string_view name) const noexcept; template < typename... Args > - [[nodiscard]] function get_function_with(std::string_view name) const noexcept; + [[nodiscard]] function get_function_with( // + std::string_view name + ) const noexcept; + template < typename Iter > - [[nodiscard]] function get_function_with(std::string_view name, Iter first, Iter last) const noexcept; - [[nodiscard]] function get_function_with(std::string_view name, std::span args) const noexcept; - [[nodiscard]] function get_function_with(std::string_view name, std::initializer_list args) const noexcept; + [[nodiscard]] function get_function_with( // + std::string_view name, + Iter first, + Iter last + ) const noexcept; + + [[nodiscard]] function get_function_with( // + std::string_view name, + std::span args + ) const noexcept; + + [[nodiscard]] function get_function_with( // + std::string_view name, + std::initializer_list args + ) const noexcept; }; class variable final : public state_base { @@ -8418,78 +8471,88 @@ namespace meta_hpp return base.is_virtual_base_of(*this); } - inline function class_type::get_function(std::string_view name) const noexcept { + inline function class_type::get_function(std::string_view name, bool recursively) const noexcept { for ( const function& function : data_->functions ) { if ( function.get_name() == name ) { return function; } } - for ( const class_type& base : data_->base_classes ) { - if ( const function& function = base.get_function(name) ) { - return function; + if ( recursively ) { + for ( const class_type& base : data_->base_classes ) { + if ( const function& function = base.get_function(name, recursively) ) { + return function; + } } } return function{}; } - inline member class_type::get_member(std::string_view name) const noexcept { + inline member class_type::get_member(std::string_view name, bool recursively) const noexcept { for ( const member& member : data_->members ) { if ( member.get_name() == name ) { return member; } } - for ( const class_type& base : data_->base_classes ) { - if ( const member& member = base.get_member(name) ) { - return member; + if ( recursively ) { + for ( const class_type& base : data_->base_classes ) { + if ( const member& member = base.get_member(name, recursively) ) { + return member; + } } } return member{}; } - inline method class_type::get_method(std::string_view name) const noexcept { + inline method class_type::get_method(std::string_view name, bool recursively) const noexcept { for ( const method& method : data_->methods ) { if ( method.get_name() == name ) { return method; } } - for ( const class_type& base : data_->base_classes ) { - if ( const method& method = base.get_method(name) ) { - return method; + if ( recursively ) { + for ( const class_type& base : data_->base_classes ) { + if ( const method& method = base.get_method(name, recursively) ) { + return method; + } } } return method{}; } - inline any_type class_type::get_typedef(std::string_view name) const noexcept { + inline any_type class_type::get_typedef(std::string_view name, bool recursively) const noexcept { if ( auto iter{data_->typedefs.find(name)}; iter != data_->typedefs.end() ) { return iter->second; } - for ( const class_type& base : data_->base_classes ) { - if ( const any_type& type = base.get_typedef(name) ) { - return type; + if ( recursively ) { + for ( const class_type& base : data_->base_classes ) { + if ( const any_type& type = base.get_typedef(name, recursively) ) { + return type; + } } } return any_type{}; } - inline variable class_type::get_variable(std::string_view name) const noexcept { + inline variable class_type::get_variable(std::string_view name, bool recursively) const noexcept { for ( const variable& variable : data_->variables ) { if ( variable.get_name() == name ) { return variable; } } - for ( const class_type& base : data_->base_classes ) { - if ( const variable& variable = base.get_variable(name) ) { - return variable; + if ( recursively ) { + for ( const class_type& base : data_->base_classes ) { + if ( const variable& variable = base.get_variable(name, recursively) ) { + return variable; + } } } @@ -8541,13 +8604,21 @@ namespace meta_hpp // template < typename... Args > - function class_type::get_function_with(std::string_view name) const noexcept { + function class_type::get_function_with( // + std::string_view name, + bool recursively + ) const noexcept { detail::type_registry& registry{detail::type_registry::instance()}; - return get_function_with(name, {registry.resolve_type()...}); + return get_function_with(name, {registry.resolve_type()...}, recursively); } template < typename Iter > - function class_type::get_function_with(std::string_view name, Iter first, Iter last) const noexcept { + function class_type::get_function_with( // + std::string_view name, + Iter first, + Iter last, + bool recursively + ) const noexcept { for ( const function& function : data_->functions ) { if ( function.get_name() != name ) { continue; @@ -8559,21 +8630,31 @@ namespace meta_hpp } } - for ( const class_type& base : data_->base_classes ) { - if ( const function& function = base.get_function_with(name, first, last) ) { - return function; + if ( recursively ) { + for ( const class_type& base : data_->base_classes ) { + if ( const function& function = base.get_function_with(name, first, last, recursively) ) { + return function; + } } } return function{}; } - inline function class_type::get_function_with(std::string_view name, std::span args) const noexcept { - return get_function_with(name, args.begin(), args.end()); + inline function class_type::get_function_with( // + std::string_view name, + std::span args, + bool recursively + ) const noexcept { + return get_function_with(name, args.begin(), args.end(), recursively); } - inline function class_type::get_function_with(std::string_view name, std::initializer_list args) const noexcept { - return get_function_with(name, args.begin(), args.end()); + inline function class_type::get_function_with( // + std::string_view name, + std::initializer_list args, + bool recursively + ) const noexcept { + return get_function_with(name, args.begin(), args.end(), recursively); } // @@ -8581,13 +8662,21 @@ namespace meta_hpp // template < typename... Args > - method class_type::get_method_with(std::string_view name) const noexcept { + method class_type::get_method_with( // + std::string_view name, + bool recursively + ) const noexcept { detail::type_registry& registry{detail::type_registry::instance()}; - return get_method_with(name, {registry.resolve_type()...}); + return get_method_with(name, {registry.resolve_type()...}, recursively); } template < typename Iter > - method class_type::get_method_with(std::string_view name, Iter first, Iter last) const noexcept { + method class_type::get_method_with( // + std::string_view name, + Iter first, + Iter last, + bool recursively + ) const noexcept { for ( const method& method : data_->methods ) { if ( method.get_name() != name ) { continue; @@ -8599,21 +8688,31 @@ namespace meta_hpp } } - for ( const class_type& base : data_->base_classes ) { - if ( const method& method = base.get_method_with(name, first, last) ) { - return method; + if ( recursively ) { + for ( const class_type& base : data_->base_classes ) { + if ( const method& method = base.get_method_with(name, first, last, recursively) ) { + return method; + } } } return method{}; } - inline method class_type::get_method_with(std::string_view name, std::span args) const noexcept { - return get_method_with(name, args.begin(), args.end()); + inline method class_type::get_method_with( // + std::string_view name, + std::span args, + bool recursively + ) const noexcept { + return get_method_with(name, args.begin(), args.end(), recursively); } - inline method class_type::get_method_with(std::string_view name, std::initializer_list args) const noexcept { - return get_method_with(name, args.begin(), args.end()); + inline method class_type::get_method_with( // + std::string_view name, + std::initializer_list args, + bool recursively + ) const noexcept { + return get_method_with(name, args.begin(), args.end(), recursively); } } @@ -8673,13 +8772,19 @@ namespace meta_hpp } template < typename... Args > - function scope::get_function_with(std::string_view name) const noexcept { + function scope::get_function_with( // + std::string_view name + ) const noexcept { detail::type_registry& registry{detail::type_registry::instance()}; return get_function_with(name, {registry.resolve_type()...}); } template < typename Iter > - function scope::get_function_with(std::string_view name, Iter first, Iter last) const noexcept { + function scope::get_function_with( // + std::string_view name, + Iter first, + Iter last + ) const noexcept { for ( const function& function : state_->functions ) { if ( function.get_name() != name ) { continue; @@ -8693,11 +8798,17 @@ namespace meta_hpp return function{}; } - inline function scope::get_function_with(std::string_view name, std::span args) const noexcept { + inline function scope::get_function_with( // + std::string_view name, + std::span args + ) const noexcept { return get_function_with(name, args.begin(), args.end()); } - inline function scope::get_function_with(std::string_view name, std::initializer_list args) const noexcept { + inline function scope::get_function_with( // + std::string_view name, + std::initializer_list args + ) const noexcept { return get_function_with(name, args.begin(), args.end()); } } diff --git a/develop/untests/meta_types/class_type_tests.cpp b/develop/untests/meta_types/class_type_tests.cpp index e31eb6a..577a3bd 100644 --- a/develop/untests/meta_types/class_type_tests.cpp +++ b/develop/untests/meta_types/class_type_tests.cpp @@ -386,8 +386,10 @@ TEST_CASE("meta/meta_types/class_type") { CHECK(base_clazz_2_type.get_function("base_function_2")); CHECK_FALSE(base_clazz_2_type.get_function("derived_function")); - CHECK(derived_clazz_type.get_function("base_function_1")); - CHECK(derived_clazz_type.get_function("base_function_2")); + CHECK(derived_clazz_type.get_function("base_function_1", true)); + CHECK(derived_clazz_type.get_function("base_function_2", true)); + CHECK_FALSE(derived_clazz_type.get_function("base_function_1", false)); + CHECK_FALSE(derived_clazz_type.get_function("base_function_2", false)); CHECK(derived_clazz_type.get_function("derived_function")); } @@ -400,8 +402,10 @@ TEST_CASE("meta/meta_types/class_type") { CHECK(base_clazz_2_type.get_member("base_member_2")); CHECK_FALSE(base_clazz_2_type.get_member("derived_member")); - CHECK(derived_clazz_type.get_member("base_member_1")); - CHECK(derived_clazz_type.get_member("base_member_2")); + CHECK(derived_clazz_type.get_member("base_member_1", true)); + CHECK(derived_clazz_type.get_member("base_member_2", true)); + CHECK_FALSE(derived_clazz_type.get_member("base_member_1", false)); + CHECK_FALSE(derived_clazz_type.get_member("base_member_2", false)); CHECK(derived_clazz_type.get_member("derived_member")); } @@ -414,8 +418,10 @@ TEST_CASE("meta/meta_types/class_type") { CHECK(base_clazz_2_type.get_method("base_method_2")); CHECK_FALSE(base_clazz_2_type.get_method("derived_method")); - CHECK(derived_clazz_type.get_method("base_method_1")); - CHECK(derived_clazz_type.get_method("base_method_2")); + CHECK(derived_clazz_type.get_method("base_method_1", true)); + CHECK(derived_clazz_type.get_method("base_method_2", true)); + CHECK_FALSE(derived_clazz_type.get_method("base_method_1", false)); + CHECK_FALSE(derived_clazz_type.get_method("base_method_2", false)); CHECK(derived_clazz_type.get_method("derived_method")); } @@ -428,8 +434,10 @@ TEST_CASE("meta/meta_types/class_type") { CHECK(base_clazz_2_type.get_variable("base_variable_2")); CHECK_FALSE(base_clazz_2_type.get_variable("derived_variable")); - CHECK(derived_clazz_type.get_variable("base_variable_1")); - CHECK(derived_clazz_type.get_variable("base_variable_2")); + CHECK(derived_clazz_type.get_variable("base_variable_1", true)); + CHECK(derived_clazz_type.get_variable("base_variable_2", true)); + CHECK_FALSE(derived_clazz_type.get_variable("base_variable_1", false)); + CHECK_FALSE(derived_clazz_type.get_variable("base_variable_2", false)); CHECK(derived_clazz_type.get_variable("derived_variable")); } diff --git a/headers/meta.hpp/meta_states.hpp b/headers/meta.hpp/meta_states.hpp index a834ffb..6c77243 100644 --- a/headers/meta.hpp/meta_states.hpp +++ b/headers/meta.hpp/meta_states.hpp @@ -335,11 +335,26 @@ namespace meta_hpp [[nodiscard]] variable get_variable(std::string_view name) const noexcept; template < typename... Args > - [[nodiscard]] function get_function_with(std::string_view name) const noexcept; + [[nodiscard]] function get_function_with( // + std::string_view name + ) const noexcept; + template < typename Iter > - [[nodiscard]] function get_function_with(std::string_view name, Iter first, Iter last) const noexcept; - [[nodiscard]] function get_function_with(std::string_view name, std::span args) const noexcept; - [[nodiscard]] function get_function_with(std::string_view name, std::initializer_list args) const noexcept; + [[nodiscard]] function get_function_with( // + std::string_view name, + Iter first, + Iter last + ) const noexcept; + + [[nodiscard]] function get_function_with( // + std::string_view name, + std::span args + ) const noexcept; + + [[nodiscard]] function get_function_with( // + std::string_view name, + std::initializer_list args + ) const noexcept; }; class variable final : public state_base { diff --git a/headers/meta.hpp/meta_states/scope.hpp b/headers/meta.hpp/meta_states/scope.hpp index 90df6d1..a1d4403 100644 --- a/headers/meta.hpp/meta_states/scope.hpp +++ b/headers/meta.hpp/meta_states/scope.hpp @@ -72,13 +72,19 @@ namespace meta_hpp } template < typename... Args > - function scope::get_function_with(std::string_view name) const noexcept { + function scope::get_function_with( // + std::string_view name + ) const noexcept { detail::type_registry& registry{detail::type_registry::instance()}; return get_function_with(name, {registry.resolve_type()...}); } template < typename Iter > - function scope::get_function_with(std::string_view name, Iter first, Iter last) const noexcept { + function scope::get_function_with( // + std::string_view name, + Iter first, + Iter last + ) const noexcept { for ( const function& function : state_->functions ) { if ( function.get_name() != name ) { continue; @@ -92,11 +98,17 @@ namespace meta_hpp return function{}; } - inline function scope::get_function_with(std::string_view name, std::span args) const noexcept { + inline function scope::get_function_with( // + std::string_view name, + std::span args + ) const noexcept { return get_function_with(name, args.begin(), args.end()); } - inline function scope::get_function_with(std::string_view name, std::initializer_list args) const noexcept { + inline function scope::get_function_with( // + std::string_view name, + std::initializer_list args + ) const noexcept { return get_function_with(name, args.begin(), args.end()); } } diff --git a/headers/meta.hpp/meta_types.hpp b/headers/meta.hpp/meta_types.hpp index 6a55006..fc289be 100644 --- a/headers/meta.hpp/meta_types.hpp +++ b/headers/meta.hpp/meta_types.hpp @@ -200,11 +200,11 @@ namespace meta_hpp [[nodiscard]] bool is_virtual_derived_from() const noexcept; [[nodiscard]] bool is_virtual_derived_from(const class_type& base) const noexcept; - [[nodiscard]] function get_function(std::string_view name) const noexcept; - [[nodiscard]] member get_member(std::string_view name) const noexcept; - [[nodiscard]] method get_method(std::string_view name) const noexcept; - [[nodiscard]] any_type get_typedef(std::string_view name) const noexcept; - [[nodiscard]] variable get_variable(std::string_view name) const noexcept; + [[nodiscard]] function get_function(std::string_view name, bool recursively = true) const noexcept; + [[nodiscard]] member get_member(std::string_view name, bool recursively = true) const noexcept; + [[nodiscard]] method get_method(std::string_view name, bool recursively = true) const noexcept; + [[nodiscard]] any_type get_typedef(std::string_view name, bool recursively = true) const noexcept; + [[nodiscard]] variable get_variable(std::string_view name, bool recursively = true) const noexcept; template < typename... Args > [[nodiscard]] constructor get_constructor_with() const noexcept; @@ -216,18 +216,56 @@ namespace meta_hpp [[nodiscard]] destructor get_destructor() const noexcept; template < typename... Args > - [[nodiscard]] function get_function_with(std::string_view name) const noexcept; + [[nodiscard]] function get_function_with( // + std::string_view name, + bool recursively = true + ) const noexcept; + template < typename Iter > - [[nodiscard]] function get_function_with(std::string_view name, Iter first, Iter last) const noexcept; - [[nodiscard]] function get_function_with(std::string_view name, std::span args) const noexcept; - [[nodiscard]] function get_function_with(std::string_view name, std::initializer_list args) const noexcept; + [[nodiscard]] function get_function_with( // + std::string_view name, + Iter first, + Iter last, + bool recursively = true + ) const noexcept; + + [[nodiscard]] function get_function_with( // + std::string_view name, + std::span args, + bool recursively = true + ) const noexcept; + + [[nodiscard]] function get_function_with( // + std::string_view name, + std::initializer_list args, + bool recursively = true + ) const noexcept; template < typename... Args > - [[nodiscard]] method get_method_with(std::string_view name) const noexcept; + [[nodiscard]] method get_method_with( // + std::string_view name, + bool recursively = true + ) const noexcept; + template < typename Iter > - [[nodiscard]] method get_method_with(std::string_view name, Iter first, Iter last) const noexcept; - [[nodiscard]] method get_method_with(std::string_view name, std::span args) const noexcept; - [[nodiscard]] method get_method_with(std::string_view name, std::initializer_list args) const noexcept; + [[nodiscard]] method get_method_with( // + std::string_view name, + Iter first, + Iter last, + bool recursively = true + ) const noexcept; + + [[nodiscard]] method get_method_with( // + std::string_view name, + std::span args, + bool recursively = true + ) const noexcept; + + [[nodiscard]] method get_method_with( // + std::string_view name, + std::initializer_list args, + bool recursively = true + ) const noexcept; }; class constructor_type final : public type_base { diff --git a/headers/meta.hpp/meta_types/class_type.hpp b/headers/meta.hpp/meta_types/class_type.hpp index 4842ed4..93c1cf2 100644 --- a/headers/meta.hpp/meta_types/class_type.hpp +++ b/headers/meta.hpp/meta_types/class_type.hpp @@ -261,78 +261,88 @@ namespace meta_hpp return base.is_virtual_base_of(*this); } - inline function class_type::get_function(std::string_view name) const noexcept { + inline function class_type::get_function(std::string_view name, bool recursively) const noexcept { for ( const function& function : data_->functions ) { if ( function.get_name() == name ) { return function; } } - for ( const class_type& base : data_->base_classes ) { - if ( const function& function = base.get_function(name) ) { - return function; + if ( recursively ) { + for ( const class_type& base : data_->base_classes ) { + if ( const function& function = base.get_function(name, recursively) ) { + return function; + } } } return function{}; } - inline member class_type::get_member(std::string_view name) const noexcept { + inline member class_type::get_member(std::string_view name, bool recursively) const noexcept { for ( const member& member : data_->members ) { if ( member.get_name() == name ) { return member; } } - for ( const class_type& base : data_->base_classes ) { - if ( const member& member = base.get_member(name) ) { - return member; + if ( recursively ) { + for ( const class_type& base : data_->base_classes ) { + if ( const member& member = base.get_member(name, recursively) ) { + return member; + } } } return member{}; } - inline method class_type::get_method(std::string_view name) const noexcept { + inline method class_type::get_method(std::string_view name, bool recursively) const noexcept { for ( const method& method : data_->methods ) { if ( method.get_name() == name ) { return method; } } - for ( const class_type& base : data_->base_classes ) { - if ( const method& method = base.get_method(name) ) { - return method; + if ( recursively ) { + for ( const class_type& base : data_->base_classes ) { + if ( const method& method = base.get_method(name, recursively) ) { + return method; + } } } return method{}; } - inline any_type class_type::get_typedef(std::string_view name) const noexcept { + inline any_type class_type::get_typedef(std::string_view name, bool recursively) const noexcept { if ( auto iter{data_->typedefs.find(name)}; iter != data_->typedefs.end() ) { return iter->second; } - for ( const class_type& base : data_->base_classes ) { - if ( const any_type& type = base.get_typedef(name) ) { - return type; + if ( recursively ) { + for ( const class_type& base : data_->base_classes ) { + if ( const any_type& type = base.get_typedef(name, recursively) ) { + return type; + } } } return any_type{}; } - inline variable class_type::get_variable(std::string_view name) const noexcept { + inline variable class_type::get_variable(std::string_view name, bool recursively) const noexcept { for ( const variable& variable : data_->variables ) { if ( variable.get_name() == name ) { return variable; } } - for ( const class_type& base : data_->base_classes ) { - if ( const variable& variable = base.get_variable(name) ) { - return variable; + if ( recursively ) { + for ( const class_type& base : data_->base_classes ) { + if ( const variable& variable = base.get_variable(name, recursively) ) { + return variable; + } } } @@ -384,13 +394,21 @@ namespace meta_hpp // template < typename... Args > - function class_type::get_function_with(std::string_view name) const noexcept { + function class_type::get_function_with( // + std::string_view name, + bool recursively + ) const noexcept { detail::type_registry& registry{detail::type_registry::instance()}; - return get_function_with(name, {registry.resolve_type()...}); + return get_function_with(name, {registry.resolve_type()...}, recursively); } template < typename Iter > - function class_type::get_function_with(std::string_view name, Iter first, Iter last) const noexcept { + function class_type::get_function_with( // + std::string_view name, + Iter first, + Iter last, + bool recursively + ) const noexcept { for ( const function& function : data_->functions ) { if ( function.get_name() != name ) { continue; @@ -402,21 +420,31 @@ namespace meta_hpp } } - for ( const class_type& base : data_->base_classes ) { - if ( const function& function = base.get_function_with(name, first, last) ) { - return function; + if ( recursively ) { + for ( const class_type& base : data_->base_classes ) { + if ( const function& function = base.get_function_with(name, first, last, recursively) ) { + return function; + } } } return function{}; } - inline function class_type::get_function_with(std::string_view name, std::span args) const noexcept { - return get_function_with(name, args.begin(), args.end()); + inline function class_type::get_function_with( // + std::string_view name, + std::span args, + bool recursively + ) const noexcept { + return get_function_with(name, args.begin(), args.end(), recursively); } - inline function class_type::get_function_with(std::string_view name, std::initializer_list args) const noexcept { - return get_function_with(name, args.begin(), args.end()); + inline function class_type::get_function_with( // + std::string_view name, + std::initializer_list args, + bool recursively + ) const noexcept { + return get_function_with(name, args.begin(), args.end(), recursively); } // @@ -424,13 +452,21 @@ namespace meta_hpp // template < typename... Args > - method class_type::get_method_with(std::string_view name) const noexcept { + method class_type::get_method_with( // + std::string_view name, + bool recursively + ) const noexcept { detail::type_registry& registry{detail::type_registry::instance()}; - return get_method_with(name, {registry.resolve_type()...}); + return get_method_with(name, {registry.resolve_type()...}, recursively); } template < typename Iter > - method class_type::get_method_with(std::string_view name, Iter first, Iter last) const noexcept { + method class_type::get_method_with( // + std::string_view name, + Iter first, + Iter last, + bool recursively + ) const noexcept { for ( const method& method : data_->methods ) { if ( method.get_name() != name ) { continue; @@ -442,20 +478,30 @@ namespace meta_hpp } } - for ( const class_type& base : data_->base_classes ) { - if ( const method& method = base.get_method_with(name, first, last) ) { - return method; + if ( recursively ) { + for ( const class_type& base : data_->base_classes ) { + if ( const method& method = base.get_method_with(name, first, last, recursively) ) { + return method; + } } } return method{}; } - inline method class_type::get_method_with(std::string_view name, std::span args) const noexcept { - return get_method_with(name, args.begin(), args.end()); + inline method class_type::get_method_with( // + std::string_view name, + std::span args, + bool recursively + ) const noexcept { + return get_method_with(name, args.begin(), args.end(), recursively); } - inline method class_type::get_method_with(std::string_view name, std::initializer_list args) const noexcept { - return get_method_with(name, args.begin(), args.end()); + inline method class_type::get_method_with( // + std::string_view name, + std::initializer_list args, + bool recursively + ) const noexcept { + return get_method_with(name, args.begin(), args.end(), recursively); } }