java: fix Java return type for readData in MMA7455

Signed-off-by: Petre <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Petre 2015-08-26 18:44:34 +03:00 committed by Mihai Tudor Panu
parent 4f30959a43
commit ea669ddfc6
3 changed files with 33 additions and 0 deletions

View File

@ -10,4 +10,20 @@
#include "mma7455.h"
%}
%typemap(jni) short* "jshortArray"
%typemap(jstype) short* "short[]"
%typemap(jtype) short* "short[]"
%typemap(javaout) short* {
return $jnicall;
}
%typemap(out) short *readData {
$result = JCALL1(NewShortArray, jenv, 3);
JCALL4(SetShortArrayRegion, jenv, $result, 0, 3, (const signed short*)$1);
delete [] $1;
}
%ignore readData(short *, short *, short *);
%include "mma7455.h"

View File

@ -137,6 +137,14 @@ MMA7455::readData (short * ptrX, short * ptrY, short * ptrZ) {
return MRAA_SUCCESS;
}
#ifdef SWIGJAVA
short *MMA7455::readData() {
short *v = new short[3];
readData(&v[0], &v[1], &v[2]);
return v;
}
#endif
int
MMA7455::ic2ReadReg (unsigned char reg, unsigned char * buf, unsigned char size) {
if (MRAA_SUCCESS != mraa_i2c_address(m_i2ControlCtx, m_controlAddr)) {

View File

@ -206,6 +206,15 @@ class MMA7455 {
*/
mraa_result_t readData (short * ptrX, short * ptrY, short * ptrZ);
#ifdef SWIGJAVA
/**
* Reads X-axis, Y-axis, and Z-axis acceleration data
*
* @return Array containing X, Y, Z acceleration data
*/
short *readData ();
#endif
/**
*
*