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

@ -46,22 +46,33 @@ sig_handler(int signo)
}
//! [Interesting]
void
nrf_handler()
class mycb : public virtual Callback
{
std::cout << "Reciever :: " << *((uint32_t*) &(comm.m_rxBuffer[0])) << std::endl;
}
public:
mycb(upm::NRF24L01 *com) : _com(com) {}
virtual void run()
{
if (_com != NULL)
std::cout << "Reciever :: " << *((uint32_t*) &(_com->m_rxBuffer[0])) << std::endl;
else
std::cout << "Example callback!" << std::endl;
}
private:
upm::NRF24L01* _com;
};
int
main(int argc, char** argv)
{
mycb cb(&comm);
comm.setSourceAddress((uint8_t*) local_address);
comm.setDestinationAddress((uint8_t*) broadcast_address);
comm.setPayload(MAX_BUFFER);
comm.configure();
comm.setSpeedRate(upm::NRF_250KBPS);
comm.setChannel(99);
comm.setDataReceivedHandler(nrf_handler);
comm.setDataReceivedHandler(&cb);
signal(SIGINT, sig_handler);

View File

@ -46,10 +46,21 @@ sig_handler(int signo)
}
}
void
nrf_handler()
class mycb : public virtual Callback
{
}
public:
mycb(upm::NRF24L01 *com) : _com(com) {}
virtual void run()
{
if (_com != NULL)
std::cout << "Reciever :: " << *((uint32_t*) &(_com->m_rxBuffer[0])) << std::endl;
else
std::cout << "Example callback!" << std::endl;
}
private:
upm::NRF24L01* _com;
};
int
main(int argc, char** argv)
@ -57,12 +68,14 @@ main(int argc, char** argv)
//! [Interesting]
uint32_t dummyData = 0;
upm::NRF24L01 comm(7, 8);
mycb cb(&comm);
comm.setSourceAddress((uint8_t*) srcAddress);
comm.setDestinationAddress((uint8_t*) destAddress);
comm.setPayload(MAX_BUFFER);
comm.setChannel(99);
comm.configure();
comm.setDataReceivedHandler(nrf_handler);
comm.setDataReceivedHandler(&cb);
signal(SIGINT, sig_handler);

View File

@ -42,17 +42,24 @@ sig_handler(int signo)
}
}
void
handler(clbk_data data)
//! [Interesting]
class mycb : public virtual Callback
{
printf("callback data (%d)\n", data.is_heart_beat);
}
public:
virtual void run(clbk_data arg)
{
printf("callback data (%d)\n", arg.is_heart_beat);
}
};
int
main(int argc, char** argv)
{
mycb cb;
//! [Interesting]
Pulsensor sensor(handler);
Pulsensor sensor(&cb);
sensor.start_sampler();
while (!doWork) {