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

@ -1,6 +1,5 @@
#pragma once
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
class Callback
{
public:
@ -11,5 +10,3 @@ class Callback
{ /* empty, overloaded in Java*/
}
};
#endif

View File

@ -32,7 +32,6 @@
using namespace upm;
#if defined(JAVACALLBACK)
Pulsensor::Pulsensor (Callback *obj_call) : pin_ctx(0)
{
obj_callback = obj_call;
@ -49,24 +48,6 @@ Pulsensor::Pulsensor (Callback *obj_call) : pin_ctx(0)
qs = FALSE;
apmlitude = 100;
}
#else
Pulsensor::Pulsensor (callback_handler handler) : pin_ctx(0)
{
callback = handler;
sample_counter = 0;
last_beat_time = 0;
threshold = 512;
ibi = 600;
trough = 512;
peak = 512;
is_pulse = FALSE;
ret = FALSE;
bpm = 0;
qs = FALSE;
apmlitude = 100;
}
#endif
void Pulsensor::start_sampler ()
{
@ -114,11 +95,8 @@ void *Pulsensor::do_sample (void *arg) {
(pulsensor->is_pulse == FALSE) &&
(N > (pulsensor->ibi / 5)* 3) ) {
pulsensor->is_pulse = callback_data.is_heart_beat = TRUE;
#if defined(JAVACALLBACK)
pulsensor->obj_callback->run(callback_data);
#else
pulsensor->callback(callback_data);
#endif
pulsensor->ibi = pulsensor->sample_counter - pulsensor->last_beat_time;
pulsensor->last_beat_time = pulsensor->sample_counter;
@ -156,11 +134,9 @@ void *Pulsensor::do_sample (void *arg) {
if (data_from_sensor < pulsensor->threshold &&
pulsensor->is_pulse == TRUE) {
pulsensor->is_pulse = callback_data.is_heart_beat = FALSE;
#if defined(JAVACALLBACK)
pulsensor->obj_callback->run(callback_data);
#else
pulsensor->callback(callback_data);
#endif
pulsensor->is_pulse = FALSE;
pulsensor->apmlitude = pulsensor->peak - pulsensor->trough;
pulsensor->threshold = pulsensor->apmlitude / 2 + pulsensor->trough;

View File

@ -47,11 +47,7 @@ struct clbk_data {
int is_heart_beat; /**< heartbeat check */
};
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
#include "Callback.hpp"
#else
typedef void (* callback_handler) (clbk_data);
#endif
namespace upm {
/**
@ -80,11 +76,8 @@ namespace upm {
class Pulsensor {
public:
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
Pulsensor(Callback *callback);
#else
Pulsensor(callback_handler handler);
#endif
void start_sampler();
void stop_sampler();
@ -106,11 +99,8 @@ private:
uint8_t second_beat; /**< Second heartbeat */
uint8_t ret; /**< Return value */
mraa::Aio pin_ctx; /**< The pin context */
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
Callback *obj_callback; /**< The callback object */
#else
callback_handler callback; /**< The callback function */
#endif
volatile uint16_t ctx_counter;
};
}