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

Don't use jl_value_ptr #267

Merged
merged 1 commit into from
Aug 28, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/callback.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function julia_extptr_callback(p::Ptr{ListSxp})
# julia function pointer
f_sxp = car(l)::Ptr{ExtPtrSxp}
ptr = ccall((:R_ExternalPtrAddr, libR), Ptr{Cvoid}, (Ptr{ExtPtrSxp},), f_sxp)
f = unsafe_pointer_to_objref(ptr)
f = unsafe_pointer_to_objref(ptr)[]
l = cdr(l)

# # extract arguments
Expand Down Expand Up @@ -111,9 +111,11 @@ We store the pointer and the object in a const Dict to prevent it being
removed by the Julia GC.
"""
function sexp(::Type{RClass{:externalptr}}, j)
jptr = ccall(:jl_value_ptr, Ptr{Cvoid}, (Any,), j)
# wrap in a `Ref`
refj = Ref(j)
jptr = pointer_from_objref(refj)
s = makeExternalPtr(jptr)
jtypExtPtrs[s] = j
jtypExtPtrs[s] = refj
registerCFinalizerEx(s)
s
end
Expand Down