diff --git a/REQUIRE b/REQUIRE index aefaac4e4..293a824b9 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,6 +1,6 @@ julia 0.6 BinDeps 0.6.0 Blosc -Compat 0.32.0 +Compat 0.61.0 @osx Homebrew 0.3.1 @windows WinRPM diff --git a/deps/build.jl b/deps/build.jl index a3a5442e4..346a24224 100644 --- a/deps/build.jl +++ b/deps/build.jl @@ -1,5 +1,6 @@ using BinDeps using Compat +using Compat.Libdl @BinDeps.setup diff --git a/src/HDF5.jl b/src/HDF5.jl index f4ad8f2c3..706718b19 100644 --- a/src/HDF5.jl +++ b/src/HDF5.jl @@ -4,14 +4,16 @@ module HDF5 using Compat -using Base: unsafe_convert -using Compat: StringVector +using Base: unsafe_convert, StringVector +using Compat: findfirst import Base: close, convert, done, eltype, endof, flush, getindex, ==, isempty, isvalid, length, names, ndims, next, parent, read, setindex!, show, size, sizeof, start, write, isopen +import Compat.Libdl + export # types HDF5Attribute, HDF5File, HDF5Group, HDF5Dataset, HDF5Datatype, @@ -320,7 +322,7 @@ mutable struct HDF5File <: DataFile function HDF5File(id, filename, toclose::Bool=true) f = new(id, filename) if toclose - finalizer(f, close) + @compat finalizer(close, f) end f end @@ -341,7 +343,7 @@ mutable struct HDF5Group <: DataFile function HDF5Group(id, file) g = new(id, file) - finalizer(g, close) + @compat finalizer(close, g) g end end @@ -360,7 +362,7 @@ mutable struct HDF5Dataset function HDF5Dataset(id, file) dset = new(id, file) - finalizer(dset, close) + @compat finalizer(close, dset) dset end end @@ -381,14 +383,14 @@ mutable struct HDF5Datatype function HDF5Datatype(id, toclose::Bool=true) nt = new(id, toclose) if toclose - finalizer(nt, close) + @compat finalizer(close, nt) end nt end function HDF5Datatype(id, file::HDF5File, toclose::Bool=true) nt = new(id, toclose, file) if toclose - finalizer(nt, close) + @compat finalizer(close, nt) end nt end @@ -407,7 +409,7 @@ mutable struct HDF5Dataspace function HDF5Dataspace(id) dspace = new(id) - finalizer(dspace, close) + @compat finalizer(close, dspace) dspace end end @@ -419,7 +421,7 @@ mutable struct HDF5Attribute function HDF5Attribute(id, file) dset = new(id, file) - finalizer(dset, close) + @compat finalizer(close, dset) dset end end @@ -438,7 +440,7 @@ mutable struct HDF5Properties function HDF5Properties(id, toclose::Bool=true) p = new(id, toclose) if toclose - finalizer(p, close) + @compat finalizer(close, p) end p end @@ -488,15 +490,15 @@ HDF5Vlen(A::Array{Array{T,N}}) where {T<:HDF5Scalar,N} = HDF5Vlen{T}(A) # For VLEN struct Hvl_t len::Csize_t - p::Ptr{Void} + p::Ptr{Cvoid} end const HVL_SIZE = sizeof(Hvl_t) # and determine the size of the buffer needed function vlenpack(v::HDF5Vlen{T}) where {T<:Union{HDF5Scalar,CharType}} len = length(v.data) Tp = t2p(T) # Ptr{UInt8} or Ptr{T} - h = Vector{Hvl_t}(len) + h = Vector{Hvl_t}(undef,len) for i = 1:len - h[i] = Hvl_t(convert(Csize_t, length(v.data[i])), convert(Ptr{Void}, unsafe_convert(Tp, v.data[i]))) + h[i] = Hvl_t(convert(Csize_t, length(v.data[i])), convert(Ptr{Cvoid}, unsafe_convert(Tp, v.data[i]))) end h end @@ -853,8 +855,8 @@ getindex(x::HDF5Attributes, name::String) = a_open(x.parent, name) # Path manipulation function split1(path::String) - off = search(path, '/') - if off == 0 + off = findfirst(isequal('/'),path) + if off === nothing return path, nothing else if off == 1 @@ -1065,8 +1067,8 @@ name(attr::HDF5Attribute) = h5a_get_name(attr.id) function names(x::Union{HDF5Group,HDF5File}) checkvalid(x) n = length(x) - res = Vector{String}(n) - buf = Vector{UInt8}(100) + res = Vector{String}(undef,n) + buf = Vector{UInt8}(undef,100) for i in 1:n len = h5g_get_objname_by_idx(x.id, i - 1, buf, length(buf)) if len >= length(buf) @@ -1081,10 +1083,10 @@ end function names(x::HDF5Attributes) checkvalid(x.parent) n = length(x) - res = Vector{String}(n) + res = Vector{String}(undef,n) for i in 1:n len = h5a_get_name_by_idx(x.parent.id, ".", H5_INDEX_NAME, H5_ITER_INC, i-1, "", 0, H5P_DEFAULT) - buf = Vector{UInt8}(len+1) + buf = Vector{UInt8}(undef,len+1) len = h5a_get_name_by_idx(x.parent.id, ".", H5_INDEX_NAME, H5_ITER_INC, i-1, buf, len+1, H5P_DEFAULT) res[i] = String(buf[1:len]) end @@ -1162,7 +1164,7 @@ dataspace(attr::HDF5Attribute) = HDF5Dataspace(h5a_get_space(checkvalid(attr).id # Create a dataspace from in-memory types dataspace(x::T) where {T<:HDF5Scalar} = HDF5Dataspace(h5s_create(H5S_SCALAR)) function _dataspace(sz::Tuple{Vararg{Int}}, max_dims::Union{Dims, Tuple{}}=()) - dims = Vector{Hsize}(length(sz)) + dims = Vector{Hsize}(undef,length(sz)) any_zero = false for i = 1:length(sz) dims[end-i+1] = sz[i] @@ -1188,7 +1190,7 @@ end dataspace(A::AbstractArray; max_dims::Union{Dims, Tuple{}} = ()) = _dataspace(size(A), max_dims) dataspace(str::String) = HDF5Dataspace(h5s_create(H5S_SCALAR)) dataspace(v::HDF5Vlen; max_dims::Union{Dims, Tuple{}}=()) = _dataspace(size(v.data), max_dims) -dataspace(n::Void) = HDF5Dataspace(h5s_create(H5S_NULL)) +dataspace(n::Nothing) = HDF5Dataspace(h5s_create(H5S_NULL)) dataspace(sz::Dims; max_dims::Union{Dims, Tuple{}}=()) = _dataspace(sz, max_dims) dataspace(sz1::Int, sz2::Int, sz3::Int...; max_dims::Union{Dims, Tuple{}}=()) = _dataspace(tuple(sz1, sz2, sz3...), max_dims) @@ -1265,7 +1267,7 @@ function read(obj::DatasetOrAttribute, ::Type{Array{T}}) where {T<:HDF5Scalar} return T[] end dims = size(obj) - data = Array{T}(dims) + data = Array{T}(undef,dims) readarray(obj, hdf5_type_id(T), data) data end @@ -1277,7 +1279,7 @@ end function read(obj::DatasetOrAttribute, ::Type{A}) where {A<:FixedArray} T = eltype(A) sz = size(A) - data = Array{T}(sz) + data = Array{T}(undef,sz) readarray(obj, hdf5_type_id(T), data) data end @@ -1288,7 +1290,7 @@ function read(obj::DatasetOrAttribute, ::Type{Array{A}}) where {A<:FixedArray} end sz = size(A) dims = size(obj) - data = Array{T}(sz..., dims...) + data = Array{T}(undef,sz..., dims...) nd = length(sz) hsz = Hsize[convert(Hsize,sz[nd-i+1]) for i = 1:nd] memtype_id = h5t_array_create(hdf5_type_id(T), convert(Cuint, length(sz)), hsz) @@ -1297,7 +1299,7 @@ function read(obj::DatasetOrAttribute, ::Type{Array{A}}) where {A<:FixedArray} finally h5t_close(memtype_id) end - ret = Array{Array{T}}(dims) + ret = Array{Array{T}}(undef,dims) # Because of garbage-collection concerns, it's best to copy the data L = prod(sz) for i = 1:prod(dims) @@ -1309,8 +1311,8 @@ end # Clean up string buffer according to padding mode function unpad(s::String, pad::Integer) if pad == H5T_STR_NULLTERM - v = search(s, '\0') - v == 0 ? s : s[1:v-1] + v = findfirst(isequal('\0'),s) + v === nothing ? s : s[1:v-1] elseif pad == H5T_STR_NULLPAD rstrip(s, '\0') elseif pad == H5T_STR_SPACEPAD @@ -1336,7 +1338,7 @@ function read(obj::DatasetOrAttribute, ::Type{S}) where {S<:String} else n = h5t_get_size(objtype.id) pad = h5t_get_strpad(objtype.id) - buf = Vector{UInt8}(n) + buf = Vector{UInt8}(undef,n) readarray(obj, objtype.id, buf) pbuf = String(buf) ret = unpad(pbuf, pad) @@ -1367,10 +1369,10 @@ function read(obj::DatasetOrAttribute, ::Type{Array{S}}) where {S<:String} return S[] else dspace = dataspace(obj) - ret = Array{S}(sz) + ret = Array{S}(undef,sz) if isvar # Variable-length - buf = Vector{Cstring}(len) + buf = Vector{Cstring}(undef,len) h5t_set_size(memtype_id, H5T_VARIABLE) readarray(obj, memtype_id, buf) for i = 1:len @@ -1379,14 +1381,14 @@ function read(obj::DatasetOrAttribute, ::Type{Array{S}}) where {S<:String} else # Fixed length ilen += 1 # for null terminator - buf = Vector{UInt8}(len*ilen) + buf = Vector{UInt8}(undef,len*ilen) h5t_set_size(memtype_id, ilen) readarray(obj, memtype_id, buf) src = 1 for i = 1:len - slen = findnext(buf, 0x00, src) - src # find null terminator + slen = coalesce(findnext(isequal(0x00), buf, src), 0) - src # find null terminator sv = StringVector(slen) - copy!(sv, 1, buf, src, slen) + copyto!(sv, 1, buf, src, slen) ret[i] = String(sv) src += ilen end @@ -1417,16 +1419,16 @@ function read_row(io::IO, membertype, membersize) row = Any[] for (dtype, dsize) in zip(membertype, membersize) if dtype === String - push!(row, unpad(read!(io, Vector{UInt8}(dsize)), H5T_STR_NULLPAD)) + push!(row, unpad(read!(io, Vector{UInt8}(undef,dsize)), H5T_STR_NULLPAD)) elseif dtype<:HDF5.FixedArray && eltype(dtype)<:HDF5BitsKind - val = read!(io, Vector{eltype(dtype)}(prod(size(dtype)))) + val = read!(io, Vector{eltype(dtype)}(undef,prod(size(dtype)))) push!(row, reshape(val, size(dtype))) elseif dtype<:HDF5BitsKind push!(row, read(io, dtype)) else # for other types, just store the raw bytes and let the user # decide what to do - push!(row, read!(io, Vector{UInt8}(dsize))) + push!(row, read!(io, Vector{UInt8}(undef,dsize))) end end return (row...,) @@ -1439,11 +1441,11 @@ function read(obj::HDF5Dataset, T::Union{Type{Array{HDF5Compound{N}}},Type{HDF5C local membername; local membertype; local memberoffset; local memberfiletype; local membersize; try - memberfiletype = Vector{HDF5Datatype}(N) - membertype = Vector{Type}(N) - membername = Vector{String}(N) - memberoffset = Vector{UInt64}(N) - membersize = Vector{UInt32}(N) + memberfiletype = Vector{HDF5Datatype}(undef,N) + membertype = Vector{Type}(undef,N) + membername = Vector{String}(undef,N) + memberoffset = Vector{UInt64}(undef,N) + membersize = Vector{UInt32}(undef,N) for i = 1:N filetype = HDF5Datatype(h5t_get_member_type(t.id, i-1)) memberfiletype[i] = filetype @@ -1462,7 +1464,7 @@ function read(obj::HDF5Dataset, T::Union{Type{Array{HDF5Compound{N}}},Type{HDF5C h5t_insert(memtype_id, membername[i], memberoffset[i], memberfiletype[i].id) # FIXME strings end # Read the raw data - buf = Vector{UInt8}(length(obj)*sz) + buf = Vector{UInt8}(undef,length(obj)*sz) h5d_read(obj.id, memtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) # Convert to the appropriate data format using iobuffer @@ -1490,13 +1492,13 @@ function read(obj::DatasetOrAttribute, ::Type{Array{HDF5Opaque}}) objtype = datatype(obj) try len = h5t_get_size(objtype) - buf = Vector{UInt8}(prod(sz)*len) + buf = Vector{UInt8}(undef,prod(sz)*len) tag = h5t_get_tag(objtype.id) readarray(obj, objtype.id, buf) finally close(objtype) end - data = Array{Array{UInt8}}(sz) + data = Array{Array{UInt8}}(undef,sz) for i = 1:prod(sz) data[i] = buf[(i-1)*len+1:i*len] end @@ -1515,12 +1517,12 @@ function read(obj::DatasetOrAttribute, ::Type{HDF5Vlen{T}}) where {T<:Union{HDF5 sz = size(obj) len = prod(sz) # Read the data - structbuf = Vector{Hvl_t}(len) + structbuf = Vector{Hvl_t}(undef,len) memtype_id = h5t_vlen_create(hdf5_type_id(T)) readarray(obj, memtype_id, structbuf) h5t_close(memtype_id) # Unpack the data - data = Array{atype(T)}(sz) + data = Array{atype(T)}(undef,sz) for i = 1:len h = structbuf[i] data[i] = p2a(convert(Ptr{T}, h.p), Int(h.len)) @@ -1684,7 +1686,7 @@ function _getindex(dset::HDF5Dataset, T::Type, indices::Union{AbstractRange{Int} error("Dataset indexing (hyperslab) is available only for bits types") end dsel_id = hyperslab(dset, indices...) - ret = Array{T}(map(length, indices)) + ret = Array{T}(undef,map(length, indices)) memtype = datatype(ret) memspace = dataspace(ret) try @@ -1759,9 +1761,9 @@ function hyperslab(dset::HDF5Dataset, indices::Union{AbstractRange{Int},Int}...) error("Wrong number of indices supplied, supplied length $(length(indices)) but expected $(n_dims).") end dsel_id = h5s_copy(dspace.id) - dsel_start = Vector{Hsize}(n_dims) - dsel_stride = Vector{Hsize}(n_dims) - dsel_count = Vector{Hsize}(n_dims) + dsel_start = Vector{Hsize}(undef,n_dims) + dsel_stride = Vector{Hsize}(undef,n_dims) + dsel_count = Vector{Hsize}(undef,n_dims) for k = 1:n_dims index = indices[n_dims-k+1] if isa(index, Integer) @@ -1802,7 +1804,7 @@ d_create_external(parent::Union{HDF5File, HDF5Group}, name::String, filepath::St function do_write_chunk(dataset::HDF5Dataset, offset, chunk_bytes::Vector{UInt8}, filter_mask=0) checkvalid(dataset) - offs = collect(Hsize, reverse(offset))-1 + offs = collect(Hsize, reverse(offset)) .- 1 h5do_write_chunk(dataset, H5P_DEFAULT, UInt32(filter_mask), offs, length(chunk_bytes), chunk_bytes) end @@ -2019,17 +2021,17 @@ for (jlname, h5name, outtype, argtypes, argsyms, msg) in (:h5_open, :H5open, Herr, (), (), "Error initializing the HDF5 library"), (:h5_set_free_list_limits, :H5set_free_list_limits, Herr, (Cint, Cint, Cint, Cint, Cint, Cint), (:reg_global_lim, :reg_list_lim, :arr_global_lim, :arr_list_lim, :blk_global_lim, :blk_list_lim), "Error setting limits on free lists"), (:h5a_close, :H5Aclose, Herr, (Hid,), (:id,), "Error closing attribute"), - (:h5a_write, :H5Awrite, Herr, (Hid, Hid, Ptr{Void}), (:attr_hid, :mem_type_id, :buf), "Error writing attribute data"), + (:h5a_write, :H5Awrite, Herr, (Hid, Hid, Ptr{Cvoid}), (:attr_hid, :mem_type_id, :buf), "Error writing attribute data"), (:h5d_close, :H5Dclose, Herr, (Hid,), (:dataset_id,), "Error closing dataset"), (:h5d_flush, :H5Dflush, Herr, (Hid,), (:dataset_id,), "Error flushing dataset"), - (:h5d_oappend, :H5DOappend, Herr, (Hid, Hid, Cuint, Hsize, Hid, Ptr{Void}) , (:dset_id, :dxpl_id, :index, :num_elem, :memtype, :buffer), "error appending"), - (:h5do_write_chunk, :H5DOwrite_chunk, Herr, (Hid, Hid, Int32, Ptr{Hsize}, Csize_t, Ptr{Void}), (:dset_id, :dxpl_id, :filter_mask, :offset, :bufsize, :buf), "Error writing chunk"), + (:h5d_oappend, :H5DOappend, Herr, (Hid, Hid, Cuint, Hsize, Hid, Ptr{Cvoid}) , (:dset_id, :dxpl_id, :index, :num_elem, :memtype, :buffer), "error appending"), + (:h5do_write_chunk, :H5DOwrite_chunk, Herr, (Hid, Hid, Int32, Ptr{Hsize}, Csize_t, Ptr{Cvoid}), (:dset_id, :dxpl_id, :filter_mask, :offset, :bufsize, :buf), "Error writing chunk"), (:h5d_refresh, :H5Drefresh, Herr, (Hid,), (:dataset_id,), "Error refreshing dataset"), (:h5d_set_extent, :H5Dset_extent, Herr, (Hid, Ptr{Hsize}), (:dataset_id, :new_dims), "Error extending dataset dimensions"), (:h5d_vlen_get_buf_size, :H5Dvlen_get_buf_size, Herr, (Hid, Hid, Hid, Ptr{Hsize}), (:dset_id, :type_id, :space_id, :buf), "Error getting vlen buffer size"), - (:h5d_vlen_reclaim, :H5Dvlen_reclaim, Herr, (Hid, Hid, Hid, Ptr{Void}), (:type_id, :space_id, :plist_id, :buf), "Error reclaiming vlen buffer"), - (:h5d_write, :H5Dwrite, Herr, (Hid, Hid, Hid, Hid, Hid, Ptr{Void}), (:dataset_id, :mem_type_id, :mem_space_id, :file_space_id, :xfer_plist_id, :buf), "Error writing dataset"), - (:h5e_set_auto, :H5Eset_auto2, Herr, (Hid, Ptr{Void}, Ptr{Void}), (:estack_id, :func, :client_data), "Error setting error reporting behavior"), # FIXME callbacks, for now pass C_NULL for both pointers + (:h5d_vlen_reclaim, :H5Dvlen_reclaim, Herr, (Hid, Hid, Hid, Ptr{Cvoid}), (:type_id, :space_id, :plist_id, :buf), "Error reclaiming vlen buffer"), + (:h5d_write, :H5Dwrite, Herr, (Hid, Hid, Hid, Hid, Hid, Ptr{Cvoid}), (:dataset_id, :mem_type_id, :mem_space_id, :file_space_id, :xfer_plist_id, :buf), "Error writing dataset"), + (:h5e_set_auto, :H5Eset_auto2, Herr, (Hid, Ptr{Cvoid}, Ptr{Cvoid}), (:estack_id, :func, :client_data), "Error setting error reporting behavior"), # FIXME callbacks, for now pass C_NULL for both pointers (:h5f_close, :H5Fclose, Herr, (Hid,), (:file_id,), "Error closing file"), (:h5f_flush, :H5Fflush, Herr, (Hid, Cint), (:object_id, :scope,), "Error flushing object to file"), (:hf5start_swmr_write, :H5Fstart_swmr_write, Herr, (Hid,), (:id,), "Error starting SWMR write"), @@ -2093,7 +2095,7 @@ for (jlname, h5name, outtype, argtypes, argsyms, ex_error) in (:h5a_get_space, :H5Aget_space, Hid, (Hid,), (:attr_id,), :(error("Error getting attribute dataspace"))), (:h5a_get_type, :H5Aget_type, Hid, (Hid,), (:attr_id,), :(error("Error getting attribute type"))), (:h5a_open, :H5Aopen, Hid, (Hid, Ptr{UInt8}, Hid), (:obj_id, :pathname, :aapl_id), :(error("Error opening attribute ", h5i_get_name(obj_id), "/", pathname))), - (:h5a_read, :H5Aread, Herr, (Hid, Hid, Ptr{Void}), (:attr_id, :mem_type_id, :buf), :(error("Error reading attribute ", h5a_get_name(attr_id)))), + (:h5a_read, :H5Aread, Herr, (Hid, Hid, Ptr{Cvoid}), (:attr_id, :mem_type_id, :buf), :(error("Error reading attribute ", h5a_get_name(attr_id)))), (:h5d_create, :H5Dcreate2, Hid, (Hid, Ptr{UInt8}, Hid, Hid, Hid, Hid, Hid), (:loc_id, :pathname, :dtype_id, :space_id, :dlcpl_id, :dcpl_id, :dapl_id), :(error("Error creating dataset ", h5i_get_name(loc_id), "/", pathname))), (:h5d_get_access_plist, :H5Dget_access_plist, Hid, (Hid,), (:dataset_id,), :(error("Error getting dataset access property list"))), (:h5d_get_create_plist, :H5Dget_create_plist, Hid, (Hid,), (:dataset_id,), :(error("Error getting dataset create property list"))), @@ -2101,7 +2103,7 @@ for (jlname, h5name, outtype, argtypes, argsyms, ex_error) in (:h5d_get_space, :H5Dget_space, Hid, (Hid,), (:dataset_id,), :(error("Error getting dataspace"))), (:h5d_get_type, :H5Dget_type, Hid, (Hid,), (:dataset_id,), :(error("Error getting dataspace type"))), (:h5d_open, :H5Dopen2, Hid, (Hid, Ptr{UInt8}, Hid), (:loc_id, :pathname, :dapl_id), :(error("Error opening dataset ", h5i_get_name(loc_id), "/", pathname))), - (:h5d_read, :H5Dread, Herr, (Hid, Hid, Hid, Hid, Hid, Ptr{Void}), (:dataset_id, :mem_type_id, :mem_space_id, :file_space_id, :xfer_plist_id, :buf), :(error("Error reading dataset ", h5i_get_name(dataset_id)))), + (:h5d_read, :H5Dread, Herr, (Hid, Hid, Hid, Hid, Hid, Ptr{Cvoid}), (:dataset_id, :mem_type_id, :mem_space_id, :file_space_id, :xfer_plist_id, :buf), :(error("Error reading dataset ", h5i_get_name(dataset_id)))), (:h5f_create, :H5Fcreate, Hid, (Ptr{UInt8}, Cuint, Hid, Hid), (:pathname, :flags, :fcpl_id, :fapl_id), :(error("Error creating file ", pathname))), (:h5f_get_access_plist, :H5Fget_access_plist, Hid, (Hid,), (:file_id,), :(error("Error getting file access property list"))), (:h5f_get_create_plist, :H5Fget_create_plist, Hid, (Hid,), (:file_id,), :(error("Error getting file create property list"))), @@ -2129,10 +2131,10 @@ for (jlname, h5name, outtype, argtypes, argsyms, ex_error) in (:h5p_create, :H5Pcreate, Hid, (Hid,), (:cls_id,), "Error creating property list"), (:h5p_get_chunk, :H5Pget_chunk, Cint, (Hid, Cint, Ptr{Hsize}), (:plist_id, :n_dims, :dims), :(error("Error getting chunk size"))), (:h5p_get_layout, :H5Pget_layout, Cint, (Hid,), (:plist_id,), :(error("Error getting layout"))), - (:h5p_get_driver, :H5Pget_driver_info, Ptr{Void}, (Hid,), (:plist_id,), "Error getting driver info"), + (:h5p_get_driver, :H5Pget_driver_info, Ptr{Cvoid}, (Hid,), (:plist_id,), "Error getting driver info"), (:h5r_create, :H5Rcreate, Herr, (Ptr{HDF5ReferenceObj}, Hid, Ptr{UInt8}, Cint, Hid), (:ref, :loc_id, :pathname, :ref_type, :space_id), :(error("Error creating reference to object ", hi5_get_name(loc_id), "/", pathname))), - (:h5r_get_obj_type, :H5Rget_obj_type2, Herr, (Hid, Cint, Ptr{Void}, Ptr{Cint}), (:loc_id, :ref_type, :ref, :obj_type), :(error("Error getting object type"))), - (:h5r_get_region, :H5Rget_region, Hid, (Hid, Cint, Ptr{Void}), (:loc_id, :ref_type, :ref), :(error("Error getting region from reference"))), + (:h5r_get_obj_type, :H5Rget_obj_type2, Herr, (Hid, Cint, Ptr{Cvoid}, Ptr{Cint}), (:loc_id, :ref_type, :ref, :obj_type), :(error("Error getting object type"))), + (:h5r_get_region, :H5Rget_region, Hid, (Hid, Cint, Ptr{Cvoid}), (:loc_id, :ref_type, :ref), :(error("Error getting region from reference"))), (:h5s_copy, :H5Scopy, Hid, (Hid,), (:space_id,), :(error("Error copying dataspace"))), (:h5s_create, :H5Screate, Hid, (Cint,), (:class,), :(error("Error creating dataspace"))), (:h5s_create_simple, :H5Screate_simple, Hid, (Cint, Ptr{Hsize}, Ptr{Hsize}), (:rank, :current_dims, :maximum_dims), :(error("Error creating simple dataspace"))), @@ -2209,19 +2211,19 @@ end function h5a_get_name(attr_id::Hid) len = h5a_get_name(attr_id, 0, C_NULL) # order of args differs from {f,i}_get_name - buf = Vector{UInt8}(len+1) + buf = Vector{UInt8}(undef,len+1) h5a_get_name(attr_id, len+1, buf) String(buf[1:len]) end function h5f_get_name(loc_id::Hid) len = h5f_get_name(loc_id, C_NULL, 0) - buf = Vector{UInt8}(len+1) + buf = Vector{UInt8}(undef,len+1) h5f_get_name(loc_id, buf, len+1) String(buf[1:len]) end function h5i_get_name(loc_id::Hid) len = h5i_get_name(loc_id, C_NULL, 0) - buf = Vector{UInt8}(len+1) + buf = Vector{UInt8}(undef,len+1) h5i_get_name(loc_id, buf, len+1) String(buf[1:len]) end @@ -2232,8 +2234,8 @@ function h5l_get_info(link_loc_id::Hid, link_name::String, lapl_id::Hid) end function h5s_get_simple_extent_dims(space_id::Hid) n = h5s_get_simple_extent_ndims(space_id) - dims = Vector{Hsize}(n) - maxdims = Vector{Hsize}(n) + dims = Vector{Hsize}(undef,n) + maxdims = Vector{Hsize}(undef,n) h5s_get_simple_extent_dims(space_id, dims, maxdims) return tuple(reverse!(dims)...), tuple(reverse!(maxdims)...) end @@ -2263,7 +2265,7 @@ function h5f_get_obj_ids(file_id::Hid, types::Integer) sz = ccall((:H5Fget_obj_count, libhdf5), Int, (Hid, UInt32), file_id, types) sz >= 0 || error("error getting object count") - hids = Vector{Hid}(sz) + hids = Vector{Hid}(undef,sz) sz2 = ccall((:H5Fget_obj_ids, libhdf5), Int, (Hid, UInt32, UInt, Ptr{Hid}), file_id, types, sz, hids) sz2 >= 0 || error("error getting objects") @@ -2279,7 +2281,7 @@ end function hdf5array(objtype) nd = h5t_get_array_ndims(objtype.id) - dims = Vector{Hsize}(nd) + dims = Vector{Hsize}(undef,nd) h5t_get_array_dims(objtype.id, dims) eltyp = HDF5Datatype(h5t_get_super(objtype.id)) T = hdf5_to_julia_eltype(eltyp) @@ -2294,7 +2296,7 @@ get_create_properties(g::HDF5File) = HDF5Properties(h5f_get_create_plist(dset.id get_create_properties(g::HDF5Attribute) = HDF5Properties(h5a_get_create_plist(dset.id)) function get_chunk(p::HDF5Properties) n = h5p_get_chunk(p, 0, C_NULL) - cdims = Vector{Hsize}(n) + cdims = Vector{Hsize}(undef,n) h5p_get_chunk(p, n, cdims) tuple(convert(Array{Int}, reverse(cdims))...) end @@ -2377,14 +2379,14 @@ end function hiding_errors(f) error_stack = H5E_DEFAULT # error_stack = ccall((:H5Eget_current_stack, libhdf5), Hid, ()) - old_func = Ref{Ptr{Void}}() - old_client_data = Ref{Ptr{Void}}() - ccall((:H5Eget_auto2, libhdf5), Herr, (Hid, Ptr{Ptr{Void}}, Ptr{Ptr{Void}}), + old_func = Ref{Ptr{Cvoid}}() + old_client_data = Ref{Ptr{Cvoid}}() + ccall((:H5Eget_auto2, libhdf5), Herr, (Hid, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}), error_stack, old_func, old_client_data) - ccall((:H5Eset_auto2, libhdf5), Herr, (Hid, Ptr{Void}, Ptr{Void}), + ccall((:H5Eset_auto2, libhdf5), Herr, (Hid, Ptr{Cvoid}, Ptr{Cvoid}), error_stack, C_NULL, C_NULL) res = f() - ccall((:H5Eset_auto2, libhdf5), Herr, (Hid, Ptr{Void}, Ptr{Void}), + ccall((:H5Eset_auto2, libhdf5), Herr, (Hid, Ptr{Cvoid}, Ptr{Cvoid}), error_stack, old_func[], old_client_data[]) res end diff --git a/src/blosc_filter.jl b/src/blosc_filter.jl index a9d1f5b2b..05088d117 100644 --- a/src/blosc_filter.jl +++ b/src/blosc_filter.jl @@ -15,19 +15,19 @@ struct H5Z_class2_t encoder_present::Cuint # Does this filter have an encoder? decoder_present::Cuint # Does this filter have a decoder? name::Ptr{UInt8} # Comment for debugging - can_apply::Ptr{Void} # The "can apply" callback - set_local::Ptr{Void} # The "set local" callback - filter::Ptr{Void} # The filter callback + can_apply::Ptr{Cvoid} # The "can apply" callback + set_local::Ptr{Cvoid} # The "set local" callback + filter::Ptr{Cvoid} # The filter callback end const FILTER_BLOSC_VERSION = 2 const FILTER_BLOSC = 32001 # Filter ID registered with the HDF Group for Blosc const blosc_name = "blosc" -const blosc_flags_ = Vector{Cuint}(1) -const blosc_nelements_ = Vector{Csize_t}(1) -const blosc_values = Vector{Cuint}(8) -const blosc_chunkdims = Vector{Hsize}(32) +const blosc_flags_ = Vector{Cuint}(undef,1) +const blosc_nelements_ = Vector{Csize_t}(undef,1) +const blosc_values = Vector{Cuint}(undef,8) +const blosc_chunkdims = Vector{Hsize}(undef,32) function blosc_set_local(dcpl::Hid, htype::Hid, space::Hid) blosc_nelements_[1] = 8 if ccall((:H5Pget_filter_by_id2,libhdf5), Herr, @@ -75,7 +75,7 @@ end function blosc_filter(flags::Cuint, cd_nelmts::Csize_t, cd_values::Ptr{Cuint}, nbytes::Csize_t, - buf_size::Ptr{Csize_t}, buf::Ptr{Ptr{Void}}) + buf_size::Ptr{Csize_t}, buf::Ptr{Ptr{Cvoid}}) typesize = unsafe_load(cd_values, 3) # The datatype size outbuf_size = unsafe_load(cd_values, 4) # Compression level: @@ -122,7 +122,7 @@ function register_blosc() c_blosc_set_local = cfunction(blosc_set_local, Herr, Tuple{Hid,Hid,Hid}) c_blosc_filter = cfunction(blosc_filter, Csize_t, Tuple{Cuint, Csize_t, Ptr{Cuint}, Csize_t, - Ptr{Csize_t}, Ptr{Ptr{Void}}}) + Ptr{Csize_t}, Ptr{Ptr{Cvoid}}}) if ccall((:H5Zregister, libhdf5), Herr, (Ref{H5Z_class2_t},), H5Z_class2_t(H5Z_CLASS_T_VERS, FILTER_BLOSC, diff --git a/src/datafile.jl b/src/datafile.jl index 25c10c471..69c6f18cc 100644 --- a/src/datafile.jl +++ b/src/datafile.jl @@ -9,7 +9,7 @@ # Types inheriting from DataFile should have names, read, and write # methods -@compat abstract type DataFile end +abstract type DataFile end import Base: read, write @@ -40,7 +40,7 @@ read(f::Base.Callable, parent::DataFile, name::String...) = # Read every variable in the file function read(f::DataFile) vars = names(f) - vals = Vector{Any}(length(vars)) + vals = Vector{Any}(undef,length(vars)) for i = 1:length(vars) vals[i] = read(f, vars[i]) end diff --git a/test/extend_test.jl b/test/extend_test.jl index 3d8745423..14b2cb5c1 100644 --- a/test/extend_test.jl +++ b/test/extend_test.jl @@ -1,5 +1,5 @@ using HDF5 -using Base.Test +using Compat.Test @testset "extendtest" begin diff --git a/test/external.jl b/test/external.jl index e075436c4..caefb763b 100644 --- a/test/external.jl +++ b/test/external.jl @@ -1,5 +1,5 @@ using HDF5 -using Base.Test +using Compat.Test @testset "external" begin diff --git a/test/gc.jl b/test/gc.jl index 478b68449..48ddb5ebc 100644 --- a/test/gc.jl +++ b/test/gc.jl @@ -1,11 +1,12 @@ using HDF5 -using Base.Test +using Compat.Test +import Compat.GC macro gcvalid(args...) Expr(:block, quote - gc_enable(true) - gc() - gc_enable(false) + GC.enable(true) + GC.gc() + GC.enable(false) end, [:(@test HDF5.isvalid($(esc(x)))) for x in args]...) end @@ -23,7 +24,7 @@ end @testset "gc" begin -gc_enable(false) +GC.enable(false) fn = tempname() for i = 1:10 file = h5open(fn, "w") @@ -62,7 +63,7 @@ for i = 1:10 @gcvalid dt ds d g a close(file) end -gc_enable(true) +GC.enable(true) rm(fn) end # testset gc diff --git a/test/plain.jl b/test/plain.jl index 8e5c37268..208717fe5 100644 --- a/test/plain.jl +++ b/test/plain.jl @@ -1,6 +1,6 @@ using HDF5 -using Base.Test using Compat +using Compat.Test @testset "plain" begin diff --git a/test/readremote.jl b/test/readremote.jl index 7099a17f6..700f50a3c 100644 --- a/test/readremote.jl +++ b/test/readremote.jl @@ -1,5 +1,6 @@ using HDF5 -using Base.Test +using Compat.Test +using Compat.LinearAlgebra: norm @testset "readremote" begin diff --git a/test/runtests.jl b/test/runtests.jl index 1171f6ae7..6f6b469b2 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,5 +1,7 @@ using HDF5 -using Base.Test +using Compat.Test +using Compat.Distributed +using Compat.SharedArrays include("plain.jl") include("readremote.jl") diff --git a/test/swmr.jl b/test/swmr.jl index 428634d27..4122a68f1 100644 --- a/test/swmr.jl +++ b/test/swmr.jl @@ -7,7 +7,7 @@ if nprocs() == 1 addprocs(1) end @everywhere using HDF5 -using Base.Test +using Compat.Test @testset "swmr" begin fname = tempname()