-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Our current setup using CBindingGen will not work on Julia v1.7, see #37. Thus, we need to switch to CBinding.jl v1.0 or Clang.jl. However, neither option (CBinding.jl or Clang.jl) is perfect right now, as seen in #38 and discussed on Slack. Here is a summary of the current state.
Clang.jl
The new generator interface of Clang.jl looks promising. It basically creates Julia code to use the standard Julia interface for calling C code. However, it has some limitations such as
- no support of
va_listarguments - there is no REPL tab completion for properties defined automatically (REPL autocompletion JuliaInterop/Clang.jl#316)
- we don't get docstrings by default but there might be ways to achieve this, see Function and other signatures in comments JuliaInterop/Clang.jl#195
CBinding.jl v1.0
CBinding.jl provides another way of wrapping C code but doesn't use the Julia base C interface. This can make it more difficult to understand what's going on (e.g., trixi-framework/Trixi.jl#637 (comment)) but it might also be more intuitive sometimes. However, it doesn't work right now as we would like, see #38...
Patterns currently in use in Trixi.jl based on CBindingGen v0.9
Here is a list of the access patterns that we use in Trixi.jl at the moment.
p4est.connectivityconn.num_treesconn.num_verticesunsafe_wrap(Array, conn.vertices, (3, n_vertices))unsafe_wrap(Array, conn.tree_to_vertex, (2^NDIMS, n_trees))Ptr{Int}(quadrant.p.user_data)tree = unsafe_load_tree(info.p4est, info.treeid + 1)tree.quadrants_offsetquad_id = offset + info.quadidPtr{Int}(info.quad.p.user_data)quadrants = unsafe_wrap_sc(p4est_quadrant_t, trees[tree].quadrants)quad.x,quad.y,quad.zside.is_hanginglocal_quad_id = side.is.full.quadidinfo.sides.elem_countsides[1].treeidtrees[1].quadrants_offset