* 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);
+}
// 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
#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
#ifdef TEST_STAGE
printf(":c: getJavaVM succesfull.. \n");
#endif
- }
- else {
+ } else {
#ifdef TEST_STAGE
printf(":!c: getJavaVM() failed! \n");
#endif
}
// 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");
/////////////////////////////////////////////////////
// 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");
// 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);
// 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) {