diff --git a/src/HDF5.jl b/src/HDF5.jl index 8cadcea25..fda612aad 100644 --- a/src/HDF5.jl +++ b/src/HDF5.jl @@ -1936,14 +1936,6 @@ function __init__() __init_globals__() register_blosc() - # Generate the Float16 datatype: - float16 = h5t_copy(H5T.NATIVE_FLOAT) - h5t_set_fields(float16, 15, 10, 5, 0, 10) - h5t_set_size(float16, 2) - h5t_set_ebias(float16, 15) - h5t_lock(float16) - H5T.NATIVE_FLOAT16 = float16 - # Turn off automatic error printing # h5e_set_auto(H5E.DEFAULT, C_NULL, C_NULL) diff --git a/src/api_types.jl b/src/api_types.jl index 1cdb81639..2f2db615d 100644 --- a/src/api_types.jl +++ b/src/api_types.jl @@ -414,5 +414,13 @@ function __init_globals__() H5T.NATIVE_FLOAT = read_const(:H5T_NATIVE_FLOAT_g) H5T.NATIVE_DOUBLE = read_const(:H5T_NATIVE_DOUBLE_g) + # Defines a type corresponding to Julia's IEEE Float16 type. + float16 = h5t_copy(H5T.NATIVE_FLOAT) + h5t_set_fields(float16, 15, 10, 5, 0, 10) + h5t_set_size(float16, 2) + h5t_set_ebias(float16, 15) + h5t_lock(float16) + H5T.NATIVE_FLOAT16 = float16 + nothing end diff --git a/src/macros.jl b/src/macros.jl index a8f029724..8a0856aeb 100644 --- a/src/macros.jl +++ b/src/macros.jl @@ -54,13 +54,13 @@ macro defconstants(prefix::Symbol, expr::Expr) isruntime = isexpr(line, :(=)) ? false : isexpr(line, :(::)) ? true : - error("Unexpected statement: ", repr(line)) + error("Unexpected statement: ", line) # Get the name and type pair nametype = isruntime ? line : line.args[1] - isexpr(nametype, :(::)) || error("Expected `name::type`, got ", repr(nametype)) + isexpr(nametype, :(::)) || error("Expected `name::type`, got: ", nametype) name = nametype.args[1]::Symbol - type = nametype.args[2] + type = nametype.args[2]::Union{Symbol,Expr} # Save type for later use push!(imports, type) @@ -106,12 +106,14 @@ macro defconstants(prefix::Symbol, expr::Expr) end function Base.getproperty(::$einnermod.$prefix, sym::Symbol) $(getbody...) + error($(string(prefix) * " has no constant "), sym) end end if !isempty(setbody) setfn = quote function Base.setproperty!(::$einnermod.$prefix, sym::Symbol, value) $(setbody...) + error($(string(prefix) * "."), sym, " cannot be set") end end append!(block.args, Base.remove_linenums!(setfn).args)