summaryrefslogtreecommitdiffstats
path: root/java/src/jni/h5util.c
diff options
context:
space:
mode:
authorAllen Byrne <50328838+byrnHDF@users.noreply.github.com>2022-10-26 04:33:30 (GMT)
committerGitHub <noreply@github.com>2022-10-26 04:33:30 (GMT)
commit9c61f7b1e1cfb65cd562febfbb7ad49e8785825c (patch)
tree2bf6453021345ae6013d6181e6028f2ff41dd7cb /java/src/jni/h5util.c
parentad2d77397ac564836f5fd89e66d5647250daf10e (diff)
downloadhdf5-9c61f7b1e1cfb65cd562febfbb7ad49e8785825c.zip
hdf5-9c61f7b1e1cfb65cd562febfbb7ad49e8785825c.tar.gz
hdf5-9c61f7b1e1cfb65cd562febfbb7ad49e8785825c.tar.bz2
JNI: Improve varlen datatype handling in H5A/H5D read/write functions (#2156)
* Improve JNI VL datatype read/write to handle complex combinations * Implement VL of VL JNI writes and reads * Add Java VLofVL test for attributtes * Changes to address review issues * Fix H5Aread vl blocks
Diffstat (limited to 'java/src/jni/h5util.c')
-rw-r--r--java/src/jni/h5util.c545
1 files changed, 545 insertions, 0 deletions
diff --git a/java/src/jni/h5util.c b/java/src/jni/h5util.c
index 37d0194..265213e 100644
--- a/java/src/jni/h5util.c
+++ b/java/src/jni/h5util.c
@@ -4043,6 +4043,551 @@ done:
H5Aclose(attr_id);
} /* end Java_hdf_hdf5lib_H5_H5export_1attribute */
+herr_t
+translate_rbuf(JNIEnv *env, jobjectArray ret_buf, jlong mem_type_id, H5T_class_t type_class, jsize count,
+ jbyte *raw_buf)
+{
+ herr_t status = FAIL;
+ hid_t memb = H5I_INVALID_HID;
+ H5T_class_t vlClass;
+ size_t vlSize;
+ jobjectArray jList = NULL;
+ size_t i, j, x;
+
+ /* retrieve the java.util.ArrayList interface class */
+ jclass arrCList = ENVPTR->FindClass(ENVONLY, "java/util/ArrayList");
+ jmethodID arrListMethod = ENVPTR->GetMethodID(ENVONLY, arrCList, "<init>", "(I)V");
+ jmethodID arrAddMethod = ENVPTR->GetMethodID(ENVONLY, arrCList, "add", "(Ljava/lang/Object;)Z");
+
+ /* Cache class types */
+ /* jclass cBool = ENVPTR->FindClass(ENVONLY, "java/lang/Boolean"); */
+ jclass cByte = ENVPTR->FindClass(ENVONLY, "java/lang/Byte");
+ jclass cShort = ENVPTR->FindClass(ENVONLY, "java/lang/Short");
+ jclass cInt = ENVPTR->FindClass(ENVONLY, "java/lang/Integer");
+ jclass cLong = ENVPTR->FindClass(ENVONLY, "java/lang/Long");
+ jclass cFloat = ENVPTR->FindClass(ENVONLY, "java/lang/Float");
+ jclass cDouble = ENVPTR->FindClass(ENVONLY, "java/lang/Double");
+ /*jobjectArray
+ jmethodID boolValueMid =
+ ENVPTR->GetStaticMethodID(ENVONLY, cBool, "valueOf", "(Z)Ljava/lang/Boolean;");
+ */
+ jmethodID byteValueMid = ENVPTR->GetStaticMethodID(ENVONLY, cByte, "valueOf", "(B)Ljava/lang/Byte;");
+ jmethodID shortValueMid = ENVPTR->GetStaticMethodID(ENVONLY, cShort, "valueOf", "(S)Ljava/lang/Short;");
+ jmethodID intValueMid = ENVPTR->GetStaticMethodID(ENVONLY, cInt, "valueOf", "(I)Ljava/lang/Integer;");
+ jmethodID longValueMid = ENVPTR->GetStaticMethodID(ENVONLY, cLong, "valueOf", "(J)Ljava/lang/Long;");
+ jmethodID floatValueMid = ENVPTR->GetStaticMethodID(ENVONLY, cFloat, "valueOf", "(F)Ljava/lang/Float;");
+ jmethodID doubleValueMid =
+ ENVPTR->GetStaticMethodID(ENVONLY, cDouble, "valueOf", "(D)Ljava/lang/Double;");
+
+ if (type_class == H5T_VLEN) {
+ if (!(memb = H5Tget_super(mem_type_id)))
+ H5_LIBRARY_ERROR(ENVONLY);
+ if ((vlClass = H5Tget_class(memb)) < 0)
+ H5_LIBRARY_ERROR(ENVONLY);
+ if (!(vlSize = H5Tget_size(memb)))
+ H5_LIBRARY_ERROR(ENVONLY);
+
+ /* Convert each element to a list */
+ for (i = 0; i < (size_t)count; i++) {
+ hvl_t vl_elem;
+ jboolean found_jList = JNI_TRUE;
+
+ /* Get the number of sequence elements */
+ HDmemcpy(&vl_elem, (char *)raw_buf + i * sizeof(hvl_t), sizeof(hvl_t));
+ jsize nelmts = (jsize)vl_elem.len;
+ if (vl_elem.len != (size_t)nelmts)
+ H5_JNI_FATAL_ERROR(ENVONLY, "translate_rbuf: overflow of number of VL elements");
+
+ if (nelmts < 0)
+ H5_BAD_ARGUMENT_ERROR(ENVONLY, "translate_rbuf: number of VL elements < 0");
+
+ /* The list we're going to return: */
+ if (NULL == (jList = ENVPTR->GetObjectArrayElement(ENVONLY, (jobjectArray)ret_buf, (jsize)i))) {
+ found_jList = JNI_FALSE;
+ if (NULL == (jList = (jobjectArray)ENVPTR->NewObject(ENVONLY, arrCList, arrListMethod, 0)))
+ H5_OUT_OF_MEMORY_ERROR(ENVONLY, "translate_rbuf: failed to allocate list read buffer");
+ }
+
+ if ((vlClass == H5T_ARRAY) || (vlClass == H5T_COMPOUND) || (vlClass == H5T_VLEN))
+ translate_rbuf(ENVONLY, jList, memb, vlClass, (jsize)nelmts, vl_elem.p);
+ else {
+ jobject jobj = NULL;
+ for (j = 0; j < (size_t)nelmts; j++) {
+ switch (vlClass) {
+ /*case H5T_BOOL: {
+ jboolean boolValue;
+ for (x = 0; x < vlSize; x++) {
+ ((char *)&boolValue)[x] = ((char *)vl_elem.p)[j*vlSize+x];
+ }
+
+ jobj = ENVPTR->CallStaticObjectMethod(ENVONLY, cBool, boolValueMid, boolValue);
+ CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
+ break;
+ } */
+ case H5T_INTEGER: {
+ switch (vlSize) {
+ case sizeof(jbyte): {
+ jbyte byteValue;
+ for (x = 0; x < vlSize; x++) {
+ ((char *)&byteValue)[x] = ((char *)vl_elem.p)[j * vlSize + x];
+ }
+ jobj = ENVPTR->CallStaticObjectMethod(ENVONLY, cByte, byteValueMid,
+ byteValue);
+ CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
+ break;
+ }
+ case sizeof(jshort): {
+ jshort shortValue;
+ for (x = 0; x < vlSize; x++) {
+ ((char *)&shortValue)[x] = ((char *)vl_elem.p)[j * vlSize + x];
+ }
+ jobj = ENVPTR->CallStaticObjectMethod(ENVONLY, cShort, shortValueMid,
+ shortValue);
+ CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
+ break;
+ }
+ case sizeof(jint): {
+ jint intValue;
+ for (x = 0; x < vlSize; x++) {
+ ((char *)&intValue)[x] = ((char *)vl_elem.p)[j * vlSize + x];
+ }
+ jobj =
+ ENVPTR->CallStaticObjectMethod(ENVONLY, cInt, intValueMid, intValue);
+ CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE);
+ break;
+ }
+ case sizeof(jlong): {
+ jlong longValue;
+ for (x = 0; x < vlSize; x++) {
+ ((char *)&longValue)[x] = ((char *)vl_elem.p)[j * vlSize + x];
+ }
+ jobj = ENVPTR->CallStaticObjectMethod(ENVONLY, cLong, longValueMid,
+ longValue);
+ CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
+ break;
+ }
+ }
+ break;
+ }
+ case H5T_FLOAT: {
+ switch (vlSize) {
+ case sizeof(jfloat): {
+ jfloat floatValue;
+ for (x = 0; x < vlSize; x++) {
+ ((char *)&floatValue)[x] = ((char *)vl_elem.p)[j * vlSize + x];
+ }
+ jobj = ENVPTR->CallStaticObjectMethod(ENVONLY, cFloat, floatValueMid,
+ (double)floatValue);
+ CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
+ break;
+ }
+ case sizeof(jdouble): {
+ jdouble doubleValue;
+ for (x = 0; x < vlSize; x++) {
+ ((char *)&doubleValue)[x] = ((char *)vl_elem.p)[j * vlSize + x];
+ }
+ jobj = ENVPTR->CallStaticObjectMethod(ENVONLY, cDouble, doubleValueMid,
+ doubleValue);
+ CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
+ break;
+ }
+ }
+ break;
+ }
+ case H5T_REFERENCE: {
+ jboolean bb;
+ jbyte *barray = NULL;
+ jsize byteArraySize = (jsize)vlSize;
+
+ if (vlSize != (size_t)byteArraySize)
+ H5_JNI_FATAL_ERROR(ENVONLY, "translate_rbuf: overflow of byteArraySize");
+
+ if (NULL == (jobj = ENVPTR->NewByteArray(ENVONLY, byteArraySize)))
+ CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
+
+ PIN_BYTE_ARRAY(ENVONLY, (jbyteArray)jobj, barray, &bb,
+ "read(translate_buf) reference: byte array not pinned");
+ for (x = 0; x < vlSize; x++) {
+ barray[x] = ((jbyte *)vl_elem.p)[j * vlSize + x];
+ }
+ if (barray)
+ UNPIN_BYTE_ARRAY(ENVONLY, (jbyteArray)jobj, barray, jobj ? 0 : JNI_ABORT);
+
+ break;
+ }
+ default:
+ H5_UNIMPLEMENTED(ENVONLY, "translate_rbuf: invalid class type");
+ break;
+ }
+ /* Add it to the list */
+ if (jobj) {
+ ENVPTR->CallBooleanMethod(ENVONLY, jList, arrAddMethod, jobj);
+ CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE);
+
+ ENVPTR->DeleteLocalRef(ENVONLY, jobj);
+ }
+ }
+ if (!found_jList) {
+ ENVPTR->CallBooleanMethod(ENVONLY, ret_buf, arrAddMethod, jList);
+ CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE);
+ ENVPTR->DeleteLocalRef(ENVONLY, jList);
+ }
+ }
+ }
+ }
+ else if (type_class == H5T_COMPOUND) {
+ int nmembs = H5Tget_nmembers(mem_type_id);
+ void *objBuf = NULL;
+ size_t offset;
+
+ if (nmembs < 0)
+ goto done;
+
+ /* Convert each element to a list */
+ for (i = 0; i < (size_t)nmembs; i++) {
+ jboolean found_jList = JNI_TRUE;
+
+ if ((memb = H5Tget_member_type(mem_type_id, (unsigned int)i)) < 0)
+ H5_LIBRARY_ERROR(ENVONLY);
+ offset = H5Tget_member_offset(mem_type_id, (unsigned int)i);
+
+ if ((vlClass = H5Tget_class(memb)) < 0)
+ H5_LIBRARY_ERROR(ENVONLY);
+ if (!(vlSize = H5Tget_size(memb)))
+ H5_LIBRARY_ERROR(ENVONLY);
+
+ /* Get the object element */
+ HDmemcpy(&objBuf, (char *)raw_buf + offset, vlSize);
+
+ /* The list we're going to return: */
+ if (NULL == (jList = ENVPTR->GetObjectArrayElement(ENVONLY, (jobjectArray)ret_buf, (jsize)i))) {
+ found_jList = JNI_FALSE;
+ if (NULL == (jList = (jobjectArray)ENVPTR->NewObject(ENVONLY, arrCList, arrListMethod, 0)))
+ H5_OUT_OF_MEMORY_ERROR(ENVONLY, "translate_rbuf: failed to allocate list read buffer");
+ }
+
+ if ((vlClass == H5T_ARRAY) || (vlClass == H5T_COMPOUND) || (vlClass == H5T_VLEN))
+ translate_rbuf(ENVONLY, jList, memb, vlClass, (jsize)1, objBuf);
+ else {
+ jobject jobj = NULL;
+ switch (vlClass) {
+ /*case H5T_BOOL: {
+ jboolean boolValue;
+ for (x = 0; x < vlSize; x++) {
+ ((char *)&boolValue)[x] = ((char *)vl_elem.p)[j*vlSize+x];
+ }
+
+ jobj = ENVPTR->CallStaticObjectMethod(ENVONLY, cBool, boolValueMid, boolValue);
+ CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
+ break;
+ } */
+ case H5T_INTEGER: {
+ switch (vlSize) {
+ case sizeof(jbyte): {
+ jbyte byteValue;
+ for (x = 0; x < vlSize; x++) {
+ ((char *)&byteValue)[x] = ((char *)objBuf)[vlSize + x];
+ }
+
+ jobj =
+ ENVPTR->CallStaticObjectMethod(ENVONLY, cByte, byteValueMid, byteValue);
+ CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
+ break;
+ }
+ case sizeof(jshort): {
+ jshort shortValue;
+ for (x = 0; x < vlSize; x++) {
+ ((char *)&shortValue)[x] = ((char *)objBuf)[vlSize + x];
+ }
+
+ jobj = ENVPTR->CallStaticObjectMethod(ENVONLY, cShort, shortValueMid,
+ shortValue);
+ CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
+ break;
+ }
+ case sizeof(jint): {
+ jint intValue;
+ for (x = 0; x < vlSize; x++) {
+ ((char *)&intValue)[x] = ((char *)objBuf)[vlSize + x];
+ }
+
+ jobj = ENVPTR->CallStaticObjectMethod(ENVONLY, cInt, intValueMid, intValue);
+ CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
+ break;
+ }
+ case sizeof(jlong): {
+ jlong longValue;
+ for (x = 0; x < vlSize; x++) {
+ ((char *)&longValue)[x] = ((char *)objBuf)[vlSize + x];
+ }
+
+ jobj =
+ ENVPTR->CallStaticObjectMethod(ENVONLY, cLong, longValueMid, longValue);
+ CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
+ break;
+ }
+ }
+ break;
+ }
+ case H5T_FLOAT: {
+ switch (vlSize) {
+ case sizeof(jfloat): {
+ jfloat floatValue;
+ for (x = 0; x < vlSize; x++) {
+ ((char *)&floatValue)[x] = ((char *)objBuf)[vlSize + x];
+ }
+
+ jobj = ENVPTR->CallStaticObjectMethod(ENVONLY, cFloat, floatValueMid,
+ (double)floatValue);
+ CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
+ break;
+ }
+ case sizeof(jdouble): {
+ jdouble doubleValue;
+ for (x = 0; x < vlSize; x++) {
+ ((char *)&doubleValue)[x] = ((char *)objBuf)[vlSize + x];
+ }
+
+ jobj = ENVPTR->CallStaticObjectMethod(ENVONLY, cDouble, doubleValueMid,
+ doubleValue);
+ CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
+ break;
+ }
+ }
+ break;
+ }
+ case H5T_REFERENCE: {
+ jboolean bb;
+ jbyte *barray = NULL;
+
+ jsize byteArraySize = (jsize)vlSize;
+ if (vlSize != (size_t)byteArraySize)
+ H5_JNI_FATAL_ERROR(ENVONLY, "translate_rbuf: overflow of byteArraySize");
+
+ if (NULL == (jobj = ENVPTR->NewByteArray(ENVONLY, byteArraySize)))
+ CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
+
+ PIN_BYTE_ARRAY(ENVONLY, (jbyteArray)jobj, barray, &bb,
+ "translate_rbuf reference: byte array not pinned");
+
+ for (x = 0; x < vlSize; x++) {
+ barray[x] = ((jbyte *)objBuf)[vlSize + x];
+ }
+ if (barray)
+ UNPIN_BYTE_ARRAY(ENVONLY, (jbyteArray)jobj, barray, jobj ? 0 : JNI_ABORT);
+ break;
+ }
+ default:
+ H5_UNIMPLEMENTED(ENVONLY, "translate_rbuf: invalid class type");
+ break;
+ }
+ /* Add it to the list */
+ if (jobj) {
+ ENVPTR->CallBooleanMethod(ENVONLY, jList, arrAddMethod, jobj);
+ CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE);
+
+ ENVPTR->DeleteLocalRef(ENVONLY, jobj);
+ }
+ }
+ if (!found_jList) {
+ ENVPTR->CallBooleanMethod(ENVONLY, ret_buf, arrAddMethod, jList);
+ CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE);
+ ENVPTR->DeleteLocalRef(ENVONLY, jList);
+ }
+ }
+ H5Tclose(memb);
+ }
+ else if (type_class == H5T_ARRAY) {
+ if (!(memb = H5Tget_super(mem_type_id)))
+ H5_LIBRARY_ERROR(ENVONLY);
+ if ((vlClass = H5Tget_class(memb)) < 0)
+ H5_LIBRARY_ERROR(ENVONLY);
+ if (!(vlSize = H5Tget_size(memb)))
+ H5_LIBRARY_ERROR(ENVONLY);
+
+ // TODO
+ H5_UNIMPLEMENTED(ENVONLY, "translate_rbuf: invalid H5T_ARRAY type");
+ }
+
+done:
+
+ return (jint)status;
+}
+
+herr_t
+translate_wbuf(JNIEnv *env, jobjectArray in_buf, jlong mem_type_id, H5T_class_t type_class, jsize count,
+ jbyte *raw_buf)
+{
+ herr_t status = FAIL;
+ hid_t memb = H5I_INVALID_HID;
+ H5T_class_t vlClass;
+ size_t vlSize;
+ jobjectArray jList = NULL;
+ size_t i, j, x;
+
+ /* retrieve the java.util.ArrayList interface class */
+ jclass arrCList = ENVPTR->FindClass(ENVONLY, "java/util/ArrayList");
+ /* retrieve the toArray method */
+ jmethodID mToArray = ENVPTR->GetMethodID(ENVONLY, arrCList, "toArray", "()[Ljava/lang/Object;");
+
+ /* Cache class types */
+ /* jclass cBool = ENVPTR->FindClass(ENVONLY, "java/lang/Boolean"); */
+ jclass cByte = ENVPTR->FindClass(ENVONLY, "java/lang/Byte");
+ jclass cShort = ENVPTR->FindClass(ENVONLY, "java/lang/Short");
+ jclass cInt = ENVPTR->FindClass(ENVONLY, "java/lang/Integer");
+ jclass cLong = ENVPTR->FindClass(ENVONLY, "java/lang/Long");
+ jclass cFloat = ENVPTR->FindClass(ENVONLY, "java/lang/Float");
+ jclass cDouble = ENVPTR->FindClass(ENVONLY, "java/lang/Double");
+
+ /* jmethodID boolValueMid = ENVPTR->GetMethodID(ENVONLY, cBool, "booleanValue", "()Z"); */
+ jmethodID byteValueMid = ENVPTR->GetMethodID(ENVONLY, cByte, "byteValue", "()B");
+ jmethodID shortValueMid = ENVPTR->GetMethodID(ENVONLY, cShort, "shortValue", "()S");
+ jmethodID intValueMid = ENVPTR->GetMethodID(ENVONLY, cInt, "intValue", "()I");
+ jmethodID longValueMid = ENVPTR->GetMethodID(ENVONLY, cLong, "longValue", "()J");
+ jmethodID floatValueMid = ENVPTR->GetMethodID(ENVONLY, cFloat, "floatValue", "()F");
+ jmethodID doubleValueMid = ENVPTR->GetMethodID(ENVONLY, cDouble, "doubleValue", "()D");
+
+ if (type_class == H5T_VLEN) {
+ if (!(memb = H5Tget_super(mem_type_id)))
+ H5_LIBRARY_ERROR(ENVONLY);
+ if ((vlClass = H5Tget_class((hid_t)memb)) < 0)
+ H5_LIBRARY_ERROR(ENVONLY);
+ if (!(vlSize = H5Tget_size(memb)))
+ H5_LIBRARY_ERROR(ENVONLY);
+
+ /* Convert each list to a vlen element */
+ for (i = 0; i < (size_t)count; i++) {
+ hvl_t vl_elem;
+
+ if (NULL == (jList = ENVPTR->GetObjectArrayElement(ENVONLY, (jobjectArray)in_buf, (jsize)i)))
+ CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
+
+ /* invoke the toArray method */
+ if (mToArray == NULL)
+ CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
+ jobjectArray array = (jobjectArray)ENVPTR->CallObjectMethod(ENVONLY, jList, mToArray);
+ jsize jnelmts = ENVPTR->GetArrayLength(ENVONLY, array);
+
+ if (jnelmts < 0)
+ H5_BAD_ARGUMENT_ERROR(ENVONLY, "translate_wbuf: number of VL elements < 0");
+
+ vl_elem.len = (size_t)jnelmts;
+
+ if (NULL == (vl_elem.p = HDmalloc((size_t)jnelmts * vlSize)))
+ H5_OUT_OF_MEMORY_ERROR(ENVONLY, "translate_wbuf: failed to allocate vlen ptr buffer");
+
+ if ((vlClass == H5T_ARRAY) || (vlClass == H5T_COMPOUND) || (vlClass == H5T_VLEN))
+ translate_wbuf(ENVONLY, (jobjectArray)array, memb, vlClass, (jsize)jnelmts, vl_elem.p);
+ else {
+ jobject jobj = NULL;
+ for (j = 0; j < (size_t)jnelmts; j++) {
+ if (NULL ==
+ (jobj = ENVPTR->GetObjectArrayElement(ENVONLY, (jobjectArray)array, (jsize)j)))
+ CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
+
+ switch (vlClass) {
+ /* case H5T_BOOL: {
+ jboolean boolValue = ENVPTR->CallBooleanMethod(ENVONLY, jobj, boolValueMid);
+ for (x = 0; x < vlSize; x++) {
+ ((char *)vl_elem.p)[j * vlSize + x] = ((char *)&boolValue)[x];
+ }
+ break;
+ } */
+ case H5T_INTEGER: {
+ switch (vlSize) {
+ case sizeof(jbyte): {
+ jbyte byteValue = ENVPTR->CallByteMethod(ENVONLY, jobj, byteValueMid);
+ for (x = 0; x < vlSize; x++) {
+ ((char *)vl_elem.p)[j * vlSize + x] = ((char *)&byteValue)[x];
+ }
+ break;
+ }
+ case sizeof(jshort): {
+ jshort shortValue = ENVPTR->CallShortMethod(ENVONLY, jobj, shortValueMid);
+ for (x = 0; x < vlSize; x++) {
+ ((char *)vl_elem.p)[j * vlSize + x] = ((char *)&shortValue)[x];
+ }
+ break;
+ }
+ case sizeof(jint): {
+ jint intValue = ENVPTR->CallIntMethod(ENVONLY, jobj, intValueMid);
+ for (x = 0; x < vlSize; x++) {
+ ((char *)vl_elem.p)[j * vlSize + x] = ((char *)&intValue)[x];
+ }
+ break;
+ }
+ case sizeof(jlong): {
+ jlong longValue = ENVPTR->CallLongMethod(ENVONLY, jobj, longValueMid);
+ for (x = 0; x < vlSize; x++) {
+ ((char *)vl_elem.p)[j * vlSize + x] = ((char *)&longValue)[x];
+ }
+ break;
+ }
+ }
+ break;
+ }
+ case H5T_FLOAT: {
+ switch (vlSize) {
+ case sizeof(jfloat): {
+ jfloat floatValue = ENVPTR->CallFloatMethod(ENVONLY, jobj, floatValueMid);
+ for (x = 0; x < vlSize; x++) {
+ ((char *)vl_elem.p)[j * vlSize + x] = ((char *)&floatValue)[x];
+ }
+ break;
+ }
+ case sizeof(jdouble): {
+ jdouble doubleValue =
+ ENVPTR->CallDoubleMethod(ENVONLY, jobj, doubleValueMid);
+ for (x = 0; x < vlSize; x++) {
+ ((char *)vl_elem.p)[j * vlSize + x] = ((char *)&doubleValue)[x];
+ }
+ break;
+ }
+ }
+ break;
+ }
+ case H5T_REFERENCE: {
+ jbyte *barray = (jbyte *)ENVPTR->GetByteArrayElements(ENVONLY, jobj, 0);
+ for (x = 0; x < vlSize; x++) {
+ ((char *)vl_elem.p)[j * vlSize + x] = ((char *)barray)[x];
+ }
+ ENVPTR->ReleaseByteArrayElements(ENVONLY, jobj, barray, 0);
+ break;
+ }
+ default:
+ H5_UNIMPLEMENTED(ENVONLY, "translate_wbuf: invalid class type");
+ break;
+ }
+ ENVPTR->DeleteLocalRef(ENVONLY, jobj);
+ }
+ }
+
+ HDmemcpy((char *)raw_buf + i * sizeof(hvl_t), &vl_elem, sizeof(hvl_t));
+
+ ENVPTR->DeleteLocalRef(ENVONLY, jList);
+ } /* end for (i = 0; i < count; i++) */
+ }
+ else if (type_class == H5T_COMPOUND) {
+ // TODO
+ H5_UNIMPLEMENTED(ENVONLY, "translate_wbuf: invalid H5T_COMPOUND type");
+ }
+ else if (type_class == H5T_ARRAY) {
+ if (!(memb = H5Tget_super(mem_type_id)))
+ H5_LIBRARY_ERROR(ENVONLY);
+ if ((vlClass = H5Tget_class(memb)) < 0)
+ H5_LIBRARY_ERROR(ENVONLY);
+ if (!(vlSize = H5Tget_size(memb)))
+ H5_LIBRARY_ERROR(ENVONLY);
+
+ // TODO
+ H5_UNIMPLEMENTED(ENVONLY, "translate_wbuf: invalid H5T_ARRAY type");
+ }
+
+done:
+
+ return (jint)status;
+}
+
#ifdef __cplusplus
}
#endif