From d39426af61030cd8ef332edf92453f5c5c9cc8e6 Mon Sep 17 00:00:00 2001 From: Benjamin Lorenz Date: Sat, 28 Oct 2023 15:57:08 +0200 Subject: [PATCH] julia 1.11: add some workarounds for jl_array changes --- include/jlcxx/array.hpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/include/jlcxx/array.hpp b/include/jlcxx/array.hpp index 0891384..7984b05 100644 --- a/include/jlcxx/array.hpp +++ b/include/jlcxx/array.hpp @@ -4,6 +4,11 @@ #include "type_conversion.hpp" #include "tuple.hpp" +#if (JULIA_VERSION_MAJOR * 100 + JULIA_VERSION_MINOR) >= 111 +// yes the arguments are really switched +#define jl_arrayset(args, s, i) jl_array_ptr_set(args, i, s) +#endif + namespace jlcxx { @@ -164,6 +169,14 @@ struct ArrayElementType template class ArrayRef { + /// wrapper for julia jl_array_data for different julia versions + static julia_t* jlcxx_array_data(jl_array_t* arr) { +#if (JULIA_VERSION_MAJOR * 100 + JULIA_VERSION_MINOR) >= 111 + return jl_array_data(arr, julia_t); +#else + return static_cast(jl_array_data(arr)); +#endif + } public: using julia_t = typename detail::ArrayElementType::type; @@ -191,22 +204,22 @@ class ArrayRef iterator begin() { - return iterator(static_cast(jl_array_data(wrapped()))); + return iterator(jlcxx_array_data(wrapped())); } const_iterator begin() const { - return const_iterator(static_cast(jl_array_data(wrapped()))); + return const_iterator(jlcxx_array_data(wrapped())); } iterator end() { - return iterator(static_cast(jl_array_data(wrapped())) + jl_array_len(wrapped())); + return iterator(jlcxx_array_data(wrapped()) + jl_array_len(wrapped())); } const_iterator end() const { - return const_iterator(static_cast(jl_array_data(wrapped())) + jl_array_len(wrapped())); + return const_iterator(jlcxx_array_data(wrapped()) + jl_array_len(wrapped())); } void push_back(const ValueT& val) @@ -223,12 +236,12 @@ class ArrayRef const julia_t* data() const { - return (julia_t*)jl_array_data(wrapped()); + return jlcxx_array_data(wrapped()); } julia_t* data() { - return (julia_t*)jl_array_data(wrapped()); + return jlcxx_array_data(wrapped()); } std::size_t size() const