44#include " type_conversion.hpp"
55#include " tuple.hpp"
66
7+ #if (JULIA_VERSION_MAJOR * 100 + JULIA_VERSION_MINOR) >= 111
8+ // yes the arguments are really switched
9+ #define jl_arrayset (args, s, i ) jl_array_ptr_set(args, i, s)
10+ #endif
11+
712namespace jlcxx
813{
914
@@ -164,6 +169,14 @@ struct ArrayElementType<T,WrappedPtrTrait>
164169template <typename ValueT, int Dim = 1 >
165170class ArrayRef
166171{
172+ // / wrapper for julia jl_array_data for different julia versions
173+ static julia_t * jlcxx_array_data (jl_array_t * arr) {
174+ #if (JULIA_VERSION_MAJOR * 100 + JULIA_VERSION_MINOR) >= 111
175+ return jl_array_data (arr, julia_t );
176+ #else
177+ return static_cast <julia_t *>(jl_array_data (arr));
178+ #endif
179+ }
167180public:
168181
169182 using julia_t = typename detail::ArrayElementType<ValueT>::type;
@@ -191,22 +204,22 @@ class ArrayRef
191204
192205 iterator begin ()
193206 {
194- return iterator (static_cast < julia_t *>( jl_array_data ( wrapped () )));
207+ return iterator (jlcxx_array_data ( wrapped ()));
195208 }
196209
197210 const_iterator begin () const
198211 {
199- return const_iterator (static_cast < julia_t *>( jl_array_data ( wrapped () )));
212+ return const_iterator (jlcxx_array_data ( wrapped ()));
200213 }
201214
202215 iterator end ()
203216 {
204- return iterator (static_cast < julia_t *>( jl_array_data ( wrapped () )) + jl_array_len (wrapped ()));
217+ return iterator (jlcxx_array_data ( wrapped ()) + jl_array_len (wrapped ()));
205218 }
206219
207220 const_iterator end () const
208221 {
209- return const_iterator (static_cast < julia_t *>( jl_array_data ( wrapped () )) + jl_array_len (wrapped ()));
222+ return const_iterator (jlcxx_array_data ( wrapped ()) + jl_array_len (wrapped ()));
210223 }
211224
212225 void push_back (const ValueT& val)
@@ -223,12 +236,12 @@ class ArrayRef
223236
224237 const julia_t * data () const
225238 {
226- return ( julia_t *) jl_array_data (wrapped ());
239+ return jlcxx_array_data (wrapped ());
227240 }
228241
229242 julia_t * data ()
230243 {
231- return ( julia_t *) jl_array_data (wrapped ());
244+ return jlcxx_array_data (wrapped ());
232245 }
233246
234247 std::size_t size () const
0 commit comments