-
Notifications
You must be signed in to change notification settings - Fork 10
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
Minor NSArray improvements #26
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #26 +/- ##
==========================================
+ Coverage 69.48% 69.68% +0.19%
==========================================
Files 9 9
Lines 626 630 +4
==========================================
+ Hits 435 439 +4
Misses 191 191 ☔ View full report in Codecov by Sentry. |
Test failures unrelated; looks like the dispatch tests are a little fragile. |
# XXX: it's too bad `cconvert` cannot do the `[pointer(obj) for obj in objs]` for us | ||
# (because we can only derive unsafe references in `unsafe_convert`) | ||
Base.unsafe_convert(T::Type{<:id}, ptrs::Vector{<:id}) = | ||
reinterpret(T, pointer(ptrs)) |
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.
FWIW, this is what Base.RefArray
is for doing, as it will recursively derive a pointer for you after cconverting recursively
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.
Ah, interesting, I figured something like that would exist already.
I think I'll have to copy the pattern though, as AFAIU RefArray only works to ultimately convert to a Ptr, while we're using a custom id
pointer here.
EDIT: #27
Fixes #25
This prevents constructing invalid NSArray objects (and likely segfaulting) by both constraining the type signature, and by not using the questionable
Ptr{id{Object}}
type signature (id
is already a pointer, and relying on Julia'sPtr
leads to surprising automatic conversion from otherwise incompatible array values).