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

@ -4,44 +4,17 @@
%include "typemaps.i"
%include "arrays_java.i";
%include "../java_buffer.i"
%include "std_vector.i"
%template(IntVector) std::vector<int>;
%template(FloatVector) std::vector<float>;
%apply int *OUTPUT { int *x, int *y, int *z };
%apply float *OUTPUT { float *ax, float *ay, float *az };
%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);
}
%typemap(jni) int* "jintArray"
%typemap(jstype) int* "int[]"
%typemap(jtype) int* "int[]"
%typemap(javaout) int* {
return $jnicall;
}
%typemap(out) int *getRawValues {
$result = JCALL1(NewIntArray, jenv, 3);
JCALL4(SetIntArrayRegion, jenv, $result, 0, 3, (const signed int*)$1);
}
%ignore getRawValues(int *, int *, int *);
%ignore getAcceleration(float *, float *, float *);
%{
#include "mma7660.hpp"
#include "mma7660_regs.h"
#include "mma7660.hpp"
#include "mma7660_regs.h"
%}
%include "mma7660_regs.h"
%include "mma7660.hpp"

View File

@ -23,7 +23,9 @@
*/
#pragma once
#include <mma7660.h>
#include <vector>
#include "mma7660.h"
namespace upm {
@ -197,17 +199,16 @@ namespace upm {
*/
bool setSampleRate(MMA7660_AUTOSLEEP_T sr);
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
/**
* Reads the current acceleration values. The returned memory
* is statically allocated and will be overwritten on each
* call.
*
* @return Array containing x, y, z.
* @return std::vector containing x, y, z.
*/
float *getAcceleration()
std::vector<float> getAcceleration()
{
static float values[3];
std::vector<float> values(3);
getAcceleration(&values[0], &values[1], &values[2]);
return values;
}
@ -217,15 +218,15 @@ namespace upm {
* is statically allocated and will be overwritten on each
* call.
*
* @return Array containing x, y, z.
* @return std::vector containing x, y, z.
*/
int *getRawValues()
std::vector<int> getRawValues()
{
static int values[3];
std::vector<int> values(3);
getRawValues(&values[0], &values[1], &values[2]);
return values;
}
#endif
/**
* Installs an interrupt service routine (ISR) to be called when
* an interrupt occurs