]> sigrok.org Git - libsigrok.git/commitdiff
bindings/java: Fix build issue with SWIG 4.x.
authorUwe Hermann <redacted>
Sat, 4 Apr 2020 19:54:13 +0000 (21:54 +0200)
committerUwe Hermann <redacted>
Sat, 4 Apr 2020 20:24:05 +0000 (22:24 +0200)
Tested with SWIG 3.x and SWIG 4.x.

This fixes bug #1527.

bindings/java/org/sigrok/core/classes/classes.i

index 75793b2531a39e8f5858cb9bc9af239a18824b73..e953fe5d8331052215b59e5c97608c50e851da8a 100644 (file)
@@ -94,10 +94,18 @@ VECTOR(std::shared_ptr<sigrok::HardwareDevice>, HardwareDevice)
   "java.util.Map<JKey, JValue>"
 
 %typemap(javain,
   "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")
     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 > {
   std::map< CKey, CValue > "$javaclassname.getCPtr(temp$javainput)"
 
 %typemap(javaout) std::map< CKey, CValue > {