Unboxing while embedding Julia in C++?

Hello!

So I am embedding some Julia code in C++, and this Julia code returns;

2×2 Array{Array{Int64,1},2}:
 [2812, 2126, 74, 1469, 892, 1881, 1693, 318, 1337, 2805  …  2742, 1390, 1916, 2307, 1110, 6, 856, 2408, 2786, 218]       …  [1760, 1090, 2381, 2376, 1265, 905, 1461, 2351, 1273, 880  …  618, 2298, 321, 420, 1035, 1042, 1717, 2180, 2440, 1473]
 [1704, 29, 2564, 176, 2420, 1481, 1124, 2284, 2597, 1442  …  2488, 2475, 2260, 2151, 1366, 341, 2772, 2432, 2346, 2224]     [306, 1316, 2111, 1333, 1671, 1131, 2553, 1662, 2308, 2502  …  632, 1140, 2417, 186, 1535, 1038, 1241, 2055, 322, 2663]

I am trying then to return it in a way so that I can use it in my C++ application, but I have some trouble doing this since it is an array of an array, which I cannot figure out from this documention of how to do, https://docs.julialang.org/en/v1/manual/embedding/. I can construct the inner array as:

jl_value_t *innerarray_type = jl_apply_array_type((jl_value_t*)jl_int64_type, 1);

But cannot figure out how to construct the outer array, which consists of the inner array.

Secondly, I have found a function which supposedly should return the type given as;

jl_typeof()

But again I have trouble unboxing this properly. Can anyone point me in the right direction?

Kind regards

I will post my personal solution. I ended up changing the array to:

4x1 Array{Array{Int64,1},1}:

And then the following code would work:

    jl_function_t *RangeList = jl_get_function(modJulia,"RangeSearch");

    jl_array_t *retRL = (jl_array_t *)jl_call2(RangeList,(jl_value_t*)pre_data,jl_box_float64(0.1));
    
    // Protect `var` until we add its reference to `refs`.
    JL_GC_PUSH1(&retRL);

    const size_t nsize = jl_array_dim(retRL,0);
    int64_t* p = (int64_t*)jl_array_data(retRL);
    
    JL_GC_POP();

There is a small error in the documentation, it will not work, if you do not add “(jl_value_t*)” infront of your data pointer, in this case, data_pre.

Kind regards