java: Eliminated double definition of SWIGJAVA and the need for "#undefine SWIGJAVA"

Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>

Conflicts:
	src/CMakeLists.txt
This commit is contained in:
Stefan Andritoiu 2015-09-14 18:10:12 +03:00 committed by Mihai Tudor Panu
parent f991bcf915
commit ef74a7b137
28 changed files with 34 additions and 144 deletions

View File

@ -74,7 +74,7 @@ macro(upm_SWIG_JAVA)
"${JAVA_INCLUDE_PATH}"
)
set_target_properties (javaupm_${libname} PROPERTIES
COMPILE_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive"
COMPILE_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive -DJAVACALLBACK"
PREFIX "lib"
SUFFIX ".so"
)

View File

@ -1,6 +1,6 @@
#pragma once
#ifdef SWIGJAVA
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
class IsrCallback
{
public:

View File

@ -54,7 +54,7 @@ bool A110X::magnetDetected()
return (!mraa_gpio_read(m_gpio) ? true : false);
}
#ifdef SWIGJAVA
#ifdef JAVACALLBACK
void A110X::installISR( IsrCallback *cb)
{
installISR(generic_callback_isr, cb);

View File

@ -26,7 +26,7 @@
#include <string>
#include <mraa/gpio.h>
#ifdef SWIGJAVA
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
#include "../IsrCallback.h"
#endif
@ -89,7 +89,7 @@ namespace upm {
* @param arg Pointer to an object to be supplied as an
* argument to the ISR.
*/
#ifdef SWIGJAVA
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
void installISR(IsrCallback *cb);
#else
void installISR(void (*isr)(void *), void *arg);
@ -101,7 +101,7 @@ namespace upm {
void uninstallISR();
private:
#ifdef SWIGJAVA
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
void installISR(void (*isr)(void *), void *arg);
#endif

View File

@ -26,13 +26,7 @@
#include <stdint.h>
#include <sys/time.h>
#ifdef SWIGJAVA
#undef SWIGJAVA
#include <mraa/gpio.hpp>
#define SWIGJAVA
#else
#include <mraa/gpio.hpp>
#endif
#include <mraa/aio.hpp>

View File

@ -30,14 +30,7 @@
#include <mraa/aio.hpp>
#include <mraa/common.hpp>
#ifdef SWIGJAVA
#undef SWIGJAVA
#include <mraa/gpio.hpp>
#define SWIGJAVA
#else
#include <mraa/gpio.hpp>
#endif
#define MAX_BIT_PER_BLOCK 16
#define CMDMODE 0x0000

View File

@ -31,7 +31,7 @@
using namespace upm;
#ifdef SWIGJAVA
#ifdef JAVACALLBACK
HCSR04::HCSR04 (uint8_t triggerPin, uint8_t echoPin, IsrCallback *cb)
{
HCSR04 (triggerPin, echoPin, generic_callback_isr);

View File

@ -29,7 +29,7 @@
#include <mraa/pwm.h>
#include <sys/time.h>
#ifdef SWIGJAVA
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
#include "../IsrCallback.h"
#endif
@ -62,8 +62,8 @@ namespace upm {
*/
class HCSR04 {
public:
#ifdef SWIGJAVA
HCSR04 (uint8_t triggerPin, uint8_t echoPin, IsrCallback *cb);
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
HCSR04 (uint8_t triggerPin, uint8_t echoPin, IsrCallback *cb);
#else
/**
* Instantiates an HCSR04 object
@ -103,7 +103,7 @@ class HCSR04 {
}
private:
#ifdef SWIGJAVA
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
HCSR04 (uint8_t triggerPin, uint8_t echoPin, void (*fptr)(void *));
#endif
mraa_pwm_context m_pwmTriggerCtx;

View File

@ -26,13 +26,7 @@
#include <string>
#include <mraa/spi.hpp>
#ifdef SWIGJAVA
#undef SWIGJAVA
#include <mraa/gpio.hpp>
#define SWIGJAVA
#else
#include <mraa/gpio.hpp>
#endif
#include "lcd.h"
#include "ssd.h"

View File

@ -35,14 +35,7 @@
#include <string>
#include <mraa/i2c.hpp>
#ifdef SWIGJAVA
#undef SWIGJAVA
#include <mraa/gpio.hpp>
#define SWIGJAVA
#else
#include <mraa/gpio.hpp>
#endif
#include "lcd.h"

View File

@ -26,14 +26,7 @@
#include <string>
#include <mraa/aio.hpp>
#ifdef SWIGJAVA
#undef SWIGJAVA
#include <mraa/gpio.hpp>
#define SWIGJAVA
#else
#include <mraa/gpio.hpp>
#endif
#include <mraa/spi.hpp>

View File

@ -602,7 +602,7 @@ void LSM9DS0::getMagnetometer(float *x, float *y, float *z)
*z = (m_magZ * m_magScale) / 1000.0;
}
#ifdef SWIGJAVA
#ifdef JAVACALLBACK
float *LSM9DS0::getAccelerometer()
{
float *v = new float[3];

View File

@ -27,19 +27,12 @@
#include <mraa/common.hpp>
#include <mraa/i2c.hpp>
#ifdef SWIGJAVA
#undef SWIGJAVA
#include <mraa/gpio.hpp>
#define SWIGJAVA
#else
#include <mraa/gpio.hpp>
#endif
#ifdef SWIGJAVA
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
#include "../IsrCallback.h"
#endif
#define LSM9DS0_I2C_BUS 1
#define LSM9DS0_DEFAULT_XM_ADDR 0x1d
#define LSM9DS0_DEFAULT_GYRO_ADDR 0x6b
@ -1268,7 +1261,7 @@ namespace upm {
*/
void getMagnetometer(float *x, float *y, float *z);
#ifdef SWIGJAVA
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
/**
* get the accelerometer values in gravities
*
@ -1418,7 +1411,7 @@ namespace upm {
*/
uint8_t getInterruptGen2Src();
#ifdef SWIGJAVA
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
void installISR(INTERRUPT_PINS_T intr, int gpio, mraa::Edge level,
IsrCallback *cb);
#else
@ -1471,7 +1464,7 @@ namespace upm {
private:
// OR'd with a register, this enables register autoincrement mode,
// which we need.
#ifdef SWIGJAVA
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
void installISR(INTERRUPT_PINS_T intr, int gpio, mraa::Edge level,
void (*isr)(void *), void *arg);
#endif

View File

@ -26,14 +26,7 @@
#include <string>
#include <mraa/aio.hpp>
#ifdef SWIGJAVA
#undef SWIGJAVA
#include <mraa/gpio.hpp>
#define SWIGJAVA
#else
#include <mraa/gpio.hpp>
#endif
#include <mraa/spi.hpp>

View File

@ -26,15 +26,7 @@
#include <string>
#include <mraa/aio.hpp>
#ifdef SWIGJAVA
#undef SWIGJAVA
#include <mraa/gpio.hpp>
#define SWIGJAVA
#else
#include <mraa/gpio.hpp>
#endif
#include <mraa/spi.hpp>
#define HIGH 1

View File

@ -88,7 +88,7 @@ void MMA7660::getRawValues(int *x, int *y, int *z)
*z = getVerifiedAxis(REG_ZOUT);
}
#ifdef SWIGJAVA
#ifdef JAVACALLBACK
int *MMA7660::getRawValues()
{
int *values = new int[3];
@ -204,7 +204,7 @@ bool MMA7660::tiltShake()
return false;
}
#ifdef SWIGJAVA
#ifdef JAVACALLBACK
void MMA7660::installISR(int pin, IsrCallback *cb)
{
installISR(pin, generic_callback_isr, cb);
@ -263,7 +263,7 @@ void MMA7660::getAcceleration(float *ax, float *ay, float *az)
*az = z/21.33;
}
#ifdef SWIGJAVA
#ifdef JAVACALLBACK
float *MMA7660::getAcceleration()
{
float *values = new float[3];

View File

@ -27,7 +27,7 @@
#include <mraa/i2c.h>
#include <mraa/gpio.h>
#ifdef SWIGJAVA
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
#include "../IsrCallback.h"
#endif
@ -169,7 +169,7 @@ namespace upm {
*/
void getRawValues(int *x, int *y, int *z);
#ifdef SWIGJAVA
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
/**
* Reads the current value of conversion
*
@ -187,7 +187,7 @@ namespace upm {
*/
void getAcceleration(float *ax, float *ay, float *az);
#ifdef SWIGJAVA
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
/**
* Gets the computed acceleration
*
@ -270,7 +270,7 @@ namespace upm {
* @param arg Pointer to an object to be supplied as an
* argument to the ISR.
*/
#ifdef SWIGJAVA
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
void installISR(int pin, IsrCallback *cb);
#else
void installISR(int pin, void (*isr)(void *), void *arg);
@ -301,7 +301,7 @@ namespace upm {
bool setSampleRate(MMA7660_AUTOSLEEP_T sr);
private:
#ifdef SWIGJAVA
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
void installISR(int pin, void (*isr)(void *), void *arg);
#endif

View File

@ -380,7 +380,7 @@ uint8_t MPU60X0::getInterruptPinConfig()
return readReg(REG_INT_PIN_CFG);
}
#ifdef SWIGJAVA
#ifdef JAVACALLBACK
void MPU60X0::installISR(int gpio, mraa::Edge level,
IsrCallback *cb)
{

View File

@ -27,15 +27,9 @@
#include <mraa/common.hpp>
#include <mraa/i2c.hpp>
#ifdef SWIGJAVA
#undef SWIGJAVA
#include <mraa/gpio.hpp>
#define SWIGJAVA
#else
#include <mraa/gpio.hpp>
#endif
#ifdef SWIGJAVA
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
#include "../IsrCallback.h"
#endif
@ -809,7 +803,7 @@ namespace upm {
*/
void getGyroscope(float *x, float *y, float *z);
#ifdef SWIGJAVA
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
/**
* get the accelerometer values
*
@ -926,7 +920,7 @@ namespace upm {
* @param isr the interrupt handler, accepting a void * argument
* @param arg the argument to pass the the interrupt handler
*/
#ifdef SWIGJAVA
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
void installISR(int gpio, mraa::Edge level, IsrCallback *cb);
#else
void installISR(int gpio, mraa::Edge level, void (*isr)(void *), void *arg);
@ -957,7 +951,7 @@ namespace upm {
float m_gyroScale;
private:
#ifdef SWIGJAVA
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
void installISR(int gpio, mraa::Edge level, void (*isr)(void *), void *arg);
#endif

View File

@ -27,14 +27,7 @@
#include <mraa/aio.hpp>
#include <mraa/common.hpp>
#ifdef SWIGJAVA
#undef SWIGJAVA
#include <mraa/gpio.hpp>
#define SWIGJAVA
#else
#include <mraa/gpio.hpp>
#endif
#define MAX_BIT_PER_BLOCK 16
#define CMDMODE 0x0000

View File

@ -28,14 +28,7 @@
#include <mraa/aio.hpp>
#include <mraa/common.hpp>
#ifdef SWIGJAVA
#undef SWIGJAVA
#include <mraa/gpio.hpp>
#define SWIGJAVA
#else
#include <mraa/gpio.hpp>
#endif
#include <mraa/spi.hpp>
#include <cstring>

View File

@ -34,14 +34,7 @@
#include <mraa/common.hpp>
#include <mraa/i2c.hpp>
#ifdef SWIGJAVA
#undef SWIGJAVA
#include <mraa/gpio.hpp>
#define SWIGJAVA
#else
#include <mraa/gpio.hpp>
#endif
#define PN532_I2C_BUS 0
#define PN532_DEFAULT_I2C_ADDR (0x48 >> 1)

View File

@ -28,13 +28,7 @@
#include <stdint.h>
#include <unistd.h>
#ifdef SWIGJAVA
#undef SWIGJAVA
#include <mraa/gpio.hpp>
#define SWIGJAVA
#else
#include <mraa/gpio.hpp>
#endif
#include <mraa/pwm.hpp>

View File

@ -26,7 +26,6 @@
#include "rpr220.h"
using namespace upm;
using namespace std;
@ -56,10 +55,10 @@ bool RPR220::blackDetected()
return (mraa_gpio_read(m_gpio) ? true : false);
}
#ifdef SWIGJAVA
#ifdef JAVACALLBACK
void RPR220::installISR(IsrCallback *cb)
{
installISR(generic_callback_isr, cb);
installISR(generic_callback_isr, cb);
}
#endif

View File

@ -26,7 +26,7 @@
#include <string>
#include <mraa/gpio.h>
#ifdef SWIGJAVA
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
#include "../IsrCallback.h"
#endif
@ -87,7 +87,7 @@ namespace upm {
*/
bool blackDetected();
#ifdef SWIGJAVA
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
void installISR(IsrCallback *cb);
#else
/**
@ -108,7 +108,7 @@ namespace upm {
void uninstallISR();
private:
#ifdef SWIGJAVA
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
void installISR(void (*isr)(void *), void *arg);
#endif
bool m_isrInstalled;

View File

@ -28,14 +28,7 @@
#include <unistd.h>
#include <stdint.h>
#ifdef SWIGJAVA
#undef SWIGJAVA
#include <mraa.hpp>
#define SWIGJAVA
#else
#include <mraa.hpp>
#endif
#define swap(a, b) { int16_t t = a; a = b; b = t; }

View File

@ -30,14 +30,7 @@
#include <mraa/aio.hpp>
#include <mraa/common.hpp>
#ifdef SWIGJAVA
#undef SWIGJAVA
#include <mraa/gpio.hpp>
#define SWIGJAVA
#else
#include <mraa/gpio.hpp>
#endif
#include <mraa/spi.hpp>
#include <gfx.h>

View File

@ -32,14 +32,7 @@
#include <mraa/aio.hpp>
#include <mraa/common.hpp>
#ifdef SWIGJAVA
#undef SWIGJAVA
#include <mraa/gpio.hpp>
#define SWIGJAVA
#else
#include <mraa/gpio.hpp>
#endif
#define MIN_PERIOD 500
#define MAX_PERIOD 1000