-
Notifications
You must be signed in to change notification settings - Fork 5
Closed
Description
I have realized that some structs from p4est only have data as single fieldname and the access to the actual fields is defined by Base.getproperty, e.g. for p4est_quadrant. This currently makes it impossible to access the data for PointerWrapper-wrapped pointers by pw.fieldname[], for example:
julia> using P4est
julia> using MPI; MPI.Init()
MPI.ThreadLevel(2)
julia> connectivity = p4est_connectivity_new_periodic()
Ptr{p4est_connectivity} @0x0000000002fccd80
julia> p4est = p4est_new_ext(MPI.COMM_WORLD, connectivity, 0, 2, 0, 0, C_NULL, C_NULL)
Into p4est_new with min quadrants 0 level 2 uniform 0
New p4est with 1 trees on 1 processors
Initial level 2 potential global quadrants 16 per tree 16
Done p4est_new with 10 total quadrants
Ptr{P4est.LibP4est.p4est} @0x0000000002b57d80
julia> p4est_pw = PointerWrapper(p4est)
PointerWrapper{P4est.LibP4est.p4est}(Ptr{P4est.LibP4est.p4est} @0x0000000002b57d80)
julia> p4est_pw.global_first_position.level[] # This should work
ERROR: type p4est_quadrant has no field level
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:35
[2] getproperty(pw::PointerWrapper{p4est_quadrant}, name::Symbol)
@ P4est.PointerWrappers ~/.julia/packages/P4est/XU3GX/src/pointerwrappers.jl:61
[3] top-level scope
@ REPL[7]:1
julia> p4est_pw.global_first_position[].level # This is a way out, but shouldn't be necessary
29I guess to cure this issue we need to adjust the getproperty function from PointerWrapper to not only look for fieldnames(T) (since e.g. fieldnames(p4est_quadrant) is (:data,) and not (:x, :y, :level, :pad8, :pad16, :p,)), but for the actual fields we can access via Base.getproperty. However, I'm not quite sure how exactly to do that. Any ideas on that or other possibilities to solve the problem, @ranocha, @sloede?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels