Skip to content

Commit

Permalink
Replace Uint->UInt in typenames (backwards compatibility for old files)
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed Nov 15, 2014
1 parent 4f76312 commit 047c3ba
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/JLD.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ import HDF5: close, dump, exists, file, getindex, setindex!, g_create, g_open, o
HDF5ReferenceObj, HDF5BitsKind, ismmappable, readmmap
import Base: length, endof, show, done, next, start, delete!

# .jld files written before v"0.4.0-dev+1419" might have Uint32 instead of UInt32 as the typename string.
# See julia issue #8907
if VERSION >= v"0.4.0-dev+1419"
julia_type(s::String) = _julia_type(replace(s, r"Uint(?=\d{1,3})", "UInt"))
else
julia_type(s::String) = _julia_type(s)
end


const magic_base = "Julia data file (HDF5), version "
const version_current = v"0.1"
const pathrefs = "/_refs"
Expand Down Expand Up @@ -725,7 +734,7 @@ is_valid_type_ex(e::Expr) = ((e.head == :curly || e.head == :tuple || e.head ==
const _typedict = Dict{String,Type}()
_typedict["Core.Type{TypeVar(:T,Union(Core.Any,Core.Undef))}"] = Type

function julia_type(s::String)
function _julia_type(s::String)
typ = get(_typedict, s, UnconvertedType)
if typ == UnconvertedType
typ = julia_type(parse(s))
Expand Down
9 changes: 8 additions & 1 deletion src/JLD00.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ if !isdefined(:read!)
const read! = read
end

# See julia issue #8907
if VERSION >= v"0.4.0-dev+1419"
julia_type(s::String) = _julia_type(replace(s, r"Uint(?=\d{1,3})", "UInt"))
else
julia_type(s::String) = _julia_type(s)
end

const magic_base = "Julia data file (HDF5), version "
const version_current = "0.0.2"
const pathrefs = "/_refs"
Expand Down Expand Up @@ -922,7 +929,7 @@ is_valid_type_ex(e::Expr) = ((e.head == :curly || e.head == :tuple || e.head ==
(e.head == :call && (e.args[1] == :Union || e.args[1] == :TypeVar))

_typedict = Dict{String, DataType}()
function julia_type(s::String)
function _julia_type(s::String)
typ = get(_typedict, s, UnconvertedType)
if typ == UnconvertedType
e = parse(s)
Expand Down

0 comments on commit 047c3ba

Please sign in to comment.