Skip to content

Commit

Permalink
try to fix the H5Sencode method
Browse files Browse the repository at this point in the history
  • Loading branch information
picca committed Aug 6, 2024
1 parent 15d3bcb commit f5b1e26
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
10 changes: 10 additions & 0 deletions src/Bindings/HDF5/Dataspace.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,17 @@ encodeDataspace (Dataspace space_id) =
withOutByteString $ \buf bufSz ->
withInOut_ bufSz $ \ioBufSz ->
withErrorCheck_ $
#if H5_VERSION_GE(1,12,0)
# if H5Sencode_vers == 2
h5s_encode space_id buf ioBufSz H5P_DEFAULT
# elif H5Sencode_vers == 1
h5s_encode space_id buf ioBufSz
# else
# error "H5Sencode_vers set to invalid value"
# endif
#else
h5s_encode space_id buf ioBufSz
#endif

decodeDataspace :: BS.ByteString -> IO Dataspace
decodeDataspace bs = BS.unsafeUseAsCString bs $ \buf ->
Expand Down
21 changes: 14 additions & 7 deletions src/Bindings/HDF5/Raw/H5S.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,21 @@ import Foreign.Ptr.Conventions
--
-- Returns non-negative on success, negative on failure.
--
-- > herr_t H5Sencode(hid_t obj_id, void *buf, size_t *nalloc);
#if HDF5get_info_vers == 1
#ccall H5Sencode, <hid_t> -> OutArray CChar -> InOut <size_t> -> IO <herr_t>
#if H5_VERSION_GE(1,12,0)
# if H5Sencode_vers == 2
-- > herr_t H5Sencode2 (hid_t obj_id, void *buf, size_t *nalloc, hid_t fapl)
# ccall H5Sencode2, <hid_t> -> OutArray CChar -> InOut <size_t> -> <hid_t> -> IO <herr_t>
h5s_encode = H5Sencode2
# elif H5Sencode_vers == 1
-- > herr_t H5Sencode1(hid_t obj_id, void *buf, size_t *nalloc)
# ccall H5Sencode1, <hid_t> -> OutArray CChar -> InOut <size_t> -> IO <herr_t>
h5s_encode = H5Sencode1
# else
# error "H5Sencode_vers set to invalid value"
# endif
#else
#ccall H5Sencode2, <hid_t> -> OutArray CChar -> InOut <size_t> -> IO <herr_t>

h5s_encode :: HId_t -> OutArray CChar -> InOut CSize -> IO HErr_t
h5s_encode = h5s_encode2
-- > herr_t H5Sencode(hid_t obj_id, void *buf, size_t *nalloc)
# ccall H5Sencode, <hid_t> -> OutArray CChar -> InOut <size_t> -> IO <herr_t>
#endif

-- |Decode a binary object description of dataspace and
Expand Down

0 comments on commit f5b1e26

Please sign in to comment.