This was added in an attempt to avoid warnings from a static analysis
tool which wants us to use nullptr instead of NULL, but we can't do so
unconditionally while continuing to support C++98.
SWIG_NULLPTR is ugly, verbose and non-standard and NULL is still
standard C++ so we've decided to just use NULL instead. Users of tools
which don't like NULL can just suppress this warning for SWIG-generated
code.
Closes#3165Closes#3166
SWIG_NOEXCEPT is generated instead of throw() which is deprecated in
c++11. If c++11 or later is being used, then this macro expands to
noexcept instead of throw().
Affects director code only.
Also fix up some testcase to not use throw() when using c++11 or later.
Tested with clang and -Wdeprecated-dynamic-exception-spec as gcc
doesn't seem to warn for this deprecation.
Closes#3027
Fixes removeFirst() and removeLast() incompatibilities with methods
of the same name in the Java base class java.util.AbstractSequentialList
which were added in JDK 21 as part of JEP-431.
configure.ac has been modified to detect the version of JDK/Java for use
in testing the test-suite via the JAVA_VERSION_MAJOR variable.
Needed to continue testing removeFirst(), removeLast(), addFirst(), addLast().
Closes#3156
New macro added to the family of %interface macros. This new macro
is for adding additional interfaces for the generated interface to
extend/derive from.
Closes#1188
* char_binary_java_fix-tidyup:
Move SWIGStringWithLengthHelper to csharphead.swg
cdata whitespace/cosmetic fixups
cdata doc updates
Rename `typemaps/cdata_struct.swg` to `typemaps/cdata_begin.swg`. And `typemaps/cdata.swg` to `typemaps/cdata.swg`. Move `cdata_apply.swg` content to `typemaps/cdata.swg`.
Group the C# marshalling of STRING-LENGTH typemap into C# class named SWIGStringWithLengthHelper.
Leave Length & string reverse order typemap in typemaps/strings.swg
Support old C# as "LPUTF8Str" was add in 2017.
Improve documentation. Follow @wsfulton reviews.
Use a dummy for MzScheme and untested OCaml cdate. To prevent compilation error.
Further fixing follow reviews.
Reorganise raw data typemap, so typemaps folder contain only common part. Improve document.
Inline SWIG_string_to_utf8_bytes SWIG_utf8_bytes_to_string code
Fixes of STRING/BYTES LENGTH typemaps.
Conflicts:
CHANGES.current
And `typemaps/cdata.swg` to `typemaps/cdata.swg`.
Move `cdata_apply.swg` content to `typemaps/cdata.swg`.
Signed-off-by: Erez Geva <ErezGeva2@gmail.com>
Java's nested iterator class in std::map, std::set, std::unordered_map,
std::unordered_set needs to be public instead of protected for
access to work when moving STL types into different Java packages.
- Also fixes null handling.
- Don't swallow exceptions.
- Use default encoding for consistency across all of the Java wrappers.
Note, the encoding can be changed via the 'in' typemap, eg:
%typemap(javain, throws="java.io.IllegalCharsetNameException") (const char *STRING, size_t LENGTH) %{($javainput == null) ? null : $javainput.getBytes("UTF-8")%}
Fix Java STRING LENGTH typemap.
Use string type in static typed languages (Java, C#, D and Go).
Add BYTES LENGTH typemap and apply it for binary data.
Use byte type in static typed languages.
Add li_cdata_cpp, li_cdata and char_binary
tests for most of languages(apart from R and experimental).
Fix the director_binary_string test and add it to C#, D, Go,
Perl, PHP, Python, Ruby and octave.
Update documents.
Signed-off-by: Erez Geva <ErezGeva2@gmail.com>
With Perl the returned string is still being corrupted (the testcase
flags this as "TODO" for Perl's test harness).
Warnings aren't currently emitted for Perl, Ruby or Tcl as I'm not
seeing where in the UTL maze the directorout typemap actually gets
defined.
These have done nothing except emit a warning saying they are no
longer required for a long time.
One exception is guile and mzscheme still define non-trivial
specialize_std_map_on_* - it seems they were missed for some
reason, but the same improved machinery which meant these macros
are no longer required for other target languages should apply
to them too.
std::vector::capacity and std::vector::reserve signature changes.
Java api changes from:
public long capacity() { ... }
public void reserve(long n) { ... }
to:
public int capacity() { ... }
public void reserve(int n) { ... }
to fit in with the usual Java convention of using int for container
indexing and sizing.
The original api for std::vector::reserve can be also be made available via
%extend to add in an overloaded method as follows:
%include <std_vector.i>
%extend std::vector {
void reserve(jlong n) throw (std::length_error, std::out_of_range) {
if (n < 0)
throw std::out_of_range("vector reserve size must be positive");
self->reserve(n);
}
}
This change is partially driven by the need to seamlessly support the full
64-bit range for size_t generically, apart from the customisations for the
STL containers, by using:
%apply unsigned long long { size_t };
%apply const unsigned long long & { const size_t & };
Similarly for std::array::size.
Also enhance docs for applying unsigned long long typemaps for 64-bit
size_t.
Defining SWIGWORDSIZE64 now applies the (unsigned) long long
typemaps to (unsigned) long for a better match on systems
where long is 64-bits.
Although size_t typemaps are now applied from the int typemaps instead
of the long typemaps, identical code is generated and the mapping is
still to the Java signed long type.
Closes#646Closes#649
Running the test-suite as follows on a 64-bit long system:
env SWIG_FEATURES=-DSWIGWORDSIZE64 make check-java-test-suite
passes, except for a few tests which fail where they expect the
default Java type to be int or long instead of long or BigInteger
respectively.
Also arrays_java.i results in:
invalid conversion from ‘long int*’ to ‘long long int*’ [-fpermissive]
invalid conversion from ‘long int**’ to ‘long long int**’ [-fpermissive]
The "deprecation" warning has been changed to a "removal" warning
with newer JDK versions. This needs to be addressed, but meanwhile
it makes running the testsuite unusably noisy so suppressing it
seems more helpful than not.
Closes: #2556
We aim to produce code that works with C90 or C++98 so we can't
assume snprintf() is available, but it almost always is (even
on systems from before it was standardised) so having a way to
use it is helpful.
Enable this automatically if the compiler claims conformance
with at least C90 or C++98 and check SWIG_HAVE_SNPRINTF to allow
turning on manually, but disable if SWIG_NO_SNPRINTF if defined.
The fallback is to call sprintf() without a buffer size check -
checking after the call is really shutting the stable door after
the horse has bolted, and most of our uses either have a fixed maximum
possible size or dynamically allocate a buffer that's large enough.
Fixes: #2502 (sprintf deprecation warnings on macos)
Fixes: #2548
Add Swig_obligatory_macros which must be called by each
target language to define SWIG_VERSION correctly
in the generated code, as well as the language specific
macro SWIGXXX where XXX is the target language name.
Drop the #ifdef SWIGXXX that was previously generated -
I can't see the point of this and if users are defining
this macro somehow, then users will need to change this
Closes#1050
Ensure that SWIG_VERSION is defined both at SWIG-time and in the
generated C/C++ wrapper code (it was only defined in the wrapper
for some target languages previously).
SWIGGO and SWIGJAVASCRIPT are now defined in the generated wrappers
to match behaviour for all other target languages.
Stop defining SWIGVERSION in the wrapper. This only happened as a
side-effect of how SWIG_VERSION was defined but was never documented and
is redundant.
The new testcase also checks that SWIG is defined at SWIG-time but not
in the generated wrapper, and that exactly one of a list of
target-language specific macros is defined.
Fixes#1050
For implementing full move semantics when passing parameters by value.
Based on SWIGTYPE && and std::unique_ptr typemaps which implement move
semantics.
Added for all languages, but untested for: Go, Ocaml, R, Scilab (and
unlikely to be fully functional for same reasons as for std::unique_ptr
support).
Issue #999
Change these typemaps to assume that after a function call,
the parameter has been moved. The parameter's proxy class
that owns the C++ object thus has the underlying pointer set
to null so the object cannot be used again and the object is deleted.
Scrap new javarelease typemap and move contents into javabody typemap.
This works by transferring ownership of the underlying C++ memory
from the target language proxy class to an instance of the unique_ptr
which is passed to the wrapped function via std::move.
The proxy class has a new swigRelease() method which sets the
underlying C++ pointer for the proxy class to null, so working
in much the same way as std::unique_ptr::release(). Any attempt at
using the proxy class will be the same as if the delete() function
has been called on the proxy class. That is, using a C++ null pointer,
when a non-null pointer is usually expected.
This commit relies on the previous commit that uses std::move
on the temporary variable used for the wrapped function's input parameter
as std::unique_ptr is not copyable, it has move-only semantics.