]> sigrok.org Git - libsigrok.git/blobdiff - bindings/java/org/sigrok/core/classes/classes.i
bindings/java: Fix build issue with SWIG 4.x.
[libsigrok.git] / bindings / java / org / sigrok / core / classes / classes.i
index 129654d959105bcc7a51894e8852adb7bb56489e..e953fe5d8331052215b59e5c97608c50e851da8a 100644 (file)
 %pragma(java) jniclassimports=%{
 /**
  * @mainpage API Reference
- * 
+ *
  * Introduction
  * ------------
- * 
+ *
  * The sigrok-java API provides an object-oriented Java interface to the
  * functionality in libsigrok. It is built on top of the libsigrokcxx C++ API.
- * 
+ *
  * Getting started
  * ---------------
- * 
+ *
  * Usage of the sigrok-java API needs to begin with a call to Context.create().
  * This will create the global libsigrok context and returns a Context object.
  * Methods on this object provide access to the hardware drivers, input and
  * output formats supported by the library, as well as means of creating other
  * objects such as sessions and triggers.
- * 
+ *
  * Error handling
  * --------------
- * 
+ *
  * When any libsigrok C API call returns an error, an Error exception is raised,
  * which provides access to the error code and description.
  */
@@ -76,7 +76,7 @@ namespace Glib {
   for (auto entry : $1)
   {
     *(CValue **) &value = new CValue(entry);
-    jenv->CallObjectMethod($result, Vector_add,
+    jenv->CallBooleanMethod($result, Vector_add,
       jenv->NewObject(Value, Value_init, value, true));
   }
 }
@@ -94,10 +94,18 @@ VECTOR(std::shared_ptr<sigrok::HardwareDevice>, HardwareDevice)
   "java.util.Map<JKey, JValue>"
 
 %typemap(javain,
+/* SWIG 4.0.0 changed the std::map wrappers in an incompatible way. */
+#if SWIG_VERSION >= 0x040000
+    pre="  $javaclassname temp$javainput = new $javaclassname();
+    for (java.util.Map.Entry<JKey, JValue> entry : $javainput.entrySet())
+      temp$javainput.put(entry.getKey(), entry.getValue());",
+    pgcppname="temp$javainput")
+#else
     pre="  $javaclassname temp$javainput = new $javaclassname();
     for (java.util.Map.Entry<JKey, JValue> entry : $javainput.entrySet())
       temp$javainput.set(entry.getKey(), entry.getValue());",
     pgcppname="temp$javainput")
+#endif
   std::map< CKey, CValue > "$javaclassname.getCPtr(temp$javainput)"
 
 %typemap(javaout) std::map< CKey, CValue > {
@@ -197,7 +205,7 @@ MAP_COMMON(const sigrok::ConfigKey *, Glib::VariantBase, ConfigKey, Variant)
 
 %typemap(in, numinputs=0) JNIEnv * %{
    $1 = jenv;
-%} 
+%}
 
 /* Thread safe JNIEnv handling */