diff --git a/MMCoreJ_wrap/MMCoreJ.i b/MMCoreJ_wrap/MMCoreJ.i index 35137b03e..a20314bd0 100644 --- a/MMCoreJ_wrap/MMCoreJ.i +++ b/MMCoreJ_wrap/MMCoreJ.i @@ -24,8 +24,9 @@ // CVS: $Id: MMCoreJ.i 16466 2017-08-23 21:46:52Z nico $ // -#if SWIG_VERSION < 0x020000 || SWIG_VERSION >= 0x040000 -#error SWIG 2.x or 3.x is currently required to build MMCoreJ +// Different SWIG major versions can produce incompatible Java APIs. +#if SWIG_VERSION < 0x040000 || SWIG_VERSION >= 0x050000 +#error "SWIG 4.x is required to build MMCoreJ" #endif %module (directors="1") MMCoreJ @@ -603,7 +604,6 @@ // Map all exception objects coming from C++ level // generic Java Exception // -%rename(eql) operator=; // CMMError used by MMCore %typemap(throws, throws="java.lang.Exception") CMMError { @@ -632,9 +632,17 @@ // We've translated exceptions to java.lang.Exception, so don't wrap the unused // C++ exception classes. %ignore CMMError; +%ignore MetadataError; %ignore MetadataKeyError; %ignore MetadataIndexError; +// Hide methods that take istringstream, which is not usable from Java +%ignore Metadata::readLine; +%ignore MetadataTag::ReadLine; +%ignore MetadataTag::Restore; +%ignore MetadataArrayTag::Restore; +%ignore MetadataSingleTag::Restore; + %typemap(javaimports) CMMCore %{ import mmcorej.org.json.JSONObject; @@ -937,6 +945,16 @@ // instantiate STL mappings +// SWIG 4 changed the std::vector wrappers and (among other things) removed +// the constructor overload taking (Java) long, which creates a vector of the +// requested number of empty/default elements. Since all of the element types +// that we wrap vector for are default-constructible, we can add back this +// overload. +// See the 2019-02-28 entry in https://www.swig.org/Release/CHANGES. +%extend std::vector { + vector(size_type count) { return new std::vector(count); } +} + namespace std { %typemap(javaimports) vector %{ import java.lang.Iterable; @@ -965,10 +983,6 @@ namespace std { throw new NoSuchElementException(); } } - - public void remove() throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } }; } @@ -976,11 +990,11 @@ namespace std { if (0==size()) return new Character[0]; - Character ints[] = new Character[(int) size()]; + Character cs[] = new Character[(int) size()]; for (int i=0; i %{ - import java.lang.Iterable; - import java.util.Iterator; - import java.util.NoSuchElementException; - import java.lang.UnsupportedOperationException; - %} - - %typemap(javainterfaces) vector %{ Iterable%} - - %typemap(javacode) vector %{ - - public Iterator iterator() { - return new Iterator() { - - private int i_=0; - - public boolean hasNext() { - return (i_ %{ import java.lang.Iterable; @@ -1208,10 +1159,6 @@ namespace std { throw new NoSuchElementException(); } } - - public void remove() throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } }; } @@ -1219,11 +1166,11 @@ namespace std { if (0==size()) return new Long[0]; - Long ints[] = new Long[(int) size()]; + Long ls[] = new Long[(int) size()]; for (int i=0; i; %template(DoubleVector) vector; %template(StrVector) vector; - %template(BooleanVector) vector; %template(UnsignedVector) vector; - %template(pair_ss) pair; - %template(StrMap) map; - - - - }