swig: fix usage of SWIGPYTHON for python specific code
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
@@ -34,7 +34,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SWIG
|
#ifdef SWIGPYTHON
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ typedef struct {
|
|||||||
/*@{*/
|
/*@{*/
|
||||||
int pin; /**< the pin number, as known to the os. */
|
int pin; /**< the pin number, as known to the os. */
|
||||||
int value_fp; /**< the file pointer to the value of the gpio */
|
int value_fp; /**< the file pointer to the value of the gpio */
|
||||||
#ifdef SWIG
|
#ifdef SWIGPYTHON
|
||||||
PyObject *isr; /**< the interupt service request */
|
PyObject *isr; /**< the interupt service request */
|
||||||
#else
|
#else
|
||||||
void (* isr)(); /**< the interupt service request */
|
void (* isr)(); /**< the interupt service request */
|
||||||
|
|||||||
@@ -71,6 +71,8 @@ endif ()
|
|||||||
|
|
||||||
find_package (SWIG)
|
find_package (SWIG)
|
||||||
if (SWIG_FOUND)
|
if (SWIG_FOUND)
|
||||||
|
set (CMAKE_C_FLAGS -DSWIG=${SWIG_FOUND})
|
||||||
|
set (CMAKE_CXX_CFLAGS -DSWIG=${SWIG_FOUND})
|
||||||
include (${SWIG_USE_FILE})
|
include (${SWIG_USE_FILE})
|
||||||
|
|
||||||
add_subdirectory (python)
|
add_subdirectory (python)
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ maa_gpio_interrupt_handler(void* arg)
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
ret = maa_gpio_wait_interrupt(dev->isr_value_fp);
|
ret = maa_gpio_wait_interrupt(dev->isr_value_fp);
|
||||||
if (ret == MAA_SUCCESS) {
|
if (ret == MAA_SUCCESS) {
|
||||||
#ifdef SWIG
|
#ifdef SWIGPYTHON
|
||||||
// In order to call a python object (all python functions are objects) we
|
// In order to call a python object (all python functions are objects) we
|
||||||
// need to aquire the GIL (Global Interpreter Lock). This may not always be
|
// need to aquire the GIL (Global Interpreter Lock). This may not always be
|
||||||
// nessecary but especially if doing IO (like print()) python will segfault
|
// nessecary but especially if doing IO (like print()) python will segfault
|
||||||
@@ -202,7 +202,7 @@ maa_gpio_isr_exit(maa_gpio_context *dev)
|
|||||||
{
|
{
|
||||||
maa_result_t ret = MAA_SUCCESS;
|
maa_result_t ret = MAA_SUCCESS;
|
||||||
|
|
||||||
#ifdef SWIG
|
#ifdef SWIGPYTHON
|
||||||
// Dereference our Python call back function
|
// Dereference our Python call back function
|
||||||
Py_DECREF(dev->isr);
|
Py_DECREF(dev->isr);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ maa_init()
|
|||||||
if (plat != NULL) {
|
if (plat != NULL) {
|
||||||
return MAA_ERROR_PLATFORM_ALREADY_INITIALISED;
|
return MAA_ERROR_PLATFORM_ALREADY_INITIALISED;
|
||||||
}
|
}
|
||||||
#ifdef SWIG
|
#ifdef SWIGPYTHON
|
||||||
// Initialise python threads, this allows use to grab the GIL when we are
|
// Initialise python threads, this allows use to grab the GIL when we are
|
||||||
// required to do so
|
// required to do so
|
||||||
Py_InitializeEx(0);
|
Py_InitializeEx(0);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ include_directories(
|
|||||||
swig_add_module (pymaa python pymaa.i ${maa_LIB_SRCS})
|
swig_add_module (pymaa python pymaa.i ${maa_LIB_SRCS})
|
||||||
swig_link_libraries (pymaa ${PYTHON_LIBRARIES})
|
swig_link_libraries (pymaa ${PYTHON_LIBRARIES})
|
||||||
|
|
||||||
set (CMAKE_C_FLAGS -DSWIG=${SWIG_FOUND})
|
set (CMAKE_C_FLAGS -DSWIGPYTHON=${SWIG_FOUND})
|
||||||
|
|
||||||
if (DOXYGEN_FOUND)
|
if (DOXYGEN_FOUND)
|
||||||
foreach (_file ${DOCFILES})
|
foreach (_file ${DOCFILES})
|
||||||
|
|||||||
Reference in New Issue
Block a user