Translating a C type with Julia embedded to a Julia type of the same layout

Hi,

I am trying to figure out the Julia equivalents of the types in this Julia embedded struct https://github.com/JuliaLang/julia/blob/master/src/julia.h#L1615. Is there any mapping list (couldn’t find in the docs) of what the jl_ types (and the other ones) map to in Julia? I want to translate this whole type to Julia, such that the Julia and C types will have the same memory layout. Any tips?

Thanks a lot!

jl_task_t is mapped to the Task type in julia and you should just use that if possible. (However for Task there are several hidden fields after the ones which are exposed to julia, marked in the source with the “hidden fields” comment. These are generally the parts which are not required on the julia side and have no neat / safe representation there. Like the task’s stack, for instance.)

Generally to know about how types in the C runtime are reflected into julia, you can grep for jl_new_datatype. Nearly all the uses of this are in src/jltypes.c (other than Task, which is in task.c).

1 Like

Thanks for the tips and info. The hidden fields seem hard to crack though.

I’m not sure exactly what you mean by that :slight_smile: Do you need to look at the hidden fields and if so, why?

I will reconsider what I need to do.