From 52b3087de9e69b57e19e7014503a0852acdc0279 Mon Sep 17 00:00:00 2001 From: Serban Waltter Date: Thu, 21 Jun 2018 16:34:38 +0300 Subject: [PATCH] Added new interfaces bindings Signed-off-by: Serban Waltter Signed-off-by: Mihai Tudor Panu --- examples/java/SHT1X_Example.java | 3 +++ src/CMakeLists.txt | 6 +++++- src/sht1x/sht1x.i | 7 +++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/examples/java/SHT1X_Example.java b/examples/java/SHT1X_Example.java index 068d535c..961c27cd 100644 --- a/examples/java/SHT1X_Example.java +++ b/examples/java/SHT1X_Example.java @@ -23,6 +23,7 @@ */ import upm_sht1x.SHT1X; +import upm_new_interfaces.*; public class SHT1X_Example { @@ -32,8 +33,10 @@ public class SHT1X_Example // Instantiate a SHT1X sensor using D2 as the clock, and D3 as the // data pin. + iTemperature temp = new SHT1X(2, 3); SHT1X sensor = new SHT1X(2, 3); + // Every 2 seconds, update and print values while (true) { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 71d17505..7a7a0bc0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -531,6 +531,10 @@ function(upm_swig_java) # target .jar file in the classpath, otherwise this variable will be empty set (INTERFACES_JAR_FILE ${CMAKE_BINARY_DIR}/src/interfaces/upm_interfaces.jar) endif () + if(module_iface) + add_dependencies(javaupm_${libname} javaupm_new_interfaces) + set (NEW_INTERFACES_JAR_FILE ${CMAKE_BINARY_DIR}/interfaces/upm_new_interfaces.jar) + endif() # For linker to report unresolved symbols. Note, there is currently no test # for linker flags (similar to compile files), so this is it for now. swig_link_libraries (javaupm_${libname} ${MRAAJAVA_LIBRARY} ${JAVA_LIBRARIES} ${libname} -Wl,--unresolved-symbols=report-all) @@ -581,7 +585,7 @@ function(upm_swig_java) add_custom_command (TARGET javaupm_${libname} POST_BUILD COMMAND cmake -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/upm_${libname} - COMMAND ${JAVAC} *.java -d ${CMAKE_CURRENT_BINARY_DIR} -cp ${INTERFACES_JAR_FILE}:. + COMMAND ${JAVAC} *.java -d ${CMAKE_CURRENT_BINARY_DIR} -cp ${INTERFACES_JAR_FILE}:${NEW_INTERFACES_JAR_FILE}:. COMMAND ${JAR} cf upm_${libname}.jar upm_${libname} ) diff --git a/src/sht1x/sht1x.i b/src/sht1x/sht1x.i index 93f3d7fd..14cf1705 100644 --- a/src/sht1x/sht1x.i +++ b/src/sht1x/sht1x.i @@ -1,10 +1,17 @@ +#ifdef SWIGPYTHON %module (package="pyupm_new_interfaces") sht1x +#endif + %import "interfaces/new_interfaces.i" %include "../common_top.i" /* BEGIN Java syntax ------------------------------------------------------- */ #ifdef SWIGJAVA +%typemap(javaimports) SWIGTYPE %{ +import upm_new_interfaces.*; +%} + JAVA_JNI_LOADLIBRARY(javaupm_sht1x) #endif /* END Java syntax */