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

@ -1,5 +1,22 @@
%module javaupm_lol
%include "../upm.i"
%include "stdint.i"
%include "arrays_java.i";
%include "typemaps.i"
%typemap(jni) unsigned char* "jbyteArray";
%typemap(jtype) unsigned char* "byte[]";
%typemap(jstype) unsigned char* "byte[]";
%typemap(javaout) unsigned char* {
return $jnicall;
}
%typemap(out) unsigned char* {
$result = JCALL1(NewByteArray, jenv, LOL_X*LOL_Y);
JCALL4(SetByteArrayRegion, jenv, $result, 0, LOL_X*LOL_Y-1, reinterpret_cast<jbyte*>($1));
delete [] $1;
}
%{
#include "lol.h"

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

View File

@ -164,7 +164,7 @@ typedef union {
*
* @brief API for the MMA7455 Accelerometer
*
* This file defines the MMA7455 interface for libmma7455
* This module defines the MMA7455 interface for libmma7455
*
* @image html mma7455.jpg
* @snippet mma7455.cxx Interesting
@ -181,6 +181,8 @@ class MMA7455 {
/**
* Returns the name of the component
*
* @return Name of the component
*/
std::string name()
{
@ -189,6 +191,8 @@ class MMA7455 {
/**
* Calibrates the sensor
*
* @return 0 (MRAA_SUCCESS) if successful; non-zero otherwise
*/
mraa::Result calibrate ();
@ -198,6 +202,8 @@ class MMA7455 {
* @param ptrX X-axis
* @param ptrY Y-axis
* @param ptrZ Z-axis
*
* @return 0 (MRAA_SUCCESS) if successful; non-zero otherwise
*/
mraa::Result readData (short * ptrX, short * ptrY, short * ptrZ);
@ -209,28 +215,26 @@ class MMA7455 {
*/
short *readData ();
#endif
/**
*
* Internal function for reading I2C data
*
* @param reg Register address
* @param buffer Register data buffer
* @param size Buffer size
* @param len Buffer size
*/
int i2cReadReg (unsigned char reg, uint8_t *buffer, int len);
/**
*
* Internal function for writing I2C data
*
* @param reg Register address
* @param buffer Register data buffer
* @param size Buffer size
* @param len Buffer size
*/
mraa::Result i2cWriteReg (unsigned char reg, uint8_t *buffer, int len);
private:
std::string m_name;
int m_controlAddr;
int m_bus;
mraa::I2c m_i2ControlCtx;

View File

@ -1,5 +1,39 @@
%module javaupm_st7735
%include "../upm.i"
%include "arrays_java.i"
%include "typemaps.i"
%include "stdint.i"
%ignore m_map;
%ignore Bcmd;
%ignore font;
%ignore Rcmd1;
%ignore Rcmd2green;
%ignore Rcmd2red;
%ignore Rcmd3;
/*
%typemap(jni) unsigned char[] "jbyteArray";
%typemap(jtype) unsigned char[] "byte[]";
%typemap(jstype) unsigned char[] "byte[]";
%typemap(out) unsigned char[] {
$result = SWIG_JavaArrayOutSchar(jenv, reinterpret_cast<signed char*>($1), sizeof($1));
}
%typemap(freearg) unsigned char* {
JCALL3(ReleaseByteArrayElements, jenv, $input, reinterpret_cast<jbyte*>($1), 0);
}
*/
%typemap(jni) unsigned char* "jbyteArray";
%typemap(jtype) unsigned char* "byte[]";
%typemap(jstype) unsigned char* "byte[]";
%typemap(javain) unsigned char* "$javainput"
%typemap(in) unsigned char* {
$1 = (unsigned char *)JCALL2(GetByteArrayElements, jenv, $input, NULL);
}
%include "gfx.h"
%{