From 6818f6e9819c1b0af47a3971a3261cbbbc108b65 Mon Sep 17 00:00:00 2001 From: Raymond Lu Date: Thu, 24 Apr 2003 15:15:42 -0500 Subject: [svn-r6744] Purpose: A little code rewriting Description: object types were defined as macros in H5Gpublic.h Solution: changed them to enumerate type Platforms tested: h5committtest --- src/H5G.c | 19 ++++++++++--------- src/H5Gpkg.h | 2 +- src/H5Gprivate.h | 10 +++++----- src/H5Gpublic.h | 18 ++++++++++++++++-- src/H5R.c | 12 ++++++------ 5 files changed, 38 insertions(+), 23 deletions(-) diff --git a/src/H5G.c b/src/H5G.c index a3eb9b5..2b9c043 100644 --- a/src/H5G.c +++ b/src/H5G.c @@ -156,7 +156,7 @@ static herr_t H5G_move(H5G_entry_t *src_loc, const char *src_name, static herr_t H5G_unlink(H5G_entry_t *loc, const char *name, hid_t dxpl_id); static herr_t H5G_get_num_objs(H5G_t *grp, hsize_t *num_objs, hid_t dxpl_id); static ssize_t H5G_get_objname_by_idx(H5G_t *grp, hsize_t idx, char* name, size_t size, hid_t dxpl_id); -static int H5G_get_objtype_by_idx(H5G_t *grp, hsize_t idx, hid_t dxpl_id); +static H5G_obj_t H5G_get_objtype_by_idx(H5G_t *grp, hsize_t idx, hid_t dxpl_id); static herr_t H5G_replace_ent(void *obj_ptr, hid_t obj_id, const void *key); static herr_t H5G_traverse_slink(H5G_entry_t *grp_ent/*in,out*/, H5G_entry_t *obj_ent/*in,out*/, int *nlinks/*in,out*/, hid_t dxpl_id); @@ -511,12 +511,12 @@ done: * *------------------------------------------------------------------------- */ -int +H5G_obj_t H5Gget_objtype_by_idx(hid_t group_id, hsize_t idx) { H5G_t *group = NULL; hsize_t num_objs; - int ret_value = FAIL; + H5G_obj_t ret_value = H5G_UNKNOWN; FUNC_ENTER_API(H5Gget_objtype_by_idx, FAIL); H5TRACE2("Is","ih",group_id,idx); @@ -1003,7 +1003,7 @@ H5G_term_interface(void) *------------------------------------------------------------------------- */ herr_t -H5G_register_type(int type, htri_t(*isa)(H5G_entry_t*, hid_t), const char *_desc) +H5G_register_type(H5G_obj_t type, htri_t(*isa)(H5G_entry_t*, hid_t), const char *_desc) { char *desc = NULL; size_t i; @@ -2298,7 +2298,7 @@ done: * *------------------------------------------------------------------------- */ -int +H5G_obj_t H5G_get_type(H5G_entry_t *ent, hid_t dxpl_id) { htri_t isa; @@ -2521,10 +2521,11 @@ done: * *------------------------------------------------------------------------- */ -static int +static H5G_obj_t H5G_get_objtype_by_idx(H5G_t *grp, hsize_t idx, hid_t dxpl_id) { - int ret_value = FAIL; + H5G_obj_t ret_value = H5G_UNKNOWN; + herr_t ret; H5G_bt_ud3_t udata; FUNC_ENTER_NOAPI(H5G_get_objtype_by_idx, FAIL); @@ -2534,7 +2535,7 @@ H5G_get_objtype_by_idx(H5G_t *grp, hsize_t idx, hid_t dxpl_id) udata.group = grp; /* Iterate over the group members */ - if ((ret_value = H5B_iterate (H5G_fileof(grp), dxpl_id, H5B_SNODE, + if ((ret = H5B_iterate (H5G_fileof(grp), dxpl_id, H5B_SNODE, H5G_node_type, grp->ent.cache.stab.btree_addr, &udata))<0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "iteration operator failed"); @@ -3057,7 +3058,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G_replace_name( int type, H5G_entry_t *loc, +H5G_replace_name(H5G_obj_t type, H5G_entry_t *loc, H5RS_str_t *src_name, H5G_entry_t *src_loc, H5RS_str_t *dst_name, H5G_entry_t *dst_loc, H5G_names_op_t op ) { diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index 5f9adfb..53e8a31 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -126,7 +126,7 @@ typedef struct H5G_bt_ud3_t { hsize_t idx; /*index of group member to be querried */ char *name; /*member name to be returned */ hsize_t num_objs; /*the number of objects having been traversed*/ - int type; /*member type to be returned */ + H5G_obj_t type; /*member type to be returned */ } H5G_bt_ud3_t; /* diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index 80d8ded..66fd86e 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -120,9 +120,9 @@ typedef struct H5G_t H5G_t; * is allocated dynamically. */ typedef struct H5G_typeinfo_t { - int type; /*one of the public H5G_* types */ + H5G_obj_t type; /*one of the public H5G_* types */ htri_t (*isa)(H5G_entry_t*, hid_t); /*function to determine type */ - char *desc; /*description of object type */ + char *desc; /*description of object type */ } H5G_typeinfo_t; /* Type of operation being performed for call to H5G_replace_name() */ @@ -148,7 +148,7 @@ struct H5O_stab_t; * Library prototypes... These are the ones that other packages routinely * call. */ -H5_DLL herr_t H5G_register_type(int type, htri_t(*isa)(H5G_entry_t*, hid_t), +H5_DLL herr_t H5G_register_type(H5G_obj_t type, htri_t(*isa)(H5G_entry_t*, hid_t), const char *desc); H5_DLL H5G_entry_t *H5G_loc(hid_t loc_id); H5_DLL herr_t H5G_mkroot(H5F_t *f, hid_t dxpl_id, H5G_entry_t *root_entry); @@ -158,7 +158,7 @@ H5_DLL H5G_t *H5G_open(H5G_entry_t *loc, const char *name, hid_t dxpl_id); H5_DLL H5G_t *H5G_open_oid(H5G_entry_t *ent, hid_t dxpl_id); H5_DLL herr_t H5G_close(H5G_t *grp); H5_DLL H5G_t *H5G_rootof(H5F_t *f); -H5_DLL int H5G_get_type(H5G_entry_t *ent, hid_t dxpl_id); +H5_DLL H5G_obj_t H5G_get_type(H5G_entry_t *ent, hid_t dxpl_id); H5_DLL herr_t H5G_get_objinfo(H5G_entry_t *loc, const char *name, hbool_t follow_link, H5G_stat_t *statbuf/*out*/, hid_t dxpl_id); @@ -167,7 +167,7 @@ H5_DLL herr_t H5G_insert(H5G_entry_t *loc, const char *name, H5_DLL herr_t H5G_find(H5G_entry_t *loc, const char *name, H5G_entry_t *grp_ent/*out*/, H5G_entry_t *ent/*out*/, hid_t dxpl_id); H5_DLL H5F_t *H5G_insertion_file(H5G_entry_t *loc, const char *name, hid_t dxpl_id); -H5_DLL herr_t H5G_replace_name(int type, H5G_entry_t *loc, +H5_DLL herr_t H5G_replace_name(H5G_obj_t type, H5G_entry_t *loc, H5RS_str_t *src_name, H5G_entry_t *src_loc, H5RS_str_t *dst_name, H5G_entry_t *dst_loc, H5G_names_op_t op); H5_DLL herr_t H5G_free_grp_name(H5G_t *grp); diff --git a/src/H5Gpublic.h b/src/H5Gpublic.h index 54db123..febb6c7 100644 --- a/src/H5Gpublic.h +++ b/src/H5Gpublic.h @@ -52,6 +52,7 @@ typedef enum H5G_link_t { * application is running. An object may satisfy the `isa' function for more * than one type. */ +#ifdef TRY #define H5G_UNKNOWN (-1) /* Unknown object type */ #define H5G_LINK 0 /* Object is a symbolic link */ #define H5G_GROUP 1 /* Object is a group */ @@ -61,6 +62,19 @@ typedef enum H5G_link_t { #define H5G_RESERVED_5 5 /* Reserved for future use */ #define H5G_RESERVED_6 6 /* Reserved for future use */ #define H5G_RESERVED_7 7 /* Reserved for future use */ +#else +typedef 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 */ + H5G_RESERVED_4, /* Reserved for future use */ + H5G_RESERVED_5, /* Reserved for future use */ + H5G_RESERVED_6, /* Reserved for future use */ + H5G_RESERVED_7 /* Reserved for future use */ +} H5G_obj_t; +#endif /*TRY*/ #define H5G_NTYPES 256 /* Max possible number of types */ #define H5G_NLIBTYPES 8 /* Number of internal types */ @@ -72,7 +86,7 @@ typedef struct H5G_stat_t { unsigned long fileno[2]; /*file number */ unsigned long objno[2]; /*object number */ unsigned nlink; /*number of hard links to object*/ - int type; /*basic object type */ + H5G_obj_t type; /*basic object type */ time_t mtime; /*modification time */ size_t linklen; /*symbolic link value length */ } H5G_stat_t; @@ -93,7 +107,7 @@ H5_DLL herr_t H5Giterate(hid_t loc_id, const char *name, int *idx, H5G_iterate_t op, void *op_data); H5_DLL herr_t H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs); H5_DLL ssize_t H5Gget_objname_by_idx(hid_t group_id, hsize_t idx, char* name, size_t size); -H5_DLL int H5Gget_objtype_by_idx(hid_t group_id, hsize_t idx); +H5_DLL H5G_obj_t H5Gget_objtype_by_idx(hid_t group_id, hsize_t idx); H5_DLL herr_t H5Gmove2(hid_t src_loc, const char *src, hid_t dst_loc, const char *dst); H5_DLL herr_t H5Glink2(hid_t src_loc, const char *cur_name, H5G_link_t type, diff --git a/src/H5R.c b/src/H5R.c index ea0c4be..ee1c7e4 100644 --- a/src/H5R.c +++ b/src/H5R.c @@ -40,7 +40,7 @@ static herr_t H5R_create(void *ref, H5G_entry_t *loc, const char *name, H5R_type_t ref_type, H5S_t *space, hid_t dxpl_id); static hid_t H5R_dereference(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, void *_ref); static H5S_t * H5R_get_region(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, void *_ref); -static int H5R_get_obj_type(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, void *_ref); +static H5G_obj_t H5R_get_obj_type(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, void *_ref); /*-------------------------------------------------------------------------- @@ -337,7 +337,7 @@ H5R_dereference(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, void *_ref) H5T_t *datatype; /* Pointer to datatype to open */ H5G_entry_t ent; /* Symbol table entry */ uint8_t *p; /* Pointer to OID to store */ - int oid_type; /* type of object being dereferenced */ + H5G_obj_t oid_type; /* type of object being dereferenced */ hid_t ret_value; FUNC_ENTER_NOINIT(H5R_dereference); @@ -647,13 +647,13 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -static int +static H5G_obj_t H5R_get_object_type(H5F_t *file, void *_ref) { H5G_entry_t ent; /* Symbol table entry */ hobj_ref_t *ref=(hobj_ref_t *)_ref; /* Only object references currently supported */ uint8_t *p; /* Pointer to OID to store */ - int ret_value; + H5G_obj_t ret_value; FUNC_ENTER_NOINIT(H5R_get_object_type); @@ -752,12 +752,12 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -static int +static H5G_obj_t H5R_get_obj_type(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, void *_ref) { H5G_entry_t ent; /* Symbol table entry */ uint8_t *p; /* Pointer to OID to store */ - int ret_value; + H5G_obj_t ret_value; FUNC_ENTER_NOINIT(H5R_get_obj_type); -- cgit v0.12