-
-
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
Support for "recursive" unsafe_wrap
#44
Comments
Indeed, this would be a great feature! It will likely require use of another operator (basically like C does): outer.inner->val = 3 So finding something like an |
Couldn't this be achieved by just skipping the first outer_ptr->inner->val = 3 and would not have to worry about operator precedence. |
Yes, that should be achievable... I've used C for over 25 years, and I just now learned this little tidbit of |
Thanks for adding this feature so quickly. However, now I am wondering: How do I access the pointer values of a nested structure when I need that to, e.g., pass it back to a C function? Preferrably in a way that has zero overhead (i.e., without having to create a |
I'm not exactly sure what you mean, but do you need to get a pointer to a nested struct? Something like this: struct Outer {
struct Inner {
int i;
} inner;
};
struct Outer o;
init(&o.inner); |
No, I was rather thinking about struct Inner {
int i;
};
struct Outer {
Inner* inner;
};
struct Outer o;
init(o.inner); But the answer to your example would be interesting as well! P.S.: Please excuse if this is not valid C code, I'm coming from C++ 🙈 |
Ahh, yes, that is precisely what #46 now allows. So this is what that would look like in Julia: o = Outer(undef)
init(o.inner) # init(ptr::Ptr{Inner}) = ... Haha, strikingly similar... |
OK, so |
Yes, any pointer to a x = o.inner # x::Ptr{Inner}
x.i = 3
o.inner.i == 3 |
I was wondering if it is possible (currently, and if not, in general) to use
unsafe_wrap
in a recursive manner. What I am thinking about is the following:Is something like this at all feasible to do? It would be a great boost to convenience, but I immediately see the challenge that you probably would need to keep track of the types for which you can do this conversion automatically, i.e., for which there are
@cstruct
s available.The text was updated successfully, but these errors were encountered: