diff --git a/.github/workflows/test-linux-mac.yml b/.github/workflows/test-linux-mac.yml index 3ff46b1..47e85a0 100644 --- a/.github/workflows/test-linux-mac.yml +++ b/.github/workflows/test-linux-mac.yml @@ -2,11 +2,11 @@ name: test-linux-mac on: - push - pull_request - + defaults: run: shell: bash - + jobs: test: name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} @@ -15,12 +15,12 @@ jobs: fail-fast: false matrix: version: - - '1.6' - - '1.10' - - 'nightly' + - "1.6" + - "1.10" + - "nightly" os: - ubuntu-latest - - macOS-latest + - macos-13 arch: - x64 steps: diff --git a/.github/workflows/test-win.yml b/.github/workflows/test-win.yml index f0e5c39..de1cf08 100644 --- a/.github/workflows/test-win.yml +++ b/.github/workflows/test-win.yml @@ -1,12 +1,13 @@ name: test-win + on: - push - pull_request - + defaults: run: shell: bash - + jobs: test: name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} @@ -15,9 +16,9 @@ jobs: fail-fast: false matrix: version: - - '1.6' - - '1.10' - - 'nightly' + - "1.7" + - "1.10" + - "nightly" os: - windows-latest arch: @@ -26,28 +27,19 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 + - uses: julia-actions/setup-julia@latest with: version: ${{ matrix.version }} arch: ${{ matrix.arch }} - - name: Config 32bit - if: ${{ matrix.arch == 'x86'}} + - name: Config and Test run: | - mkdir build - cd build - cmake -G "Visual Studio 17 2022" -A Win32 -DOVERRIDES_PATH=$HOMEDRIVE/$HOMEPATH/.julia/artifacts/Overrides.toml -DOVERRIDE_ROOT=./ -DAPPEND_OVERRIDES_TOML=ON .. - - name: Config 64bit - if: ${{ matrix.arch == 'x64'}} - run: | - mkdir build - cd build - cmake -G "Visual Studio 17 2022" -A x64 -DOVERRIDES_PATH=$HOMEDRIVE/$HOMEPATH/.julia/artifacts/Overrides.toml -DOVERRIDE_ROOT=./ -DAPPEND_OVERRIDES_TOML=ON .. - - name: Test - run: | - body="${{github.event.pull_request.body}}" - package="$(echo "$body" | sed -n '1p')" - cd build - cmake --build . --config Release - julia -e "using Pkg; Pkg.Registry.add(\"General\"); Pkg.Registry.add(RegistrySpec(url = \"https://github.com/barche/CxxWrapTestRegistry.git\"))" - julia -e "using Pkg; pkg\"add ${package}\"; using CxxWrap" - ctest -j 1 -C Release -V + mkdir build + cd build + cmake -G "Visual Studio 17 2022" -A x64 -DOVERRIDES_PATH=$HOMEDRIVE/$HOMEPATH/.julia/artifacts/Overrides.toml -DOVERRIDE_ROOT=./ -DAPPEND_OVERRIDES_TOML=ON .. + body="${{github.event.pull_request.body}}" + package="$(echo "$body" | sed -n '1p')" + cmake --build . --config Release + julia -e "using Pkg; Pkg.Registry.add(\"General\"); Pkg.Registry.add(RegistrySpec(url = \"https://github.com/barche/CxxWrapTestRegistry.git\"))" + julia -e "using Pkg; pkg\"add ${package}\"; using CxxWrap" + ctest -j 1 -C Release -V diff --git a/CMakeLists.txt b/CMakeLists.txt index 972ee6f..83194f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,7 +42,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-parameter -Wextra -Wreorder -fPIC") endif() -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) add_definitions(-DJULIA_ENABLE_THREADING) @@ -169,8 +169,8 @@ set_property(TARGET ${JLCXX_TARGET} APPEND PROPERTY COMPATIBLE_INTERFACE_STRING ${JLCXX_TARGET}_MAJOR_VERSION ) target_compile_definitions(${JLCXX_TARGET} PUBLIC "JULIA_ENABLE_THREADING") -target_compile_features(${JLCXX_TARGET} PUBLIC cxx_std_17) -target_compile_features(${JLCXX_STL_TARGET} PUBLIC cxx_std_17) +target_compile_features(${JLCXX_TARGET} PUBLIC cxx_std_20) +target_compile_features(${JLCXX_STL_TARGET} PUBLIC cxx_std_20) generate_export_header(${JLCXX_TARGET}) diff --git a/include/jlcxx/julia_headers.hpp b/include/jlcxx/julia_headers.hpp index 7cf9d91..db915ed 100644 --- a/include/jlcxx/julia_headers.hpp +++ b/include/jlcxx/julia_headers.hpp @@ -4,12 +4,6 @@ #ifdef _MSC_VER #include #include - - template - static inline T jl_atomic_load_relaxed(volatile T *obj) - { - return jl_atomic_load_acquire(obj); - } #endif #include diff --git a/include/jlcxx/stl.hpp b/include/jlcxx/stl.hpp index 771fc58..32f41d0 100644 --- a/include/jlcxx/stl.hpp +++ b/include/jlcxx/stl.hpp @@ -75,22 +75,12 @@ using stltypes = remove_duplicates, fundamental_int_types>, fixed_int_types>>; template -void wrap_common(TypeWrapperT& wrapped) +void wrap_range_based_algorithms(TypeWrapperT& wrapped) { using WrappedT = typename TypeWrapperT::type; using T = typename WrappedT::value_type; wrapped.module().set_override_module(StlWrappers::instance().module()); - wrapped.method("cppsize", &WrappedT::size); - wrapped.method("resize", [] (WrappedT& v, const cxxint_t s) { v.resize(s); }); - wrapped.method("append", [] (WrappedT& v, jlcxx::ArrayRef arr) - { - const std::size_t addedlen = arr.size(); - v.reserve(v.size() + addedlen); - for(size_t i = 0; i != addedlen; ++i) - { - v.push_back(arr[i]); - } - }); + wrapped.method("StdFill", [] (WrappedT& v, const T& val) { std::ranges::fill(v, val); }); wrapped.module().unset_override_module(); } @@ -102,7 +92,7 @@ struct WrapVectorImpl { using WrappedT = std::vector; - wrap_common(wrapped); + wrap_range_based_algorithms(wrapped); wrapped.module().set_override_module(StlWrappers::instance().module()); wrapped.method("push_back", static_cast(&WrappedT::push_back)); wrapped.method("cxxgetindex", [] (const WrappedT& v, cxxint_t i) -> typename WrappedT::const_reference { return v[i-1]; }); @@ -120,7 +110,6 @@ struct WrapVectorImpl { using WrappedT = std::vector; - wrap_common(wrapped); wrapped.module().set_override_module(StlWrappers::instance().module()); wrapped.method("push_back", [] (WrappedT& v, const bool val) { v.push_back(val); }); wrapped.method("cxxgetindex", [] (const WrappedT& v, cxxint_t i) { return bool(v[i-1]); }); @@ -136,6 +125,19 @@ struct WrapVector { using WrappedT = typename TypeWrapperT::type; using T = typename WrappedT::value_type; + wrapped.module().set_override_module(StlWrappers::instance().module()); + wrapped.method("cppsize", &WrappedT::size); + wrapped.method("resize", [] (WrappedT& v, const cxxint_t s) { v.resize(s); }); + wrapped.method("append", [] (WrappedT& v, jlcxx::ArrayRef arr) + { + const std::size_t addedlen = arr.size(); + v.reserve(v.size() + addedlen); + for(size_t i = 0; i != addedlen; ++i) + { + v.push_back(arr[i]); + } + }); + wrapped.module().unset_override_module(); WrapVectorImpl::wrap(wrapped); } }; @@ -147,6 +149,8 @@ struct WrapValArray { using WrappedT = typename TypeWrapperT::type; using T = typename WrappedT::value_type; + + wrap_range_based_algorithms(wrapped); wrapped.template constructor(); wrapped.template constructor(); wrapped.template constructor(); @@ -167,6 +171,8 @@ struct WrapDeque { using WrappedT = typename TypeWrapperT::type; using T = typename WrappedT::value_type; + + wrap_range_based_algorithms(wrapped); wrapped.template constructor(); wrapped.module().set_override_module(StlWrappers::instance().module()); wrapped.method("cppsize", &WrappedT::size);