]> rtime.felk.cvut.cz Git - orte.git/commitdiff
JORTE: coding style fixes
authorMartin Vajnar <martin.vajnar@gmail.com>
Wed, 10 Jun 2015 21:14:35 +0000 (23:14 +0200)
committerMartin Vajnar <martin.vajnar@gmail.com>
Wed, 10 Jun 2015 21:14:35 +0000 (23:14 +0200)
orte/include/jorte/org_ocera_orte_types_RecvInfo.h
orte/libjorte/JORTERecvInfoHelpers.c
orte/libjorte/JORTESubscriptionCreate.c

index 971bddd8c683ccb8ef9f536679943ac27e5118a0..0494557b1e78a828eef7adf19672dbc90c8b9429 100644 (file)
@@ -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
index c113d5ff20d9ac0c84f3ed7fdc7ac6356e2a04af..fe377b767a57c5a9298bd685ca46161ece2c2dd2 100644 (file)
  * 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);
+}
index f93d9e452f9f27db77d9a82cedf27fb007dcc96a..e0838cf748657ab3b7aba6603d0e7e7c6029f206 100644 (file)
@@ -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, "<init>", "()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) {