[h5py] 14/26: Start work on replacement exception system
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Thu Jul 2 18:20:18 UTC 2015
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to annotated tag 1.3.1
in repository h5py.
commit 46e8bc0f104e5985c82c9d85509b5dbd374b22ba
Author: andrewcollette <andrew.collette at gmail.com>
Date: Tue Oct 26 23:39:57 2010 +0000
Start work on replacement exception system
---
h5py/auto_api.py | 101 +++++++
h5py/auto_functions.txt | 3 +
h5py/defs.pxd | 639 +---------------------------------------
h5py/defs_types.pxi | 668 ++++++++++++++++++++++++++++++++++++++++++
h5py/tests/high/test_links.py | 11 +-
5 files changed, 784 insertions(+), 638 deletions(-)
diff --git a/h5py/auto_api.py b/h5py/auto_api.py
new file mode 100644
index 0000000..15536a0
--- /dev/null
+++ b/h5py/auto_api.py
@@ -0,0 +1,101 @@
+
+import re
+
+function_pattern = r'(?P<code>(unsigned[ ]+)?[a-zA-Z_]+[a-zA-Z0-9_]*\**)[ ]+(?P<fname>[a-zA-Z_]+[a-zA-Z0-9_]*)\((?P<sig>[a-zA-Z0-9_,* ]+)\)'
+sig_pattern = r'(?:[a-zA-Z_]+[a-zA-Z0-9_]*\**)[ ]+(?P<param>[a-zA-Z_]+[a-zA-Z0-9_]*)'
+
+fp = re.compile(function_pattern)
+sp = re.compile(sig_pattern)
+
+class BadLineError(Exception):
+ pass
+
+class UnknownCodeError(Exception):
+ pass
+
+class FunctionCruncher(object):
+
+ def load_line(self, line):
+ m = fp.match(line)
+ if m is None:
+ raise BadLineException("Line <<%s>> did not match regexp" % line)
+ self.code = m.group('code')
+ self.fname = m.group('fname')
+ self.sig = m.group('sig')
+
+ m = sp.findall(self.sig)
+ if m is None:
+ raise BadLineError("Signature for line <<%s>> did not match regexp" % line)
+ self.sig_parts = m
+
+ if '*' in self.code:
+ self.condition = "==NULL"
+ self.retval = "NULL"
+ elif self.code in ('int', 'herr_t', 'htri_t', 'hid_t'):
+ self.condition = "<0"
+ self.retval = "-1"
+ elif self.code in ('unsigned int',):
+ self.condition = "==0"
+ self.retval = 0
+ else:
+ raise UnknownCodeError("Return code <<%s>> unknown" % self.code)
+
+ return code % code_dict
+
+ def put_cython_signature(self):
+
+ return "cdef %s %s_(%s) except %s" % (self.code, self.fname,
+ self.sig, self.retval)
+
+ def put_cython_wrapper(self):
+
+ code_dict = {'code': self.code, 'fname': self.fname,
+ 'sig': self.sig, 'args': ", ".join(self.sig_parts),
+ 'condition': self.condition, 'retval': self.retval}
+
+ code = """\
+cdef %(code)s %(fname)s_(%(sig)s) except %(retval)s:
+ cdef %(code)s r;
+ r = %(fname)s(%(args)s)
+ if r%(condition)s:
+ set_exception()
+ return %(retval)s;
+ return r
+"""
+ return code % code_dict
+
+ def put_cython_import(self):
+
+ return "%s %s(%s)" % (self.code, self.fname, self.sig)
+
+if __name__ == '__main__':
+
+ fc = FunctionCruncher()
+ f = open('auto_functions.txt','r')
+ f_pxd = open('auto_defs.pxd','w')
+ f_pyx = open('auto_defs.pyx','w')
+
+ f_pxd.write("# This file is auto-generated. Do not edit.\n\n")
+ f_pyx.write("# This file is auto-generated. Do not edit.\n\n")
+
+ defs = 'cdef extern from "hdf5.h":\n'
+ sigs = ""
+ wrappers = ""
+
+ for line in f:
+ line = line.strip()
+ fc.load_line(line)
+ defs += " "+fc.put_cython_import()+"\n"
+ sigs += fc.put_cython_signature()+"\n"
+ wrappers += fc.put_cython_wrapper()+"\n"
+
+ f_pxd.write(defs)
+ f_pxd.write("\n\n")
+ f_pxd.write(sigs)
+ f_pyx.write(wrappers)
+
+ f_pxd.close()
+ f_pyx.close()
+
+
+
diff --git a/h5py/auto_functions.txt b/h5py/auto_functions.txt
new file mode 100644
index 0000000..dc8965b
--- /dev/null
+++ b/h5py/auto_functions.txt
@@ -0,0 +1,3 @@
+ herr_t H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf)
+ herr_t H5Dwrite(hid_t dset_id, hid_t mem_type, hid_t mem_space, hid_t file_space, hid_t xfer_plist, void* buf)
+ herr_t H5Dextend(hid_t dataset_id, hsize_t *size)
diff --git a/h5py/defs.pxd b/h5py/defs.pxd
index c01d5c0..f2cf80c 100644
--- a/h5py/defs.pxd
+++ b/h5py/defs.pxd
@@ -77,22 +77,10 @@ cdef extern from "lzf_filter.h":
# === H5 - Common definitions and library functions ===========================
-cdef extern from "hdf5.h":
-
- # Basic types
- ctypedef int hid_t
- ctypedef int hbool_t
- ctypedef int herr_t
- ctypedef int htri_t
- ctypedef long long hsize_t
- ctypedef signed long long hssize_t
- ctypedef signed long long haddr_t
-
- ctypedef struct hvl_t:
- size_t len # Length of VL data (in base type units)
- void *p # Pointer to VL data
+# Type definitions
+include "defs_types.pxi"
- int HADDR_UNDEF
+cdef extern from "hdf5.h":
# H5 API
herr_t H5open() except *
@@ -101,59 +89,10 @@ cdef extern from "hdf5.h":
herr_t H5get_libversion(unsigned *majnum, unsigned *minnum,
unsigned *relnum) except *
- # New in 1.8.X
- IF H5PY_18API:
-
- ctypedef enum H5_iter_order_t:
- H5_ITER_UNKNOWN = -1, # Unknown order
- H5_ITER_INC, # Increasing order
- H5_ITER_DEC, # Decreasing order
- H5_ITER_NATIVE, # No particular order, whatever is fastest
- H5_ITER_N # Number of iteration orders
-
- ctypedef enum H5_index_t:
- H5_INDEX_UNKNOWN = -1, # Unknown index type
- H5_INDEX_NAME, # Index on names
- H5_INDEX_CRT_ORDER, # Index on creation order
- H5_INDEX_N # Number of indices defined
-
-
# === H5D - Dataset API =======================================================
cdef extern from "hdf5.h":
- ctypedef enum H5D_layout_t:
- H5D_LAYOUT_ERROR = -1,
- H5D_COMPACT = 0,
- H5D_CONTIGUOUS = 1,
- H5D_CHUNKED = 2,
- H5D_NLAYOUTS = 3
-
- ctypedef enum H5D_alloc_time_t:
- H5D_ALLOC_TIME_ERROR =-1,
- H5D_ALLOC_TIME_DEFAULT =0,
- H5D_ALLOC_TIME_EARLY =1,
- H5D_ALLOC_TIME_LATE =2,
- H5D_ALLOC_TIME_INCR =3
-
- ctypedef enum H5D_space_status_t:
- H5D_SPACE_STATUS_ERROR =-1,
- H5D_SPACE_STATUS_NOT_ALLOCATED =0,
- H5D_SPACE_STATUS_PART_ALLOCATED =1,
- H5D_SPACE_STATUS_ALLOCATED =2
-
- ctypedef enum H5D_fill_time_t:
- H5D_FILL_TIME_ERROR =-1,
- H5D_FILL_TIME_ALLOC =0,
- H5D_FILL_TIME_NEVER =1,
- H5D_FILL_TIME_IFSET =2
-
- ctypedef enum H5D_fill_value_t:
- H5D_FILL_VALUE_ERROR =-1,
- H5D_FILL_VALUE_UNDEFINED =0,
- H5D_FILL_VALUE_DEFAULT =1,
- H5D_FILL_VALUE_USER_DEFINED =2
-
hid_t H5Dcreate(hid_t loc, char* name, hid_t type_id, hid_t space_id,
hid_t create_plist_id) except *
hid_t H5Dopen(hid_t file_id, char *name) except *
@@ -184,8 +123,6 @@ cdef extern from "hdf5.h":
herr_t H5Dvlen_reclaim(hid_t type_id, hid_t space_id,
hid_t plist, void *buf) except *
- ctypedef herr_t (*H5D_operator_t)(void *elem, hid_t type_id, unsigned ndim,
- hsize_t *point, void *operator_data) except -1
herr_t H5Diterate(void *buf, hid_t type_id, hid_t space_id,
H5D_operator_t op, void* operator_data) except *
herr_t H5Dset_extent(hid_t dset_id, hsize_t* size)
@@ -201,35 +138,6 @@ cdef extern from "hdf5.h":
cdef extern from "hdf5.h":
- # File constants
- cdef enum:
- H5F_ACC_TRUNC
- H5F_ACC_RDONLY
- H5F_ACC_RDWR
- H5F_ACC_EXCL
- H5F_ACC_DEBUG
- H5F_ACC_CREAT
-
- # The difference between a single file and a set of mounted files
- cdef enum H5F_scope_t:
- H5F_SCOPE_LOCAL = 0, # specified file handle only
- H5F_SCOPE_GLOBAL = 1, # entire virtual file
- H5F_SCOPE_DOWN = 2 # for internal use only
-
- cdef enum H5F_close_degree_t:
- H5F_CLOSE_WEAK = 0,
- H5F_CLOSE_SEMI = 1,
- H5F_CLOSE_STRONG = 2,
- H5F_CLOSE_DEFAULT = 3
-
- int H5F_OBJ_FILE
- int H5F_OBJ_DATASET
- int H5F_OBJ_GROUP
- int H5F_OBJ_DATATYPE
- int H5F_OBJ_ATTR
- int H5F_OBJ_ALL
- int H5F_OBJ_LOCAL
-
hid_t H5Fcreate(char *filename, unsigned int flags,
hid_t create_plist, hid_t access_plist) except *
hid_t H5Fopen(char *name, unsigned flags, hid_t access_id) except *
@@ -253,88 +161,10 @@ cdef extern from "hdf5.h":
# === H5FD - Low-level file descriptor API ====================================
-cdef extern from "hdf5.h":
-
- ctypedef enum H5FD_mem_t:
- H5FD_MEM_NOLIST = -1,
- H5FD_MEM_DEFAULT = 0,
- H5FD_MEM_SUPER = 1,
- H5FD_MEM_BTREE = 2,
- H5FD_MEM_DRAW = 3,
- H5FD_MEM_GHEAP = 4,
- H5FD_MEM_LHEAP = 5,
- H5FD_MEM_OHDR = 6,
- H5FD_MEM_NTYPES
-
- # HDF5 uses a clever scheme wherein these are actually init() calls
- # Hopefully Cython won't have a problem with this.
- # Thankfully they are defined but -1 if unavailable
- hid_t H5FD_CORE
- hid_t H5FD_FAMILY
-# hid_t H5FD_GASS not in 1.8.X
- hid_t H5FD_LOG
- hid_t H5FD_MPIO
- hid_t H5FD_MULTI
- hid_t H5FD_SEC2
- hid_t H5FD_STDIO
-
- int H5FD_LOG_LOC_READ # 0x0001
- int H5FD_LOG_LOC_WRITE # 0x0002
- int H5FD_LOG_LOC_SEEK # 0x0004
- int H5FD_LOG_LOC_IO # (H5FD_LOG_LOC_READ|H5FD_LOG_LOC_WRITE|H5FD_LOG_LOC_SEEK)
-
- # Flags for tracking number of times each byte is read/written
- int H5FD_LOG_FILE_READ # 0x0008
- int H5FD_LOG_FILE_WRITE # 0x0010
- int H5FD_LOG_FILE_IO # (H5FD_LOG_FILE_READ|H5FD_LOG_FILE_WRITE)
-
- # Flag for tracking "flavor" (type) of information stored at each byte
- int H5FD_LOG_FLAVOR # 0x0020
-
- # Flags for tracking total number of reads/writes/seeks
- int H5FD_LOG_NUM_READ # 0x0040
- int H5FD_LOG_NUM_WRITE # 0x0080
- int H5FD_LOG_NUM_SEEK # 0x0100
- int H5FD_LOG_NUM_IO # (H5FD_LOG_NUM_READ|H5FD_LOG_NUM_WRITE|H5FD_LOG_NUM_SEEK)
-
- # Flags for tracking time spent in open/read/write/seek/close
- int H5FD_LOG_TIME_OPEN # 0x0200 # Not implemented yet
- int H5FD_LOG_TIME_READ # 0x0400 # Not implemented yet
- int H5FD_LOG_TIME_WRITE # 0x0800 # Partially implemented (need to track total time)
- int H5FD_LOG_TIME_SEEK # 0x1000 # Partially implemented (need to track total time & track time for seeks during reading)
- int H5FD_LOG_TIME_CLOSE # 0x2000 # Fully implemented
- int H5FD_LOG_TIME_IO # (H5FD_LOG_TIME_OPEN|H5FD_LOG_TIME_READ|H5FD_LOG_TIME_WRITE|H5FD_LOG_TIME_SEEK|H5FD_LOG_TIME_CLOSE)
-
- # Flag for tracking allocation of space in file
- int H5FD_LOG_ALLOC # 0x4000
- int H5FD_LOG_ALL # (H5FD_LOG_ALLOC|H5FD_LOG_TIME_IO|H5FD_LOG_NUM_IO|H5FD_LOG_FLAVOR|H5FD_LOG_FILE_IO|H5FD_LOG_LOC_IO)
-
-
# === H5G - Groups API ========================================================
cdef extern from "hdf5.h":
- ctypedef enum H5G_link_t:
- H5G_LINK_ERROR = -1,
- H5G_LINK_HARD = 0,
- H5G_LINK_SOFT = 1
-
- cdef enum H5G_obj_t:
- H5G_UNKNOWN = -1, # Unknown object type
- H5G_LINK, # Object is a symbolic link
- H5G_GROUP, # Object is a group
- H5G_DATASET, # Object is a dataset
- H5G_TYPE, # Object is a named data type
-
- ctypedef struct H5G_stat_t:
- unsigned long fileno[2]
- unsigned long objno[2]
- unsigned int nlink
- H5G_obj_t type # new in HDF5 1.6
- time_t mtime
- size_t linklen
- #H5O_stat_t ohdr # Object header information. New in HDF5 1.6
-
hid_t H5Gcreate(hid_t loc_id, char *name, size_t size_hint) except *
hid_t H5Gopen(hid_t loc_id, char *name) except *
herr_t H5Gclose(hid_t group_id) except *
@@ -348,7 +178,6 @@ cdef extern from "hdf5.h":
int H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char *name, size_t size) except *
int H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx) except *
- ctypedef herr_t (*H5G_iterate_t)(hid_t group, char *name, void* op_data) except 2
herr_t H5Giterate(hid_t loc_id, char *name, int *idx, H5G_iterate_t op, void* data) except *
herr_t H5Gget_objinfo(hid_t loc_id, char* name, int follow_link, H5G_stat_t *statbuf) except *
@@ -359,17 +188,6 @@ cdef extern from "hdf5.h":
# New extensions in 1.8.X
IF H5PY_18API:
- ctypedef enum H5G_storage_type_t:
- H5G_STORAGE_TYPE_UNKNOWN = -1,
- H5G_STORAGE_TYPE_SYMBOL_TABLE,
- H5G_STORAGE_TYPE_COMPACT,
- H5G_STORAGE_TYPE_DENSE
-
- ctypedef struct H5G_info_t:
- H5G_storage_type_t storage_type
- hsize_t nlinks
- int64_t max_corder
-
hid_t H5Gcreate_anon( hid_t loc_id, hid_t gcpl_id, hid_t gapl_id) except *
hid_t H5Gcreate2(hid_t loc_id, char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id) except *
hid_t H5Gopen2( hid_t loc_id, char * name, hid_t gapl_id) except *
@@ -382,20 +200,6 @@ cdef extern from "hdf5.h":
cdef extern from "hdf5.h":
- ctypedef enum H5I_type_t:
- H5I_BADID = -1, # invalid Group
- H5I_FILE = 1, # group ID for File objects
- H5I_GROUP, # group ID for Group objects
- H5I_DATATYPE, # group ID for Datatype objects
- H5I_DATASPACE, # group ID for Dataspace objects
- H5I_DATASET, # group ID for Dataset objects
- H5I_ATTR, # group ID for Attribute objects
- H5I_REFERENCE, # group ID for Reference objects
- H5I_VFL, # group ID for virtual file layer
- H5I_GENPROP_CLS, # group ID for generic property list classes
- H5I_GENPROP_LST, # group ID for generic property lists
- H5I_NGROUPS # number of valid groups, MUST BE LAST!
-
H5I_type_t H5Iget_type(hid_t obj_id) except *
ssize_t H5Iget_name( hid_t obj_id, char *name, size_t size) except *
hid_t H5Iget_file_id(hid_t obj_id) except *
@@ -410,45 +214,6 @@ IF H5PY_18API:
cdef extern from "hdf5.h":
- # TODO: put both versions in h5t.pxd
- ctypedef enum H5T_cset_t:
- H5T_CSET_ERROR = -1, #
- H5T_CSET_ASCII = 0, # US ASCII
- H5T_CSET_UTF8 = 1, # UTF-8 Unicode encoding
-
- unsigned int H5L_MAX_LINK_NAME_LEN # ((uint32_t) (-1)) (4GB - 1)
-
- # Link class types.
- # * Values less than 64 are reserved for the HDF5 library's internal use.
- # * Values 64 to 255 are for "user-defined" link class types; these types are
- # * defined by HDF5 but their behavior can be overridden by users.
- # * Users who want to create new classes of links should contact the HDF5
- # * development team at hdfhelp at ncsa.uiuc.edu .
- # * These values can never change because they appear in HDF5 files.
- #
- ctypedef enum H5L_type_t:
- H5L_TYPE_ERROR = (-1), # Invalid link type id
- H5L_TYPE_HARD = 0, # Hard link id
- H5L_TYPE_SOFT = 1, # Soft link id
- H5L_TYPE_EXTERNAL = 64, # External link id
- H5L_TYPE_MAX = 255 # Maximum link type id
-
- # Information struct for link (for H5Lget_info/H5Lget_info_by_idx)
- cdef union _add_u:
- haddr_t address # Address hard link points to
- size_t val_size # Size of a soft link or UD link value
-
- ctypedef struct H5L_info_t:
- H5L_type_t type # Type of link
- hbool_t corder_valid # Indicate if creation order is valid
- int64_t corder # Creation order
- H5T_cset_t cset # Character set of link name
- _add_u u
-
- # Prototype for H5Literate/H5Literate_by_name() operator
- ctypedef herr_t (*H5L_iterate_t) (hid_t group, char *name, H5L_info_t *info,
- void *op_data) except 2
-
# Links API
herr_t H5Lmove(hid_t src_loc, char *src_name, hid_t dst_loc,
@@ -508,71 +273,12 @@ IF H5PY_18API:
herr_t H5Lcreate_external(char *file_name, char *obj_name,
hid_t link_loc_id, char *link_name, hid_t lcpl_id, hid_t lapl_id) except *
-
# === H5O - General object operations (1.8.X only) ============================
IF H5PY_18API:
cdef extern from "hdf5.h":
- ctypedef uint32_t H5O_msg_crt_idx_t
-
- ctypedef enum H5O_type_t:
- H5O_TYPE_UNKNOWN = -1, # Unknown object type
- H5O_TYPE_GROUP, # Object is a group
- H5O_TYPE_DATASET, # Object is a dataset
- H5O_TYPE_NAMED_DATATYPE, # Object is a named data type
- H5O_TYPE_NTYPES # Number of different object types (must be last!)
-
- unsigned int H5O_COPY_SHALLOW_HIERARCHY_FLAG # (0x0001u) Copy only immediate members
- unsigned int H5O_COPY_EXPAND_SOFT_LINK_FLAG # (0x0002u) Expand soft links into new objects
- unsigned int H5O_COPY_EXPAND_EXT_LINK_FLAG # (0x0004u) Expand external links into new objects
- unsigned int H5O_COPY_EXPAND_REFERENCE_FLAG # (0x0008u) Copy objects that are pointed by references
- unsigned int H5O_COPY_WITHOUT_ATTR_FLAG # (0x0010u) Copy object without copying attributes
- unsigned int H5O_COPY_PRESERVE_NULL_FLAG # (0x0020u) Copy NULL messages (empty space)
- unsigned int H5O_COPY_ALL # (0x003Fu) All object copying flags (for internal checking)
-
- # --- Components for the H5O_info_t struct ----------------------------------
-
- ctypedef struct space:
- hsize_t total # Total space for storing object header in file
- hsize_t meta # Space within header for object header metadata information
- hsize_t mesg # Space within header for actual message information
- hsize_t free # Free space within object header
-
- ctypedef struct mesg:
- unsigned long present # Flags to indicate presence of message type in header
- unsigned long shared # Flags to indicate message type is shared in header
-
- ctypedef struct hdr:
- unsigned version # Version number of header format in file
- unsigned nmesgs # Number of object header messages
- unsigned nchunks # Number of object header chunks
- unsigned flags # Object header status flags
- space space
- mesg mesg
-
- ctypedef struct H5_ih_info_t:
- hsize_t index_size, # btree and/or list
- hsize_t heap_size
-
- cdef struct meta_size:
- H5_ih_info_t obj, # v1/v2 B-tree & local/fractal heap for groups, B-tree for chunked datasets
- H5_ih_info_t attr # v2 B-tree & heap for attributes
-
- ctypedef struct H5O_info_t:
- unsigned long fileno # File number that object is located in
- haddr_t addr # Object address in file
- H5O_type_t type # Basic object type (group, dataset, etc.)
- unsigned rc # Reference count of object
- time_t atime # Access time
- time_t mtime # Modification time
- time_t ctime # Change time
- time_t btime # Birth time
- hsize_t num_attrs # # of attributes attached to object
- hdr hdr
- meta_size meta_size
-
# --- H5O API -------------------------------------------------------------
hid_t H5Oopen(hid_t loc_id, char *name, hid_t lapl_id) except *
@@ -602,9 +308,6 @@ IF H5PY_18API:
ssize_t H5Oget_comment_by_name(hid_t loc_id, char *name,
char *comment, size_t bufsize, hid_t lapl_id) except *
- ctypedef herr_t (*H5O_iterate_t)(hid_t obj, char *name, H5O_info_t *info,
- void *op_data) except 2
-
herr_t H5Ovisit(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order,
H5O_iterate_t op, void *op_data) except *
herr_t H5Ovisit_by_name(hid_t loc_id, char *obj_name,
@@ -617,78 +320,7 @@ IF H5PY_18API:
cdef extern from "hdf5.h":
- int H5P_DEFAULT
-
- ctypedef int H5Z_filter_t
-
- # HDF5 layouts
- ctypedef enum H5D_layout_t:
- H5D_LAYOUT_ERROR = -1,
- H5D_COMPACT = 0, # raw data is very small
- H5D_CONTIGUOUS = 1, # the default
- H5D_CHUNKED = 2, # slow and fancy
- H5D_NLAYOUTS = 3 # this one must be last!
-
- ctypedef enum H5D_alloc_time_t:
- H5D_ALLOC_TIME_ERROR =-1,
- H5D_ALLOC_TIME_DEFAULT =0,
- H5D_ALLOC_TIME_EARLY =1,
- H5D_ALLOC_TIME_LATE =2,
- H5D_ALLOC_TIME_INCR =3
-
- ctypedef enum H5D_space_status_t:
- H5D_SPACE_STATUS_ERROR =-1,
- H5D_SPACE_STATUS_NOT_ALLOCATED =0,
- H5D_SPACE_STATUS_PART_ALLOCATED =1,
- H5D_SPACE_STATUS_ALLOCATED =2
-
- ctypedef enum H5D_fill_time_t:
- H5D_FILL_TIME_ERROR =-1,
- H5D_FILL_TIME_ALLOC =0,
- H5D_FILL_TIME_NEVER =1,
- H5D_FILL_TIME_IFSET =2
-
- ctypedef enum H5D_fill_value_t:
- H5D_FILL_VALUE_ERROR =-1,
- H5D_FILL_VALUE_UNDEFINED =0,
- H5D_FILL_VALUE_DEFAULT =1,
- H5D_FILL_VALUE_USER_DEFINED =2
-
- cdef enum H5Z_EDC_t:
- H5Z_ERROR_EDC = -1,
- H5Z_DISABLE_EDC = 0,
- H5Z_ENABLE_EDC = 1,
- H5Z_NO_EDC = 2
-
- cdef enum H5F_close_degree_t:
- H5F_CLOSE_WEAK = 0,
- H5F_CLOSE_SEMI = 1,
- H5F_CLOSE_STRONG = 2,
- H5F_CLOSE_DEFAULT = 3
-
- ctypedef enum H5FD_mem_t:
- H5FD_MEM_NOLIST = -1,
- H5FD_MEM_DEFAULT = 0,
- H5FD_MEM_SUPER = 1,
- H5FD_MEM_BTREE = 2,
- H5FD_MEM_DRAW = 3,
- H5FD_MEM_GHEAP = 4,
- H5FD_MEM_LHEAP = 5,
- H5FD_MEM_OHDR = 6,
- H5FD_MEM_NTYPES
-
- # Property list classes
- hid_t H5P_NO_CLASS
- hid_t H5P_FILE_CREATE
- hid_t H5P_FILE_ACCESS
- hid_t H5P_DATASET_CREATE
- hid_t H5P_DATASET_XFER
- IF H5PY_18API:
- hid_t H5P_OBJECT_CREATE
- hid_t H5P_OBJECT_COPY
- hid_t H5P_LINK_CREATE
- hid_t H5P_LINK_ACCESS
- hid_t H5P_GROUP_CREATE
+
# General operations
hid_t H5Pcreate(hid_t plist_id) except *
@@ -804,16 +436,6 @@ cdef extern from "hdf5.h":
cdef extern from "hdf5.h":
- size_t H5R_DSET_REG_REF_BUF_SIZE
- size_t H5R_OBJ_REF_BUF_SIZE
-
- ctypedef enum H5R_type_t:
- H5R_BADTYPE = (-1),
- H5R_OBJECT,
- H5R_DATASET_REGION,
- H5R_INTERNAL,
- H5R_MAXTYPE
-
herr_t H5Rcreate(void *ref, hid_t loc_id, char *name, H5R_type_t ref_type,
hid_t space_id) except *
hid_t H5Rdereference(hid_t obj_id, H5R_type_t ref_type, void *ref) except *
@@ -827,38 +449,6 @@ cdef extern from "hdf5.h":
cdef extern from "hdf5.h":
- int H5S_ALL, H5S_MAX_RANK
- hsize_t H5S_UNLIMITED
-
- # Codes for defining selections
- ctypedef enum H5S_seloper_t:
- H5S_SELECT_NOOP = -1,
- H5S_SELECT_SET = 0,
- H5S_SELECT_OR,
- H5S_SELECT_AND,
- H5S_SELECT_XOR,
- H5S_SELECT_NOTB,
- H5S_SELECT_NOTA,
- H5S_SELECT_APPEND,
- H5S_SELECT_PREPEND,
- H5S_SELECT_INVALID # Must be the last one
-
- ctypedef enum H5S_class_t:
- H5S_NO_CLASS = -1, #/*error
- H5S_SCALAR = 0, #/*scalar variable
- H5S_SIMPLE = 1, #/*simple data space
- # no longer defined in 1.8
- #H5S_COMPLEX = 2 #/*complex data space
-
- ctypedef enum H5S_sel_type:
- H5S_SEL_ERROR = -1, #Error
- H5S_SEL_NONE = 0, #Nothing selected
- H5S_SEL_POINTS = 1, #Sequence of points selected
- H5S_SEL_HYPERSLABS = 2, #"New-style" hyperslab selection defined
- H5S_SEL_ALL = 3, #Entire extent selected
- H5S_SEL_N = 4 #/*THIS MUST BE LAST
-
-
# Basic operations
hid_t H5Screate(H5S_class_t type) except *
hid_t H5Scopy(hid_t space_id ) except *
@@ -911,148 +501,9 @@ cdef extern from "hdf5.h":
cdef extern from "hdf5.h":
- hid_t H5P_DEFAULT
-
- # --- Enumerated constants --------------------------------------------------
-
- # Byte orders
- ctypedef enum H5T_order_t:
- H5T_ORDER_ERROR = -1, # error
- H5T_ORDER_LE = 0, # little endian
- H5T_ORDER_BE = 1, # bit endian
- H5T_ORDER_VAX = 2, # VAX mixed endian
- H5T_ORDER_NONE = 3 # no particular order (strings, bits,..)
-
- # HDF5 signed enums
- ctypedef enum H5T_sign_t:
- H5T_SGN_ERROR = -1, # error
- H5T_SGN_NONE = 0, # this is an unsigned type
- H5T_SGN_2 = 1, # two's complement
- H5T_NSGN = 2 # this must be last!
-
- ctypedef enum H5T_norm_t:
- H5T_NORM_ERROR = -1,
- H5T_NORM_IMPLIED = 0,
- H5T_NORM_MSBSET = 1,
- H5T_NORM_NONE = 2
-
- ctypedef enum H5T_cset_t:
- H5T_CSET_ERROR = -1,
- H5T_CSET_ASCII = 0
-
- ctypedef enum H5T_str_t:
- H5T_STR_ERROR = -1,
- H5T_STR_NULLTERM = 0,
- H5T_STR_NULLPAD = 1,
- H5T_STR_SPACEPAD = 2
-
- # Atomic datatype padding
- ctypedef enum H5T_pad_t:
- H5T_PAD_ZERO = 0,
- H5T_PAD_ONE = 1,
- H5T_PAD_BACKGROUND = 2
-
- # HDF5 type classes
- cdef enum H5T_class_t:
- H5T_NO_CLASS = -1, # error
- H5T_INTEGER = 0, # integer types
- H5T_FLOAT = 1, # floating-point types
- H5T_TIME = 2, # date and time types
- H5T_STRING = 3, # character string types
- H5T_BITFIELD = 4, # bit field types
- H5T_OPAQUE = 5, # opaque types
- H5T_COMPOUND = 6, # compound types
- H5T_REFERENCE = 7, # reference types
- H5T_ENUM = 8, # enumeration types
- H5T_VLEN = 9, # variable-length types
- H5T_ARRAY = 10, # array types
- H5T_NCLASSES # this must be last
-
- # Native search direction
- cdef enum H5T_direction_t:
- H5T_DIR_DEFAULT,
- H5T_DIR_ASCEND,
- H5T_DIR_DESCEND
-
- # For vlen strings
- cdef size_t H5T_VARIABLE
-
- # --- Predefined datatypes --------------------------------------------------
-
- cdef enum:
- H5T_NATIVE_B8
- H5T_NATIVE_CHAR
- H5T_NATIVE_SCHAR
- H5T_NATIVE_UCHAR
- H5T_NATIVE_SHORT
- H5T_NATIVE_USHORT
- H5T_NATIVE_INT
- H5T_NATIVE_UINT
- H5T_NATIVE_LONG
- H5T_NATIVE_ULONG
- H5T_NATIVE_LLONG
- H5T_NATIVE_ULLONG
- H5T_NATIVE_FLOAT
- H5T_NATIVE_DOUBLE
- H5T_NATIVE_LDOUBLE
-
- # "Standard" types
- cdef enum:
- H5T_STD_I8LE
- H5T_STD_I16LE
- H5T_STD_I32LE
- H5T_STD_I64LE
- H5T_STD_U8LE
- H5T_STD_U16LE
- H5T_STD_U32LE
- H5T_STD_U64LE
- H5T_STD_B8LE
- H5T_STD_B16LE
- H5T_STD_B32LE
- H5T_STD_B64LE
- H5T_IEEE_F32LE
- H5T_IEEE_F64LE
- H5T_STD_I8BE
- H5T_STD_I16BE
- H5T_STD_I32BE
- H5T_STD_I64BE
- H5T_STD_U8BE
- H5T_STD_U16BE
- H5T_STD_U32BE
- H5T_STD_U64BE
- H5T_STD_B8BE
- H5T_STD_B16BE
- H5T_STD_B32BE
- H5T_STD_B64BE
- H5T_IEEE_F32BE
- H5T_IEEE_F64BE
-
- cdef enum:
- H5T_NATIVE_INT8
- H5T_NATIVE_UINT8
- H5T_NATIVE_INT16
- H5T_NATIVE_UINT16
- H5T_NATIVE_INT32
- H5T_NATIVE_UINT32
- H5T_NATIVE_INT64
- H5T_NATIVE_UINT64
-
- # Unix time types
- cdef enum:
- H5T_UNIX_D32LE
- H5T_UNIX_D64LE
- H5T_UNIX_D32BE
- H5T_UNIX_D64BE
-
- # String types
- cdef enum:
- H5T_FORTRAN_S1
- H5T_C_S1
-
- # References
- cdef enum:
- H5T_STD_REF_OBJ
- H5T_STD_REF_DSETREG
+ #hid_t H5P_DEFAULT
+
+
# --- Datatype operations ---------------------------------------------------
@@ -1148,37 +599,6 @@ cdef extern from "hdf5.h":
herr_t H5Tcommit2(hid_t loc_id, char *name, hid_t dtype_id, hid_t lcpl_id,
hid_t tcpl_id, hid_t tapl_id)
- # Type-conversion infrastructure
-
- ctypedef enum H5T_pers_t:
- H5T_PERS_DONTCARE = -1,
- H5T_PERS_HARD = 0, # /*hard conversion function */
- H5T_PERS_SOFT = 1 # /*soft conversion function */
-
- ctypedef enum H5T_cmd_t:
- H5T_CONV_INIT = 0, #/*query and/or initialize private data */
- H5T_CONV_CONV = 1, #/*convert data from source to dest datatype */
- H5T_CONV_FREE = 2 #/*function is being removed from path */
-
- ctypedef enum H5T_bkg_t:
- H5T_BKG_NO = 0, #/*background buffer is not needed, send NULL */
- H5T_BKG_TEMP = 1, #/*bkg buffer used as temp storage only */
- H5T_BKG_YES = 2 #/*init bkg buf with data before conversion */
-
- ctypedef struct H5T_cdata_t:
- H5T_cmd_t command # /*what should the conversion function do? */
- H5T_bkg_t need_bkg #/*is the background buffer needed? */
- hbool_t recalc # /*recalculate private data */
- void *priv # /*private data */
-
- ctypedef struct hvl_t:
- size_t len # /* Length of VL data (in base type units) */
- void *p #/* Pointer to VL data */
-
- ctypedef herr_t (*H5T_conv_t)(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
- size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf,
- void *bkg, hid_t dset_xfer_plist) except -1
-
H5T_conv_t H5Tfind(hid_t src_id, hid_t dst_id, H5T_cdata_t **pcdata) except *
herr_t H5Tregister(H5T_pers_t pers, char *name, hid_t src_id,
@@ -1192,41 +612,6 @@ cdef extern from "hdf5.h":
cdef extern from "hdf5.h":
- ctypedef int H5Z_filter_t
-
- int H5Z_FILTER_ERROR
- int H5Z_FILTER_NONE
- int H5Z_FILTER_ALL
- int H5Z_FILTER_DEFLATE
- int H5Z_FILTER_SHUFFLE
- int H5Z_FILTER_FLETCHER32
- int H5Z_FILTER_SZIP
- int H5Z_FILTER_RESERVED
- int H5Z_FILTER_MAX
- int H5Z_MAX_NFILTERS
-
- int H5Z_FLAG_DEFMASK
- int H5Z_FLAG_MANDATORY
- int H5Z_FLAG_OPTIONAL
-
- int H5Z_FLAG_INVMASK
- int H5Z_FLAG_REVERSE
- int H5Z_FLAG_SKIP_EDC
-
- int H5_SZIP_ALLOW_K13_OPTION_MASK #1
- int H5_SZIP_CHIP_OPTION_MASK #2
- int H5_SZIP_EC_OPTION_MASK #4
- int H5_SZIP_NN_OPTION_MASK #32
- int H5_SZIP_MAX_PIXELS_PER_BLOCK #32
-
- int H5Z_FILTER_CONFIG_ENCODE_ENABLED #(0x0001)
- int H5Z_FILTER_CONFIG_DECODE_ENABLED #(0x0002)
-
- cdef enum H5Z_EDC_t:
- H5Z_ERROR_EDC = -1,
- H5Z_DISABLE_EDC = 0,
- H5Z_ENABLE_EDC = 1,
- H5Z_NO_EDC = 2
htri_t H5Zfilter_avail(H5Z_filter_t id_) except *
herr_t H5Zget_filter_info(H5Z_filter_t filter_, unsigned int *filter_config_flags) except *
@@ -1249,18 +634,10 @@ cdef extern from "hdf5.h":
ssize_t H5Aget_name(hid_t attr_id, size_t buf_size, char *buf) except *
hid_t H5Aget_space(hid_t attr_id) except *
hid_t H5Aget_type(hid_t attr_id) except *
-
- ctypedef herr_t (*H5A_operator_t)(hid_t loc_id, char *attr_name, void* operator_data) except 2
herr_t H5Aiterate(hid_t loc_id, unsigned * idx, H5A_operator_t op, void* op_data) except *
IF H5PY_18API:
- ctypedef struct H5A_info_t:
- hbool_t corder_valid # Indicate if creation order is valid
- H5O_msg_crt_idx_t corder # Creation order
- H5T_cset_t cset # Character set of attribute name
- hsize_t data_size # Size of raw data
-
herr_t H5Adelete_by_name(hid_t loc_id, char *obj_name, char *attr_name,
hid_t lapl_id) except *
herr_t H5Adelete_by_idx(hid_t loc_id, char *obj_name, H5_index_t idx_type,
@@ -1288,8 +665,6 @@ cdef extern from "hdf5.h":
herr_t H5Aget_info_by_idx(hid_t loc_id, char *obj_name, H5_index_t idx_type,
H5_iter_order_t order, hsize_t n, H5A_info_t *ainfo, hid_t lapl_id) except *
- ctypedef herr_t (*H5A_operator2_t)(hid_t location_id, char *attr_name,
- H5A_info_t *ainfo, void *op_data) except 2
herr_t H5Aiterate2(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order,
hsize_t *n, H5A_operator2_t op, void *op_data) except *
diff --git a/h5py/defs_types.pxi b/h5py/defs_types.pxi
new file mode 100644
index 0000000..a716604
--- /dev/null
+++ b/h5py/defs_types.pxi
@@ -0,0 +1,668 @@
+
+cdef extern from "hdf5.h":
+
+ # Basic types
+ ctypedef int hid_t
+ ctypedef int hbool_t
+ ctypedef int herr_t
+ ctypedef int htri_t
+ ctypedef long long hsize_t
+ ctypedef signed long long hssize_t
+ ctypedef signed long long haddr_t
+
+ ctypedef struct hvl_t:
+ size_t len # Length of VL data (in base type units)
+ void *p # Pointer to VL data
+
+ int HADDR_UNDEF
+
+ # New in 1.8.X
+ IF H5PY_18API:
+
+ ctypedef enum H5_iter_order_t:
+ H5_ITER_UNKNOWN = -1, # Unknown order
+ H5_ITER_INC, # Increasing order
+ H5_ITER_DEC, # Decreasing order
+ H5_ITER_NATIVE, # No particular order, whatever is fastest
+ H5_ITER_N # Number of iteration orders
+
+ ctypedef enum H5_index_t:
+ H5_INDEX_UNKNOWN = -1, # Unknown index type
+ H5_INDEX_NAME, # Index on names
+ H5_INDEX_CRT_ORDER, # Index on creation order
+ H5_INDEX_N # Number of indices defined
+
+# === H5D - Dataset API =======================================================
+
+ ctypedef enum H5D_layout_t:
+ H5D_LAYOUT_ERROR = -1,
+ H5D_COMPACT = 0,
+ H5D_CONTIGUOUS = 1,
+ H5D_CHUNKED = 2,
+ H5D_NLAYOUTS = 3
+
+ ctypedef enum H5D_alloc_time_t:
+ H5D_ALLOC_TIME_ERROR =-1,
+ H5D_ALLOC_TIME_DEFAULT =0,
+ H5D_ALLOC_TIME_EARLY =1,
+ H5D_ALLOC_TIME_LATE =2,
+ H5D_ALLOC_TIME_INCR =3
+
+ ctypedef enum H5D_space_status_t:
+ H5D_SPACE_STATUS_ERROR =-1,
+ H5D_SPACE_STATUS_NOT_ALLOCATED =0,
+ H5D_SPACE_STATUS_PART_ALLOCATED =1,
+ H5D_SPACE_STATUS_ALLOCATED =2
+
+ ctypedef enum H5D_fill_time_t:
+ H5D_FILL_TIME_ERROR =-1,
+ H5D_FILL_TIME_ALLOC =0,
+ H5D_FILL_TIME_NEVER =1,
+ H5D_FILL_TIME_IFSET =2
+
+ ctypedef enum H5D_fill_value_t:
+ H5D_FILL_VALUE_ERROR =-1,
+ H5D_FILL_VALUE_UNDEFINED =0,
+ H5D_FILL_VALUE_DEFAULT =1,
+ H5D_FILL_VALUE_USER_DEFINED =2
+
+ ctypedef herr_t (*H5D_operator_t)(void *elem, hid_t type_id, unsigned ndim,
+ hsize_t *point, void *operator_data) except -1
+
+# === H5F - File API ==========================================================
+
+ # File constants
+ cdef enum:
+ H5F_ACC_TRUNC
+ H5F_ACC_RDONLY
+ H5F_ACC_RDWR
+ H5F_ACC_EXCL
+ H5F_ACC_DEBUG
+ H5F_ACC_CREAT
+
+ # The difference between a single file and a set of mounted files
+ cdef enum H5F_scope_t:
+ H5F_SCOPE_LOCAL = 0, # specified file handle only
+ H5F_SCOPE_GLOBAL = 1, # entire virtual file
+ H5F_SCOPE_DOWN = 2 # for internal use only
+
+ cdef enum H5F_close_degree_t:
+ H5F_CLOSE_WEAK = 0,
+ H5F_CLOSE_SEMI = 1,
+ H5F_CLOSE_STRONG = 2,
+ H5F_CLOSE_DEFAULT = 3
+
+ int H5F_OBJ_FILE
+ int H5F_OBJ_DATASET
+ int H5F_OBJ_GROUP
+ int H5F_OBJ_DATATYPE
+ int H5F_OBJ_ATTR
+ int H5F_OBJ_ALL
+ int H5F_OBJ_LOCAL
+
+# === H5FD - Low-level file descriptor API ====================================
+
+ ctypedef enum H5FD_mem_t:
+ H5FD_MEM_NOLIST = -1,
+ H5FD_MEM_DEFAULT = 0,
+ H5FD_MEM_SUPER = 1,
+ H5FD_MEM_BTREE = 2,
+ H5FD_MEM_DRAW = 3,
+ H5FD_MEM_GHEAP = 4,
+ H5FD_MEM_LHEAP = 5,
+ H5FD_MEM_OHDR = 6,
+ H5FD_MEM_NTYPES
+
+ # HDF5 uses a clever scheme wherein these are actually init() calls
+ # Hopefully Cython won't have a problem with this.
+ # Thankfully they are defined but -1 if unavailable
+ hid_t H5FD_CORE
+ hid_t H5FD_FAMILY
+# hid_t H5FD_GASS not in 1.8.X
+ hid_t H5FD_LOG
+ hid_t H5FD_MPIO
+ hid_t H5FD_MULTI
+ hid_t H5FD_SEC2
+ hid_t H5FD_STDIO
+
+ int H5FD_LOG_LOC_READ # 0x0001
+ int H5FD_LOG_LOC_WRITE # 0x0002
+ int H5FD_LOG_LOC_SEEK # 0x0004
+ int H5FD_LOG_LOC_IO # (H5FD_LOG_LOC_READ|H5FD_LOG_LOC_WRITE|H5FD_LOG_LOC_SEEK)
+
+ # Flags for tracking number of times each byte is read/written
+ int H5FD_LOG_FILE_READ # 0x0008
+ int H5FD_LOG_FILE_WRITE # 0x0010
+ int H5FD_LOG_FILE_IO # (H5FD_LOG_FILE_READ|H5FD_LOG_FILE_WRITE)
+
+ # Flag for tracking "flavor" (type) of information stored at each byte
+ int H5FD_LOG_FLAVOR # 0x0020
+
+ # Flags for tracking total number of reads/writes/seeks
+ int H5FD_LOG_NUM_READ # 0x0040
+ int H5FD_LOG_NUM_WRITE # 0x0080
+ int H5FD_LOG_NUM_SEEK # 0x0100
+ int H5FD_LOG_NUM_IO # (H5FD_LOG_NUM_READ|H5FD_LOG_NUM_WRITE|H5FD_LOG_NUM_SEEK)
+
+ # Flags for tracking time spent in open/read/write/seek/close
+ int H5FD_LOG_TIME_OPEN # 0x0200 # Not implemented yet
+ int H5FD_LOG_TIME_READ # 0x0400 # Not implemented yet
+ int H5FD_LOG_TIME_WRITE # 0x0800 # Partially implemented (need to track total time)
+ int H5FD_LOG_TIME_SEEK # 0x1000 # Partially implemented (need to track total time & track time for seeks during reading)
+ int H5FD_LOG_TIME_CLOSE # 0x2000 # Fully implemented
+ int H5FD_LOG_TIME_IO # (H5FD_LOG_TIME_OPEN|H5FD_LOG_TIME_READ|H5FD_LOG_TIME_WRITE|H5FD_LOG_TIME_SEEK|H5FD_LOG_TIME_CLOSE)
+
+ # Flag for tracking allocation of space in file
+ int H5FD_LOG_ALLOC # 0x4000
+ int H5FD_LOG_ALL # (H5FD_LOG_ALLOC|H5FD_LOG_TIME_IO|H5FD_LOG_NUM_IO|H5FD_LOG_FLAVOR|H5FD_LOG_FILE_IO|H5FD_LOG_LOC_IO)
+
+# === H5G - Groups API ========================================================
+
+ ctypedef enum H5G_link_t:
+ H5G_LINK_ERROR = -1,
+ H5G_LINK_HARD = 0,
+ H5G_LINK_SOFT = 1
+
+ cdef enum H5G_obj_t:
+ H5G_UNKNOWN = -1, # Unknown object type
+ H5G_LINK, # Object is a symbolic link
+ H5G_GROUP, # Object is a group
+ H5G_DATASET, # Object is a dataset
+ H5G_TYPE, # Object is a named data type
+
+ ctypedef struct H5G_stat_t:
+ unsigned long fileno[2]
+ unsigned long objno[2]
+ unsigned int nlink
+ H5G_obj_t type # new in HDF5 1.6
+ time_t mtime
+ size_t linklen
+ #H5O_stat_t ohdr # Object header information. New in HDF5 1.6
+
+ ctypedef herr_t (*H5G_iterate_t)(hid_t group, char *name, void* op_data) except 2
+
+ IF H5PY_18API:
+
+ ctypedef enum H5G_storage_type_t:
+ H5G_STORAGE_TYPE_UNKNOWN = -1,
+ H5G_STORAGE_TYPE_SYMBOL_TABLE,
+ H5G_STORAGE_TYPE_COMPACT,
+ H5G_STORAGE_TYPE_DENSE
+
+ ctypedef struct H5G_info_t:
+ H5G_storage_type_t storage_type
+ hsize_t nlinks
+ int64_t max_corder
+
+# === H5I - Identifier and reflection interface ===============================
+
+ ctypedef enum H5I_type_t:
+ H5I_BADID = -1, # invalid Group
+ H5I_FILE = 1, # group ID for File objects
+ H5I_GROUP, # group ID for Group objects
+ H5I_DATATYPE, # group ID for Datatype objects
+ H5I_DATASPACE, # group ID for Dataspace objects
+ H5I_DATASET, # group ID for Dataset objects
+ H5I_ATTR, # group ID for Attribute objects
+ H5I_REFERENCE, # group ID for Reference objects
+ H5I_VFL, # group ID for virtual file layer
+ H5I_GENPROP_CLS, # group ID for generic property list classes
+ H5I_GENPROP_LST, # group ID for generic property lists
+ H5I_NGROUPS # number of valid groups, MUST BE LAST!
+
+# === H5L/H5O - Links interface (1.8.X only) ======================================
+
+ IF H5PY_18API:
+
+
+ # TODO: put both versions in h5t.pxd
+ ctypedef enum H5T_cset_t:
+ H5T_CSET_ERROR = -1, #
+ H5T_CSET_ASCII = 0, # US ASCII
+ H5T_CSET_UTF8 = 1, # UTF-8 Unicode encoding
+
+ unsigned int H5L_MAX_LINK_NAME_LEN # ((uint32_t) (-1)) (4GB - 1)
+
+ # Link class types.
+ # * Values less than 64 are reserved for the HDF5 library's internal use.
+ # * Values 64 to 255 are for "user-defined" link class types; these types are
+ # * defined by HDF5 but their behavior can be overridden by users.
+ # * Users who want to create new classes of links should contact the HDF5
+ # * development team at hdfhelp at ncsa.uiuc.edu .
+ # * These values can never change because they appear in HDF5 files.
+ #
+ ctypedef enum H5L_type_t:
+ H5L_TYPE_ERROR = (-1), # Invalid link type id
+ H5L_TYPE_HARD = 0, # Hard link id
+ H5L_TYPE_SOFT = 1, # Soft link id
+ H5L_TYPE_EXTERNAL = 64, # External link id
+ H5L_TYPE_MAX = 255 # Maximum link type id
+
+ # Information struct for link (for H5Lget_info/H5Lget_info_by_idx)
+ cdef union _add_u:
+ haddr_t address # Address hard link points to
+ size_t val_size # Size of a soft link or UD link value
+
+ ctypedef struct H5L_info_t:
+ H5L_type_t type # Type of link
+ hbool_t corder_valid # Indicate if creation order is valid
+ int64_t corder # Creation order
+ H5T_cset_t cset # Character set of link name
+ _add_u u
+
+ # Prototype for H5Literate/H5Literate_by_name() operator
+ ctypedef herr_t (*H5L_iterate_t) (hid_t group, char *name, H5L_info_t *info,
+ void *op_data) except 2
+
+ ctypedef uint32_t H5O_msg_crt_idx_t
+
+ ctypedef enum H5O_type_t:
+ H5O_TYPE_UNKNOWN = -1, # Unknown object type
+ H5O_TYPE_GROUP, # Object is a group
+ H5O_TYPE_DATASET, # Object is a dataset
+ H5O_TYPE_NAMED_DATATYPE, # Object is a named data type
+ H5O_TYPE_NTYPES # Number of different object types (must be last!)
+
+ unsigned int H5O_COPY_SHALLOW_HIERARCHY_FLAG # (0x0001u) Copy only immediate members
+ unsigned int H5O_COPY_EXPAND_SOFT_LINK_FLAG # (0x0002u) Expand soft links into new objects
+ unsigned int H5O_COPY_EXPAND_EXT_LINK_FLAG # (0x0004u) Expand external links into new objects
+ unsigned int H5O_COPY_EXPAND_REFERENCE_FLAG # (0x0008u) Copy objects that are pointed by references
+ unsigned int H5O_COPY_WITHOUT_ATTR_FLAG # (0x0010u) Copy object without copying attributes
+ unsigned int H5O_COPY_PRESERVE_NULL_FLAG # (0x0020u) Copy NULL messages (empty space)
+ unsigned int H5O_COPY_ALL # (0x003Fu) All object copying flags (for internal checking)
+
+ # --- Components for the H5O_info_t struct ----------------------------------
+
+ ctypedef struct space:
+ hsize_t total # Total space for storing object header in file
+ hsize_t meta # Space within header for object header metadata information
+ hsize_t mesg # Space within header for actual message information
+ hsize_t free # Free space within object header
+
+ ctypedef struct mesg:
+ unsigned long present # Flags to indicate presence of message type in header
+ unsigned long shared # Flags to indicate message type is shared in header
+
+ ctypedef struct hdr:
+ unsigned version # Version number of header format in file
+ unsigned nmesgs # Number of object header messages
+ unsigned nchunks # Number of object header chunks
+ unsigned flags # Object header status flags
+ space space
+ mesg mesg
+
+ ctypedef struct H5_ih_info_t:
+ hsize_t index_size, # btree and/or list
+ hsize_t heap_size
+
+ cdef struct meta_size:
+ H5_ih_info_t obj, # v1/v2 B-tree & local/fractal heap for groups, B-tree for chunked datasets
+ H5_ih_info_t attr # v2 B-tree & heap for attributes
+
+ ctypedef struct H5O_info_t:
+ unsigned long fileno # File number that object is located in
+ haddr_t addr # Object address in file
+ H5O_type_t type # Basic object type (group, dataset, etc.)
+ unsigned rc # Reference count of object
+ time_t atime # Access time
+ time_t mtime # Modification time
+ time_t ctime # Change time
+ time_t btime # Birth time
+ hsize_t num_attrs # # of attributes attached to object
+ hdr hdr
+ meta_size meta_size
+
+ ctypedef herr_t (*H5O_iterate_t)(hid_t obj, char *name, H5O_info_t *info,
+ void *op_data) except 2
+
+# === H5P - Property list API =================================================
+
+ int H5P_DEFAULT
+
+ ctypedef int H5Z_filter_t
+
+ # HDF5 layouts
+ ctypedef enum H5D_layout_t:
+ H5D_LAYOUT_ERROR = -1,
+ H5D_COMPACT = 0, # raw data is very small
+ H5D_CONTIGUOUS = 1, # the default
+ H5D_CHUNKED = 2, # slow and fancy
+ H5D_NLAYOUTS = 3 # this one must be last!
+
+ ctypedef enum H5D_alloc_time_t:
+ H5D_ALLOC_TIME_ERROR =-1,
+ H5D_ALLOC_TIME_DEFAULT =0,
+ H5D_ALLOC_TIME_EARLY =1,
+ H5D_ALLOC_TIME_LATE =2,
+ H5D_ALLOC_TIME_INCR =3
+
+ ctypedef enum H5D_space_status_t:
+ H5D_SPACE_STATUS_ERROR =-1,
+ H5D_SPACE_STATUS_NOT_ALLOCATED =0,
+ H5D_SPACE_STATUS_PART_ALLOCATED =1,
+ H5D_SPACE_STATUS_ALLOCATED =2
+
+ ctypedef enum H5D_fill_time_t:
+ H5D_FILL_TIME_ERROR =-1,
+ H5D_FILL_TIME_ALLOC =0,
+ H5D_FILL_TIME_NEVER =1,
+ H5D_FILL_TIME_IFSET =2
+
+ ctypedef enum H5D_fill_value_t:
+ H5D_FILL_VALUE_ERROR =-1,
+ H5D_FILL_VALUE_UNDEFINED =0,
+ H5D_FILL_VALUE_DEFAULT =1,
+ H5D_FILL_VALUE_USER_DEFINED =2
+
+ cdef enum H5Z_EDC_t:
+ H5Z_ERROR_EDC = -1,
+ H5Z_DISABLE_EDC = 0,
+ H5Z_ENABLE_EDC = 1,
+ H5Z_NO_EDC = 2
+
+ cdef enum H5F_close_degree_t:
+ H5F_CLOSE_WEAK = 0,
+ H5F_CLOSE_SEMI = 1,
+ H5F_CLOSE_STRONG = 2,
+ H5F_CLOSE_DEFAULT = 3
+
+ ctypedef enum H5FD_mem_t:
+ H5FD_MEM_NOLIST = -1,
+ H5FD_MEM_DEFAULT = 0,
+ H5FD_MEM_SUPER = 1,
+ H5FD_MEM_BTREE = 2,
+ H5FD_MEM_DRAW = 3,
+ H5FD_MEM_GHEAP = 4,
+ H5FD_MEM_LHEAP = 5,
+ H5FD_MEM_OHDR = 6,
+ H5FD_MEM_NTYPES
+
+ # Property list classes
+ hid_t H5P_NO_CLASS
+ hid_t H5P_FILE_CREATE
+ hid_t H5P_FILE_ACCESS
+ hid_t H5P_DATASET_CREATE
+ hid_t H5P_DATASET_XFER
+ IF H5PY_18API:
+ hid_t H5P_OBJECT_CREATE
+ hid_t H5P_OBJECT_COPY
+ hid_t H5P_LINK_CREATE
+ hid_t H5P_LINK_ACCESS
+ hid_t H5P_GROUP_CREATE
+
+# === H5R - Reference API =====================================================
+
+ size_t H5R_DSET_REG_REF_BUF_SIZE
+ size_t H5R_OBJ_REF_BUF_SIZE
+
+ ctypedef enum H5R_type_t:
+ H5R_BADTYPE = (-1),
+ H5R_OBJECT,
+ H5R_DATASET_REGION,
+ H5R_INTERNAL,
+ H5R_MAXTYPE
+
+# === H5S - Dataspaces ========================================================
+
+ int H5S_ALL, H5S_MAX_RANK
+ hsize_t H5S_UNLIMITED
+
+ # Codes for defining selections
+ ctypedef enum H5S_seloper_t:
+ H5S_SELECT_NOOP = -1,
+ H5S_SELECT_SET = 0,
+ H5S_SELECT_OR,
+ H5S_SELECT_AND,
+ H5S_SELECT_XOR,
+ H5S_SELECT_NOTB,
+ H5S_SELECT_NOTA,
+ H5S_SELECT_APPEND,
+ H5S_SELECT_PREPEND,
+ H5S_SELECT_INVALID # Must be the last one
+
+ ctypedef enum H5S_class_t:
+ H5S_NO_CLASS = -1, #/*error
+ H5S_SCALAR = 0, #/*scalar variable
+ H5S_SIMPLE = 1, #/*simple data space
+ # no longer defined in 1.8
+ #H5S_COMPLEX = 2 #/*complex data space
+
+ ctypedef enum H5S_sel_type:
+ H5S_SEL_ERROR = -1, #Error
+ H5S_SEL_NONE = 0, #Nothing selected
+ H5S_SEL_POINTS = 1, #Sequence of points selected
+ H5S_SEL_HYPERSLABS = 2, #"New-style" hyperslab selection defined
+ H5S_SEL_ALL = 3, #Entire extent selected
+ H5S_SEL_N = 4 #/*THIS MUST BE LAST
+
+# === H5T - Datatypes =========================================================
+
+ # --- Enumerated constants --------------------------------------------------
+
+ # Byte orders
+ ctypedef enum H5T_order_t:
+ H5T_ORDER_ERROR = -1, # error
+ H5T_ORDER_LE = 0, # little endian
+ H5T_ORDER_BE = 1, # bit endian
+ H5T_ORDER_VAX = 2, # VAX mixed endian
+ H5T_ORDER_NONE = 3 # no particular order (strings, bits,..)
+
+ # HDF5 signed enums
+ ctypedef enum H5T_sign_t:
+ H5T_SGN_ERROR = -1, # error
+ H5T_SGN_NONE = 0, # this is an unsigned type
+ H5T_SGN_2 = 1, # two's complement
+ H5T_NSGN = 2 # this must be last!
+
+ ctypedef enum H5T_norm_t:
+ H5T_NORM_ERROR = -1,
+ H5T_NORM_IMPLIED = 0,
+ H5T_NORM_MSBSET = 1,
+ H5T_NORM_NONE = 2
+
+ ctypedef enum H5T_cset_t:
+ H5T_CSET_ERROR = -1,
+ H5T_CSET_ASCII = 0
+
+ ctypedef enum H5T_str_t:
+ H5T_STR_ERROR = -1,
+ H5T_STR_NULLTERM = 0,
+ H5T_STR_NULLPAD = 1,
+ H5T_STR_SPACEPAD = 2
+
+ # Atomic datatype padding
+ ctypedef enum H5T_pad_t:
+ H5T_PAD_ZERO = 0,
+ H5T_PAD_ONE = 1,
+ H5T_PAD_BACKGROUND = 2
+
+ # HDF5 type classes
+ cdef enum H5T_class_t:
+ H5T_NO_CLASS = -1, # error
+ H5T_INTEGER = 0, # integer types
+ H5T_FLOAT = 1, # floating-point types
+ H5T_TIME = 2, # date and time types
+ H5T_STRING = 3, # character string types
+ H5T_BITFIELD = 4, # bit field types
+ H5T_OPAQUE = 5, # opaque types
+ H5T_COMPOUND = 6, # compound types
+ H5T_REFERENCE = 7, # reference types
+ H5T_ENUM = 8, # enumeration types
+ H5T_VLEN = 9, # variable-length types
+ H5T_ARRAY = 10, # array types
+ H5T_NCLASSES # this must be last
+
+ # Native search direction
+ cdef enum H5T_direction_t:
+ H5T_DIR_DEFAULT,
+ H5T_DIR_ASCEND,
+ H5T_DIR_DESCEND
+
+ # For vlen strings
+ cdef size_t H5T_VARIABLE
+
+ # --- Predefined datatypes --------------------------------------------------
+
+ cdef enum:
+ H5T_NATIVE_B8
+ H5T_NATIVE_CHAR
+ H5T_NATIVE_SCHAR
+ H5T_NATIVE_UCHAR
+ H5T_NATIVE_SHORT
+ H5T_NATIVE_USHORT
+ H5T_NATIVE_INT
+ H5T_NATIVE_UINT
+ H5T_NATIVE_LONG
+ H5T_NATIVE_ULONG
+ H5T_NATIVE_LLONG
+ H5T_NATIVE_ULLONG
+ H5T_NATIVE_FLOAT
+ H5T_NATIVE_DOUBLE
+ H5T_NATIVE_LDOUBLE
+
+ # "Standard" types
+ cdef enum:
+ H5T_STD_I8LE
+ H5T_STD_I16LE
+ H5T_STD_I32LE
+ H5T_STD_I64LE
+ H5T_STD_U8LE
+ H5T_STD_U16LE
+ H5T_STD_U32LE
+ H5T_STD_U64LE
+ H5T_STD_B8LE
+ H5T_STD_B16LE
+ H5T_STD_B32LE
+ H5T_STD_B64LE
+ H5T_IEEE_F32LE
+ H5T_IEEE_F64LE
+ H5T_STD_I8BE
+ H5T_STD_I16BE
+ H5T_STD_I32BE
+ H5T_STD_I64BE
+ H5T_STD_U8BE
+ H5T_STD_U16BE
+ H5T_STD_U32BE
+ H5T_STD_U64BE
+ H5T_STD_B8BE
+ H5T_STD_B16BE
+ H5T_STD_B32BE
+ H5T_STD_B64BE
+ H5T_IEEE_F32BE
+ H5T_IEEE_F64BE
+
+ cdef enum:
+ H5T_NATIVE_INT8
+ H5T_NATIVE_UINT8
+ H5T_NATIVE_INT16
+ H5T_NATIVE_UINT16
+ H5T_NATIVE_INT32
+ H5T_NATIVE_UINT32
+ H5T_NATIVE_INT64
+ H5T_NATIVE_UINT64
+
+ # Unix time types
+ cdef enum:
+ H5T_UNIX_D32LE
+ H5T_UNIX_D64LE
+ H5T_UNIX_D32BE
+ H5T_UNIX_D64BE
+
+ # String types
+ cdef enum:
+ H5T_FORTRAN_S1
+ H5T_C_S1
+
+ # References
+ cdef enum:
+ H5T_STD_REF_OBJ
+ H5T_STD_REF_DSETREG
+
+ # Type-conversion infrastructure
+
+ ctypedef enum H5T_pers_t:
+ H5T_PERS_DONTCARE = -1,
+ H5T_PERS_HARD = 0, # /*hard conversion function */
+ H5T_PERS_SOFT = 1 # /*soft conversion function */
+
+ ctypedef enum H5T_cmd_t:
+ H5T_CONV_INIT = 0, #/*query and/or initialize private data */
+ H5T_CONV_CONV = 1, #/*convert data from source to dest datatype */
+ H5T_CONV_FREE = 2 #/*function is being removed from path */
+
+ ctypedef enum H5T_bkg_t:
+ H5T_BKG_NO = 0, #/*background buffer is not needed, send NULL */
+ H5T_BKG_TEMP = 1, #/*bkg buffer used as temp storage only */
+ H5T_BKG_YES = 2 #/*init bkg buf with data before conversion */
+
+ ctypedef struct H5T_cdata_t:
+ H5T_cmd_t command # /*what should the conversion function do? */
+ H5T_bkg_t need_bkg #/*is the background buffer needed? */
+ hbool_t recalc # /*recalculate private data */
+ void *priv # /*private data */
+
+ ctypedef struct hvl_t:
+ size_t len # /* Length of VL data (in base type units) */
+ void *p #/* Pointer to VL data */
+
+ ctypedef herr_t (*H5T_conv_t)(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
+ size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf,
+ void *bkg, hid_t dset_xfer_plist) except -1
+
+# === H5Z - Filters ===========================================================
+
+ ctypedef int H5Z_filter_t
+
+ int H5Z_FILTER_ERROR
+ int H5Z_FILTER_NONE
+ int H5Z_FILTER_ALL
+ int H5Z_FILTER_DEFLATE
+ int H5Z_FILTER_SHUFFLE
+ int H5Z_FILTER_FLETCHER32
+ int H5Z_FILTER_SZIP
+ int H5Z_FILTER_RESERVED
+ int H5Z_FILTER_MAX
+ int H5Z_MAX_NFILTERS
+
+ int H5Z_FLAG_DEFMASK
+ int H5Z_FLAG_MANDATORY
+ int H5Z_FLAG_OPTIONAL
+
+ int H5Z_FLAG_INVMASK
+ int H5Z_FLAG_REVERSE
+ int H5Z_FLAG_SKIP_EDC
+
+ int H5_SZIP_ALLOW_K13_OPTION_MASK #1
+ int H5_SZIP_CHIP_OPTION_MASK #2
+ int H5_SZIP_EC_OPTION_MASK #4
+ int H5_SZIP_NN_OPTION_MASK #32
+ int H5_SZIP_MAX_PIXELS_PER_BLOCK #32
+
+ int H5Z_FILTER_CONFIG_ENCODE_ENABLED #(0x0001)
+ int H5Z_FILTER_CONFIG_DECODE_ENABLED #(0x0002)
+
+ cdef enum H5Z_EDC_t:
+ H5Z_ERROR_EDC = -1,
+ H5Z_DISABLE_EDC = 0,
+ H5Z_ENABLE_EDC = 1,
+ H5Z_NO_EDC = 2
+
+# === H5A - Attributes API ====================================================
+
+ ctypedef herr_t (*H5A_operator_t)(hid_t loc_id, char *attr_name, void* operator_data) except 2
+
+ IF H5PY_18API:
+
+ ctypedef struct H5A_info_t:
+ hbool_t corder_valid # Indicate if creation order is valid
+ H5O_msg_crt_idx_t corder # Creation order
+ H5T_cset_t cset # Character set of attribute name
+ hsize_t data_size # Size of raw data
+
+ ctypedef herr_t (*H5A_operator2_t)(hid_t location_id, char *attr_name,
+ H5A_info_t *ainfo, void *op_data) except 2
+
+
+
+
+
diff --git a/h5py/tests/high/test_links.py b/h5py/tests/high/test_links.py
index fdbf5f0..d8af426 100644
--- a/h5py/tests/high/test_links.py
+++ b/h5py/tests/high/test_links.py
@@ -102,13 +102,12 @@ class TestExternal(Base):
@tests.require(api=18)
def test_file(self):
""" (Links) File attribute works correctly on external links """
+ from h5py.h5 import _global_ids as gi
+ from h5py import h5i
self.f['ext'] = h5py.ExternalLink(self.ename, '/external')
- try:
- g = self.f['ext']
- self.assertNotEqual(g.file, self.f)
- finally:
- g.file.close()
-
+ g = self.f['ext']
+ print "g is %s" % id(g)
+ self.assertNotEqual(g.file, self.f)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/h5py.git
More information about the debian-science-commits
mailing list