From da97c9e2358b105ffe59b66fbb27e0e6aeb1afd5 Mon Sep 17 00:00:00 2001 From: PraneethJain Date: Sat, 23 Mar 2024 13:02:25 +0530 Subject: [PATCH 01/10] feat: fill algorithm --- include/jlcxx/stl.hpp | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) 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); From 7e64f84e6aa7926951113a661ed2b2592a84dc46 Mon Sep 17 00:00:00 2001 From: PraneethJain Date: Sat, 23 Mar 2024 14:03:35 +0530 Subject: [PATCH 02/10] build: bump to c++20 --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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}) From 4a56bcdce227387594cfce672b81b333c3fb1e1e Mon Sep 17 00:00:00 2001 From: PraneethJain Date: Sat, 23 Mar 2024 16:40:39 +0530 Subject: [PATCH 03/10] build: switch to macos-13 --- .github/workflows/test-linux-mac.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-linux-mac.yml b/.github/workflows/test-linux-mac.yml index 3ff46b1..56c3b07 100644 --- a/.github/workflows/test-linux-mac.yml +++ b/.github/workflows/test-linux-mac.yml @@ -20,7 +20,7 @@ jobs: - 'nightly' os: - ubuntu-latest - - macOS-latest + - macos-13 arch: - x64 steps: From e1411dfd05222ceabec715af634902608593ca42 Mon Sep 17 00:00:00 2001 From: PraneethJain Date: Sat, 23 Mar 2024 19:39:18 +0530 Subject: [PATCH 04/10] feat: simplify build --- .github/workflows/test-win.yml | 42 ++++++++++++++-------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/.github/workflows/test-win.yml b/.github/workflows/test-win.yml index f0e5c39..d327f3c 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.6" + - "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 From 3fd32a6f21927791081f8506fedcac0f92d5260a Mon Sep 17 00:00:00 2001 From: PraneethJain Date: Tue, 26 Mar 2024 15:53:36 +0530 Subject: [PATCH 05/10] test on julia 1.7 --- .github/workflows/test-linux-mac.yml | 1 + .github/workflows/test-win.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/test-linux-mac.yml b/.github/workflows/test-linux-mac.yml index 56c3b07..b07f1a6 100644 --- a/.github/workflows/test-linux-mac.yml +++ b/.github/workflows/test-linux-mac.yml @@ -16,6 +16,7 @@ jobs: matrix: version: - '1.6' + - '1.7' - '1.10' - 'nightly' os: diff --git a/.github/workflows/test-win.yml b/.github/workflows/test-win.yml index d327f3c..774a200 100644 --- a/.github/workflows/test-win.yml +++ b/.github/workflows/test-win.yml @@ -17,6 +17,7 @@ jobs: matrix: version: - "1.6" + - "1.7" - "1.10" - "nightly" os: From 374171c161497cc51900018727c879b57307babf Mon Sep 17 00:00:00 2001 From: PraneethJain Date: Wed, 27 Mar 2024 13:44:19 +0530 Subject: [PATCH 06/10] bump: Julia 1.7 --- .github/workflows/test-linux-mac.yml | 11 +++++------ .github/workflows/test-win.yml | 1 - 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test-linux-mac.yml b/.github/workflows/test-linux-mac.yml index b07f1a6..596ae36 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,10 +15,9 @@ jobs: fail-fast: false matrix: version: - - '1.6' - - '1.7' - - '1.10' - - 'nightly' + - "1.7" + - "1.10" + - "nightly" os: - ubuntu-latest - macos-13 diff --git a/.github/workflows/test-win.yml b/.github/workflows/test-win.yml index 774a200..de1cf08 100644 --- a/.github/workflows/test-win.yml +++ b/.github/workflows/test-win.yml @@ -16,7 +16,6 @@ jobs: fail-fast: false matrix: version: - - "1.6" - "1.7" - "1.10" - "nightly" From 4f2494d50d563ed90b0a0dd27dcd9b9305d9d0d6 Mon Sep 17 00:00:00 2001 From: PraneethJain Date: Wed, 27 Mar 2024 13:44:37 +0530 Subject: [PATCH 07/10] misc: remove dead code --- include/jlcxx/julia_headers.hpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/include/jlcxx/julia_headers.hpp b/include/jlcxx/julia_headers.hpp index 7cf9d91..6072193 100644 --- a/include/jlcxx/julia_headers.hpp +++ b/include/jlcxx/julia_headers.hpp @@ -1,17 +1,6 @@ #ifndef JLCXX_JULIA_HEADERS_HPP #define JLCXX_JULIA_HEADERS_HPP -#ifdef _MSC_VER - #include - #include - - template - static inline T jl_atomic_load_relaxed(volatile T *obj) - { - return jl_atomic_load_acquire(obj); - } -#endif - #include #include From 30ab093a1f5124e48a4e1367d3c81f6940609a56 Mon Sep 17 00:00:00 2001 From: PraneethJain Date: Wed, 27 Mar 2024 13:50:40 +0530 Subject: [PATCH 08/10] fix: add windows.h --- include/jlcxx/julia_headers.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/jlcxx/julia_headers.hpp b/include/jlcxx/julia_headers.hpp index 6072193..1c60a73 100644 --- a/include/jlcxx/julia_headers.hpp +++ b/include/jlcxx/julia_headers.hpp @@ -1,6 +1,10 @@ #ifndef JLCXX_JULIA_HEADERS_HPP #define JLCXX_JULIA_HEADERS_HPP +#ifdef _MSC_VER + #include +#endif + #include #include From eac9dd1fff38abef2d024f19953f7bb9179cf27e Mon Sep 17 00:00:00 2001 From: PraneethJain Date: Wed, 27 Mar 2024 13:53:10 +0530 Subject: [PATCH 09/10] fix: add uv.h --- include/jlcxx/julia_headers.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/jlcxx/julia_headers.hpp b/include/jlcxx/julia_headers.hpp index 1c60a73..db915ed 100644 --- a/include/jlcxx/julia_headers.hpp +++ b/include/jlcxx/julia_headers.hpp @@ -2,6 +2,7 @@ #define JLCXX_JULIA_HEADERS_HPP #ifdef _MSC_VER + #include #include #endif From fc1abe929fb2fbbef2f0c2660426ecc5a5fe793f Mon Sep 17 00:00:00 2001 From: PraneethJain Date: Sun, 31 Mar 2024 11:40:25 +0530 Subject: [PATCH 10/10] test: switch back to Julia 1.6 --- .github/workflows/test-linux-mac.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-linux-mac.yml b/.github/workflows/test-linux-mac.yml index 596ae36..47e85a0 100644 --- a/.github/workflows/test-linux-mac.yml +++ b/.github/workflows/test-linux-mac.yml @@ -15,7 +15,7 @@ jobs: fail-fast: false matrix: version: - - "1.7" + - "1.6" - "1.10" - "nightly" os: