-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add sugar to set fields with PointerWrapper #77
Conversation
Codecov Report
@@ Coverage Diff @@
## main #77 +/- ##
=======================================
Coverage ? 15.63%
=======================================
Files ? 3
Lines ? 1516
Branches ? 0
=======================================
Hits ? 237
Misses ? 1279
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot! Having setproperty!
as analog of getproperty
is a nice idea.
@JoshuaLampert Could you please please have a look at this and merge it if it looks good to you?
Looks good from my side, thanks for the contribution! I wonder if it would be necessary to also add one or two examples to the docs for correctly using this feature. AFAIU, one has to GC-preserve any variables before getting their pointer, at least if the variable is not used afterwards anymore, such that the memory address remains valid. This is of course not an issue of PW but if Julia itself, however, since we expose some very low level stuff with a nice convenience layer, less experienced users might fall into hard-to-debug traps. I am thinking of maybe one example for a persistent variable to show general usage, and maybe one for a local variable where GC preserve is necessary for defined behavior. What do the others think? |
When this is documented this LGTM. Thanks! |
This enables the setting of the `user_pointer` field of a `p4est`. This is useful to access julia data in p4est's callback functions. For example: ``` conn = p4est_connectivity_new_brick(2, 2, 0, 0) p4est = p4est_new_ext(MPI.COMM_WORLD, conn, 0, 2, 0, 0, C_NULL, C_NULL) pw = PointerWrapper(p4est) pw.user_pointer = pointer_from_objref(Ref((3,4))) ```
Okay, I added a minimal example. |
Good point. Now that #74 is merged, I think we can proceed like this.
|
This enables the setting of the
user_pointer
field of ap4est
. This is useful to access julia data in p4est's callback functions. For example: