SWIGJAVA: Remove the last JAVA ifdefs from src

Removed all references to #ifdef SWIGJAVA and JAVACALLBACK from the
library source.  All java-specific source code has been moved to the
corresponding library's .i file for java.

    * Update library source
    * Update examples where necessary
    * The function pointer methodology has been remove from libraries
      which provided callbacks as both a class and a function pointer
      implementation.  Examples were updated to use the class version
      of callbacks.
    * Updated documentation for SWIGJAVA

Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
Noel Eck
2018-01-23 11:58:12 -08:00
parent d49ab2ac95
commit 666452e873
44 changed files with 280 additions and 509 deletions

View File

@ -3,29 +3,15 @@
%include "typemaps.i"
%include "arrays_java.i";
%include "../java_buffer.i"
%include "std_vector.i"
%template(ShortVector) std::vector<short>;
%apply short *OUTPUT { short * ptrX, short * ptrY, short * ptrZ };
%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.hpp"
#include "mma7455.hpp"
%}
%include "mma7455.hpp"
JAVA_JNI_LOADLIBRARY(javaupm_mma7455)
JAVA_JNI_LOADLIBRARY(javaupm_mma7455)

View File

@ -26,6 +26,7 @@
#include <string>
#include <stdexcept>
#include <unistd.h>
#include <vector>
#include <stdlib.h>
#include <string.h>
#include <math.h>
@ -133,13 +134,11 @@ MMA7455::readData (short * ptrX, short * ptrY, short * ptrZ) {
return mraa::SUCCESS;
}
#ifdef SWIGJAVA
short *MMA7455::readData() {
short *v = new short[3];
std::vector<short> MMA7455::readData() {
std::vector<short> v(3);
readData(&v[0], &v[1], &v[2]);
return v;
}
#endif
int
MMA7455::i2cReadReg (unsigned char reg, uint8_t *buffer, int len) {

View File

@ -24,6 +24,7 @@
#pragma once
#include <string>
#include <vector>
#include <mraa/i2c.hpp>
#define ADDR 0x1D // device address
@ -208,14 +209,13 @@ class MMA7455 {
*/
mraa::Result 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
* @return std::vector containing X, Y, Z acceleration data
*/
short *readData ();
#endif
std::vector<short> readData ();
/**
* Internal function for reading I2C data
*