diff options
Diffstat (limited to 'hl/src/H5LTparse.y')
-rw-r--r-- | hl/src/H5LTparse.y | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/hl/src/H5LTparse.y b/hl/src/H5LTparse.y index 50e8f6d..c67f0e5 100644 --- a/hl/src/H5LTparse.y +++ b/hl/src/H5LTparse.y @@ -332,12 +332,33 @@ enum_def : '"' enum_symbol '"' { } enum_val ';' { - int memb_val; + char char_val=(char)yylval.ival; + short short_val=(short)yylval.ival; + int int_val=(int)yylval.ival; + long long_val=(long)yylval.ival; + long long llong_val=(long long)yylval.ival; + hid_t super = H5Tget_super(enum_id); + hid_t native = H5Tget_native_type(super, H5T_DIR_ASCEND); + 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)); + /*To handle machines of different endianness*/ + if(H5Tequal(native, H5T_NATIVE_SCHAR) || H5Tequal(native, H5T_NATIVE_UCHAR)) + H5Tenum_insert(enum_id, enum_memb_symbol, &char_val); + else if(H5Tequal(native, H5T_NATIVE_SHORT) || H5Tequal(native, H5T_NATIVE_USHORT)) + H5Tenum_insert(enum_id, enum_memb_symbol, &short_val); + else if(H5Tequal(native, H5T_NATIVE_INT) || H5Tequal(native, H5T_NATIVE_UINT)) + H5Tenum_insert(enum_id, enum_memb_symbol, &int_val); + else if(H5Tequal(native, H5T_NATIVE_LONG) || H5Tequal(native, H5T_NATIVE_ULONG)) + H5Tenum_insert(enum_id, enum_memb_symbol, &long_val); + else if(H5Tequal(native, H5T_NATIVE_LLONG) || H5Tequal(native, H5T_NATIVE_ULLONG)) + H5Tenum_insert(enum_id, enum_memb_symbol, &llong_val); + is_enum_memb = 0; if(enum_memb_symbol) free(enum_memb_symbol); } + + H5Tclose(super); + H5Tclose(native); } ; enum_symbol : STRING |