[svn-r152] Changes since 19980107

----------------------

./html/Datatypes.html
	Updated to match code.

./src/H5Odtype.c
./src/H5Oprivate.h
./src/H5Tpkg.h
./src/H5detect.c
	Changed H5T_FIXED to H5T_INTEGER.

./src/H5T.c
./src/H5Tprivate.h
./src/H5Tpublic.h
./test/dtypes.c
	Implemented lots of type properties.

./src/H5detect.c
./src/H5Tpublic.h
	It is no longer necessary to call H5init() before using a
	predefined data type.
This commit is contained in:
Robb Matzke 1998-01-09 12:49:23 -05:00
parent 159fa7a232
commit 1063eb8a1e
8 changed files with 1607 additions and 93 deletions

View File

@ -90,9 +90,9 @@ H5O_dtype_decode_helper (const uint8 **pp, H5T_t *dt)
UINT32DECODE (*pp, dt->size);
switch (dt->type) {
case H5T_FIXED:
case H5T_INTEGER:
/*
* Fixed-point types...
* Integer types...
*/
dt->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE;
dt->u.atomic.lo_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO;
@ -217,9 +217,9 @@ H5O_dtype_encode_helper (uint8 **pp, const H5T_t *dt)
UINT32ENCODE (*pp, dt->size);
switch (dt->type) {
case H5T_FIXED:
case H5T_INTEGER:
/*
* Fixed-point data types...
* Integer data types...
*/
switch (dt->u.atomic.order) {
case H5T_ORDER_LE:
@ -538,7 +538,7 @@ H5O_dtype_size (H5F_t *f, const void *mesg)
assert (mesg);
switch (dt->type) {
case H5T_FIXED:
case H5T_INTEGER:
ret_value += 4;
break;
@ -637,13 +637,13 @@ H5O_dtype_debug (H5F_t *f, const void *mesg, FILE *stream,
assert (fwidth>=0);
switch (dt->type) {
case H5T_FIXED:
s = "fixed-point";
case H5T_INTEGER:
s = "integer";
break;
case H5T_FLOAT:
s = "floating-point";
break;
case H5T_DATE:
case H5T_TIME:
s = "date and time";
break;
case H5T_STRING:
@ -838,7 +838,7 @@ H5O_dtype_debug (H5F_t *f, const void *mesg, FILE *stream,
"Mantissa size:",
(unsigned long)(dt->u.atomic.u.f.msize));
} else if (H5T_FIXED==dt->type) {
} else if (H5T_INTEGER==dt->type) {
switch (dt->u.atomic.u.i.sign) {
case H5T_SGN_NONE:
s = "none";

View File

@ -52,10 +52,6 @@ typedef struct H5O_class_t {
size_t native_size; /*size of native message */
void *(*decode)(H5F_t*,size_t,const uint8*);
herr_t (*encode)(H5F_t*,size_t,uint8*,const void*);
#if 0
void *(*fast)(const H5G_cache_t*, void*);/*get from of entry */
hbool_t (*cache)(H5G_type_t*, H5G_cache_t*,const void*); /*into entry*/
#endif
void *(*copy)(const void*,void*); /*copy native value */
size_t (*raw_size)(H5F_t*,const void*); /*sizeof raw val */
herr_t (*reset)(void*); /*free nested data structures */

1474
src/H5T.c

File diff suppressed because it is too large Load Diff

View File

@ -26,8 +26,8 @@ typedef struct H5T_atomic_t {
intn hi_pad; /*type of msb padding */
union {
struct {
H5T_sign_t sign; /*type of fixed-point sign */
} i; /*integer; fixed-point types */
H5T_sign_t sign; /*type of integer sign */
} i; /*integer; integer types */
struct {
size_t sign; /*bit position of sign bit */

View File

@ -38,7 +38,13 @@ H5T_t *H5T_copy (const H5T_t *old_dt);
herr_t H5T_close (H5T_t *dt);
size_t H5T_get_size (const H5T_t *dt);
intn H5T_cmp (const H5T_t *dt1, const H5T_t *dt2);
hbool_t H5T_is_atomic (const H5T_t *dt);
herr_t H5T_insert (H5T_t *parent, const char *name, off_t offset,
const H5T_t *member);
herr_t H5T_sort_by_offset (H5T_t *dt);
herr_t H5T_pack (H5T_t *dt);
herr_t H5T_debug (H5T_t *dt, FILE *stream);
herr_t H5T_insert_member (H5T_t *parent, const char *name, off_t offset,
const H5T_t *member);
#endif

View File

@ -26,9 +26,9 @@
/* These are the various classes of data types */
typedef enum H5T_class_t {
H5T_NO_CLASS =-1, /*error */
H5T_FIXED =0, /*fixed-point types */
H5T_INTEGER =0, /*integer types */
H5T_FLOAT =1, /*floating-point types */
H5T_DATE =2, /*date and time 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 */
@ -42,13 +42,16 @@ typedef enum H5T_order_t {
H5T_ORDER_BE =1, /*bit endian */
H5T_ORDER_VAX =2, /*VAX mixed endian */
H5T_ORDER_NONE =3 /*no particular order (strings, bits,..)*/
/*H5T_ORDER_NONE must be last*/
} H5T_order_t;
/* Types of fixed-point sign schemes */
/* Types of integer sign schemes */
typedef 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_SGN_2 =1, /*two's complement */
H5T_SGN_N =2 /*this must be last */
} H5T_sign_t;
/* Floating-point normalization schemes */
@ -57,6 +60,7 @@ typedef enum H5T_norm_t {
H5T_NORM_IMPLIED =0, /*msb of mantissa isn't stored, always 1*/
H5T_NORM_MSBSET =1, /*msb of mantissa is always 1 */
H5T_NORM_NONE =2 /*not normalized */
/*H5T_NORM_NONE must be last*/
} H5T_norm_t;
/* Character set to use for text strings */
@ -72,39 +76,86 @@ typedef enum H5T_str_t {
H5T_STR_SPACE =1 /*pad with spaces like in Fortran */
} H5T_str_t;
/* Type of padding to use in other atomic types */
typedef enum H5T_pad_t {
H5T_PAD_ERROR =-1, /*error */
H5T_PAD_ZERO =0, /*always set to zero */
H5T_PAD_ONE =1, /*always set to one */
H5T_PAD_BACKGROUND =2, /*set to background value */
H5T_NPAD =3 /*THIS MUST BE LAST */
} H5T_pad_t;
#define H5T_PAD_ZERO (-1) /*pad with all zeros */
#define H5T_PAD_ONE (-2) /*pad with all ones */
#define H5T_PAD_FROM(X) (X) /*pad with value of bit X */
#define HOFFSET(S,M) ((const char*)&S.M-(const char*)&S)
#define HPOFFSET(P,M) ((const char*)&(P->M)-(const char*)P)
/* The predefined types */
extern hid_t H5T_NATIVE_CHAR;
extern hid_t H5T_NATIVE_UCHAR;
extern hid_t H5T_NATIVE_SHORT;
extern hid_t H5T_NATIVE_USHORT;
extern hid_t H5T_NATIVE_INT;
extern hid_t H5T_NATIVE_UINT;
extern hid_t H5T_NATIVE_LONG;
extern hid_t H5T_NATIVE_ULONG;
extern hid_t H5T_NATIVE_FLOAT;
extern hid_t H5T_NATIVE_DOUBLE;
#define H5T_NATIVE_CHAR (H5init(), H5T_NATIVE_CHAR_g)
#define H5T_NATIVE_UCHAR (H5init(), H5T_NATIVE_UCHAR_g)
#define H5T_NATIVE_SHORT (H5init(), H5T_NATIVE_SHORT_g)
#define H5T_NATIVE_USHORT (H5init(), H5T_NATIVE_USHORT_g)
#define H5T_NATIVE_INT (H5init(), H5T_NATIVE_INT_g)
#define H5T_NATIVE_UINT (H5init(), H5T_NATIVE_UINT_g)
#define H5T_NATIVE_LONG (H5init(), H5T_NATIVE_LONG_g)
#define H5T_NATIVE_ULONG (H5init(), H5T_NATIVE_ULONG_g)
#define H5T_NATIVE_FLOAT (H5init(), H5T_NATIVE_FLOAT_g)
#define H5T_NATIVE_DOUBLE (H5init(), H5T_NATIVE_DOUBLE_g)
extern hid_t H5T_NATIVE_CHAR_g;
extern hid_t H5T_NATIVE_UCHAR_g;
extern hid_t H5T_NATIVE_SHORT_g;
extern hid_t H5T_NATIVE_USHORT_g;
extern hid_t H5T_NATIVE_INT_g;
extern hid_t H5T_NATIVE_UINT_g;
extern hid_t H5T_NATIVE_LONG_g;
extern hid_t H5T_NATIVE_ULONG_g;
extern hid_t H5T_NATIVE_FLOAT_g;
extern hid_t H5T_NATIVE_DOUBLE_g;
#ifdef __cplusplus
extern "C" {
#endif
/* Operations defined on all data types */
hid_t H5Tcreate (H5T_class_t type, size_t size);
hid_t H5Tcopy (hid_t type_id);
herr_t H5Tclose (hid_t type_id);
hbool_t H5Tequal (hid_t type1_id, hid_t type2_id);
/* Operations defined on compound data types */
herr_t H5Tinsert (hid_t parent_id, const char *name, off_t offset,
hid_t member_id);
herr_t H5Tpack (hid_t type_id);
/* Querying property values */
H5T_class_t H5Tget_class (hid_t type_id);
size_t H5Tget_size (hid_t type_id);
H5T_order_t H5Tget_order (hid_t type_id);
size_t H5Tget_precision (hid_t type_id);
size_t H5Tget_offset (hid_t type_id);
H5T_sign_t H5Tget_sign (hid_t type_id);
herr_t H5Tget_fields (hid_t type_id, size_t *spos/*out*/,
size_t *epos/*out*/, size_t *esize/*out*/,
size_t *mpos/*out*/, size_t *msize/*out*/);
size_t H5Tget_ebias (hid_t type_id);
H5T_norm_t H5Tget_norm (hid_t type_id);
intn H5Tget_nmembers (hid_t type_id);
char *H5Tget_member_name (hid_t type_id, int membno);
size_t H5Tget_member_offset (hid_t type_id, int membno);
int H5Tget_member_dims (hid_t type_id, int membno,
int dims[]/*out*/, int perm[]/*out*/);
hid_t H5Tget_member_type (hid_t type_id, int membno);
herr_t H5Tinsert_member (hid_t parent_id, const char *name, off_t offset,
hid_t member_id);
/* Setting property values */
herr_t H5Tset_size (hid_t type_id, size_t size);
herr_t H5Tset_order (hid_t type_id, H5T_order_t order);
herr_t H5Tset_precision (hid_t type_id, size_t prec);
herr_t H5Tset_offset (hid_t type_id, size_t offset);
herr_t H5Tset_sign (hid_t type_id, H5T_sign_t sign);
herr_t H5Tset_fields (hid_t type_id, size_t spos, size_t epos, size_t esize,
size_t mpos, size_t msize);
herr_t H5Tset_ebias (hid_t type_id, size_t ebias);
herr_t H5Tset_norm (hid_t type_id, H5T_norm_t norm);
#ifdef __cplusplus

View File

@ -98,13 +98,13 @@ static detected_t Known[] = {
{"Byte addressable",
1, 0, LE_1, INTEGER},
/* Little-endian fixed-point */
/* Little-endian integer */
{"Little-endian",
2, 0, LE_2, INTEGER},
{"Little-endian",
4, 0, LE_4, INTEGER},
/* Big-endian fixed-point */
/* Big-endian integer */
{"Big-endian",
2, 0, BE_2, INTEGER},
{"Big-endian",
@ -284,7 +284,7 @@ static hbool_t interface_initialize_g = FALSE;\n\
/* Global definitions for each type */
for (i=0; i<nd; i++) {
printf ("hid_t H5T_NATIVE_%s;\n", d[i].varname);
printf ("hid_t H5T_NATIVE_%s_g = FAIL;\n", d[i].varname);
}
/* Function declaration */
@ -318,7 +318,7 @@ H5T_init (void)\n\
dt->u.atomic.prec = %d;\n\
dt->u.atomic.lo_pad = H5T_PAD_ZERO;\n\
dt->u.atomic.hi_pad = H5T_PAD_ZERO;\n",
d[i].msize?"FLOAT":"FIXED", /*class */
d[i].msize?"FLOAT":"INTEGER", /*class */
d[i].size+abs (d[i].padding), /*size */
d[i].perm[0]?"BE":"LE", /*byte order */
8*d[i].size); /*precision */
@ -350,7 +350,7 @@ H5T_init (void)\n\
/* Atomize the type */
printf ("\
if ((H5T_NATIVE_%s = H5Aregister_atom (H5_DATATYPE, dt))<0) {\n\
if ((H5T_NATIVE_%s_g = H5Aregister_atom (H5_DATATYPE, dt))<0) {\n\
HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,\n\
\"can't initialize type system (atom registration \"\n\
\"failure\");\n\
@ -829,7 +829,7 @@ true exponent. The radix point is assumed\n\
to be before the first `M' bit. Any bit\n\
of a floating-point value not falling into one\n\
of these categories is printed as a question\n\
mark. Bits of fixed-point types are printed as\n\
mark. Bits of integer types are printed as\n\
`I' for 2's complement and `U' for magnitude.\n\
\n\
If the most significant bit of the normalized\n\

View File

@ -11,6 +11,8 @@
#include <stdio.h>
#include <unistd.h>
#include <H5Tprivate.h>
#ifndef HAVE_FUNCTION
#define __FUNCTION__ ""
@ -18,6 +20,10 @@
#define AT() printf (" at %s:%d in %s()...\n", \
__FILE__, __LINE__, __FUNCTION__);
typedef struct complex_t {
double re;
double im;
} complex_t;
/*-------------------------------------------------------------------------
@ -43,7 +49,7 @@ test_classes (void)
printf ("%-70s", "Testing H5Tget_class()");
if (H5T_FIXED!=(type_class=H5Tget_class (H5T_NATIVE_INT))) {
if (H5T_INTEGER!=(type_class=H5Tget_class (H5T_NATIVE_INT))) {
puts ("*FAILED*");
if (!isatty (1)) {
AT ();
@ -129,6 +135,82 @@ test_copy (void)
return FAIL;
}
/*-------------------------------------------------------------------------
* Function: test_compound
*
* Purpose: Tests various things about compound data types.
*
* Return: Success: SUCCEED
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
test_compound (void)
{
complex_t tmp;
hid_t complex_id;
herr_t status;
printf ("%-70s", "Testing compound data types");
/* Create the empty type */
complex_id = H5Tcreate (H5T_COMPOUND, sizeof tmp);
if (complex_id<0) {
puts ("*FAILED*");
if (!isatty (1)) {
AT ();
printf (" Cannot create empty compound data type.\n");
}
goto error;
}
/* Add a coupld fields */
status = H5Tinsert (complex_id, "real", HOFFSET (tmp, re),
H5T_NATIVE_DOUBLE);
if (status<0) {
puts ("*FAILED*");
if (!isatty (1)) {
AT ();
printf (" Cannot insert real component.\n");
}
goto error;
}
status = H5Tinsert (complex_id, "imaginary", HOFFSET (tmp, im),
H5T_NATIVE_DOUBLE);
if (status<0) {
puts ("*FAILED*");
if (!isatty (1)) {
AT ();
printf (" Cannot insert imaginary component.\n");
}
goto error;
}
puts (" PASSED");
/* Just for debugging... */
H5T_debug (H5Aatom_object (complex_id), stdout);
printf ("\n");
return SUCCEED;
error:
return FAIL;
}
/*-------------------------------------------------------------------------
* Function: main
@ -159,6 +241,9 @@ main (void)
status = test_copy ();
nerrors += status<0 ? 1 : 0;
status = test_compound ();
nerrors += status<0 ? 1 : 0;
if (nerrors) {