mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-04-12 17:31:09 +08:00
[svn-r11676] Purpose: New feature
Description: Adding the new function H5LTtext_to_dtype() for converting text description to data type. The next step will be H5LTdtype_to_text(). Solution: Use Lex and Yacc to do parsing of the text. H5LTanalyze.l is the lexer for analyzing the input; H5LTparse.y is the parser. They are not part of HL library, but are used to generate lex.yy.c (from H5LTanalyze.l) as well as y.tab.c and y.tab.h (from H5LTparse.y). The tools used to create these source files are GNU FLEX and YACC on a Linux machine (fuss). The commands are "lex H5LTanalyze.l" and "yacc -d H5LTparse.y". Detailed document will be added later. Platforms tested: h5committest and fuss. Misc. update: MANIFEST
This commit is contained in:
parent
7fd6ff2413
commit
47b0c3b356
@ -1978,9 +1978,42 @@ out:
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5LTtext_to_dtype
|
||||
*
|
||||
* Purpose: Convert DDL description to HDF5 data type.
|
||||
*
|
||||
* Return: Success: 0, Failure: -1
|
||||
*
|
||||
* Programmer: Raymond Lu, slu@ncsa.uiuc.edu
|
||||
*
|
||||
* Date: October 6, 2004
|
||||
*
|
||||
* Comments:
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
hid_t H5LTtext_to_dtype(const char *text)
|
||||
{
|
||||
|
||||
hid_t type_id;
|
||||
hsize_t i;
|
||||
|
||||
input_len = strlen(text);
|
||||
myinput = strdup(text);
|
||||
|
||||
type_id = yyparse();
|
||||
|
||||
free(myinput);
|
||||
input_len = 0;
|
||||
|
||||
return type_id;
|
||||
|
||||
out:
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5LTrepack
|
||||
|
@ -27,7 +27,8 @@
|
||||
#endif
|
||||
|
||||
#define TESTING(WHAT) {printf("%-70s", "Testing " WHAT); fflush(stdout);}
|
||||
#define TESTING2(WHAT) {printf("%-70s", "Testing " WHAT); fflush(stdout);}
|
||||
#define TESTING2(WHAT) {printf("%-70s", "Testing " WHAT); fflush(stdout);}
|
||||
#define TESTING3(WHAT) {printf("%-70s", "" WHAT); fflush(stdout);}
|
||||
#define PASSED() {puts(" PASSED");fflush(stdout);}
|
||||
#define H5_FAILED() {puts("*FAILED*");fflush(stdout);}
|
||||
#define SKIPPED() {puts(" -SKIP-");fflush(stdout);}
|
||||
@ -38,7 +39,10 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* For Lex and Yacc */
|
||||
int input_len;
|
||||
char *myinput;
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* Make dataset functions
|
||||
@ -344,6 +348,7 @@ H5_HLDLL herr_t H5LTget_attribute_info( hid_t loc_id,
|
||||
H5_HLDLL hid_t H5LTcreate_compound_type( hsize_t nfields, size_t size, const char *field_names[],
|
||||
const size_t *field_offset, const hid_t *field_types );
|
||||
|
||||
hid_t H5LTtext_to_dtype(const char *text);
|
||||
|
||||
H5_HLDLL herr_t H5LTrepack( hsize_t nfields,
|
||||
hsize_t nrecords,
|
||||
|
161
hl/src/H5LTanalyze.l
Normal file
161
hl/src/H5LTanalyze.l
Normal file
@ -0,0 +1,161 @@
|
||||
%{
|
||||
#include <string.h>
|
||||
#include<hdf5.h>
|
||||
#include "y.tab.h"
|
||||
#undef YY_INPUT
|
||||
#define YY_INPUT(b, r, ms) (r=my_yyinput(b, ms))
|
||||
#define token(x) (int)x
|
||||
extern char *myinput;
|
||||
extern int input_len;
|
||||
|
||||
#define STACK_SIZE 16
|
||||
|
||||
/*variables for compound type*/
|
||||
extern struct cmpd_info {
|
||||
hid_t id;
|
||||
hbool_t is_field;
|
||||
hbool_t first_memb;
|
||||
};
|
||||
extern struct cmpd_info cmpd_stack[STACK_SIZE];
|
||||
extern int csindex;
|
||||
|
||||
/*variables for array type*/
|
||||
extern struct arr_info {
|
||||
hsize_t dims[H5S_MAX_RANK];
|
||||
int ndim;
|
||||
hbool_t is_dim;
|
||||
};
|
||||
extern struct arr_info arr_stack[STACK_SIZE];
|
||||
extern int asindex;
|
||||
|
||||
/*variables for enumerate type*/
|
||||
extern hbool_t is_enum;
|
||||
extern hbool_t is_enum_memb;
|
||||
|
||||
/*variables for string type*/
|
||||
extern hbool_t is_str_size;
|
||||
extern hbool_t is_str_pad;
|
||||
|
||||
/*variables for opaque type*/
|
||||
extern hbool_t is_opq_size;
|
||||
extern hbool_t is_opq_tag;
|
||||
|
||||
hbool_t first_quote = 1;
|
||||
|
||||
%}
|
||||
|
||||
%s TAG_STRING
|
||||
|
||||
%%
|
||||
|
||||
H5T_STD_I8BE {return token(H5T_STD_I8BE_TOKEN);}
|
||||
H5T_STD_I8LE {return token(H5T_STD_I8LE_TOKEN);}
|
||||
H5T_STD_I16BE {return token(H5T_STD_I16BE_TOKEN);}
|
||||
H5T_STD_I16LE {return token(H5T_STD_I16LE_TOKEN);}
|
||||
H5T_STD_I32BE {return token(H5T_STD_I32BE_TOKEN);}
|
||||
H5T_STD_I32LE {return token(H5T_STD_I32LE_TOKEN);}
|
||||
H5T_STD_I64BE {return token(H5T_STD_I64BE_TOKEN);}
|
||||
H5T_STD_I64LE {return token(H5T_STD_I64LE_TOKEN);}
|
||||
|
||||
H5T_STD_U8BE {return token(H5T_STD_U8BE_TOKEN);}
|
||||
H5T_STD_U8LE {return token(H5T_STD_U8LE_TOKEN);}
|
||||
H5T_STD_U16BE {return token(H5T_STD_U16BE_TOKEN);}
|
||||
H5T_STD_U16LE {return token(H5T_STD_U16LE_TOKEN);}
|
||||
H5T_STD_U32BE {return token(H5T_STD_U32BE_TOKEN);}
|
||||
H5T_STD_U32LE {return token(H5T_STD_U32LE_TOKEN);}
|
||||
H5T_STD_U64BE {return token(H5T_STD_U64BE_TOKEN);}
|
||||
H5T_STD_U64LE {return token(H5T_STD_U64LE_TOKEN);}
|
||||
|
||||
H5T_NATIVE_CHAR {return token(H5T_NATIVE_CHAR_TOKEN);}
|
||||
H5T_NATIVE_SCHAR {return token(H5T_NATIVE_SCHAR_TOKEN);}
|
||||
H5T_NATIVE_UCHAR {return token(H5T_NATIVE_UCHAR_TOKEN);}
|
||||
H5T_NATIVE_SHORT {return token(H5T_NATIVE_SHORT_TOKEN);}
|
||||
H5T_NATIVE_USHORT {return token(H5T_NATIVE_USHORT_TOKEN);}
|
||||
H5T_NATIVE_INT {return token(H5T_NATIVE_INT_TOKEN);}
|
||||
H5T_NATIVE_UINT {return token(H5T_NATIVE_UINT_TOKEN);}
|
||||
H5T_NATIVE_LONG {return token(H5T_NATIVE_LONG_TOKEN);}
|
||||
H5T_NATIVE_ULONG {return token(H5T_NATIVE_ULONG_TOKEN);}
|
||||
H5T_NATIVE_LLONG {return token(H5T_NATIVE_LLONG_TOKEN);}
|
||||
H5T_NATIVE_ULLONG {return token(H5T_NATIVE_ULLONG_TOKEN);}
|
||||
|
||||
H5T_IEEE_F32BE {return token(H5T_IEEE_F32BE_TOKEN);}
|
||||
H5T_IEEE_F32LE {return token(H5T_IEEE_F32LE_TOKEN);}
|
||||
H5T_IEEE_F64BE {return token(H5T_IEEE_F64BE_TOKEN);}
|
||||
H5T_IEEE_F64LE {return token(H5T_IEEE_F64LE_TOKEN);}
|
||||
H5T_NATIVE_FLOAT {return token(H5T_NATIVE_FLOAT_TOKEN);}
|
||||
H5T_NATIVE_DOUBLE {return token(H5T_NATIVE_DOUBLE_TOKEN);}
|
||||
H5T_NATIVE_LDOUBLE {return token(H5T_NATIVE_LDOUBLE_TOKEN);}
|
||||
|
||||
H5T_STRING {return token(H5T_STRING_TOKEN);}
|
||||
STRSIZE {return token(STRSIZE_TOKEN);}
|
||||
STRPAD {return token(STRPAD_TOKEN);}
|
||||
CSET {return token(CSET_TOKEN);}
|
||||
CTYPE {return token(CTYPE_TOKEN);}
|
||||
H5T_STR_NULLTERM {return token(H5T_STR_NULLTERM_TOKEN);}
|
||||
H5T_STR_NULLPAD {return token(H5T_STR_NULLPAD_TOKEN);}
|
||||
H5T_STR_SPACEPAD {return token(H5T_STR_SPACEPAD_TOKEN);}
|
||||
H5T_CSET_ASCII {return token(H5T_CSET_ASCII_TOKEN);}
|
||||
H5T_C_S1 {return token(H5T_C_S1_TOKEN);}
|
||||
H5T_FORTRAN_S1 {return token(H5T_FORTRAN_S1_TOKEN);}
|
||||
H5T_VARIABLE {return token(H5T_VARIABLE_TOKEN);}
|
||||
|
||||
H5T_COMPOUND {return token(H5T_COMPOUND_TOKEN);}
|
||||
H5T_ENUM {return token(H5T_ENUM_TOKEN);}
|
||||
H5T_ARRAY {return token(H5T_ARRAY_TOKEN);}
|
||||
H5T_VLEN {return token(H5T_VLEN_TOKEN);}
|
||||
|
||||
H5T_OPAQUE {return token(H5T_OPAQUE_TOKEN);}
|
||||
OPQ_SIZE {return token(OPQ_SIZE_TOKEN);}
|
||||
OPQ_TAG {return token(OPQ_TAG_TOKEN);}
|
||||
|
||||
[0-9]+ {
|
||||
if(is_str_size || (is_enum && is_enum_memb) ||
|
||||
is_opq_size || (asindex>-1 && arr_stack[asindex].is_dim)) {
|
||||
yylval.ival = atoi(yytext);
|
||||
return NUMBER;
|
||||
} else
|
||||
REJECT;
|
||||
}
|
||||
|
||||
"\"" {
|
||||
/*if it's first quote, and is a opaque tag or an enum symbol*/
|
||||
if((is_opq_tag || is_enum || (csindex>-1 && cmpd_stack[csindex].is_field)) && first_quote) {
|
||||
first_quote = 0;
|
||||
BEGIN TAG_STRING;
|
||||
} else /*if it's second quote*/
|
||||
first_quote = 1;
|
||||
return token('"');
|
||||
}
|
||||
<TAG_STRING>[^\"]+ {
|
||||
yylval.sval = strdup(yytext);
|
||||
BEGIN INITIAL;
|
||||
return STRING;
|
||||
}
|
||||
|
||||
"{" {return token('{');}
|
||||
"}" {return token('}');}
|
||||
"[" {return token('[');}
|
||||
"]" {return token(']');}
|
||||
";" {return token(';');}
|
||||
[ \t\n]* ;
|
||||
"\n" { return 0; }
|
||||
|
||||
%%
|
||||
int my_yyinput(char *buf, int max_size)
|
||||
{
|
||||
int ret;
|
||||
|
||||
memcpy(buf, myinput, input_len);
|
||||
ret = input_len;
|
||||
return ret;
|
||||
}
|
||||
|
||||
yyerror(msg)
|
||||
{
|
||||
printf("ERROR: %s before \"%s\".\n", msg, yytext);
|
||||
}
|
||||
|
||||
yywrap()
|
||||
{
|
||||
return(1);
|
||||
}
|
288
hl/src/H5LTparse.y
Normal file
288
hl/src/H5LTparse.y
Normal file
@ -0,0 +1,288 @@
|
||||
%{
|
||||
#include<stdio.h>
|
||||
#include<string.h>
|
||||
#include<hdf5.h>
|
||||
|
||||
#define STACK_SIZE 16
|
||||
|
||||
/*structure for compound type information*/
|
||||
struct cmpd_info {
|
||||
hid_t id; /*type ID*/
|
||||
hbool_t is_field; /*flag to lexer for compound member*/
|
||||
hbool_t first_memb; /*flag for first compound member*/
|
||||
};
|
||||
/*stack for nested compound type*/
|
||||
struct cmpd_info cmpd_stack[STACK_SIZE] = { 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1,
|
||||
0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1,
|
||||
0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1,
|
||||
0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1 };
|
||||
int csindex = -1; /*pointer to the top of compound stack*/
|
||||
|
||||
/*structure for array type information*/
|
||||
struct arr_info {
|
||||
hsize_t dims[H5S_MAX_RANK]; /*size of each dimension, limited to 32 dimensions*/
|
||||
int ndims; /*number of dimensions*/
|
||||
hbool_t is_dim; /*flag to lexer for dimension*/
|
||||
};
|
||||
/*stack for nested array type*/
|
||||
struct arr_info arr_stack[STACK_SIZE];
|
||||
int asindex = -1; /*pointer to the top of array stack*/
|
||||
|
||||
hbool_t is_str_size = 0; /*flag to lexer for string size*/
|
||||
hbool_t is_str_pad = 0; /*flag to lexer for string padding*/
|
||||
|
||||
hid_t enum_id; /*type ID*/
|
||||
hbool_t is_enum = 0; /*flag to lexer for enum type*/
|
||||
hbool_t is_enum_memb = 0; /*flag to lexer for enum member*/
|
||||
char* enum_memb_symbol; /*enum member symbol string*/
|
||||
|
||||
hbool_t is_opq_size = 0; /*flag to lexer for opaque type size*/
|
||||
hbool_t is_opq_tag = 0; /*flag to lexer for opaque type tag*/
|
||||
|
||||
%}
|
||||
%union {
|
||||
int ival; /*for integer token*/
|
||||
char *sval; /*for compound member name*/
|
||||
}
|
||||
|
||||
%token <ival> H5T_STD_I8BE_TOKEN H5T_STD_I8LE_TOKEN H5T_STD_I16BE_TOKEN H5T_STD_I16LE_TOKEN
|
||||
%token <ival> H5T_STD_I32BE_TOKEN H5T_STD_I32LE_TOKEN H5T_STD_I64BE_TOKEN H5T_STD_I64LE_TOKEN
|
||||
%token <ival> H5T_STD_U8BE_TOKEN H5T_STD_U8LE_TOKEN H5T_STD_U16BE_TOKEN H5T_STD_U16LE_TOKEN
|
||||
%token <ival> H5T_STD_U32BE_TOKEN H5T_STD_U32LE_TOKEN H5T_STD_U64BE_TOKEN H5T_STD_U64LE_TOKEN
|
||||
%token <ival> H5T_NATIVE_CHAR_TOKEN H5T_NATIVE_SCHAR_TOKEN H5T_NATIVE_UCHAR_TOKEN
|
||||
%token <ival> H5T_NATIVE_SHORT_TOKEN H5T_NATIVE_USHORT_TOKEN H5T_NATIVE_INT_TOKEN H5T_NATIVE_UINT_TOKEN
|
||||
%token <ival> H5T_NATIVE_LONG_TOKEN H5T_NATIVE_ULONG_TOKEN H5T_NATIVE_LLONG_TOKEN H5T_NATIVE_ULLONG_TOKEN
|
||||
|
||||
%token <ival> H5T_IEEE_F32BE_TOKEN H5T_IEEE_F32LE_TOKEN H5T_IEEE_F64BE_TOKEN H5T_IEEE_F64LE_TOKEN
|
||||
%token <ival> H5T_NATIVE_FLOAT_TOKEN H5T_NATIVE_DOUBLE_TOKEN H5T_NATIVE_LDOUBLE_TOKEN
|
||||
|
||||
%token <ival> H5T_STRING_TOKEN STRSIZE_TOKEN STRPAD_TOKEN CSET_TOKEN CTYPE_TOKEN H5T_VARIABLE_TOKEN
|
||||
%token <ival> H5T_STR_NULLTERM_TOKEN H5T_STR_NULLPAD_TOKEN H5T_STR_SPACEPAD_TOKEN
|
||||
%token <ival> H5T_CSET_ASCII_TOKEN H5T_C_S1_TOKEN H5T_FORTRAN_S1_TOKEN
|
||||
|
||||
%token <ival> H5T_OPAQUE_TOKEN OPQ_SIZE_TOKEN OPQ_TAG_TOKEN
|
||||
|
||||
%token <ival> H5T_COMPOUND_TOKEN
|
||||
%token <ival> H5T_ENUM_TOKEN
|
||||
%token <ival> H5T_ARRAY_TOKEN
|
||||
%token <ival> H5T_VLEN_TOKEN
|
||||
|
||||
%token <sval> STRING
|
||||
%token <ival> NUMBER
|
||||
%token <ival> '{' '}' '[' ']' '"' ';'
|
||||
|
||||
%%
|
||||
start : { memset(arr_stack, 0, STACK_SIZE*sizeof(struct arr_info)); /*initialize here?*/ }
|
||||
| ddl_type { return $<ival>$;}
|
||||
;
|
||||
ddl_type : atomic_type
|
||||
| compound_type
|
||||
| array_type
|
||||
| vlen_type
|
||||
;
|
||||
atomic_type : integer_type
|
||||
| fp_type
|
||||
| string_type
|
||||
| enum_type
|
||||
| opaque_type
|
||||
;
|
||||
|
||||
integer_type : H5T_STD_I8BE_TOKEN { $<ival>$ = H5Tcopy(H5T_STD_I8BE); }
|
||||
| H5T_STD_I8LE_TOKEN { $<ival>$ = H5Tcopy(H5T_STD_I8LE); }
|
||||
| H5T_STD_I16BE_TOKEN { $<ival>$ = H5Tcopy(H5T_STD_I16BE); }
|
||||
| H5T_STD_I16LE_TOKEN { $<ival>$ = H5Tcopy(H5T_STD_I16LE); }
|
||||
| H5T_STD_I32BE_TOKEN { $<ival>$ = H5Tcopy(H5T_STD_I32BE); }
|
||||
| H5T_STD_I32LE_TOKEN { $<ival>$ = H5Tcopy(H5T_STD_I32LE); }
|
||||
| H5T_STD_I64BE_TOKEN { $<ival>$ = H5Tcopy(H5T_STD_I64BE); }
|
||||
| H5T_STD_I64LE_TOKEN { $<ival>$ = H5Tcopy(H5T_STD_I64LE); }
|
||||
| H5T_STD_U8BE_TOKEN { $<ival>$ = H5Tcopy(H5T_STD_U8BE); }
|
||||
| H5T_STD_U8LE_TOKEN { $<ival>$ = H5Tcopy(H5T_STD_U8LE); }
|
||||
| H5T_STD_U16BE_TOKEN { $<ival>$ = H5Tcopy(H5T_STD_U16BE); }
|
||||
| H5T_STD_U16LE_TOKEN { $<ival>$ = H5Tcopy(H5T_STD_U16LE); }
|
||||
| H5T_STD_U32BE_TOKEN { $<ival>$ = H5Tcopy(H5T_STD_U32BE); }
|
||||
| H5T_STD_U32LE_TOKEN { $<ival>$ = H5Tcopy(H5T_STD_U32LE); }
|
||||
| H5T_STD_U64BE_TOKEN { $<ival>$ = H5Tcopy(H5T_STD_U64BE); }
|
||||
| H5T_STD_U64LE_TOKEN { $<ival>$ = H5Tcopy(H5T_STD_U64LE); }
|
||||
| H5T_NATIVE_CHAR_TOKEN { $<ival>$ = H5Tcopy(H5T_NATIVE_CHAR); }
|
||||
| H5T_NATIVE_SCHAR_TOKEN { $<ival>$ = H5Tcopy(H5T_NATIVE_SCHAR); }
|
||||
| H5T_NATIVE_UCHAR_TOKEN { $<ival>$ = H5Tcopy(H5T_NATIVE_UCHAR); }
|
||||
| H5T_NATIVE_SHORT_TOKEN { $<ival>$ = H5Tcopy(H5T_NATIVE_SHORT); }
|
||||
| H5T_NATIVE_USHORT_TOKEN { $<ival>$ = H5Tcopy(H5T_NATIVE_USHORT); }
|
||||
| H5T_NATIVE_INT_TOKEN { $<ival>$ = H5Tcopy(H5T_NATIVE_INT); }
|
||||
| H5T_NATIVE_UINT_TOKEN { $<ival>$ = H5Tcopy(H5T_NATIVE_UINT); }
|
||||
| H5T_NATIVE_LONG_TOKEN { $<ival>$ = H5Tcopy(H5T_NATIVE_LONG); }
|
||||
| H5T_NATIVE_ULONG_TOKEN { $<ival>$ = H5Tcopy(H5T_NATIVE_ULONG); }
|
||||
| H5T_NATIVE_LLONG_TOKEN { $<ival>$ = H5Tcopy(H5T_NATIVE_LLONG); }
|
||||
| H5T_NATIVE_ULLONG_TOKEN { $<ival>$ = H5Tcopy(H5T_NATIVE_ULLONG); }
|
||||
;
|
||||
|
||||
fp_type : H5T_IEEE_F32BE_TOKEN { $<ival>$ = H5Tcopy(H5T_IEEE_F32BE); }
|
||||
| H5T_IEEE_F32LE_TOKEN { $<ival>$ = H5Tcopy(H5T_IEEE_F32LE); }
|
||||
| H5T_IEEE_F64BE_TOKEN { $<ival>$ = H5Tcopy(H5T_IEEE_F64BE); }
|
||||
| H5T_IEEE_F64LE_TOKEN { $<ival>$ = H5Tcopy(H5T_IEEE_F64LE); }
|
||||
| H5T_NATIVE_FLOAT_TOKEN { $<ival>$ = H5Tcopy(H5T_NATIVE_FLOAT); }
|
||||
| H5T_NATIVE_DOUBLE_TOKEN { $<ival>$ = H5Tcopy(H5T_NATIVE_DOUBLE); }
|
||||
| H5T_NATIVE_LDOUBLE_TOKEN { $<ival>$ = H5Tcopy(H5T_NATIVE_LDOUBLE); }
|
||||
;
|
||||
|
||||
compound_type : H5T_COMPOUND_TOKEN
|
||||
{ csindex++; cmpd_stack[csindex].id = H5Tcreate(H5T_COMPOUND, 1); /*temporarily set size to 1*/ }
|
||||
'{' memb_list '}'
|
||||
{ $<ival>$ = cmpd_stack[csindex].id;
|
||||
cmpd_stack[csindex].id = 0;
|
||||
cmpd_stack[csindex].first_memb = 1;
|
||||
csindex--;
|
||||
}
|
||||
;
|
||||
memb_list :
|
||||
| memb_list memb_def
|
||||
;
|
||||
memb_def : ddl_type { cmpd_stack[csindex].is_field = 1; /*notify lexer a compound member is parsed*/ }
|
||||
'"' field_name '"' ';'
|
||||
{ int origin_size, new_size;
|
||||
hid_t dtype_id = cmpd_stack[csindex].id;
|
||||
|
||||
/*Adjust size and insert member. Leave no space between.*/
|
||||
if(cmpd_stack[csindex].first_memb) { /*reclaim the size 1 temporarily set*/
|
||||
new_size = H5Tget_size($<ival>1);
|
||||
H5Tset_size(dtype_id, new_size);
|
||||
/*member name is saved in yylval.sval by lexer*/
|
||||
H5Tinsert(dtype_id, yylval.sval, 0, $<ival>1);
|
||||
|
||||
cmpd_stack[csindex].first_memb = 0;
|
||||
} else {
|
||||
origin_size = H5Tget_size(dtype_id);
|
||||
new_size = origin_size + H5Tget_size($<ival>1);
|
||||
H5Tset_size(dtype_id, new_size);
|
||||
H5Tinsert(dtype_id, yylval.sval, origin_size, $<ival>1);
|
||||
}
|
||||
|
||||
cmpd_stack[csindex].is_field = 0;
|
||||
H5Tclose($<ival>1);
|
||||
|
||||
new_size = H5Tget_size(dtype_id);
|
||||
}
|
||||
;
|
||||
field_name : STRING
|
||||
;
|
||||
|
||||
array_type : H5T_ARRAY_TOKEN { asindex++; /*pushd onto the stack*/ }
|
||||
'{' dim_list ddl_type '}'
|
||||
{
|
||||
$<ival>$ = H5Tarray_create($<ival>5, arr_stack[asindex].ndims, arr_stack[asindex].dims, NULL);
|
||||
arr_stack[asindex].ndims = 0;
|
||||
asindex--;
|
||||
H5Tclose($<ival>5);
|
||||
}
|
||||
;
|
||||
dim_list :
|
||||
| dim_list dim
|
||||
;
|
||||
dim : '[' { arr_stack[asindex].is_dim = 1; /*notice lexer of dimension size*/ }
|
||||
dimsize { int ndims = arr_stack[asindex].ndims;
|
||||
arr_stack[asindex].dims[ndims] = (hsize_t)yylval.ival;
|
||||
arr_stack[asindex].ndims++;
|
||||
arr_stack[asindex].is_dim = 0;
|
||||
}
|
||||
']'
|
||||
;
|
||||
dimsize : NUMBER
|
||||
;
|
||||
|
||||
vlen_type : H5T_VLEN_TOKEN '{' ddl_type '}'
|
||||
{ $<ival>$ = H5Tvlen_create($<ival>3); H5Tclose($<ival>3); }
|
||||
;
|
||||
|
||||
opaque_type : H5T_OPAQUE_TOKEN
|
||||
'{'
|
||||
OPQ_SIZE_TOKEN { is_opq_size = 1; } opaque_size ';'
|
||||
{
|
||||
size_t size = (size_t)yylval.ival;
|
||||
$<ival>$ = H5Tcreate(H5T_OPAQUE, size);
|
||||
is_opq_size = 0;
|
||||
}
|
||||
OPQ_TAG_TOKEN { is_opq_tag = 1; } '"' opaque_tag '"' ';'
|
||||
{
|
||||
H5Tset_tag($<ival>7, yylval.sval);
|
||||
is_opq_tag = 0;
|
||||
}
|
||||
'}' { $<ival>$ = $<ival>7; }
|
||||
;
|
||||
opaque_size : NUMBER
|
||||
;
|
||||
opaque_tag : STRING
|
||||
;
|
||||
|
||||
string_type : H5T_STRING_TOKEN
|
||||
'{'
|
||||
CTYPE_TOKEN ctype ';'
|
||||
{
|
||||
if($<ival>4 == H5T_C_S1_TOKEN)
|
||||
$<ival>$ = H5Tcopy(H5T_C_S1);
|
||||
else if($<ival>4 == H5T_FORTRAN_S1_TOKEN)
|
||||
$<ival>$ = H5Tcopy(H5T_FORTRAN_S1);
|
||||
}
|
||||
STRSIZE_TOKEN { is_str_size = 1; } strsize ';'
|
||||
{
|
||||
if($<ival>9 == H5T_VARIABLE_TOKEN)
|
||||
H5Tset_size($<ival>6, H5T_VARIABLE);
|
||||
else
|
||||
H5Tset_size($<ival>6, yylval.ival);
|
||||
is_str_size = 0;
|
||||
}
|
||||
STRPAD_TOKEN strpad ';'
|
||||
{
|
||||
if($<ival>13 == H5T_STR_NULLTERM_TOKEN)
|
||||
H5Tset_strpad($<ival>6, H5T_STR_NULLTERM);
|
||||
else if($<ival>13 == H5T_STR_NULLPAD_TOKEN)
|
||||
H5Tset_strpad($<ival>6, H5T_STR_NULLPAD);
|
||||
else if($<ival>13 == H5T_STR_SPACEPAD_TOKEN)
|
||||
H5Tset_strpad($<ival>6, H5T_STR_SPACEPAD);
|
||||
}
|
||||
CSET_TOKEN cset ';'
|
||||
{
|
||||
if($<ival>17 == H5T_CSET_ASCII_TOKEN)
|
||||
H5Tset_cset($<ival>6, H5T_CSET_ASCII);
|
||||
}
|
||||
'}' { $<ival>$ = $<ival>6; }
|
||||
|
||||
;
|
||||
strsize : H5T_VARIABLE_TOKEN {$<ival>$ = H5T_VARIABLE_TOKEN;}
|
||||
| NUMBER
|
||||
;
|
||||
strpad : H5T_STR_NULLTERM_TOKEN {$<ival>$ = H5T_STR_NULLTERM_TOKEN;}
|
||||
| H5T_STR_NULLPAD_TOKEN {$<ival>$ = H5T_STR_NULLPAD_TOKEN;}
|
||||
| H5T_STR_SPACEPAD_TOKEN {$<ival>$ = H5T_STR_SPACEPAD_TOKEN;}
|
||||
;
|
||||
cset : H5T_CSET_ASCII_TOKEN {$<ival>$ = H5T_CSET_ASCII_TOKEN;}
|
||||
;
|
||||
ctype : H5T_C_S1_TOKEN {$<ival>$ = H5T_C_S1_TOKEN;}
|
||||
| H5T_FORTRAN_S1_TOKEN {$<ival>$ = H5T_FORTRAN_S1_TOKEN;}
|
||||
;
|
||||
|
||||
enum_type : H5T_ENUM_TOKEN '{' integer_type ';'
|
||||
{ is_enum = 1; enum_id = H5Tenum_create($<ival>3); H5Tclose($<ival>3); }
|
||||
enum_list '}'
|
||||
{ is_enum = 0; /*reset*/ $<ival>$ = enum_id; }
|
||||
;
|
||||
enum_list :
|
||||
| enum_list enum_def
|
||||
;
|
||||
enum_def : '"' enum_symbol '"' {
|
||||
is_enum_memb = 1; /*indicate member of enum*/
|
||||
enum_memb_symbol = strdup(yylval.sval);
|
||||
}
|
||||
enum_val ';'
|
||||
{
|
||||
int memb_val;
|
||||
if(is_enum && is_enum_memb) { /*if it's an enum member*/
|
||||
H5Tenum_insert(enum_id, enum_memb_symbol, (memb_val=yylval.ival,&memb_val));
|
||||
is_enum_memb = 0;
|
||||
if(enum_memb_symbol) free(enum_memb_symbol);
|
||||
}
|
||||
}
|
||||
;
|
||||
enum_symbol : STRING
|
||||
;
|
||||
enum_val : NUMBER
|
||||
;
|
@ -25,9 +25,9 @@ AM_CPPFLAGS=-I$(top_srcdir)/src
|
||||
# This library is our main target.
|
||||
lib_LTLIBRARIES=libhdf5_hl.la
|
||||
|
||||
libhdf5_hl_la_SOURCES=H5LT.c H5TB.c H5IM.c H5DS.c H5PT.c H5HL_private.c
|
||||
libhdf5_hl_la_SOURCES=H5LT.c H5TB.c H5IM.c H5DS.c H5PT.c H5HL_private.c y.tab.c lex.yy.c
|
||||
|
||||
# Public header files (to be installed)
|
||||
include_HEADERS=H5IM.h H5LT.h H5TB.h H5DS.h H5PT.h
|
||||
include_HEADERS=H5IM.h H5LT.h H5TB.h H5DS.h H5PT.h y.tab.h
|
||||
|
||||
include $(top_srcdir)/config/conclude.am
|
||||
|
@ -77,7 +77,7 @@ libLTLIBRARIES_INSTALL = $(INSTALL)
|
||||
LTLIBRARIES = $(lib_LTLIBRARIES)
|
||||
libhdf5_hl_la_LIBADD =
|
||||
am_libhdf5_hl_la_OBJECTS = H5LT.lo H5TB.lo H5IM.lo H5DS.lo H5PT.lo \
|
||||
H5HL_private.lo
|
||||
H5HL_private.lo y.tab.lo lex.yy.lo
|
||||
libhdf5_hl_la_OBJECTS = $(am_libhdf5_hl_la_OBJECTS)
|
||||
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/src
|
||||
depcomp = $(SHELL) $(top_srcdir)/bin/depcomp
|
||||
@ -336,10 +336,10 @@ AM_CPPFLAGS = -I$(top_srcdir)/src
|
||||
|
||||
# This library is our main target.
|
||||
lib_LTLIBRARIES = libhdf5_hl.la
|
||||
libhdf5_hl_la_SOURCES = H5LT.c H5TB.c H5IM.c H5DS.c H5PT.c H5HL_private.c
|
||||
libhdf5_hl_la_SOURCES = H5LT.c H5TB.c H5IM.c H5DS.c H5PT.c H5HL_private.c y.tab.c lex.yy.c
|
||||
|
||||
# Public header files (to be installed)
|
||||
include_HEADERS = H5IM.h H5LT.h H5TB.h H5DS.h H5PT.h
|
||||
include_HEADERS = H5IM.h H5LT.h H5TB.h H5DS.h H5PT.h y.tab.h
|
||||
|
||||
# Automake needs to be taught how to build lib, progs, and tests targets.
|
||||
# These will be filled in automatically for the most part (e.g.,
|
||||
@ -432,6 +432,8 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5LT.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5PT.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5TB.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lex.yy.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/y.tab.Plo@am__quote@
|
||||
|
||||
.c.o:
|
||||
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
|
||||
|
2253
hl/src/lex.yy.c
Normal file
2253
hl/src/lex.yy.c
Normal file
File diff suppressed because it is too large
Load Diff
1008
hl/src/y.tab.c
Normal file
1008
hl/src/y.tab.c
Normal file
File diff suppressed because it is too large
Load Diff
64
hl/src/y.tab.h
Normal file
64
hl/src/y.tab.h
Normal file
@ -0,0 +1,64 @@
|
||||
#ifndef YYERRCODE
|
||||
#define YYERRCODE 256
|
||||
#endif
|
||||
|
||||
#define H5T_STD_I8BE_TOKEN 257
|
||||
#define H5T_STD_I8LE_TOKEN 258
|
||||
#define H5T_STD_I16BE_TOKEN 259
|
||||
#define H5T_STD_I16LE_TOKEN 260
|
||||
#define H5T_STD_I32BE_TOKEN 261
|
||||
#define H5T_STD_I32LE_TOKEN 262
|
||||
#define H5T_STD_I64BE_TOKEN 263
|
||||
#define H5T_STD_I64LE_TOKEN 264
|
||||
#define H5T_STD_U8BE_TOKEN 265
|
||||
#define H5T_STD_U8LE_TOKEN 266
|
||||
#define H5T_STD_U16BE_TOKEN 267
|
||||
#define H5T_STD_U16LE_TOKEN 268
|
||||
#define H5T_STD_U32BE_TOKEN 269
|
||||
#define H5T_STD_U32LE_TOKEN 270
|
||||
#define H5T_STD_U64BE_TOKEN 271
|
||||
#define H5T_STD_U64LE_TOKEN 272
|
||||
#define H5T_NATIVE_CHAR_TOKEN 273
|
||||
#define H5T_NATIVE_SCHAR_TOKEN 274
|
||||
#define H5T_NATIVE_UCHAR_TOKEN 275
|
||||
#define H5T_NATIVE_SHORT_TOKEN 276
|
||||
#define H5T_NATIVE_USHORT_TOKEN 277
|
||||
#define H5T_NATIVE_INT_TOKEN 278
|
||||
#define H5T_NATIVE_UINT_TOKEN 279
|
||||
#define H5T_NATIVE_LONG_TOKEN 280
|
||||
#define H5T_NATIVE_ULONG_TOKEN 281
|
||||
#define H5T_NATIVE_LLONG_TOKEN 282
|
||||
#define H5T_NATIVE_ULLONG_TOKEN 283
|
||||
#define H5T_IEEE_F32BE_TOKEN 284
|
||||
#define H5T_IEEE_F32LE_TOKEN 285
|
||||
#define H5T_IEEE_F64BE_TOKEN 286
|
||||
#define H5T_IEEE_F64LE_TOKEN 287
|
||||
#define H5T_NATIVE_FLOAT_TOKEN 288
|
||||
#define H5T_NATIVE_DOUBLE_TOKEN 289
|
||||
#define H5T_NATIVE_LDOUBLE_TOKEN 290
|
||||
#define H5T_STRING_TOKEN 291
|
||||
#define STRSIZE_TOKEN 292
|
||||
#define STRPAD_TOKEN 293
|
||||
#define CSET_TOKEN 294
|
||||
#define CTYPE_TOKEN 295
|
||||
#define H5T_VARIABLE_TOKEN 296
|
||||
#define H5T_STR_NULLTERM_TOKEN 297
|
||||
#define H5T_STR_NULLPAD_TOKEN 298
|
||||
#define H5T_STR_SPACEPAD_TOKEN 299
|
||||
#define H5T_CSET_ASCII_TOKEN 300
|
||||
#define H5T_C_S1_TOKEN 301
|
||||
#define H5T_FORTRAN_S1_TOKEN 302
|
||||
#define H5T_OPAQUE_TOKEN 303
|
||||
#define OPQ_SIZE_TOKEN 304
|
||||
#define OPQ_TAG_TOKEN 305
|
||||
#define H5T_COMPOUND_TOKEN 306
|
||||
#define H5T_ENUM_TOKEN 307
|
||||
#define H5T_ARRAY_TOKEN 308
|
||||
#define H5T_VLEN_TOKEN 309
|
||||
#define STRING 310
|
||||
#define NUMBER 311
|
||||
typedef union {
|
||||
int ival; /*for integer token*/
|
||||
char *sval; /*for compound member name*/
|
||||
} YYSTYPE;
|
||||
extern YYSTYPE yylval;
|
@ -1043,6 +1043,409 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name )
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* test H5LTtext_to_dtype function
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static int test_text_dtype(void)
|
||||
{
|
||||
TESTING("H5LTtext_to_dtype");
|
||||
|
||||
if(test_integers()<0)
|
||||
goto out;
|
||||
|
||||
if(test_fps()<0)
|
||||
goto out;
|
||||
|
||||
if(test_strings()<0)
|
||||
goto out;
|
||||
|
||||
if(test_opaques()<0)
|
||||
goto out;
|
||||
|
||||
if(test_enums()<0)
|
||||
goto out;
|
||||
|
||||
if(test_variables()<0)
|
||||
goto out;
|
||||
|
||||
if(test_arrays()<0)
|
||||
goto out;
|
||||
|
||||
if(test_compounds()<0)
|
||||
goto out;
|
||||
|
||||
return 0;
|
||||
|
||||
out:
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* subroutine for test_text_dtype(): test_integers().
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static int test_integers(void)
|
||||
{
|
||||
hid_t dtype;
|
||||
|
||||
TESTING3("\n text for integer types");
|
||||
|
||||
if((dtype = H5LTtext_to_dtype("H5T_NATIVE_INT\n"))<0)
|
||||
goto out;
|
||||
if(!H5Tequal(dtype, H5T_NATIVE_INT))
|
||||
goto out;
|
||||
if(H5Tclose(dtype)<0)
|
||||
goto out;
|
||||
|
||||
if((dtype = H5LTtext_to_dtype("H5T_STD_I8BE\n"))<0)
|
||||
goto out;
|
||||
if(!H5Tequal(dtype, H5T_STD_I8BE))
|
||||
goto out;
|
||||
if(H5Tclose(dtype)<0)
|
||||
goto out;
|
||||
|
||||
if((dtype = H5LTtext_to_dtype("H5T_STD_U16LE\n"))<0)
|
||||
goto out;
|
||||
if(!H5Tequal(dtype, H5T_STD_U16LE))
|
||||
goto out;
|
||||
if(H5Tclose(dtype)<0)
|
||||
goto out;
|
||||
|
||||
PASSED();
|
||||
return 0;
|
||||
|
||||
out:
|
||||
H5_FAILED();
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* subroutine for test_text_dtype(): test_fps().
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static int test_fps(void)
|
||||
{
|
||||
hid_t dtype;
|
||||
|
||||
TESTING3(" text for floating-point types");
|
||||
|
||||
if((dtype = H5LTtext_to_dtype("H5T_NATIVE_LDOUBLE\n"))<0)
|
||||
goto out;
|
||||
if(!H5Tequal(dtype, H5T_NATIVE_LDOUBLE))
|
||||
goto out;
|
||||
if(H5Tclose(dtype)<0)
|
||||
goto out;
|
||||
|
||||
if((dtype = H5LTtext_to_dtype("H5T_IEEE_F32BE\n"))<0)
|
||||
goto out;
|
||||
if(!H5Tequal(dtype, H5T_IEEE_F32BE))
|
||||
goto out;
|
||||
if(H5Tclose(dtype)<0)
|
||||
goto out;
|
||||
|
||||
if((dtype = H5LTtext_to_dtype("H5T_IEEE_F64LE\n"))<0)
|
||||
goto out;
|
||||
if(!H5Tequal(dtype, H5T_IEEE_F64LE))
|
||||
goto out;
|
||||
if(H5Tclose(dtype)<0)
|
||||
goto out;
|
||||
|
||||
PASSED();
|
||||
return 0;
|
||||
|
||||
out:
|
||||
H5_FAILED();
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* subroutine for test_text_dtype(): test_strings().
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static int test_strings(void)
|
||||
{
|
||||
hid_t dtype;
|
||||
size_t str_size;
|
||||
H5T_str_t str_pad;
|
||||
H5T_cset_t str_cset;
|
||||
H5T_class_t type_class;
|
||||
|
||||
TESTING3(" text for string types");
|
||||
|
||||
if((dtype = H5LTtext_to_dtype("H5T_STRING { CTYPE H5T_C_S1; STRSIZE 13; STRPAD H5T_STR_NULLTERM; CSET H5T_CSET_ASCII; }"))<0)
|
||||
goto out;
|
||||
|
||||
if((type_class = H5Tget_class(dtype))<0)
|
||||
goto out;
|
||||
if(type_class != H5T_STRING)
|
||||
goto out;
|
||||
|
||||
str_size = H5Tget_size(dtype);
|
||||
if(str_size != 13)
|
||||
goto out;
|
||||
|
||||
str_pad = H5Tget_strpad(dtype);
|
||||
if(str_pad != H5T_STR_NULLTERM)
|
||||
goto out;
|
||||
|
||||
str_cset = H5Tget_cset(dtype);
|
||||
if(str_cset != H5T_CSET_ASCII)
|
||||
goto out;
|
||||
|
||||
if(H5Tclose(dtype)<0)
|
||||
goto out;
|
||||
|
||||
if((dtype = H5LTtext_to_dtype("H5T_STRING { CTYPE H5T_FORTRAN_S1; STRSIZE H5T_VARIABLE; STRPAD H5T_STR_NULLPAD; CSET H5T_CSET_ASCII; }"))<0)
|
||||
goto out;
|
||||
|
||||
if(!H5Tis_variable_str(dtype))
|
||||
goto out;
|
||||
|
||||
str_pad = H5Tget_strpad(dtype);
|
||||
if(str_pad != H5T_STR_NULLPAD)
|
||||
goto out;
|
||||
|
||||
str_cset = H5Tget_cset(dtype);
|
||||
if(str_cset != H5T_CSET_ASCII)
|
||||
goto out;
|
||||
|
||||
if(H5Tclose(dtype)<0)
|
||||
goto out;
|
||||
|
||||
PASSED();
|
||||
return 0;
|
||||
|
||||
out:
|
||||
H5_FAILED();
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* subroutine for test_text_dtype(): test_opaques().
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static int test_opaques(void)
|
||||
{
|
||||
hid_t dtype;
|
||||
size_t opq_size;
|
||||
char *opq_tag = NULL;
|
||||
H5T_class_t type_class;
|
||||
|
||||
TESTING3(" text for opaque types");
|
||||
|
||||
if((dtype = H5LTtext_to_dtype("H5T_OPAQUE { OPQ_SIZE 19; OPQ_TAG \"This is a tag for opaque type\"; }\n"))<0)
|
||||
goto out;
|
||||
|
||||
if((type_class = H5Tget_class(dtype))<0)
|
||||
goto out;
|
||||
if(type_class != H5T_OPAQUE)
|
||||
goto out;
|
||||
|
||||
if((opq_size = H5Tget_size(dtype)) == 0)
|
||||
goto out;
|
||||
if(opq_size != 19)
|
||||
goto out;
|
||||
|
||||
if((opq_tag = H5Tget_tag(dtype)) == NULL)
|
||||
goto out;
|
||||
if(strcmp(opq_tag, "This is a tag for opaque type"))
|
||||
goto out;
|
||||
free(opq_tag);
|
||||
|
||||
if(H5Tclose(dtype)<0)
|
||||
goto out;
|
||||
|
||||
PASSED();
|
||||
return 0;
|
||||
|
||||
out:
|
||||
H5_FAILED();
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* subroutine for test_text_dtype(): test_enums().
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static int test_enums(void)
|
||||
{
|
||||
hid_t dtype;
|
||||
size_t size = 16;
|
||||
char name1[16];
|
||||
int value1 = 7;
|
||||
char *name2 = "WHITE";
|
||||
int value2;
|
||||
H5T_class_t type_class;
|
||||
|
||||
TESTING3(" text for enum types");
|
||||
|
||||
if((dtype = H5LTtext_to_dtype("H5T_ENUM { H5T_STD_I32LE; \"RED\" 5; \"GREEN\" 6; \"BLUE\" 7; \"WHITE\" 8; }"))<0)
|
||||
goto out;
|
||||
|
||||
if((type_class = H5Tget_class(dtype))<0)
|
||||
goto out;
|
||||
if(type_class != H5T_ENUM)
|
||||
goto out;
|
||||
|
||||
if(H5Tenum_nameof(dtype, &value1, name1, size)<0)
|
||||
goto out;
|
||||
if(strcmp(name1, "BLUE"))
|
||||
goto out;
|
||||
|
||||
if(H5Tenum_valueof(dtype, name2, &value2)<0)
|
||||
goto out;
|
||||
if(value2 != 8)
|
||||
goto out;
|
||||
|
||||
if(H5Tclose(dtype)<0)
|
||||
goto out;
|
||||
|
||||
PASSED();
|
||||
return 0;
|
||||
|
||||
out:
|
||||
H5_FAILED();
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* subroutine for test_text_dtype(): test_variables().
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static int test_variables(void)
|
||||
{
|
||||
hid_t dtype;
|
||||
H5T_class_t type_class;
|
||||
|
||||
TESTING3(" text for variable types");
|
||||
|
||||
if((dtype = H5LTtext_to_dtype("H5T_VLEN { H5T_NATIVE_CHAR }\n"))<0)
|
||||
goto out;
|
||||
|
||||
if((type_class = H5Tget_class(dtype))<0)
|
||||
goto out;
|
||||
if(type_class != H5T_VLEN)
|
||||
goto out;
|
||||
|
||||
if(H5Tis_variable_str(dtype))
|
||||
goto out;
|
||||
|
||||
if(H5Tclose(dtype)<0)
|
||||
goto out;
|
||||
|
||||
if((dtype = H5LTtext_to_dtype("H5T_VLEN { H5T_VLEN { H5T_STD_I32BE } }\n"))<0)
|
||||
goto out;
|
||||
|
||||
if(H5Tis_variable_str(dtype))
|
||||
goto out;
|
||||
|
||||
if(H5Tclose(dtype)<0)
|
||||
goto out;
|
||||
|
||||
PASSED();
|
||||
return 0;
|
||||
|
||||
out:
|
||||
H5_FAILED();
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* subroutine for test_text_dtype(): test_arrays().
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static int test_arrays(void)
|
||||
{
|
||||
hid_t dtype;
|
||||
int ndims;
|
||||
hsize_t dims[3];
|
||||
H5T_class_t type_class;
|
||||
|
||||
TESTING3(" text for array types");
|
||||
|
||||
if((dtype = H5LTtext_to_dtype("H5T_ARRAY { [5][7][13] H5T_ARRAY { [17][19] H5T_COMPOUND { H5T_STD_I8BE \"arr_compound_1\"; H5T_STD_I32BE \"arr_compound_2\"; } } }"))<0)
|
||||
goto out;
|
||||
|
||||
if((type_class = H5Tget_class(dtype))<0)
|
||||
goto out;
|
||||
if(type_class != H5T_ARRAY)
|
||||
goto out;
|
||||
|
||||
if((ndims = H5Tget_array_ndims(dtype))<0)
|
||||
goto out;
|
||||
if(ndims != 3)
|
||||
goto out;
|
||||
|
||||
if(H5Tget_array_dims(dtype, dims, NULL)<0)
|
||||
goto out;
|
||||
if(dims[0] != 5 || dims[1] != 7 || dims[2] != 13)
|
||||
goto out;
|
||||
|
||||
if(H5Tclose(dtype)<0)
|
||||
goto out;
|
||||
|
||||
|
||||
PASSED();
|
||||
return 0;
|
||||
|
||||
out:
|
||||
H5_FAILED();
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* subroutine for test_text_dtype(): test_compounds().
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static int test_compounds(void)
|
||||
{
|
||||
hid_t dtype;
|
||||
int nmembs;
|
||||
char *memb_name = NULL;
|
||||
H5T_class_t memb_class;
|
||||
H5T_class_t type_class;
|
||||
|
||||
TESTING3(" text for compound types");
|
||||
|
||||
if((dtype = H5LTtext_to_dtype("H5T_COMPOUND { H5T_STD_I16BE \"one_field\"; H5T_STD_U8LE \"two_field\"; }"))<0)
|
||||
goto out;
|
||||
|
||||
if((type_class = H5Tget_class(dtype))<0)
|
||||
goto out;
|
||||
if(type_class != H5T_COMPOUND)
|
||||
goto out;
|
||||
|
||||
if((nmembs = H5Tget_nmembers(dtype))<0)
|
||||
goto out;
|
||||
if(nmembs != 2)
|
||||
goto out;
|
||||
|
||||
if(H5Tclose(dtype)<0)
|
||||
goto out;
|
||||
|
||||
if((dtype = H5LTtext_to_dtype("H5T_COMPOUND { H5T_STD_I32BE \"i32_field\"; H5T_STD_I16BE \"i16_field\"; H5T_COMPOUND { H5T_STD_I16BE \"sec_field\"; H5T_COMPOUND { H5T_STD_I32BE \"thd_field\"; } \"grandchild\"; } \"child_compound\"; H5T_STD_I8BE \"i8_field\"; }"))<0)
|
||||
goto out;
|
||||
|
||||
if((memb_name = H5Tget_member_name(dtype, 1)) == NULL)
|
||||
goto out;
|
||||
if(strcmp(memb_name, "i16_field"))
|
||||
goto out;
|
||||
free(memb_name);
|
||||
|
||||
if((memb_class = H5Tget_member_class(dtype, 2))<0)
|
||||
goto out;
|
||||
if(memb_class != H5T_COMPOUND)
|
||||
goto out;
|
||||
|
||||
PASSED();
|
||||
return 0;
|
||||
|
||||
out:
|
||||
H5_FAILED();
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* the main program
|
||||
*-------------------------------------------------------------------------
|
||||
@ -1057,6 +1460,9 @@ int main( void )
|
||||
|
||||
/* test attribute functions */
|
||||
nerrors += test_attr();
|
||||
|
||||
/* test text-dtype functions */
|
||||
nerrors += test_text_dtype();
|
||||
|
||||
/* check for errors */
|
||||
if (nerrors)
|
||||
|
Loading…
x
Reference in New Issue
Block a user