-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Allow passing NTuple{N,T} as Ref{T}/Ptr{T} to ccall #34199
Conversation
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.
This looks nice—a bit like how we handle Array objects.
b1263e5
to
709169d
Compare
709169d
to
9556d49
Compare
NEWS item added (First Post!) |
convert(Ptr{T}, unsafe_convert(Ptr{NTuple{N,T}}, r)) | ||
unsafe_convert(::Type{Ptr{T}}, r::Ref{NTuple{N,T}}) where {N,T} = | ||
convert(Ptr{T}, unsafe_convert(Ptr{NTuple{N,T}}, r)) | ||
unsafe_convert(::Type{Ptr{T}}, r::Ptr{NTuple{N,T}}) where {N,T} = |
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.
I believe this method is redundant? (There is already an unsafe_convert method to go between pointer types.)
This makes it convenient when working with APIs that use small arrays. Based on discussion in https://discourse.julialang.org/t/ccall-with-pointer-argument-to-array-of-custom-type-via-an-ntuple-of-immutables/1048/2
385e710
to
4609ada
Compare
This makes it convenient when working with APIs that use small arrays. Based on discussion in https://discourse.julialang.org/t/ccall-with-pointer-argument-to-array-of-custom-type-via-an-ntuple-of-immutables/1048/2
This makes it convenient when working with APIs that use small arrays.
Based on discussion on Slack with @vtjnash and Discourse comment by @yuyichao