mirror of
https://github.com/eclipse/upm.git
synced 2025-07-26 21:51:16 +03:00
SWIG: Moved common SWIG syntax to ${libname}.i
This commit moves common SWIG syntax to a ${libname}.i for sensor libraries. Much of the swig content was originally duplicated for each wrapper language which has lead to inconsistencies between wrappers over time. This commit moves all swig syntax to a common file. Language specific swig syntax can be added with #ifdef SWIG<LANGUAGE>. The src/CMakeLists.txt will look first for a language-specific .i file, then fall back to ${libname}.i. In this way, it's possible to override the common ${libname}.i file. If a fallback .i file does NOT exist, UPM CMake will generate a simple interface file for all languages. Example: If no src/abp/pyupm_abp.i and no src/abp/abp.i then generate ${CMAKE_CURRENT_BINARY_DIR}/abp.i When src/CMakeLists.txt uses a common ${libname}.i, it adds a -module <language>upm_${libname} to the swig command line. In the example below, a -module argument is provided for both Java and Javascript, while the python module takes all syntax from pyupm_abp.i. SWIG FILE Language CMake added SWIG args --------------- ---------- --------------------- src/abp/abp.i java -module javaupm_abp src/abp/abp.i javascript -module jsupm_abp src/abp/pyupm_abp.i python This commit removes ~4500 redundant lines for the UPM repository and helps promote uniformity for the SWIG'ed languages. Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
56
src/bmg160/bmg160.i
Normal file
56
src/bmg160/bmg160.i
Normal file
@ -0,0 +1,56 @@
|
||||
%include "../common_top.i"
|
||||
|
||||
/* BEGIN Java syntax ------------------------------------------------------- */
|
||||
#ifdef SWIGJAVA
|
||||
%include "../upm_javastdvector.i"
|
||||
|
||||
%ignore installISR (BMG160_INTERRUPT_PINS_T , int mraa::Edge , void *, void *);
|
||||
%ignore getGyroscope(float *, float *, float *);
|
||||
|
||||
%typemap(javaimports) SWIGTYPE %{
|
||||
import java.util.AbstractList;
|
||||
import java.lang.Float;
|
||||
%}
|
||||
|
||||
%typemap(javaout) SWIGTYPE {
|
||||
return new $&javaclassname($jnicall, true);
|
||||
}
|
||||
%typemap(javaout) std::vector<float> {
|
||||
return (AbstractList<Float>)(new $&javaclassname($jnicall, true));
|
||||
}
|
||||
%typemap(jstype) std::vector<float> "AbstractList<Float>"
|
||||
|
||||
%template(floatVector) std::vector<float>;
|
||||
|
||||
%define INTERRUPT BMG160_INTERRUPT_PINS_T
|
||||
%enddef
|
||||
|
||||
JAVA_ADD_INSTALLISR_INTERRUPT(upm::BMG160)
|
||||
JAVA_JNI_LOADLIBRARY(javaupm_bmg160)
|
||||
#endif
|
||||
/* END Java syntax */
|
||||
|
||||
/* BEGIN Javascript syntax ------------------------------------------------- */
|
||||
#ifdef SWIGJAVASCRIPT
|
||||
%include "../upm_vectortypes.i"
|
||||
%pointer_functions(int, intp);
|
||||
%pointer_functions(float, floatp);
|
||||
#endif
|
||||
/* END Javascript syntax */
|
||||
|
||||
/* BEGIN Python syntax ----------------------------------------------------- */
|
||||
#ifdef SWIGPYTHON
|
||||
%include "../upm_vectortypes.i"
|
||||
%pointer_functions(int, intp);
|
||||
%pointer_functions(float, floatp);
|
||||
#endif
|
||||
/* END Python syntax */
|
||||
|
||||
/* BEGIN Common SWIG syntax ------------------------------------------------- */
|
||||
%{
|
||||
#include "bmg160_defs.h"
|
||||
#include "bmg160.hpp"
|
||||
%}
|
||||
%include "bmg160_defs.h"
|
||||
%include "bmg160.hpp"
|
||||
/* END Common SWIG syntax */
|
@ -1,37 +0,0 @@
|
||||
%module javaupm_bmg160
|
||||
%include "../upm.i"
|
||||
%include "typemaps.i"
|
||||
%include "../upm_javastdvector.i"
|
||||
|
||||
%ignore getGyroscope(float *, float *, float *);
|
||||
|
||||
%typemap(javaimports) SWIGTYPE %{
|
||||
import java.util.AbstractList;
|
||||
import java.lang.Float;
|
||||
%}
|
||||
|
||||
%typemap(javaout) SWIGTYPE {
|
||||
return new $&javaclassname($jnicall, true);
|
||||
}
|
||||
%typemap(javaout) std::vector<float> {
|
||||
return (AbstractList<Float>)(new $&javaclassname($jnicall, true));
|
||||
}
|
||||
%typemap(jstype) std::vector<float> "AbstractList<Float>"
|
||||
|
||||
%template(floatVector) std::vector<float>;
|
||||
|
||||
%{
|
||||
#include "bmg160.hpp"
|
||||
#include "bmg160_defs.h"
|
||||
%}
|
||||
%include "bmg160_defs.h"
|
||||
%include "bmg160.hpp"
|
||||
|
||||
|
||||
%ignore installISR (BMG160_INTERRUPT_PINS_T , int mraa::Edge , void *, void *);
|
||||
|
||||
%define INTERRUPT BMG160_INTERRUPT_PINS_T
|
||||
%enddef
|
||||
JAVA_ADD_INSTALLISR_INTERRUPT(upm::BMG160)
|
||||
|
||||
JAVA_JNI_LOADLIBRARY(javaupm_bmg160)
|
@ -1,14 +0,0 @@
|
||||
%module jsupm_bmg160
|
||||
%include "../upm.i"
|
||||
%include "cpointer.i"
|
||||
%include "../upm_vectortypes.i"
|
||||
|
||||
/* Send "int *" and "float *" to JavaScript as intp and floatp */
|
||||
%pointer_functions(int, intp);
|
||||
%pointer_functions(float, floatp);
|
||||
|
||||
%include "bmg160_defs.h"
|
||||
%include "bmg160.hpp"
|
||||
%{
|
||||
#include "bmg160.hpp"
|
||||
%}
|
@ -1,16 +0,0 @@
|
||||
// Include doxygen-generated documentation
|
||||
%include "pyupm_doxy2swig.i"
|
||||
%module pyupm_bmg160
|
||||
%include "../upm.i"
|
||||
%include "cpointer.i"
|
||||
%include "../upm_vectortypes.i"
|
||||
|
||||
/* Send "int *" and "float *" to python as intp and floatp */
|
||||
%pointer_functions(int, intp);
|
||||
%pointer_functions(float, floatp);
|
||||
|
||||
%include "bmg160_defs.h"
|
||||
%include "bmg160.hpp"
|
||||
%{
|
||||
#include "bmg160.hpp"
|
||||
%}
|
Reference in New Issue
Block a user