java: solved some SWIGTYPE issues

Signed-off-by: Andrei Vasiliu <andrei.vasiliu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>

Conflicts:
	src/mma7455/mma7455.cxx
	src/mma7455/mma7455.h
This commit is contained in:
Andrei Vasiliu
2015-09-14 19:30:03 +03:00
committed by Mihai Tudor Panu
parent ff42bd390f
commit 6cbddff31a
6 changed files with 84 additions and 10 deletions

View File

@ -4,6 +4,21 @@
%include "arrays_java.i";
%include "../java_buffer.i"
%typemap(jni) uint8_t * "jbyteArray"
%typemap(jtype) uint8_t * "byte[]"
%typemap(jstype) uint8_t * "byte[]"
%typemap(javaout) uint8_t * {
return $jnicall;
}
%typemap(out) uint8_t *{
int length = upm::M24LR64E::UID_LENGTH;
$result = JCALL1(NewByteArray, jenv, length);
JCALL4(SetByteArrayRegion, jenv, $result, 0, length, reinterpret_cast<signed char *>($1));
delete [] $1;
}
%{
#include "m24lr64e.h"
%}

View File

@ -163,9 +163,12 @@ uint8_t M24LR64E::getAFI()
return EEPROM_Read_Byte(AFI_ADDR);
}
void M24LR64E::getUID(uint8_t* buffer)
uint8_t *M24LR64E::getUID()
{
uint8_t* buffer = new uint8_t[UID_LENGTH];
EEPROM_Read_Bytes(UID_ADDR, buffer, UID_LENGTH);
return buffer;
}
uint32_t M24LR64E::getMemorySize()

View File

@ -215,10 +215,11 @@ namespace upm {
/**
* Returns a unique ID.
* Must be in the root mode.
* Maintained to preserve compatibility with older code.
*
* @param buf Buffer to hold the returned UID. Must be UID_LENGTH bytes.
* @result buf Buffer to hold the UID. Must be UID_LENGTH bytes.
*/
void getUID(uint8_t* buffer);
uint8_t *getUID();
/**
* Returns the memory size