java: fix Java return types in h3lis331dl

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:12:02 +03:00 committed by Mihai Tudor Panu
parent fb6627083b
commit 9cfd1a9679
3 changed files with 83 additions and 0 deletions

View File

@ -567,3 +567,26 @@ void H3LIS331DL::getXYZ(int *x, int *y, int*z)
*y = (m_rawY - m_adjY);
*z = (m_rawZ - m_adjZ);
}
#ifdef SWIGJAVA
float *H3LIS331DL::getAcceleration()
{
float *v = new float[3];
getAcceleration(&v[0], &v[1], &v[2]);
return v;
}
int *H3LIS331DL::getRawXYZ()
{
int *v = new int[3];
getRawXYZ(&v[0], &v[1], &v[2]);
return v;
}
int *H3LIS331DL::getXYZ()
{
int *v = new int[3];
getXYZ(&v[0], &v[1], &v[2]);
return v;
}
#endif

View File

@ -593,6 +593,30 @@ namespace upm {
*/
void getXYZ(int *x, int *y, int *z);
#ifdef SWIGJAVA
/**
* Gets acceleration values for each of the axes
*
* @return Array containing X, Y, Z acceleration values
*/
float *getAcceleration();
/**
* Gets raw axis values
*
* @return Array containing X, Y, Z raw values
*/
int *getRawXYZ();
/**
* Gets adjusted axis values
*
* @return Array containing X, Y, Z adjusted axis values
*/
int *getXYZ();
#endif
/**
* Provides public access to the MRAA I2C context of the class for
* direct user access

View File

@ -12,4 +12,40 @@
#include "h3lis331dl.h"
%}
%typemap(jni) float* "jfloatArray"
%typemap(jstype) float* "float[]"
%typemap(jtype) float* "float[]"
%typemap(javaout) float* {
return $jnicall;
}
%typemap(out) float *getAcceleration {
$result = JCALL1(NewFloatArray, jenv, 3);
JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1);
delete [] $1;
}
%typemap(jni) int* "jintArray"
%typemap(jstype) int* "int[]"
%typemap(jtype) int* "int[]"
%typemap(javaout) int* {
return $jnicall;
}
%typemap(out) int *getRawXYZ {
$result = JCALL1(NewIntArray, jenv, 3);
JCALL4(SetIntArrayRegion, jenv, $result, 0, 3, (const int*)$1);
}
%typemap(out) int *getXYZ {
$result = JCALL1(NewIntArray, jenv, 3);
JCALL4(SetIntArrayRegion, jenv, $result, 0, 3, (const int*)$1);
}
%ignore getRawXYZ(int *, int *, int *);
%ignore getXYZ(int *, int *, int *);
%ignore getAcceleration(float *, float *, float *);
%include "h3lis331dl.h"