qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgodf...@apache.org
Subject svn commit: r1442549 - in /qpid/proton/trunk/proton-c/bindings/java: java.i src/main/java/org/apache/qpid/proton/codec/jni/JNIData.java
Date Tue, 05 Feb 2013 11:35:31 GMT
Author: rgodfrey
Date: Tue Feb  5 11:35:31 2013
New Revision: 1442549

URL: http://svn.apache.org/viewvc?rev=1442549&view=rev
Log:
PROTON-192 : [JNI Binding] use correct method for converting pn_bytes into byte[]

Modified:
    qpid/proton/trunk/proton-c/bindings/java/java.i
    qpid/proton/trunk/proton-c/bindings/java/src/main/java/org/apache/qpid/proton/codec/jni/JNIData.java

Modified: qpid/proton/trunk/proton-c/bindings/java/java.i
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/java/java.i?rev=1442549&r1=1442548&r2=1442549&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/bindings/java/java.i (original)
+++ qpid/proton/trunk/proton-c/bindings/java/java.i Tue Feb  5 11:35:31 2013
@@ -385,36 +385,6 @@ ssize_t pn_sasl_recv(pn_sasl_t *sasl, ch
 ssize_t pn_sasl_send(pn_sasl_t *sasl, char *DATA, size_t SIZE);
 %ignore pn_sasl_send;
 
-%typemap(jni) char *start "jbyteArray"
-%typemap(jtype) char *start "byte[]"
-%typemap(jstype) char *start "byte[]"
-%typemap(javaout) char *start {
-    return $jnicall;
-}
-
-%typemap(out) char *start {
-    // TODO - RG
-    $result = JCALL1(NewByteArray, jenv, arg1->size);
-    JCALL4(SetByteArrayRegion, jenv, $result, 0, arg1->size, $1);
-}
-
-%typemap(in) char *start {
-    jbyte* barr = (*jenv)->GetByteArrayElements(jenv, $input, NULL);
-    jsize length = (*jenv)->GetArrayLength(jenv, $input);
-    char *buf = malloc(length);
-    jint i = 0;
-    for(i=0;i<length;i++)
-    {
-      buf[i] = barr[i];
-    }
-    (*jenv)->ReleaseByteArrayElements(jenv, $input, barr, 0);
-    $1 = buf;
-}
-%typemap(freearg) char *start  {
-
-}
-
-
 %rename(pn_delivery) wrap_pn_delivery;
 %inline %{
   pn_delivery_t *wrap_pn_delivery(pn_link_t *link, char *STRING, size_t LENGTH) {

Modified: qpid/proton/trunk/proton-c/bindings/java/src/main/java/org/apache/qpid/proton/codec/jni/JNIData.java
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/java/src/main/java/org/apache/qpid/proton/codec/jni/JNIData.java?rev=1442549&r1=1442548&r2=1442549&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/bindings/java/src/main/java/org/apache/qpid/proton/codec/jni/JNIData.java
(original)
+++ qpid/proton/trunk/proton-c/bindings/java/src/main/java/org/apache/qpid/proton/codec/jni/JNIData.java
Tue Feb  5 11:35:31 2013
@@ -675,7 +675,8 @@ public class JNIData implements Data
     public Binary getBinary()
     {
         pn_bytes_t b = Proton.pn_data_get_binary(_impl);
-        return new Binary(b.getStart());
+
+        return b == null ? null : new Binary(Proton.pn_bytes_to_array(b));
     }
 
     @Override
@@ -683,7 +684,7 @@ public class JNIData implements Data
     public String getString()
     {
         pn_bytes_t b = Proton.pn_data_get_string(_impl);
-        return new String(b.getStart(), UTF8_CHARSET);
+        return b == null ? null : new String(Proton.pn_bytes_to_array(b), UTF8_CHARSET);
     }
 
     @Override
@@ -691,7 +692,7 @@ public class JNIData implements Data
     public Symbol getSymbol()
     {
         pn_bytes_t b = Proton.pn_data_get_symbol(_impl);
-        return Symbol.valueOf(new String(b.getStart(), UTF8_CHARSET));
+        return b == null ? null : Symbol.valueOf(new String(Proton.pn_bytes_to_array(b),
ASCII_CHARSET));
     }
 
     @Override



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message