diff --git a/headers/meta.hpp/meta_all.hpp b/headers/meta.hpp/meta_all.hpp index 45fe3a7..8936e65 100644 --- a/headers/meta.hpp/meta_all.hpp +++ b/headers/meta.hpp/meta_all.hpp @@ -14,24 +14,24 @@ #include "meta_binds/scope_bind.hpp" #include "meta_indices.hpp" -#include "meta_indices/ctor_index.hpp" -#include "meta_indices/dtor_index.hpp" +#include "meta_indices/argument_index.hpp" +#include "meta_indices/constructor_index.hpp" +#include "meta_indices/destructor_index.hpp" #include "meta_indices/evalue_index.hpp" #include "meta_indices/function_index.hpp" #include "meta_indices/member_index.hpp" #include "meta_indices/method_index.hpp" -#include "meta_indices/parameter_index.hpp" #include "meta_indices/scope_index.hpp" #include "meta_indices/variable_index.hpp" #include "meta_states.hpp" -#include "meta_states/ctor.hpp" -#include "meta_states/dtor.hpp" +#include "meta_states/argument.hpp" +#include "meta_states/constructor.hpp" +#include "meta_states/destructor.hpp" #include "meta_states/evalue.hpp" #include "meta_states/function.hpp" #include "meta_states/member.hpp" #include "meta_states/method.hpp" -#include "meta_states/parameter.hpp" #include "meta_states/scope.hpp" #include "meta_states/variable.hpp" @@ -39,8 +39,8 @@ #include "meta_types/any_type.hpp" #include "meta_types/array_type.hpp" #include "meta_types/class_type.hpp" -#include "meta_types/ctor_type.hpp" -#include "meta_types/dtor_type.hpp" +#include "meta_types/constructor_type.hpp" +#include "meta_types/destructor_type.hpp" #include "meta_types/enum_type.hpp" #include "meta_types/function_type.hpp" #include "meta_types/member_type.hpp" diff --git a/headers/meta.hpp/meta_base.hpp b/headers/meta.hpp/meta_base.hpp index 4921cd8..6819a7b 100644 --- a/headers/meta.hpp/meta_base.hpp +++ b/headers/meta.hpp/meta_base.hpp @@ -103,35 +103,35 @@ namespace meta_hpp namespace meta_hpp { - class ctor; - class dtor; + class argument; + class constructor; + class destructor; class evalue; class function; class member; class method; - class parameter; class scope; class variable; namespace detail { - struct ctor_state; - struct dtor_state; + struct argument_state; + struct constructor_state; + struct destructor_state; struct evalue_state; struct function_state; struct member_state; struct method_state; - struct parameter_state; struct scope_state; struct variable_state; - using ctor_state_ptr = std::shared_ptr; - using dtor_state_ptr = std::shared_ptr; + using argument_state_ptr = std::shared_ptr; + using constructor_state_ptr = std::shared_ptr; + using destructor_state_ptr = std::shared_ptr; using evalue_state_ptr = std::shared_ptr; using function_state_ptr = std::shared_ptr; using member_state_ptr = std::shared_ptr; using method_state_ptr = std::shared_ptr; - using parameter_state_ptr = std::shared_ptr; using scope_state_ptr = std::shared_ptr; using variable_state_ptr = std::shared_ptr; } @@ -142,8 +142,8 @@ namespace meta_hpp class any_type; class array_type; class class_type; - class ctor_type; - class dtor_type; + class constructor_type; + class destructor_type; class enum_type; class function_type; class member_type; @@ -159,8 +159,8 @@ namespace meta_hpp struct type_data_base; struct array_type_data; struct class_type_data; - struct ctor_type_data; - struct dtor_type_data; + struct constructor_type_data; + struct destructor_type_data; struct enum_type_data; struct function_type_data; struct member_type_data; @@ -174,8 +174,8 @@ namespace meta_hpp using type_data_base_ptr = std::shared_ptr; using array_type_data_ptr = std::shared_ptr; using class_type_data_ptr = std::shared_ptr; - using ctor_type_data_ptr = std::shared_ptr; - using dtor_type_data_ptr = std::shared_ptr; + using constructor_type_data_ptr = std::shared_ptr; + using destructor_type_data_ptr = std::shared_ptr; using enum_type_data_ptr = std::shared_ptr; using function_type_data_ptr = std::shared_ptr; using member_type_data_ptr = std::shared_ptr; @@ -190,33 +190,33 @@ namespace meta_hpp namespace meta_hpp { - class ctor_index; - class dtor_index; + class argument_index; + class constructor_index; + class destructor_index; class evalue_index; class function_index; class member_index; class method_index; - class parameter_index; class scope_index; class variable_index; } namespace meta_hpp { + using argument_list = std::vector; + using class_set = std::set>; using class_map = std::map>; using enum_set = std::set>; using enum_map = std::map>; - using ctor_map = std::map>; - using dtor_map = std::map>; + using constructor_map = std::map>; + using destructor_map = std::map>; using evalue_map = std::map>; using function_map = std::map>; using member_map = std::map>; using method_map = std::map>; using scope_map = std::map>; using variable_map = std::map>; - - using parameter_list = std::vector; } diff --git a/headers/meta.hpp/meta_base/type_kinds.hpp b/headers/meta.hpp/meta_base/type_kinds.hpp index dd39caf..c0ea70e 100644 --- a/headers/meta.hpp/meta_base/type_kinds.hpp +++ b/headers/meta.hpp/meta_base/type_kinds.hpp @@ -50,8 +50,8 @@ namespace meta_hpp::detail enum class type_kind : std::uint32_t { array_, class_, - ctor_, - dtor_, + constructor_, + destructor_, enum_, function_, member_, diff --git a/headers/meta.hpp/meta_binds.hpp b/headers/meta.hpp/meta_binds.hpp index 272e08b..2ec5a53 100644 --- a/headers/meta.hpp/meta_binds.hpp +++ b/headers/meta.hpp/meta_binds.hpp @@ -14,12 +14,12 @@ namespace meta_hpp namespace detail { template < typename Class, typename... Args > - concept class_bind_ctor_kind = + concept class_bind_constructor_kind = class_kind && requires(Args&&... args) { { Class{std::forward(args)...} }; }; template < typename Class > - concept class_bind_dtor_kind = + concept class_bind_destructor_kind = class_kind && requires(Class&& inst) { { inst.~Class() }; }; @@ -46,19 +46,19 @@ namespace meta_hpp operator class_type() const noexcept; template < typename... Args - , ctor_policy_kind Policy = ctor_policy::as_object > - class_bind& ctor_(Policy = Policy{}) - requires detail::class_bind_ctor_kind; + , constructor_policy_kind Policy = constructor_policy::as_object > + class_bind& constructor_(Policy = Policy{}) + requires detail::class_bind_constructor_kind; template < typename... Args - , ctor_policy_kind Policy = ctor_policy::as_object > - class_bind& ctor_( - std::initializer_list pnames, + , constructor_policy_kind Policy = constructor_policy::as_object > + class_bind& constructor_( + std::initializer_list anames, Policy = Policy{}) - requires detail::class_bind_ctor_kind; + requires detail::class_bind_constructor_kind; - class_bind& dtor_() - requires detail::class_bind_dtor_kind; + class_bind& destructor_() + requires detail::class_bind_destructor_kind; template < detail::class_kind Base > class_bind& base_() @@ -73,7 +73,7 @@ namespace meta_hpp class_bind& function_( std::string name, Function function, - std::initializer_list pnames, + std::initializer_list anames, Policy = Policy{}); template < detail::member_kind Member @@ -91,7 +91,7 @@ namespace meta_hpp class_bind& method_( std::string name, Method method, - std::initializer_list pnames, + std::initializer_list anames, Policy = Policy{}) requires detail::class_bind_method_kind; @@ -143,7 +143,7 @@ namespace meta_hpp scope_bind& function_( std::string name, Function function, - std::initializer_list pnames, + std::initializer_list anames, Policy = Policy{}); template < detail::pointer_kind Pointer diff --git a/headers/meta.hpp/meta_binds/class_bind.hpp b/headers/meta.hpp/meta_binds/class_bind.hpp index b6254c4..e6cb114 100644 --- a/headers/meta.hpp/meta_binds/class_bind.hpp +++ b/headers/meta.hpp/meta_binds/class_bind.hpp @@ -23,41 +23,41 @@ namespace meta_hpp } template < detail::class_kind Class > - template < typename... Args, ctor_policy_kind Policy > - class_bind& class_bind::ctor_(Policy policy) - requires detail::class_bind_ctor_kind + template < typename... Args, constructor_policy_kind Policy > + class_bind& class_bind::constructor_(Policy policy) + requires detail::class_bind_constructor_kind { - return ctor_({}, policy); + return constructor_({}, policy); } template < detail::class_kind Class > - template < typename... Args, ctor_policy_kind Policy > - class_bind& class_bind::ctor_( - std::initializer_list pnames, + template < typename... Args, constructor_policy_kind Policy > + class_bind& class_bind::constructor_( + std::initializer_list anames, [[maybe_unused]] Policy policy) - requires detail::class_bind_ctor_kind + requires detail::class_bind_constructor_kind { - auto ctor_state = detail::ctor_state::make(); + auto constructor_state = detail::constructor_state::make(); - if ( pnames.size() > ctor_state->parameters.size() ) { - detail::throw_exception_with("provided parameter names don't match constructor argument count"); + if ( anames.size() > constructor_state->arguments.size() ) { + detail::throw_exception_with("provided argument names don't match constructor argument count"); } - for ( std::size_t i = 0; i < pnames.size(); ++i ) { - parameter& param = ctor_state->parameters[i]; - detail::state_access(param)->name = std::string{std::data(pnames)[i]}; + for ( std::size_t i = 0; i < anames.size(); ++i ) { + argument& arg = constructor_state->arguments[i]; + detail::state_access(arg)->name = std::string{std::data(anames)[i]}; } - data_->ctors.emplace(ctor_state->index, std::move(ctor_state)); + data_->constructors.emplace(constructor_state->index, std::move(constructor_state)); return *this; } template < detail::class_kind Class > - class_bind& class_bind::dtor_() - requires detail::class_bind_dtor_kind + class_bind& class_bind::destructor_() + requires detail::class_bind_destructor_kind { - auto dtor_state = detail::dtor_state::make(); - data_->dtors.emplace(dtor_state->index, std::move(dtor_state)); + auto destructor_state = detail::destructor_state::make(); + data_->destructors.emplace(destructor_state->index, std::move(destructor_state)); return *this; } @@ -86,18 +86,18 @@ namespace meta_hpp class_bind& class_bind::function_( std::string name, Function function, - std::initializer_list pnames, + std::initializer_list anames, [[maybe_unused]] Policy policy) { auto function_state = detail::function_state::make(std::move(name), std::move(function)); - if ( pnames.size() > function_state->parameters.size() ) { - detail::throw_exception_with("provided parameter names don't match function argument count"); + if ( anames.size() > function_state->arguments.size() ) { + detail::throw_exception_with("provided argument names don't match function argument count"); } - for ( std::size_t i = 0; i < pnames.size(); ++i ) { - parameter& param = function_state->parameters[i]; - detail::state_access(param)->name = std::string{std::data(pnames)[i]}; + for ( std::size_t i = 0; i < anames.size(); ++i ) { + argument& arg = function_state->arguments[i]; + detail::state_access(arg)->name = std::string{std::data(anames)[i]}; } data_->functions.emplace(function_state->index, std::move(function_state)); @@ -127,19 +127,19 @@ namespace meta_hpp class_bind& class_bind::method_( std::string name, Method method, - std::initializer_list pnames, + std::initializer_list anames, [[maybe_unused]] Policy policy) requires detail::class_bind_method_kind { auto method_state = detail::method_state::make(std::move(name), std::move(method)); - if ( pnames.size() > method_state->parameters.size() ) { - detail::throw_exception_with("provided parameter names don't match method argument count"); + if ( anames.size() > method_state->arguments.size() ) { + detail::throw_exception_with("provided argument names don't match method argument count"); } - for ( std::size_t i = 0; i < pnames.size(); ++i ) { - parameter& param = method_state->parameters[i]; - detail::state_access(param)->name = std::string{std::data(pnames)[i]}; + for ( std::size_t i = 0; i < anames.size(); ++i ) { + argument& arg = method_state->arguments[i]; + detail::state_access(arg)->name = std::string{std::data(anames)[i]}; } data_->methods.emplace(method_state->index, std::move(method_state)); diff --git a/headers/meta.hpp/meta_binds/scope_bind.hpp b/headers/meta.hpp/meta_binds/scope_bind.hpp index 1f00cd9..93eb02b 100644 --- a/headers/meta.hpp/meta_binds/scope_bind.hpp +++ b/headers/meta.hpp/meta_binds/scope_bind.hpp @@ -47,18 +47,18 @@ namespace meta_hpp scope_bind& scope_bind::function_( std::string name, Function function, - std::initializer_list pnames, + std::initializer_list anames, [[maybe_unused]] Policy policy) { auto function_state = detail::function_state::make(std::move(name), std::move(function)); - if ( pnames.size() > function_state->parameters.size() ) { - detail::throw_exception_with("provided parameter names don't match function argument count"); + if ( anames.size() > function_state->arguments.size() ) { + detail::throw_exception_with("provided argument names don't match function argument count"); } - for ( std::size_t i = 0; i < pnames.size(); ++i ) { - parameter& param = function_state->parameters[i]; - detail::state_access(param)->name = std::string{std::data(pnames)[i]}; + for ( std::size_t i = 0; i < anames.size(); ++i ) { + argument& arg = function_state->arguments[i]; + detail::state_access(arg)->name = std::string{std::data(anames)[i]}; } state_->functions.emplace(function_state->index, std::move(function_state)); diff --git a/headers/meta.hpp/meta_detail/state_family.hpp b/headers/meta.hpp/meta_detail/state_family.hpp index 18c4865..114caab 100644 --- a/headers/meta.hpp/meta_detail/state_family.hpp +++ b/headers/meta.hpp/meta_detail/state_family.hpp @@ -12,13 +12,13 @@ namespace meta_hpp::detail { template < typename T > inline constexpr bool is_state_family_v = - std::is_same_v || - std::is_same_v || + std::is_same_v || + std::is_same_v || + std::is_same_v || std::is_same_v || std::is_same_v || std::is_same_v || std::is_same_v || - std::is_same_v || std::is_same_v || std::is_same_v; diff --git a/headers/meta.hpp/meta_detail/type_family.hpp b/headers/meta.hpp/meta_detail/type_family.hpp index 66764e5..8655d3b 100644 --- a/headers/meta.hpp/meta_detail/type_family.hpp +++ b/headers/meta.hpp/meta_detail/type_family.hpp @@ -15,8 +15,8 @@ namespace meta_hpp::detail std::is_same_v || std::is_same_v || std::is_same_v || - std::is_same_v || - std::is_same_v || + std::is_same_v || + std::is_same_v || std::is_same_v || std::is_same_v || std::is_same_v || diff --git a/headers/meta.hpp/meta_detail/type_registry.hpp b/headers/meta.hpp/meta_detail/type_registry.hpp index 763e166..9f63b31 100644 --- a/headers/meta.hpp/meta_detail/type_registry.hpp +++ b/headers/meta.hpp/meta_detail/type_registry.hpp @@ -82,10 +82,10 @@ namespace meta_hpp::detail [[nodiscard]] class_type resolve_class_type() { return class_type{resolve_class_type_data()}; } template < class_kind Class, typename... Args > - [[nodiscard]] ctor_type resolve_ctor_type() { return ctor_type{resolve_ctor_type_data()}; } + [[nodiscard]] constructor_type resolve_constructor_type() { return constructor_type{resolve_constructor_type_data()}; } template < class_kind Class > - [[nodiscard]] dtor_type resolve_dtor_type() { return dtor_type{resolve_dtor_type_data()}; } + [[nodiscard]] destructor_type resolve_destructor_type() { return destructor_type{resolve_destructor_type_data()}; } template < enum_kind Enum > [[nodiscard]] enum_type resolve_enum_type() { return enum_type{resolve_enum_type_data()}; } @@ -131,14 +131,14 @@ namespace meta_hpp::detail } template < class_kind Class, typename... Args > - [[nodiscard]] ctor_type_data_ptr resolve_ctor_type_data() { - static ctor_type_data_ptr data{std::make_shared(type_list{}, type_list{})}; + [[nodiscard]] constructor_type_data_ptr resolve_constructor_type_data() { + static constructor_type_data_ptr data{std::make_shared(type_list{}, type_list{})}; return data; } template < class_kind Class > - [[nodiscard]] dtor_type_data_ptr resolve_dtor_type_data() { - static dtor_type_data_ptr data{std::make_shared(type_list{})}; + [[nodiscard]] destructor_type_data_ptr resolve_destructor_type_data() { + static destructor_type_data_ptr data{std::make_shared(type_list{})}; return data; } @@ -234,15 +234,15 @@ namespace meta_hpp::detail namespace meta_hpp::detail { template < class_kind Class, typename... Args > - ctor_type resolve_ctor_type() { + constructor_type resolve_constructor_type() { type_registry& registry = type_registry::instance(); - return registry.resolve_ctor_type(); + return registry.resolve_constructor_type(); } template < class_kind Class > - dtor_type resolve_dtor_type() { + destructor_type resolve_destructor_type() { type_registry& registry = type_registry::instance(); - return registry.resolve_dtor_type(); + return registry.resolve_destructor_type(); } } diff --git a/headers/meta.hpp/meta_detail/type_traits/ctor_traits.hpp b/headers/meta.hpp/meta_detail/type_traits/constructor_traits.hpp similarity index 69% rename from headers/meta.hpp/meta_detail/type_traits/ctor_traits.hpp rename to headers/meta.hpp/meta_detail/type_traits/constructor_traits.hpp index 9c8eedd..2d4e9ee 100644 --- a/headers/meta.hpp/meta_detail/type_traits/ctor_traits.hpp +++ b/headers/meta.hpp/meta_detail/type_traits/constructor_traits.hpp @@ -10,28 +10,28 @@ namespace meta_hpp::detail { - enum class ctor_flags : std::uint32_t { + enum class constructor_flags : std::uint32_t { is_noexcept = 1 << 0, }; - ENUM_HPP_OPERATORS_DECL(ctor_flags) - using ctor_bitflags = bitflags; + ENUM_HPP_OPERATORS_DECL(constructor_flags) + using constructor_bitflags = bitflags; } namespace meta_hpp::detail { template < class_kind Class, typename... Args > - struct ctor_traits { + struct constructor_traits { static constexpr std::size_t arity{sizeof...(Args)}; using class_type = Class; using argument_types = type_list; - [[nodiscard]] static constexpr ctor_bitflags make_flags() noexcept { - ctor_bitflags flags{}; + [[nodiscard]] static constexpr constructor_bitflags make_flags() noexcept { + constructor_bitflags flags{}; if constexpr ( std::is_nothrow_constructible_v ) { - flags.set(ctor_flags::is_noexcept); + flags.set(constructor_flags::is_noexcept); } return flags; diff --git a/headers/meta.hpp/meta_detail/type_traits/dtor_traits.hpp b/headers/meta.hpp/meta_detail/type_traits/destructor_traits.hpp similarity index 66% rename from headers/meta.hpp/meta_detail/type_traits/dtor_traits.hpp rename to headers/meta.hpp/meta_detail/type_traits/destructor_traits.hpp index 759cdd5..e7ad092 100644 --- a/headers/meta.hpp/meta_detail/type_traits/dtor_traits.hpp +++ b/headers/meta.hpp/meta_detail/type_traits/destructor_traits.hpp @@ -10,25 +10,25 @@ namespace meta_hpp::detail { - enum class dtor_flags : std::uint32_t { + enum class destructor_flags : std::uint32_t { is_noexcept = 1 << 0, }; - ENUM_HPP_OPERATORS_DECL(dtor_flags) - using dtor_bitflags = bitflags; + ENUM_HPP_OPERATORS_DECL(destructor_flags) + using destructor_bitflags = bitflags; } namespace meta_hpp::detail { template < class_kind Class > - struct dtor_traits { + struct destructor_traits { using class_type = Class; - [[nodiscard]] static constexpr dtor_bitflags make_flags() noexcept { - dtor_bitflags flags{}; + [[nodiscard]] static constexpr destructor_bitflags make_flags() noexcept { + destructor_bitflags flags{}; if constexpr ( std::is_nothrow_destructible_v ) { - flags.set(dtor_flags::is_noexcept); + flags.set(destructor_flags::is_noexcept); } return flags; diff --git a/headers/meta.hpp/meta_indices.hpp b/headers/meta.hpp/meta_indices.hpp index 7033a92..fc0a38b 100644 --- a/headers/meta.hpp/meta_indices.hpp +++ b/headers/meta.hpp/meta_indices.hpp @@ -11,36 +11,54 @@ namespace meta_hpp { - class ctor_index final { + class argument_index final { public: - ctor_index() = delete; - [[nodiscard]] const ctor_type& get_type() const noexcept; + argument_index() = delete; + [[nodiscard]] const any_type& get_type() const noexcept; + [[nodiscard]] std::size_t get_position() const noexcept; private: - friend detail::ctor_state; - template < detail::class_kind Class, typename... Args > - [[nodiscard]] static ctor_index make(); + friend detail::argument_state; + template < typename Argument > + [[nodiscard]] static argument_index make(std::size_t position); private: - explicit ctor_index(ctor_type type); - friend bool operator<(const ctor_index& l, const ctor_index& r) noexcept; - friend bool operator==(const ctor_index& l, const ctor_index& r) noexcept; + explicit argument_index(any_type type, std::size_t position); + friend bool operator<(const argument_index& l, const argument_index& r) noexcept; + friend bool operator==(const argument_index& l, const argument_index& r) noexcept; private: - ctor_type type_; + any_type type_; + std::size_t position_{}; }; - class dtor_index final { + class constructor_index final { public: - dtor_index() = delete; - [[nodiscard]] const dtor_type& get_type() const noexcept; + constructor_index() = delete; + [[nodiscard]] const constructor_type& get_type() const noexcept; private: - friend detail::dtor_state; + friend detail::constructor_state; + template < detail::class_kind Class, typename... Args > + [[nodiscard]] static constructor_index make(); + private: + explicit constructor_index(constructor_type type); + friend bool operator<(const constructor_index& l, const constructor_index& r) noexcept; + friend bool operator==(const constructor_index& l, const constructor_index& r) noexcept; + private: + constructor_type type_; + }; + + class destructor_index final { + public: + destructor_index() = delete; + [[nodiscard]] const destructor_type& get_type() const noexcept; + private: + friend detail::destructor_state; template < detail::class_kind Class > - [[nodiscard]] static dtor_index make(); + [[nodiscard]] static destructor_index make(); private: - explicit dtor_index(dtor_type type); - friend bool operator<(const dtor_index& l, const dtor_index& r) noexcept; - friend bool operator==(const dtor_index& l, const dtor_index& r) noexcept; + explicit destructor_index(destructor_type type); + friend bool operator<(const destructor_index& l, const destructor_index& r) noexcept; + friend bool operator==(const destructor_index& l, const destructor_index& r) noexcept; private: - dtor_type type_; + destructor_type type_; }; class evalue_index final { @@ -115,24 +133,6 @@ namespace meta_hpp std::string name_; }; - class parameter_index final { - public: - parameter_index() = delete; - [[nodiscard]] const any_type& get_type() const noexcept; - [[nodiscard]] std::size_t get_position() const noexcept; - private: - friend detail::parameter_state; - template < typename Parameter > - [[nodiscard]] static parameter_index make(std::size_t position); - private: - explicit parameter_index(any_type type, std::size_t position); - friend bool operator<(const parameter_index& l, const parameter_index& r) noexcept; - friend bool operator==(const parameter_index& l, const parameter_index& r) noexcept; - private: - any_type type_; - std::size_t position_{}; - }; - class scope_index final { public: scope_index() = delete; diff --git a/headers/meta.hpp/meta_indices/parameter_index.hpp b/headers/meta.hpp/meta_indices/argument_index.hpp similarity index 58% rename from headers/meta.hpp/meta_indices/parameter_index.hpp rename to headers/meta.hpp/meta_indices/argument_index.hpp index 00b9d48..7cb3ef3 100644 --- a/headers/meta.hpp/meta_indices/parameter_index.hpp +++ b/headers/meta.hpp/meta_indices/argument_index.hpp @@ -14,28 +14,28 @@ namespace meta_hpp { - inline parameter_index::parameter_index(any_type type, std::size_t position) + inline argument_index::argument_index(any_type type, std::size_t position) : type_{std::move(type)} , position_{position} {} - template < typename Parameter > - inline parameter_index parameter_index::make(std::size_t position) { - return parameter_index{detail::resolve_type(), position}; + template < typename Argument > + inline argument_index argument_index::make(std::size_t position) { + return argument_index{detail::resolve_type(), position}; } - inline const any_type& parameter_index::get_type() const noexcept { + inline const any_type& argument_index::get_type() const noexcept { return type_; } - inline std::size_t parameter_index::get_position() const noexcept { + inline std::size_t argument_index::get_position() const noexcept { return position_; } - inline bool operator<(const parameter_index& l, const parameter_index& r) noexcept { + inline bool operator<(const argument_index& l, const argument_index& r) noexcept { return l.type_ < r.type_ || (l.type_ == r.type_ && l.position_ < r.position_); } - inline bool operator==(const parameter_index& l, const parameter_index& r) noexcept { + inline bool operator==(const argument_index& l, const argument_index& r) noexcept { return l.type_ == r.type_ && l.position_ == r.position_; } } diff --git a/headers/meta.hpp/meta_indices/ctor_index.hpp b/headers/meta.hpp/meta_indices/constructor_index.hpp similarity index 61% rename from headers/meta.hpp/meta_indices/ctor_index.hpp rename to headers/meta.hpp/meta_indices/constructor_index.hpp index 0d83eb6..9ab13b6 100644 --- a/headers/meta.hpp/meta_indices/ctor_index.hpp +++ b/headers/meta.hpp/meta_indices/constructor_index.hpp @@ -14,23 +14,23 @@ namespace meta_hpp { - inline ctor_index::ctor_index(ctor_type type) + inline constructor_index::constructor_index(constructor_type type) : type_{std::move(type)} {} template < detail::class_kind Class, typename... Args > - ctor_index ctor_index::make() { - return ctor_index{detail::resolve_ctor_type()}; + constructor_index constructor_index::make() { + return constructor_index{detail::resolve_constructor_type()}; } - inline const ctor_type& ctor_index::get_type() const noexcept { + inline const constructor_type& constructor_index::get_type() const noexcept { return type_; } - inline bool operator<(const ctor_index& l, const ctor_index& r) noexcept { + inline bool operator<(const constructor_index& l, const constructor_index& r) noexcept { return l.type_ < r.type_; } - inline bool operator==(const ctor_index& l, const ctor_index& r) noexcept { + inline bool operator==(const constructor_index& l, const constructor_index& r) noexcept { return l.type_ == r.type_; } } diff --git a/headers/meta.hpp/meta_indices/dtor_index.hpp b/headers/meta.hpp/meta_indices/destructor_index.hpp similarity index 61% rename from headers/meta.hpp/meta_indices/dtor_index.hpp rename to headers/meta.hpp/meta_indices/destructor_index.hpp index e62828d..2207b85 100644 --- a/headers/meta.hpp/meta_indices/dtor_index.hpp +++ b/headers/meta.hpp/meta_indices/destructor_index.hpp @@ -14,23 +14,23 @@ namespace meta_hpp { - inline dtor_index::dtor_index(dtor_type type) + inline destructor_index::destructor_index(destructor_type type) : type_{std::move(type)} {} template < detail::class_kind Class > - dtor_index dtor_index::make() { - return dtor_index{detail::resolve_dtor_type()}; + destructor_index destructor_index::make() { + return destructor_index{detail::resolve_destructor_type()}; } - inline const dtor_type& dtor_index::get_type() const noexcept { + inline const destructor_type& destructor_index::get_type() const noexcept { return type_; } - inline bool operator<(const dtor_index& l, const dtor_index& r) noexcept { + inline bool operator<(const destructor_index& l, const destructor_index& r) noexcept { return l.type_ < r.type_; } - inline bool operator==(const dtor_index& l, const dtor_index& r) noexcept { + inline bool operator==(const destructor_index& l, const destructor_index& r) noexcept { return l.type_ == r.type_; } } diff --git a/headers/meta.hpp/meta_states.hpp b/headers/meta.hpp/meta_states.hpp index 3e4d3d3..f238b80 100644 --- a/headers/meta.hpp/meta_states.hpp +++ b/headers/meta.hpp/meta_states.hpp @@ -15,7 +15,7 @@ namespace meta_hpp { - namespace ctor_policy + namespace constructor_policy { struct as_object final {}; struct as_raw_pointer final {}; @@ -51,10 +51,10 @@ namespace meta_hpp } template < typename Policy > - inline constexpr bool is_ctor_policy_v = - std::is_same_v || - std::is_same_v || - std::is_same_v; + inline constexpr bool is_constructor_policy_v = + std::is_same_v || + std::is_same_v || + std::is_same_v; template < typename Policy > inline constexpr bool is_function_policy_v = @@ -81,7 +81,7 @@ namespace meta_hpp std::is_same_v; template < typename Policy > - concept ctor_policy_kind = is_ctor_policy_v; + concept constructor_policy_kind = is_constructor_policy_v; template < typename Policy > concept function_policy_kind = is_function_policy_v; @@ -98,16 +98,33 @@ namespace meta_hpp namespace meta_hpp { - class ctor final { + class argument final { public: - explicit ctor() = default; - explicit ctor(detail::ctor_state_ptr state); + explicit argument() = default; + explicit argument(detail::argument_state_ptr state); [[nodiscard]] bool is_valid() const noexcept; [[nodiscard]] explicit operator bool() const noexcept; - [[nodiscard]] const ctor_index& get_index() const noexcept; - [[nodiscard]] const ctor_type& get_type() const noexcept; + [[nodiscard]] const argument_index& get_index() const noexcept; + [[nodiscard]] const any_type& get_type() const noexcept; + [[nodiscard]] std::size_t get_position() const noexcept; + [[nodiscard]] const std::string& get_name() const noexcept; + private: + detail::argument_state_ptr state_; + friend auto detail::state_access(const argument&); + }; + + class constructor final { + public: + explicit constructor() = default; + explicit constructor(detail::constructor_state_ptr state); + + [[nodiscard]] bool is_valid() const noexcept; + [[nodiscard]] explicit operator bool() const noexcept; + + [[nodiscard]] const constructor_index& get_index() const noexcept; + [[nodiscard]] const constructor_type& get_type() const noexcept; template < typename... Args > uvalue invoke(Args&&... args) const; @@ -121,23 +138,23 @@ namespace meta_hpp template < typename... Args > [[nodiscard]] bool is_invocable_with(Args&&... args) const noexcept; - [[nodiscard]] parameter get_parameter(std::size_t position) const noexcept; - [[nodiscard]] const parameter_list& get_parameters() const noexcept; + [[nodiscard]] argument get_argument(std::size_t position) const noexcept; + [[nodiscard]] const argument_list& get_arguments() const noexcept; private: - detail::ctor_state_ptr state_; - friend auto detail::state_access(const ctor&); + detail::constructor_state_ptr state_; + friend auto detail::state_access(const constructor&); }; - class dtor final { + class destructor final { public: - explicit dtor() = default; - explicit dtor(detail::dtor_state_ptr state); + explicit destructor() = default; + explicit destructor(detail::destructor_state_ptr state); [[nodiscard]] bool is_valid() const noexcept; [[nodiscard]] explicit operator bool() const noexcept; - [[nodiscard]] const dtor_index& get_index() const noexcept; - [[nodiscard]] const dtor_type& get_type() const noexcept; + [[nodiscard]] const destructor_index& get_index() const noexcept; + [[nodiscard]] const destructor_type& get_type() const noexcept; template < typename Arg > void invoke(Arg&& ptr) const; @@ -151,8 +168,8 @@ namespace meta_hpp template < typename Arg > [[nodiscard]] bool is_invocable_with(Arg&& ptr) const noexcept; private: - detail::dtor_state_ptr state_; - friend auto detail::state_access(const dtor&); + detail::destructor_state_ptr state_; + friend auto detail::state_access(const destructor&); }; class evalue final { @@ -198,8 +215,8 @@ namespace meta_hpp template < typename... Args > [[nodiscard]] bool is_invocable_with(Args&&... args) const noexcept; - [[nodiscard]] parameter get_parameter(std::size_t position) const noexcept; - [[nodiscard]] const parameter_list& get_parameters() const noexcept; + [[nodiscard]] argument get_argument(std::size_t position) const noexcept; + [[nodiscard]] const argument_list& get_arguments() const noexcept; private: detail::function_state_ptr state_; friend auto detail::state_access(const function&); @@ -269,30 +286,13 @@ namespace meta_hpp template < typename Instance, typename... Args > [[nodiscard]] bool is_invocable_with(Instance&& instance, Args&&... args) const noexcept; - [[nodiscard]] parameter get_parameter(std::size_t position) const noexcept; - [[nodiscard]] const parameter_list& get_parameters() const noexcept; + [[nodiscard]] argument get_argument(std::size_t position) const noexcept; + [[nodiscard]] const argument_list& get_arguments() const noexcept; private: detail::method_state_ptr state_; friend auto detail::state_access(const method&); }; - class parameter final { - public: - explicit parameter() = default; - explicit parameter(detail::parameter_state_ptr state); - - [[nodiscard]] bool is_valid() const noexcept; - [[nodiscard]] explicit operator bool() const noexcept; - - [[nodiscard]] const parameter_index& get_index() const noexcept; - [[nodiscard]] const any_type& get_type() const noexcept; - [[nodiscard]] std::size_t get_position() const noexcept; - [[nodiscard]] const std::string& get_name() const noexcept; - private: - detail::parameter_state_ptr state_; - friend auto detail::state_access(const parameter&); - }; - class scope final { public: explicit scope() = default; @@ -394,30 +394,30 @@ namespace meta_hpp namespace meta_hpp::detail { - struct ctor_state final { + struct constructor_state final { using invoke_impl = fixed_function)>; using is_invocable_with_impl = fixed_function)>; - ctor_index index; + constructor_index index; invoke_impl invoke; is_invocable_with_impl is_invocable_with; - parameter_list parameters; + argument_list arguments; - template < ctor_policy_kind Policy, class_kind Class, typename... Args > - [[nodiscard]] static ctor_state_ptr make(); + template < constructor_policy_kind Policy, class_kind Class, typename... Args > + [[nodiscard]] static constructor_state_ptr make(); }; - struct dtor_state final { + struct destructor_state final { using invoke_impl = fixed_function; using is_invocable_with_impl = fixed_function; - dtor_index index; + destructor_index index; invoke_impl invoke; is_invocable_with_impl is_invocable_with; template < class_kind Class > - [[nodiscard]] static dtor_state_ptr make(); + [[nodiscard]] static destructor_state_ptr make(); }; struct evalue_state final { @@ -437,7 +437,7 @@ namespace meta_hpp::detail invoke_impl invoke; is_invocable_with_impl is_invocable_with; - parameter_list parameters; + argument_list arguments; template < function_policy_kind Policy, function_kind Function > [[nodiscard]] static function_state_ptr make(std::string name, Function function); @@ -468,19 +468,19 @@ namespace meta_hpp::detail invoke_impl invoke; is_invocable_with_impl is_invocable_with; - parameter_list parameters; + argument_list arguments; template < method_policy_kind Policy, method_kind Method > [[nodiscard]] static method_state_ptr make(std::string name, Method method); }; - struct parameter_state final { - parameter_index index; + struct argument_state final { + argument_index index; std::string name{}; - template < typename Parameter > - [[nodiscard]] static parameter_state_ptr make(std::size_t position); + template < typename Argument > + [[nodiscard]] static argument_state_ptr make(std::size_t position); }; struct scope_state final { diff --git a/headers/meta.hpp/meta_states/parameter.hpp b/headers/meta.hpp/meta_states/argument.hpp similarity index 53% rename from headers/meta.hpp/meta_states/parameter.hpp rename to headers/meta.hpp/meta_states/argument.hpp index e0cad8d..4d47d9f 100644 --- a/headers/meta.hpp/meta_states/parameter.hpp +++ b/headers/meta.hpp/meta_states/argument.hpp @@ -11,10 +11,10 @@ namespace meta_hpp::detail { - template < typename Parameter > - inline parameter_state_ptr parameter_state::make(std::size_t position) { - return std::make_shared(parameter_state{ - .index{parameter_index::make(position)}, + template < typename Argument > + inline argument_state_ptr argument_state::make(std::size_t position) { + return std::make_shared(argument_state{ + .index{argument_index::make(position)}, }); } } @@ -22,30 +22,30 @@ namespace meta_hpp::detail namespace meta_hpp { - inline parameter::parameter(detail::parameter_state_ptr state) + inline argument::argument(detail::argument_state_ptr state) : state_{std::move(state)} {} - inline bool parameter::is_valid() const noexcept { + inline bool argument::is_valid() const noexcept { return !!state_; } - inline parameter::operator bool() const noexcept { + inline argument::operator bool() const noexcept { return is_valid(); } - inline const parameter_index& parameter::get_index() const noexcept { + inline const argument_index& argument::get_index() const noexcept { return state_->index; } - inline const any_type& parameter::get_type() const noexcept { + inline const any_type& argument::get_type() const noexcept { return state_->index.get_type(); } - inline std::size_t parameter::get_position() const noexcept { + inline std::size_t argument::get_position() const noexcept { return state_->index.get_position(); } - inline const std::string& parameter::get_name() const noexcept { + inline const std::string& argument::get_name() const noexcept { return state_->name; } } diff --git a/headers/meta.hpp/meta_states/ctor.hpp b/headers/meta.hpp/meta_states/constructor.hpp similarity index 61% rename from headers/meta.hpp/meta_states/ctor.hpp rename to headers/meta.hpp/meta_states/constructor.hpp index 432d665..fade6dc 100644 --- a/headers/meta.hpp/meta_states/ctor.hpp +++ b/headers/meta.hpp/meta_states/constructor.hpp @@ -9,26 +9,26 @@ #include "../meta_base.hpp" #include "../meta_states.hpp" -#include "../meta_types/ctor_type.hpp" +#include "../meta_types/constructor_type.hpp" #include "../meta_detail/value_utilities/uarg.hpp" namespace meta_hpp::detail { - template < ctor_policy_kind Policy, class_kind Class, typename... Args > - uvalue raw_ctor_invoke(std::span args) { - using ct = ctor_traits; + template < constructor_policy_kind Policy, class_kind Class, typename... Args > + uvalue raw_constructor_invoke(std::span args) { + using ct = constructor_traits; using class_type = typename ct::class_type; using argument_types = typename ct::argument_types; constexpr bool as_object = stdex::copy_constructible && - stdex::same_as; + stdex::same_as; constexpr bool as_raw_ptr = - stdex::same_as; + stdex::same_as; constexpr bool as_shared_ptr = - stdex::same_as; + stdex::same_as; static_assert(as_object || as_raw_ptr || as_shared_ptr); @@ -62,8 +62,8 @@ namespace meta_hpp::detail } template < class_kind Class, typename... Args > - bool raw_ctor_is_invocable_with(std::span args) { - using ct = ctor_traits; + bool raw_constructor_is_invocable_with(std::span args) { + using ct = constructor_traits; using argument_types = typename ct::argument_types; if ( args.size() != ct::arity ) { @@ -79,71 +79,71 @@ namespace meta_hpp::detail namespace meta_hpp::detail { - template < ctor_policy_kind Policy, class_kind Class, typename... Args > - ctor_state::invoke_impl make_ctor_invoke() { - return &raw_ctor_invoke; + template < constructor_policy_kind Policy, class_kind Class, typename... Args > + constructor_state::invoke_impl make_constructor_invoke() { + return &raw_constructor_invoke; } template < class_kind Class, typename... Args > - ctor_state::is_invocable_with_impl make_ctor_is_invocable_with() { - return &raw_ctor_is_invocable_with; + constructor_state::is_invocable_with_impl make_constructor_is_invocable_with() { + return &raw_constructor_is_invocable_with; } template < class_kind Class, typename... Args > - parameter_list make_ctor_parameters() { - using ct = detail::ctor_traits; + argument_list make_constructor_arguments() { + using ct = detail::constructor_traits; - parameter_list parameters; - parameters.reserve(ct::arity); + argument_list arguments; + arguments.reserve(ct::arity); // NOLINTNEXTLINE(readability-named-parameter) - [¶meters](std::index_sequence) mutable { - (parameters.push_back([](){ + [&arguments](std::index_sequence) mutable { + (arguments.push_back([](){ using P = detail::type_list_at_t; - return parameter{detail::parameter_state::make

