[svn-r165] Changes since 19980122

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

./src/H5.c
./src/H5B.c
./src/H5Bprivate.h
	Changed `new' to something else in 6 places for Fabio.

./src/H5T.c
./src/H5Tconv.c
	Beginning to work on compound data type conversion. Don't look
	yet :-)
This commit is contained in:
Robb Matzke 1998-01-22 14:57:48 -05:00
parent a0ee2c57e9
commit dec0c95436
5 changed files with 117 additions and 25 deletions

View File

@ -121,17 +121,17 @@ herr_t
H5_add_exit(void (*func) (void))
{
herr_t ret_value = SUCCEED;
H5_exit_t *new;
H5_exit_t *new_exit;
FUNC_ENTER_INIT(H5_add_exit, NULL, FAIL);
assert(func);
new = H5MM_xcalloc(1, sizeof(H5_exit_t));
new_exit = H5MM_xcalloc(1, sizeof(H5_exit_t));
new->func = func;
new->next = lib_exit_head;
lib_exit_head = new;
new_exit->func = func;
new_exit->next = lib_exit_head;
lib_exit_head = new_exit;
FUNC_LEAVE(ret_value);
} /* end H5_add_exit() */

View File

@ -1033,7 +1033,7 @@ H5B_insert_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
assert(type);
assert(type->decode);
assert(type->cmp3);
assert(type->new);
assert(type->new_node);
assert(lt_key);
assert(lt_key_changed);
assert(rt_key);
@ -1076,8 +1076,8 @@ H5B_insert_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
assert(0 == bt->level);
bt->key[0].nkey = bt->native;
bt->key[1].nkey = bt->native + type->sizeof_nkey;
if ((type->new) (f, H5B_INS_FIRST, bt->key[0].nkey, udata,
bt->key[1].nkey, bt->child + 0 /*out */ ) < 0) {
if ((type->new_node) (f, H5B_INS_FIRST, bt->key[0].nkey, udata,
bt->key[1].nkey, bt->child + 0/*out*/) < 0) {
bt->key[0].nkey = bt->key[1].nkey = NULL;
HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, H5B_INS_ERROR,
"unable to create leaf node");
@ -1152,8 +1152,8 @@ H5B_insert_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
}
my_ins = H5B_INS_LEFT;
HDmemcpy(md_key, bt->key[idx].nkey, type->sizeof_nkey);
if ((type->new) (f, H5B_INS_LEFT, bt->key[idx].nkey, udata, md_key,
&child_addr /*out */ ) < 0) {
if ((type->new_node) (f, H5B_INS_LEFT, bt->key[idx].nkey, udata,
md_key, &child_addr/*out*/) < 0) {
HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
"can't insert minimum leaf node");
}
@ -1209,8 +1209,8 @@ H5B_insert_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
}
my_ins = H5B_INS_RIGHT;
HDmemcpy(md_key, bt->key[idx + 1].nkey, type->sizeof_nkey);
if ((type->new) (f, H5B_INS_RIGHT, md_key, udata,
bt->key[idx + 1].nkey, &child_addr /*out */ ) < 0) {
if ((type->new_node) (f, H5B_INS_RIGHT, md_key, udata,
bt->key[idx + 1].nkey, &child_addr/*out*/) < 0) {
HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
"can't insert maximum leaf node");
}

View File

@ -68,7 +68,7 @@ typedef struct H5B_class_t {
H5B_subid_t id; /*id as found in file*/
size_t sizeof_nkey; /*size of native (memory) key*/
size_t (*get_sizeof_rkey) (H5F_t *, const void *); /*raw key size */
herr_t (*new) (H5F_t *, H5B_ins_t, void *, void *, void *, haddr_t *);
herr_t (*new_node) (H5F_t*, H5B_ins_t, void*, void*, void*, haddr_t*);
intn (*cmp2) (H5F_t *, void *, void *, void *); /*compare 2 keys */
intn (*cmp3) (H5F_t *, void *, void *, void *); /*compare 3 keys */
herr_t (*found) (H5F_t *, const haddr_t *, const void *, void *,

View File

@ -174,6 +174,7 @@ H5T_init_interface(void)
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
"can't initialize H5T layer");
}
/* STRING */
dt = H5MM_xcalloc(1, sizeof(H5T_t));
dt->locked = TRUE;
@ -190,6 +191,7 @@ H5T_init_interface(void)
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
"can't initialize H5T layer");
}
/* BITFIELD */
dt = H5MM_xcalloc(1, sizeof(H5T_t));
dt->locked = TRUE;
@ -204,6 +206,7 @@ H5T_init_interface(void)
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to initialize H5T layer");
}
/* OPAQUE */
dt = H5MM_xcalloc(1, sizeof(H5T_t));
dt->locked = TRUE;
@ -218,6 +221,7 @@ H5T_init_interface(void)
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to initialize H5T layer");
}
/*
* Define aliases.
*/
@ -231,7 +235,6 @@ H5T_init_interface(void)
* Register conversion functions beginning with the most general and
* ending with the most specific.
*/
if (H5Tregister_soft(H5T_INTEGER, H5T_INTEGER, H5T_conv_order) < 0) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to register conversion function");
@ -240,6 +243,12 @@ H5T_init_interface(void)
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to register conversion function");
}
if (H5Tregister_soft (H5T_COMPOUND, H5T_COMPOUND, H5T_conv_struct)<0) {
HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to register conversion function");
}
FUNC_LEAVE(ret_value);
}
@ -2629,12 +2638,12 @@ H5T_sort_by_offset(H5T_t *dt)
/* Use a bubble sort because we can short circuit */
nmembs = dt->u.compnd.nmembs;
for (i = nmembs - 1, swapped = TRUE; i > 0 && swapped; --i) {
for (j = 0, swapped = FALSE; j < i; j++) {
if (dt->u.compnd.memb[j].offset > dt->u.compnd.memb[j + 1].offset) {
H5T_member_t tmp = dt->u.compnd.memb[j];
dt->u.compnd.memb[j] = dt->u.compnd.memb[j + 1];
dt->u.compnd.memb[j + 1] = tmp;
for (i=nmembs-1, swapped=TRUE; i>0 && swapped; --i) {
for (j=0, swapped=FALSE; j<i; j++) {
if (dt->u.compnd.memb[j].offset > dt->u.compnd.memb[j+1].offset) {
H5T_member_t tmp = dt->u.compnd.memb[j];
dt->u.compnd.memb[j] = dt->u.compnd.memb[j+1];
dt->u.compnd.memb[j+1] = tmp;
swapped = 1;
}
}

View File

@ -11,12 +11,13 @@
#include <H5Aprivate.h>
#include <H5Eprivate.h>
#include <H5MMprivate.h>
#include <H5Tpkg.h>
/* Interface initialization */
static intn interface_initialize_g = FALSE;
static intn interface_initialize_g = FALSE;
#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
* Function: H5T_conv_noop
*
@ -41,7 +42,7 @@ H5T_conv_noop(hid_t src_id, hid_t dst_id, size_t nelmts,
FUNC_ENTER(H5T_conv_noop, FAIL);
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5T_conv_order
*
@ -84,6 +85,7 @@ H5T_conv_order(hid_t src_id, hid_t dst_id, size_t nelmts,
HRETURN_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL,
"background values not supported in this conv path");
}
if (!buf) {
/* Capability query */
if (src->size != dst->size ||
@ -138,7 +140,19 @@ H5T_conv_order(hid_t src_id, hid_t dst_id, size_t nelmts,
* Function: H5T_conv_struct
*
* Purpose: Converts between compound data types. This is a soft
* conversion function.
* conversion function. The algorithm is basically:
*
* For I=1..NUM_MEMBERS do
* If sizeof detination type <= sizeof source type then
* Convert member to destination type;
* Move member as far left as possible;
*
* For I=NUM_MEMBERS..1 do
* If not destination type then
* Convert member to destination type;
* Move member to correct position in BACKGROUND
*
* Copy BACKGROUND to BUF
*
* Return: Success: SUCCEED
*
@ -155,10 +169,79 @@ herr_t
H5T_conv_struct(hid_t src_id, hid_t dst_id, size_t nelmts,
void *_buf, const void *background)
{
uint8 *buf = (uint8 *)_buf; /*cast for pointer arithmetic */
H5T_t *src = NULL; /*source data type */
H5T_t *dst = NULL; /*destination data type */
intn *dst2src_map = NULL; /*maps dst member to src member */
intn i;
FUNC_ENTER (H5T_conv_struct, FAIL);
HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "not implemented yet");
/* Check args */
if (H5_DATATYPE != H5A_group(src_id) ||
NULL == (src = H5A_object(src_id)) ||
H5_DATATYPE != H5A_group(dst_id) ||
NULL == (dst = H5A_object(dst_id))) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
}
if (background) {
HRETURN_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL,
"background values not supported in this conv path");
}
/* Capability query? */
if (!buf) {
assert (H5T_COMPOUND==src->type);
assert (H5T_COMPOUND==dst->type);
HRETURN (SUCCEED);
}
/*
* Build a mapping from destination member number to source member number
*/
H5T_sort_by_offset (src);
H5T_sort_by_offset (dst);
dst2src_map = H5MM_xmalloc (dst->u.compnd.nmembs * sizeof(intn));
for (i=0; i<src->u.compnd.nmembs; i++) {
}
/*
* For each source member which will be present in the destination,
* convert the member to the destination type unless it is larger than
* the source type. Then move the member to the left-most unoccupied
* position in the buffer. This makes the data point as small as
* possible with all the free space on the right side.
*/
for (i=0; i<src->u.compnd.nmembs; i++) {
}
/*
* For each source member which will be present in the destination,
* convert the member to the destination type if it is larger than the
* source type (that is, has not been converted yet). Then copy the
* member to the destination offset in the background buffer.
*/
for (i=src->u.compnd.nmembs-1; i>=0; --i) {
}
/*
* Copy the background buffer back into the in-place conversion buffer.
*/
HDmemcpy (buf, background, dst->size);
HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "not implemented yet");
FUNC_LEAVE (SUCCEED);
}