diff --git a/src/mic/javaupm_mic.i b/src/mic/javaupm_mic.i index 0dcc4eca..1764429e 100644 --- a/src/mic/javaupm_mic.i +++ b/src/mic/javaupm_mic.i @@ -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" diff --git a/src/ublox6/javaupm_ublox6.i b/src/ublox6/javaupm_ublox6.i index 57673b4f..9a93422f 100644 --- a/src/ublox6/javaupm_ublox6.i +++ b/src/ublox6/javaupm_ublox6.i @@ -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);