Merge branch 'dev' into feature/shared_experiments

This commit is contained in:
BlackMATov
2024-01-31 20:50:30 +07:00
14 changed files with 129 additions and 72 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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",

View File

@@ -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;
}
}

View File

@@ -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));

View File

@@ -135,6 +135,8 @@ TEST_CASE("meta/meta_states/metadata/class") {
const meta::constructor ivec2_ctor = ivec2_type.get_constructor_with<int>();
REQUIRE(ivec2_ctor);
CHECK(ivec2_ctor.get_arity() == 1);
REQUIRE(ivec2_ctor.get_metadata().contains("desc"));
CHECK(ivec2_ctor.get_metadata().at("desc").as<std::string>() == "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<int, int>();
REQUIRE(ivec2_ctor);
CHECK(ivec2_ctor.get_arity() == 2);
REQUIRE(ivec2_ctor.get_metadata().contains("desc"));
CHECK(ivec2_ctor.get_metadata().at("desc").as<std::string>() == "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<std::string>() == "iadd-function"s);

View File

@@ -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));

View File

@@ -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;

View File

@@ -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{};
}

View File

@@ -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{};
}

View File

@@ -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{};
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}