java: map C buffer pointer and length to Java array for Ublox6

Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Petre Eftime 2015-08-28 18:10:43 +03:00 committed by Mihai Tudor Panu
parent 42c59e98ab
commit fb6627083b
2 changed files with 19 additions and 2 deletions

View File

@ -1,9 +1,9 @@
%module javaupm_mic
%include "../upm.i"
%include "stdint.i"
%include "typemaps.i"
%include "arrays_java.i"
%apply uint16_t *OUTPUT { uint16_t *buffer };
%apply unsigned short[] {uint16_t *buffer};
%{
#include "mic.h"

View File

@ -8,6 +8,23 @@
speed_t int_B9600 = B9600;
%}
%typemap(jni) (char *buffer, size_t len) "jbyteArray";
%typemap(jtype) (char *buffer, size_t len) "byte[]";
%typemap(jstype) (char *buffer, size_t len) "byte[]";
%typemap(in) (char *buffer, size_t len) {
$1 = (char *) JCALL2(GetByteArrayElements, jenv, $input, NULL);
$2 = JCALL1(GetArrayLength, jenv, $input);
}
%typemap(freearg) readData(char *buffer, size_t len) {
JCALL2(ReleaseByteArrayElements, jenv, $input, JNI_ABORT);
}
%typemap(freearg) writeData(char *buffer, size_t len) {
JCALL2(ReleaseByteArrayElements, jenv, $input, 0);
}
%include "ublox6.h"
speed_t int_B9600 = B9600;
%array_class(char, charArray);