blob: 049f449c393a5823a01c21549f8ffe7b99cd37f2 [file] [log] [blame] [edit]
SWIG (Simplified Wrapper and Interface Generator)
See the CHANGES.current file for changes in the current version.
See the RELEASENOTES file for a summary of changes in each release.
Issue # numbers mentioned below can be found on Github. For more details, add
the issue number to the end of the URL: https://github.com/swig/swig/issues/
Version 4.1.1 (30 Nov 2022)
===========================
2022-11-29: bero
Fix mismatch between #pragma GCC diagnostic push and pop statements
2022-11-26: wsfulton
#2449 Fix undefined behaviour in ccache-swig calculating md4 hashes and possibly
also handling errors when CCACHE_CPP2 is set.
2022-11-25: wsfulton
#961 Fix syntax error parsing unnamed template parameters with a default value.
2022-11-25: olly
#2447 Fix undefined behaviour in swig's parser when handling
default parameter expressions containing method calls.
2022-11-13: olly
[PHP] #2419 Update the documentation to reflect that SWIG 4.1.0
dropped support for -noproxy when generating PHP wrappers.
2022-11-05: wsfulton
#2417 Fix -swiglib for Windows when building with CMake.
2022-11-02: wsfulton
#2418 Fix infinite loop handling non-type template parameters.
Fixes infinite loop due to () brackets in a non-type template
parameter containing an expression.
2022-10-28: wsfulton
[R] R rtypecheck typemaps
Further switch to use rtypecheck typemaps instead of hard coded logic.
The full switch to typemaps is deferred until swig-4.2 as it can't be fully
backwards compatible. For now a warning is provided to help the
transition. It provides the full typemap that should be placed into
a user's interface file, for example:
%typemap("rtype") int32_t * "integer"
void testmethod(int32_t * i);
void testmethod();
If there is no rtypecheck typemap for int32_t *, the warning shown is:
example.i:7: Warning 750: Optional rtypecheck code is deprecated. Add the
following typemap to fix as the next version of SWIG will not work without it:
%typemap("rtypecheck") int32_t * %{ (is.integer($arg) || is.numeric($arg)) %}
The warning is shown for any code that previously used "numeric", "integer" or
"character" for the rtype typemap. Copying the rtypecheck typemap as
shown into the user interface file will provide the appropriate fix and
the warning will disappear. This is important to do as swig-4.2 will
not be able to provide this helpful warning.
2022-10-27: wsfulton
[R] Allow NULL to be used in overloaded functions taking shared_ptr.
Also fixes special variable $argtype expansion in rtypecheck typemaps.
2022-10-26: wsfulton
[R] Improve R wrapper error message when calling overloaded methods
when incorrect types passed are passed to the overloaded methods.
Old unhelpful error message:
Error in f(...) : could not find function "f"
Example of new improved error message:
Error in use_count(k) :
cannot find overloaded function for use_count with argtypes (NULL)
2022-10-26: wsfulton
[R] #2386 Fix memory leak in R shared_ptr wrappers.
Fix leak when a cast up a class inheritance chain is required.
Version 4.1.0 (24 Oct 2022)
===========================
2022-10-24: wsfulton, AndLLA
[R] #2386 Fix problems in shared_ptr wrappers where the class names
were not consistent when using the shared_ptr template or the actual
underlying type.
2022-10-24: wsfulton
[R] Add support for special variable replacement in the $typemap()
special variable macro for R specific typemaps (rtype, rtypecheck,
scoercein, scoereout).
2022-10-24: wsfulton
[R] Polymorphism in the wrappers was only working for C++ classes,
now this works for C++ structs too.
2022-10-19: olly
[Lua] #2126 Fix type resolution between multiple SWIG-wrapped
modules.
2022-10-17: wsfulton
[R] #2385 Add support for std::vector<std::vector<std::string>>.
2022-10-14: murillo128
[Javascript] #2109 Tweak unsigned long and unsigned long long typemaps
to create a v8::Number instead of v8::Integer if the value exceeds
the size of v8::Integer. Note that the v8::Number value will be
imprecise if the value is > MAX_SAFE_INTEGER.
2022-10-14: olly
[R] Arrange that destructors of local C++ objects in the wrapper
function get run on SWIG_fail (which calls Rf_error() which calls
longjmp()).
2022-10-14: olly
[Lua] Arrange that destructors of local C++ objects in the wrapper
function get run on SWIG_fail (which calls lua_error() which calls
longjmp()).
2022-10-13: wsfulton
[R] Add missing SWIGTYPE *const& typemaps for supporting pointers
by const reference.
2022-10-10: wsfulton
#2160 Fix compile error when using templates with more than one template
parameter and used as an input parameter in a virtual method in a
director class (problem affecting most of the scripting languages).
2022-10-10: treitmayr, wsfulton
[Python, Ruby] #1811 #1823 Fix invalid code generated in some cases when
returning a pointer or reference to a director-enabled class instance.
This previously only worked in very simple cases, now return types are
resolved to fix. A bug in template instantiations using pointers also
works now.
2022-10-06: wsfulton
[CFFI] #1966 #2200 Remove code for Common Lisp CFFI. We dropped support
for it in SWIG 4.0.0 by disabling it as the first stage. This is the
final stage for complete removal as there has been no meaningful
progress to revive it to the status of experimental language.
2022-10-06: olly
[Python] #2390 Remove deprecated and apparently useless defarg.swg
The only documentation is in the file itself and describes a Python
wrapper around the C function defined here, but digging though the
git history this Python wrapper doesn't seem to have ever actually
been generated by SWIG.
This file was also marked as deprecated in 2005.
2022-10-06: wsfulton
[Java] #2048 Fix quoting for doxygen \image command to quote the output
file name generated into the html src attribute.
2022-10-05: benjamin-sch
[Python] added an interpreter counter to fix deinitialization
issues if multiple subinterpreters are used
2022-10-05: olly, wsfulton
#672 Add support for parsing C++11 final classes such as:
class X final {};
This no longer gives a syntax error.
2022-10-05: wsfulton
[OCaml] Fix %rename for enum items. Previously the rename had no effect.
2022-10-05: olly
#1465 Report errors in preprocessor expressions by default
Until now SWIG quietly ignored such errors unless -Wextra (or -Wall
which implies -Wextra) was passed, but this is unhelpful as it tends
to hide genuine problems. To illustrate this point, enabling this
warning by default revealed a typo in the preproc_defined.i
testcase in SWIG's own testsuite.
If you really don't want to see this warning, you can suppress it
with command line option -w202 or by using this in your interface
file:
%warnfilter(SWIGWARN_PP_EVALUATION);
Both will work with older versions of SWIG too.
2022-10-04: olly
#1050 Consistently define SWIG_VERSION both at SWIG-time and in
the generated wrapper. Best practice remains to check at SWIG-time
where possible because that results in smaller generated wrapper
sources.
SWIGGO and SWIGJAVASCRIPT are now defined in the generated wrappers
to match behaviour for all other target languages.
The undocumented SWIGVERSION macro is no longer defined.
2022-09-29: olly
#2303 SWIG's internal hash tables now use a better hash function.
The old hash function only considerd the last five characters
plus the least significant bit of the last-but-sixth character,
which as you might guess generated a lot of many-way collisions.
This change seems to give about a 4% reduction in wallclock time
for processing li_std_list_wrap.i from the testsuite for Python.
The hash collision rate for this example drops from 39% to 0!
2022-09-29: wsfulton
#2303 Type tables are now output in a fixed order whereas previously
the order may change with any minor input code change. This shouldn't
affect users except SWIG_TypePrettyName may output a different C/C++
typedef to a type - it's used mostly for showing errors when the type
passed to a function is wrong.
2022-09-29: olly
[PHP] Dynamic class properties are no longer supported by default.
Historically PHP has supported dynamic class properties and SWIG
has implemented them too (because we implement the magic __get(),
__set() and __isset() methods we need to include explicit
handling).
PHP 8.2 deprecates dynamic class properties - initially they'll
warn, and apparently they'll not work by default in PHP 9.0:
https://wiki.php.net/rfc/deprecate_dynamic_properties
In PHP code dynamic properties can be enabled for a class by
marking that class with the attribute `#[AllowDynamicProperties]`.
To follow this PHP change, in SWIG you now need to specify
`%feature("php:allowdynamicproperties", 1) Foo;` (or
`%feature("php:allowdynamicproperties", 1)` to enable it for
all wrapped classes). Unknown features are ignored, so you can add
it unconditionally and it'll work with older SWIG too.
*** POTENTIAL INCOMPATIBILITY ***
2022-09-19: wsfulton
#1484 Fixes for class inheritance with the same name in different namespaces
such as:
namespace A { class Bar {}; }
namespace B { template<typename T, typename U> class Bar : public A::Bar {}; }
2022-09-19: wsfulton
#2316 Remove swig.spec file and srcrpm makefile target. These are very out of date
and don't seem to be used by RPM based Linux distributions which have their
own version of swig.spec.
2022-09-17: wsfulton
[Go, Guile, Racket, Scilab] Add throws typemaps for std::string so that thrown
string exception messages can be seen.
2022-09-17: wsfulton
[Racket] Add throws typemaps for char * so that thrown string exception
messages can be seen from Racket.
2022-09-17: wsfulton
[Javascript, Octave, R] Improve exceptions for %catches and exception
specifications for native types. String exception messages are shown as
the exception message instead of just the type of the exception.
2022-09-17: wsfulton
Add missing typecheck typemaps for std::auto_ptr and std::unique_ptr to
fix overloading when using these types.
2022-09-17: wsfulton
[Guile] Add error checking to SWIGTYPE and SWIGTYPE & in typemaps to prevent
seg faults when passing #nil to these parameter types.
2022-09-16: wsfulton
#999 Provide SWIGTYPE MOVE typemaps in swigmove.i for implementing full
move semantics when passing parameters by value.
2022-08-31: wsfulton
#999 Improve move semantics when using rvalue references.
The SWIGTYPE && input typemaps now assume the object has been moved.
These typemaps have been changed assuming that after the function call,
the rvalue reference parameter has been moved. The parameter's proxy class
that owns the C++ object thus has the underlying pointer set to null
so that the (moved from, but still valid) C++ object cannot be used again
and the object is additionally deleted.
*** POTENTIAL INCOMPATIBILITY ***
2022-08-28: wsfulton
[Octave] SWIG now marshals a C/C++ NULL pointer into the null matrix, [].
SWIG has always marshalled the null matrix into a NULL pointer; this remains
and now we have consistency in representing a NULL pointer.
2022-08-26: wsfulton
[Racket] SWIG now marshals a C/C++ NULL pointer into a null value by calling
scheme_make_null(), so that scheme's null? is true for a NULL C/C++ pointer value.
2022-08-18: wsfulton
[Racket] Add support for std::unique_ptr in std_unique_ptr.i.
Add support for std::auto_ptr in std_auto_ptr.i.
2022-08-13: wsfulton
[Guile] Add support for std::unique_ptr in std_unique_ptr.i.
Add support for std::auto_ptr in std_auto_ptr.i.
2022-08-11: wsfulton
[Lua] Add support for std::unique_ptr in std_unique_ptr.i.
Add support for std::auto_ptr in std_auto_ptr.i.
2022-08-05: wsfulton
[D] Fix occasional undefined behaviour with inheritance hierarchies, particularly
when using virtual inheritance as the pointers weren't correctly upcast from derived
class to base class when stored in the base's proxy class.
2022-08-05: wsfulton
[D] Add support for std::unique_ptr in std_unique_ptr.i.
Add support for std::auto_ptr in std_auto_ptr.i.
2022-08-03: wsfulton
[Javascript] Add support for std::unique_ptr in std_unique_ptr.i.
Add support for std::auto_ptr in std_auto_ptr.i.
2022-08-02: wsfulton
[Octave] Add support for std::unique_ptr in std_unique_ptr.i.
Add support for std::auto_ptr in std_auto_ptr.i.
2022-08-01: wsfulton
[Python] Add initialisers for additional members in PyHeapTypeObject
(builtin mode) for Python-3.11 - _ht_tpname, _spec_cache.
2022-07-30: wsfulton
C++20 has deprecated std::basic_string<>::reserve() and the C++11 method
std::basic_string<>::shrink_to_fit() is a replacement that can be used.
std_string.i and std_wstring.i provided wrappers for reserve with the following
template instantiations:
%template(string) std::basic_string<char>;
%template(wstring) std::basic_string<wchar_t>;
The reserve method is no longer wrapped, however the shrink_to_fit() method
can be used as an alternative from the target language (the generated wrappers
call reserve() instead if C++<=20).
Note that std::basic_string<>::reserve(size_t n) is still wrapped unchanged.
*** POTENTIAL INCOMPATIBILITY ***
2022-07-30: wsfulton
[Tcl] Add support for std::unique_ptr in std_unique_ptr.i.
Add support for std::auto_ptr in std_auto_ptr.i.
2022-07-27: ZackerySpytz, olly
#1678 Support parsing C++20 templated lambdas.
2022-07-27: ZackerySpytz, olly
#1622 Add support for the C++20 spaceship operator (<=>).
2022-07-26: olly
[Tcl] https://sourceforge.net/p/swig/bugs/977/
Fix handling of long long on 32-bit platforms. This fix raises
SWIG's minimum supported Tcl version to 8.4.0 (which was released
just under 20 years ago).
2022-07-26: olly
Fix incorrect operator precedence in preprocessor expressions.
2022-07-25: olly
Support for C++14 binary integer literals in preprocessor expressions.
2022-07-20: wsfulton
[C#, Java] Ensure the order of interfaces generated in proxy interfaces for the
%interface family of macros is the same as that parsed from the bases in C++.
2022-07-20: jicks, Ingener74, olly
#422 [Python] Fix mishandling of a Python class inheriting from
multiple SWIG-wrapped director classes.
2022-07-19: wsfulton
#692 [C#, Java, Perl, Python, Ruby] std::unique_ptr and std::auto_ptr typemaps
provided for inputs types in std_unique_ptr.i and std_auto_ptr.i.
Now these smart pointers can be used as input parameters to functions. A proxy
class instance transfers memory ownership of the underlying C++ object from the
proxy class to a smart pointer instance passed to the wrapped function.
2022-07-19: jschueller
[Python] #2314 Drop support for Python 3.2.
2022-07-19: olly
Remove remaining support code for classic macos, which has not been
supported by Apple for over 20 years now.
2022-07-12: wsfulton
#999 Performance optimisation for parameters passed by value that are C++11 movable.
The C++ wrappers create a temporary variable for a parameter to be passed to a
function. This is initially default constructed and then copy assigned from the
instance being passed in from the target language. This is unchanged, however,
when the temporary variable is passed to the wrapped function, it is now done using
std::move. If the type is move constructible, the move constructor will be used
instead of the copy constructor.
2022-07-12: wsfulton
[Perl] Add std::auto_ptr support in std_auto_ptr.i library file.
2022-07-12: erezgeva
[Perl] Add std::unique_ptr support in std_unique_ptr.i library file.
2022-07-07: jmarrec
#1158 #2286 Add basic support for C++11 attributes. These are now
crudely ignored by SWIG's parser's tokeniser, which is better than
failing with a parse error.
2022-07-05: ianlancetaylor
[Go] #2245 Handle NULL pointers for string* conversions.
Rearrange generation of director methods and rename
receiver argument from p to swig_p.
2022-07-03: wsfulton
#999 Performance optimisation for directors for classes passed by value. The directorin
typemaps in the director methods now use std::move on the input parameter when
copying the object from the stack to the heap prior to the callback into the target
language, thereby taking advantage of move semantics if available.
2022-07-02: wsfulton
#1722 [C#, Java, Python, Ruby] Add std::unique_ptr support. Ported from std::auto_ptr.
Use the %unique_ptr(T) macro as follows for usage std::unique_ptr<T>. For example, for
a class called Klass:
%include "std_unique_ptr.i"
%unique_ptr(Klass)
Support is currently limited to only returning a std::unique_ptr from a function.
2022-06-29: wsfulton
#999 #1044 Enhance SWIGTYPE "out" typemaps to use std::move when copying
objects, thereby making use of move semantics when wrapping a function returning
by value if the returned type supports move semantics.
Wrapping functions that return move only types 'by value' now work out the box
without having to provide custom typemaps.
The implementation removed all casts in the "out" typemaps to allow the compiler to
appropriately choose calling a move constructor, where possible, otherwise a copy
constructor. The implementation also required modifying SwigValueWrapper to
change a cast operator from:
SwigValueWrapper::operator T&() const;
to
#if __cplusplus >=201103L
SwigValueWrapper::operator T&&() const;
#else
SwigValueWrapper::operator T&() const;
#endif
This is not backwards compatible for C++11 and later when using the valuewrapper feature
if a cast is explicitly being made in user supplied "out" typemaps. Suggested change
in custom "out" typemaps for C++11 and later code:
1. Try remove the cast altogether to let the compiler use an appropriate implicit cast.
2. Change the cast, for example, from static_cast<X &> to static_cast<X &&>, using the
__cplusplus macro if all versions of C++ need to be supported.
*** POTENTIAL INCOMPATIBILITY ***
2022-06-15: wsfulton
#2039 Add move assignment operator to SwigValueWrapper used by the
valuewrapper feature.
2022-06-04: sethrj
Enhance $typemap to support typemap attributes.
$typemap(method:attribute, typepattern)
For example:
%typemap(cstype, out="object") XClass "XClass"
%typemap(cscode) BarClass %{
$typemap(cstype:out, XClass) bar() {
return null;
}
which expands to
object bar() {
return null;
}
2022-05-30: wsfulton
[C#, D] Add new special variable expansion: $imfuncname.
Expands to the function name called in the intermediary class.
2022-05-30: LindleyF
[Java] #2042 Add new special variable expansion: $imfuncname.
Expands to the function name called in the intermediary class.
2022-05-28: jkuebart
[Java] On some versions of Android, specifically Android 6,
detaching the current thread from the JVM after every invocation
causes a memory leak.
Offer SWIG_JAVA_DETACH_ON_THREAD_END to configure a behaviour
where the JVM is only detached in the thread destructor.
See https://developer.android.com/training/articles/perf-jni#threads.
2022-05-27: xypron
[Python] #2277 Define PY_SSIZE_T_CLEAN macro before #include "Python.h" as
recommended in Python 3.7 and later.
To avoid this macro definition, add the following to your interface file so
that SWIG_NO_PY_SSIZE_T_CLEAN is defined at the beginning of the C++ wrappers:
%begin %{
#define SWIG_NO_PY_SSIZE_T_CLEAN
%}
2022-05-26: rokups
[C#] #1323 Modify SwigDerivedClassHasMethod for a more efficient director
implementation when calling virtual methods that are not overridden.
2022-05-15: erezgeva, eiselekd
[Lua, Perl, Octave, PHP, Tcl] #2275 #2276 #2283 Add argcargv.i library containing
(int ARGC, char **ARGV) multi-argument typemaps.
Document this library in Typemaps.html.
2022-05-07: KrisThielemans
[Python] Fix "too many initializers for 'PyHeapTypeObject'" errors
using PyPy 3.8 and later.
2022-05-04: wsfulton
[C#] Add C# wchar_t * director typemaps
2022-04-20: cminyard
Fix an issue where newlines were not properly generated
for godirectorin typemaps. If you have a virtual function
not assigned to zero, in some cases it won't generate a
newline and you will see errors:
example.go:1508:3: expected ';', found swig_r
when compiling the go code.
Also add an example of using goin and godirectorin and add
a test for this situation.
2022-04-29: jason-daly, JerryJoyce, wsfulton
[C#] #1233 Add wchar_t * and std::wstring Unicode string support on Linux.
2022-04-11: robinst
#2257 Fix new Ruby 3.2 warning "undefining the allocator of T_DATA
class swig_runtime_data".
2022-04-07: olly
#1750 SWIG now recognises and ignores Doxygen group commands `@{` and `@}`.
2022-04-06: wsfulton
./configure now enables C++11 and later C++ standards testing by default (when
running: 'make check').
The options to control this testing are the same:
./configure --enable-cpp11-testing
./configure --disable-cpp11-testing
But the former is now the default and the latter can be used to turn off C++11 and
later C++ standards testing.
2022-04-06: wsfulton
[Python] #1635 The "autodoc" feature no longer overrides Doxygen comments
in the generated docstring.
If a "docstring" feature is present it will still override a Doxygen comment.
If the "autodoc" feature is also present, the combined "autodoc" and "docstring"
will override the Doxygen comment. If no "docstring" is present then the
"autodoc" feature will not be generated when there is a Doxygen comment.
This way the "autodoc" feature can be specified and used to provide documentation
for 'missing' Doxygen comments.
*** POTENTIAL INCOMPATIBILITY ***
2022-04-01: olly
Remove undocumented and non-functional -browse command line option.
2022-03-26: eltoder
[Python] #1684 Use different capsule names with and without -builtin
Types generated with and without -builtin are not compatible. Mixing
them in a common type list leads to crashes. Avoid this by using
different capsule names: "type_pointer_capsule" without -builtin and
"type_pointer_capsule_builtin" with.
2022-03-25: wsfulton
The debug command line options that display parse tree nodes
(-debug-module, -debug-top, -debug-symtabs) now display previously hidden
linked list pointers which are useful for debugging parse trees.
Added new command line option -debug-quiet. This suppresses the display
of most linked list pointers and symbol table pointers in the parse tree nodes.
The keys in the parse tree node are now shown in alphabetical order.
2022-03-24: wsfulton
#2244 Fix using declaration in derived class bugs when all the base
class's overloaded methods were overridden in the derived class -
fixes "multiply defined" errors.
2022-03-23: wsfulton
[Python] #1779 The -py3 option is deprecated and now has no effect on the
code generated. Use of this option results in a deprecated warning.
The related SWIGPYTHON_PY3 macro that this option defined is no longer generated.
Note that %pythonnondynamic feature generates a metaclass that works on both
Python 2 and Python 3.
2022-03-21: wsfulton
[Python] #1779 pyabc.i for abstract base classes now supports versions of
Python prior to 3.3 by using the collection module for these older versions.
Python-3.3 and later continue to use the collections.abc module.
The -py3 option no longer has any effect on the %pythonabc feature.
2022-03-21: jschueller, jim-easterbrook, wsfulton
[Python] #2137 C++ static member functions no longer generate a "flattened"
name in the Python module. For example:
s = example.Spam()
s.foo() # Spam::foo() via an instance
example.Spam.foo() # Spam::foo() using class method
example.Spam_foo() # Spam::foo() "flattened" name
The "flattened" name is no longer generated, but can be generated
by using the new -flatstaticmethod option.
*** POTENTIAL INCOMPATIBILITY ***
2022-03-18: ianlancetaylor
[Go] #337 Implement %extend base methods in child classes.
2022-03-17: olly
[Python] #1779 SWIG's Python test-suite and examples are now
run with Python 3 by default. To run them with Python 2, set
PY2 to a non-empty value, e.g.:
make check-python-test-suite PY2=1
2022-03-16: olly
[Go] #683 -intgosize is now optional - if not specified the
generated C/C++ wrapper code will use ptrdiff_t for intgo and
size_t for uintgo.
2022-03-15: ianlancetaylor
[Go] Add typemaps for std::string*.
2022-03-15: ianlancetaylor
[Go] Don't convert arrays to pointers if there is a "gotype"
typemap entry.
2022-03-15: ianlancetaylor
[Go] Add documentation note about Go and C++ exceptions.
2022-03-12: wsfulton
#1524 %interface family of macros no longer contain the getter/setter
methods for wrapping variables. The interface only contains
virtual and non-virtual instance methods, that is, no static methods.
Enums are also no longer added to the interface (affects Java only where
they were missing from the proxy class, C# never had them in the interface).
*** POTENTIAL INCOMPATIBILITY ***
2022-03-12: wsfulton
#1277 Fixes for the family of %interface macros, %interface,
%interface_impl and %interface_custom fixes for overloaded methods
in an inheritance chain.
When C++ methods are not able to be overloaded in a derived class,
such as when they differ by just const, or the target language
parameters types are identical even when the C++ parameter types
are different, SWIG will ignore one of the overloaded methods with
a warning. A %ignore is required to explicitly ignore one of the
overloaded methods to avoid the warning message. Methods added
in the derived classes due to one of the %interface macros are now
similarly ignored/not added to the derived class.
The methods added to the derived classes can now also be modified
via %feature and %rename.
2022-03-08: ianlancetaylor
[Go] Treat a nil argument as a NULL pointer.
2022-03-08: ianlancetaylor
[Go] Add documentation notes about thread local storage.
2022-03-08: olly
#1006 SWIG now copes with an interface filename specified on the
command line which contains a closing parenthesis `)`, and more
generally with attributes to `%include` and `%import` which
are quoted and contain parentheses.
2022-03-07: Omar Medina
[Tcl] https://sourceforge.net/p/swig/bugs/1290/
Fix SWIG_AsWCharPtrAndSize() to actually assign to result
variable. It looks like SWIG/Tcl wide character handling is
currently fundamentally broken except on systems which use wide
characters as the system encoding, but this should fix wrapping
functions which take a wide string as a parameter on Microsoft
Windows.
2022-03-07: olly
[Javascript] #682 Fix handling of functions which take void*.
2022-03-06: olly
SWIG should now reliably exit with status 0 if the run was
successful and status 1 if there was an error (or a warning and
-Werror was in effect).
Previously in some situations SWIG would try to exit with the
status set to the number of errors encountered, but that's
problematic - for example if there were 256 errors this would
result in exit status 0 on most platforms. Also some error
statuses have special meanings e.g. those defined by <sysexits.h>.
Also SWIG/Javascript tried to exit with status -1 in a few places
(which typically results in exit status 255).
2022-03-05: wsfulton
#1441 Fix using declaration in derived class incorrectly introducing a method
from a base class when the using declaration is declared before the method
declaration. Problem occurred when within a namespace and the parameter types
in the method signatures were not fully qualified.
2022-03-05: ianlancetaylor
[Go] Treat non-const references as pointers.
2022-03-05: ianlancetaylor
In SWIG Go testsuite, fail test if "go build" fails.
2022-03-03: olly
#1901 #2223 SWIG should now always exit cleanly if memory
allocation fails, including removing any output files created
during the current run.
Previously most places in the code didn't check for a NULL return
from malloc()/realloc()/calloc() at all, typically resulting in
undefined behaviour; some places used assert() to check for a NULL
return (which is a misuse of assert() and such checks disappear if
built with NDEBUG defined leaving us back with undefined
behaviour).
2022-03-03: olly
#891 Report errors for typemap attributes without a value
(previously SWIG segfaulted) and for typemap types with a value
(previously the value was quietly ignored).
The old way of specifying a language name in the typemap attributes
is no longer supported (it has been deprecated for 16 years).
2022-03-02: geographika, wsfulton
[Python] #1951 Add Python variable annotations support.
Both function annotations and variable annotations are turned on using the
"python:annotations" feature. Example:
%feature("python:annotations", "c");
struct V {
float val;
};
The generated code contains a variable annotation containing the C float type:
class V(object):
val: "float" = property(_example.V_val_get, _example.V_val_set)
...
Python 3.5 and earlier do not support variable annotations, so variable
annotations can be turned off with a "python:annotations:novar" feature flag.
Example turning on function annotations but not variable annotations globally:
%feature("python:annotations", "c");
%feature("python:annotations:novar");
or via the command line:
-features python:annotations=c,python:annotations:novar
*** POTENTIAL INCOMPATIBILITY ***
2022-02-27: wsfulton
[Python] #735 #1561 Function annotations containing C/C++ types are no longer
generated when using the -py3 option. Function annotations support has been
moved to a feature to provide finer grained control. It can be turned on
globally by adding:
%feature("python:annotations", "c");
or by using the command line argument:
-features python:annotations=c
Also see entry dated 2022-03-02, regarding variable annotations.
*** POTENTIAL INCOMPATIBILITY ***
2022-02-26: wsfulton
#655 #1840 Add new warning WARN_LANG_USING_NAME_DIFFERENT to warn when a
method introduced by a using declaration in a derived class cannot
be used due to a conflict in names.
2022-02-24: olly
#1465 An invalid preprocessor expression is reported as a pair of
warnings with the second giving a more detailed message from the
expression evaluator. Previously SWIG prefixed the second message
with "Error:" - that was confusing as it's actually only a warning
by default so we've now dropped this prefix.
Before:
x.i:1: Warning 202: Could not evaluate expression '1.2'
x.i:1: Warning 202: Error: 'Floating point constant in preprocessor expression'
Now:
x.i:1: Warning 202: Could not evaluate expression '1.2'
x.i:1: Warning 202: Floating point constant in preprocessor expression
2022-02-23: olly
#1384 Fix a preprocessor expression evaluation bug. A
subexpression in parentheses lost its string/int type flag and
instead used whatever type was left in the stack entry from
previous use. In practice we mostly got away with this because
most preprocessor expressions are integer, but it could have
resulted in a preprocessor expression incorrectly evaluating as
zero. If -Wextra was in use you got a warning:
Warning 202: Error: 'Can't mix strings and integers in expression'
2022-02-21: davidcl
[Scilab] Improve 5.5.2, 6.0.0 and 6.1.0 support.
For Scilab 5, long names are reduced to small names preserving the
class prefix and accessor suffix (get or set).
For Scilab 6, long names with the class prefix and accessor suffix
should be used on the user code.
The `-targetversion` option has been removed as the generated code
now detects the Scilab version in loader.sce or builder.sce.
*** POTENTIAL INCOMPATIBILITY ***
2022-02-20: wsfulton
Fix %warnfilter warning suppress for warning 315 SWIGWARN_PARSE_USING_UNDEF.
2022-02-17: olly
[PHP] https://sourceforge.net/p/swig/bugs/1211/
Fix to call cleanup code in exception situations and not to invoke
the freearg typemap twice in certain situations.
2022-02-15: olly
#300 #368 Improve parser handling of % followed immediately by
an identifier. If it's not a recognised directive the scanner
now emits MODULO and then rescans what follows, and if the parser
then gives a syntax error we report it as an unknown directive.
This means that `a%b` is now allowed in an expression, and that
things like `%std::vector<std::string>` now give an error rather
than being quietly ignored.
2022-02-11: adr26
[Python] #2154 Fix memory leak.
SWIG python objects were being freed after the corresponding SWIG
module information was destroyed in Python 3, causing leaks when as
a result the object destructor could not be invoked. To prevent this
misordering, SWIG python objects now obtain a reference to the
Python capsule wrapping the module information, so that the module
information is correctly destroyed after all SWIG python objects
have been freed (and corresponding destructors invoked).
2022-02-10: olly
[Tcl] https://sourceforge.net/p/swig/bugs/1207/
https://sourceforge.net/p/swig/bugs/1213/
Fix Tcl generic input typemap for std::vector.
2022-02-07: sethrj
#2196 Add alternative syntax for specifying fragments in typemaps.
New syntax:
%typemap("in", fragment="frag1", fragment="frag2", fragment="frag3") {...}
which is equivalent to:
%typemap(in, fragment="frag1,frag2,frag3") {...}
2022-02-07: olly
#1806 Remove support for the "command" encoder, which was mostly
intended for use in `%rename` - most uses can be achieved using
the "regex" encoder, so we recommend using that instead.
The "command" encoder suffers from a number of issues - as the
documentation for it admitted, "[it] is extremely slow compared to
all the other [encoders] as it involves spawning a separate process
and using it for many declarations is not recommended" and that it
"should generally be avoided because of performance
considerations".
But it's also not portable. The design assumes that `/bin/sh`
supports `<<<` but that's a bash-specific feature so it doesn't
work on platforms where `/bin/sh` is not bash - it fails on
Debian, Ubuntu and probably some other Linux distros, plus most
non-Linux platforms. Microsoft Windows doesn't even have a
/bin/sh as standard.
Finally, no escaping of the passed string is done, so it has
potential security issues (though at least with %rename the input
is limited to valid C/C++ symbol names).
2022-02-06: olly
#2193 -DFOO on the SWIG command line now sets FOO to 1 for
consistency with C/C++ compiler preprocessors. Previously
SWIG set FOO to an empty value.
Existing invocations of SWIG with `-DFOO` where the empty value
matters can be updated to `-DFOO=` which should work with both
old and new releases of SWIG.
*** POTENTIAL INCOMPATIBILITY ***
2022-02-06: sethrj
#2194 Classes that are non-assignable due to const data or const
reference members are now automatically detected.
2022-02-04: friedrichatgc
[Octave] #1672 Fix for isobject for Octave 4.4 - 6.0.
2022-02-03: olly
[C#] #283 #998 Fix memory leak in directorin typemap for
std::string.
2022-02-03: olly
[Python] #967 Make `self` parameter available to user typemaps.
2022-02-03: teythoon
[Python] #801 Fix -Wunused-parameter warnings with builtin,
2022-02-03: teythoon
#801 Fix -Wstrict-prototypes warnings in generated pointer
functions.
2022-02-03: olly
#660 https://sourceforge.net/p/swig/bugs/1081/
Default parameter values containing method calls are now parsed and
handled - e.g. `x->foo(3,4)` and `y.z()`.
2022-02-02: olly
[Ruby] https://sourceforge.net/p/swig/bugs/1136/ Fix remove of prefix
from method name to only remove it at the start.
2022-02-01: olly
#231 Handle returning an object by reference in a C++ trailing
return type.
2022-02-01: davidcl
[Scilab] #745 use SWIG_<module>_Init() as a C module init function.
2022-02-01: olly
[OCaml] #2083 Fix to work when CAML_SAFE_STRING is on, which it is
by default in recent Ocaml releases.
2022-01-31: mreeez
https://sourceforge.net/p/swig/bugs/1147/
Fix copyToR() generated for a struct in a namespace.
2022-01-29: fschlimb
#655 Better handling of using declarations.
2022-01-29: dontpanic92
[Go] #676 Fix code generated for a C++ class with a non-capitalised
name.
2022-01-26: trex58
#1919 #1921 #1923 Various fixes for AIX portability.
2022-01-26: olly
#1935 Don't crash on an unclosed HTML tag in a doxygen comment
when -doxygen is specified.
2022-01-25: olly
Constant expressions now support member access with `.` such as
`foo.bar`. Previous this only worked in a case like `x->foo.bar`.
2022-01-25: olly
#2091 Support most cases of `sizeof` applied to an expression
in constant expressions. Previously there was only support for
`sizeof(<type>)` and expressions which syntactically look like a
type (such as `sizeof(foo)`).
2022-01-25: olly
#80 #635 https://sourceforge.net/p/swig/bugs/1139/
Add support for parsing common cases of `<` and `>` comparisons
in constant expressions. Adding full support for these seems hard
to do without introducing conflicts into the parser grammar, but in
fact all reported cases have had parentheses around the comparison
and we can support that with a few restrictions on the left side of
`<`.
2022-01-25: wsfulton
New warning 327 for extern templates, eg:
extern template class std::vector<int>;
extern template void Func<int>();
results in warning
example.i:3: Warning 327: Extern template ignored.
example.i:4: Warning 327: Extern template ignored.
Extern template classes previously resulted in warning 320.
2022-01-24: romintomasetti
#2131 #2157 C++11 extern function template parsing error fix.
2022-01-21: wsfulton
#2120 #2138 Replace legacy PCRE dependency with PCRE2.
This requires changes for building SWIG from source. See updated
html documentation in Preface.html and Windows.html. Updated
instructions are also shown when running ./configure if PCRE2 is not
found. Note that debian based systems can install PCRE2 using:
apt install libpcre2-dev
Note that https://github.com/swig/swig/wiki/Getting-Started also has
updated information for building from source.
2022-01-19: olly
[PHP] #2027 Automatically generate PHP type declarations for PHP 8.
The generate code still compiles for PHP 7.x, but without type
declarations since PHP 7.x has much more limited type declaration
support.
2022-01-18: olly
[Perl] #1629 Perl 5.8.0 is now the oldest version we aim to support.
2022-01-14: wsfulton
[Python] Fix %callback and specifying the callback function as a
static member function using Python staticmethod syntax, such as
Klass.memberfunction instead of Klass_memberfunction when using
-builtin and -fastproxy.
2022-01-11: wsfulton
[Python] Accept keyword arguments accessing static member functions when
using -builtin and kwargs feature and Python class staticmethod syntax.
The missing keyword argument support was only when using the
class staticmethod syntax, such as Klass.memberfunction, and not when
using the flat static method syntax, such as Klass_memberfunction.
2022-01-04: juierror
[Go] #2045 Add support for std::array in std_array.i.
2021-12-18: olly
[PHP] Add PHP keyword 'readonly' (added in 8.1) to the list SWIG
knows to automatically rename. This keyword is special in that PHP
allows it to be used as a function (or method) name.
2021-12-07: vstinner
[Python] #2116 Python 3.11 support: use Py_SET_TYPE()
2021-12-05: rwf1
[Octave] #2020 #1893 Add support for Octave 6 up to and including 6.4.
Also add support for compiling with -Bsymbolic which is used by default
by mkoctfile.
2021-12-02: jsenn
[Python] #2102 Fixed crashes when using embedded Python interpreters.
2021-11-12: wsfulton
[Javascript] v8 and node only. Fix mismatched new char[] and free()
when wrapping C code char arrays. Now calloc is now used instead of
new char[] in SWIG_AsCharPtrAndSize.
2021-10-03: ajrh1
[Perl] #2074: Avoid -Wmisleading-indentation in generated code
when using gcc11.
2021-10-03: jschueller
[CMake] #2065: Add option to enable or disable PCRE support.
2021-09-16: ianlancetaylor
[Go] Improved _cgo_panic implementation.
2021-09-16: ianlancetaylor
[Go] Don't use crosscall2 for panicking. Instead rely on documented
and exported interfaces.
2021-09-14: ianlancetaylor
[Go] Remove -no-cgo option (long unsupported in Go)
2021-05-04: olly
[PHP] #2014 Throw PHP exceptions instead of using PHP errors
PHP exceptions can be caught and handled if desired, but if they
aren't caught then PHP exits in much the same way as it does for a
PHP error.
In particular this means parameter type errors and some other cases
in SWIG-generated wrappers now throw a PHP exception, which matches
how PHP's native parameter handling deals with similar situations.
`SWIG_ErrorCode()`, `SWIG_ErrorMsg()`, `SWIG_FAIL()` and `goto thrown;`
are no longer supported (these are really all internal implementation
details and none are documented aside from brief mentions in CHANGES
for the first three). I wasn't able to find any uses in user interface
files at least in FOSS code via code search tools.
If you are using these:
Use `SWIG_PHP_Error(code,msg);` instead of `SWIG_ErrorCode(code);
SWIG_ErrorMsg(msg);` (which will throw a PHP exception in SWIG >= 4.1
and do the same as the individual calls in older SWIG).
`SWIG_FAIL();` and `goto thrown;` can typically be replaced with
`SWIG_fail;`. This will probably also work with older SWIG, but
please test with your wrappers if this is important to you.
*** POTENTIAL INCOMPATIBILITY ***
2021-05-17: adr26
[Python] #1985 Fix memory leaks:
1. Python object references were being incorrectly retained by
SwigPyClientData, causing swig_varlink_dealloc() never to run / free
memory. SwigPyClientData_New() / SwigPyClientData_Del() were updated
to fix the object reference counting, causing swig_varlink_dealloc()
to run and the memory swig_varlink owns to be freed.
2. SwigPyClientData itself was not freed by SwigPyClientData_Del(),
causing another heap leak. The required free() was added to
SwigPyClientData_Del()
3. Fix reference counting/leak of python cached type query
4. Fix reference counting/leak of SwigPyObject dict (-builtin)
5. Python object reference counting fixes for out-of-memory
scenarios were added to: SWIG_Python_RaiseOrModifyTypeError(),
SWIG_Python_AppendOutput(), SwigPyClientData_New(),
SwigPyObject_get___dict__() and SwigPyObject_format()
6. Add error handling for PyModule_AddObject() to
SWIG_Python_SetModule() (failure could be caused by OOM or a name
clash caused by malicious code)
2021-05-13: olly
[UFFI] #2009 Remove code for Common Lisp UFFI. We dropped support
for it in SWIG 4.0.0 and nobody has stepped forward to revive it in
over 2 years.
2021-05-13: olly
[S-EXP] #2009 Remove code for Common Lisp S-Exp. We dropped
support for it in SWIG 4.0.0 and nobody has stepped forward to
revive it in over 2 years.
2021-05-13: olly
[Pike] #2009 Remove code for Pike. We dropped support for it in
SWIG 4.0.0 and nobody has stepped forward to revive it in over 2
years.
2021-05-13: olly
[Modula3] #2009 Remove code for Modula3. We dropped support for it
in SWIG 4.0.0 and nobody has stepped forward to revive it in over 2
years.
2021-05-13: olly
[CLISP] #2009 Remove code for GNU Common Lisp. We dropped support
for it in SWIG 4.0.0 and nobody has stepped forward to revive it in
over 2 years.
2021-05-13: olly
[Chicken] #2009 Remove code for Chicken. We dropped support for it
in SWIG 4.0.0 and nobody has stepped forward to revive it in over 2
years.
2021-05-13: olly
[Allegrocl] #2009 Remove code for Allegro Common Lisp. We dropped
support for it in SWIG 4.0.0 and nobody has stepped forward to
revive it in over 2 years.
2021-05-04: olly
[PHP] #1982 #1457 https://sourceforge.net/p/swig/bugs/1339/
SWIG now only use PHP's C API to implement its wrappers, and no
longer generates PHP code to define classes. The wrappers should
be almost entirely compatible with those generated before, but
faster and without some previously hard-to-fix bugs.
The main notable difference is SWIG no longer generates a .php
wrapper at all by default (only if %pragma(php) code=... or
%pragma(php) include=... are specified in the interface file).
This also means you need to load the module via extension=...
in php.ini, rather than letting the dl() in the generated
.php wrapper load it (but dl() has only worked for command-line
PHP for some years now).
*** POTENTIAL INCOMPATIBILITY ***
2021-04-30: olly
#1984 Remove support for $source and $target.
These were officially deprecated in 2001, and attempts to use them have
resulted in a warning (including a pointer to what to update them to)
for most if not all of that time.
2021-04-27: wsfulton
#1987 [Java] Fix %interface family of macros for returning by const
pointer reference.
2021-04-19: olly
Fix use of uninitialised variable in the generated code for an
empty typecheck typemap, such as the dummy one we include for
std::initializer_list.
2021-04-12: olly
#1777 [Python] Specifying -py3 now generates a check for Python
version >= 3.0.
2021-03-26: olly
[PHP] Add PHP keywords 'fn' (added in 7.4) and 'match' (added in
8.0) to the list SWIG knows to automatically rename.
2021-03-23: wsfulton
#1942 [Python] Fix compilation error in wrappers when using -builtin
and wrapping varargs in constructors.
2021-03-22: goto40
#1977 Fix handling of template template parameters.
2021-03-21: olly
#1929, #1978 [PHP] Add support for PHP 8.
2021-03-19: wsfulton
#1610 Remove -ansi from default compilation flags.
2021-03-19: dot-asm
#1934 [Java] Clean up typemaps for long long arrays.
2021-03-19: olly
#1527 [PHP] Improve PHP object creation in directorin case.
Reportedly the code we were using in this case gave segfaults in
PHP 7.2 and later - we've been unable to reproduce these, but the
new approach is also simpler and should be bit faster too.
2021-03-18: olly
#1655 [PHP] Fix char* typecheck typemap to accept PHP Null like the
corresponding in typemap does.
2021-03-18: olly
#1900, #1905 [PHP] Fix wrapping of overloaded directed methods with
non-void return.
2021-03-11: murillo128
#1498 [Javascript] Support type conversion.
2021-03-06: nshmyrev
#872 [Javascript] Various typemap issues in arrays_javascript.i fixed.
2021-03-03: vaughamhong
#577 [Javascript] Implemented SetModule/GetModule for JSC to allow type sharing
across modules.
2021-03-01: xantares, Oliver Buchtala, geographika
#1040 Add support for building SWIG with CMake. See documentation in Windows.html.
2021-03-01: vadz
#1952 Fix incorrect warning "Unknown Doxygen command: ."
2021-02-28: p2k
#969 [Javascript] v8/node - prevent crash calling a constructor without new keyword.
2021-02-28: alecmev
#405 #1121 [Javascript] Fix OUTPUT typemaps on methods that don't return void.
The output value is appended to the return value.
2021-02-26: murillo128, wsfulton
#1269 [Javascript] Fix handling of large positive unsigned long and
unsigned long long values.
2021-02-24: tomleavy, yegorich, tungntpham
#1746 [Javascript] Add support for Node v12, v14 and v16.
SWIG support for Node is now for v6 and later only.
2020-02-09: ZackerySpytz
#1872 Fix typos in attribute2ref macros.
2020-10-10: wsfulton
[Javascript] Fix so that ccomplex.i interface to file can be used.
2020-10-10: wsfulton
#252 complex can now be used as a C identifier and doesn't give a syntax error.
2020-10-10: lpsinger
#1770 Correct C complex support.
_Complex is now parsed as a keyword rather than complex as per the C99 standard.
The complex macro is available in the ccomplex.i library file along with other
complex number handling provided by the complex.h header.
2020-10-07: ZackerySpytz
[Python] #1812 Fix the error handling for the PyObject_GetBuffer() calls in
pybuffer.i.
2020-10-07: treitmayr
#1824 Add missing space in director method declaration returning
const pointer.
2020-10-07: adelva1984
#1859 Remove all (two) exceptions from SWIG executable.
2020-09-25: wsfulton
[C#, Java] #1874 Add ability to change the modifiers for the interface
generated when using the %interface macros.
For C# use the 'csinterfacemodifiers' typemap.
For Java use the 'javainterfacemodifiers' typemap.
For example:
%typemap(csinterfacemodifiers) X "internal interface"
2020-09-24: geefr
[C#] #1868 Fix wchar_t* csvarout typemap for member variable wrappers.
2020-08-28: wsfulton
[Java] #1862 Fix crashes in swig_connect_director during director class construction
when using the director class from multiple threads - a race condition initialising
block scope static variables. The fix is guaranteed when using C++11, but most
compilers also fix it when using C++03/C++98.
2020-08-16: wsfulton
[Python] Add missing initializer for member '_heaptypeobject::ht_module' when using
-builtin to complete Python 3.9 support.
2020-08-16: wsfulton
[Python] Remove PyEval_InitThreads() call for Python 3.7 and later as Python calls
it automatically now. This removes a deprecation warning when using Python 3.9.
2020-08-15: wsfulton
[Python] All Python examples and tests are written to be Python 2 and Python 3
compatible, removing the need for 2to3 to run the examples or test-suite.
2020-08-13: wsfulton
[C#] Add support for void *VOID_INT_PTR for member variables.
2020-07-29: chrisburr
#1843 [Python] Compilation error fix in SwigPyBuiltin_SetMetaType when using PyPy.
2020-06-14: ZackerySpytz
#1642 #1809 Fix virtual comparison operators in director classes by removing an
incorrect space in the function name (for example, operator= = is now operator==).
Version 4.0.2 (8 Jun 2020)
==========================
2020-06-07 vigsterkr
[Ruby] #1717 Nil fix mangling strings
2020-06-07 vadz
#1748 Fix doxygen comments quoting issue
2020-06-07 munoah
#1800 Escape spaces in file paths for dependencies (-M -MM etc)
2020-06-06 andreas-schwab
[Ruby] #1801 Fix encoding on big endian systems when wrapping std::wstring.
2020-05-31 kwwette
[Octave] #1789 error handling improvements and return error code on exit for SWIG wrapped modules.
2020-05-30 msteinbeck
[D] #1593 Replace broken imports when using newer versions of D.
2020-05-29: ZackerySpytz
[Python] #1716 Performance improvements when converting strings when using Python >= 3.3.
2020-05-28: ZackerySpytz
#1776 Quite dramatically decrease run times when generating very large interface files by changing
some internal memory pool sizes.
2020-05-28: mcfarljm
#1788 Fix handling of Doxygen \endlink command.
2020-05-24: vapier
[Javascript] #1796 Fix pkg-config invocation in configure.
2020-04-30: kwwette
[Octave] Fix exception raising for newer Octave versions
Since (at least) Octave 5.1.0, the Octave error() function now raises a C++ exception,
which if uncaught immediately exits a SWIG wrapper function, bypassing any cleanup code
that may appear after a "fail:" label. This patch adds a "try { ... } catch(...) { }"
block around the contents of SWIG wrapper functions to first execute the cleanup code
before rethrowing any exception raised. It is backward compatible with earlier versions
of Octave where error() does not raise an exception, which will still branch to the
"fail:" block to execute cleanup code if an error is encountered.
Note that the new "try { ... } catch(...) { }" block will localise any local variables
used in typemaps that were NOT declared through SWIG's %typemap(...) syntax, so it's
possible this could break existing SWIG wrappers which were implicitly sharing local
variables between typemaps. This can be fixed, however, by declaring local variables
which need to be shared between typemaps through SWIG's %typemap(...) syntax.
2020-02-18: ryannevell
[Lua] #1728 Add support for LUA lightuserdata to SWIG_Lua_ConvertPtr.
2020-02-18: dmach
[Ruby] #1725 Fix gcc -Wcatch-value warnings.
2020-02-14: treitmayr
#1724 Fix wrapping of abstract user-defined conversion operators.
2020-02-13: ddurham2
[Python] #1512 Fix memleak when using STL containers of shared_ptr objects.
2020-02-06: wsfulton
[Python] #1673 #1674 Fix setting 'this' when extending a proxy class with __slots__.
2020-01-31: vadz
[Ruby] #1651 Add std::auto_ptr<> typemaps.
2020-01-31: ZackerySpytz
[Python] #1700 The Python C API functions PyBytes_AsStringAndSize() and
PyString_AsStringAndSize() are now checked for failure.
2020-01-31: vadz
[Python] #1710 Fix crash parsing empty docstrings.
2020-01-30: Alzathar
[R] #910 #914 Fix R memory leak on exception.
2020-01-30: richardbeare
[R] #1511 Fix bug wrapping functions. These were previously incorrectly wrapped as if
they were variables. This happened when 'get' or 'set' was in the name of the function
or method, but sometimes also in some other circumstances. If you were using R
attribute syntax to access these methods, you'll need to switch to calling them as R
methods.
*** POTENTIAL INCOMPATIBILITY ***
2020-01-24: etse-dignitas, wsfulton
[C#, D, Java] #1533 Fix upcasting for shared_ptr's of templated types.
2020-01-16: mcfarljm
#1643 #1654 When using -doxygen, fix segfault when nameless parameters or vararg parameters
are used.
2020-01-16: mcfarljm
#1632 #1659 Fix newline handling for doxygen "///" comments.
2020-01-14: mcfarljm
#1647 #1656 Fix crash handling empty doxygen comments.
2020-01-14: mcfarljm
#1608 Improve doxygen support.
- Add support for \param[] commands such as: \param[in].
- Optional arguments are marked as 'optional' in pydoc.
- Improve support for \code commands so that other languages are supported as code blocks.
Support added for java, c and py. For example Python: \code{.py} ... \endcode
- Fix doxygen handling of \em and \p tags for Python.
2020-01-13: wsfulton
[Python] #1595 Python -builtin constructors silently ignored keyword arguments.
Instead of silently ignoring them, now a "TypeError: f() takes no keyword arguments"
exception is thrown if keyword arguments are used. Hence constructors and normal methods/
functions behave in the same way. Note, -keyword should be used with -builtin to obtain
keyword argument support.
2020-01-05: jschueller shadchin
[Python] #1670 #1696 Add missing field initializers introduced in python 3.8:
tp_vectorcall and tp_print.
2020-01-05: friedrichatgc
[Octave] #1688 Change swig_this() to use size_t instead of long for compatibility
with Windows 64 bit.
2020-01-05: treitmayr
[Ruby] #1692 #1689 Add support for Ruby 2.7
2019-12-30: treitmayr
[Ruby] #1653 #1668 Fix code generated when using -globalmodule option.
2019-12-29: ZackerySpytz
[OCaml] #1686 Fix compilation errors with OCaml 4.09.0.
2019-12-10: wsfulton
#1679 Fix parsing of C++11 identifiers with special meaning (final and override) when
they are used as part of the scope name of an identifier, such as a namespace name.
2019-11-26: wsfulton
[C#] #1628 'out' or 'ref' used in a cstype typemap was not always stripped out in parts
of director code generation.
2019-11-01: wsfulton
[Python] #1595 Fix bug in support for keyword arguments (kwargs feature or -keyword)
when using -builtin. The fix is in the argument error checking when wrapping zero
argument constructors only.
Version 4.0.1 (21 Aug 2019)
===========================
2019-08-20: TekuConcept
[Javascript] #1535 Add %native support to Javascript.
2019-08-20: bkotzz
[Java] #1616 Add SWIG_JavaIllegalStateException to support throwing
java.lang.IllegalStateException from JNI code.
2019-08-19: sjml
[Lua] #1596 tostring output changes to show the underlying C/C++ pointer.
2019-08-08: rokups
[C#, Java] #1601 Fix invalid code generated for "%constant enum EnumType.
2019-08-07: wsfulton
[Python] Fix method overloading of methods that take STL containers of different
types. The following usage (using std::vector) would fail when using -builtin:
%include <std_string.i>
%include <std_vector.i>
%inline %{
struct X {};
%}
%template(VectorX) std::vector<X>;
%template(VectorInt) std::vector<int>;
%inline %{
using namespace std;
string VectorOverload(vector<X> v);
string VectorOverload(vector<int> v);
%}
The following would incorrectly fail:
s = VectorOverload([1, 2, 3])
With:
Traceback (most recent call last):
File "runme3.py", line 20, in <module>
ret = VectorOverload([1, 2, 3])
TypeError: Wrong number or type of arguments for overloaded function 'VectorOverload'.
Possible C/C++ prototypes are:
VectorOverload(std::vector< Number,std::allocator< Number > >)
VectorOverload(std::vector< int,std::allocator< int > >)
The problem was due to some error handling that was not cleared during typechecking.
In this case an error was not cleared when the elements in the list failed the
typecheck for converting to X. Only occurs in Python 3+.
In some combinations of overloaded methods, the following type of error message would
occur:
RuntimeError: in sequence element 0
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "runme3.py", line 23, in <module>
check(VectorOverload(v), "vector<X>")
SystemError: <built-in function VectorOverload> returned a result with an error set
2019-08-01: wsfulton
#1602 Fix regression in 4.0.0 where a template function containing a parameter
with the same name as the function name led to the parameter name used in the
target language being incorrectly modified.
2019-07-29: wsfulton
Remove all generated files on error. Previously generated files were not removed,
potentially breaking Makefiles using file dependencies, especially when -Werror
(warnings as errors) was used.
2019-07-23: smithx
[C#] #1530 #1532 Fix marshalling of std::wstring to C#.
2019-07-18: gicmo
[Python] #1587 Python 3.8 support - remove use of deprecated PyObject_GC_UnTrack.
2019-07-18: cher-nov
[Python] #1573 Generated Python code uses consistent string quoting style - double
quotes.
2019-07-16: geefr
[C#] #616 #1576 Fix C# bool INPUT[], bool OUTPUT[], bool INOUT[] typemaps to marshall
as 1-byte.
2019-07-12: vadz
[C#, Java] #1568 #1583 Fix std::set<> typemaps for primitive types.
2019-07-12: vadz
#1566 #1584 Regression in 4.0.0 - fix missing value for first item of enums with
trailing comma.
2019-07-11: mcfarljm
#1548 #1578 Fix segfault in Doxygen parser parsing empty lines in some commands like
\code.
2019-07-09: IsaacPascual
[C#, Java] #1570 Fix name of generated C#/Java classes for %interface macros
in swiginterface.i when wrapping nested C++ classes.
2019-07-05: wsfulton
[Python] #1547 Whitespace fixes in Doxygen translated comments into pydoc comments
for Sphinx compatibility.
2019-06-28: wsfulton
[MzScheme, OCaml] #1559 $arg and $input were incorrectly substituted in the
argout typemap when two or more arguments were present.
2019-06-24: wsfulton
[Python, Ruby] #1538 Remove the UnknownExceptionHandler class in order to be
C++17 compliant as it uses std::unexpected_handler which was removed in C++17.
This class was intended for director exception handling but was never used by
SWIG and was never documented.
*** POTENTIAL INCOMPATIBILITY ***
2019-06-06: bkotzz
[Java] #1552 Improve performance in Java std::vector constructor wrapper that takes
a native Java array as input.
2019-06-03: olly
[Python] Fix regression in implicit_conv handling of tuples,
introduced in SWIG 4.0.0. Fixes #1553, reported by Alexandre
Duret-Lutz.
2019-05-24: wsfulton
[Octave] Fix detection of Octave on MacOS.
2019-05-24: opoplawski
[Octave] #1522 Adapt OCTAVE_LDFLAGS for Octave 5.1.
2019-05-22: ferdynator
[PHP] #1528 Don't add a closing '?>' PHP tag to generated files.
PSR-2 says it MUST be omitted for files containing only PHP.
Version 4.0.0 (27 Apr 2019)
===========================
2019-04-24: vadz
#1517 Fix crash if "@return" Doxygen tag was used on a node without any return type.
2019-04-24: vadz
#1515 Fix parsing of enums with trailing comma when using -doxygen.
2019-04-19: ianlancetaylor
[Go] #1055 When generating Go code, make -cgo the default. Add new -no-cgo option
to disable the default.
2019-04-19: pbecherer
[Tcl] #1508 Fix Visual Studio 2015 and later compilation errors due to snprintf macro
definition.
2019-04-09: wsfulton
[C#] Fix FxCop warning CA2002 in SWIGPendingException - a lock on a reference of
type 'Type'.
2019-03-30: wsfulton
[Java, D] Add the parameters typemap attribute to the javadestruct,
javadestruct_derived, ddispose, ddispose_derived typemaps to mirror enhanced
flexibility in the csdisposing and csdisposing_derived (C#) typemaps. If provided
the contents are generated as the delete/dispose method's parameters declaration.
2019-03-30: wsfulton
[C#] #421 Fix FxCop warning CA1063 by implementing the recommended Dispose methods for
the IDisposable interface. Previously just the Dispose() method was generated.
Now the Dispose() and Dispose(bool disposing) methods are generated.
Changes are required if custom "csfinalize", "csdestruct" or "csdestruct_derived"
typemaps are being used. Details in #421 on Github. SWIG will error out if one of
the "csfinalize, "csdestruct" or "csdestruct_derived" typemaps are found. Example
error message:
foo.h:60: Error: A deprecated csfinalize typemap was found for Foo, please remove
it and replace all csdestruct, csdestruct_derived and csfinalize typemaps by the
csdispose, csdispose_derived, csdisposing and csdisposing_derived typemaps.
*** POTENTIAL INCOMPATIBILITY ***
2019-03-25: Liryna
[C#] #1143 Add std_list.i for std::list support.
The C# std::list<T> wrappers are made to look and feel like a C#
System.Collections.Generic.LinkedList<> collection.
The IEnumerable<> interface is implemented in the proxy class.
The ICollection<> interface can also be implemented to provide enhanced functionality
whenever a C++ operator== is available. This is the case for when T is a
primitive type or a pointer. If T does define an operator==, then use the
SWIG_STD_LIST_ENHANCED macro to obtain this enhanced functionality, for example:
SWIG_STD_LIST_ENHANCED(SomeNamespace::Klass)
%template(ListKlass) std::list<SomeNamespace::Klass>;
2019-03-18: richardbeare
[R] #1328 Non-trivial enums are working now. The enum values are now obtained from
the C/C++ layer. const reference enums and C++11 enum classes are also now working.
2019-03-14: mochizk
[Javascript] #1500 Fix compilation errors due to deprecating V8 API in Node.js.
New V8 API is used if node.js >= v10.12, or if V8 >= v7.0.
2019-03-12: vadz
[C#] #1495 Add std_set.i for std::set support.
2019-03-11: dirteat,opoplawski
[Octave] Fix compilation errors in Octave 5.1.
error: format not a string literal and no format arguments [-Werror=format-security]
2019-02-28: wsfulton
[Java] std::vector improvements for types that do not have a default constructor.
The std::vector wrappers have been changed to work by default for elements that are
not default insertable, i.e. have no default constructor. This has been achieved by
not wrapping:
vector(size_type n);
Previously the above had to be ignored via %ignore.
If the above constructor is still required it can be added back in again via %extend:
%extend std::vector {
vector(size_type count) { return new std::vector< T >(count); }
}
Alternatively, the following wrapped constructor could be used as it provides near-enough
equivalent functionality:
vector(jint count, const value_type& value);
*** POTENTIAL INCOMPATIBILITY ***
2019-02-25: wsfulton
[Python] Fix compile errors wrapping overloaded functions/constructors where a vararg
function is declared after a non-vararg function.
2019-02-23: zphensley42
Use fully qualified name 'java.lang.Object' instead of 'Object' in generated code to
avoid clashes with wrapped C++ classes called 'Object'.
2019-02-23: gtbX
[Java] #1035 Add (const char *STRING, size_t LENGTH) typemaps in addition to the non-const
typemaps (char *STRING, size_t LENGTH) which does not attempt to write back to the const
string.
2019-02-22: tamuratak
[Ruby] #984 Add support for RTypedData introduced in Ruby 1.9.3.
2019-02-22: ZackerySpytz
#1483 Fix compilation failures when a director class has final methods.
2019-02-21: wsfulton
[Java] #1240 Suppress Java 9 deprecation warnings on finalize method.
2019-02-21: ZackerySpytz
#1480 Fix some rejections of valid floating-point literals.
2019-02-19: wsfulton
#1475 Fix regression parsing gcc preprocessor linemarkers in the form:
# linenum filename flags
2019-02-18: jakecobb
[Python] #945 #1234 Elements in std::vector memory access fix.
Accessing an element in a std::vector obtains a reference to the element via an
iterator pointing to the element in the container. If the vector is garbage collected,
the SWIG wrapper containing the pointer to the element becomes invalid. The fix is
to obtain a back-reference to the container by the wrapper to the element in the Python
layer to prevent the garbage collector from destroying the underlying container.
2019-02-17: wsfulton
Fix typemap matching to expand template parameters when the name contains
template parameters. In the %typemap below the type is T and the name is X<T>::make
and the name now expands correctly to X< int >::make
template<typename T> struct X {
%typemap(out) T X<T>::make "..."
T make();
};
%template(Xint) X<int>;
2019-02-16: wsfulton
Fix parser error containing multiple #define statements inside an enum.
The second #define fails to parse:
enum FooEnum {
ENUM1 = 0,
ENUM2 = 1,
#define MACRO_DEF1 "Hello"
#define MACRO_DEF2 "World!"
ENUM3 = 2,
ENUM4 = 3,
};
Bug mentioned at https://sourceforge.net/p/swig/patches/333/
2019-02-14: wsfulton
Add some missing copy constructors into STL containers.
2019-02-14: bkotzz
[Java] #1356 Add STL containers:
std::unordered_map
std::unordered_set
std::set
2019-02-14: bkotzz
[Java] #1356 std::map wrappers have been modified. Now the Java proxy class
extends java.util.AbstractMap. The std::map container looks and feels much like
a java.util.HashMap from Java.
A few members have changed their names. If the old method signatures are needed,
then copy std_map.i from swig-3.0.12 and use that instead. Alternatively,
add the old missing methods to the new methods by using the following %proxycode:
%extend std::map {
%proxycode %{
// Old API
public boolean empty() {
return isEmpty();
}
public void set($typemap(jboxtype, K) key, $typemap(jboxtype, T) x) {
put(key, x);
}
public void del($typemap(jboxtype, K) key) {
remove(key);
}
public boolean has_key($typemap(jboxtype, K) key) {
return containsKey(key);
}
%}
}
*** POTENTIAL INCOMPATIBILITY ***
2019-02-13: ZackerySpytz
#1469 Add support for C++17 hexadecimal floating literals.
2019-02-11: wsfulton
[OCaml] #1437 OCaml has been give the 'Experimental' language status. The examples work
and most of the test-suite is also working, so it is quite close to being a 'Supported' language.
2019-02-10: ZackerySpytz
#1464 Add support for C++14 binary integer literals.
2019-02-10: ZackerySpytz
#1450 Add support for C++11 UCS-2 and UCS-4 character literals. Also, add support for
C++17 UTF-8 character literals.
2019-02-10: wsfulton
[MzScheme] #1437 MzScheme/Racket is now an 'Experimental' language. The examples work
and a large portion of the test-suite is also working.
2019-02-10: wsfulton
[MzScheme] Destructor wrappers were not being generated.
2019-02-10: wsfulton
[MzScheme] Static variable wrappers fixed - $argnum was not expanded.
2019-02-10: sethrj
#1452 Fix %apply for anonymous template instantiations
2019-02-09: olly
[PHP] Fix access to already released memory during PHP module
shutdown, which often didn't cause visible problems, but could
result in segmentation faults, bus errors, etc. Fixes #1170,
reported by Jitka Plesníková.
2019-02-09: olly
[PHP] A renamed constructor is now wrapped as a static method in
PHP.
2019-02-08: olly
[PHP] Don't generate code which references $r when $r hasn't been
defined. This could happen in overloaded methods which returned
void and took at least one const std::string& parameter.
2019-02-08: olly
[PHP] The generated code is now compatible with PHP 7.3, and the
testsuite now runs cleanly with this version too.
2019-02-05: wsfulton
#1437 SWIG now classifies the status of target languages into either 'Experimental' or
'Supported'. This status is provided to indicate the level of maturity to expect when using
a particular target language as not all target languages are fully developed. Details are
in the Introduction.html chapter of the documentation.
2019-02-04: wsfulton
[CFFI] #1447 Common Lisp CFFI has been disabled as a target language in SWIG as part of a
clean up to remove target languages that have been neglected/not functional.
2019-02-04: wsfulton
[Allegrocl] #1447 Allegro Common Lisp has been disabled as a target language in SWIG as part of a
clean up to remove target languages that have been neglected/not functional.
2019-02-04: wsfulton
[Chicken] #1447 CHICKEN has been disabled as a target language in SWIG as part of a
clean up to remove target languages that have been neglected/not functional.
2019-02-04: wsfulton
[CLISP] #1447 GNU Common Lisp has been disabled as a target language in SWIG as part of a
clean up to remove target languages that have been neglected/not functional.
2019-02-04: wsfulton
[S-EXP] #1447 Common Lisp S-Exp has been disabled as a target language in SWIG as part of a
clean up to remove target languages that have been neglected/not functional.
2019-02-04: wsfulton
[UFFI] #1447 Common Lisp UFFI has been disabled as a target language in SWIG as part of a
clean up to remove target languages that have been neglected/not functional.
2019-02-04: wsfulton
[Pike] #1447 Pike has been disabled as a target language in SWIG as part of a
clean up to remove target languages that have been neglected/not functional.
2019-02-04: wsfulton
[Modula3] #1447 Modula3 has been disabled as a target language in SWIG as part of a
clean up to remove target languages that have been neglected/not functional.
2019-02-02: ahnolds
[Python] Documentation enhancements for Python:
#728 Fixed the handling of autodoc when using -fastproxy.
#1367 Added documentation to wrapped member variables using the
property(... doc="...") construct.
Only show a single documentation entry for functions with default arguments when
using autodoc.
Fixed a bug where a cached doxygen docstring could be deleted while still in use,
causing swig to segfault.
2019-01-31: olly
SWIG now requires a target language to be specified instead of
defaulting to wrapping for Tcl. Specifying swig --help without
a target language now just shows the generic help. The -nolang
option has been removed.
2019-01-28: ZackerySpytz
[OCaml] #1429 Remove support for OCaml versions < 3.12.0.
*** POTENTIAL INCOMPATIBILITY ***
2019-01-22: vadz
[Ruby, Octave] #1424 Improve autodoc parameter naming.
2019-01-22: vadz
[Python] #1271 #1423 Always include default parameter values in autodoc strings.
2019-01-19: vadz
#1272, #1421 When a function's parameter is a keyword, the name of the paramater is
no longer simply changed to argN, where N is the argument number. Instead the
parameter name is changed to the renaming rules for keywords that normally apply to
symbols such as classes/functions etc. Note that unlike other symbol renaming,
parameter renaming does not issue a warning when the parameter is renamed. This
change only affects languages where the parameter names are actually used, for example,
Java function parameter lists in the proxy class or Python documentation comments.
2019-01-18: wsfulton
#1420 Fix gdb debugger functions 'swigprint' and 'locswigprint' from swig.gdb to
work with newer versions of gdb-8. Fixes errors when debugging SWIG source with gdb:
(gdb) swigprint n
Undefined command: "Printf". Try "help".
2019-01-16: wsfulton
Python static method wrapper changes
- Static method wrappers were using the 'fastproxy' approach by default.
This is inconsistent with instance method wrappers. The fastproxy approach
is now turned off by default to be consistent with instance methods.
Static method wrappers can now also be controlled using the -fastproxy and
-olddefs options.
Example:
struct Klass {
static int statmethod(int a = 2);
};
generates by default:
class Klass(object):
...
@staticmethod
def statmethod(a=2):
return _example.Klass_statmethod(a)
instead of the following (which can be restored by using -fastproxy):
class Klass(object):
...
statmethod = staticmethod(_example.Klass_statmethod)
- Modernise wrappers for static methods to use decorator syntax - @staticmethod.
- Add missing runtime test for static class methods and using the actual class method.
2019-01-12: ZackerySpytz
[OCaml] #1403 #1194 Fix compilation problems for OCaml >= 4.03.0 due to OCaml using
int64_t instead of int64.
2019-01-11: ZackerySpytz
[OCaml] #1400 Fix the getters and setters of non-static member variables.
2019-01-07: wsfulton
#358 Add VOID to windows.i
2019-01-05: wsfulton
#948 #1019 #1273 Fix for C++11 raw strings where the delimiters were mistakenly left
in the string contents in situations where the string was copied into generated code.
For example, %constant, the "docstring" feature and for C#/Java/D constants turned on
with %javaconst/%csconst/%dmanifestconst.
2019-01-05: wsfulton
[Ruby] #538. Fix Ruby support for %feature("docstring").
2019-01-03: wsfulton
#1202 Fix overloading of non-pointer class types in scripting languages when overloaded
with a pointer and a NULL scripting language equivalent is used, eg None in Python.
The implementation changes the SWIGTYPE, SWIGTYPE& and SWIGTYPE&& typecheck typemaps to
prevent accepting a conversion to a NULL pointer.
2019-01-03: ZackerySpytz
[OCaml] #1386 Fix the OCaml examples and test suite for out-of-source builds.
2019-01-01: wsfulton
[Python] #639 remove duplicate proxy method definitions for global function wrappers.
Global functions previously generated two definitions, eg:
def foo():
return _example.foo()
foo = _example.foo
The first definition is replaced by the second definition and so the second definition
is the one used when the method is actually called. Now just the first definition is
generated by default and if the -fastproxy command line option is used, just the second
definition is generated. The second definition is faster as it avoids the proxy Python
method as it calls the low-level C wrapper directly. Using both -fastproxy and -olddefs
command line options will restore the previously generated code as it will generate both
method definitions.
With this change, the wrappers for global C/C++ functions and C++ class methods now work
in the same way wrt to generating just a proxy method by default and control via
-fastproxy/-olddefs options.
2018-12-20: hasinoff,wsfulton
[Java] #1334 Set Java thread name to native thread name when using directors.
Default is to use name "Thread-XXX" and is still works like this by default. However,
adding the following will turn on the thread name setting (works for more recent
versions of Linux and MacOS):
%begin %{
#define SWIG_JAVA_USE_THREAD_NAME
%}
2018-12-20: chlandsi
[Python] #1357. Fix overriding __new__ in Python 3.6.
Fixes SystemError: Objects/tupleobject.c:81: bad argument to internal function"
2018-12-16: wsfulton
[Python] #848 #1343 The module import logic has changed to stop obfuscating real ImportError
problems. Only one import of the low-level C/C++ module from the pure Python module is
attempted now. Previously a second import of the low-level C/C++ module was attempted
after an ImportError occurred and was done to support 'split modules'. A 'split module' is
a configuration where the pure Python module is a module within a Python package and the
low-level C/C++ module is a global Python module. Now a 'split module' configuration is
no longer supported by default. This configuration can be supported with a simple
customization, such as:
%module(package="mypackage", moduleimport="import $module") foo
or if using -builtin:
%module(package="mypackage", moduleimport="from $module import *") foo
instead of
%module(package="mypackage") foo
See the updated Python chapter titled "Location of modules" in the documentation.
2018-12-11: tlby
[Perl] #1374 repair EXTEND() handling in typemaps
2018-12-06: vadz
#1359 #1364 Add missing nested class destructor wrapper when the nested class is
inside a template. Removes associated bogus 'Illegal destructor name' warning. Only
occurred when the nested class' destructor is explicitly specified.
2018-12-04: adr26
[Python] #1368 #1369 Access Violation in tp_print caused by mismatched Python/extension
CRT usage
Remove all use of tp_print, as this API uses a FILE*, which can be
mismatched when modules are built with different C libraries from
the main python executable.
This change also brings consistent output between Python 2 and 3 for the 'cvar' SWIG
object (that contains the global variables) and SWIG packed objects (such as callback
constants).
2018-12-04: wsfulton
[Python] #1282 Fix running 'python -m' when using 'swig -builtin'
Similar to the earlier PEP 366 conforming fix for non-builtin.
2018-11-29: adr26
[Python] #1360 Leak of SWIG var link object
Fix reference counting on _SWIG_globals to allow var link to be freed on module unload.
2018-11-28: wsfulton
[Python] When using -builtin, the two step C-extension module import is now
one step and the wrapped API is only available once and not in an underlying
module attribute like it is without -builtin. To understand this, consider a
module named 'example' (using: %module example). The C-extension is compiled into
a Python module called '_example' and a pure Python module provides the actual
API from the module called 'example'. It was previously possible to additionally
access the API from the module attribute 'example._example'. The latter was an
implementation detail and is no longer available. It shouldn't have been used, but
if necessary it can be resurrected using the moduleimport attribute described in the
Python chapter of the documentation. If both modules are provided in a Python
package, try:
%module(moduleimport="from . import _example\nfrom ._example import *") example
or more generically:
%module(moduleimport="from . import $module\nfrom .$module import *") example
and if both are provided as global modules, try:
%module(moduleimport="import _example\nfrom _example import *") example
or more generically:
%module(moduleimport="import $module\nfrom $module import *") example
The module import code shown will appear in the example.py file.
2018-11-24: vadz
#1358 Fix handling of abstract base classes nested inside templates
Correct detecting of whether a derived class method overrides a pure virtual
base class method when both classes are nested inside a template class: this
notably didn't work correctly for methods taking parameters of the base class
type.
2018-11-22: rupertnash
[Python] #1282 Make generated module runnable via python -m (PEP 366 conforming)
Previously any SWIG generated modules in a package would fail with an ImportError
when using 'python -m' for example 'python -m mypkg.mymodule'.
This fix also allows the SWIG generated module to be placed into a directory and
then renamed __init__.py to convert the module into a package again. This ability
stopped working in swig-3.0.9. However, only Python 2.7 or 3.3 and later work. If
Python 3.2 support is needed, use moduleimport in %module to customise the import
code.
2018-11-13: wsfulton
#1340 Remove -cppcast and -nocppcast command line options (this was an option
available to the scripting language targets).
The -cppcast option is still turned on by default. The -nocppcast option
to turn off the use of c++ casts (const_cast, static_cast etc) has been
removed. However, defining SWIG_NO_CPLUSPLUS_CAST will still generate C casts
instead of C++ casts for C++ wrappers.
*** POTENTIAL INCOMPATIBILITY ***
2018-11-13: wsfulton
[Python] #1340 Remove -outputtuple and -nooutputtuple command line options.
Both the command line and %module options of the same name have been
removed. These were undocumented. The -outputtuple option returned a
Python tuple instead of a list, mostly typically in the OUTPUT
typemap implementations.
It unclear why a tuple instead of a list return type is needed and
hence this option has been removed as part of the simplification of
the SWIG Python command line options for SWIG 4.
2018-11-13: wsfulton
[Python] #1340 Remove -noproxyimport command line option.
This option turned off the insertion of Python import statements
derived from a %import directive. For example given:
%module module_b
%import "module_a.i"
then module_b.py will contain:
import module_a
*** POTENTIAL INCOMPATIBILITY ***
2018-10-29: AlexanderGabriel
[PHP] The following PHP7 reserved keywords are now only renamed by
SWIG when used as function names in the API being wrapper:
__halt_compiler array die echo empty eval exit include include_once
isset list print require require_once return unset
2018-10-22: olly,wsfulton
[Python] #1261 #1340 Turn on many optimisation options by default and rationalise the
number of command line options.
There were an unnecessary number of command line options and many of these have now
been removed in a drive for simplification. Some were needed to support older versions
of Python (2.6 and earlier).
Many of the options could be turned on individually and when using -O. Previously -O
resulted in turning on a set of options:
-modern -fastdispatch -nosafecstrings -fvirtual -noproxydel
-fastproxy -fastinit -fastunpack -fastquery -modernargs -nobuildnone
Now -O results in turning on this reduced set:
-fastdispatch -fastproxy -fvirtual
The following options are now on by default, a deprecated warning is displayed if they
are used:
-fastinit Class initialisation code done in C/C++ rather than in Python code.
-fastquery Python dictionary used for lookup of types.
-fastunpack Faster unpacking of function arguments in C/C++ wrappers.
-modern Use Python 2.3 features such as object and property.
-modernargs Use Python 2.3 C APIs for unpacking arguments in tuples.
-noproxydel Stop generating a proxy __del__ method for backwards compatiblity.
-safecstrings No discernable difference
The following options have been removed altogether:
-aliasobj0
-buildnone
-classptr
-new_repr
-newrepr
-noaliasobj0
-nobuildnone
-nocastmode
-nodirvtable
-noextranative
-nofastinit
-nofastproxy
-nofastquery
-nomodern
-nomodernargs
-nooutputtuple
-nosafecstrings
-old_repr
-oldrepr
-proxydel
-new_vwm is no longer supported. Use the -newvwm alias instead.
*** POTENTIAL INCOMPATIBILITY ***
2018-10-22: olly
[Python] #1261 Remove command line option no longer needed as Python 2.3 and earlier
are no longer supported:
-classic
2018-10-09: wsfulton
[D, Go, Guile, Lua, Mzscheme, Ocaml, Perl5, Php, Scilab, Tcl]
Allow wrapping of std::map using non-default comparison function.
2018-10-09: vadz
[Java] #1274 Allow wrapping of std::map using non-default comparison function.
2018-10-04: wsfulton
[Python] #1126 Fix C default arguments with -builtin and -fastunpack and -modernargs.
Problem occurred when there is just one (defaulted) parameter in the parameter list.
2018-09-24: wsfulton
[Python] #1319 C++11 hash tables implementation is finished now (including for -builtin):
std::unordered_map
std::unordered_set
std::unordered_multimap
std::unordered_multiset
2018-09-21: wsfulton
[Python] Fix when using -builtin and wrapping std::map, std::set, std::unordered_map or
std::unordered_set to ensure __contains__ is called. This is a wrapper for the STL
container's find method. Without it, Python will do its own slower sequence search.
2018-09-19: wsfulton
[Python] Fix functors (wrapped as __call__) when using -builtin -modern -fastunpack.
2018-09-02: andreas.gaeer,tkrasnukha
[Python] #1321 Fix assert in PyTuple_GET_SIZE in debug interpreter builds of python-3.7
when calling tp_new.
2018-09-01: ChristopherHogan
[Guile] #1288 Fix garbage collection for guile >= 2.0.12.
2018-08-31: wsfulton
[Python] #1319 C++11 hash tables support:
std::unordered_map
std::unordered_set
std::unordered_multimap
std::unordered_multiset
is now compiling and working (sorting using -builtin not fully functional yet though).
2018-08-20: wkalinin
#1305 Fix nested structure symbol tables in C mode to fix member name conflicts
in different structs with the same nested struct member name.
2018-08-18: wsfulton
[Python] #688 Fix makefile recursion when running python test-suite.
2018-08-18: wsfulton
[Python] #1310 Re-implement Python -fastproxy option.
The previous implementation failed with Python 3 and abstract base clases.
The new implementation replaces the Python 2 implementation using
new.instancemethod with the C API PyMethod_New to match the equivalent Python 3
implementation which uses PyInstanceMethod_New.
The new approach runs slightly faster. See #1310.
2018-08-12: gmazzamuto
[Python] #1283 Update pybuffer.i library to use new-style Python buffer C API.
2018-08-12: brianhatwood,wsfulton
[Java] #1303 #1304 Fix crash in directors when using OUTPUT and INOUT typemaps in typemaps.i and
passing NULL pointers in C++ to director method overloaded and implemented in Java.
2018-08-10: wsfulton
[Python] #1293 Improve TypeError message inconsistencies between default and fastdispatch
mode when handling overloaded C++ functions. Previously the error message did not always
display the possible C/C++ prototypes in fastdispatch mode.
2018-08-02: furylynx,jacobwgillespie,p2k
[Javascript] #1290, #968. Add support for NodeJS versions 2-10.
2018-07-31: wsfulton
[Python] #1293 Overloaded C++ function wrappers now raise a TypeError instead
of NotImplementedError when the types passed are incorrect. This change means
there is now consistency with non-overloaded function wrappers which have always
raised TypeError when the incorrect types are passed. The error message remains
the same and is for example now:
TypeError: Wrong number or type of arguments for overloaded function 'f'.
Possible C/C++ prototypes are:
f(int)
f(char const *)
instead of:
NotImplementedError: Wrong number or type of arguments for overloaded function 'f'.
Possible C/C++ prototypes are:
f(int)
f(char const *)
*** POTENTIAL INCOMPATIBILITY ***
2018-06-23: wsfulton
[Python] #718 Fix pythonnondynamic feature for modern classes
Fixes nondynamic mode when an instance variable is set with the same
name as a class variable in a class derived from a SWIG proxy class.
This corner case set an instance variable instead of raising an AttributeError.
Also fix %pythonnondynamic in Python 3 with -modern. The metaclass
containing the implementation was previously not being applied in Python 3.
2018-07-17: petrmitrichev,wsfulton
[Python] #1275 #1279 Initialize function-local statics (singletons) that call Python
code during Python module initialization in order to avoid deadlocks with subsequent
multi-threaded usage.
2018-06-15: wsfulton
[Python] Fix seg fault using Python 2 when passing a Python string, containing
invalid utf-8 content, to a wstring or wchar * parameter. A TypeError is thrown instead, eg:
%include <std_wstring.i>
void instring(const std::wstring& s);
instring(b"h\xe9llooo") # Python
2018-06-15: wsfulton
[Python] Python 3.7 support: Replace use of deprecated PyUnicode_GetSize with
PyUnicode_GetLength to remove deprecated warnings compiling the C/C++ wrappers.
2018-06-12: wsfulton
[Python] Python 3.7 support: The %pythonabc feature in pyabc.i now uses base classes
collections.abc.MutableSequence
collections.abc.MutableMapping
collections.abc.MutableSet
instead of
collections.MutableSequence
collections.MutableMapping
collections.MutableSet
as the latter are deprecated in Python 3.7 and are due to be removed in Python 3.8.
The classes in collections.abc.* are available from Python 3.3 onwards. If you
require support for Python 3.2, then copy the pyabc.i file and modify by removing
the few instances of the .abc sub-module.
*** POTENTIAL INCOMPATIBILITY ***
2018-06-12: olly,wsfulton
[Python] #701 Remove support for Python versions < 2.7 and 3.0 and 3.1.
*** POTENTIAL INCOMPATIBILITY ***
2018-06-11: olly
[Python] Fix new GCC8 warnings in generated code by avoiding casts
between incompatible function types where possible, and by
suppressing the warning when it's due to the design of Python's C
API. Fixes #1259.
2018-06-08: philippkraft
[Python] Stop exposing <CLASS>_swigregister to Python. It's not
useful for user Python code to call this, and it just clutters the
API unnecessarily. Fixes #1225.
2018-06-07: cmfoil, kabbi, Jamie Kirkpatrick, markok314, vadz, wsfulton, Yann Diorcet
#170 Doxygen documentation support added. This allows translation of Doxygen comments
into JavaDoc and PyDoc documentation. It is enabled via the -doxygen command line
option. See the Doxygen.html chapter in the documentation for further information.
2018-06-07: olly
[PHP] We've finally removed support for %pragma(php4) which was
deprecated back in 2008. Use %pragma(php) instead, which has been
supported since at least 2005.
*** POTENTIAL INCOMPATIBILITY ***
2018-06-07: olly
[PHP5] Support for PHP5 has been removed. PHP5 is no longer
actively supported by the PHP developers and security support for
it ends completely at the end of 2018, so it doesn't make sense
to include support for it in the upcoming SWIG 4.0.0 release.
*** POTENTIAL INCOMPATIBILITY ***
2018-06-06: olly
[Lua] Improve configure probes for Lua headers and libs used in testsuite.
2018-05-15: kwwette
[Octave] add support for version 4.4
- Should not introduce any user-visible incompatibilities
2018-05-15: wsfulton
[C#, D, Java] Fix lookup of csconstruct, dconstruct and javaconstruct typemaps.
The C++ namespace was previously ignored when looking up the typemap.
2018-05-15: wsfulton
[Javascript] Fix generated C++ code when using %nspace on namespaces that are more
than two levels deep.
2018-05-14: wsfulton
Issue #1251 Add support for C++17 nested namespace definitions,
for example:
namespace A::B { ... }
2018-05-11: wsfulton
[C#, D, Java] Add support so that the %csmethodmodifiers, %dmethodmodifiers,
%javamethodmodifiers can modify the method modifiers for the destructor wrappers
in the proxy class: dispose, Dispose, delete. With this feature, it is now possible
to make a C# proxy class sealed, eg when wrapping a class X, the virtual method modifiers
can be removed using:
%typemap(csclassmodifiers) X "public sealed class"
%csmethodmodifiers X::~X "public /*virtual*/";
2018-04-18: olly
[Python] Suppress new pycodestyle warning:
E252 missing whitespace around parameter equals
2018-04-07: goatshriek
[Ruby] #1213 Fix ruby %alias directive for global C/C++ functions.
2018-04-03: olly
[Ruby] Fix to pass Qnil instead of NULL to rb_funcall(), which silences GCC
-Wconversion-null warning (on by default with recent GCC).
2018-03-09: wsfulton
[Java] #1184 Fix swigReleaseOwnership() and swigTakeOwnership() regression
for non-director classes. Restores a dynamic_cast which was previously removed.
2018-03-07: llongi
Github PR #1166 - Fix preprocessor handling of macros with commas
in a // comment.
2018-02-18: JPEWdev
Patch #1164 - Add support for a command-line options file, also sometimes
called a response file. This is useful if the command-line options exceed
the system command-line length limit. To use, put the command-line options
into a file, then provide the file name prefixed with @, for example using
a file called args.txt:
swig @args.txt
2018-02-11: wsfulton
[Javascript] #1187 Fix compilation error wrapping std::complex via
std_complex.i.
2018-01-30: smarchetto
[Scilab] add type name argument in SWIG_ptr() function to cast from pointer address to typed pointers
2018-01-16: wsfulton
Expressions following a preprocessor directive must now be separated by whitespace
or non-numeric characters. This syntax change makes the SWIG preprocessor work like
the C preprocessor in this area.
For example, the following code used be accepted as valid syntax:
#if1
#define ABC 123
#endif
Now you get an error:
example.h:1: Error: Unknown SWIG preprocessor directive: if1 (if this is a block of
target language code, delimit it with %{ and %})
example.h:3: Error: Extraneous #endif.
The following is the correct syntax:
#if 1
#define ABC 123
#endif
The following of course also works:
#if(1)
#define ABC 123
#endif
*** POTENTIAL INCOMPATIBILITY ***
2018-01-15: wsfulton
Fix issue #1183. Floating point exception evaluating preprocessor expressions
resulting in division by zero.
2018-01-14: wsfulton
Fix issue #1172. Seg fault parsing invalid exponents in the preprocessor.
2018-01-12: Liryna
[C#] Patch #1128. Add ToArray function to std::vector wrappers.
2018-01-12: wsfulton
[Java] Fix issue #1156. Add missing throws clause for interfaces when using the
%interface family of macros.
2018-01-05: wsfulton
Fix default arguments using expressions containing -> syntax error. Problem reported on
swig-user mailing list.
2017-12-30: wsfulton
[Python] Replace pep8 with pycodestyle for checking the Python code style when
running Python tests.
2017-12-30: davedissian
Fixed a symbol lookup issue when encountering a typedef of a symbol from the tag
namespace to the global namespace when the names are identical, such as 'typedef
struct Foo Foo;'.
2017-12-13: wsfulton
[Perl] add missing support for directorfree typemaps.
2017-12-13: wsfulton
Issue #1167 Fix directorout typemaps which were causing undefined behaviour when
returning pointers by reference.
2017-12-08: olly
[PHP] Use ZEND_MODULE_GLOBALS_ACCESSOR to access globals so the
generated code builds when PHP was built with ZTS enabled.
2017-12-04: wsfulton
[Python] Add missing checks for failures in calls to PyUnicode_AsUTF8String. Previously a
seg fault could occur when passing invalid UTF8 strings (low surrogates), eg passing
u"\udcff" to the C layer (Python 3).
2017-11-24: joequant
[R] Fix #1124 and return R_NilValue for null pointers
2017-11-29: wsfulton
[Java] director exception handling improvements.
When a director method throws an exception and it is caught by DirectorException
and passed back to Java using Swig::DirectorException::throwException, the Java
stack trace now contains the original source line that threw the exception.
Deprecate Swig::DirectorException::raiseJavaException, please replace usage with
Swig::DirectorException::throwException.
*** POTENTIAL INCOMPATIBILITY ***
2017-10-26: wsfulton
Add support for C++11 ref-qualifiers when using directors.
2017-10-26: wsfulton
Fix generated code when using directors and methods returning const ref pointers.
2017-10-26: wsfulton
[C#, D, Java, Octave, R, Scilab] Port director typemaps to these additional languages.
Issue #700.
2017-10-26: radarsat1
[Ruby Python] Patch #1029 - Correct handling of null using directors and shared_ptr.
2017-10-10: joequant
[R] pass enum expressions to R. This will generate
incorrect files when there is an arithmetic expression
in the enum, but this is better than silently generating
incorrect code
2017-10-09: olly
[PHP] Fix incorrect wrapper code generated when there's a
combination of overloading, parameters with a default value
and %newobject. Fixes https://sourceforge.net/p/swig/bugs/1350/
2017-10-09: olly
Remove GCJ support. It isn't in a good state and doesn't seem to
be used, and GCC7 dropped GCJ. Closes
https://sourceforge.net/p/swig/bugs/823/
2017-10-07: olly
Fix preprocessor handling of empty macro arguments to match that of
C/C++ compilers. Fixes issue #1111 and
https://sourceforge.net/p/swig/bugs/826/
2017-10-06: wsfulton
[Python] Issue #1108. Fix platform inconsistency in Python default argument handling.
32 bit and 64 bit compiled versions of SWIG generated different Python files
when default arguments were outside the range of 32 bit signed integers.
The default arguments specified in Python are now only those that are in the
range of a 32 bit signed integer, otherwise the default is obtained from C/C++ code.
2017-10-02: wsfulton
[C#] Fix std::complex types passed by value.
2017-10-02: wsfulton
[Javascript, Python, Ruby] Issue #732 - Missing type information for std::complex
in std_complex.i meant that previously std::complex always had to be fully qualified
in order to be wrapped with the appropriate typemaps.
2017-10-01: joequant
allow R package names with docs
allowing multiple get accessors in R
fix smart-pointer and NAMESPACE support
constructors now returning smart pointers (if class
declared as such)
smart-pointer classes deriving from parent smart-pointers
2017-09-29: wsfulton
Issue #1100 - Allow an instantiated template to have the same name in the target
language as the C++ template name, for example, this is now possible:
template<typename T> struct X { ... };
%template(X) X<int>;
2017-09-23: wsfulton
Issue #1098. Fix overloading of shared_ptr with underlying pointer types, eg:
void m(std::shared_ptr<T> p);
void m(T &p);
void m(T *p);
Only the first method is wrapped and the others are ignored/shadowed.
The implementation is done via a new attribute in the 'typecheck' typemap called
'equivalent'. If specified, it must contain the equivalent pointer type for overloading
and can only be used for the special SWIG_TYPECHECK_POINTER precedence level.
The shared_ptr 'typecheck' typemaps have been modified accordingly.
Here is a simplified version:
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="T *")
T,
T CONST &,
T CONST *,
T *CONST&,
std::shared_ptr< T >,
std::shared_ptr< T > &,
std::shared_ptr< T > *,
std::shared_ptr< T > *&
{ ... }
Overloading with any of these types will result in SWIG ignoring all but the first
overloaded method by default. Without the 'equivalent' attribute, wrapping the overloaded
methods resulted in types being shadowed (scripting languages) or code that did not
compile (statically typed languages).
2017-09-19: futatuki
[Python] #1003 Add --with-2to3=/path/to/2to3 option to configure.
2017-09-18: wsfulton
Fix type promotion wrapping constant expressions of the form:
# define EXPR_MIXED1 (0x80 + 11.1) - 1
This was previously an integral type instead of a floating point type.
2017-09-17: wsfulton
Fix generated code for constant expressions containing wchar_t L literals such as:
# define __WCHAR_MAX (0x7fffffff + L'\0')
# define __WCHAR_MIN (-__WCHAR_MAX - 1)
2017-09-10: mlamarre
[Python] Patch #1083. Define_DEBUG to 1 to do exactly like Visual Studio
/LDd, /MDd or /MTd compiler options.
2017-08-25: wsfulton
Issue #1059. Add support for C++11 ref-qualifiers on non-static member functions.
Members with lvalue ref-qualifiers such as:
struct RQ {
void m1(int x) &;
void m2(int x) const &;
};
are wrapped like any other member function. Member functions with rvalue ref-qualifiers
are ignored by default, such as:
struct RQ {
void m3(int x) &&;
void m4(int x) const &&;
};
example.i:7: Warning 405: Method with rvalue ref-qualifier m3(int) && ignored.
example.i:8: Warning 405: Method with rvalue ref-qualifier m4(int) const && ignored.
These can be unignored and exposed to the target language, see further documentation in
CPlusPlus11.html.
2017-08-16: wsfulton
Fix #1063. Add using declarations to templates into typedef table.
Using declarations to templates were missing in SWIG's internal typedef tables.
This led to a few problems, such as, templates that did not instantiate and generated
C++ code that did not compile as SWIG did not know what scope the template was
in. This happened mostly when a using declaration was used on a template type in a
completely unrelated namespace.
2017-08-16: wsfulton
Fix type lookup in the presence of using directives and using declarations.
Fix some cases of type lookup failure via a combination of both using directives and
using declarations resulting in C++ code that did not compile as the generated type was
not fully qualified for use in the global namespace. Example below:
namespace Space5 {
namespace SubSpace5 {
namespace SubSubSpace5 {
struct F {};
}
}
using namespace SubSpace5;
using SubSubSpace5::F;
void func(SubSubSpace5::F f);
}
2017-08-16: wsfulton
Issue #1051. %template scope enforcement and class definition fixes.
The scoping rules around %template have been specified and enforced.
The %template directive for a class template is the equivalent to an
explicit instantiation of a C++ class template. The scope for a valid
%template instantiation is now the same as the scope required for a
valid explicit instantiation of a C++ template. A definition of the
template for the explicit instantiation must be in scope where the
instantiation is declared and must not be enclosed within a different
namespace.
For example, a few %template and C++ explicit instantiations of std::vector
are shown below:
// valid
namespace std {
%template(vin) vector<int>;
template class vector<int>;
}
// valid
using namespace std;
%template(vin) vector<int>;
template class vector<int>;
// valid
using std::vector;
%template(vin) vector<int>;
template class vector<int>;
// ill-formed
namespace unrelated {
using std::vector;
%template(vin) vector<int>;
template class vector<int>;
}
// ill-formed
namespace unrelated {
using namespace std;
%template(vin) vector<int>;
template class vector<int>;
}
// ill-formed
namespace unrelated {
namespace std {
%template(vin) vector<int>;
template class vector<int>;
}
}
// ill-formed
namespace unrelated {
%template(vin) std::vector<int>;
template class std::vector<int>;
}
When the scope is incorrect, an error now occurs such as:
cpp_template_scope.i:34: Error: 'vector' resolves to 'std::vector' and
was incorrectly instantiated in scope 'unrelated' instead of within scope 'std'.
Previously SWIG accepted the ill-formed examples above but this led to
numerous subtle template scope problems especially in the presence of
using declarations and using directives as well as with %feature and %typemap.
Actually, a valid instantiation is one which conforms to the C++03
standard as C++11 made a change to disallow using declarations and
using directives to find a template.
// valid C++03, ill-formed C++11
using std::vector;
template class vector<int>;
Similar fixes for defining classes using forward class references have
also been put in place. For example:
namespace Space1 {
struct A;
}
namespace Space2 {
struct Space1::A {
void x();
}
}
will now error out with:
cpp_class_definition.i:5: Error: 'Space1::A' resolves to 'Space1::A' and
was incorrectly instantiated in scope 'Space2' instead of within scope 'Space1'.
Previously some symbols would have been instantiated in the wrong scope and led
to lots of scope problems involving SWIG typemaps, features, renames etc.
You will need to correct the scope used in other SWIG directives which do not
support 'using declarations' and 'using directives'. For example, if you previously had:
%rename(Zap) vector<int>::clear;
using namespace std;
%template(VectorInt) vector<int>;
Prior versions of SWIG incorrectly instantiated vector<int> in the global namespace
and so the %rename matched. Now the template is instantiated in the correct namespace,
so is fully qualified as std::vector<int>. The other SWIG directives need correcting as
they do not follow 'using declarations' and 'using directives'. Change it to:
%rename(Zap) std::vector<int>::clear;
using namespace std;
%template(vin) vector<int>;
*** POTENTIAL INCOMPATIBILITY ***
2017-08-16: wsfulton
Fix scope lookup for template parameters containing unary scope operators.
Fixes cases like:
namespace Alloc {
template<typename T> struct Rebind {
typedef int Integer;
};
}
%template(RebindBucket) Alloc::Rebind< Bucket >;
OR
%template(RebindBucket) Alloc::Rebind< ::Bucket >;
Alloc::Rebind< Bucket >::Integer Bucket1();
Alloc::Rebind< ::Bucket >::Integer Bucket2();
Alloc::Rebind<::template TemplateBucket<double>>::Integer Bucket3();
2017-08-16: wsfulton
For templates only, the template parameters are fully resolved when
handling typemaps. Without this, it is too hard to have decent rules
to apply typemaps when parameter types are typedef'd and template
parameters have default values.
Fixes %clear for typedefs in templates, eg:
%typemap("in") XXX<int>::Long "..."
template typename<T> struct XXX {
typedef long Long;
};
%clear XXX<int>::Long;
as the typemap was previously incorrectly stored as a typemap for long
instead of XXX<int>::Long.
2017-08-05: olly
[C++11] Allow static_assert at the top level (and disallow it right
after template<T>). Fixes issue 1031 reported by Artem V L.
2017-08-02: wsfulton
Fix incorrectly shown warning when an empty template instantiation was used on a
class used as a base class and that base class was explicitly ignored with %ignore.
Example of the warning which will no longer appear:
Warning 401: Base class 'Functor< int,int >' has no name as it is an empty
template instantiated with '%template()'. Ignored.
2017-07-17: fflexo
[Java] #674 Add std_list.i to add support for std::list containers. The Java proxy
extends java.util.AbstractSequentialList and makes the C++ std::list container look
and feel much like a java.util.LinkedList from Java.
2017-07-07: wsfulton
[Python] Fix display of documented template types when using the autodoc
feature. For example when wrapping:
%feature("autodoc");
template<typename X> struct T {};
%template(TInteger) T<int>;
the generated documentation contains:
"""Proxy of C++ T< int > class."""
instead of:
"""Proxy of C++ T<(int)> class."""
and
"""__init__(TInteger self) -> TInteger"""
instead of
"""__init__(T<(int)> self) -> TInteger"""
2017-06-27: nihaln
[PHP] Update the OUTPUT Typemap to add return statement to the
PHP Wrapper.
2017-06-27: nihaln
[PHP] Update the enum and value examples to use the OO wrappers
rather than the flat functions produced with -noproxy. There's
not been a good reason to use -noproxy for since PHP5 OO wrapping
was fixed back in 2005.
2017-06-23: m7thon
[Python] fix and improve default argument handling:
1. Fix negative octals. Currently not handled correctly by `-py3`
(unusual case, but incorrect).
2. Fix arguments of type "octal + something" (e.g. `0640 | 04`).
Currently drops everything after the first octal. Nasty!
3. Fix bool arguments "0 + something" (e.g. `0 | 1`) are always
"False" (unusual case, but incorrect).
4. Remove special handling of "TRUE" and "FALSE" from
`convertValue` since there's no reason these have to match
"true" and "false".
5. Remove the Python 2 vs. Python 3 distinction based on the
`-py3` flag. Now the same python code is produced for default
arguments for Python 2 and Python 3. For this, octal default
arguments, e.g. 0644, are now wrapped as `int('644', 8)`. This
is required, as Python 2 and Python 3 have incompatible syntax
for octal literals.
Fixes #707
2017-06-21: futatuki
#1004 - Fix ccache-swig executable name to respect configure's --program-prefix and
--program-suffix values if used.
2017-06-21: tamuratak
[Ruby] #911 - Add std::wstring support.
2017-06-19: wsfulton
[Python] Fix handling of rich comparisons when wrapping overloaded operators:
operator< operator<= operator> operator>= operator== operator!=
Previously a TypeError was always thrown if the type was not correct. NotImplemented
is now returned from these wrapped functions if the type being compared with is
not correct. The subsequent behaviour varies between different versions of Python
and the comparison function being used, but is now consistent with normal Python
behaviour. For example, for the first 4 operator overloads above, a TypeError
'unorderable types' is thrown in Python 3, but Python 2 will return True or False.
NotImplemented should be returned when the comparison cannot be done, see PEP 207 and
https://docs.python.org/3/library/constants.html#NotImplemented
Note that the bug was only present when overloaded operators did not also have a
function overload.
Fixes SF bug #1208 (3441262) and SF patch #303.
*** POTENTIAL INCOMPATIBILITY ***
2017-06-17: fabrice102
[Go] Fix Go callback example. Fixes github #600, #955, #1000.
2017-06-16: wsfulton
Make sure warning and error messages are not split up by other processes writing to
stdout at the same time.
2017-06-16: wsfulton
[R] Fix wrapping function pointers containing rvalue and lvalue reference parameters.
2017-06-13: olly
[Perl] Fix testsuite to work without . in @INC - it was removed in
Perl 5.26 for security reasons, and has also been removed from
older versions in some distros. Fixes #997 reported by lfam.
2017-06-03: wsfulton
Fix %import on a file containing a file scope %fragment forced inclusion to not
generate the fragment contents as %import should not result in code being generated.
The behaviour is now the same as importing code insertion blocks.
Wrapping FileC.i in the following example will result in no generated code, whereas
previously "#include <limits.h>" was generated:
// FileA.i
%fragment("<limits.h>", "header") %{
#include <limits.h>
%}
%{
#include <stdio.h>
%}
%fragment("<limits.h>");
// FileC.i
%import "FileA.i"
*** POTENTIAL INCOMPATIBILITY ***
2017-05-26: Volker Diels-Grabsch, vadz
[Java] #842 Extend from java.util.AbstractList<> and implement java.util.RandomAccess for
std::vector wrappers. This notably allows to iterate over wrapped vectors in a natural way.
Note that boxed types are now used in the Java layer when wrapping vector of C primitive
types, for example. This may introduce some subtle incompatibilities due to some
differences in how Java converts boxed types and unboxed types. For example,
int i=0;
double d1 = i; // ok
Double d2 = i; // error: incompatible types: int cannot be converted to Double
This can be a problem when calling the add and set functions. A suggested backwards
compatible workaround is to use something like (shown for std::vector<double>:
#if defined(SWIGJAVA)
// Add in old api that uses non-boxed types
%extend std::vector<double> {
%proxycode %{
public void add(double x) {
add(Double.valueOf(x));
}
public void set(int i, double val) {
set(i, Double.valueOf(val));
}
%}
}
#endif
%include "std_vector.i"
%template(VectorDouble) std::vector<double>;
*** POTENTIAL INCOMPATIBILITY ***
2017-05-30: davidcl
[Scilab] #994 Undefined symbol error when loading in Scilab 6
2017-05-25: asibross
[Java] #370 #417 Missing smart pointer handling in Java director extra methods
swigReleaseOwnership() and swigTakeOwnership().
2017-05-23: wsfulton
[Java] #230 #759 Fix Java shared_ptr and directors for derived classes java compilation
error.
For shared_ptr proxy proxy classes, add a protected method swigSetCMemOwn for modifying
the swigCMemOwn and swigCMemOwnDerived member variables which are used by various other
methods for controlling memory ownership.
2017-05-21: Sghirate
[Java, C#, D] #449 Remove unnecessary use of dynamic_cast in directors to enable
non-RTTI compilation.
2017-05-21: wsfulton
[Python] #993 Fix handling of default -ve unsigned values, such as:
void f(unsigned = -1U);
2017-05-20: jschueller
[Python] #991 Fix E731 PEP8 warning: do not assign a lambda expression
2017-05-16: nihal95
[PHP] Add %pragma version directive to allow the version of the
extension to be set. Patch #970, fixes #360.
2017-05-13: yag00
Patch #975 - Add support for noexcept on director methods.
2017-04-27: redbrain
Issue #974, Patch #976 - Fix preprocessor handling of macros with commas in a comment.
2017-04-25: jleveque
[Lua] #959 - Fix Visual Studio C4244 conversion warnings in Lua wrappers.
2017-04-21: tamuratak
[Ruby] #964 - Add shared_ptr director typemaps.
2017-04-20: wsfulton
[Ruby] #586, #935 Add assert for invalid NULL type parameter when calling SWIG_Ruby_NewPointerObj.
2017-04-20: tamuratak
[Ruby] #930, #937 - Fix containers of std::shared_ptr.
Upcasting, const types (eg vector<shared_ptr<const T>>) and NULL/nullptr support added.
2017-04-12: smarchetto
[Scilab] New parameter targetversion to specify the Scilab target version (5, 6, ..) for code generation
With Scilab 6 target specified, identifier names truncation is disabled (no longer necessary)
2017-03-24: tamuratak
[Ruby] Fix #939 - Wrapping std::vector<bool> fix due to incorrect null checks
on VALUE obj.
2017-03-17: vadz
[C#] #947 Add support for std::complex<T>
2017-03-17: wsfulton
[Go] Fix handling of typedef'd function pointers and typedef'd member function pointers
such as:
typedef int (*FnPtr_td)(int, int);
int do_op(int x, int y, FnPtr_td op);
2017-03-16: wsfulton
Add support for member const function pointers such as:
int fn(short (Funcs::* parm)(bool)) const;
Also fix parsing of references/pointers and qualifiers to member
pointers such as:
int fn(short (Funcs::* const parm)(bool));
int fn(short (Funcs::* & parm)(bool));
2017-03-10: wsfulton
Extend C++11 alternate function syntax parsing to support const and noexcept, such as:
auto sum1(int x, int y) const -> int { return x + y; }
auto sum2(int x, int y) noexcept -> int { return x + y; }
2017-02-29: tamuratak
[Ruby] #917 - Add Enumerable module to all container class wrappers. It was missing
for std::list, std::multiset, std::unordered_multiset and std::unordered_map.
2017-02-27: assambar
[C++11] Extend parser to support throw specifier in combination
with override and/or final.
2017-02-10: tamuratak
[Ruby] #883 - Add support for C++11 hash tables:
std::unordered_map
std::unordered_set
std::unordered_multimap
std::unordered_multiset
2017-02-08: jcsharp
[C#] #887 Improve std::vector<T> wrapper constructors -
Replace constructor taking ICollection with IEnumerable and also add IEnumerable<T>
constructor to avoid the boxing and unboxing overhead of the original constructor,
when the type parameter is a value type.
Version 3.0.12 (27 Jan 2017)
============================
2017-01-27: wsfulton
[C#] #882 Fix missing filename in error messages when there is a problem
writing out C# files.
2017-01-27: briancaine
[Guile] #744 Fix compilation errors in Guile wrappers - regression
introduced in swig-3.0.11.
2017-01-24: andrey-starodubtsev
[Java] Apply #704 - director typemap improvements.
Memory leak fixes, add support for "directorargout" typemap and
add director support to typemaps.i.
2017-01-24: wsfulton
Enhance %extend to extend a class with template constructors, eg:
struct Foo {
%extend {
template<typename T>
Foo(int a, T b) {
...
}
}
};
%template(Foo) Foo::Foo<double>;
2017-01-22: wsfulton
Issue #876 Enhance %extend to extend a class with template methods, eg:
struct Foo {
%extend {
template<typename T>
void do_stuff(int a, T b) {
...
}
}
};
%template(do_stuff_inst) Foo::do_stuff<double>;
Similarly for static template methods.
2017-01-22: kwwette
[Octave] add support for version 4.2
- The Octave API now uses some C++11 features. It is recommended to use
the mkoctfile program supplied by Octave to compile the SWIG-generated
wrapper code, as mkoctfile will ensure the correct C++ compiler/options
are used. Otherwise, the value of `mkoctfile -p CXX` should be parsed
for any -std=* flags which might be present.
- Octave has dropped support for << and >> operators, so SWIG now
ignores them.
- The Octave error() function now raises C++ exceptions to propagate
Octave errors, so %exception directives may need to be modified.
For convenience the SWIG_RETHROW_OCTAVE_EXCEPTIONS macro can be used
to rethrow any Octave exceptions for Octave itself to handle, e.g.:
try {
$action // may call error()
}
SWIG_RETHROW_OCTAVE_EXCEPTIONS // error() exceptions are rethrown
catch(...) {
... // all other exceptions
}
*** POTENTIAL INCOMPATIBILITY ***
2017-01-16: wkalinin
[C#] Fix #733 regression introduced in swig-3.0.9.
Missing virtual function override in C# layer when using %import.
2017-01-16: fschlimb
Fix #813 template symbol name lookup bug when typedef names are the same but in different
namespaces.
2017-01-15: wsfulton
[C# D Java]
The SWIG library no longer uses the javatype, dtype or cstype typemaps, thereby
completely freeing them up for users to use without having to replicate the library
code that they previously added. The code previously generated by these typemaps
has been replaced by the new %proxycode directive. Their use in the library code
was fairly minimal:
C# cstype: std_array.i std_map.i std_vector.i
D dtype: std_vector.i
Java javatype: arrays_java.i
2017-01-14: wsfulton
The %extend directive can now optionally support one of the 'class', 'struct' or 'union'
keywords before the identifier name, for example:
struct X { ... };
%extend struct X { ... }
Previously this had to specified as:
struct X { ... };
%extend X { ... }
2017-01-13: wsfulton
[C# D Java] Add new %proxycode directive which is a macro for %insert("proxycode").
This is a way of adding pure C#/D/Java code into the appropriate proxy class, eg:
%extend Proxy2 {
%proxycode %{
public int proxycode2(int i) {
return i+2;
}
%}
}
%inline %{
struct Proxy2 {};
%}
There will then be a pure Java/C#/D method called proxycode2 in the Proxy2 class.
2016-12-31: ajrheading1
Issue #860 - Remove use of std::unary_function and std::binary_function
which is deprecated in C++11.
2016-12-30: olly
[PHP7] Register internal 'swig_runtime_data_type_pointer' constant
as "CONST_PERSISTENT" to avoid segmentation fault on module unload.
Fixes #859 reported by Timotheus Pokorra. Thanks also to Javier Torres
for a minimal reproducer.
Version 3.0.11 (29 Dec 2016)
============================
2016-12-24: wsfulton
[C#] Add %feature("csdirectordelegatemodifiers") to enable customization
of the delegate access modifiers generated in director classes.
Fixes issue #748.
2016-12-23: wsfulton
[Python] Fix builtin "python:slot" feature failing for tp_hash when using
hashfunc closure with a "Wrong type for hash function" for Python 2.
Issue #843.
2016-12-21: joequamt
Changed generation of functions so that only functions
that end in _set generate accessor functions rather than
looking for "set".
Change generation of operators to not have underscores
to start in R. Users need to provide custom names for these operator overloads.
2016-12-21: olly
Fix isfinite() checks to work with all C++11 compilers.
Fixes issues #615, #788 and #849.
2016-12-20: wsfulton
%namewarn unnecessarily caused keyword warnings for non-instantiated template classes
and duplicate warnings for instantiated template classes when keywords were used.
Issue #845.
2016-12-18: ezralanglois
[Python, Ruby, Octave] Memory leak fix on error in std::pair wrappers.
Issue #851.
2016-12-18: wsfulton
Zero initialize arrays when using %array_class and %array_functions.
2016-12-18: t-ikegami
[Python] Fix #446
Python %array_class of carrays.i failed with -builtin option.
2016-12-16: briancaine
[Guile] Patch #744 Added support for Guile's native pointer functionality
2016-12-01: wsfulton
[Python] Issue #769.
Add optional moduleimport attribute to %module so that the
default module import code can be overridden. See the "Searching for the wrapper module"
documentation in Python.html. Example:
%module(moduleimport="import _foo") foo
$module also expands to the low-level C/C++ module name, so the following is the
same as above
%module(moduleimport="import $module") foo
2016-11-30: olly
[PHP] Add support for PHP7. PHP5's C extension API has changed
substantially so you need to use -php7 to specify you want PHP7
compatible wrappers. The default extension for generated wrappers
is now .cxx (to match SWIG's default for every other language - to
generate foo_wrap.cpp you can run SWIG with -cppext cpp). Fixes
issue #571.
As part of this change, the language subdirectory for PHP5 has
changed from "php" to "php5" - if you are making use of the search
path feature where the language subdirectory of each directory
is also searched, you'll need to update your bindings. A simple
fix which works for older and newer SWIG is to add a symlink:
ln -s php php5
*** POTENTIAL INCOMPATIBILITY ***
2016-11-30: olly
[PHP] Only emit one copy of each distinct arginfo. Previously we
emitted a separate one for every wrapped function, but typically
many functions have the same number of parameters and combinations
of parameters passed by reference or not.
This change significantly reduces both the size of the generated
wrapper, and of the compiled PHP extension module (e.g. by ~6% for
the stripped extension module for Xapian's PHP7 bindings).
2016-11-28: wsfulton
Fix %rename override of wildcard %rename for templates. For example:
%rename(GlobalIntOperator) *::operator bool; // wildcard %rename
%rename(XIntOperator) X::operator bool; // fix now overrides first %rename above
OR
%rename(XIntOperator) X<int>::operator bool; // fix now overrides first %rename above
template<typename T> struct X {
operator bool();
...
};
%template(Xint) X<int>;
This also fixes %rename override of global %rename for templates. For example:
// Global rename to make all functions start with a lower case letter
%rename("%(firstlowercase)s", %$isfunction ) "";
%rename(woohoo) W::Woo; // fix now overrides above %rename
template<typename T> struct W {
W Woo();
...
};
%template(Wint) W<int>;
The above also introduces a possibly unexpected change. Many of the STL containers
provided by SWIG use %rename to rename some methods, eg in std::vector, push_back
is renamed to add in Java. Previously this intended rename did not happen when using
using global %rename rules and the method would remain as push_back, but is now
renamed to add. Some more info in issue #856.
*** POTENTIAL INCOMPATIBILITY ***
2016-11-26: m7thon
[Python] Issue #709 - improved wrapping of division operators
'from __future__ import division' now works in Python 2 whether or not the
-py3 flag is used.
2016-11-12: joequant
[R] Issue #697 - fix comma issue with overload methods
2016-11-12: joequant
[R] Issue #555 - R runtime needs stdio.h
2016-11-02: wsfulton
[Python] Issue #816 - fix compilation error when using -extranative and -builtin.
2016-11-02: liorgold
Patch #741 - Add support for C++11 alias templates, see updated CPlusPlus11.html
documentation.
2016-10-30: myd7349
[C#] Patch #740 Add std_array.i for C# for wrapping std::array.
Patch also enhances std::vector<std::wstring> C# wrappers with additional functions
(Contains, IndexOf, LastIndexOf and Remove).
2016-10-30: tobilau
[Java] Fix wrappers for wstring parameters in director methods to cleanup local
ref after director callback has finished.
2016-10-23: wsfulton
[C#] Add missing csdirectorin VOID_INT_PTR and csdirectorout VOID_INT_PTR typemaps.
2016-10-23: jiulongw
Patch #781 - Fix wrapping of C compound expressions containing char constants
in quotes such as:
#define H_SUPPRESS_SCALING_MAGIC (('s'<<24) | ('u'<<16) | ('p'<<8) | 'p')
enum DifferentTypes {
typecharcompound='A'+1,
typecharcompound2='B' << 2
};
2016-10-13: wsfulton
[Python] Issue #808 - fix Python pickling and metaclass for builtin wrappers.
The metaclass (SwigPyObjectType) for SWIG objects was not defined in
a way that let importlib successfully import the Python wrappers.
The pickle module previously failed to pickle objects because it couldn't
determine what module the SWIG wrapped objects were in.
2016-09-29: wsfulton
[Allegrocl, CFFI, GO, Javascript, Ocaml, R, Scilab]
Add missing support for the "ret" typemap in a few target languages.
The documentation also now has info on the "ret" typemap.
2016-09-27: ahmed-usman
[xml] Handle template parameters correctly.
2016-09-27: dontpanic92
[Go] Fix argument names in inherited functions taking more than 8
parameters. Fixes #795.
2016-09-26: smarchetto
[Scilab] mlists that map pointers can be given a custom type name.
2016-09-25: wsfulton
Patch #793 from q-p to expand exception handling to include std::bad_cast
in std_except.i.
2016-09-24: olly
[PHP] Fix code generated for feature("director:except") -
previously the return value of call_user_function() was ignored and
we checked an uninitialised value instead. Fixes #627. Based on
patch from Sergey Seroshtan.
2016-09-22: wsfulton
[Python] More flexible python builtin slots for overloaded C++ function.
The closure names used for builtin slots are mangled with their functype so
that overloaded C++ method names can be used for multiple slots.
For example:
%feature("python:slot", "mp_subscript", functype="binaryfunc") SimpleArray::__getitem__;
%feature("python:slot", "sq_item", functype="ssizeargfunc") SimpleArray::__getitem__(Py_ssize_t n);
will generate closures:
SWIGPY_SSIZEARGFUNC_CLOSURE(_wrap_SimpleArray___getitem__) /* defines _wrap_SimpleArray___getitem___ssizeargfunc_closure */
SWIGPY_BINARYFUNC_CLOSURE(_wrap_SimpleArray___getitem__) /* defines _wrap_SimpleArray___getitem___binaryfunc_closure */
Previously only one name was defined: _wrap_SimpleArray___getitem___closure.
Hence the overloaded __getitem__ method can be used to support both mp_subscript and sq_item slots.
2016-09-17: wsfulton
[Python] Fix iterators for containers of NULL pointers (or Python None) when using
-builtin. Previously iteration would stop at the first element that was NULL.
2016-09-16: olly
[Javascript] Fix SWIG_exception() macro to return from the current
function. Fixes #789, reported by Julien Dutriaux.
2016-09-16: olly
[PHP] Fix SWIG_exception() macro to return from the current function.
Fixes #240, reported by Sergey Seroshtan.
2016-09-12: xypron
[C#] Patch #786 Keyword rename to be CLS compliant by adding an underscore
suffix instead of an underscore prefix to the C symbol name. Please use an explicit
%rename to rename the symbol with a _ prefix if you want the old symbol name.
*** POTENTIAL INCOMPATIBILITY ***
2016-09-09: olly
[Python] Fix import handling for Python 2.6 to work in a frozen
application. Fixes #145, reported by Thomas Kluyver.
2016-09-02: smarchetto
[Scilab] Pointers are mapped to mlist instead of tlist
(mlist better for scilab overloading)
2016-09-02: olly
[PHP] Fix "out" typemap for member function pointers and "in"
typemap for char INPUT[ANY].
2016-09-01: wsfulton
[Python] More efficient Python slicing.
Call reserve for container types that support it to avoid repeated
memory reallocations for new slices or slices that grow in size.
2016-09-01: wsfulton
[Python] #771 - Make builtin types hashable by default.
Default hash is the underlying C/C++ pointer. This matches up with testing for
equivalence (Py_EQ in SwigPyObject_richcompare) which compares the pointers.
2016-08-22: wsfulton
[Python] The following builtin slots can be customized like other slots via the
"python:<x>" and "python:slot" features where <x> is the appropriate slot name:
tp_allocs
tp_bases
tp_basicsize
tp_cache
tp_del
tp_dealloc
tp_flags
tp_frees
tp_getset
tp_is_gc
tp_maxalloc
tp_methods
tp_mro
tp_new
tp_next
tp_prev
tp_richcompare
tp_subclasses
tp_weaklist
was_sq_ass_slice
was_sq_slice
A few documentation improvements for slot customization.
2016-08-09: joequant
[R] Patch #765 Fix extern "C" header includes for C++ code.
2016-08-05: olly
[xml] Fix how the output filename is built to avoid problems when
it contains the embedded strings ".c", ".cpp" or ".cxx".
Fixes #540 reported by djack42.
2016-07-01: wsfulton
Fix corner case of wrapping std::vector of T pointers where a pointer to a pointer of T
also exists in the wrapped code. SF Bug 2359417 (967).
2016-06-26: wkalinin
[Java, C#] Patch #681 Fix seg fault when ignoring nested classes.
2016-06-25: mromberg
[Python] #711 Fix -castmode and conversion of signed and unsigned integer types.
See 2015-12-23 CHANGES entry for details of these improvements when they were
implemented for the default options (ie not using -castmode).
2016-06-25: ahnolds
Patch #730 - Fix %implicitconv for overloaded functions when using
-castmode or -fastdispatch options.
The result is that in all overload cases where there are multiple possibilities
with the same number of arguments, the dispatch function will first check for
exact (aka non implicit) matches, and then subsequently check for implicit
casting matches. This was already happening in the normal dispatch situation,
and in the -fastdispatch case two passes through the candidates were happening,
just with SWIG_POINTER_IMPLICIT_CONV always set. After this patch, it is not set
on the first pass, and then set on the second pass.
2016-06-25: liorgold
Patch #727 - Add support for C++11 type aliasing.
Version 3.0.10 (12 Jun 2016)
============================
2016-06-06: mromberg
[Python] Patch #698. Add support for -relativeimport for python 2.7, so -py3 is no
longer also required for relative import support.
2016-06-05: mromberg
[Python] Patch #694 - Fix package import regressions introduced in swig-3.0.9.
1) The code in 3.0.9 did not fall back to 'import _foo' if 'import bar._foo' failed
(assuming bar.foo was the main module). Every place _foo is imported now first tries
it from the package where foo was found and if that fails tries _foo as a global module.
2) The separate block of Python code that injected code to pull in the attributes
from _foo when -builtin is used made use of the -py3 switch to either do
'from ._foo import *' or "from _foo import *". This block of code no longer does this
and instead checks the Python version at runtime to switch between the two syntaxes.
In summary, swig-3.0.10 has been modified to ease the creation of wrapper modules
that can be fully made part of a Python package. SWIG no longer
assumes the dynamically linked C module is a global module.
The dynamic module can now be placed into either the same package as the pure Python
module or as a global module. Both locations are used by the Python wrapper to
locate the C module.
However, this could cause a backwards incompatibility with some code
that was relying on the ability of "from package import _module" to
pull attributes out of the package directly. If your code populates a
module (which is also a package) with attributes that are SWIG
generated modules which were not loaded in a conventional way,
swig-3.0.8 and earlier may have worked due to 'from package import
_module' bypassing a real import and pulling your module in as an
attribute. This will no longer work. Since this is not a common (or
even recommended) practice, most folk should not be affected.
*** POTENTIAL INCOMPATIBILITY ***
2016-05-31: wsfulton
Fix #690 - Smart pointer to %ignored class doesn't expose inherited methods.
Regression introduced in swig-3.0.9.
Version 3.0.9 (29 May 2016)
===========================
2016-05-24: mromberg
[Python] Patch #612 - Add support for Python's implicit namespace packages.
2016-05-23: wsfulton
[Ruby] Fix #602 - Error handling regression of opaque pointers introduced
in swig-3.0.8 when C functions explicitly reset a pointer using 'DATA_PTR(self) = 0'.
An ObjectPreviouslyDeleted error was incorrectly thrown when the pointer was used
as a parameter.
2016-05-17: tamuratak
[Ruby] Patch #651 - Correct overloaded function error message when function is
using %newobject.
2016-05-17: aurelj
[Ruby] Patch #582 - add support for docstring option in %module()
2016-05-14: wsfulton
Fix #434 - Passing classes by value as parameters in director methods did not create
a copy of the argument leading to invalid memory accesses if the object was used
after the upcall into the target language. Passing arguments by value shouldn't give
rise to these sorts of memory problems and so the objects are now copied and ownership
of their lifetime is controlled by the target language.
2016-05-07: wsfulton
Fix #611. Fix assertion handling defaultargs when using %extend for a template
class and the extended methods contain default arguments.
2016-05-05: ejulian
[Python] Patch #617. Fix operator/ wrappers.
2016-05-02: wsfulton
Fix #669. Don't issue warning about ignoring base classes when the derived class is
itself ignored.
2016-04-18: ianlancetaylor
[Go] Fix use of goout typemap when calling base method by
forcing the "type" attribute to the value we need.
2016-04-17: ianlancetaylor
[Go] Fixes for Go 1.6: avoid returning Go pointers from
directors that return string values; add a trailing 0 byte
when treating Go string as C char*.
2016-04-06: smarchetto
[Scilab] #552 Make Scilab runtime keep track of pointer types
Instead of a Scilab pointer which has no type, SWIG Scilab maps a
pointer to a structure tlist containing the pointer adress and its type.
2016-04-02: ahnolds
[Python] Apply #598. Fix misleading error message when attempting to read a non-existent
attribute. The previous cryptic error message:
AttributeError: type object 'object' has no attribute '__getattr__'
is now replaced with one mentioning the attribute name, eg:
AttributeError: 'Foo' object has no attribute 'bar'
2016-04-02: derkuci
[Python] Patch #610 to fix #607.
Fix single arguments when using python -builtin -O with %feature("compactdefaultargs")
2016-03-31: wsfulton
Fixes #594. Fix assertion for some languages when wrapping a C++11 enum class that
is private in a class.
Also don't wrap private enums for a few languages that attempted to do so.
2016-03-31: wsfulton
[Java] unsigned long long marshalling improvements when a negative number
is passed from Java to C. A cast to signed long long in the C layer will now
result in the expected value. No change for positive numbers passed to C.
Fixes #623.
2016-03-22: alexwarg
[Lua] #398 Fix lua __getitem + inheritance
The new handling of classes in Lua (not merging methods into the derived classes)
breaks for classes that provide a __getitem function. The __getitem function
prevents method calls to any method defined in a base class. This fix calls
__getitem only if the member is not found using recursive lookup.
2016-03-18: ptomulik
[Python] #563 Stop generating unnecessary _swigconstant helpers.
2016-03-16: richardbeare
[R] #636 Add extra std::vector numeric types
2016-03-14: wsfulton
[Java] Add std_array.i for C++11 std::array support.
2016-03-12: wsfulton
[Java, C#, D] Fix static const char member variables wrappers with %javaconst(1)
%csconst(1) or %dmanifestconst.
This fixes the case when an integer is used as the initializer, such as:
struct W { static const char w = 100; };
Fix generated code parsing enum values using char escape sequences
when these values appear in the Java code (usually when using %javaconst(1))
such as:
enum X { x1 = '\n', x2 = '\1' };
Similarly for static const member char variables such as:
struct Y { static const char y = '\n'; }
Likewise for D and %dmanifestconstant. For C# and %csconst(1), char
values in C# are now hex escaped as C# doesn't support C octal escaping.
2016-03-11: wsfulton
[Java C#] Add support for treating C++ base classes as Java interfaces
instead of Java proxy classes. This enable some sort of support for
multiple inheritance. The implementation is in swiginterface.i and
provides additional macros (see Java.html for full documentation):
%interface(CTYPE)
%interface_impl(CTYPE)
%interface_custom("PROXY", "INTERFACE", CTYPE)
2016-03-01: wsfulton
Add rstrip encoder for use in %rename. This is like the strip encoder but
strips the symbol's suffix instead of the prefix. The example below
will rename SomeThingCls to SomeThing and AnotherThingCls to AnotherThing:
%rename("%(rstrip:[Cls])s") "";
class SomeThingCls {};
struct AnotherThingCls {};
2016-03-01: olly
Fix isfinite() check to work with GCC6. Fixes
issue #615 reported by jplesnik.
2016-02-17: olly
[Python] Add missing keywords 'as' and 'with' to pythonkw.swg.
2016-02-07: kwwette
[Octave] recognise various unary functions
* Use __float__() for numeric conversions, e.g. when calling double()
* Map various unary functions, e.g. abs() to __abs__(), see full list
in section 32.3.10 of manual; only available in Octave 3.8.0 or later
2016-02-07: kwwette
[Octave] export function swig_octave_prereq() for testing Octave version
2016-02-06: pjohangustavsson
[C#] Fix duplicate symbol problems when linking the source generated
from multiple SWIG modules into one shared library for the -namespace
option. The namespace is now mangled into the global PInvoke function
names.
*** POTENTIAL INCOMPATIBILITY ***
2016-01-27: ahnolds
[Python] Added support for differentiating between Python Bytes
and Unicode objects using by defining SWIG_PYTHON_STRICT_BYTE_CHAR
and SWIG_PYTHON_STRICT_UNICODE_WCHAR.
2016-01-27: steeve
[Go] Ensure structs are properly packed between gc and GCC/clang.
2016-01-25: ahnolds
[Python] Support the full Python test suite in -classic mode
* Convert long/unsigned long/long long/unsigned long long to PyInt
rather than PyLong when possible. Certain python functions like
len() require a PyInt when operating on old-style classes.
* Add support for static methods in classic mode, including support
for pythonappend, pythonprepend, and docstrings.
* Removing the use of __swig_getmethods__ for static member methods
since they will always be found by the standard argument lookup
* Fix a bug where the wrong type of exception was caught when
checking for new-style class support
2016-01-23: ahnolds
[Go] Enable support for the Go test-suite on OSX:
* The linker on OSX requires that all symbols (even weak symbols)
are defined at link time. Because the function _cgo_topofstack is
only defined starting in Go version 1.4, we explicitly mark it as
undefined for older versions of Go on OSX.
* Avoid writing empty swigargs structs, since empty structs are not
allowed in extern "C" blocks.
2016-01-12: olly
[Javascript] Look for "nodejs" as well as "node", as it's packaged
as the former on Debian.
2016-01-12: olly
[Javascript] For v8 >= 4.3.0, use V8_MAJOR_VERSION.
Fixes issue 561.
2016-01-10: ahnolds
Improved size_t and ptrdiff_t typemaps to support large values
on platforms where sizeof(size_t) > sizeof(unsigned long) and
sizeof(ptrdiff_t) > sizeof(long).
Version 3.0.8 (31 Dec 2015)
===========================
2015-12-30: wsfulton
The pdf documentation is now generated by wkhtmltopdf and has colour
for the code snippets just like the html documentation!
2015-12-23: ahnolds
[Python] Fixes for conversion of signed and unsigned integer types:
No longer check for PyInt objects in Python3. Because PyInt_Check
and friends are #defined to the corresponding PyLong methods, this
had caused errors in Python3 where values greater than what could be
stored in a long were incorrectly interpreted as the value -1 with
the Python error indicator set to OverflowError. This applies to
both the conversions PyLong->long and PyLong->double.
Conversion from PyLong to long, unsigned long, long long, and
unsigned long long now raise OverflowError instead of TypeError in
both Python2 and Python3 for PyLong values outside the range
expressible by the corresponding C type. This matches the existing
behavior for other integral types (signed and unsigned ints, shorts,
and chars), as well as the conversion for PyInt to all numeric
types. This also indirectly applies to the size_t and ptrdiff_t
types, which depend on the conversions for unsigned long and long.
2015-12-19: wsfulton
[Python] Python 2 Unicode UTF-8 strings can be used as inputs to char * or
std::string types if the generated C/C++ code has SWIG_PYTHON_2_UNICODE defined.
2015-12-17: wsfulton
Issues #286, #128
Remove ccache-swig.1 man page - please use the CCache.html docs instead.
The yodl2man and yodl2html tools are no longer used and so SWIG no
longer has a dependency on these packages which were required when
building from git.
2015-12-16: zturner/coleb
[Python] Fix Python3.5 interpreter assertions when objects are being
deleted due to an existing exception. Most notably in generators
which terminate using a StopIteration exception. Fixes #559 #560 #573.
If a further exception is raised during an object destruction,
PyErr_WriteUnraisable is used on this second exception and the
original exception bubbles through.
2015-12-14: ahnolds/wsfulton
[Python] Add in missing initializers for tp_finalize,
nb_matrix_multiply, nb_inplace_matrix_multiply, ht_qualname
ht_cached_keys and tp_prev.
2015-12-12: wsfulton
Fix STL wrappers to not generate <: digraphs.
For example std::vector<::X::Y> was sometimes generated, now
corrected to std::vector< ::X::Y >.
2015-11-25: wsfulton
[Ruby] STL ranges and slices fixes.
Ruby STL container setting slices fixes:
Setting an STL container wrapper slice better matches the way Ruby
arrays work. The behaviour is now the same as Ruby arrays. The only
exception is the default value used when expanding a container
cannot be nil as this is not a valid type/value for C++ container
elements.
Obtaining a Ruby STL container ranges and slices fixes:
Access via ranges and slices now behave identically to Ruby arrays.
The fixes are mostly for out of range indices and lengths.
- Zero length slice requests return an empty container instead of nil.
- Slices which request a length greater than the size of the container
no longer chop off the last element.
- Ranges which used to return nil now return an empty array when the
the start element is a valid index.
Ruby STL container negative indexing support improved.
Using negative indexes to set values works the same as Ruby arrays, eg
%template(IntVector) std::vector<int>;
iv = IntVector.new([1,2,3,4])
iv[-4] = 9 # => [1,2,3,9]
iv[-5] = 9 # => IndexError
2015-11-21: wsfulton
[Ruby, Python] Add std::array container wrappers.
These work much like any of the other STL containers except Python/Ruby slicing
is somewhat limited because the array is a fixed size. Only slices of
the full size are supported.
2015-10-10: wsfulton
[Python] #539 - Support Python 3.5 and -builtin. PyAsyncMethods is a new
member in PyHeapTypeObject.
2015-10-06: ianlancetaylor
[Go] Don't emit a constructor function for a director
class with an abstract method, since the function will
always panic.
2015-10-01: wsfulton
Fix %shared_ptr support for private and protected inheritance.
- Remove unnecessary Warning 520: Derived class 'Derived' of 'Base'
is not similarly marked as a smart pointer
- Do not generate code that attempts to cast up the inheritance chain in the
type system runtime in such cases as it doesn't compile and can't be used.
Remove unnecessary warning 520 for %shared_ptr when the base class is ignored.
2015-10-01: vkalinin
Fix #508: Fix segfault parsing anonymous typedef nested classes.
2015-09-26: wsfulton
[Ruby] Add shared_ptr support
2015-09-13: kkaempf
[Ruby] Resolve tracking bug - issue #225.
The bug is that the tracking code uses a ruby hash and thus may
allocate objects (Bignum) while running the GC. This was tolerated in
1.8 but is invalid (raises an exception) in 1.9.
The patch uses a C hash (also used by ruby) instead.
2015-09-09: lyze
[CFFI] Extend the "export" feature in the CFFI module to support
exporting to a specified package.
2015-09-04: olly
[Python] Fix docstrings for %callback functions.
2015-09-03: demi-rluddy
[Go] Removed golang stringing for signed/unsigned char
Changed default handling of signed char* and unsigned char* to be
opaque pointers rather than strings, similarly to how other
languages work.
Any existing code relying on treating signed char* or unsigned
char* as a string can restore the old behavior with typemaps.i by
using %apply to copy the [unchanged] char* behavior.
*** POTENTIAL INCOMPATIBILITY ***
2015-08-07: talby
[Perl] tidy -Wtautological-constant-out-of-range-compare warnings when building generated code under clang
2015-08-07: xantares
[Python] pep257 & numpydoc conforming docstrings:
- Mono-line module docsstring
- Rewrite autodoc parameters section in numpydoc style:
https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt
- One line summary should end with "."
- Adds a blank line after class docstring
2015-08-05: vadz
[Java] Make (char* STRING, size_t LENGTH) typemaps usable for
strings of other types, e.g. "unsigned char*".
Version 3.0.7 (3 Aug 2015)
==========================
2015-08-02: wsfulton
[Java] Fix potential security exploit in generated Java classes.
The swigCPtr and swigCMemOwn member variables in the generated Java
classes are now declared 'transient' by default. Further details of the exploit
in Android is being published in an academic paper as part of USENIX WOOT '15:
https://www.usenix.org/conference/woot15/workshop-program/presentation/peles.
In the unlikely event that you are relying on these members being serializable,
then you will need to override the default javabody and javabody_derived typemaps
to generate the old generated code. The relevant typemaps are in the Lib directory
in the java.swg, boost_shared_ptr.i and boost_intrusive_ptr.i files. Copy the
relevant default typemaps into your interface file and remove the 'transient' keyword.
*** POTENTIAL INCOMPATIBILITY ***
2015-08-01: vadz
Make configure --without-alllang option more useful: it can now be overridden by the following
--with-xxx options, allowing to easily enable just one or two languages.
2015-07-30: wsfulton
Fix #440 - Initialise all newly created arrays when using %array_functions and %array_class
in the carrays.i library - bug is only relevant when using C++.
2015-07-29: wsfulton
[Python] Improve indentation warning and error messages for code in the following directives:
%pythonprepend
%pythonappend
%pythoncode
%pythonbegin
%feature("shadow")
Old error example:
Error: Line indented less than expected (line 3 of pythoncode)
New error example:
Error: Line indented less than expected (line 3 of %pythoncode or %insert("python") block)
as no line should be indented less than the indentation in line 1
Old warning example:
Warning 740: Whitespace prefix doesn't match (line 2 of %pythoncode or %insert("python") block)
New warning example:
Warning 740: Whitespace indentation is inconsistent compared to earlier lines (line 3 of
%pythoncode or %insert("python") block)
2015-07-28: wsfulton
[Python] Fix #475. Improve docstring indentation handling.
SWIG-3.0.5 and earlier sometimes truncated text provided in the docstring feature.
This occurred when the indentation (whitespace) in the docstring was less in the
second or later lines when compared to the first line.
SWIG-3.0.6 gave a 'Line indented less than expected' error instead of truncating
the docstring text.
Now the indentation for the 'docstring' feature is smarter and is appropriately
adjusted so that no truncation occurs.
2015-07-22: wsfulton
Support for special variable expansion in typemap attributes. Example usage expansion
in the 'out' attribute (C# specific):
%typemap(ctype, out="$*1_ltype") unsigned int& "$*1_ltype"
is equivalent to the following as $*1_ltype expands to 'unsigned int':
%typemap(ctype, out="unsigned int") unsigned int& "unsigned int"
Special variables can be used within special variable macros too. Example usage expansion:
%typemap(cstype) unsigned int "uint"
%typemap(cstype, out="$typemap(cstype, $*1_ltype)") unsigned int& "$typemap(cstype, $*1_ltype)"
Special variables are expanded first and hence the above is equivalent to:
%typemap(cstype, out="$typemap(cstype, unsigned int)") unsigned int& "$typemap(cstype, unsigned int)"
which then expands to:
%typemap(cstype, out="uint") unsigned int& "uint"
2015-07-22: lindleyf
Apply patch #439 - support for $typemap() (aka embedded typemaps or special variable
macros) in typemap attributes. A simple example where $typemap() is expanded in the
'out' attribute (C# specific):
%typemap(cstype) unsigned int "uint"
%typemap(cstype, out="$typemap(cstype, unsigned int)") unsigned int& "$typemap(cstype, unsigned int)"
is equivalent to:
%typemap(cstype, out="uint") unsigned int& "uint"
2015-07-18: m7thon
[Python] Docstrings provided via %feature("docstring") are now quoted and added to
the tp_doc slot when using python builtin classes (-builtin). When no docstring is
provided, the tp_doc slot is set to the fully qualified C/C++ class name.
Github issues #445 and #461.
2015-07-17: kwwette
[octave] Support Octave version 4.0.0 (thanks to patches from Orion Poplawski).
2015-07-07: wsfulton
SWIG no longer generates a wrapper for a class' constructor if that class has
any base class with a private destructor. This is because your compiler should
not allow a class to be instantiated if a base has a private destructor. Some
compilers do, so if you need the old behaviour, use the "notabstract" feature, eg:
%feature("notabstract") Derived;
class Base {
~Base() {}
};
struct Derived : Base {};
Version 3.0.6 (5 Jul 2015)
==========================
2015-07-02: wsfulton
Fix syntax error when the template keyword is used in types, eg:
std::template vector<int> v;
2015-07-02: ngladitz
[Lua] Push characters as unformatted 1-character strings to avoid
unprintable characters such as (char)127 being converted to
"<\127>" with Lua 5.3 and later. (github PR #452)
2015-06-29: olly
[Python] Improve handling of whitespace in %pythoncode.
Previously SWIG looked at the indentation of the first line and
removed that many characters from each subsequent line, regardless
of what those characters were. This was made worse because SWIG's
preprocessor removes any whitespace before a '#'. Fixes github
issue #379, reported by Joe Orton.
2015-06-12: wsfulton
[R] Fix #430 - call to SWIG_createNewRef in copyToC was incorrectly named.
2015-06-11: sghirate
[C#] Patch #427 adds in new command line option -outfile to combine all the
generated C# code into a single file.
2015-06-09: wsfulton
Fix seg fault processing C++11 type aliasing. Issue #424.
2015-05-28: wsfulton
[Python] Add new feature "python:cdefaultargs" to control default argument
code generation. By default, SWIG attempts to convert C/C++ default argument values
into Python values and generates code into the Python layer with these values.
Recent versions of SWIG are able to convert more of these values, however, the
new behaviour can be circumvented if desired via this new feature, such that
the default argument values are obtained from the C layer and not the Python layer.
For example:
struct CDA {
int fff(int a = 1, bool b = false);
};
The default code generation in the Python layer is:
class CDA(_object):
...
def fff(self, a=1, b=False):
return _default_args.CDA_fff(self, a, b)
Adding the feature:
%feature("python:cdefaultargs") CDA::fff;
Results in:
class CDA(_object):