Skip to content

Commit

Permalink
Merge pull request #173 from JuliaInterop/0.6
Browse files Browse the repository at this point in the history
v0.6 compatibility
  • Loading branch information
randy3k authored Mar 15, 2017
2 parents 325e1a7 + 98fc1f8 commit 35a4095
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 81 deletions.
4 changes: 2 additions & 2 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
julia 0.5
DataStructures 0.4.3
DataFrames 0.8.4
DataFrames 0.9
NullableArrays 0.0.10
CategoricalArrays 0.0.6
Compat 0.8
Compat 0.20.0
@windows WinReg 0.2.0
12 changes: 6 additions & 6 deletions src/convert-base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ for (J,S) in ((:Integer,:IntSxp),

rcopy{T<:$J}(::Type{T},s::Ptr{$S}) = convert(T,s[1])
function rcopy{T<:$J}(::Type{Vector{T}},s::Ptr{$S})
a = Array(T,length(s))
a = Array{T}(length(s))
copy!(a,unsafe_vec(s))
a
end
function rcopy{T<:$J}(::Type{Array{T}},s::Ptr{$S})
a = Array(T,size(s)...)
a = Array{T}(size(s)...)
copy!(a,unsafe_vec(s))
a
end
Expand All @@ -157,12 +157,12 @@ rcopy(::Type{Cint},s::Ptr{LglSxp}) = convert(Cint,s[1])
rcopy(::Type{Bool},s::Ptr{LglSxp}) = s[1]!=0

function rcopy(::Type{Vector{Cint}},s::Ptr{LglSxp})
a = Array(Cint,length(s))
a = Array{Cint}(length(s))
copy!(a,unsafe_vec(s))
a
end
function rcopy(::Type{Vector{Bool}},s::Ptr{LglSxp})
a = Array(Bool,length(s))
a = Array{Bool}(length(s))
v = unsafe_vec(s)
for i = 1:length(a)
a[i] = v[i] != 0
Expand All @@ -178,12 +178,12 @@ function rcopy(::Type{BitVector},s::Ptr{LglSxp})
a
end
function rcopy(::Type{Array{Cint}},s::Ptr{LglSxp})
a = Array(Cint,size(s)...)
a = Array{Cint}(size(s)...)
copy!(a,unsafe_vec(s))
a
end
function rcopy(::Type{Array{Bool}},s::Ptr{LglSxp})
a = Array(Bool,size(s)...)
a = Array{Bool}(size(s)...)
v = unsafe_vec(s)
for i = 1:length(a)
a[i] = v[i] != 0
Expand Down
8 changes: 4 additions & 4 deletions src/eval.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ A pure julia wrapper of R_tryEval.
"""
function tryEval{S<:Sxp}(expr::Ptr{S}, env::Ptr{EnvSxp}=sexp(Const.GlobalEnv))
disable_sigint() do
status = Array(Cint,1)
status = Array{Cint}(1)
protect(expr)
protect(env)
val = ccall((:R_tryEval,libR),UnknownSxpPtr,(Ptr{S},Ptr{EnvSxp},Ptr{Cint}),expr,env,status)
Expand All @@ -20,9 +20,9 @@ function reval_p{S<:Sxp}(expr::Ptr{S}, env::Ptr{EnvSxp})
val, status = tryEval(expr, env)
flush_print_buffer(STDOUT)
if status !=0
error("RCall.jl: ", takebuf_string(errorBuffer))
error("RCall.jl: ", String(take!(errorBuffer)))
elseif nb_available(errorBuffer) != 0
warn("RCall.jl: ", takebuf_string(errorBuffer))
warn("RCall.jl: ", String(take!(errorBuffer)))
end
sexp(val)
end
Expand Down Expand Up @@ -59,7 +59,7 @@ reval(str::Union{AbstractString,Symbol}, env=Const.GlobalEnv) = RObject(reval_p(
function parseVector{S<:Sxp}(st::Ptr{StrSxp}, sf::Ptr{S}=sexp(Const.NilValue))
protect(st)
protect(sf)
status = Array(Cint,1)
status = Array{Cint}(1)
val = ccall((:R_ParseVector,libR),UnknownSxpPtr,
(Ptr{StrSxp},Cint,Ptr{Cint},UnknownSxpPtr),
st,-1,status,sf)
Expand Down
10 changes: 5 additions & 5 deletions src/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function rprint{S<:Sxp}(io::IO, s::Ptr{S})
tryEval(rlang_p(Const.BaseNamespace[Symbol("print.default")], :x), env)
end
env[:x] = Const.NilValue
write(io,takebuf_string(printBuffer))
write(io, String(take!(printBuffer)))
unprotect(2)
PrintBufferLocked = false
nothing
Expand All @@ -43,11 +43,11 @@ function show(io::IO,r::RObject)
# print error messages or warnings
# in general, only S3/S4 custom print will fail
if nb_available(errorBuffer) != 0
warn(takebuf_string(errorBuffer))
warn(String(take!(errorBuffer)))
end

# ggplot2's plot is displayed after `print` function is invoked,
# so we have to clear any displayed plots.
# so we have to clear any displayed String(take!(plots.)
isdefined(Main, :IJulia) && Main.IJulia.inited && ijulia_displayplots()
end

Expand Down Expand Up @@ -78,14 +78,14 @@ function flush_print_buffer(io::IO)
global PrintBufferLocked
# dump printBuffer's content when it is not locked
if !PrintBufferLocked && nb_available(printBuffer) != 0
write(io, takebuf_string(printBuffer))
write(io, String(take!(printBuffer)))
end
nothing
end

function flush_error_buffer(io::IO)
if nb_available(errorBuffer) != 0
write(io, takebuf_string(errorBuffer))
write(io, String(take!(errorBuffer)))
end
nothing
end
1 change: 1 addition & 0 deletions src/methods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ naeltype{S<:Integer}(::Type{S}) = Const.NaInt
naeltype{S<:Real}(::Type{S}) = Const.NaReal
naeltype(::Type{Complex}) = complex(Const.NaReal,Const.NaReal)
naeltype{S<:String}(::Type{S}) = sexp(Const.NaString)
naeltype(::Type{Union{}}) = Const.NaInt

"""
Check if values correspond to R's sentinel NA values.
Expand Down
4 changes: 2 additions & 2 deletions src/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function bracketed_paste_callback(s, o...)
end

LineEdit.edit_insert(sbuffer, input)
input = takebuf_string(sbuffer)
input = String(take!(sbuffer))

oldpos = start(input)
nextpos = 0
Expand Down Expand Up @@ -113,7 +113,7 @@ function respond(repl, main)
if !ok
return REPL.transition(s, :abort)
end
script = takebuf_string(buf)
script = String(take!(buf))
if !isempty(strip(script))
REPL.reset(repl)
repl_eval(script, repl.t.out_stream, repl.t.err_stream)
Expand Down
Loading

0 comments on commit 35a4095

Please sign in to comment.