Skip to content

Commit

Permalink
Adjust to reinterpret change (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
Keno authored and ararslan committed Oct 10, 2017
1 parent d89aa72 commit 103b9a5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions src/JLD.jl
Original file line number Diff line number Diff line change
Expand Up @@ -592,15 +592,17 @@ _write(parent::Union{JldFile, JldGroup}, path::String, data::Array{Union{}},
function h5convert_array(f::JldFile, data::Array,
dtype::JldDatatype, wsession::JldWriteSession)
if dtype == JLD_REF_TYPE
refs = Vector{HDF5ReferenceObj}(length(data))
# For type stability, return as Vector{UInt8}
refs = VERSION < v"0.7.0-DEV.2083" ? reinterpret(UInt8,Vector{HDF5ReferenceObj}(length(data))) : Vector{UInt8}(length(data)*sizeof(HDF5ReferenceObj))
arefs = reinterpret(HDF5ReferenceObj, refs)
for i = 1:length(data)
if isassigned(data, i)
refs[i] = write_ref(f, data[i], wsession)
arefs[i] = write_ref(f, data[i], wsession)
else
refs[i] = HDF5.HDF5ReferenceObj_NULL
arefs[i] = HDF5.HDF5ReferenceObj_NULL
end
end
reinterpret(UInt8, refs) # for type stability
refs
else
gen_h5convert(f, eltype(data))
h5convert_vals(f, data, dtype, wsession)
Expand Down
6 changes: 3 additions & 3 deletions src/JLD00.jl
Original file line number Diff line number Diff line change
Expand Up @@ -525,13 +525,13 @@ end

# Write "basic" types
function write(parent::Union{JldFile, JldGroup}, name::String,
data::Union{T, Array{T}}, astype::String) where T<:Union{HDF5BitsKind, String}
data::Union{T, StridedArray{T}}, astype::String) where T<:Union{HDF5BitsKind, String}
# Create the dataset
dset, dtype = d_create(parent.plain, name, data)
try
# Write the attribute
a_write(dset, name_type_attr, astype)
isa(data, Array) && isempty(data) && a_write(dset, "dims", [size(data)...])
isa(data, StridedArray) && isempty(data) && a_write(dset, "dims", [size(data)...])
# Write the data
HDF5.writearray(dset, dtype.id, data)
finally
Expand Down Expand Up @@ -602,7 +602,7 @@ function write(parent::Union{JldFile, JldGroup}, name::String, c::Complex)
write(parent, name, reim, full_typename(typeof(c)))
end
function write(parent::Union{JldFile, JldGroup}, name::String, C::Array{T}) where T<:Complex
reim = reinterpret(realtype(T), C, ntuple(i->i==1 ? 2 : size(C,i-1), ndims(C)+1))
reim = reinterpret(realtype(T), reshape(C, ntuple(i->i==1 ? 1 : size(C,i-1), ndims(C)+1)))
write(parent, name, reim, full_typename(typeof(C)))
end

Expand Down

0 comments on commit 103b9a5

Please sign in to comment.