mirror of
https://github.com/eclipse/upm.git
synced 2025-03-15 04:57:30 +03:00
java: convert (uint8_t* buf, int len) to byte[] in Java for lsm9ds0, free resources
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:
parent
3aad8e367f
commit
be2e8d7c76
@ -11,7 +11,6 @@
|
||||
|
||||
%apply int {mraa::Edge};
|
||||
%apply float *INOUT { float *x, float *y, float *z };
|
||||
%apply unsigned char[] {uint8_t *buf};
|
||||
|
||||
%{
|
||||
#include "lsm9ds0.h"
|
||||
@ -28,20 +27,38 @@
|
||||
%typemap(out) float *getAccelerometer {
|
||||
$result = JCALL1(NewFloatArray, jenv, 3);
|
||||
JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1);
|
||||
delete [] $1;
|
||||
}
|
||||
|
||||
%typemap(out) float *getGyroscope {
|
||||
$result = JCALL1(NewFloatArray, jenv, 3);
|
||||
JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1);
|
||||
delete [] $1;
|
||||
}
|
||||
|
||||
%typemap(out) float *getMagnetometer {
|
||||
$result = JCALL1(NewFloatArray, jenv, 3);
|
||||
JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1);
|
||||
delete [] $1;
|
||||
}
|
||||
|
||||
%ignore getAccelerometer(float *, float *, float *);
|
||||
%ignore getGyroscope(float *, float *, float *);
|
||||
%ignore getMagnetometer(float *, float *, float *);
|
||||
|
||||
%typemap(jni) (uint8_t *buf, int len) "jbyteArray";
|
||||
%typemap(jtype) (uint8_t *buf, int len) "byte[]";
|
||||
%typemap(jstype) (uint8_t *buf, int len) "byte[]";
|
||||
|
||||
%typemap(javain) (uint8_t *buf, int len) "$javainput";
|
||||
|
||||
%typemap(in) (uint8_t *buf, int len) {
|
||||
$1 = (uint8_t *) JCALL2(GetByteArrayElements, jenv, $input, NULL);
|
||||
$2 = JCALL1(GetArrayLength, jenv, $input);
|
||||
}
|
||||
|
||||
%typemap(freearg) (uint8_t *buf, int len) {
|
||||
JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0);
|
||||
}
|
||||
|
||||
%include "lsm9ds0.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user