I’m embedding Julia in C and I would like to be able to create named tuples with the number of filelds, their names and types being determined at runtime.
I am currently able to create a standard tuple like this:
jl_value_t *types[3] = {(jl_value_t *) jl_float64_type,
(jl_value_t *) jl_int64_type,
(jl_value_t *) jl_int64_type};
jl_tupletype_t *tt = jl_apply_tuple_type_v(types, 3);
jl_value_t *tup_values[3] = {(jl_value_t *) jl_box_float64(2.2),
(jl_value_t *) jl_box_int64(2),
(jl_value_t *) jl_box_int64(3)};
jl_value_t *tuple = jl_new_structv(tt, tup_values, 3);
How could I also include the field names in the tuple object, so as to create a named tuple instead?
jl_value_t *names[3] = {(jl_value_t *) jl_cstr_to_string("key1"),
(jl_value_t *) jl_cstr_to_string("key2"),
(jl_value_t *) jl_cstr_to_string("key3")};
Thank you very much.