From 83cb6dc2fd10dc5c1a14fe026f6fc9e88eca83e2 Mon Sep 17 00:00:00 2001 From: Petre Eftime Date: Tue, 1 Sep 2015 18:55:28 +0300 Subject: [PATCH] java: fix Java arrays for mma7455 Signed-off-by: Petre Eftime Signed-off-by: Mihai Tudor Panu --- src/mma7455/javaupm_mma7455.i | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/mma7455/javaupm_mma7455.i b/src/mma7455/javaupm_mma7455.i index 1f57ef47..160b88f6 100644 --- a/src/mma7455/javaupm_mma7455.i +++ b/src/mma7455/javaupm_mma7455.i @@ -3,7 +3,6 @@ %include "typemaps.i" %include "arrays_java.i"; -%apply unsigned char[] {unsigned char *}; %apply short *OUTPUT { short * ptrX, short * ptrY, short * ptrZ }; %{ @@ -26,4 +25,19 @@ %ignore readData(short *, short *, short *); +%typemap(jni) (unsigned char *buf, unsigned char size) "jbyteArray"; +%typemap(jtype) (unsigned char *buf, unsigned char size) "byte[]"; +%typemap(jstype) (unsigned char *buf, unsigned char size) "byte[]"; + +%typemap(javain) (unsigned char *buf, unsigned char size) "$javainput"; + +%typemap(in) (unsigned char *buf, unsigned char size) { + $1 = (unsigned char *) JCALL2(GetByteArrayElements, jenv, $input, NULL); + $2 = JCALL1(GetArrayLength, jenv, $input); +} + +%typemap(freearg) (unsigned char *buf, unsigned char size) { + JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0); +} + %include "mma7455.h"