From ef225dbe26efd4a9333d61ecf884273dd45225c7 Mon Sep 17 00:00:00 2001 From: Brendan Le Foll Date: Tue, 13 May 2014 20:55:08 +0000 Subject: [PATCH] swig: fix usage of SWIGPYTHON for python specific code Signed-off-by: Brendan Le Foll --- api/gpio.h | 4 ++-- src/CMakeLists.txt | 2 ++ src/gpio/gpio.c | 4 ++-- src/maa.c | 2 +- src/python/CMakeLists.txt | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/api/gpio.h b/api/gpio.h index 594a84c..eaa7de2 100644 --- a/api/gpio.h +++ b/api/gpio.h @@ -34,7 +34,7 @@ extern "C" { #endif -#ifdef SWIG +#ifdef SWIGPYTHON #include #endif @@ -50,7 +50,7 @@ typedef struct { /*@{*/ int pin; /**< the pin number, as known to the os. */ int value_fp; /**< the file pointer to the value of the gpio */ -#ifdef SWIG +#ifdef SWIGPYTHON PyObject *isr; /**< the interupt service request */ #else void (* isr)(); /**< the interupt service request */ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index faa5c4b..c42ca0e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -71,6 +71,8 @@ endif () find_package (SWIG) if (SWIG_FOUND) + set (CMAKE_C_FLAGS -DSWIG=${SWIG_FOUND}) + set (CMAKE_CXX_CFLAGS -DSWIG=${SWIG_FOUND}) include (${SWIG_USE_FILE}) add_subdirectory (python) diff --git a/src/gpio/gpio.c b/src/gpio/gpio.c index e2fd9fd..4a93d71 100644 --- a/src/gpio/gpio.c +++ b/src/gpio/gpio.c @@ -124,7 +124,7 @@ maa_gpio_interrupt_handler(void* arg) for (;;) { ret = maa_gpio_wait_interrupt(dev->isr_value_fp); if (ret == MAA_SUCCESS) { -#ifdef SWIG +#ifdef SWIGPYTHON // 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 // 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; -#ifdef SWIG +#ifdef SWIGPYTHON // Dereference our Python call back function Py_DECREF(dev->isr); #endif diff --git a/src/maa.c b/src/maa.c index 37987c0..70b39f6 100644 --- a/src/maa.c +++ b/src/maa.c @@ -55,7 +55,7 @@ maa_init() if (plat != NULL) { return MAA_ERROR_PLATFORM_ALREADY_INITIALISED; } -#ifdef SWIG +#ifdef SWIGPYTHON // Initialise python threads, this allows use to grab the GIL when we are // required to do so Py_InitializeEx(0); diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt index ac43c5b..45f355f 100644 --- a/src/python/CMakeLists.txt +++ b/src/python/CMakeLists.txt @@ -9,7 +9,7 @@ include_directories( swig_add_module (pymaa python pymaa.i ${maa_LIB_SRCS}) swig_link_libraries (pymaa ${PYTHON_LIBRARIES}) -set (CMAKE_C_FLAGS -DSWIG=${SWIG_FOUND}) +set (CMAKE_C_FLAGS -DSWIGPYTHON=${SWIG_FOUND}) if (DOXYGEN_FOUND) foreach (_file ${DOCFILES}) -- 2.7.4