Embedding: jl_new_array signature seems incorrect in documentation


#1

Up until v0.3, the signature of jl_new_array was

jl_array_t *jl_new_array(jl_value_t *atype, jl_tuple_t *dims)

And as off v0.4, the signature has changed to

jl_array_t *jl_new_array(jl_value_t *atype, jl_value_t *dims)

The documentation still reflects the old signature: https://docs.julialang.org/en/latest/devdocs/object.html#Object-allocation-1

More practically, I wonder what is the right way to allocate the dims tuple to be passed to jl_new_array with a given size from the C API. Is there any example of that somewhere?


#2

It is still a tuple though it’s not called jl_tuple_t anymore. You can create the tuple type with jl_apply_tuple_type or jl_apply_tuple_type_v and then allocate the object with jl_new_bits or jl_new_struct_uninit. The layout is just an array of Int so that’s what you need to pass to jl_new_bits or cast the result of jl_new_struct_uninit to before filling the numbers in.


#3

Yay, it works! Thanks for helping.