]> rtime.felk.cvut.cz Git - orte.git/commitdiff
JORTE: improve ByteOrder handling
authorMartin Vajnar <martin.vajnar@gmail.com>
Fri, 26 Jul 2013 08:44:46 +0000 (10:44 +0200)
committerMartin Vajnar <martin.vajnar@gmail.com>
Fri, 26 Jul 2013 08:44:46 +0000 (10:44 +0200)
Store the ByteOrder of MessageData's ByteBuffer in receive callback
structure in C (in case someone reuses already created MessageData instance
with new subscriber).

Force native byte order setting in publisher.

orte/include/jorte/org_ocera_orte_Subscription.h
orte/java/src/org/ocera/orte/Publication.java
orte/java/src/org/ocera/orte/Subscription.java
orte/libjorte/JORTESubscriptionCreate.c

index 11abfa3a2e690fee08de8b232e80434f0761dcaf..9b7598cd96ca82ce094aa57067149a00ef37d224 100644 (file)
@@ -13,7 +13,7 @@ extern "C" {
  * Signature: (JIILjava/lang/String;Ljava/lang/String;ILorg/ocera/orte/types/MessageData;Lorg/ocera/orte/types/NtpTime;Lorg/ocera/orte/types/NtpTime;Lorg/ocera/orte/SubscriptionCallback;J)J
  */
 JNIEXPORT jlong JNICALL Java_org_ocera_orte_Subscription_jORTESubscriptionCreate
-  (JNIEnv *, jobject, jlong, jint, jint, jstring, jstring, jobject, jobject, jobject, jobject, jobject, jlong);
+  (JNIEnv *, jobject, jlong, jint, jint, jstring, jstring, jobject, jint, jobject, jobject, jobject, jobject, jlong);
 
 /*
  * Class:     org_ocera_orte_Subscription
index 4eab46988e01cc9b2b751522bb356d54ad0e5079..c39a5dc18de3f8707ef8e65e57bd53f1e202f869 100644 (file)
@@ -24,6 +24,7 @@
 
 package org.ocera.orte;
 import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
 
 import org.ocera.orte.types.*;
 
@@ -63,6 +64,7 @@ public class Publication {
                       PublProp publProp,
                                          MessageData instance)
   {
+        instance.getBuffer().order(ByteOrder.nativeOrder());
        this.handle = jORTEPublicationCreate(d.handle,
                                             publProp.getTopic(),
                                             publProp.getTypeName(),
index 68af0f44cb323f160a06ea650fe5218e6af486ec..485f9e3301f8aa2234a0ffd00834fcec6f6bbe97 100644 (file)
@@ -24,6 +24,7 @@
 
 package org.ocera.orte;
 import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
 
 import  org.ocera.orte.types.*;
 
@@ -58,6 +59,7 @@ public class Subscription {
                                              subsProp.getTopic(),
                                              subsProp.getTypeName(),
                                              message.getBuffer(),
+                                              message.getBuffer().order().equals(ByteOrder.BIG_ENDIAN) ? 0 : 1,
                                              message,
                                                                                  subsProp.getDeadline(),
                                                              subsProp.getMinSeparation(),
@@ -193,6 +195,7 @@ public class Subscription {
                                String topic,
                                String typeName,
                                ByteBuffer buffer,
+                               int byte_order,
                                MessageData message,
                                                          NtpTime deadline,
                                NtpTime minSeparation,
index e8ee56db2d1093975cc8f64bf691a2259c67c949..599f9c8621dc81de34fd05a0c7ce2f6296b731d3 100644 (file)
@@ -328,6 +328,7 @@ Java_org_ocera_orte_Subscription_jORTESubscriptionCreate
  jstring   jtopic,    // subs topic
  jstring   jtname,    // subs typeName
  jobject   jinstance, // direct ByteBuffer
+ jint      jbyteOrder,// byte order of ByteBuffer
  jobject   obj_msg,   // messageData instance
  jobject   jdeadline,
  jobject   jminSeparation,
@@ -385,7 +386,7 @@ Java_org_ocera_orte_Subscription_jORTESubscriptionCreate
       #endif
     }
     callback_cont->jvm = jvm;
-    callback_cont->cur_endian = FLAG_ENDIANNESS;
+    callback_cont->cur_endian = (CDR_Endianness) jbyteOrder;
     // create global references
     callback_cont->obj = (*env)->NewGlobalRef(env, obj_callback);
     //