diff options
Diffstat (limited to 'src/H5Tconv.c')
-rw-r--r-- | src/H5Tconv.c | 93 |
1 files changed, 88 insertions, 5 deletions
diff --git a/src/H5Tconv.c b/src/H5Tconv.c index d5ad0bb..ff612ba 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -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); } |