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

Suppress warnings on julia v0.6 #26

Merged
merged 9 commits into from
Apr 10, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion src/RData.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module RData
using Compat, DataFrames, GZip, FileIO
import DataArrays: data
import DataFrames: identifier
import Compat: UTF8String, unsafe_string
import Compat: unsafe_string
import FileIO: load

export
Expand Down
2 changes: 1 addition & 1 deletion src/config.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const LONG_VECTOR_SUPPORT = (Sys.WORD_SIZE > 32) # disable long vectors support

const RVecLength = LONG_VECTOR_SUPPORT ? Int64 : Int

const RString = UTF8String # default String container for R string
const RString = String # default String container for R string
const Hash = Dict{RString, Any}

const emptyhash = Hash()
Expand Down
2 changes: 1 addition & 1 deletion src/io/ASCIIIO.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
type ASCIIIO{T<:IO} <: RDAIO
sub::T # underlying IO stream

@compat (::Type{ASCIIIO}){T<:IO}(io::T) = new{T}(io)
(::Type{ASCIIIO}){T<:IO}(io::T) = new{T}(io)
end

readint32(io::ASCIIIO) = parse(Int32, readline(io.sub))
Expand Down
2 changes: 1 addition & 1 deletion src/io/NativeIO.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"""
type NativeIO{T<:IO} <: RDAIO
sub::T # underlying IO stream
@compat (::Type{NativeIO}){T<:IO}(io::T) = new{T}(io)
(::Type{NativeIO}){T<:IO}(io::T) = new{T}(io)
end
13 changes: 9 additions & 4 deletions src/io/XDRIO.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,26 @@
type XDRIO{T<:IO} <: RDAIO
sub::T # underlying IO stream
buf::Vector{UInt8} # buffer for strings
@compat (::Type{XDRIO}){T <: IO}(io::T) = new{T}(io, Array{UInt8}(1024))
@compat (::Type{XDRIO}){T <: IO}(io::T) = new{T}(io, Vector{UInt8}(1024))
end

readint32(io::XDRIO) = ntoh(read(io.sub, Int32))
readuint32(io::XDRIO) = ntoh(read(io.sub, UInt32))
readfloat64(io::XDRIO) = reinterpret(Float64, ntoh(read(io.sub, Int64)))

readintorNA(io::XDRIO) = readint32(io)
readintorNA(io::XDRIO, n::RVecLength) = [readint32(io) for _ in 1:n]
function readintorNA(io::XDRIO, n::RVecLength)
v = read(io.sub, Int32, n)
map!(ntoh, v, v)
end

# this method have Win32 ABI issues, see JuliaStats/RData.jl#5
# R's NA is silently converted to NaN when the value is loaded in the register(?)
#readfloatorNA(io::XDRIO) = readfloat64(io)

readfloatorNA(io::XDRIO, n::RVecLength) = [readfloat64(io) for _ in 1:n]
function readfloatorNA(io::XDRIO, n::RVecLength)
v = read(io.sub, UInt64, n)
reinterpret(Float64, map!(ntoh, v, v))
end

readuint8(io::XDRIO, n::RVecLength) = readbytes(io.sub, n)

Expand Down
4 changes: 2 additions & 2 deletions src/readers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ function readbytecodeconsts(bctx::BytecodeContext)
readitem(bctx.ctx)
end
end
return RList(v, Hash())
return RList(v)
end

function readbytecodecontents(bctx::BytecodeContext)
Expand All @@ -254,7 +254,7 @@ end
Definition of R type.
"""
immutable SXTypeInfo
name::UTF8String # R type name
name::String # R type name
reader::Function # function to deserialize R type from RDA stream
end

Expand Down
4 changes: 3 additions & 1 deletion src/sxtypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,10 @@ end
type RVector{T, S} <: RVEC{T, S}
data::Vector{T}
attr::Hash # collection of R object attributes

@compat RVector{T,S}(v::Vector{T} = T[], attr::Hash = Hash()) where {T,S} = new(v, attr)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIU @compat doesn't/cannot support 0.6 where syntax on 0.5. But, in fact, you don't need explicit type parameters here as they would be taken from the type definition. I hope this would work

RVector(v::Vector{T} = T[], attr::Hash = Hash()) = new(v, attr)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted the change but now get a warning

WARNING: deprecated syntax "inner constructor RVector(...) around /home/bates/.julia/v0.6/RData/src/sxtypes.jl:115".
Use "RVector{T,S}(...) where {T,S}" instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need (::Type{RVector{T,S}}){T,S}(v::Vector{T}=T[], attr::Hash=Hash()) = new{T,S}(v, attr)


end
RVector{T}(v::Vector{T} = T[]) = RVector(v, Hash())

const RLogicalVector = RVector{Int32, LGLSXP}
const RIntegerVector = RVector{Int32, INTSXP}
Expand Down