Skip to content
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

Merged
merged 1 commit into from
Jan 28, 2020
Merged

Conversation

simonbyrne
Copy link
Contributor

@simonbyrne simonbyrne commented Dec 26, 2019

This makes it convenient when working with APIs that use small arrays.

Based on discussion on Slack with @vtjnash and Discourse comment by @yuyichao

Copy link
Sponsor Member

@vtjnash vtjnash left a 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.

base/refpointer.jl Outdated Show resolved Hide resolved
@ararslan ararslan added the needs news A NEWS entry is required for this change label Dec 31, 2019
@simonbyrne simonbyrne removed the needs news A NEWS entry is required for this change label Jan 2, 2020
@simonbyrne
Copy link
Contributor Author

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} =
Copy link
Sponsor Member

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.)

base/refpointer.jl Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants