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:
Noel Eck
2018-01-26 11:52:34 -08:00
parent 3d674efb51
commit 20aa4962f0
809 changed files with 3421 additions and 8069 deletions

View File

@ -1,11 +0,0 @@
/* Include global UPM interface file */
%include "../upm.i"
%{
/* SWIG preprocessor copies this directly to the output wrapper*/
#include "sensortemplate.hpp"
%}
/* %include is a SWIG directive. SWIG will wrap types exposed in this
* header to the target language. */
%include "sensortemplate.hpp"

View File

@ -1,8 +0,0 @@
/* Specify the name of the target JAVA module */
%module javaupm_sensortemplate
/* Include the base sensor interface file */
%include "common.i"
/* Add the JAVA code to load the module */
JAVA_JNI_LOADLIBRARY(javaupm_sensortemplate)

View File

@ -1,5 +0,0 @@
/* Specify the name of the target JavaScript module */
%module jsupm_sensortemplate
/* Include the base sensor interface file */
%include "common.i"

View File

@ -1,9 +0,0 @@
/* Specify the name of the target JAVA module */
%module pyupm_sensortemplate
/* If documentation is enabled, a full "pyupm_doxy2swig.i file will be
* generated and used... Otherwise, use a stub */
%include "pyupm_doxy2swig.i"
/* Include the base sensor interface file */
%include "common.i"

View File

@ -0,0 +1,29 @@
%include "../common_top.i"
/* BEGIN Java syntax ------------------------------------------------------- */
#ifdef SWIGJAVA
/* Add the JAVA code to load the module */
JAVA_JNI_LOADLIBRARY(javaupm_sensortemplate)
#endif
/* END Java syntax */
/* BEGIN Javascript syntax ------------------------------------------------- */
#ifdef SWIGJAVASCRIPT
#endif
/* END Javascript syntax */
/* BEGIN Python syntax ----------------------------------------------------- */
#ifdef SWIGPYTHON
#endif
/* END Python syntax */
/* BEGIN Common SWIG syntax ------------------------------------------------- */
%{
/* SWIG preprocessor copies this directly to the output wrapper*/
#include "sensortemplate.hpp"
%}
/* %include is a SWIG directive. SWIG will wrap types exposed in this
* header to the target language. */
%include "sensortemplate.hpp"
/* END Common SWIG syntax */