common.hpp: use common.hpp instead of renaming C functions in interface
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
@@ -30,6 +30,7 @@
|
|||||||
namespace mraa {
|
namespace mraa {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @file
|
||||||
* @brief C++ API to common functions of MRAA
|
* @brief C++ API to common functions of MRAA
|
||||||
*
|
*
|
||||||
* This file defines the C++ interface for libmraa common functions
|
* This file defines the C++ interface for libmraa common functions
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ functionality.
|
|||||||
| @ref aio.h "aio" | @ref mraa::Aio "Aio class" |
|
| @ref aio.h "aio" | @ref mraa::Aio "Aio class" |
|
||||||
| @ref pwm.h "pwm" | @ref mraa::Pwm "Pwm class" |
|
| @ref pwm.h "pwm" | @ref mraa::Pwm "Pwm class" |
|
||||||
| @ref spi.h "spi" | @ref mraa::Spi "Spi class" |
|
| @ref spi.h "spi" | @ref mraa::Spi "Spi class" |
|
||||||
| @ref common.h "common" | @ref common.h "common" |
|
| @ref common.h "common" | @ref common.hpp "common" |
|
||||||
</center>
|
</center>
|
||||||
|
|
||||||
### Hello Mraa
|
### Hello Mraa
|
||||||
|
|||||||
@@ -60,8 +60,10 @@ int main (int argc, char **argv)
|
|||||||
return MRAA_ERROR_UNSPECIFIED;
|
return MRAA_ERROR_UNSPECIFIED;
|
||||||
}
|
}
|
||||||
int response = gpio->dir(mraa::DIR_OUT);
|
int response = gpio->dir(mraa::DIR_OUT);
|
||||||
if (response != MRAA_SUCCESS)
|
if (response != MRAA_SUCCESS) {
|
||||||
mraa_result_print((mraa_result_t) MRAA_SUCCESS);
|
mraa::printError(response);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
while (running == 0) {
|
while (running == 0) {
|
||||||
response = gpio->write(1);
|
response = gpio->write(1);
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ install (TARGETS mraa DESTINATION lib)
|
|||||||
if (DOXYGEN_FOUND)
|
if (DOXYGEN_FOUND)
|
||||||
set (CMAKE_SWIG_FLAGS -DDOXYGEN=${DOXYGEN_FOUND})
|
set (CMAKE_SWIG_FLAGS -DDOXYGEN=${DOXYGEN_FOUND})
|
||||||
set (DOCCLASSES aio gpio i2c pwm spi)
|
set (DOCCLASSES aio gpio i2c pwm spi)
|
||||||
|
# CPP class headers
|
||||||
foreach (_file ${DOCCLASSES})
|
foreach (_file ${DOCCLASSES})
|
||||||
add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}_class_doc.i
|
add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}_class_doc.i
|
||||||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/doxy2swig.py -n
|
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/doxy2swig.py -n
|
||||||
@@ -56,6 +57,7 @@ if (DOXYGEN_FOUND)
|
|||||||
add_custom_target (${_file}class_doc_i DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_file}_class_doc.i)
|
add_custom_target (${_file}class_doc_i DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_file}_class_doc.i)
|
||||||
add_dependencies (${_file}class_doc_i doc)
|
add_dependencies (${_file}class_doc_i doc)
|
||||||
endforeach ()
|
endforeach ()
|
||||||
|
# C header files
|
||||||
set (DOCFILES common ${DOCCLASSES})
|
set (DOCFILES common ${DOCCLASSES})
|
||||||
foreach (_file ${DOCFILES})
|
foreach (_file ${DOCFILES})
|
||||||
add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}_doc.i
|
add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}_doc.i
|
||||||
@@ -67,6 +69,15 @@ if (DOXYGEN_FOUND)
|
|||||||
add_custom_target (${_file}doc_i DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_file}_doc.i)
|
add_custom_target (${_file}doc_i DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_file}_doc.i)
|
||||||
add_dependencies (${_file}doc_i doc)
|
add_dependencies (${_file}doc_i doc)
|
||||||
endforeach ()
|
endforeach ()
|
||||||
|
# CPP common header
|
||||||
|
add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/common_hpp_doc.i
|
||||||
|
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/doxy2swig.py -n
|
||||||
|
${CMAKE_BINARY_DIR}/xml/common_8hpp.xml
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}//common_hpp_doc.i
|
||||||
|
DEPENDS ${CMAKE_BINARY_DIR}/xml/common_8hpp.xml
|
||||||
|
)
|
||||||
|
add_custom_target (common_hpp_doc_i DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/common_hpp_doc.i)
|
||||||
|
add_dependencies (common_hpp_doc_i doc)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (BUILDSWIG)
|
if (BUILDSWIG)
|
||||||
|
|||||||
15
src/mraa.i
15
src/mraa.i
@@ -1,7 +1,8 @@
|
|||||||
%include stdint.i
|
%include stdint.i
|
||||||
|
%include std_string.i
|
||||||
|
|
||||||
#ifdef DOXYGEN
|
#ifdef DOXYGEN
|
||||||
%include common_doc.i
|
%include common_hpp_doc.i
|
||||||
%include gpio_class_doc.i
|
%include gpio_class_doc.i
|
||||||
%include i2c_class_doc.i
|
%include i2c_class_doc.i
|
||||||
%include pwm_class_doc.i
|
%include pwm_class_doc.i
|
||||||
@@ -10,7 +11,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
%{
|
%{
|
||||||
#include "common.h"
|
#include "common.hpp"
|
||||||
#include "gpio.hpp"
|
#include "gpio.hpp"
|
||||||
#include "pwm.hpp"
|
#include "pwm.hpp"
|
||||||
#include "i2c.hpp"
|
#include "i2c.hpp"
|
||||||
@@ -23,18 +24,12 @@
|
|||||||
mraa_init();
|
mraa_init();
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%rename(getVersion) mraa_get_version;
|
|
||||||
|
|
||||||
%rename(setPriority) mraa_set_priority;
|
|
||||||
|
|
||||||
%rename(printError) mraa_result_print(mraa_result_t error);
|
|
||||||
|
|
||||||
%rename(getPlatform) mraa_get_platform_type;
|
|
||||||
|
|
||||||
%typemap(in) uint8_t = char;
|
%typemap(in) uint8_t = char;
|
||||||
%typemap(in) unsigned char* = char*;
|
%typemap(in) unsigned char* = char*;
|
||||||
%apply (char *STRING, size_t LENGTH) { (char *data, size_t length) };
|
%apply (char *STRING, size_t LENGTH) { (char *data, size_t length) };
|
||||||
|
|
||||||
|
%include "common.hpp"
|
||||||
|
|
||||||
%include "types.h"
|
%include "types.h"
|
||||||
|
|
||||||
#### GPIO ####
|
#### GPIO ####
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ if (DOXYGEN_FOUND)
|
|||||||
foreach (_file ${DOCCLASSES})
|
foreach (_file ${DOCCLASSES})
|
||||||
add_dependencies (${SWIG_MODULE_python-mraa_REAL_NAME} ${_file}class_doc_i)
|
add_dependencies (${SWIG_MODULE_python-mraa_REAL_NAME} ${_file}class_doc_i)
|
||||||
endforeach ()
|
endforeach ()
|
||||||
add_dependencies (${SWIG_MODULE_python-mraa_REAL_NAME} commondoc_i)
|
add_dependencies (${SWIG_MODULE_python-mraa_REAL_NAME} common_hpp_doc_i)
|
||||||
|
|
||||||
add_custom_target (pydoc
|
add_custom_target (pydoc
|
||||||
pydoc -w ${CMAKE_CURRENT_BINARY_DIR}/mraa.py ${CMAKE_CURRENT_BINARY_DIR}/
|
pydoc -w ${CMAKE_CURRENT_BINARY_DIR}/mraa.py ${CMAKE_CURRENT_BINARY_DIR}/
|
||||||
|
|||||||
Reference in New Issue
Block a user