From 804c4a437d52696900d3cf5e5eda4a729a11a6ea Mon Sep 17 00:00:00 2001 From: Brendan Le Foll Date: Tue, 29 Apr 2014 18:44:09 +0100 Subject: [PATCH] javascript: fix swig generation of node.js api Signed-off-by: Brendan Le Foll --- api/gpio.h | 8 ++++++++ api/i2c.h | 8 ++++++++ api/maa.h | 8 ++++++++ api/pwm.h | 8 ++++++++ src/javascript/CMakeLists.txt | 3 ++- 5 files changed, 34 insertions(+), 1 deletion(-) diff --git a/api/gpio.h b/api/gpio.h index 0298779..0779d2f 100644 --- a/api/gpio.h +++ b/api/gpio.h @@ -24,6 +24,10 @@ * */ +#ifdef __cplusplus +extern "C" { +#endif + #include #include "maa.h" @@ -116,3 +120,7 @@ int maa_gpio_read(maa_gpio_context *dev); * @return maa result type */ maa_result_t maa_gpio_write(maa_gpio_context *dev, int value); + +#ifdef __cplusplus +} +#endif diff --git a/api/i2c.h b/api/i2c.h index e0c46cc..8ff156a 100644 --- a/api/i2c.h +++ b/api/i2c.h @@ -24,6 +24,10 @@ * */ +#ifdef __cplusplus +extern "C" { +#endif + #include #include #include @@ -116,3 +120,7 @@ void maa_i2c_address(maa_i2c_context* dev, int address); * @param dev the i2c context */ void maa_i2c_stop(maa_i2c_context* dev); + +#ifdef __cplusplus +} +#endif diff --git a/api/maa.h b/api/maa.h index fa0c5c3..fe4dd86 100644 --- a/api/maa.h +++ b/api/maa.h @@ -30,6 +30,10 @@ * */ +#ifdef __cplusplus +extern "C" { +#endif + typedef enum { MAA_SUCCESS = 0, MAA_ERROR_FEATURE_NOT_IMPLEMENTED = 1, @@ -52,3 +56,7 @@ typedef enum { * @return version string from version.h */ const char* maa_get_version(); + +#ifdef __cplusplus +} +#endif diff --git a/api/pwm.h b/api/pwm.h index 0c66f1e..54cce8e 100644 --- a/api/pwm.h +++ b/api/pwm.h @@ -24,6 +24,10 @@ * */ +#ifdef __cplusplus +extern "C" { +#endif + #include #include @@ -92,3 +96,7 @@ void maa_pwm_enable(maa_pwm_context* pwm, int enable); /** Close and unexport the PWM pin. */ void maa_pwm_close(maa_pwm_context* pwm); + +#ifdef __cplusplus +} +#endif diff --git a/src/javascript/CMakeLists.txt b/src/javascript/CMakeLists.txt index c8b6943..f6c3ef2 100644 --- a/src/javascript/CMakeLists.txt +++ b/src/javascript/CMakeLists.txt @@ -14,8 +14,9 @@ include_directories( ) SET_SOURCE_FILES_PROPERTIES(maajs.i PROPERTIES SWIG_FLAGS "-node") +SET_SOURCE_FILES_PROPERTIES(maajs.i PROPERTIES CPLUSPLUS ON) -SWIG_ADD_MODULE(maajs javascript ${maa_LIB_SRCS}) +SWIG_ADD_MODULE(maajs javascript maajs.i ${maa_LIB_SRCS}) SWIG_LINK_LIBRARIES(maajs ${NODE_LIBRARIES}) set_target_properties(maajs PROPERTIES