(I)}; + return argument{detail::argument_state::make

(I)}; }.template operator()()), ...); }(std::make_index_sequence()); - return parameters; + return arguments; } } namespace meta_hpp::detail { - template < ctor_policy_kind Policy, class_kind Class, typename... Args > - ctor_state_ptr ctor_state::make() { - return std::make_shared(ctor_state{ - .index{ctor_index::make()}, - .invoke{make_ctor_invoke()}, - .is_invocable_with{make_ctor_is_invocable_with()}, - .parameters{make_ctor_parameters()}, + template < constructor_policy_kind Policy, class_kind Class, typename... Args > + constructor_state_ptr constructor_state::make() { + return std::make_shared(constructor_state{ + .index{constructor_index::make()}, + .invoke{make_constructor_invoke()}, + .is_invocable_with{make_constructor_is_invocable_with()}, + .arguments{make_constructor_arguments()}, }); } } namespace meta_hpp { - inline ctor::ctor(detail::ctor_state_ptr state) + inline constructor::constructor(detail::constructor_state_ptr state) : state_{std::move(state)} {} - inline bool ctor::is_valid() const noexcept { + inline bool constructor::is_valid() const noexcept { return !!state_; } - inline ctor::operator bool() const noexcept { + inline constructor::operator bool() const noexcept { return is_valid(); } - inline const ctor_index& ctor::get_index() const noexcept { + inline const constructor_index& constructor::get_index() const noexcept { return state_->index; } - inline const ctor_type& ctor::get_type() const noexcept { + inline const constructor_type& constructor::get_type() const noexcept { return state_->index.get_type(); } template < typename... Args > - uvalue ctor::invoke(Args&&... args) const { + uvalue constructor::invoke(Args&&... args) const { if constexpr ( sizeof...(Args) > 0 ) { using namespace detail; const std::array vargs{uarg{std::forward(args)}...}; @@ -154,12 +154,12 @@ namespace meta_hpp } template < typename... Args > - uvalue ctor::operator()(Args&&... args) const { + uvalue constructor::operator()(Args&&... args) const { return invoke(std::forward(args)...); } template < typename... Args > - bool ctor::is_invocable_with() const noexcept { + bool constructor::is_invocable_with() const noexcept { if constexpr ( sizeof...(Args) > 0 ) { using namespace detail; const std::array vargs{uarg_base{type_list{}}...}; @@ -170,7 +170,7 @@ namespace meta_hpp } template < typename... Args > - bool ctor::is_invocable_with(Args&&... args) const noexcept { + bool constructor::is_invocable_with(Args&&... args) const noexcept { if constexpr ( sizeof...(Args) > 0 ) { using namespace detail; const std::array vargs{uarg_base{std::forward(args)}...}; @@ -180,11 +180,11 @@ namespace meta_hpp } } - inline parameter ctor::get_parameter(std::size_t position) const noexcept { - return position < state_->parameters.size() ? state_->parameters[position] : parameter{}; + inline argument constructor::get_argument(std::size_t position) const noexcept { + return position < state_->arguments.size() ? state_->arguments[position] : argument{}; } - inline const parameter_list& ctor::get_parameters() const noexcept { - return state_->parameters; + inline const argument_list& constructor::get_arguments() const noexcept { + return state_->arguments; } } diff --git a/headers/meta.hpp/meta_states/dtor.hpp b/headers/meta.hpp/meta_states/destructor.hpp similarity index 60% rename from headers/meta.hpp/meta_states/dtor.hpp rename to headers/meta.hpp/meta_states/destructor.hpp index 079c563..d408b1b 100644 --- a/headers/meta.hpp/meta_states/dtor.hpp +++ b/headers/meta.hpp/meta_states/destructor.hpp @@ -9,14 +9,14 @@ #include "../meta_base.hpp" #include "../meta_states.hpp" -#include "../meta_types/dtor_type.hpp" +#include "../meta_types/destructor_type.hpp" #include "../meta_detail/value_utilities/uarg.hpp" namespace meta_hpp::detail { template < class_kind Class > - void raw_dtor_invoke(const uarg& ptr) { - using dt = dtor_traits; + void raw_destructor_invoke(const uarg& ptr) { + using dt = destructor_traits; using class_type = typename dt::class_type; if ( !ptr.can_cast_to() ) { @@ -30,8 +30,8 @@ namespace meta_hpp::detail } template < class_kind Class > - bool raw_dtor_is_invocable_with(const uarg_base& ptr) { - using dt = dtor_traits; + bool raw_destructor_is_invocable_with(const uarg_base& ptr) { + using dt = destructor_traits; using class_type = typename dt::class_type; return ptr.can_cast_to(); @@ -41,70 +41,70 @@ namespace meta_hpp::detail namespace meta_hpp::detail { template < class_kind Class > - dtor_state::invoke_impl make_dtor_invoke() { - return &raw_dtor_invoke; + destructor_state::invoke_impl make_destructor_invoke() { + return &raw_destructor_invoke; } template < class_kind Class > - dtor_state::is_invocable_with_impl make_dtor_is_invocable_with() { - return &raw_dtor_is_invocable_with; + destructor_state::is_invocable_with_impl make_destructor_is_invocable_with() { + return &raw_destructor_is_invocable_with; } } namespace meta_hpp::detail { template < class_kind Class > - dtor_state_ptr dtor_state::make() { - return std::make_shared(dtor_state{ - .index{dtor_index::make()}, - .invoke{make_dtor_invoke()}, - .is_invocable_with{make_dtor_is_invocable_with()}, + destructor_state_ptr destructor_state::make() { + return std::make_shared(destructor_state{ + .index{destructor_index::make()}, + .invoke{make_destructor_invoke()}, + .is_invocable_with{make_destructor_is_invocable_with()}, }); } } namespace meta_hpp { - inline dtor::dtor(detail::dtor_state_ptr state) + inline destructor::destructor(detail::destructor_state_ptr state) : state_{std::move(state)} {} - inline bool dtor::is_valid() const noexcept { + inline bool destructor::is_valid() const noexcept { return !!state_; } - inline dtor::operator bool() const noexcept { + inline destructor::operator bool() const noexcept { return is_valid(); } - inline const dtor_index& dtor::get_index() const noexcept { + inline const destructor_index& destructor::get_index() const noexcept { return state_->index; } - inline const dtor_type& dtor::get_type() const noexcept { + inline const destructor_type& destructor::get_type() const noexcept { return state_->index.get_type(); } template < typename Arg > - void dtor::invoke(Arg&& ptr) const { + void destructor::invoke(Arg&& ptr) const { using namespace detail; const uarg varg{std::forward(ptr)}; state_->invoke(varg); } template < typename Arg > - void dtor::operator()(Arg&& ptr) const { + void destructor::operator()(Arg&& ptr) const { invoke(std::forward(ptr)); } template < typename Arg > - bool dtor::is_invocable_with() const noexcept { + bool destructor::is_invocable_with() const noexcept { using namespace detail; const uarg_base varg{type_list{}}; return state_->is_invocable_with(varg); } template < typename Arg > - bool dtor::is_invocable_with(Arg&& ptr) const noexcept { + bool destructor::is_invocable_with(Arg&& ptr) const noexcept { using namespace detail; const uarg_base varg{std::forward(ptr)}; return state_->is_invocable_with(varg); diff --git a/headers/meta.hpp/meta_states/function.hpp b/headers/meta.hpp/meta_states/function.hpp index f219171..6933a73 100644 --- a/headers/meta.hpp/meta_states/function.hpp +++ b/headers/meta.hpp/meta_states/function.hpp @@ -96,21 +96,21 @@ namespace meta_hpp::detail } template < function_kind Function > - parameter_list make_function_parameters() { + argument_list make_function_arguments() { using ft = detail::function_traits; - parameter_list parameters; - parameters.reserve(ft::arity); + argument_list arguments; + arguments.reserve(ft::arity); // NOLINTNEXTLINE(readability-named-parameter) - [¶meters](std::index_sequence) mutable { - (parameters.push_back([](){ + [&arguments](std::index_sequence) mutable { + (arguments.push_back([](){ using P = detail::type_list_at_t; - return parameter{detail::parameter_state::make

(I)}; + return argument{detail::argument_state::make

(I)}; }.template operator()()), ...); }(std::make_index_sequence()); - return parameters; + return arguments; } } @@ -122,7 +122,7 @@ namespace meta_hpp::detail .index{function_index::make(std::move(name))}, .invoke{make_function_invoke(std::move(function))}, .is_invocable_with{make_function_is_invocable_with()}, - .parameters{make_function_parameters()}, + .arguments{make_function_arguments()}, }); } } @@ -190,11 +190,11 @@ namespace meta_hpp } } - inline parameter function::get_parameter(std::size_t position) const noexcept { - return position < state_->parameters.size() ? state_->parameters[position] : parameter{}; + inline argument function::get_argument(std::size_t position) const noexcept { + return position < state_->arguments.size() ? state_->arguments[position] : argument{}; } - inline const parameter_list& function::get_parameters() const noexcept { - return state_->parameters; + inline const argument_list& function::get_arguments() const noexcept { + return state_->arguments; } } diff --git a/headers/meta.hpp/meta_states/method.hpp b/headers/meta.hpp/meta_states/method.hpp index db02f03..28b8d82 100644 --- a/headers/meta.hpp/meta_states/method.hpp +++ b/headers/meta.hpp/meta_states/method.hpp @@ -109,21 +109,21 @@ namespace meta_hpp::detail } template < method_kind Method > - parameter_list make_method_parameters() { + argument_list make_method_arguments() { using mt = detail::method_traits; - parameter_list parameters; - parameters.reserve(mt::arity); + argument_list arguments; + arguments.reserve(mt::arity); // NOLINTNEXTLINE(readability-named-parameter) - [¶meters](std::index_sequence) mutable { - (parameters.push_back([](){ + [&arguments](std::index_sequence) mutable { + (arguments.push_back([](){ using P = detail::type_list_at_t; - return parameter{detail::parameter_state::make

(I)}; + return argument{detail::argument_state::make

(I)}; }.template operator()()), ...); }(std::make_index_sequence()); - return parameters; + return arguments; } } @@ -135,7 +135,7 @@ namespace meta_hpp::detail .index{method_index::make(std::move(name))}, .invoke{make_method_invoke(std::move(method))}, .is_invocable_with{make_method_is_invocable_with()}, - .parameters{make_method_parameters()}, + .arguments{make_method_arguments()}, }); } } @@ -206,11 +206,11 @@ namespace meta_hpp } } - inline parameter method::get_parameter(std::size_t position) const noexcept { - return position < state_->parameters.size() ? state_->parameters[position] : parameter{}; + inline argument method::get_argument(std::size_t position) const noexcept { + return position < state_->arguments.size() ? state_->arguments[position] : argument{}; } - inline const parameter_list& method::get_parameters() const noexcept { - return state_->parameters; + inline const argument_list& method::get_arguments() const noexcept { + return state_->arguments; } } diff --git a/headers/meta.hpp/meta_types.hpp b/headers/meta.hpp/meta_types.hpp index 7cb9bbb..0dd3579 100644 --- a/headers/meta.hpp/meta_types.hpp +++ b/headers/meta.hpp/meta_types.hpp @@ -12,8 +12,8 @@ #include "meta_detail/type_traits/array_traits.hpp" #include "meta_detail/type_traits/class_traits.hpp" -#include "meta_detail/type_traits/ctor_traits.hpp" -#include "meta_detail/type_traits/dtor_traits.hpp" +#include "meta_detail/type_traits/constructor_traits.hpp" +#include "meta_detail/type_traits/destructor_traits.hpp" #include "meta_detail/type_traits/enum_traits.hpp" #include "meta_detail/type_traits/function_traits.hpp" #include "meta_detail/type_traits/member_traits.hpp" @@ -30,11 +30,11 @@ namespace meta_hpp using class_flags = detail::class_flags; using class_bitflags = detail::class_bitflags; - using ctor_flags = detail::ctor_flags; - using ctor_bitflags = detail::ctor_bitflags; + using constructor_flags = detail::constructor_flags; + using constructor_bitflags = detail::constructor_bitflags; - using dtor_flags = detail::dtor_flags; - using dtor_bitflags = detail::dtor_bitflags; + using destructor_flags = detail::destructor_flags; + using destructor_bitflags = detail::destructor_bitflags; using enum_flags = detail::enum_flags; using enum_bitflags = detail::enum_bitflags; @@ -72,8 +72,8 @@ namespace meta_hpp any_type(const array_type& other) noexcept; any_type(const class_type& other) noexcept; - any_type(const ctor_type& other) noexcept; - any_type(const dtor_type& other) noexcept; + any_type(const constructor_type& other) noexcept; + any_type(const destructor_type& other) noexcept; any_type(const enum_type& other) noexcept; any_type(const function_type& other) noexcept; any_type(const member_type& other) noexcept; @@ -86,8 +86,8 @@ namespace meta_hpp [[nodiscard]] bool is_array() const noexcept; [[nodiscard]] bool is_class() const noexcept; - [[nodiscard]] bool is_ctor() const noexcept; - [[nodiscard]] bool is_dtor() const noexcept; + [[nodiscard]] bool is_constructor() const noexcept; + [[nodiscard]] bool is_destructor() const noexcept; [[nodiscard]] bool is_enum() const noexcept; [[nodiscard]] bool is_function() const noexcept; [[nodiscard]] bool is_member() const noexcept; @@ -100,8 +100,8 @@ namespace meta_hpp [[nodiscard]] array_type as_array() const noexcept; [[nodiscard]] class_type as_class() const noexcept; - [[nodiscard]] ctor_type as_ctor() const noexcept; - [[nodiscard]] dtor_type as_dtor() const noexcept; + [[nodiscard]] constructor_type as_constructor() const noexcept; + [[nodiscard]] destructor_type as_destructor() const noexcept; [[nodiscard]] enum_type as_enum() const noexcept; [[nodiscard]] function_type as_function() const noexcept; [[nodiscard]] member_type as_member() const noexcept; @@ -151,8 +151,8 @@ namespace meta_hpp [[nodiscard]] any_type get_argument_type(std::size_t position) const noexcept; [[nodiscard]] const std::vector& get_argument_types() const noexcept; - [[nodiscard]] const ctor_map& get_ctors() const noexcept; - [[nodiscard]] const dtor_map& get_dtors() const noexcept; + [[nodiscard]] const constructor_map& get_ctors() const noexcept; + [[nodiscard]] const destructor_map& get_dtors() const noexcept; [[nodiscard]] const class_set& get_bases() const noexcept; [[nodiscard]] const function_map& get_functions() const noexcept; [[nodiscard]] const member_map& get_members() const noexcept; @@ -182,11 +182,11 @@ namespace meta_hpp [[nodiscard]] variable get_variable(std::string_view name) const noexcept; template < typename... Args > - [[nodiscard]] ctor get_ctor_with() const noexcept; + [[nodiscard]] constructor get_constructor_with() const noexcept; template < typename Iter > - [[nodiscard]] ctor get_ctor_with(Iter first, Iter last) const noexcept; - [[nodiscard]] ctor get_ctor_with(const std::vector& args) const noexcept; - [[nodiscard]] ctor get_ctor_with(std::initializer_list args) const noexcept; + [[nodiscard]] constructor get_constructor_with(Iter first, Iter last) const noexcept; + [[nodiscard]] constructor get_constructor_with(const std::vector& args) const noexcept; + [[nodiscard]] constructor get_constructor_with(std::initializer_list args) const noexcept; template < typename... Args > [[nodiscard]] function get_function_with(std::string_view name) const noexcept; @@ -206,41 +206,41 @@ namespace meta_hpp friend auto detail::type_access(const class_type&); }; - class ctor_type final { + class constructor_type final { public: - ctor_type() = default; - ctor_type(detail::ctor_type_data_ptr data); + constructor_type() = default; + constructor_type(detail::constructor_type_data_ptr data); [[nodiscard]] bool is_valid() const noexcept; [[nodiscard]] explicit operator bool() const noexcept; [[nodiscard]] type_id get_id() const noexcept; - [[nodiscard]] ctor_bitflags get_flags() const noexcept; + [[nodiscard]] constructor_bitflags get_flags() const noexcept; [[nodiscard]] std::size_t get_arity() const noexcept; [[nodiscard]] any_type get_class_type() const noexcept; [[nodiscard]] any_type get_argument_type(std::size_t position) const noexcept; [[nodiscard]] const std::vector& get_argument_types() const noexcept; private: - detail::ctor_type_data_ptr data_; - friend auto detail::type_access(const ctor_type&); + detail::constructor_type_data_ptr data_; + friend auto detail::type_access(const constructor_type&); }; - class dtor_type final { + class destructor_type final { public: - dtor_type() = default; - dtor_type(detail::dtor_type_data_ptr data); + destructor_type() = default; + destructor_type(detail::destructor_type_data_ptr data); [[nodiscard]] bool is_valid() const noexcept; [[nodiscard]] explicit operator bool() const noexcept; [[nodiscard]] type_id get_id() const noexcept; - [[nodiscard]] dtor_bitflags get_flags() const noexcept; + [[nodiscard]] destructor_bitflags get_flags() const noexcept; [[nodiscard]] any_type get_class_type() const noexcept; private: - detail::dtor_type_data_ptr data_; - friend auto detail::type_access(const dtor_type&); + detail::destructor_type_data_ptr data_; + friend auto detail::type_access(const destructor_type&); }; class enum_type final { @@ -466,8 +466,8 @@ namespace meta_hpp::detail const std::size_t size; const std::vector argument_types; - ctor_map ctors; - dtor_map dtors; + constructor_map constructors; + destructor_map destructors; class_set bases; function_map functions; member_map members; @@ -486,21 +486,21 @@ namespace meta_hpp::detail explicit class_type_data(type_list); }; - struct ctor_type_data final : type_data_base { - const ctor_bitflags flags; + struct constructor_type_data final : type_data_base { + const constructor_bitflags flags; const any_type class_type; const std::vector argument_types; template < class_kind Class, typename... Args > - explicit ctor_type_data(type_list, type_list); + explicit constructor_type_data(type_list, type_list); }; - struct dtor_type_data final : type_data_base { - const dtor_bitflags flags; + struct destructor_type_data final : type_data_base { + const destructor_bitflags flags; const any_type class_type; template < class_kind Class > - explicit dtor_type_data(type_list); + explicit destructor_type_data(type_list); }; struct enum_type_data final : type_data_base { diff --git a/headers/meta.hpp/meta_types/any_type.hpp b/headers/meta.hpp/meta_types/any_type.hpp index b94a4cf..ff42971 100644 --- a/headers/meta.hpp/meta_types/any_type.hpp +++ b/headers/meta.hpp/meta_types/any_type.hpp @@ -33,10 +33,10 @@ namespace meta_hpp inline any_type::any_type(const class_type& other) noexcept : data_{detail::type_access(other)} {} - inline any_type::any_type(const ctor_type& other) noexcept + inline any_type::any_type(const constructor_type& other) noexcept : data_{detail::type_access(other)} {} - inline any_type::any_type(const dtor_type& other) noexcept + inline any_type::any_type(const destructor_type& other) noexcept : data_{detail::type_access(other)} {} inline any_type::any_type(const enum_type& other) noexcept @@ -74,12 +74,12 @@ namespace meta_hpp return data_ && data_->kind == type_kind::class_; } - inline bool any_type::is_ctor() const noexcept { - return data_ && data_->kind == type_kind::ctor_; + inline bool any_type::is_constructor() const noexcept { + return data_ && data_->kind == type_kind::constructor_; } - inline bool any_type::is_dtor() const noexcept { - return data_ && data_->kind == type_kind::dtor_; + inline bool any_type::is_destructor() const noexcept { + return data_ && data_->kind == type_kind::destructor_; } inline bool any_type::is_enum() const noexcept { @@ -130,16 +130,16 @@ namespace meta_hpp : class_type{}; } - inline ctor_type any_type::as_ctor() const noexcept { - return is_ctor() - ? ctor_type{std::static_pointer_cast(data_)} - : ctor_type{}; + inline constructor_type any_type::as_constructor() const noexcept { + return is_constructor() + ? constructor_type{std::static_pointer_cast(data_)} + : constructor_type{}; } - inline dtor_type any_type::as_dtor() const noexcept { - return is_dtor() - ? dtor_type{std::static_pointer_cast(data_)} - : dtor_type{}; + inline destructor_type any_type::as_destructor() const noexcept { + return is_destructor() + ? destructor_type{std::static_pointer_cast(data_)} + : destructor_type{}; } inline enum_type any_type::as_enum() const noexcept { diff --git a/headers/meta.hpp/meta_types/class_type.hpp b/headers/meta.hpp/meta_types/class_type.hpp index 64e3dfc..9677349 100644 --- a/headers/meta.hpp/meta_types/class_type.hpp +++ b/headers/meta.hpp/meta_types/class_type.hpp @@ -9,7 +9,7 @@ #include "../meta_base.hpp" #include "../meta_types.hpp" -#include "../meta_states/ctor.hpp" +#include "../meta_states/constructor.hpp" #include "../meta_states/function.hpp" #include "../meta_states/member.hpp" #include "../meta_states/method.hpp" @@ -69,12 +69,12 @@ namespace meta_hpp return data_->argument_types; } - inline const ctor_map& class_type::get_ctors() const noexcept { - return data_->ctors; + inline const constructor_map& class_type::get_ctors() const noexcept { + return data_->constructors; } - inline const dtor_map& class_type::get_dtors() const noexcept { - return data_->dtors; + inline const destructor_map& class_type::get_dtors() const noexcept { + return data_->destructors; } inline const class_set& class_type::get_bases() const noexcept { @@ -99,7 +99,7 @@ namespace meta_hpp template < typename... Args > uvalue class_type::create(Args&&... args) const { - for ( auto&& ctor : data_->ctors ) { + for ( auto&& ctor : data_->constructors ) { if ( ctor.second.is_invocable_with(std::forward(args)...) ) { return ctor.second.invoke(std::forward(args)...); } @@ -114,7 +114,7 @@ namespace meta_hpp template < typename Arg > bool class_type::destroy(Arg&& ptr) const { - for ( auto&& dtor : data_->dtors ) { + for ( auto&& dtor : data_->destructors ) { if ( dtor.second.is_invocable_with(std::forward(ptr)) ) { dtor.second.invoke(std::forward(ptr)); return true; @@ -234,31 +234,31 @@ namespace meta_hpp } // - // get_ctor_with + // get_constructor_with // template < typename... Args > - ctor class_type::get_ctor_with() const noexcept { - return get_ctor_with({detail::resolve_type()...}); + constructor class_type::get_constructor_with() const noexcept { + return get_constructor_with({detail::resolve_type()...}); } template < typename Iter > - ctor class_type::get_ctor_with(Iter first, Iter last) const noexcept { - for ( auto&& [index, ctor] : data_->ctors ) { + constructor class_type::get_constructor_with(Iter first, Iter last) const noexcept { + for ( auto&& [index, ctor] : data_->constructors ) { const std::vector& args = ctor.get_type().get_argument_types(); if ( std::equal(first, last, args.begin(), args.end()) ) { return ctor; } } - return ctor{}; + return constructor{}; } - inline ctor class_type::get_ctor_with(const std::vector& args) const noexcept { - return get_ctor_with(args.begin(), args.end()); + inline constructor class_type::get_constructor_with(const std::vector& args) const noexcept { + return get_constructor_with(args.begin(), args.end()); } - inline ctor class_type::get_ctor_with(std::initializer_list args) const noexcept { - return get_ctor_with(args.begin(), args.end()); + inline constructor class_type::get_constructor_with(std::initializer_list args) const noexcept { + return get_constructor_with(args.begin(), args.end()); } // diff --git a/headers/meta.hpp/meta_types/constructor_type.hpp b/headers/meta.hpp/meta_types/constructor_type.hpp new file mode 100644 index 0000000..8baacf3 --- /dev/null +++ b/headers/meta.hpp/meta_types/constructor_type.hpp @@ -0,0 +1,65 @@ +/******************************************************************************* + * This file is part of the "https://github.com/blackmatov/meta.hpp" + * For conditions of distribution and use, see copyright notice in LICENSE.md + * Copyright (C) 2021, by Matvey Cherevko (blackmatov@gmail.com) + ******************************************************************************/ + +#pragma once + +#include "../meta_base.hpp" +#include "../meta_types.hpp" + +#include "../meta_detail/type_registry.hpp" +#include "../meta_detail/type_traits/constructor_traits.hpp" + +namespace meta_hpp::detail +{ + template < class_kind Class, typename... Args > + struct constructor_tag {}; + + template < class_kind Class, typename... Args > + // NOLINTNEXTLINE(readability-named-parameter) + constructor_type_data::constructor_type_data(type_list, type_list) + : type_data_base{type_id{type_list>{}}, type_kind::constructor_} + , flags{constructor_traits::make_flags()} + , class_type{resolve_type::class_type>()} + , argument_types{resolve_types(typename constructor_traits::argument_types{})} {} +} + +namespace meta_hpp +{ + inline constructor_type::constructor_type(detail::constructor_type_data_ptr data) + : data_{std::move(data)} {} + + inline bool constructor_type::is_valid() const noexcept { + return !!data_; + } + + inline constructor_type::operator bool() const noexcept { + return is_valid(); + } + + inline type_id constructor_type::get_id() const noexcept { + return data_->id; + } + + inline constructor_bitflags constructor_type::get_flags() const noexcept { + return data_->flags; + } + + inline std::size_t constructor_type::get_arity() const noexcept { + return data_->argument_types.size(); + } + + inline any_type constructor_type::get_class_type() const noexcept { + return data_->class_type; + } + + inline any_type constructor_type::get_argument_type(std::size_t position) const noexcept { + return position < data_->argument_types.size() ? data_->argument_types[position] : any_type{}; + } + + inline const std::vector& constructor_type::get_argument_types() const noexcept { + return data_->argument_types; + } +} diff --git a/headers/meta.hpp/meta_types/ctor_type.hpp b/headers/meta.hpp/meta_types/ctor_type.hpp deleted file mode 100644 index c525f2e..0000000 --- a/headers/meta.hpp/meta_types/ctor_type.hpp +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * This file is part of the "https://github.com/blackmatov/meta.hpp" - * For conditions of distribution and use, see copyright notice in LICENSE.md - * Copyright (C) 2021, by Matvey Cherevko (blackmatov@gmail.com) - ******************************************************************************/ - -#pragma once - -#include "../meta_base.hpp" -#include "../meta_types.hpp" - -#include "../meta_detail/type_registry.hpp" -#include "../meta_detail/type_traits/ctor_traits.hpp" - -namespace meta_hpp::detail -{ - template < class_kind Class, typename... Args > - struct ctor_tag {}; - - template < class_kind Class, typename... Args > - // NOLINTNEXTLINE(readability-named-parameter) - ctor_type_data::ctor_type_data(type_list, type_list) - : type_data_base{type_id{type_list>{}}, type_kind::ctor_} - , flags{ctor_traits::make_flags()} - , class_type{resolve_type::class_type>()} - , argument_types{resolve_types(typename ctor_traits::argument_types{})} {} -} - -namespace meta_hpp -{ - inline ctor_type::ctor_type(detail::ctor_type_data_ptr data) - : data_{std::move(data)} {} - - inline bool ctor_type::is_valid() const noexcept { - return !!data_; - } - - inline ctor_type::operator bool() const noexcept { - return is_valid(); - } - - inline type_id ctor_type::get_id() const noexcept { - return data_->id; - } - - inline ctor_bitflags ctor_type::get_flags() const noexcept { - return data_->flags; - } - - inline std::size_t ctor_type::get_arity() const noexcept { - return data_->argument_types.size(); - } - - inline any_type ctor_type::get_class_type() const noexcept { - return data_->class_type; - } - - inline any_type ctor_type::get_argument_type(std::size_t position) const noexcept { - return position < data_->argument_types.size() ? data_->argument_types[position] : any_type{}; - } - - inline const std::vector& ctor_type::get_argument_types() const noexcept { - return data_->argument_types; - } -} diff --git a/headers/meta.hpp/meta_types/dtor_type.hpp b/headers/meta.hpp/meta_types/destructor_type.hpp similarity index 52% rename from headers/meta.hpp/meta_types/dtor_type.hpp rename to headers/meta.hpp/meta_types/destructor_type.hpp index d0dbc02..3517003 100644 --- a/headers/meta.hpp/meta_types/dtor_type.hpp +++ b/headers/meta.hpp/meta_types/destructor_type.hpp @@ -10,43 +10,43 @@ #include "../meta_types.hpp" #include "../meta_detail/type_registry.hpp" -#include "../meta_detail/type_traits/dtor_traits.hpp" +#include "../meta_detail/type_traits/destructor_traits.hpp" namespace meta_hpp::detail { template < class_kind Class > - struct dtor_tag {}; + struct destructor_tag {}; template < class_kind Class > // NOLINTNEXTLINE(readability-named-parameter) - dtor_type_data::dtor_type_data(type_list) - : type_data_base{type_id{type_list>{}}, type_kind::dtor_} - , flags{dtor_traits::make_flags()} - , class_type{resolve_type::class_type>()} {} + destructor_type_data::destructor_type_data(type_list) + : type_data_base{type_id{type_list>{}}, type_kind::destructor_} + , flags{destructor_traits::make_flags()} + , class_type{resolve_type::class_type>()} {} } namespace meta_hpp { - inline dtor_type::dtor_type(detail::dtor_type_data_ptr data) + inline destructor_type::destructor_type(detail::destructor_type_data_ptr data) : data_{std::move(data)} {} - inline bool dtor_type::is_valid() const noexcept { + inline bool destructor_type::is_valid() const noexcept { return !!data_; } - inline dtor_type::operator bool() const noexcept { + inline destructor_type::operator bool() const noexcept { return is_valid(); } - inline type_id dtor_type::get_id() const noexcept { + inline type_id destructor_type::get_id() const noexcept { return data_->id; } - inline dtor_bitflags dtor_type::get_flags() const noexcept { + inline destructor_bitflags destructor_type::get_flags() const noexcept { return data_->flags; } - inline any_type dtor_type::get_class_type() const noexcept { + inline any_type destructor_type::get_class_type() const noexcept { return data_->class_type; } } diff --git a/manuals/meta_examples/classes_example.cpp b/manuals/meta_examples/classes_example.cpp index a969a21..83395d5 100644 --- a/manuals/meta_examples/classes_example.cpp +++ b/manuals/meta_examples/classes_example.cpp @@ -47,7 +47,7 @@ TEST_CASE("meta/meta_examples/classes/type") { // 'rectangle' class type registration meta::class_() .base_() - .ctor_() + .constructor_() .method_("get_width", &rectangle::get_width) .method_("get_height", &rectangle::get_height); diff --git a/manuals/meta_examples/functions_example.cpp b/manuals/meta_examples/functions_example.cpp index 0008a3c..c4c6dd0 100644 --- a/manuals/meta_examples/functions_example.cpp +++ b/manuals/meta_examples/functions_example.cpp @@ -54,7 +54,7 @@ TEST_CASE("meta/meta_examples/functions/usage") { // checks a type of the founded function CHECK(sub_function.get_type() == meta::resolve_type()); - // checks the ability to call the function with specific parameters + // checks the ability to call the function with specific arguments CHECK(sub_function.is_invocable_with(60, 18)); CHECK(sub_function.is_invocable_with()); diff --git a/manuals/meta_examples/methods_example.cpp b/manuals/meta_examples/methods_example.cpp index a9957ec..be68952 100644 --- a/manuals/meta_examples/methods_example.cpp +++ b/manuals/meta_examples/methods_example.cpp @@ -64,7 +64,7 @@ TEST_CASE("meta/meta_examples/methods/usage") { // checks the type of the method 'add' CHECK(ivec2_add.get_type() == meta::resolve_type()); - // checks the ability to call the method with specific parameters + // checks the ability to call the method with specific arguments CHECK(ivec2_add.is_invocable_with(v, ivec2{22, 11})); CHECK(ivec2_add.is_invocable_with()); diff --git a/untests/meta_states/ctor_tests.cpp b/untests/meta_states/ctor_tests.cpp index f5a223f..2f0d9a1 100644 --- a/untests/meta_states/ctor_tests.cpp +++ b/untests/meta_states/ctor_tests.cpp @@ -14,75 +14,75 @@ namespace clazz(int i) : i{i} { - ++ctor_counter; + ++constructor_counter; } clazz(clazz&& other) : i{other.i} { other.i = 0; - ++move_ctor_counter; + ++move_constructor_counter; } clazz(const clazz& other) : i{other.i} { - ++copy_ctor_counter; + ++copy_constructor_counter; } clazz& operator=(clazz&& other) = delete; clazz& operator=(const clazz& other) = delete; ~clazz() { - ++dtor_counter; + ++destructor_counter; } public: - static int ctor_counter; - static int dtor_counter; - static int move_ctor_counter; - static int copy_ctor_counter; + static int constructor_counter; + static int destructor_counter; + static int move_constructor_counter; + static int copy_constructor_counter; }; template < std::size_t N > - int clazz::ctor_counter{0}; + int clazz::constructor_counter{0}; template < std::size_t N > - int clazz::dtor_counter{0}; + int clazz::destructor_counter{0}; template < std::size_t N > - int clazz::move_ctor_counter{0}; + int clazz::move_constructor_counter{0}; template < std::size_t N > - int clazz::copy_ctor_counter{0}; + int clazz::copy_constructor_counter{0}; } TEST_CASE("meta/meta_states/ctor") { namespace meta = meta_hpp; meta::class_>() - .ctor_(meta::ctor_policy::as_object{}) - .dtor_(); + .constructor_(meta::constructor_policy::as_object{}) + .destructor_(); meta::class_>() - .ctor_(meta::ctor_policy::as_raw_pointer{}) - .dtor_(); + .constructor_(meta::constructor_policy::as_raw_pointer{}) + .destructor_(); meta::class_>() - .ctor_(meta::ctor_policy::as_shared_pointer{}) - .dtor_(); + .constructor_(meta::constructor_policy::as_shared_pointer{}) + .destructor_(); - clazz<1>::ctor_counter = 0; - clazz<1>::dtor_counter = 0; - clazz<1>::move_ctor_counter = 0; - clazz<1>::copy_ctor_counter = 0; + clazz<1>::constructor_counter = 0; + clazz<1>::destructor_counter = 0; + clazz<1>::move_constructor_counter = 0; + clazz<1>::copy_constructor_counter = 0; - clazz<2>::ctor_counter = 0; - clazz<2>::dtor_counter = 0; - clazz<2>::move_ctor_counter = 0; - clazz<2>::copy_ctor_counter = 0; + clazz<2>::constructor_counter = 0; + clazz<2>::destructor_counter = 0; + clazz<2>::move_constructor_counter = 0; + clazz<2>::copy_constructor_counter = 0; - clazz<3>::ctor_counter = 0; - clazz<3>::dtor_counter = 0; - clazz<3>::move_ctor_counter = 0; - clazz<3>::copy_ctor_counter = 0; + clazz<3>::constructor_counter = 0; + clazz<3>::destructor_counter = 0; + clazz<3>::move_constructor_counter = 0; + clazz<3>::copy_constructor_counter = 0; SUBCASE("clazz<1>") { const meta::class_type clazz_type = meta::resolve_type>(); @@ -98,10 +98,10 @@ TEST_CASE("meta/meta_states/ctor") { CHECK(clazz_type.destroy(meta::uvalue{nullptr})); } - CHECK(clazz<1>::ctor_counter == 1); - CHECK(clazz<1>::dtor_counter == 2); - CHECK(clazz<1>::move_ctor_counter == 1); - CHECK(clazz<1>::copy_ctor_counter == 0); + CHECK(clazz<1>::constructor_counter == 1); + CHECK(clazz<1>::destructor_counter == 2); + CHECK(clazz<1>::move_constructor_counter == 1); + CHECK(clazz<1>::copy_constructor_counter == 0); } SUBCASE("clazz<2>") { @@ -119,10 +119,10 @@ TEST_CASE("meta/meta_states/ctor") { CHECK(clazz_type.destroy(meta::uvalue{nullptr})); } - CHECK(clazz<2>::ctor_counter == 1); - CHECK(clazz<2>::dtor_counter == 1); - CHECK(clazz<2>::move_ctor_counter == 0); - CHECK(clazz<2>::copy_ctor_counter == 0); + CHECK(clazz<2>::constructor_counter == 1); + CHECK(clazz<2>::destructor_counter == 1); + CHECK(clazz<2>::move_constructor_counter == 0); + CHECK(clazz<2>::copy_constructor_counter == 0); } SUBCASE("clazz<3>") { @@ -139,9 +139,9 @@ TEST_CASE("meta/meta_states/ctor") { CHECK(clazz_type.destroy(meta::uvalue{nullptr})); } - CHECK(clazz<3>::ctor_counter == 1); - CHECK(clazz<3>::dtor_counter == 1); - CHECK(clazz<3>::move_ctor_counter == 0); - CHECK(clazz<3>::copy_ctor_counter == 0); + CHECK(clazz<3>::constructor_counter == 1); + CHECK(clazz<3>::destructor_counter == 1); + CHECK(clazz<3>::move_constructor_counter == 0); + CHECK(clazz<3>::copy_constructor_counter == 0); } } diff --git a/untests/meta_states/function2_tests.cpp b/untests/meta_states/function2_tests.cpp index ab76043..af4f62c 100644 --- a/untests/meta_states/function2_tests.cpp +++ b/untests/meta_states/function2_tests.cpp @@ -36,37 +36,37 @@ TEST_CASE("meta/meta_states/function2") { const meta::function func = ivec2_type.get_function("iadd"); REQUIRE(func); - CHECK(func.get_parameters().size() == 2); + CHECK(func.get_arguments().size() == 2); - REQUIRE(func.get_parameter(0)); - CHECK(func.get_parameter(0).get_type() == meta::resolve_type()); - CHECK(func.get_parameter(0).get_position() == 0); - CHECK(func.get_parameter(0).get_name() == "l"); + REQUIRE(func.get_argument(0)); + CHECK(func.get_argument(0).get_type() == meta::resolve_type()); + CHECK(func.get_argument(0).get_position() == 0); + CHECK(func.get_argument(0).get_name() == "l"); - REQUIRE(func.get_parameter(1)); - CHECK(func.get_parameter(1).get_type() == meta::resolve_type()); - CHECK(func.get_parameter(1).get_position() == 1); - CHECK(func.get_parameter(1).get_name() == ""); + REQUIRE(func.get_argument(1)); + CHECK(func.get_argument(1).get_type() == meta::resolve_type()); + CHECK(func.get_argument(1).get_position() == 1); + CHECK(func.get_argument(1).get_name() == ""); - CHECK_FALSE(func.get_parameter(2)); + CHECK_FALSE(func.get_argument(2)); } SUBCASE("isub2") { const meta::function func = ivec2_type.get_function("isub"); REQUIRE(func); - REQUIRE(func.get_parameters().size() == 2); + REQUIRE(func.get_arguments().size() == 2); - REQUIRE(func.get_parameter(0)); - CHECK(func.get_parameter(0).get_type() == meta::resolve_type()); - CHECK(func.get_parameter(0).get_position() == 0); - CHECK(func.get_parameter(0).get_name() == "l"); + REQUIRE(func.get_argument(0)); + CHECK(func.get_argument(0).get_type() == meta::resolve_type()); + CHECK(func.get_argument(0).get_position() == 0); + CHECK(func.get_argument(0).get_name() == "l"); - REQUIRE(func.get_parameter(1)); - CHECK(func.get_parameter(1).get_type() == meta::resolve_type()); - CHECK(func.get_parameter(1).get_position() == 1); - CHECK(func.get_parameter(1).get_name() == "r"); + REQUIRE(func.get_argument(1)); + CHECK(func.get_argument(1).get_type() == meta::resolve_type()); + CHECK(func.get_argument(1).get_position() == 1); + CHECK(func.get_argument(1).get_name() == "r"); - CHECK_FALSE(func.get_parameter(2)); + CHECK_FALSE(func.get_argument(2)); } } diff --git a/untests/meta_states/method2_tests.cpp b/untests/meta_states/method2_tests.cpp index a5ffbad..d7216b6 100644 --- a/untests/meta_states/method2_tests.cpp +++ b/untests/meta_states/method2_tests.cpp @@ -33,13 +33,13 @@ TEST_CASE("meta/meta_states/method2") { const meta::method add_m = ivec2_type.get_method("add"); REQUIRE(add_m); - CHECK(add_m.get_parameters().size() == 1); + CHECK(add_m.get_arguments().size() == 1); - REQUIRE(add_m.get_parameter(0)); - CHECK(add_m.get_parameter(0).get_type() == meta::resolve_type()); - CHECK(add_m.get_parameter(0).get_position() == 0); - CHECK(add_m.get_parameter(0).get_name() == "other"); + REQUIRE(add_m.get_argument(0)); + CHECK(add_m.get_argument(0).get_type() == meta::resolve_type()); + CHECK(add_m.get_argument(0).get_position() == 0); + CHECK(add_m.get_argument(0).get_name() == "other"); - CHECK_FALSE(add_m.get_parameter(1)); + CHECK_FALSE(add_m.get_argument(1)); } } diff --git a/untests/meta_states/scope_tests.cpp b/untests/meta_states/scope_tests.cpp index da8be1b..7664c6b 100644 --- a/untests/meta_states/scope_tests.cpp +++ b/untests/meta_states/scope_tests.cpp @@ -97,38 +97,38 @@ TEST_CASE("meta/meta_states/scope") { REQUIRE(iadd2_func); { - CHECK(iadd2_func.get_parameters().size() == 2); + CHECK(iadd2_func.get_arguments().size() == 2); - REQUIRE(iadd2_func.get_parameter(0)); - CHECK(iadd2_func.get_parameter(0).get_type() == meta::resolve_type()); - CHECK(iadd2_func.get_parameter(0).get_position() == 0); - CHECK(iadd2_func.get_parameter(0).get_name() == "l"); + REQUIRE(iadd2_func.get_argument(0)); + CHECK(iadd2_func.get_argument(0).get_type() == meta::resolve_type()); + CHECK(iadd2_func.get_argument(0).get_position() == 0); + CHECK(iadd2_func.get_argument(0).get_name() == "l"); - REQUIRE(iadd2_func.get_parameter(1)); - CHECK(iadd2_func.get_parameter(1).get_type() == meta::resolve_type()); - CHECK(iadd2_func.get_parameter(1).get_position() == 1); - CHECK(iadd2_func.get_parameter(1).get_name() == "r"); + REQUIRE(iadd2_func.get_argument(1)); + CHECK(iadd2_func.get_argument(1).get_type() == meta::resolve_type()); + CHECK(iadd2_func.get_argument(1).get_position() == 1); + CHECK(iadd2_func.get_argument(1).get_name() == "r"); - CHECK_FALSE(iadd2_func.get_parameter(2)); + CHECK_FALSE(iadd2_func.get_argument(2)); } const meta::function iadd3_func = math_scope.get_function("iadd3"); REQUIRE(iadd3_func); { - CHECK(iadd3_func.get_parameters().size() == 2); + CHECK(iadd3_func.get_arguments().size() == 2); - REQUIRE(iadd3_func.get_parameter(0)); - CHECK(iadd3_func.get_parameter(0).get_type() == meta::resolve_type()); - CHECK(iadd3_func.get_parameter(0).get_position() == 0); - CHECK(iadd3_func.get_parameter(0).get_name() == "l"); + REQUIRE(iadd3_func.get_argument(0)); + CHECK(iadd3_func.get_argument(0).get_type() == meta::resolve_type()); + CHECK(iadd3_func.get_argument(0).get_position() == 0); + CHECK(iadd3_func.get_argument(0).get_name() == "l"); - REQUIRE(iadd3_func.get_parameter(1)); - CHECK(iadd3_func.get_parameter(1).get_type() == meta::resolve_type()); - CHECK(iadd3_func.get_parameter(1).get_position() == 1); - CHECK(iadd3_func.get_parameter(1).get_name() == ""); + REQUIRE(iadd3_func.get_argument(1)); + CHECK(iadd3_func.get_argument(1).get_type() == meta::resolve_type()); + CHECK(iadd3_func.get_argument(1).get_position() == 1); + CHECK(iadd3_func.get_argument(1).get_name() == ""); - CHECK_FALSE(iadd3_func.get_parameter(2)); + CHECK_FALSE(iadd3_func.get_argument(2)); } } diff --git a/untests/meta_types/any_type_tests.cpp b/untests/meta_types/any_type_tests.cpp index 2bf6c88..256107d 100644 --- a/untests/meta_types/any_type_tests.cpp +++ b/untests/meta_types/any_type_tests.cpp @@ -32,8 +32,8 @@ TEST_CASE("meta/meta_types/any_type") { namespace meta = meta_hpp; meta::class_() - .ctor_<>() - .ctor_(); + .constructor_<>() + .constructor_(); SUBCASE("") { const meta::any_type type{}; @@ -72,8 +72,8 @@ TEST_CASE("meta/meta_types/any_type") { CHECK(type.is_class()); CHECK(type.get_kind() == meta::type_kind::class_); - CHECK_FALSE(type.is_ctor()); - CHECK_FALSE(type.as_ctor()); + CHECK_FALSE(type.is_constructor()); + CHECK_FALSE(type.as_constructor()); const meta::class_type& specific_type = type.as_class(); REQUIRE(specific_type); @@ -82,18 +82,18 @@ TEST_CASE("meta/meta_types/any_type") { SUBCASE("ctor") { const meta::any_type& type = meta::resolve_type() - .get_ctor_with<>() + .get_constructor_with<>() .get_type(); REQUIRE(type); - CHECK(type.is_ctor()); - CHECK(type.get_kind() == meta::type_kind::ctor_); + CHECK(type.is_constructor()); + CHECK(type.get_kind() == meta::type_kind::constructor_); CHECK_FALSE(type.is_enum()); CHECK_FALSE(type.as_enum()); - const meta::ctor_type& specific_type = type.as_ctor(); + const meta::constructor_type& specific_type = type.as_constructor(); REQUIRE(specific_type); CHECK(specific_type.get_id() == type.get_id()); } diff --git a/untests/meta_types/class_type_tests.cpp b/untests/meta_types/class_type_tests.cpp index f09cf03..aac9d81 100644 --- a/untests/meta_types/class_type_tests.cpp +++ b/untests/meta_types/class_type_tests.cpp @@ -62,7 +62,7 @@ TEST_CASE("meta/meta_types/class_type") { namespace meta = meta_hpp; meta::class_() - .ctor_() + .constructor_() .member_("base_member_1", &base_clazz_1::base_member_1) .method_("base_method_1", &base_clazz_1::base_method_1) .function_("base_function_1", &base_clazz_1::base_function_1) @@ -73,14 +73,14 @@ TEST_CASE("meta/meta_types/class_type") { .variable_("base_variable_1", &base_clazz_1::base_variable_1); meta::class_() - .ctor_() + .constructor_() .member_("base_member_2", &base_clazz_2::base_member_2) .method_("base_method_2", &base_clazz_2::base_method_2) .function_("base_function_2", &base_clazz_2::base_function_2) .variable_("base_variable_2", &base_clazz_2::base_variable_2); meta::class_() - .ctor_() + .constructor_() .base_() .base_() .member_("derived_member", &derived_clazz::derived_member) @@ -89,7 +89,7 @@ TEST_CASE("meta/meta_types/class_type") { .variable_("derived_variable", &derived_clazz::derived_variable); meta::class_() - .ctor_() + .constructor_() .base_(); const meta::class_type base_clazz_1_type = meta::resolve_type(); @@ -368,23 +368,23 @@ TEST_CASE("meta/meta_types/class_type") { CHECK(derived_clazz_type.get_variable("derived_variable")); } - SUBCASE("get_ctor_with") { + SUBCASE("get_constructor_with") { { - CHECK_FALSE(base_clazz_1_type.get_ctor_with<>()); - CHECK(base_clazz_1_type.get_ctor_with()); - CHECK_FALSE(base_clazz_1_type.get_ctor_with()); + CHECK_FALSE(base_clazz_1_type.get_constructor_with<>()); + CHECK(base_clazz_1_type.get_constructor_with()); + CHECK_FALSE(base_clazz_1_type.get_constructor_with()); } { - CHECK_FALSE(base_clazz_2_type.get_ctor_with<>()); - CHECK_FALSE(base_clazz_2_type.get_ctor_with()); - CHECK(base_clazz_2_type.get_ctor_with()); + CHECK_FALSE(base_clazz_2_type.get_constructor_with<>()); + CHECK_FALSE(base_clazz_2_type.get_constructor_with()); + CHECK(base_clazz_2_type.get_constructor_with()); } { - CHECK_FALSE(derived_clazz_type.get_ctor_with<>()); - CHECK_FALSE(derived_clazz_type.get_ctor_with()); - CHECK_FALSE(derived_clazz_type.get_ctor_with()); - CHECK(derived_clazz_type.get_ctor_with()); - CHECK_FALSE(derived_clazz_type.get_ctor_with()); + CHECK_FALSE(derived_clazz_type.get_constructor_with<>()); + CHECK_FALSE(derived_clazz_type.get_constructor_with()); + CHECK_FALSE(derived_clazz_type.get_constructor_with()); + CHECK(derived_clazz_type.get_constructor_with()); + CHECK_FALSE(derived_clazz_type.get_constructor_with()); } } diff --git a/untests/meta_utilities/value2_tests.cpp b/untests/meta_utilities/value2_tests.cpp index d98d9dc..8f08c37 100644 --- a/untests/meta_utilities/value2_tests.cpp +++ b/untests/meta_utilities/value2_tests.cpp @@ -21,25 +21,25 @@ namespace , y{other.y} { other.x = 0; other.y = 0; - ++move_ctor_counter; + ++move_constructor_counter; } ivec2(const ivec2& other) noexcept : x{other.x} , y{other.y} { - ++copy_ctor_counter; + ++copy_constructor_counter; } ~ivec2() noexcept { - ++dtor_counter; + ++destructor_counter; } ivec2& operator=(ivec2&& other) = delete; ivec2& operator=(const ivec2& other) = delete; - static int dtor_counter; - static int move_ctor_counter; - static int copy_ctor_counter; + static int destructor_counter; + static int move_constructor_counter; + static int copy_constructor_counter; }; struct ivec2_big final { @@ -57,25 +57,25 @@ namespace , y{other.y} { other.x = 0; other.y = 0; - ++move_ctor_counter; + ++move_constructor_counter; } ivec2_big(const ivec2_big& other) noexcept : x{other.x} , y{other.y} { - ++copy_ctor_counter; + ++copy_constructor_counter; } ~ivec2_big() noexcept { - ++dtor_counter; + ++destructor_counter; } ivec2_big& operator=(ivec2_big&& other) = delete; ivec2_big& operator=(const ivec2_big& other) = delete; - static int dtor_counter; - static int move_ctor_counter; - static int copy_ctor_counter; + static int destructor_counter; + static int move_constructor_counter; + static int copy_constructor_counter; }; [[maybe_unused]] bool operator==(const ivec2& l, const ivec2& r) noexcept { @@ -86,31 +86,31 @@ namespace return l.x == r.x && l.y == r.y; } - int ivec2::dtor_counter{0}; - int ivec2::move_ctor_counter{0}; - int ivec2::copy_ctor_counter{0}; + int ivec2::destructor_counter{0}; + int ivec2::move_constructor_counter{0}; + int ivec2::copy_constructor_counter{0}; - int ivec2_big::dtor_counter{0}; - int ivec2_big::move_ctor_counter{0}; - int ivec2_big::copy_ctor_counter{0}; + int ivec2_big::destructor_counter{0}; + int ivec2_big::move_constructor_counter{0}; + int ivec2_big::copy_constructor_counter{0}; } TEST_CASE("meta/meta_utilities/value2") { namespace meta = meta_hpp; meta::class_() - .ctor_() - .ctor_() - .ctor_() - .ctor_() + .constructor_() + .constructor_() + .constructor_() + .constructor_() .member_("x", &ivec2::x) .member_("y", &ivec2::y); meta::class_() - .ctor_() - .ctor_() - .ctor_() - .ctor_() + .constructor_() + .constructor_() + .constructor_() + .constructor_() .member_("x", &ivec2_big::x) .member_("y", &ivec2_big::y); } @@ -118,32 +118,32 @@ TEST_CASE("meta/meta_utilities/value2") { TEST_CASE("meta/meta_utilities/value2/counters/small") { namespace meta = meta_hpp; - ivec2::dtor_counter = 0; - ivec2::move_ctor_counter = 0; - ivec2::copy_ctor_counter = 0; + ivec2::destructor_counter = 0; + ivec2::move_constructor_counter = 0; + ivec2::copy_constructor_counter = 0; SUBCASE("def ctor") { { meta::uvalue v{}; - CHECK(ivec2::dtor_counter == 0); - CHECK(ivec2::move_ctor_counter == 0); - CHECK(ivec2::copy_ctor_counter == 0); + CHECK(ivec2::destructor_counter == 0); + CHECK(ivec2::move_constructor_counter == 0); + CHECK(ivec2::copy_constructor_counter == 0); } - CHECK(ivec2::dtor_counter == 0); - CHECK(ivec2::move_ctor_counter == 0); - CHECK(ivec2::copy_ctor_counter == 0); + CHECK(ivec2::destructor_counter == 0); + CHECK(ivec2::move_constructor_counter == 0); + CHECK(ivec2::copy_constructor_counter == 0); } SUBCASE("val ctor") { { meta::uvalue v{ivec2{1,2}}; - CHECK(ivec2::dtor_counter == 1); - CHECK(ivec2::move_ctor_counter == 1); - CHECK(ivec2::copy_ctor_counter == 0); + CHECK(ivec2::destructor_counter == 1); + CHECK(ivec2::move_constructor_counter == 1); + CHECK(ivec2::copy_constructor_counter == 0); } - CHECK(ivec2::dtor_counter == 2); - CHECK(ivec2::move_ctor_counter == 1); - CHECK(ivec2::copy_ctor_counter == 0); + CHECK(ivec2::destructor_counter == 2); + CHECK(ivec2::move_constructor_counter == 1); + CHECK(ivec2::copy_constructor_counter == 0); } SUBCASE("move ctor") { @@ -154,13 +154,13 @@ TEST_CASE("meta/meta_utilities/value2/counters/small") { CHECK_FALSE(v1); CHECK(v2.cast().x == 1); - CHECK(ivec2::dtor_counter == 2); - CHECK(ivec2::move_ctor_counter == 2); - CHECK(ivec2::copy_ctor_counter == 0); + CHECK(ivec2::destructor_counter == 2); + CHECK(ivec2::move_constructor_counter == 2); + CHECK(ivec2::copy_constructor_counter == 0); } - CHECK(ivec2::dtor_counter == 3); - CHECK(ivec2::move_ctor_counter == 2); - CHECK(ivec2::copy_ctor_counter == 0); + CHECK(ivec2::destructor_counter == 3); + CHECK(ivec2::move_constructor_counter == 2); + CHECK(ivec2::copy_constructor_counter == 0); } SUBCASE("copy ctor") { @@ -171,66 +171,66 @@ TEST_CASE("meta/meta_utilities/value2/counters/small") { CHECK(v1.cast().x == 1); CHECK(v2.cast().y == 2); - CHECK(ivec2::dtor_counter == 1); - CHECK(ivec2::move_ctor_counter == 1); - CHECK(ivec2::copy_ctor_counter == 1); + CHECK(ivec2::destructor_counter == 1); + CHECK(ivec2::move_constructor_counter == 1); + CHECK(ivec2::copy_constructor_counter == 1); } - CHECK(ivec2::dtor_counter == 3); - CHECK(ivec2::move_ctor_counter == 1); - CHECK(ivec2::copy_ctor_counter == 1); + CHECK(ivec2::destructor_counter == 3); + CHECK(ivec2::move_constructor_counter == 1); + CHECK(ivec2::copy_constructor_counter == 1); } SUBCASE("swap") { { meta::uvalue v1{ivec2{1,2}}; meta::uvalue v2{ivec2{3,4}}; - CHECK(ivec2::dtor_counter == 2); - CHECK(ivec2::move_ctor_counter == 2); - CHECK(ivec2::copy_ctor_counter == 0); + CHECK(ivec2::destructor_counter == 2); + CHECK(ivec2::move_constructor_counter == 2); + CHECK(ivec2::copy_constructor_counter == 0); v1.swap(v2); CHECK(v1.cast().x == 3); CHECK(v2.cast().x == 1); - CHECK(ivec2::dtor_counter == 5); - CHECK(ivec2::move_ctor_counter == 5); - CHECK(ivec2::copy_ctor_counter == 0); + CHECK(ivec2::destructor_counter == 5); + CHECK(ivec2::move_constructor_counter == 5); + CHECK(ivec2::copy_constructor_counter == 0); } - CHECK(ivec2::dtor_counter == 7); - CHECK(ivec2::move_ctor_counter == 5); - CHECK(ivec2::copy_ctor_counter == 0); + CHECK(ivec2::destructor_counter == 7); + CHECK(ivec2::move_constructor_counter == 5); + CHECK(ivec2::copy_constructor_counter == 0); } } TEST_CASE("meta/meta_utilities/value2/counters/big") { namespace meta = meta_hpp; - ivec2_big::dtor_counter = 0; - ivec2_big::move_ctor_counter = 0; - ivec2_big::copy_ctor_counter = 0; + ivec2_big::destructor_counter = 0; + ivec2_big::move_constructor_counter = 0; + ivec2_big::copy_constructor_counter = 0; SUBCASE("def ctor") { { meta::uvalue v{}; - CHECK(ivec2_big::dtor_counter == 0); - CHECK(ivec2_big::move_ctor_counter == 0); - CHECK(ivec2_big::copy_ctor_counter == 0); + CHECK(ivec2_big::destructor_counter == 0); + CHECK(ivec2_big::move_constructor_counter == 0); + CHECK(ivec2_big::copy_constructor_counter == 0); } - CHECK(ivec2_big::dtor_counter == 0); - CHECK(ivec2_big::move_ctor_counter == 0); - CHECK(ivec2_big::copy_ctor_counter == 0); + CHECK(ivec2_big::destructor_counter == 0); + CHECK(ivec2_big::move_constructor_counter == 0); + CHECK(ivec2_big::copy_constructor_counter == 0); } SUBCASE("val ctor") { { meta::uvalue v{ivec2_big{1,2}}; - CHECK(ivec2_big::dtor_counter == 1); - CHECK(ivec2_big::move_ctor_counter == 1); - CHECK(ivec2_big::copy_ctor_counter == 0); + CHECK(ivec2_big::destructor_counter == 1); + CHECK(ivec2_big::move_constructor_counter == 1); + CHECK(ivec2_big::copy_constructor_counter == 0); } - CHECK(ivec2_big::dtor_counter == 2); - CHECK(ivec2_big::move_ctor_counter == 1); - CHECK(ivec2_big::copy_ctor_counter == 0); + CHECK(ivec2_big::destructor_counter == 2); + CHECK(ivec2_big::move_constructor_counter == 1); + CHECK(ivec2_big::copy_constructor_counter == 0); } SUBCASE("move ctor") { @@ -241,13 +241,13 @@ TEST_CASE("meta/meta_utilities/value2/counters/big") { CHECK_FALSE(v1); CHECK(v2.cast().x == 1); - CHECK(ivec2_big::dtor_counter == 1); - CHECK(ivec2_big::move_ctor_counter == 1); - CHECK(ivec2_big::copy_ctor_counter == 0); + CHECK(ivec2_big::destructor_counter == 1); + CHECK(ivec2_big::move_constructor_counter == 1); + CHECK(ivec2_big::copy_constructor_counter == 0); } - CHECK(ivec2_big::dtor_counter == 2); - CHECK(ivec2_big::move_ctor_counter == 1); - CHECK(ivec2_big::copy_ctor_counter == 0); + CHECK(ivec2_big::destructor_counter == 2); + CHECK(ivec2_big::move_constructor_counter == 1); + CHECK(ivec2_big::copy_constructor_counter == 0); } SUBCASE("copy ctor") { @@ -258,77 +258,77 @@ TEST_CASE("meta/meta_utilities/value2/counters/big") { CHECK(v1.cast().x == 1); CHECK(v2.cast().y == 2); - CHECK(ivec2_big::dtor_counter == 1); - CHECK(ivec2_big::move_ctor_counter == 1); - CHECK(ivec2_big::copy_ctor_counter == 1); + CHECK(ivec2_big::destructor_counter == 1); + CHECK(ivec2_big::move_constructor_counter == 1); + CHECK(ivec2_big::copy_constructor_counter == 1); } - CHECK(ivec2_big::dtor_counter == 3); - CHECK(ivec2_big::move_ctor_counter == 1); - CHECK(ivec2_big::copy_ctor_counter == 1); + CHECK(ivec2_big::destructor_counter == 3); + CHECK(ivec2_big::move_constructor_counter == 1); + CHECK(ivec2_big::copy_constructor_counter == 1); } SUBCASE("swap") { { meta::uvalue v1{ivec2_big{1,2}}; meta::uvalue v2{ivec2_big{3,4}}; - CHECK(ivec2_big::dtor_counter == 2); - CHECK(ivec2_big::move_ctor_counter == 2); - CHECK(ivec2_big::copy_ctor_counter == 0); + CHECK(ivec2_big::destructor_counter == 2); + CHECK(ivec2_big::move_constructor_counter == 2); + CHECK(ivec2_big::copy_constructor_counter == 0); v1.swap(v2); CHECK(v1.cast().x == 3); CHECK(v2.cast().x == 1); - CHECK(ivec2_big::dtor_counter == 2); - CHECK(ivec2_big::move_ctor_counter == 2); - CHECK(ivec2_big::copy_ctor_counter == 0); + CHECK(ivec2_big::destructor_counter == 2); + CHECK(ivec2_big::move_constructor_counter == 2); + CHECK(ivec2_big::copy_constructor_counter == 0); } - CHECK(ivec2_big::dtor_counter == 4); - CHECK(ivec2_big::move_ctor_counter == 2); - CHECK(ivec2_big::copy_ctor_counter == 0); + CHECK(ivec2_big::destructor_counter == 4); + CHECK(ivec2_big::move_constructor_counter == 2); + CHECK(ivec2_big::copy_constructor_counter == 0); } } TEST_CASE("meta/meta_utilities/value2/counters/swap") { namespace meta = meta_hpp; - ivec2::dtor_counter = 0; - ivec2::move_ctor_counter = 0; - ivec2::copy_ctor_counter = 0; + ivec2::destructor_counter = 0; + ivec2::move_constructor_counter = 0; + ivec2::copy_constructor_counter = 0; - ivec2_big::dtor_counter = 0; - ivec2_big::move_ctor_counter = 0; - ivec2_big::copy_ctor_counter = 0; + ivec2_big::destructor_counter = 0; + ivec2_big::move_constructor_counter = 0; + ivec2_big::copy_constructor_counter = 0; SUBCASE("empty/small") { { meta::uvalue v1{}; meta::uvalue v2{ivec2{1,2}}; - CHECK(ivec2::dtor_counter == 1); - CHECK(ivec2::move_ctor_counter == 1); - CHECK(ivec2::copy_ctor_counter == 0); + CHECK(ivec2::destructor_counter == 1); + CHECK(ivec2::move_constructor_counter == 1); + CHECK(ivec2::copy_constructor_counter == 0); v1.swap(v2); CHECK(v1.cast().x == 1); CHECK_FALSE(v2); - CHECK(ivec2::dtor_counter == 2); - CHECK(ivec2::move_ctor_counter == 2); - CHECK(ivec2::copy_ctor_counter == 0); + CHECK(ivec2::destructor_counter == 2); + CHECK(ivec2::move_constructor_counter == 2); + CHECK(ivec2::copy_constructor_counter == 0); v1.swap(v2); CHECK_FALSE(v1); CHECK(v2.cast().y == 2); - CHECK(ivec2::dtor_counter == 3); - CHECK(ivec2::move_ctor_counter == 3); - CHECK(ivec2::copy_ctor_counter == 0); + CHECK(ivec2::destructor_counter == 3); + CHECK(ivec2::move_constructor_counter == 3); + CHECK(ivec2::copy_constructor_counter == 0); } - CHECK(ivec2::dtor_counter == 4); - CHECK(ivec2::move_ctor_counter == 3); - CHECK(ivec2::copy_ctor_counter == 0); + CHECK(ivec2::destructor_counter == 4); + CHECK(ivec2::move_constructor_counter == 3); + CHECK(ivec2::copy_constructor_counter == 0); } SUBCASE("empty/big") { @@ -336,30 +336,30 @@ TEST_CASE("meta/meta_utilities/value2/counters/swap") { meta::uvalue v1{}; meta::uvalue v2{ivec2_big{3,4}}; - CHECK(ivec2_big::dtor_counter == 1); - CHECK(ivec2_big::move_ctor_counter == 1); - CHECK(ivec2_big::copy_ctor_counter == 0); + CHECK(ivec2_big::destructor_counter == 1); + CHECK(ivec2_big::move_constructor_counter == 1); + CHECK(ivec2_big::copy_constructor_counter == 0); v1.swap(v2); CHECK(v1.cast().x == 3); CHECK_FALSE(v2); - CHECK(ivec2_big::dtor_counter == 1); - CHECK(ivec2_big::move_ctor_counter == 1); - CHECK(ivec2_big::copy_ctor_counter == 0); + CHECK(ivec2_big::destructor_counter == 1); + CHECK(ivec2_big::move_constructor_counter == 1); + CHECK(ivec2_big::copy_constructor_counter == 0); v1.swap(v2); CHECK_FALSE(v1); CHECK(v2.cast().y == 4); - CHECK(ivec2_big::dtor_counter == 1); - CHECK(ivec2_big::move_ctor_counter == 1); - CHECK(ivec2_big::copy_ctor_counter == 0); + CHECK(ivec2_big::destructor_counter == 1); + CHECK(ivec2_big::move_constructor_counter == 1); + CHECK(ivec2_big::copy_constructor_counter == 0); } - CHECK(ivec2_big::dtor_counter == 2); - CHECK(ivec2_big::move_ctor_counter == 1); - CHECK(ivec2_big::copy_ctor_counter == 0); + CHECK(ivec2_big::destructor_counter == 2); + CHECK(ivec2_big::move_constructor_counter == 1); + CHECK(ivec2_big::copy_constructor_counter == 0); } SUBCASE("small/big") { @@ -367,45 +367,45 @@ TEST_CASE("meta/meta_utilities/value2/counters/swap") { meta::uvalue v1{ivec2{1,2}}; meta::uvalue v2{ivec2_big{3,4}}; - CHECK(ivec2::dtor_counter == 1); - CHECK(ivec2::move_ctor_counter == 1); - CHECK(ivec2::copy_ctor_counter == 0); + CHECK(ivec2::destructor_counter == 1); + CHECK(ivec2::move_constructor_counter == 1); + CHECK(ivec2::copy_constructor_counter == 0); - CHECK(ivec2_big::dtor_counter == 1); - CHECK(ivec2_big::move_ctor_counter == 1); - CHECK(ivec2_big::copy_ctor_counter == 0); + CHECK(ivec2_big::destructor_counter == 1); + CHECK(ivec2_big::move_constructor_counter == 1); + CHECK(ivec2_big::copy_constructor_counter == 0); v1.swap(v2); CHECK(v1.cast().x == 3); CHECK(v2.cast().x == 1); - CHECK(ivec2::dtor_counter == 2); - CHECK(ivec2::move_ctor_counter == 2); - CHECK(ivec2::copy_ctor_counter == 0); + CHECK(ivec2::destructor_counter == 2); + CHECK(ivec2::move_constructor_counter == 2); + CHECK(ivec2::copy_constructor_counter == 0); - CHECK(ivec2_big::dtor_counter == 1); - CHECK(ivec2_big::move_ctor_counter == 1); - CHECK(ivec2_big::copy_ctor_counter == 0); + CHECK(ivec2_big::destructor_counter == 1); + CHECK(ivec2_big::move_constructor_counter == 1); + CHECK(ivec2_big::copy_constructor_counter == 0); v1.swap(v2); CHECK(v1.cast().y == 2); CHECK(v2.cast().y == 4); - CHECK(ivec2::dtor_counter == 3); - CHECK(ivec2::move_ctor_counter == 3); - CHECK(ivec2::copy_ctor_counter == 0); + CHECK(ivec2::destructor_counter == 3); + CHECK(ivec2::move_constructor_counter == 3); + CHECK(ivec2::copy_constructor_counter == 0); - CHECK(ivec2_big::dtor_counter == 1); - CHECK(ivec2_big::move_ctor_counter == 1); - CHECK(ivec2_big::copy_ctor_counter == 0); + CHECK(ivec2_big::destructor_counter == 1); + CHECK(ivec2_big::move_constructor_counter == 1); + CHECK(ivec2_big::copy_constructor_counter == 0); } - CHECK(ivec2::dtor_counter == 4); - CHECK(ivec2::move_ctor_counter == 3); - CHECK(ivec2::copy_ctor_counter == 0); + CHECK(ivec2::destructor_counter == 4); + CHECK(ivec2::move_constructor_counter == 3); + CHECK(ivec2::copy_constructor_counter == 0); - CHECK(ivec2_big::dtor_counter == 2); - CHECK(ivec2_big::move_ctor_counter == 1); - CHECK(ivec2_big::copy_ctor_counter == 0); + CHECK(ivec2_big::destructor_counter == 2); + CHECK(ivec2_big::move_constructor_counter == 1); + CHECK(ivec2_big::copy_constructor_counter == 0); } } diff --git a/untests/meta_utilities/value_tests.cpp b/untests/meta_utilities/value_tests.cpp index 920e894..20b8321 100644 --- a/untests/meta_utilities/value_tests.cpp +++ b/untests/meta_utilities/value_tests.cpp @@ -21,13 +21,13 @@ namespace , y{other.y} { other.x = 0; other.y = 0; - ++move_ctor_counter; + ++move_constructor_counter; } ivec2(const ivec2& other) noexcept : x{other.x} , y{other.y} { - ++copy_ctor_counter; + ++copy_constructor_counter; } ivec2& add(const ivec2& other) { @@ -39,8 +39,8 @@ namespace ivec2& operator=(ivec2&& other) = delete; ivec2& operator=(const ivec2& other) = delete; public: - static int move_ctor_counter; - static int copy_ctor_counter; + static int move_constructor_counter; + static int copy_constructor_counter; }; struct ivec3 { @@ -53,8 +53,8 @@ namespace ivec3(int x, int y, int z): x{x}, y{y}, z{z} {} }; - int ivec2::move_ctor_counter{0}; - int ivec2::copy_ctor_counter{0}; + int ivec2::move_constructor_counter{0}; + int ivec2::copy_constructor_counter{0}; ivec2 iadd2(ivec2 l, ivec2 r) { return {l.x + r.x, l.y + r.y}; @@ -73,10 +73,10 @@ TEST_CASE("meta/meta_utilities/value/ivec2") { namespace meta = meta_hpp; meta::class_() - .ctor_() - .ctor_() - .ctor_() - .ctor_() + .constructor_() + .constructor_() + .constructor_() + .constructor_() .member_("x", &ivec2::x) .member_("y", &ivec2::y); } @@ -85,10 +85,10 @@ TEST_CASE("meta/meta_utilities/value/ivec3") { namespace meta = meta_hpp; meta::class_() - .ctor_() - .ctor_() - .ctor_() - .ctor_() + .constructor_() + .constructor_() + .constructor_() + .constructor_() .member_("x", &ivec3::x) .member_("y", &ivec3::y) .member_("z", &ivec3::z); @@ -98,8 +98,8 @@ TEST_CASE("meta/meta_utilities/value") { namespace meta = meta_hpp; using namespace std::string_literals; - ivec2::move_ctor_counter = 0; - ivec2::copy_ctor_counter = 0; + ivec2::move_constructor_counter = 0; + ivec2::copy_constructor_counter = 0; SUBCASE("cast types") { static_assert(std::is_same_v< @@ -189,8 +189,8 @@ TEST_CASE("meta/meta_utilities/value") { ivec2& vr = v; meta::uvalue val{vr}; - CHECK(ivec2::move_ctor_counter == 0); - CHECK(ivec2::copy_ctor_counter == 1); + CHECK(ivec2::move_constructor_counter == 0); + CHECK(ivec2::copy_constructor_counter == 1); CHECK(val.get_type() == meta::resolve_type()); @@ -223,8 +223,8 @@ TEST_CASE("meta/meta_utilities/value") { const ivec2& vr = v; meta::uvalue val{vr}; - CHECK(ivec2::move_ctor_counter == 0); - CHECK(ivec2::copy_ctor_counter == 1); + CHECK(ivec2::move_constructor_counter == 0); + CHECK(ivec2::copy_constructor_counter == 1); CHECK(val.get_type() == meta::resolve_type()); @@ -256,8 +256,8 @@ TEST_CASE("meta/meta_utilities/value") { ivec2 v{1,2}; meta::uvalue val{std::move(v)}; - CHECK(ivec2::move_ctor_counter == 1); - CHECK(ivec2::copy_ctor_counter == 0); + CHECK(ivec2::move_constructor_counter == 1); + CHECK(ivec2::copy_constructor_counter == 0); CHECK(val.get_type() == meta::resolve_type()); @@ -284,8 +284,8 @@ TEST_CASE("meta/meta_utilities/value") { const ivec2 v{1,2}; meta::uvalue val{std::move(v)}; - CHECK(ivec2::move_ctor_counter == 0); - CHECK(ivec2::copy_ctor_counter == 1); + CHECK(ivec2::move_constructor_counter == 0); + CHECK(ivec2::copy_constructor_counter == 1); CHECK(val.get_type() == meta::resolve_type()); @@ -311,25 +311,25 @@ TEST_CASE("meta/meta_utilities/value") { SUBCASE("value(value&&)") { ivec2 v{1,2}; meta::uvalue val_src{std::move(v)}; - CHECK(ivec2::move_ctor_counter == 1); - CHECK(ivec2::copy_ctor_counter == 0); + CHECK(ivec2::move_constructor_counter == 1); + CHECK(ivec2::copy_constructor_counter == 0); meta::uvalue val_dst{std::move(val_src)}; CHECK(val_dst == ivec2{1,2}); - CHECK(ivec2::move_ctor_counter == 2); - CHECK(ivec2::copy_ctor_counter == 0); + CHECK(ivec2::move_constructor_counter == 2); + CHECK(ivec2::copy_constructor_counter == 0); } SUBCASE("value(const meta::value&)") { const ivec2 v{1,2}; meta::uvalue val_src{v}; - CHECK(ivec2::move_ctor_counter == 0); - CHECK(ivec2::copy_ctor_counter == 1); + CHECK(ivec2::move_constructor_counter == 0); + CHECK(ivec2::copy_constructor_counter == 1); meta::uvalue val_dst{val_src}; CHECK(val_dst == ivec2{1,2}); - CHECK(ivec2::move_ctor_counter == 0); - CHECK(ivec2::copy_ctor_counter == 2); + CHECK(ivec2::move_constructor_counter == 0); + CHECK(ivec2::copy_constructor_counter == 2); CHECK(val_src == ivec2{1,2}); CHECK(val_src.data() != val_dst.data()); @@ -348,39 +348,39 @@ TEST_CASE("meta/meta_utilities/value") { SUBCASE("value& operator=(value&&)") { meta::uvalue val_src1{"world"s}; meta::uvalue val_src2{ivec2{1,2}}; - CHECK(ivec2::move_ctor_counter == 1); - CHECK(ivec2::copy_ctor_counter == 0); + CHECK(ivec2::move_constructor_counter == 1); + CHECK(ivec2::copy_constructor_counter == 0); meta::uvalue val_dst{"hello"s}; val_dst = std::move(val_src1); CHECK(val_dst == "world"s); - CHECK(ivec2::move_ctor_counter == 1); - CHECK(ivec2::copy_ctor_counter == 0); + CHECK(ivec2::move_constructor_counter == 1); + CHECK(ivec2::copy_constructor_counter == 0); val_dst = std::move(val_src2); CHECK(val_dst == ivec2{1,2}); - CHECK(ivec2::move_ctor_counter == 3); - CHECK(ivec2::copy_ctor_counter == 0); + CHECK(ivec2::move_constructor_counter == 3); + CHECK(ivec2::copy_constructor_counter == 0); } SUBCASE("value& operator=(const meta::value&)") { meta::uvalue val_src1{"world"s}; meta::uvalue val_src2{ivec2{1,2}}; - CHECK(ivec2::move_ctor_counter == 1); - CHECK(ivec2::copy_ctor_counter == 0); + CHECK(ivec2::move_constructor_counter == 1); + CHECK(ivec2::copy_constructor_counter == 0); meta::uvalue val_dst{"hello"s}; val_dst = val_src1; CHECK(val_dst == "world"s); - CHECK(ivec2::move_ctor_counter == 1); - CHECK(ivec2::copy_ctor_counter == 0); + CHECK(ivec2::move_constructor_counter == 1); + CHECK(ivec2::copy_constructor_counter == 0); val_dst = val_src2; CHECK(val_dst == ivec2{1,2}); - CHECK(ivec2::move_ctor_counter == 2); - CHECK(ivec2::copy_ctor_counter == 1); + CHECK(ivec2::move_constructor_counter == 2); + CHECK(ivec2::copy_constructor_counter == 1); CHECK(val_src2 == ivec2{1,2}); CHECK(val_src2.data() != val_dst.data()); @@ -389,14 +389,14 @@ TEST_CASE("meta/meta_utilities/value") { SUBCASE("swap") { meta::uvalue val1{"world"s}; meta::uvalue val2{ivec2{1,2}}; - CHECK(ivec2::move_ctor_counter == 1); - CHECK(ivec2::copy_ctor_counter == 0); + CHECK(ivec2::move_constructor_counter == 1); + CHECK(ivec2::copy_constructor_counter == 0); val1.swap(val2); CHECK(val1 == ivec2{1,2}); CHECK(val2 == "world"s); - CHECK(ivec2::move_ctor_counter == 2); - CHECK(ivec2::copy_ctor_counter == 0); + CHECK(ivec2::move_constructor_counter == 2); + CHECK(ivec2::copy_constructor_counter == 0); swap(val1, val2); CHECK(val1 == "world"s); @@ -498,20 +498,20 @@ TEST_CASE("meta/meta_utilities/value") { { ivec2 v{1,2}; meta::uvalue vp{&v}; - CHECK(ivec2::move_ctor_counter == 0); - CHECK(ivec2::copy_ctor_counter == 0); + CHECK(ivec2::move_constructor_counter == 0); + CHECK(ivec2::copy_constructor_counter == 0); [[maybe_unused]] meta::uvalue vv1{*vp}; - CHECK((ivec2::move_ctor_counter == 0 || ivec2::move_ctor_counter == 2)); - CHECK(ivec2::copy_ctor_counter == 1); + CHECK((ivec2::move_constructor_counter == 0 || ivec2::move_constructor_counter == 2)); + CHECK(ivec2::copy_constructor_counter == 1); [[maybe_unused]] meta::uvalue vv2{*std::move(vp)}; - CHECK((ivec2::move_ctor_counter == 0 || ivec2::move_ctor_counter == 4)); - CHECK(ivec2::copy_ctor_counter == 2); + CHECK((ivec2::move_constructor_counter == 0 || ivec2::move_constructor_counter == 4)); + CHECK(ivec2::copy_constructor_counter == 2); [[maybe_unused]] meta::uvalue vv3{*std::as_const(vp)}; - CHECK((ivec2::move_ctor_counter == 0 || ivec2::move_ctor_counter == 6)); - CHECK(ivec2::copy_ctor_counter == 3); + CHECK((ivec2::move_constructor_counter == 0 || ivec2::move_constructor_counter == 6)); + CHECK(ivec2::copy_constructor_counter == 3); } { meta::uvalue v{std::make_shared(42)};