diff --git a/.github/workflows/darwin.yml b/.github/workflows/darwin.yml index 4f90b6e..2151810 100644 --- a/.github/workflows/darwin.yml +++ b/.github/workflows/darwin.yml @@ -10,17 +10,19 @@ jobs: matrix: config: # https://github.com/actions/virtual-environments/tree/main/images/macos - - { os: "macos-12", xcode: "14.0", arch: "x64" } - - { os: "macos-12", xcode: "14.1", arch: "x64" } - - { os: "macos-12", xcode: "14.2", arch: "x64" } - name: "xcode-${{matrix.config.xcode}}" + - { os: "macos-12", xcode: "13.4.1", arch: "x64" } + - { os: "macos-13", xcode: "14.3.1", arch: "x64" } + - { os: "macos-13", xcode: "14.3.1", arch: "arm64" } + - { os: "macos-14", xcode: "15.2", arch: "x64" } + - { os: "macos-14", xcode: "15.2", arch: "arm64" } + name: "xcode-${{matrix.config.xcode}}-${{matrix.config.arch}}" steps: - name: Setup run: | brew update brew install cmake ninja - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true - name: Select Xcode diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 362810f..bc1a603 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -9,11 +9,11 @@ jobs: fail-fast: false matrix: config: - # https://github.com/actions/virtual-environments/tree/main/images/linux + # https://github.com/actions/runner-images/tree/main/images/ubuntu - { os: "ubuntu-20.04", cc: "gcc-10", cxx: "g++-10" } - { os: "ubuntu-20.04", cc: "clang-10", cxx: "clang++-10" } - - { os: "ubuntu-22.04", cc: "gcc-12", cxx: "g++-12" } - - { os: "ubuntu-22.04", cc: "clang-14", cxx: "clang++-14" } + - { os: "ubuntu-22.04", cc: "gcc-13", cxx: "g++-13" } + - { os: "ubuntu-22.04", cc: "clang-15", cxx: "clang++-15" } name: "${{matrix.config.cxx}}" steps: - name: Setup @@ -21,7 +21,7 @@ jobs: sudo apt-get update -o Acquire::Retries=10 sudo apt-get install -o Acquire::Retries=10 -y cmake ninja-build ${{matrix.config.cc}} ${{matrix.config.cxx}} - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true - name: Build diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index f268b90..22a897a 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -9,17 +9,17 @@ jobs: fail-fast: false matrix: config: - # https://github.com/actions/virtual-environments/tree/main/images/win + # https://github.com/actions/runner-images/tree/main/images/windows - { os: "windows-2019", vc: "msvc2019", arch: "x86" } - { os: "windows-2019", vc: "msvc2019", arch: "x64" } - { os: "windows-2022", vc: "msvc2022", arch: "x86" } - { os: "windows-2022", vc: "msvc2022", arch: "x64" } - name: "${{matrix.config.vc}} ${{matrix.config.arch}}" + name: "${{matrix.config.vc}}-${{matrix.config.arch}}" steps: - name: Setup run: choco install cmake ninja - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true - name: Select MSVC diff --git a/CMakePresets.json b/CMakePresets.json index a1d314d..1d6ddf4 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -35,11 +35,11 @@ } }, { - "name": "linux-clang-14", + "name": "linux-clang-15", "inherits": "linux-base", "cacheVariables": { - "CMAKE_C_COMPILER": "clang-14", - "CMAKE_CXX_COMPILER": "clang++-14" + "CMAKE_C_COMPILER": "clang-15", + "CMAKE_CXX_COMPILER": "clang++-15" } }, { @@ -51,11 +51,11 @@ } }, { - "name": "linux-gcc-12", + "name": "linux-gcc-13", "inherits": "linux-base", "cacheVariables": { - "CMAKE_C_COMPILER": "gcc-12", - "CMAKE_CXX_COMPILER": "g++-12" + "CMAKE_C_COMPILER": "gcc-13", + "CMAKE_CXX_COMPILER": "g++-13" } }, { @@ -213,14 +213,14 @@ "configurePreset": "linux-clang-10" }, { - "name": "linux-clang-14-debug", + "name": "linux-clang-15-debug", "configuration": "Debug", - "configurePreset": "linux-clang-14" + "configurePreset": "linux-clang-15" }, { - "name": "linux-clang-14-release", + "name": "linux-clang-15-release", "configuration": "Release", - "configurePreset": "linux-clang-14" + "configurePreset": "linux-clang-15" }, { "name": "linux-gcc-10-debug", @@ -233,14 +233,14 @@ "configurePreset": "linux-gcc-10" }, { - "name": "linux-gcc-12-debug", + "name": "linux-gcc-13-debug", "configuration": "Debug", - "configurePreset": "linux-gcc-12" + "configurePreset": "linux-gcc-13" }, { - "name": "linux-gcc-12-release", + "name": "linux-gcc-13-release", "configuration": "Release", - "configurePreset": "linux-gcc-12" + "configurePreset": "linux-gcc-13" }, { "name": "macos-arm64-debug", @@ -347,9 +347,9 @@ "configurePreset": "linux-clang-10" }, { - "name": "linux-clang-14", + "name": "linux-clang-15", "inherits": "test-base", - "configurePreset": "linux-clang-14" + "configurePreset": "linux-clang-15" }, { "name": "linux-gcc-10", @@ -357,9 +357,9 @@ "configurePreset": "linux-gcc-10" }, { - "name": "linux-gcc-12", + "name": "linux-gcc-13", "inherits": "test-base", - "configurePreset": "linux-gcc-12" + "configurePreset": "linux-gcc-13" }, { "name": "macos-arm64", diff --git a/develop/singles/headers/meta.hpp/meta_all.hpp b/develop/singles/headers/meta.hpp/meta_all.hpp index 94f3a43..43883bf 100644 --- a/develop/singles/headers/meta.hpp/meta_all.hpp +++ b/develop/singles/headers/meta.hpp/meta_all.hpp @@ -3613,6 +3613,7 @@ namespace meta_hpp [[nodiscard]] constructor_type get_type() const noexcept; + [[nodiscard]] std::size_t get_arity() const noexcept; [[nodiscard]] argument get_argument(std::size_t position) const noexcept; [[nodiscard]] const argument_list& get_arguments() const noexcept; @@ -3710,6 +3711,7 @@ namespace meta_hpp [[nodiscard]] function_type get_type() const noexcept; [[nodiscard]] const std::string& get_name() const noexcept; + [[nodiscard]] std::size_t get_arity() const noexcept; [[nodiscard]] argument get_argument(std::size_t position) const noexcept; [[nodiscard]] const argument_list& get_arguments() const noexcept; @@ -3808,6 +3810,7 @@ namespace meta_hpp [[nodiscard]] method_type get_type() const noexcept; [[nodiscard]] const std::string& get_name() const noexcept; + [[nodiscard]] std::size_t get_arity() const noexcept; [[nodiscard]] argument get_argument(std::size_t position) const noexcept; [[nodiscard]] const argument_list& get_arguments() const noexcept; @@ -6353,6 +6356,10 @@ namespace meta_hpp return state_->index.get_name(); } + inline std::size_t function::get_arity() const noexcept { + return state_->arguments.size(); + } + inline argument function::get_argument(std::size_t position) const noexcept { return position < state_->arguments.size() ? state_->arguments[position] : argument{}; } @@ -7248,6 +7255,10 @@ namespace meta_hpp return state_->index.get_name(); } + inline std::size_t method::get_arity() const noexcept { + return state_->arguments.size(); + } + inline argument method::get_argument(std::size_t position) const noexcept { return position < state_->arguments.size() ? state_->arguments[position] : argument{}; } @@ -7868,6 +7879,10 @@ namespace meta_hpp return state_->index.get_type(); } + inline std::size_t constructor::get_arity() const noexcept { + return state_->arguments.size(); + } + inline argument constructor::get_argument(std::size_t position) const noexcept { return position < state_->arguments.size() ? state_->arguments[position] : argument{}; } @@ -8678,11 +8693,11 @@ namespace meta_hpp template < typename... Args > uvalue class_type::create(Args&&... args) const { - for ( const constructor& ctor : data_->constructors ) { - if ( ctor.is_invocable_with(META_HPP_FWD(args)...) ) { + for ( const constructor& constructor : data_->constructors ) { + if ( constructor.is_invocable_with(META_HPP_FWD(args)...) ) { // there is no 'use after move' here because // 'is_invocable_with' doesn't actually move 'args' - return ctor.create(META_HPP_FWD(args)...); + return constructor.create(META_HPP_FWD(args)...); } } return uvalue{}; @@ -8690,11 +8705,11 @@ namespace meta_hpp template < typename... Args > uvalue class_type::create_at(void* mem, Args&&... args) const { - for ( const constructor& ctor : data_->constructors ) { - if ( ctor.is_invocable_with(META_HPP_FWD(args)...) ) { + for ( const constructor& constructor : data_->constructors ) { + if ( constructor.is_invocable_with(META_HPP_FWD(args)...) ) { // there is no 'use after move' here because // 'is_invocable_with' doesn't actually move 'args' - return ctor.create_at(mem, META_HPP_FWD(args)...); + return constructor.create_at(mem, META_HPP_FWD(args)...); } } return uvalue{}; @@ -8702,11 +8717,11 @@ namespace meta_hpp template < typename Arg > bool class_type::destroy(Arg&& arg) const { - if ( const destructor& dtor = get_destructor() ) { - if ( dtor.is_invocable_with(META_HPP_FWD(arg)) ) { + if ( const destructor& destructor = get_destructor() ) { + if ( destructor.is_invocable_with(META_HPP_FWD(arg)) ) { // there is no 'use after move' here because // 'is_invocable_with' doesn't actually move an 'arg' - dtor.destroy(META_HPP_FWD(arg)); + destructor.destroy(META_HPP_FWD(arg)); return true; } } @@ -8714,8 +8729,8 @@ namespace meta_hpp } inline bool class_type::destroy_at(void* mem) const { - if ( const destructor& dtor = get_destructor() ) { - dtor.destroy_at(mem); + if ( const destructor& destructor = get_destructor() ) { + destructor.destroy_at(mem); return true; } return false; @@ -8877,10 +8892,12 @@ namespace meta_hpp template < typename Iter > constructor class_type::get_constructor_with(Iter first, Iter last) const noexcept { - for ( const constructor& ctor : data_->constructors ) { - const any_type_list& args = ctor.get_type().get_argument_types(); - if ( std::equal(first, last, args.begin(), args.end()) ) { - return ctor; + for ( const constructor& constructor : data_->constructors ) { + const constructor_type& constructor_type = constructor.get_type(); + const any_type_list& constructor_args = constructor_type.get_argument_types(); + + if ( std::equal(first, last, constructor_args.begin(), constructor_args.end()) ) { + return constructor; } } return constructor{}; @@ -8930,8 +8947,10 @@ namespace meta_hpp continue; } - const any_type_list& args = function.get_type().get_argument_types(); - if ( std::equal(first, last, args.begin(), args.end()) ) { + const function_type& function_type = function.get_type(); + const any_type_list& function_args = function_type.get_argument_types(); + + if ( std::equal(first, last, function_args.begin(), function_args.end()) ) { return function; } } @@ -8988,8 +9007,10 @@ namespace meta_hpp continue; } - const any_type_list& args = method.get_type().get_argument_types(); - if ( std::equal(first, last, args.begin(), args.end()) ) { + const method_type& method_type = method.get_type(); + const any_type_list& method_args = method_type.get_argument_types(); + + if ( std::equal(first, last, method_args.begin(), method_args.end()) ) { return method; } } @@ -9099,8 +9120,10 @@ namespace meta_hpp continue; } - const any_type_list& args = function.get_type().get_argument_types(); - if ( std::equal(first, last, args.begin(), args.end()) ) { + const function_type& function_type = function.get_type(); + const any_type_list& function_args = function_type.get_argument_types(); + + if ( std::equal(first, last, function_args.begin(), function_args.end()) ) { return function; } } diff --git a/develop/untests/meta_states/function2_tests.cpp b/develop/untests/meta_states/function2_tests.cpp index 401bee3..69a06c3 100644 --- a/develop/untests/meta_states/function2_tests.cpp +++ b/develop/untests/meta_states/function2_tests.cpp @@ -37,6 +37,7 @@ TEST_CASE("meta/meta_states/function2") { const meta::function func = ivec2_type.get_function("iadd"); REQUIRE(func); + CHECK(func.get_arity() == 2); CHECK(func.get_arguments().size() == 2); REQUIRE(func.get_argument(0)); @@ -56,6 +57,7 @@ TEST_CASE("meta/meta_states/function2") { const meta::function func = ivec2_type.get_function("isub"); REQUIRE(func); + CHECK(func.get_arity() == 2); REQUIRE(func.get_arguments().size() == 2); REQUIRE(func.get_argument(0)); diff --git a/develop/untests/meta_states/metadata_tests.cpp b/develop/untests/meta_states/metadata_tests.cpp index 6dff81e..d4fac8e 100644 --- a/develop/untests/meta_states/metadata_tests.cpp +++ b/develop/untests/meta_states/metadata_tests.cpp @@ -135,6 +135,8 @@ TEST_CASE("meta/meta_states/metadata/class") { const meta::constructor ivec2_ctor = ivec2_type.get_constructor_with(); REQUIRE(ivec2_ctor); + CHECK(ivec2_ctor.get_arity() == 1); + REQUIRE(ivec2_ctor.get_metadata().contains("desc")); CHECK(ivec2_ctor.get_metadata().at("desc").as() == "one arg 2d vector ctor"s); @@ -152,6 +154,8 @@ TEST_CASE("meta/meta_states/metadata/class") { const meta::constructor ivec2_ctor = ivec2_type.get_constructor_with(); REQUIRE(ivec2_ctor); + CHECK(ivec2_ctor.get_arity() == 2); + REQUIRE(ivec2_ctor.get_metadata().contains("desc")); CHECK(ivec2_ctor.get_metadata().at("desc").as() == "two args 2d vector ctor"s); @@ -204,6 +208,8 @@ TEST_CASE("meta/meta_states/metadata/class") { const meta::function ivec2_iadd = ivec2_type.get_function("iadd"); REQUIRE(ivec2_iadd); + CHECK(ivec2_iadd.get_arity() == 2); + REQUIRE(ivec2_iadd.get_metadata().contains("desc")); CHECK(ivec2_iadd.get_metadata().at("desc").as() == "iadd-function"s); diff --git a/develop/untests/meta_states/method2_tests.cpp b/develop/untests/meta_states/method2_tests.cpp index 1cd9145..1f51bce 100644 --- a/develop/untests/meta_states/method2_tests.cpp +++ b/develop/untests/meta_states/method2_tests.cpp @@ -34,6 +34,7 @@ TEST_CASE("meta/meta_states/method2") { const meta::method add_m = ivec2_type.get_method("add"); REQUIRE(add_m); + CHECK(add_m.get_arity() == 1); CHECK(add_m.get_arguments().size() == 1); REQUIRE(add_m.get_argument(0)); diff --git a/headers/meta.hpp/meta_states.hpp b/headers/meta.hpp/meta_states.hpp index 300bd12..2adac57 100644 --- a/headers/meta.hpp/meta_states.hpp +++ b/headers/meta.hpp/meta_states.hpp @@ -204,6 +204,7 @@ namespace meta_hpp [[nodiscard]] constructor_type get_type() const noexcept; + [[nodiscard]] std::size_t get_arity() const noexcept; [[nodiscard]] argument get_argument(std::size_t position) const noexcept; [[nodiscard]] const argument_list& get_arguments() const noexcept; @@ -301,6 +302,7 @@ namespace meta_hpp [[nodiscard]] function_type get_type() const noexcept; [[nodiscard]] const std::string& get_name() const noexcept; + [[nodiscard]] std::size_t get_arity() const noexcept; [[nodiscard]] argument get_argument(std::size_t position) const noexcept; [[nodiscard]] const argument_list& get_arguments() const noexcept; @@ -399,6 +401,7 @@ namespace meta_hpp [[nodiscard]] method_type get_type() const noexcept; [[nodiscard]] const std::string& get_name() const noexcept; + [[nodiscard]] std::size_t get_arity() const noexcept; [[nodiscard]] argument get_argument(std::size_t position) const noexcept; [[nodiscard]] const argument_list& get_arguments() const noexcept; diff --git a/headers/meta.hpp/meta_states/constructor.hpp b/headers/meta.hpp/meta_states/constructor.hpp index 452d1fb..ee344df 100644 --- a/headers/meta.hpp/meta_states/constructor.hpp +++ b/headers/meta.hpp/meta_states/constructor.hpp @@ -170,6 +170,10 @@ namespace meta_hpp return state_->index.get_type(); } + inline std::size_t constructor::get_arity() const noexcept { + return state_->arguments.size(); + } + inline argument constructor::get_argument(std::size_t position) const noexcept { return position < state_->arguments.size() ? state_->arguments[position] : argument{}; } diff --git a/headers/meta.hpp/meta_states/function.hpp b/headers/meta.hpp/meta_states/function.hpp index ab8ca55..49dc105 100644 --- a/headers/meta.hpp/meta_states/function.hpp +++ b/headers/meta.hpp/meta_states/function.hpp @@ -144,6 +144,10 @@ namespace meta_hpp return state_->index.get_name(); } + inline std::size_t function::get_arity() const noexcept { + return state_->arguments.size(); + } + inline argument function::get_argument(std::size_t position) const noexcept { return position < state_->arguments.size() ? state_->arguments[position] : argument{}; } diff --git a/headers/meta.hpp/meta_states/method.hpp b/headers/meta.hpp/meta_states/method.hpp index a2027c2..df8e1b2 100644 --- a/headers/meta.hpp/meta_states/method.hpp +++ b/headers/meta.hpp/meta_states/method.hpp @@ -156,6 +156,10 @@ namespace meta_hpp return state_->index.get_name(); } + inline std::size_t method::get_arity() const noexcept { + return state_->arguments.size(); + } + inline argument method::get_argument(std::size_t position) const noexcept { return position < state_->arguments.size() ? state_->arguments[position] : argument{}; } diff --git a/headers/meta.hpp/meta_states/scope.hpp b/headers/meta.hpp/meta_states/scope.hpp index fd57ad1..8583961 100644 --- a/headers/meta.hpp/meta_states/scope.hpp +++ b/headers/meta.hpp/meta_states/scope.hpp @@ -93,8 +93,10 @@ namespace meta_hpp continue; } - const any_type_list& args = function.get_type().get_argument_types(); - if ( std::equal(first, last, args.begin(), args.end()) ) { + const function_type& function_type = function.get_type(); + const any_type_list& function_args = function_type.get_argument_types(); + + if ( std::equal(first, last, function_args.begin(), function_args.end()) ) { return function; } } diff --git a/headers/meta.hpp/meta_types/class_type.hpp b/headers/meta.hpp/meta_types/class_type.hpp index 46d324f..5b69ddb 100644 --- a/headers/meta.hpp/meta_types/class_type.hpp +++ b/headers/meta.hpp/meta_types/class_type.hpp @@ -202,11 +202,11 @@ namespace meta_hpp template < typename... Args > uvalue class_type::create(Args&&... args) const { - for ( const constructor& ctor : data_->constructors ) { - if ( ctor.is_invocable_with(META_HPP_FWD(args)...) ) { + for ( const constructor& constructor : data_->constructors ) { + if ( constructor.is_invocable_with(META_HPP_FWD(args)...) ) { // there is no 'use after move' here because // 'is_invocable_with' doesn't actually move 'args' - return ctor.create(META_HPP_FWD(args)...); + return constructor.create(META_HPP_FWD(args)...); } } return uvalue{}; @@ -214,11 +214,11 @@ namespace meta_hpp template < typename... Args > uvalue class_type::create_at(void* mem, Args&&... args) const { - for ( const constructor& ctor : data_->constructors ) { - if ( ctor.is_invocable_with(META_HPP_FWD(args)...) ) { + for ( const constructor& constructor : data_->constructors ) { + if ( constructor.is_invocable_with(META_HPP_FWD(args)...) ) { // there is no 'use after move' here because // 'is_invocable_with' doesn't actually move 'args' - return ctor.create_at(mem, META_HPP_FWD(args)...); + return constructor.create_at(mem, META_HPP_FWD(args)...); } } return uvalue{}; @@ -226,11 +226,11 @@ namespace meta_hpp template < typename Arg > bool class_type::destroy(Arg&& arg) const { - if ( const destructor& dtor = get_destructor() ) { - if ( dtor.is_invocable_with(META_HPP_FWD(arg)) ) { + if ( const destructor& destructor = get_destructor() ) { + if ( destructor.is_invocable_with(META_HPP_FWD(arg)) ) { // there is no 'use after move' here because // 'is_invocable_with' doesn't actually move an 'arg' - dtor.destroy(META_HPP_FWD(arg)); + destructor.destroy(META_HPP_FWD(arg)); return true; } } @@ -238,8 +238,8 @@ namespace meta_hpp } inline bool class_type::destroy_at(void* mem) const { - if ( const destructor& dtor = get_destructor() ) { - dtor.destroy_at(mem); + if ( const destructor& destructor = get_destructor() ) { + destructor.destroy_at(mem); return true; } return false; @@ -401,10 +401,12 @@ namespace meta_hpp template < typename Iter > constructor class_type::get_constructor_with(Iter first, Iter last) const noexcept { - for ( const constructor& ctor : data_->constructors ) { - const any_type_list& args = ctor.get_type().get_argument_types(); - if ( std::equal(first, last, args.begin(), args.end()) ) { - return ctor; + for ( const constructor& constructor : data_->constructors ) { + const constructor_type& constructor_type = constructor.get_type(); + const any_type_list& constructor_args = constructor_type.get_argument_types(); + + if ( std::equal(first, last, constructor_args.begin(), constructor_args.end()) ) { + return constructor; } } return constructor{}; @@ -454,8 +456,10 @@ namespace meta_hpp continue; } - const any_type_list& args = function.get_type().get_argument_types(); - if ( std::equal(first, last, args.begin(), args.end()) ) { + const function_type& function_type = function.get_type(); + const any_type_list& function_args = function_type.get_argument_types(); + + if ( std::equal(first, last, function_args.begin(), function_args.end()) ) { return function; } } @@ -512,8 +516,10 @@ namespace meta_hpp continue; } - const any_type_list& args = method.get_type().get_argument_types(); - if ( std::equal(first, last, args.begin(), args.end()) ) { + const method_type& method_type = method.get_type(); + const any_type_list& method_args = method_type.get_argument_types(); + + if ( std::equal(first, last, method_args.begin(), method_args.end()) ) { return method; } }