From: Martin Vajnar Date: Wed, 10 Jun 2015 21:14:35 +0000 (+0200) Subject: JORTE: coding style fixes X-Git-Url: http://rtime.felk.cvut.cz/gitweb/orte.git/commitdiff_plain/afca0b463679956e5a25825ee97ae04ad190d180 JORTE: coding style fixes --- diff --git a/orte/include/jorte/org_ocera_orte_types_RecvInfo.h b/orte/include/jorte/org_ocera_orte_types_RecvInfo.h index 971bddd..0494557 100644 --- a/orte/include/jorte/org_ocera_orte_types_RecvInfo.h +++ b/orte/include/jorte/org_ocera_orte_types_RecvInfo.h @@ -12,7 +12,8 @@ extern "C" { * Method: get_string * Signature: (J)Ljava/lang/String; */ -JNIEXPORT jstring JNICALL Java_org_ocera_orte_types_RecvInfo_get_1string +JNIEXPORT jstring JNICALL +Java_org_ocera_orte_types_RecvInfo_get_1string (JNIEnv *, jclass, jlong); /* @@ -20,7 +21,8 @@ JNIEXPORT jstring JNICALL Java_org_ocera_orte_types_RecvInfo_get_1string * Method: c_helper * Signature: (Ljava/nio/ByteBuffer;)V */ -JNIEXPORT void JNICALL Java_org_ocera_orte_types_RecvInfo_c_1helper +JNIEXPORT void JNICALL +Java_org_ocera_orte_types_RecvInfo_c_1helper (JNIEnv *, jclass, jobject); #ifdef __cplusplus diff --git a/orte/libjorte/JORTERecvInfoHelpers.c b/orte/libjorte/JORTERecvInfoHelpers.c index c113d5f..fe377b7 100644 --- a/orte/libjorte/JORTERecvInfoHelpers.c +++ b/orte/libjorte/JORTERecvInfoHelpers.c @@ -19,47 +19,51 @@ * Method: c_helper * Signature: (Ljava/nio/ByteBuffer;)V */ -JNIEXPORT void JNICALL Java_org_ocera_orte_types_RecvInfo_c_1helper - (JNIEnv *env, jclass cls, jobject b_buffer) { +JNIEXPORT void JNICALL +Java_org_ocera_orte_types_RecvInfo_c_1helper + (JNIEnv *env, jclass cls, jobject b_buffer) +{ - _Static_assert(sizeof(char*) == 1 || \ - sizeof(char*) == 2 || \ - sizeof(char*) == 4 || \ - sizeof(char*) == 8, \ - "char* has incompatible size"); - _Static_assert(sizeof(ORTERecvStatus) == 1 || \ - sizeof(ORTERecvStatus) == 2 || \ - sizeof(ORTERecvStatus) == 4 || \ - sizeof(ORTERecvStatus) == 8, \ - "ORTERecvStatus has incompatible size"); + _Static_assert(sizeof(char *) == 1 || \ + sizeof(char *) == 2 || \ + sizeof(char *) == 4 || \ + sizeof(char *) == 8, \ + "char* has incompatible size"); + _Static_assert(sizeof(ORTERecvStatus) == 1 || \ + sizeof(ORTERecvStatus) == 2 || \ + sizeof(ORTERecvStatus) == 4 || \ + sizeof(ORTERecvStatus) == 8, \ + "ORTERecvStatus has incompatible size"); - int32_t* buffer = (*env)->GetDirectBufferAddress(env, b_buffer); - - buffer[0] = (int32_t)sizeof(ORTERecvInfo); - buffer[1] = (int32_t)sizeof(ORTERecvStatus); - buffer[2] = (int32_t)sizeof(char*); - buffer[3] = (int32_t)offsetof(ORTERecvInfo,status); - buffer[4] = (int32_t)offsetof(ORTERecvInfo,topic); - buffer[5] = (int32_t)offsetof(ORTERecvInfo,type); - buffer[6] = (int32_t)offsetof(ORTERecvInfo,senderGUID); - buffer[7] = (int32_t)offsetof(ORTERecvInfo,localTimeReceived); - buffer[8] = (int32_t)offsetof(ORTERecvInfo,remoteTimePublished); - buffer[9] = (int32_t)offsetof(ORTERecvInfo,sn); - buffer[10] = (int32_t)offsetof(GUID_RTPS,hid); - buffer[11] = (int32_t)offsetof(GUID_RTPS,aid); - buffer[12] = (int32_t)offsetof(GUID_RTPS,oid); - buffer[13] = (int32_t)offsetof(NtpTime,seconds); - buffer[14] = (int32_t)offsetof(NtpTime,fraction); - buffer[15] = (int32_t)offsetof(SequenceNumber,high); - buffer[16] = (int32_t)offsetof(SequenceNumber,low); - } + int32_t *buffer = (*env)->GetDirectBufferAddress(env, b_buffer); + + buffer[0] = (int32_t)sizeof(ORTERecvInfo); + buffer[1] = (int32_t)sizeof(ORTERecvStatus); + buffer[2] = (int32_t)sizeof(char *); + buffer[3] = (int32_t)offsetof(ORTERecvInfo, status); + buffer[4] = (int32_t)offsetof(ORTERecvInfo, topic); + buffer[5] = (int32_t)offsetof(ORTERecvInfo, type); + buffer[6] = (int32_t)offsetof(ORTERecvInfo, senderGUID); + buffer[7] = (int32_t)offsetof(ORTERecvInfo, localTimeReceived); + buffer[8] = (int32_t)offsetof(ORTERecvInfo, remoteTimePublished); + buffer[9] = (int32_t)offsetof(ORTERecvInfo, sn); + buffer[10] = (int32_t)offsetof(GUID_RTPS, hid); + buffer[11] = (int32_t)offsetof(GUID_RTPS, aid); + buffer[12] = (int32_t)offsetof(GUID_RTPS, oid); + buffer[13] = (int32_t)offsetof(NtpTime, seconds); + buffer[14] = (int32_t)offsetof(NtpTime, fraction); + buffer[15] = (int32_t)offsetof(SequenceNumber, high); + buffer[16] = (int32_t)offsetof(SequenceNumber, low); +} /* * Class: org_ocera_orte_types_RecvInfo * Method: get_string * Signature: (J)Ljava/lang/String; */ -JNIEXPORT jstring JNICALL Java_org_ocera_orte_types_RecvInfo_get_1string - (JNIEnv *env, jclass cls, jlong string_ptr) { - return (*env)->NewStringUTF(env, (char*) string_ptr); - } +JNIEXPORT jstring JNICALL +Java_org_ocera_orte_types_RecvInfo_get_1string + (JNIEnv *env, jclass cls, jlong string_ptr) +{ + return (*env)->NewStringUTF(env, (char *)string_ptr); +} diff --git a/orte/libjorte/JORTESubscriptionCreate.c b/orte/libjorte/JORTESubscriptionCreate.c index f93d9e4..e0838cf 100644 --- a/orte/libjorte/JORTESubscriptionCreate.c +++ b/orte/libjorte/JORTESubscriptionCreate.c @@ -68,14 +68,13 @@ recvCallBack(const ORTERecvInfo *info, void *vinstance, void *recvCallBackParam) // set local variables from struct jvm = callback_cont->jvm; // get env - if((*jvm)->AttachCurrentThread(jvm, + if ((*jvm)->AttachCurrentThread(jvm, #ifdef __ANDROID__ - &env, + &env, #else - (void **)&env, + (void **)&env, #endif - NULL) != JNI_OK) - { + NULL) != JNI_OK) { #ifdef TEST_STAGE printf(":!c: recvCallBack: AttachCurrentThread() failed \n"); #endif @@ -102,7 +101,7 @@ recvCallBack(const ORTERecvInfo *info, void *vinstance, void *recvCallBackParam) #endif //////////////////////////////////////////////////// - memcpy(callback_cont->info_buf, (void*)info, sizeof(ORTERecvInfo)); + memcpy(callback_cont->info_buf, (void *)info, sizeof(ORTERecvInfo)); //////////////////////////////////////////////////// // control print - only in TEST_STAGE @@ -219,8 +218,7 @@ Java_org_ocera_orte_Subscription_jORTESubscriptionCreate #ifdef TEST_STAGE printf(":c: getJavaVM succesfull.. \n"); #endif - } - else { + } else { #ifdef TEST_STAGE printf(":!c: getJavaVM() failed! \n"); #endif @@ -247,9 +245,9 @@ Java_org_ocera_orte_Subscription_jORTESubscriptionCreate } // get callback method ID callback_cont->mid_callback = (*env)->GetMethodID(env, - cls, - "callback", - "(Lorg/ocera/orte/types/RecvInfo;Lorg/ocera/orte/types/MessageData;)V"); + cls, + "callback", + "(Lorg/ocera/orte/types/RecvInfo;Lorg/ocera/orte/types/MessageData;)V"); if (callback_cont->mid_callback == 0) { #ifdef TEST_STAGE printf(":!c: mid_callback = NULL \n"); @@ -285,9 +283,9 @@ Java_org_ocera_orte_Subscription_jORTESubscriptionCreate ///////////////////////////////////////////////////// // methodID - read() callback_cont->mid_read = (*env)->GetMethodID(env, - cls, - "read", - "()V"); + cls, + "read", + "()V"); if (callback_cont->mid_read == 0) { #ifdef TEST_STAGE printf(":!c: mid_read = NULL \n"); @@ -298,42 +296,42 @@ Java_org_ocera_orte_Subscription_jORTESubscriptionCreate // find cls cls = findClass(env, "org.ocera.orte.types.RecvInfo"); if (cls == 0) { - #ifdef TEST_STAGE - printf(":!c: cls = NULL \n"); - #endif - break; + #ifdef TEST_STAGE + printf(":!c: cls = NULL \n"); + #endif + break; } // call object constructor mid = (*env)->GetMethodID(env, cls, "", "()V"); if (mid == 0) { - #ifdef TEST_STAGE - printf(":!c: constructor failed! \n"); - #endif - break; + #ifdef TEST_STAGE + printf(":!c: constructor failed! \n"); + #endif + break; } // create new object callback_cont->rinfo = (*env)->NewObject(env, cls, mid); if (callback_cont->rinfo == 0) { - #ifdef TEST_STAGE - printf(":!c: rinfo = NULL \n"); - #endif - break; + #ifdef TEST_STAGE + printf(":!c: rinfo = NULL \n"); + #endif + break; } // create global reference callback_cont->rinfo = (*env)->NewGlobalRef(env, callback_cont->rinfo); if (callback_cont->rinfo == 0) { - #ifdef TEST_STAGE - printf(":!c: callback_cont->rinfo = NULL \n"); - #endif - break; + #ifdef TEST_STAGE + printf(":!c: callback_cont->rinfo = NULL \n"); + #endif + break; } // lookup getBuffer() ID mid = (*env)->GetMethodID(env, cls, "getBuffer", "()Ljava/nio/ByteBuffer;"); if (mid == 0) { - #ifdef TEST_STAGE - printf(":!c: getBuffer() failed! \n"); - #endif - break; + #ifdef TEST_STAGE + printf(":!c: getBuffer() failed! \n"); + #endif + break; } // get ByteBuffer reference obj_info_buffer = (*env)->CallObjectMethod(env, callback_cont->rinfo, mid); @@ -341,23 +339,23 @@ Java_org_ocera_orte_Subscription_jORTESubscriptionCreate // create global references for ByteOrders cls = (*env)->FindClass(env, "java/nio/ByteOrder"); fid = (*env)->GetStaticFieldID(env, - cls, - "BIG_ENDIAN", - "Ljava/nio/ByteOrder;"); + cls, + "BIG_ENDIAN", + "Ljava/nio/ByteOrder;"); callback_cont->obj_BO_BE = (*env)->GetStaticObjectField(env, cls, fid); callback_cont->obj_BO_BE = (*env)->NewGlobalRef(env, callback_cont->obj_BO_BE); fid = (*env)->GetStaticFieldID(env, - cls, - "LITTLE_ENDIAN", - "Ljava/nio/ByteOrder;"); + cls, + "LITTLE_ENDIAN", + "Ljava/nio/ByteOrder;"); callback_cont->obj_BO_LE = (*env)->GetStaticObjectField(env, cls, fid); callback_cont->obj_BO_LE = (*env)->NewGlobalRef(env, callback_cont->obj_BO_LE); // get methodID - order(ByteOrder) cls = (*env)->GetObjectClass(env, callback_cont->obj_buf); callback_cont->mid_order = (*env)->GetMethodID(env, - cls, - "order", - "(Ljava/nio/ByteOrder;)Ljava/nio/ByteBuffer;"); + cls, + "order", + "(Ljava/nio/ByteOrder;)Ljava/nio/ByteBuffer;"); // cls = (*env)->GetObjectClass(env, obj); if (cls == 0) {