From ea957d2691233749d80510ff3365f4a2a0a6abb7 Mon Sep 17 00:00:00 2001 From: Justin Willmert Date: Tue, 13 Oct 2020 17:23:12 -0500 Subject: [PATCH] Address review comments --- src/HDF5.jl | 8 -------- src/api_types.jl | 10 +++++++++- src/macros.jl | 8 +++++--- 3 files changed, 14 insertions(+), 12 deletions(-) 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..4b78179c2 100644 --- a/src/api_types.jl +++ b/src/api_types.jl @@ -253,7 +253,7 @@ end # Dataspace constants @defconstants H5S begin # atomic data types - ALL::hsize_t = 0 + ALL::hid_t = 0 UNLIMITED::hsize_t = typemax(hsize_t) # Types of dataspaces (C enum H5S_class_t) @@ -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)