blob: 958e7cb0cf7a883ea70befefba63bc8cc37ef3d1 [file] [log] [blame]
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:
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
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
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
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
%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.
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
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 {
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.
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:
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 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.
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_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
2016-01-27: ahnolds
[Python] Added support for differentiating between Python Bytes
and Unicode objects using by defining SWIG_PYTHON_STRICT_BYTE_CHAR
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
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 =[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.
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:
- 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:
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.
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:
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):
def fff(self, *args):
return _default_args.CDA_fff(self, *args)
Some code generation modes, eg -builtin and -fastproxy, are unaffected by this as
the default values are always obtained from the C layer.
2015-05-27: wsfulton
[Python] Deal with an integer as the default value of a typedef to bool
parameter in the C++ prototype. See #327. Regression from 3.0.0 onwards.
2015-05-19: olly
[Python] Fix warning when compiling generated code with MSVC.
(Fixes reported by
Mateusz Szyma┬┐ski).
2015-05-14: wsfulton
Fix seg fault wrapping shared_ptr of classes with private constructors and destructors.
This also fixes the "unref" feature when used on classes with private destructors.
2015-05-10: wsfulton
[Java] Fix multi-argument typemaps (char *STRING, size_t LENGTH)
so that they can be applied to a wider range of types. Fixes #385.
2015-05-07: olly
[Python] Deal with an integer as the default value of a bool
parameter in the C++ prototype. Fixes github #327, reported by
Greg Allen.
2015-05-07: LindleyF
[Java] Allow feature("director") and feature("ref") to be used
together. Github PR#403.
2015-05-05: olly
Suppress warning 325 "Nested class not currently supported (Foo
ignored)" when Foo has already been explicitly ignored with "%ignore".
2015-05-04: wsfulton
Add support for friend templates, including operator overloading - fixes #196. Considering
the example below, previously the operator gave a syntax error and friendfunc incorrectly
warned with:
"Warning 503: Can't wrap 'friendfunc<(Type)>' unless renamed to a valid identifier."
template <class Type> class MyClass {
friend int friendfunc <Type>(double is, MyClass <Type> & x);
friend int operator<< <Type>(double un, const MyClass <Type> &x);
The following also previously incorrectly warned with:
"Warning 302: Identifier 'template_friend' redefined (ignored),"
template<typename T> T template_friend(T);
struct MyTemplate {
template<typename T> friend T template_friend(T);
2015-05-01: wsfulton
Fix handling of conversion operators where the operator is split over multiple
lines or has comments within the operator type. Fixes #401.
Also fix similar problem with normal operators which gave a syntax error if split over
multiple lines or had a comment within the operator declaration.
2015-04-30: olly
Ignore unknown preprocessor directives which are inside an inactive
conditional (github issue #394, reported by Dan Wilcox).
Regression introduced in 3.0.3.
2015-04-27: vadz
[Python] Fix "default" typemap used after an argument with "numinputs=0" (#377).
2015-04-24: wsfulton
[Python] Fix #256. Code generated with '-builtin -modernargs' segfaults for any
method taking zero arguments.
Also fixes: "SystemError: error return without exception set" during error checking
when using just -builtin and the incorrect number of arguments is passed to a class
method expecting zero arguments.
2015-04-23: wsfulton
[Java] Bug #386 - Memory leak fix in (char *STRING, size_t LENGTH) typemaps.
2015-04-23: vadz
[Python] Make "default" typemap work again (#330, #377).
2015-04-23: vadz
[Python] Fix the use of default values for the pointer types (#365, #376).
2015-04-23: wsfulton
Fix 'make check-ccache' which is part of 'make check' when one of the CCACHE_
environment variables, for example CCACHE_DISABLE, is set.
2015-04-14: wsfulton
Clearer warning message for badly constructed typecheck typemaps. For example, was:
example.i:3: Warning 467: Overloaded foo(int) not supported (no type checking
rule for 'int').
example.i:3: Warning 467: Overloaded foo(int) not supported (incomplete type checking
rule - no precedence level in typecheck typemap for 'int').
2015-04-11: wsfulton
[Java] Fix #353 - Linker multiple definition of 'ExceptionMatches' when
using directors and multiple modules.
2015-04-11: wsfulton
Merge #320 - Make __dict__ accessible for Python builtin classes.
2015-04-07: wsfulton
Fix #375 - parsing of extern "C" and typedef for example:
extern "C" typedef void (*Hook2_t)(int, const char *);
extern "C" typedef int Integer;
2015-03-12: olly
-DSWIG_DIRECTOR_STATIC is now supported for all languages with
director support, not only Python and PHP.
2015-03-02: ianlancetaylor
[Go] Add -cgo option, required for Go versions 1.5 and
2015-02-26: olly
Fix segmentation fault when top==NULL, introduced by nested class
handling (reported in issue#346 by Pawe┬┐ Tomulik).
2015-02-09: wsfulton
[Guile] Fix generated code for static const char member variables when
defined and declared inline.
2015-02-09: mishas
[Go] Fix %import of files in sub directories.
2015-02-05: ianlancetaylor
[Go] Ignore Go specific type maps (goin, goout, etc.) if they are empty.
2015-02-05: ianlancetaylor
[Go] Generated Go code no longer calls _swig_goallocate or
_swig_makegostring, as they will no longer work as of Go 1.5.
Version 3.0.5 (31 Jan 2015)
2015-01-30: wsfulton
[Python] Fix Python -classic and property setting. Setting properties on classic classes
was broken in swig-3.0.3 by attempting to use __setattr__. This regression is fixed now
by using __dict__ again when using -classic.
Fixes patch #232.
2015-01-27: smarchetto
[Scilab] Support for the Scilab language has been added
2015-01-23: olly
[PHP] When wrapping a returned resource as an object, check if all
cases wrap it in the same class, and if so eliminate the pointless
switch statement wrapper we previously generated.
2015-01-22: wsfulton
[Octave] Merge patch #297 for SF bug #1277 - Octave shared_ptr support
2015-01-15: wsfulton
[Python] Merge patch #250 - Fixes for using %constant and objects (non-primitive types)
2015-01-15: wsfulton
[C# Go] Merge patch #308 and fix #307 - C++11 strongly typed enum support
in directors
2015-01-15: wsfulton
[Python] Second fix for #294 #296 - Regression introduced in SWIG-3.0.3 when
wrapping functions with default arguments, this time when using kwargs.
Version 3.0.4 (14 Jan 2015)
2015-01-12: olly
[PHP] Fix segfault in director upcall check when using PHP built with
ZTS enabled. Fixes #155, reported by Pierre Labastie.
2015-01-12: vadz
[Python] Fix #294 #296 - Regression introduced in SWIG-3.0.3 when
wrapping functions with default arguments. Invalid or missing default
arguments were sometimes being generated into the python layer.
2015-01-08: olly
Allow C++11 "explicit constexpr". Fixes github issue #284 reported
by Pawel Tomulik. Also handle "constexpr explicit" and "constexpr
2015-01-08: olly
When reporting an error for a construct which hasn't been
terminated when the end of the file is reached, report it at the
start line rather than "EOF" as then tools like editors and IDEs
will take you to a generally more useful place for fixing the
2015-01-08: olly
Improve error messages for a few cases which previously gave the
one of the cryptic catch-all errors "Syntax error in input".
2015-01-08: olly
Provide -cppext as a general command line option for setting the
extension used for generated C++ files (previously it was specific
to the PHP backend). Deprecate the equivalent -suffix option
provided by the Ocaml backend, but continue to support that for
Version 3.0.3 (30 Dec 2014)
2014-12-27: wsfulton
Fix #280 - abort using all default template parameters within other template
2014-12-27: talby
[Perl] Issue #282 perl5 archlib vs archlibexp
[Perl] tidy "warning: duplicate 'extern' declaration specifier" when building generated code
under clang
2014-12-18: wsfulton
Add support for %constant and structs/classes - issue #272
2014-12-09: wsfulton
Fix #245 - regression (since swig-3.0.0) in templated constructors.
Templated constructors could not be instantiated - they were incorrectly ignored with a warning 504:
"Function: xyz must have a return type. Ignored."
2014-12-07: wsfulton
Add support for C++11 strongly typed enumerations.
2014-11-21: wsfulton
[Java C#] Fix multiply defined error when using %rename of enum items when using the "simple enum"
2014-10-28: vadz
[Python] Patch #201 The generated .py file no longer uses *args for all Python parameters.
Instead, the parameters are named using the C++ parameter names.
"compactdefaultargs" feature can be enabled to restore the old behaviour.
2014-10-24: timotheecour
[D] Patch #204 Use core.atomic.atomicOp to mutate shared variables
2014-10-21: wsfulton
Fix issue #242 - Use of the "kwargs" feature no longer automatically turns on the
"compactdefaultargs" feature if the target language does not support kwargs.
This change affects all languages except Python and Ruby.
2014-10-10: diorcety
[Python] Patch #232 Fix property access using directors
2014-10-06: wsfulton
[Python] Fixes when using -builtin and std::vector/std::list wrappers to allow deletion
of single elements, such as 'del vec[0]'.
2014-09-30: oliverb
[Javascript] Merge patch #216 by Richie765 - Added support for many versions of v8 javascript.
2014-09-30: oliverb
[Javascript] Merge patch #195 by zittix - Fixed JSClassRef declaration not using the static one.
2014-09-30: ianlancetaylor
[Go] In configure script, require Go 1.1 or later.
2014-09-30: wsfulton
[Python] Patch #207 - Fix No module error with -relativeimport when using single
header file import.
2014-09-27: wsfulton
Patch #208 - Initialise newly created array when using array_functions in the
carrays.i library (C++ usage).
2014-09-27: wsfulton
[Ruby] Patch #187 - Fix crash on shutdown of the Ruby interpreter if more than one
module was loaded at a time when data is being shared between modules.
2014-09-27: wsfulton
[Java] Patch #168 - Fix leak in Java director string handling after the Java
upcall when called from a native thread.
2014-09-25: ianlancetaylor
[Go] Adjust generated code to work with upcoming Go 1.4
2014-09-23: wsfulton
[Python] Add patch from Thomas Maslach to fix crash in wrappers when using -threads in
the STL iterators (SwigPyIterator destructor).
2014-09-17: wsfulton
[C#] Merge patch #229 from contre - Add bool array types to arrays_csharp.i
2014-09-12: olly
[PHP] Add support for specifying any PHP interfaces a wrapped class
implements, e.g.: %typemap("phpinterfaces") MyIterator "Iterator";
2014-09-11: olly
[PHP] Fix throwing a PHP exception through C++ from a subclassed
director method - PHP NULL gets returned by the subclassed method
in this case, so the directorout typemap needs to allow that (at
least if an exception is active).
2014-09-09: ianlancetaylor
[Go] Add goargout typemap.
2014-09-09: olly
[PHP] Fix segmentation faults with directors in PHP >= 5.4, and
reenable runme tests for director_basic testcase. Fix from
pavel-charvat in issue#164.
2014-09-05: ianlancetaylor
[Go] Add imtype, goin, goout, godirectorin, and
godirectorout typemaps, to support writing Go code to
convert between types.
2014-09-02: olly
[Python] Fix regression in indentation of python code produced with
-modern, introduced by changes in #188. Reported by fabiencastan
in #218.
2014-09-01: olly
Issue an error for unknown SWIG preprocessor directives, rather
than quietly ignoring them. Reported by jrhelsey in issue#217.
2014-08-15: talby
[Perl] Include guard fix for nested modules from Anthony Heading (SF Patch #350).
2014-08-04: wsfulton
[C#] Merge patch #200 from gpetrou - Changed CSharp license header to include auto-generated
tag so that StyleCop ignores the files.
2014-08-04: wsfulton
[Java] Merge patch #198 from Yuval Kashtan - Support for java.nio.ByteBuffer mapping to
unsigned char * in various.i in NIOBUFFER typemaps.
2014-07-14: ianlancetaylor
[Go] Change struct definition to use void *, not uint8, so
that the type is recorded as possibly containing
pointers. This ensures that the 1.3 garbage collector
does not collect pointers passed to C++ code.
2014-07-01: wsfulton
Fix SF Bug #1375 - Expansion of the $parentclassname special variable incorrectly contains
brackets in the expanded name.
Version 3.0.2 (4 Jun 2014)
2014-06-02: v-for-vandal
[Lua] Pull request #176:
If class has no __eq implemented, then default __eq is generated.
Default __eq compares actual pointers stored inside Lua userdata.
2014-06-02: vkalinin
Fix #183 - %extend and unnamed nested structs
2014-05-28: kwwette
Fix install failure when using an 'out of source' build using the shipped
tarball - regression introduced in swig-3.0.1.
2014-05-24: kwwette
[Octave] Remove deprecated -global/-noglobal command-line arguments
Version 3.0.1 (27 May 2014)
2014-05-25: hfalcic
[Python] Python 3 byte string output: use errors="surrogateescape"
if available on the version of Python that's in use. This allows
obtaining the original byte string (and potentially trying a fallback
encoding) if the bytes can't be decoded as UTF-8.
Previously, a UnicodeDecodeError would be raised with no way to treat
the data as bytes or try another codec.
2014-05-18: vkalinin
Bug #175 - Restore %extend to work for unnamed nested structures by using a C
symbol comprising the outer structure name and unnamed variable instance name.
2014-05-15: kwwette
Add #166 - 'make check' now works out of source. This required the examples to build
out of source. The main languages have been tested - C#, Go, Guile, Java, Javascript,
Lua, Octave, Perl, PHP, Python, Ruby and Tcl.
2014-05-01: Oliver Buchtala
Javascript support added, see Javascript chapter in the documentation.
2014-05-01: olly
[PHP] The generated __isset() method now returns true for read-only properties.
2014-04-24: kwwette
[Go] Fix go ./configure parsing of gccgo --version, and
goruntime.swg typo in __GNUC_PATCHLEVEL__ (SF Bug #1298)
2014-04-24: kwwette
Fix {python|perl5|ruby|tcl}/java examples
In Lib/gcj/cni.i, for compatibility with newer gcj versions:
- remove JvAllocObject() which gcj no longer defines, from gcj Changelog:
2004-04-16 Bryce McKinlay <>
* gcj/cni.h (JvAllocObject): Remove these obsolete,
undocumented CNI calls.
- change JvCreateJavaVM() argument from void* to JvVMInitArgs*, from gcj Changelog:
2005-02-23 Thomas Fitzsimmons <>
PR libgcj/16923
(JvCreateJavaVM): Declare vm_args as JvVMInitArgs* rather than void*.
2014-04-08: wsfulton
SF Bug #1366 - Remove duplicate declarations of strtoimax and strtoumax in inttypes.i
2014-04-08: wsfulton
[Java C#] Enums which have been ignored via %ignore and are subsequently
used are handled slightly differently. Type wrapper classes are now generated
which are effectively a wrapper of an empty enum. Previously in Java uncompilable
code was generated and in C# an int was used.
2014-04-04: wsfulton
Fix regression in 3.0.0 where legal code following an operator<< definition might
give a syntax error. SF Bug #1365.
2014-04-03: olly
[PHP] Fix wrapping director constructors with default parameters
with a ZTS-enabled build of PHP.
2014-04-02: olly
[PHP] Pass the ZTS context we already have to avoid needing to
call TSRMLS_FETCH, which is relatively expensive.
2014-04-02: olly
[PHP] Pass ZTS context through to t_output_helper() so it works
with a ZTS-enabled build of PHP. Reported by Pierre Labastie in
github PR#155.
2014-03-28: wsfulton
[Java C# D Go] Fixes for C enums used in an API and the definition of the enum
has not been parsed. For D, this fixes a segfault in SWIG. The other languages
now produce code that compiles, although the definition of the enum is needed
in order to use the enum properly from the target language.
2014-03-23: v-for-vandal
[Lua] Fix for usage of snprintf in Lua runtime which Visual Studio does not have.
Version 3.0.0 (16 Mar 2014)
2014-03-16: wsfulton
C++11 support initially developed as C++0x support by Matevz Jekovec as a Google Summer of Code
project has been further extended. The C++11 support is comprehensive, but by no means complete
or without limitations. Full details for each new feature in C++11 is covered in the
CPlusPlus11.html chapter in the documentation which is included in SWIG and also available
online at
2014-03-14: v-for-vandal
[Lua] Numerous Lua improvements:
1. %nspace support has been added. Namespaces are mapped to tables in the module, with the same
name as the C++ namespace.
2. Inheritance is now handled differently. Each class metatable keeps a list of class bases instead
of merging all members of all bases into the derived class.
3. The new metatables result in differences in accessing class members. For example:
%module example
struct Test {
enum { TEST1 = 10, TEST2 = 20 };
static const int ICONST = 12;
Now this can be used as follows:
The old way was:
4. The special class metatable member ".constructor" was removed. Now SWIG generates the proxy
function by itself and assigns it directly to the class table "__call" method.
5. eLua should also now support inheritance.
6. 'const' subtable in eLua is considered deprecated.
Changes in behaviour:
a. You can no longer assign to non-existing class members in classes without a __setitem__ method.
It will cause a Lua error.
b. You can no longer iterate over a module table and copy everything into the global namespace.
Actually, this was never the case, but it is now explicitly prohibited.
c. Now changing a base class will immediately affect all derived classes.
d. There might be some issues with inheritance. Although the bases iteration scheme is the same
as was used for merging base classes into derived one, some unknown issues may arise.
The old metatable behaviour can be restored by using the -no-old-metatable-bindings option.
2014-03-06: wsfulton
[Python] Change in default behaviour wrapping C++ bool. Only a Python True or False
will now work for C++ bool parameters. This fixes overloading bool with other types.
Python 2.3 minimum is now required for wrapping bool.
When wrapping:
const char* overloaded(bool value) { return "bool"; }
const char* overloaded(int value) { return "int"; }
Previous behaviour:
>>> overloaded(False)
>>> overloaded(True)
>>> overloaded(0)
Now we get the expected behaviour:
>>> overloaded(False)
>>> overloaded(0)
The consequence is when wrapping bool in non-overloaded functions:
const char* boolfunction(bool value) { return value ? "true" : "false"; }
The previous behaviour was very Pythonic:
>>> boolfunction("")
>>> boolfunction("hi")
>>> boolfunction(12.34)
>>> boolfunction(0)
>>> boolfunction(1)
Now the new behaviour more along the lines of C++ due to stricter type checking. The
above calls result in an exception and need to be explicitly converted into a bool as
>>> boolfunction(0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: in method 'boolfunction', argument 1 of type 'bool'
>>> boolfunction(bool(0))
The old behaviour can be resurrected by passing the -DSWIG_PYTHON_LEGACY_BOOL command line
parameter when executing SWIG. Typemaps can of course be written to customise the behaviour
for specific parameters.
2014-03-06: wsfulton
Fix SF Bug #1363 - Problem with method overloading when some methods are added by %extend
and others are real methods and using template default parameters with smart pointers.
This is noticeable as a regression since 2.0.12 when using the default smart pointer
handling for some languages when the smart pointer wraps std::map and other STL containers.
2014-03-02: wsfulton
[Python] SF Patch #346 from Jens Krueger. Correct exception thrown attempting to
access a non-existent C/C++ global variable on the 'cvar' object. The exception thrown
used to be a NameError. However, as this access is via a primary, an AttributeError
is more correct and so the exception thrown now is an AttributeError. Reference:
2014-03-01: wsfulton
[Python] Patch #143 Fix type shown when using type() to include the module and package
name when using -builtin.
2014-03-01: wsfulton
[Python] SF patch #347 Fix missing argument count checking with -modern.
Fixes regression introduced when builtin changes were introduced in SWIG-2.0.3.
2014-02-21: wsfulton
[PHP] Fix warning suppression using %warnfilter for PHP reserved class names.
2014-02-19: olly
[Lua] Add keyword warnings for Lua keywords and Basic Functions.
2014-02-19: olly
-Wallkw now includes keywords for all languages with keyword
warnings (previously Go and R were missing).
2014-02-19: olly
[PHP] Update the lists of PHP keywords with new ones from PHP 5.4
and newer (and some missing ones from 5.3). Reserved PHP constants
names are now checked against enum values and constants, instead
of against function and method names. Built-in PHP function names
no longer match methods added by %extend. Functions and methods
named '__sleep', '__wakeup', 'not', 'parent', or 'virtual' are no
longer needlessly renamed.
2014-02-15: wsfulton
Fix the %$ismember %rename predicates to also apply to members added via %extend.
Add %$isextendmember for %rename of members added via %extend. This can be used to
distinguish between normal class/struct members and %extend members. For example
'%$ismember, %$not %$isextendmember' will now identify just class/struct members.
2014-02-16: hfalcic
[Python] Patch #137 - fix crashes/exceptions in exception handling in Python 3.3
2014-02-15: wsfulton
[Java] Add support for the cdata library.
2014-02-08: vkalinin
Nested class support added. This primarily allows SWIG to properly parse nested
classes and keep the nested class information in the parse tree. Java and C#
have utilised this information wrapping the C++ nested classes as Java/C#
nested classes. The remaining target languages ignore nested classes as in
previous versions. Help is needed by users of these remaining languages to
design how C++ nested classes can be best wrapped. Please talk to us on the
swig-devel mailing list if you think you can help.
Previously, there was limited nested class support. Nested classes were treated
as opaque pointers. However, the "nestedworkaround" feature provided a way to
wrap a nested class as if it was a global class. This feature no longer exists
and is replaced by the new "flatnested" feature. This effectively does the same
thing with less manual code to be written. Please see the 'Nested classes'
section in the documentation in SWIGPlus.html if you were previously using this
SWIG now parses the contents of nested classes where previously it did not. You
may find that you will need to make adjustments to your interface file as
effectively extra code is being wrapped.
2014-02-06: gjanssens
[Guile] Patch #133. Make scm to string conversion work with non-ascii strings.
Guile 2 has a completely rewritten string implementation. SWIG made some assumptions
that are no longer valid as to the internals of guile's string representation.
2014-01-30: wsfulton
[C#] Add new swigtype_inout.i library containing SWIGTYPE *& OUTPUT typemaps.
Example usage wrapping:
void f(XXX *& x) { x = new XXX(111); }
would be:
XXX x = null;
f(out x);
// use x
x.Dispose(); // manually clear memory or otherwise leave out and leave it to the garbage collector
2014-01-21: ianlancetaylor
[Go] Add %go_import directive.
2014-01-21: ianlancetaylor
[Go] Add support for Go 1.3, not yet released.
2014-01-20: wsfulton
Director exceptions (Swig::DirectorException) now derive from std::exception
and hence provide the what() method. In Python and Ruby, this replaces the now
deprecated DirectorException::getMessage() method.
2014-01-14: diorcety
Patch #112 - Fix symbol resolution involving scopes that have multiple levels
of typedefs - fixes some template resolutions as well as some typemap searches.
2014-01-11: wsfulton
Fix and document the naturalvar feature override behaviour - the naturalvar
feature attached to a variable name has precedence over the naturalvar
feature attached to the variable's type. The overriding was not working
when turning the feature off on the variable's name.
Fix so that any use of the naturalvar feature will override the global
setting. Previously when set globally by -naturalvar or %module(naturalvar=1),
use of the naturalvar feature was not always honoured.
2014-01-06: ianlancetaylor
[Go] Fix bug that broke using directors from a thread not
created by Go.
2013-12-24: ptomulik
[Python] SF Bug #1297
Resolve several issues related to python imports.
For example, it's now possible to import modules having the same module
names, but belonging in different packages.
From the user's viewpoint, this patch gives a little bit more control on
import statements generated by SWIG. The user may choose to use relative
or absolute imports.
Some details:
- we (still) generate import statements in the form 'import a.b.c' which
corresponds to absolute imports in python3 and (the only available)
ambiguous one in python2.
- added -relativeimport option to use explicit relative import syntax
The "Python Packages" section in the documentation discusses how to work
with importing packages including the new -relativeimport command line option.
2013-12-23: vadz
[Octave, Perl, Python, R, Ruby, Tcl] Change the length of strings created from fixed-size char
buffers in C code.
This is a potential backwards compatibility break: a "char buf[5]" containing "ho\0la" was
returned as a string of length 5 before, but is returned as a string of length 2 now. Also,
it was possible to assign a (non-NUL-terminated) string "hello" to such a buffer before but
now this fails and only "helo" can fit.
Apply "char FIXSIZE[ANY]" typemaps to explicitly choose the old behaviour.
2013-12-23: talby
[Perl] Add support for directors.
2013-12-18: ianlancetaylor
[Go] Don't require that Go environment variables be set
when running examples or testsuite when using Go 1 or
2013-12-17: ianlancetaylor
[Go] Remove -longsize option (for backward compatibility,
ignore it if seen).
2013-12-17: ianlancetaylor
[Go] Add -go-pkgpath option.
2013-12-16: ianlancetaylor
[Go] Update for Go 1.2 release. Add support for linking
SWIG code directly into executable, rather than using a
shared library.
2013-12-13: ianlancetaylor
[Go] Add SWIG source file name as comments in generated
files. This can be used by Go documentation tools.
2013-12-12: jleveque
[Lua] Fix typo (wchar instead of wchar_t) which made wchar.i
for Lua useless.
2013-12-12: vmiklos
[PHP] PHP's peculiar call-time pass-by-reference feature was
deprecated in PHP 5.3 and removed in PHP 5.4, so update the REF
typemaps in phppointers.i to specify pass-by-reference in the
function definition. Examples/php/pointer has been updated
2013-12-12: olly
[PHP] The usage of $input in PHP directorout typemaps has been
changed to be consistent with other languages. The typemaps
provided by SWIG have been updated accordingly, but if you
have written your own directorout typemaps, you'll need to
update $input to &$input (or make equivalent changes).
2013-11-27: vadz
[C#, Java, Python] Add std_auto_ptr.i defining typemaps for returning std::auto_ptr<>.
2013-11-09: wsfulton
[C#] Apply patch #79 from Brant Kyser
- Remove using directives from the generated C# code and fully qualify the use of all .NET
framework types in order to minimize potential name collisions from input files defining
types, namespace, etc with the same name as .NET framework members.
- Globally qualify the use of .NET framework types in the System namespace
- Remove .NET 1.1 support, .NET 2 is the minimum for the C# module
This is a potential backwards compatibility break if code has been added relying on these using
statements that used to be generated:
using System;
using System.Runtime.InteropServices;
The quick fix to add these back in is to add the -DSWIG2_CSHARP command line option when
executing SWIG. See CSharp.html documentation for more info.
2013-11-05: wsfulton
[Java] Fix some corner cases for the $packagepath/$javaclassname special variable substitution.
2013-11-05: wsfulton
[Java] Apply patch #91 from Marvin Greenberg - Add director:except feature for improved
exception handling in director methods for Java.
2013-10-15: vadz
Allow using \l, \L, \u, \U and \E in the substitution part of %(regex:/pattern/subst/)
inside %rename to change the case of the text being replaced.
2013-10-12: wsfulton
[CFFI] Apply #96 - superclass not lispify
2013-10-12: wsfulton
Merge in C++11 support from the gsoc2009-matevz branch where Matevz Jekovec first
started the C++0x additions. Documentation of the C++11 features supported is in a
new Chapter of the documentation, "SWIG and C++11" in Doc/Manual/CPlusPlus11.html.
2013-10-04: wsfulton
Fix %naturalvar not having any affect on templated classes instantiated with an
enum as the template parameter type. Problem reported by Vadim Zeitlin.
2013-09-20: wsfulton
[Java] Fix a memory leak for the java char **STRING_ARRAY typemaps.
Version 2.0.12 (9 Feb 2014)
2014-01-16: wsfulton
[PHP] Fix compilation error in ZTS mode (64 bit windows) due to incorrect placement
of TSRMLS_FETCH() in SWIG_Php_GetModule() as reported by Mark Dawson-Butterworth.
2014-01-13: kwwette
[Octave] update support to Octave version 3.8.0
- Octave 3.8.0 no longer defines OCTAVE_API_VERSION_NUMBER, but 3.8.1
will define OCTAVE_{MAJOR,MINOR,PATCH}_VERSION instead: see
So we now use a new macro SWIG_OCTAVE_PREREQ(major,minor,patch) to
enable features requiring Octave version major.minor.patch or later.
For Octave versions prior to 3.8.1, we reconstruct values for
extracted from Octave's ChangeLogs. An additional hack is needed to
distinguish between Octave <= 3.2.x and 3.8.0, neither of which define
- Octave 3.8.0 deprecates symbol_table::varref(), so remove its use
for this and future versions of Octave.
- Octave 3.8.0 removes octave_value::is_real_nd_array(), used in
octave_swig_type::dims(). Its use is not required here, so remove it.
- Retested against Octave versions 3.0.5, 3.2.4, 3.4.3, 3.6.4, and 3.8.0.
- Updated Octave documentation with tested Octave versions, and added a
warning against using versions <= 3.x.x, which are no longer tested.
2013-12-22: wsfulton
C++11 support for new versions of erase and insert in the STL containers.
The erase and insert methods in the containers use const_iterator instead
of iterator in C++11. There are times when the methods wrapped must match
the parameters exactly. Specifically when full type information for
template types is missing or SWIG fails to look up the type correctly,
for example:
%include <std_vector.i>
typedef float Real;
%template(RealVector) std::vector<Real>;
SWIG does not find std::vector<Real>::iterator because %template using
typedefs does not always work and so SWIG doesn't know if the type is
copyable and so uses SwigValueWrapper<iterator> which does
not support conversion to another type (const_iterator). This resulted
in compilation errors when using the C++11 version of the containers.
Closes #73
2013-10-17: wsfulton
[R] Fix SF #1340 - Visual Studio compile error in C++ wrappers due to #include <exception>
within extern "C" block.
2013-10-17: wsfulton
[Python] Fix SF #1345 - Missing #include <stddef.h> for offsetof when using -builtin.
2013-10-12: wsfulton
[Lua] Apply #92 - missing return statements for SWIG_Lua_add_namespace_details()
and SWIG_Lua_namespace_register().
Version 2.0.11 (15 Sep 2013)
2013-09-15: wsfulton
[R] Fix attempt to free a non-heap object in OUTPUT typemaps for:
unsigned short *OUTPUT
unsigned long *OUTPUT
signed long long *OUTPUT
char *OUTPUT
signed char*OUTPUT
unsigned char*OUTPUT
2013-09-12: wsfulton
[Lua] Pull Git patch #62.
1) Static members and static functions inside class can be accessed as
ModuleName.ClassName.FunctionName (MemberName respectively). Old way such as
ModuleName.ClassName_FunctionName still works.
2) Same goes for enums inside classes: ModuleName.ClassName.EnumValue1 etc.
2013-09-12: wsfulton
[UTL] Infinity is now by default an acceptable value for type 'float'. This fix makes
the handling of type 'float' and 'double' the same. The implementation requires the
C99 isfinite() macro, or otherwise some platform dependent equivalents, to be available.
Users requiring the old behaviour of not accepting infinity, can define a 'check' typemap
wherever a float is used, such as:
%typemap(check,fragment="<float.h>") float, const float & %{
if ($1 < -FLT_MAX || $1 > FLT_MAX) {
SWIG_exception_fail(SWIG_TypeError, "Overflow in type float");
2013-08-30: wsfulton
[Lua] Pull Git patch #81: Include Lua error locus in SWIG error messages.
This is standard information in Lua error messages, and makes it much
easier to find bugs.
2013-08-29: wsfulton
Pull Git patch #75: Handle UTF-8 files with BOM at beginning of file. Was giving an
'Illegal token' syntax error.
2013-08-29: wsfulton
[C#] Pull Git patch #77: Allow exporting std::map using non-default comparison function.
2013-08-28: wsfulton
[Python] %implicitconv is improved for overloaded functions. Like in C++, the methods
with the actual types are considered before trying implicit conversions. Example:
%implicitconv A;
struct A {
A(int i);
class CCC {
int xx(int i) { return 11; }
int xx(const A& i) { return 22; }
The following python code:
will now return 11 instead of 22 - the implicit conversion is not done.
2013-08-23: olly
[Python] Fix clang++ warning in generated wrapper code.
2013-08-16: wsfulton
[Python] %implicitconv will now accept None where the implicit conversion takes a C/C++ pointer.
Problem highlighted by Bo Peng. Closes SF patch #230.
2013-08-07: wsfulton
[Python] SF Patch #326 from Kris Thielemans - Remove SwigPyObject_print and SwigPyObject_str and
make the generated wrapper use the default python implementations, which will fall back to repr
(for -builtin option).
- it avoids the swig user having to jump through hoops to get print to work as expected when
redefining repr/str slots.
- typing the name of a variable on the python prompt now prints the result of a (possibly redefined)
repr, without the swig user having to do any extra work.
- when redefining repr, the swig user doesn't necessarily have to redefine str as it will call the
redefined repr
- the behaviour is exactly the same as without the -builtin option while requiring no extra work
by the user (aside from adding the %feature("python:slot...) statements of course)
- default str() will give different (but clearer?) output on swigged classes
2013-07-30: wsfulton
[Python, Ruby] Fix #64 #65: Missing code in std::multimap wrappers. Previously an instantiation
of a std::map was erroneously required in addition to an instantiation of std::multimap with the
same template parameters to prevent compilation errors for the wrappers of a std::multimap.
2013-07-14: joequant
[R] Change types file to allow for SEXP return values
2013-07-05: wsfulton
[Python] Add %pythonbegin directive which works like %pythoncode, except the specified code is
added at the beginning of the generated .py file. This is primarily needed for importing from
__future__ statements required to be at the very beginning of the file. Example:
%pythonbegin %{
from __future__ import print_function
print("Loading", "Whizz", "Bang", sep=' ... ')
2013-07-01: wsfulton
[Python] Apply SF patch #340 - Uninitialized variable fix in SWIG_Python_NonDynamicSetAttr
when using -builtin.
2013-07-01: wsfulton
[Python, Ruby, Ocaml] Apply SF patch #341 - fix a const_cast in generated code that was generating
a <:: digraph when using the unary scope operator (::) (global scope) in a template type.
2013-07-01: wsfulton
[Python] Add SF patch #342 from Christian Delbaere to fix some director classes crashing on
object deletion when using -builtin. Fixes SF bug #1301.
2013-06-11: wsfulton
[Python] Add SWIG_PYTHON_INTERPRETER_NO_DEBUG macro which can be defined to use the Release version
of the Python interpreter in Debug builds of the wrappers. The Visual Studio .dsp example
files have been modified to use this so that Debug builds will now work without having
to install or build a Debug build of the interpreter.
2013-06-07: wsfulton
[Ruby] Git issue #52. Fix regression with missing rb_complex_new function for Ruby
versions prior to 1.9 using std::complex wrappers if just using std::complex as an output type.
Also fix the Complex helper functions external visibility (to static by default).
2013-06-04: olly
[PHP] Fix SWIG_ZTS_ConvertResourcePtr() not to dereference NULL
if the type lookup fails.
Version 2.0.10 (27 May 2013)
2013-05-25: wsfulton
[Python] Fix Python 3 inconsistency when negative numbers are passed
where a parameter expects an unsigned C type. An OverFlow error is
now consistently thrown instead of a TypeError.
2013-05-25: Artem Serebriyskiy
SVN Patch ticket #338 - fixes to %attribute macros for template usage
with %arg.
2013-05-19: wsfulton
Fix ccache-swig internal error bug due to premature file cleanup.
Fixes SF bug 1319 which shows up as a failure in the ccache tests on
Debian 64 bit Wheezy, possibly because ENABLE_ZLIB is defined.
This is a corner case which will be hit when the maximum number of files
in the cache is set to be quite low (-F option), resulting in a cache miss.
2013-05-09: kwwette
[Octave] Fix bugs in Octave module loading:
- fix a memory leak in setting of global variables
- install functions only once, to speed up module loads
2013-04-28: gjanssens
[Guile] Updates in guile module:
- Add support for guile 2.0
- Drop support for guile 1.6
- Drop support for generating wrappers using guile's gh interface.
All generated wrappers will use the scm interface from now on.
- Deprecate -gh and -scm options. They are no longer needed.
A warning will be issued when these options are still used.
- Fix all tests and examples to have a successful travis test
2013-04-18: wsfulton
Apply Patch #36 from Jesus Lopez to add support for $descriptor() special variable macro expansion
in fragments. For example:
%fragment("nameDescriptor", "header")
static const char *nameDescriptor = "$descriptor(Name)";
which will generate into the wrapper if the fragment is used:
static const char *nameDescriptor = "SWIGTYPE_Name";
2013-04-18: wsfulton
Fix SF Bug #428 - Syntax error when preprocessor macros are defined inside of enum lists, such as:
typedef enum {
eZero = 0
#define ONE 1
} EFoo;
The macros are silently ignored.
2013-04-17: wsfulton
[C#] Pull patch #34 from BrantKyser to fix smart pointers in conjunction with directors.
2013-04-15: kwwette
[Octave] Fix bugs in output of cleanup code.
- Cleanup code is now written also after the "fail:" label, so it will be called if
a SWIG_exception is raised by the wrapping function, consistent with other modules.
- Octave module now also recognises the "$cleanup" special variable, if needed.
2013-04-08: kwwette
Add -MP option to SWIG for generating phony targets for all dependencies.
- Prevents make from complaining if header files have been deleted before
the dependency file has been updated.
- Modelled on similar option in GCC.
2013-04-09: olly
[PHP] Add missing directorin typemap for char* and char[] which
fixes director_string testcase failure.
2013-04-05: wsfulton
[Ruby] SF Bug #1292 - Runtime fixes for Proc changes in ruby-1.9 when using STL
wrappers that override the default predicate, such as:
%template(Map) std::map<swig::LANGUAGE_OBJ, swig::LANGUAGE_OBJ, swig::BinaryPredicate<> >;
2013-04-05: wsfulton
[Ruby] SF Bug #1159 - Correctly check rb_respond_to call return values to fix some
further 1.9 problems with functors and use of Complex wrappers.
2013-04-02: wsfulton
[Ruby] Runtime fixes for std::complex wrappers for ruby-1.9 - new native Ruby complex numbers are used.
2013-03-30: wsfulton
[Ruby] Fix seg fault when using STL containers of generic Ruby types, GC_VALUE or LANGUAGE_OBJECT,
on exit of the Ruby interpreter. More frequently observed in ruby-1.9.
2013-03-29: wsfulton
[Ruby] Fix delete_if (reject!) for the STL container wrappers which previously would
sometimes seg fault or not work.
2013-03-25: wsfulton
[Python] Fix some undefined behaviour deleting slices in the STL containers.
2013-03-19: wsfulton
[C#, Java, D] Fix seg fault in SWIG using directors when class and virtual method names are
the same except being in different namespaces when the %nspace feature is not being used.
2013-02-19: kwwette
Fix bug in SWIG's handling of qualified (e.g. const) variables of array type. Given the typedef
a(7).q(volatile).double myarray // typedef volatile double[7] myarray;
the type
q(const).myarray // const myarray
a(7).q(const volatile).double // const volatile double[7]
Previously, SwigType_typedef_resolve() produces the type
q(const).a(7).q(volatile).double // non-sensical type
which would never match %typemap declarations, whose types were parsed correctly.
Add typemap_array_qualifiers.i to the test suite which checks for the correct behaviour.
2013-02-18: wsfulton
Deprecate typedef names used as constructor and destructor names in %extend. The real
class/struct name should be used.
typedef struct tagEStruct {
int ivar;
} EStruct;
%extend tagEStruct {
EStruct() // illegal name, should be tagEStruct()
EStruct *s = new EStruct();
s->ivar = ivar0;
return s;
~EStruct() // illegal name, should be ~tagEStruct()
delete $self;
For now these trigger a warning:
extend_constructor_destructor.i:107: Warning 522: Use of an illegal constructor name 'EStruct' in
%extend is deprecated, the constructor name should be 'tagEStruct'.
extend_constructor_destructor.i:111: Warning 523: Use of an illegal destructor name 'EStruct' in
%extend is deprecated, the destructor name should be 'tagEStruct'.
These %extend destructor and constructor names were valid up to swig-2.0.4, however swig-2.0.5 ignored
them altogether for C code as reported in SF bug #1306. The old behaviour of using them has been
restored for now, but is officially deprecated. This does not apply to anonymously defined typedef
classes/structs such as:
typedef struct {...} X;
2013-02-17: kwwette
When generating functions provided by %extend, use "(void)" for no-argument functions
instead of "()". This prevents warnings when compiling with "gcc -Wstrict-prototypes".
2013-02-17: kwwette
[Octave] Minor fix to autodoc generation: get the right type for functions returning structs.
2013-02-15: wsfulton
Deprecate typedef names used in %extend that are not the real class/struct name. For example:
typedef struct StructBName {
int myint;
} StructB;
%extend StructB {
void method() {}
will now trigger a warning:
swig_extend.i:19: Warning 326: Deprecated %extend name used - the struct name StructBName
should be used instead of the typedef name StructB.
This is only partially working anyway (the %extend only worked if placed after the class
2013-02-09: wsfulton
[CFFI] Apply patch #22 - Fix missing package before &body
2013-01-29: wsfulton
[Java] Ensure 'javapackage' typemap is used as it stopped working from version 2.0.5.
2013-01-28: wsfulton
[Python] Apply patch SF #334 - Fix default value conversions "TRUE"->True, "FALSE"->False.
2013-01-28: wsfulton
[Java] Apply patch SF #335 - Truly ignore constructors in directors with %ignore.
2013-01-18: Brant Kyser
[Java] Patch #15 - Allow the use of the nspace feature without the -package commandline option.
This works as long and the new jniclasspackage pragma is used to place the JNI intermediate class
into a package and the nspace feature is used to place all exposed types into a package.
2013-01-15: wsfulton
Fix Visual Studio examples to work when SWIG is unzipped into a directory containing spaces.
2013-01-15: wsfulton
[C#] Fix cstype typemap lookup for member variables so that a fully qualified variable name
matches. For example:
%typemap(cstype) bool MVar::mvar "MyBool"
struct MVar {
bool mvar;
2013-01-11: Brant Kyser
[Java, C#, D] SF Bug #1299 - Fix generated names for when %nspace is used on
classes with the same name in two different namespaces.
2013-01-11: Vladimir Kalinin
[C#] Add support for csdirectorin 'pre', 'post' and 'terminator' attributes.
2013-01-08: olly
[PHP] Fix to work with a ZTS build of PHP (broken in 2.0.7).
2013-01-07: olly
Fix bashism in configure, introduced in 2.0.9.
2013-01-06: wsfulton
Pull patch #4 from ptomulik to fix SF Bug #1296 - Fix incorrect warning for virtual destructors
in templates, such as:
Warning 521: Illegal destructor name B< A >::~B(). Ignored.
2013-01-05: wsfulton
[Python] Pull patch #3 from ptomulik to fix SF Bug #1295 - standard exceptions as
classes using the SWIG_STD_EXCEPTIONS_AS_CLASSES macro.
2013-01-04: wsfulton
[Java] Pull patch #2 from BrantKyser to fix SF Bug #1283 - fix smart pointers in conjuction
with directors.
2013-01-03: wsfulton
[Java] Pull patch #1 from BrantKyser to fix SF Bug #1278 - fix directors and nspace feature when
multilevel namespaces are used.
Version 2.0.9 (16 December 2012)
2012-12-16: wsfulton
Fix garbage line number / empty file name reporting for some missing
'}' or ')' error messages.
2012-12-15: kkaempf
[Ruby] Apply patch 3530444, Class#methods and Class#constants returns array of
symbols in Ruby 1.9+
2012-12-14: kkaempf
[Ruby] Apply patch 3530439 and finally replace all occurrences of the STR2CSTR() macro
with StringValuePtr(). STR2CSTR was deprecated since years and got removed in Ruby 1.9
2012-12-14: kkaempf
[Ruby] Applied patches #3530442 and 3530443 to adapt compile and runtime include
paths to match Ruby 1.9+
2012-12-14: wsfulton
[CFFI] Fix #3161614 - Some string constants are incorrect
2012-12-13: wsfulton
[CFFI] Fix #3529690 - Fix incorrect constant names.
2012-12-12: drjoe
[R] add fix to finalizer that was missed earlier
2012-12-11: wsfulton
[Python] Apply patch #3590522 - fully qualified package paths for Python 3 even if a module is in the
same package.
2012-12-08: wsfulton
[Python] Bug #3563647 - PyInt_FromSize_t unavailable prior to Python 2.5 for unsigned int types.
2012-12-08: wsfulton
[Perl] Fix bug #3571361 - C++ comment in C wrappers.
2012-12-07: wsfulton
[C#] Apply patch #3571029 which adds missing director support for const unsigned long long &.
2012-11-28: kwwette
[Octave] Simplified module loading: now just the syntax
$ example;
is accepted, which loads functions globally but constants and variables relative to the current scope.
This make module loading behaviour reliably consistent, and reduces problems when loading modules which
depend on other modules which may not have been previously loaded.
2012-11-27: wsfulton
[cffi] Fix junk output when wrapping single character literal constants.
2012-11-17: wsfulton
[Tcl, Modula3] Add missing support for -outdir.
2012-11-17: wsfulton
Fix segfaults when using filename paths greater than 1024 characters in length.
2012-11-14: wsfulton
[ccache-swig] Apply patch #3586392 from Frederik Deweerdt to fix some error cases - incorrectly using
memory after it has been deleted.
2012-11-09: vzeitlin
[Python] Fix overflow when passing values greater than LONG_MAX from Python 3 for parameters with unsigned long C type.
2012-11-09: wsfulton
Fix some feature matching issues for implicit destructors and implicit constructors and implicit
copy constructors added with %copyctor. Previously a feature for these had to be fully qualified
in order to match. Now the following will also match:
%feature("xyz") ~XXX();
struct XXX {};
2012-11-09: wsfulton
Further consistency in named output typemap lookups for implicit constructors and destructors and
implicit copy constructors added with %copyctor. Previously only the fully qualified name was being
used, now the unqualified name will also be used. For example, previously:
example.i:38: Searching for a suitable 'out' typemap for: void Space::More::~More
Looking for: void Space::More::~More
Looking for: void
Now the unqualified name is also used:
example.i:38: Searching for a suitable 'out' typemap for: void Space::More::~More
Looking for: void Space::More::~More
Looking for: void ~More
Looking for: void
2012-11-02: wsfulton
Fix some subtle named output typemap lookup misses, the fully qualified name was not always being
used for variables, for example:
struct Glob {
int MyVar;
Previously the search rules (as shown by -debug-tmsearch) for the getter wrapper were:
example.i:44: Searching for a suitable 'out' typemap for: int MyVar
Looking for: int MyVar
Looking for: int
Now the scope is named correctly:
example.i:44: Searching for a suitable 'out' typemap for: int Glob::MyVar
Looking for: int Glob::MyVar
Looking for: int MyVar
Looking for: int
2012-10-26: wsfulton
Fix director typemap searching so that a typemap specified with a name will be correctly matched. Previously
the name was ignored during the typemap search. Applies to the following list of typemaps:
directorout, csdirectorout, cstype, imtype, ctype, ddirectorout, dtype, gotype, jtype, jni, javadirectorout.
2012-10-11: wsfulton
Most of the special variables available for use in %exception are now also available for expansion in
%extend blocks. These are: $name $symname $overname $decl $fulldecl $parentclassname $parentclasssymname, see docs
on "Class extension" in SWIGPlus.html. Patch based on submission from Kris Thielemans.
2012-10-10: wsfulton
Additional new special variables in %exception are expanded as follows:
$parentclassname - The parent class name (if any) for a method.
$parentclasssymname - The target language parent class name (if any) for a method.
2012-10-08: iant
[Go] Generating Go code now requires using the -intgosize option to
indicate the size of the 'int' type in Go. This is because the
size of the type is changing from Go 1.0 to Go 1.1 for x86_64.
2012-09-14: wsfulton
Add new warning if the empty template instantiation is used as a base class, for example:
template <typename T> class Base {};
%template() Base<int>;
class Derived : public Base<int> {};
gives the following warning instead of silently ignoring the base:
cpp_inherit.i:52: Warning 401: Base class 'Base< int >' has no name as it is an empty template instantiated with '%template()'. Ignored.
cpp_inherit.i:51: Warning 401: The %template directive must be written before 'Base< int >' is used as a base class and be declared with a name.
2012-09-11: wsfulton
[Java] Fix #3535304 - Direct use of a weak global reference in directors
sometimes causing seg faults especially on Android.
2012-09-06: wsfulton
[Java] Fix (char *STRING, size_t LENGTH) typemaps to accept NULL string.
2012-08-26: drjoe
[R] make ExternalReference slot ref to contain reference
2012-08-26: drjoe
[R] fix Examples/Makefile to use C in $(CC) rather than $(CXX)
Version 2.0.8 (20 August 2012)
2012-08-15: wsfulton
[Perl] Add size_type, value_type, const_reference to the STL containers.
2012-08-15: wsfulton
[Python] Add discard and add methods to std::set wrappers so that pyabc.i can be used ensuring
MutableSet is a valid abstract base class for std::set. As reported by Alexey Sokolov.
Similarly for std::multiset.
2012-08-15: wsfulton
[Python] Fix #3541744 - Missing PyInt_FromSize_t calls for Python 3.
2012-08-13: wsfulton
[Java] Patch from David Baum to add the assumeoverride feature for Java directors to
improve performance when all overridden methods can be assumed to be overridden.
2012-08-05: wsfulton
[Python] #3530021 Fix unused variable warning.
2012-08-05: wsfulton
[C#] Fix #3536360 - Invalid code sometimes being generated for director methods
with many arguments.
2012-08-05: wsfulton
[Perl] #3545877 - Don't undefine bool if defined by C99 stdbool.h - problem using
Perl 5.16 and later.
2012-08-04: wsfulton
Remove incorrect warning (314) about target language keywords which were triggered
by using declarations and using directives. For example 'string' is a keyword in C#:
namespace std { class string; }
using std::string;
2012-07-21: wsfulton
Fix display of pointers in various places on 64 bit systems - only 32 bits were being shown.
2012-07-21: wsfulton
Fix gdb debugger functions 'swigprint' and 'locswigprint' to display to the gdb output window
rather than stdout. This fixes display problems in gdbtui and the ensures the output
appears where expected in other gdb based debuggers such as Eclipse CDT.
2012-07-20: kwwette
[Octave] segfault-on-exit prevention hack now preserves exit status, and uses C99 _Exit().
2012-07-02: wsfulton
Fix Debian bug, typemap copy failure - regression introduced
in swig-2.0.5:
using std::pair;
%template(StrPair) pair<std::string, std::string>;
2012-07-02: wsfulton
Fix using declarations combined with using directives with forward class declarations so that
types are correctly found in scope for templates. Example:
namespace Outer2 {
namespace Space2 {
template<typename T> class Thing2;
using namespace Outer2;
using Space2::Thing2;
template<typename T> class Thing2 {};
// STILL BROKEN void useit2(Thing2<int> t) {}
void useit2a(Outer2::Space2::Thing2<int> t) {}
void useit2b(::Outer2::Space2::Thing2<int> t) {}
void useit2c(Space2::Thing2<int> t) {}
namespace Outer2 {
void useit2d(Space2::Thing2<int> t) {}
%template(Thing2Int) Thing2<int>;
2012-06-30: wsfulton
Fix template namespace problems for symbols declared with a forward class declarations, such as:
namespace Space1 {
namespace Space2 {
template<typename T> struct YYY;
template<typename T> struct Space2::YYY {
T yyy(T h) {
return h;
void testYYY1(Space1::Space2::YYY<int> yy) {}
void testYYY2(Space2::YYY<int> yy) {}
void testYYY3(::Space1::Space2::YYY<int> yy) {}
%template(YYYInt) Space1::Space2::YYY<int>;
2012-06-30: wsfulton
Fix namespace problems for symbols declared with a forward class declarations, such as:
namespace Space1 {
namespace Space2 {
struct XXX;
struct YYY;
struct Space2::YYY {};
struct Space1::Space2::XXX {};
void testXXX2(Space2::XXX xx) {}
void testYYY2(Space2::YYY yy) {}
where xx and yy were not recognised as the proxy classes XXX and YYY.
2012-06-30: wsfulton
Fix using declarations combined with using directives with forward class declarations so that
types are correctly found in scope.
namespace Outer2 {
namespace Space2 {
class Thing2;
using namespace Outer2;
using Space2::Thing2;
class Thing2 {};
// None of the methods below correctly used the Thing2 proxy class
void useit2(Thing2 t) {}
void useit2a(Outer2::Space2::Thing2 t) {}
void useit2b(::Outer2::Space2::Thing2 t) {}
void useit2c(Space2::Thing2 t) {}
namespace Outer2 {
void useit2d(Space2::Thing2 t) {}
2012-06-25: wsfulton
Fix using declarations combined with using directives so that types are correctly found in scope.
namespace Outer2 {
namespace Space2 {
class Thing2 {};
using namespace Outer2; // using directive
using Space2::Thing2; // using declaration
void useit2(Thing2 t) {}
Similarly for templated classes.
2012-05-29: wsfulton
Fix #3529601 - seg fault when a protected method has the "director"
feature but the parent class does not. Also fix similar problems with
the allprotected feature.
2012-05-28: wsfulton
Fix seg fault when attempting to warn about an illegal destructor - #3530055, 3530078 and #3530118.
Version 2.0.7 (26 May 2012)
2012-05-26: wsfulton
std::string typemap modifications so they can be used with %apply for other string
2012-05-25: wsfulton
[Lua] Fixes for -external-runtime to work again.
2012-05-22: szager
[python] Disambiguate SWIG_From_unsigned_SS_int and SWIG_From_unsigned_SS_long.
2012-05-18: olly
[PHP] Fix getters for template members. (SF#3428833, SF#3528035)
2012-05-14: wsfulton
Fix some language's std::map wrappers to recognise difference_type, size_type, key_type
and mapped_type.
2012-05-14: kwwette (signed off by xavier98)
[Octave] Prevent Octave from seg-faulting at exit when SWIG
modules are loaded, due to bugs in Octave's cleanup code:
* Wrapping functions now declared with Octave DEFUN_DLD macro,
and loaded through Octave's dynamic module loader
* Global variables of swigref type are now assigned a new()
copy of the swigref class, to prevent double-free errors
* SWIG module at-exit cleanup function now created in Octave
through eval(), so not dependent on loaded .oct library
* For Octave versions 3.1.* to 3.3.*, register C-level at-exit
function which terminates Octave immediately (with correct
status code) without performing memory cleanup. This function
can be controlled with macros in Lib/octave/octruntime.swg
[Octave] New syntax for determing whether SWIG module should be
loaded globally or non-globally. To load module "example" globally,
type the module name
$ example;
as before; to load module non-globally, assign it to a variable:
$ example = example;
$ ex = example;
for a shorter (local) module name. -global/-noglobal command-line
options and module command line are deprecated. Added usage info
to module, so typing
$ help example
or incorrect usage should display proper usage, with examples.
2012-05-12: olly
[PHP] Fix memory leak in code generated for a callback. Patch from
SF bug #3510806.
2012-05-12: olly
[PHP] Avoid using zend_error_noreturn() as it doesn't work with all
builds of PHP (SF bug #3166423). Instead we now wrap it in a
SWIG_FAIL() function which we annotate as "noreturn" for GCC to
avoids warnings. This also reduces the size of the compiled
wrapper (e.g. the stripped size is reduced by 6% for Xapian's PHP
2012-05-11: wsfulton
[Java] SF patch #3522855 Fix unintended uninitialised memory access in OUTPUT typemaps.
2012-05-11: wsfulton
[Java] SF patch #3522674 Fix possible uninitialised memory access in char **STRING_OUT
2012-05-11: wsfulton
[Java] SF patch #3522611 Fix uninitialised size regression in char **STRING_ARRAY
introduced in swig-2.0.6.
2012-05-11: wsfulton
SF bug #3525050 - Fix regression introduced in swig-2.0.5 whereby defining one typemap
method such as an 'out' typemap may hide another typemap method such as an 'in' typemap -
only occurs when the type is a template type where the template parameters are the same
via a typedef.
2012-05-10: olly
[PHP] Fix the constant typemaps for SWIGTYPE, etc - previously
these used the wrong name for renamed constants. Add
autodoc_runme.php to the testsuite as a regression test for this.
2012-05-02: ianlancetaylor
[Go] Remove compatibility support for gccgo 4.6. Using
SWIG with gccgo will now require gccgo 4.7. Using SWIG
with the more commonly used gc compiler is unaffected.
2012-05-01: wsfulton
Fix generated code for C forward enum declarations in some languages.
Version 2.0.6 (30 April 2012)
2012-04-25: wsfulton
[Lua] Fix uninitialised variable in SWIGTYPE **OUTPUT typemaps as reported by Jim Anderson.
2012-04-28: wsfulton
[Python] Fix compilation errors when wrapping STL containers on Mac OS X and possibly other systems.
2012-04-28: wsfulton
[Java] Patch 3521811 from Leo Davis - char **STRING_ARRAY typemaps fixed to handle
null pointers.
Version 2.0.5 (19 April 2012)
2012-04-14: wsfulton
[Lua] Apply patch #3517435 from Miles Bader - prefer to use Lua_pushglobaltable
2012-04-14: wsfulton
[Ruby] Apply patch #3517769 from Robin Stocker to fix compile error on MacRuby using RSTRING_PTR.
2012-04-13: wsfulton
Apply patch #3511009 from Leif Middelschulte for slightly optimised char * variable wrappers.
2012-04-13: wsfulton
[Lua] Apply #3219676 from Shane Liesegang which adds:
- support for %factory
- a __tostring method
- a __disown method
2012-04-13: wsfulton
[Xml] Apply #3513569 which adds a catchlist to the xml output.
2012-04-05: olly
[Lua] Add support for Lua 5.2 (patch SF#3514593 from Miles Bader)
2012-03-26: xavier98
[octave] Apply patch #3425993 from jgillis: add extra logic to the octave_swig_type::dims(void) method: it checks if the user has defined a __dims__ method and uses this in stead of returning (1,1)
[octave] Apply patch #3424833 from jgillis: make is_object return true for swig types
2012-03-24: wsfulton
[D] Apply #3502431 to fix duplicate symbols in multiple modules.
2012-03-21: wsfulton
Fix #3494791 - %$isglobal for %rename matching.
2012-03-20: wsfulton
Fix #3487706 and #3391906 - missing stddef.h include for ptrdiff_t when using %import
for STL containers and compiling with g++-4.6. An include of stddef.h is now only
generated when SWIG generates STL helper templates which require ptrdiff_t. If you
were previously relying on "#include <stddef.h>" always being generated when using a
%include of an STL header, you may now need to add this in manually.
2012-03-16: wsfulton
Apply patch #3392264 from Sebastien Bine to parse (unsigned) long long types in enum value assignment.
2012-03-16: wsfulton
Apply patch #3505530 from Karl Wette to allow custom allocators in STL string classes for the UTL languages.
2012-03-13: wsfulton
Apply patch #3468362 from Karl Wette to fix %include inside %define.
2012-03-13: wsfulton
[Python, Ruby, Octave, R] Fix #3475492 - iterating through std::vector wrappers of enumerations.
2012-02-27: xavier98 (patches from Karl Wette)
[Octave] Use -globals . to load global variables in module namespace
[Octave] Comment declaration of unimplemented function swig_register_director
[Octave] Fix OCTAVE_PATH in octave Makefiles
[Octave] Add support for std::list - fix li_std_containers_int test
[Octave] Fix imports test
2012-02-16: wsfulton
[Java] Make generated support functions in arrays_java.i static so that generated code
from multiple instances of SWIG can be compiled and linked together - problem reported by
Evan Krause.
2012-01-24: wsfulton
Fix crash with bad regex - bug #3474250.
2012-01-24: wsfulton
[Python] Add Python stepped slicing support to the STL wrappers (std::vector, std::list).
Assigning to a slice, reading a slice and deleting a slice with steps now work.
For example:
%template(vector_i) std::vector<int>
vi = vector_i(range(10))
print list(vi)
vi[1:4:2] = [111, 333]
print list(vi)
del vi[3:10:3]
print list(vi)
print list(vi[::-1])
gives (same behaviour as native Python sequences such as list):
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[0, 111, 2, 333, 4, 5, 6, 7, 8, 9]
[0, 111, 2, 4, 5, 7, 8]
[8, 7, 5, 4, 2, 111, 0]
2012-01-23: klickverbot
[D] Correctly annotate function pointers with C linkage.
[D] Exception and Error have become blessed names; removed d_exception_name test case.
2012-01-20: wsfulton
[Python] Fix some indexing bugs in Python STL wrappers when the index is negative, eg:
%template(vector_i) std::vector<int>
now returns [0, 1, 2, 3, 4, 5] instead of [5].
vv[7:9] = [22,33]
now returns [0, 1, 2, 3, 4, 5, 22, 33] instead of "index out range" error.
Also fix some segfaults when replacing ranges, eg when il is a std::list wrapper:
il[0:2] = [11]
2012-01-17: wsfulton
[Go] Fix forward class declaration within a class when used as a base.
2012-01-07: wsfulton
[C#] Add support for %nspace when using directors.
2012-01-06: wsfulton
[Java] Patch #3452560 from Brant Kyser - add support for %nspace when using directors.
2011-12-21: wsfulton
The 'directorin' typemap now accepts $1, $2 etc expansions instead of having to use workarounds -
$1_name, $2_name etc.
2011-12-20: wsfulton
[Java] Add (char *STRING, size_t LENGTH) director typemaps.
2011-12-20: wsfulton
[C#, Go, Java, D] Add support for the 'directorargout' typemap.
2011-12-20: wsfulton
[Ocaml, Octave, PHP, Python, Ruby] Correct special variables in 'directorargout' typemap.
This change will break any 'directorargout' typemaps you may have written. Please change:
$result to $1
$input to $result
Also fix the named 'directorargout' DIRECTOROUT typemaps for these languages which didn't
previously compile and add in $1, $2 etc expansion.
2011-12-10: talby
[perl5] SWIG_error() now gets decorated with perl source file/line number.
[perl5] error handling now conforms to public XS api (fixes perl v5.14 issue).
2011-12-10: wsfulton
[Android/Java] Fix directors to compile on Android.
Added documentation and examples for Android.
2011-12-08: vadz
Bug fix: Handle methods renamed or ignored in the base class correctly in the derived classes
(they could be sometimes mysteriously not renamed or ignored there before).
2011-12-03: klickverbot
[D] Fix exception glue code for newer DMD 2 versions.
[D] Do not default to 32 bit glue code for DMD anymore.
[D] Use stdc.config.c_long/c_ulong to represent C long types.
2011-12-01: szager
[python] Fixed bug 3447426: memory leak in vector.__getitem__.
2011-11-30: wsfulton
[R] Remove C++ comments from generated C code.
2011-11-27: olly
[Python] Fix some warnings when compiling generated wrappers with
certain GCC warning options (Debian bug #650246).
2011-11-28: wsfulton
Fix #3433541 %typemap(in, numinputs=0) with 10+ arguments.
2011-11-28: olly
[Perl] Fix warnings when compiling generated wrappers with certain
GCC warning options (Debian bug #436711).
2011-11-28: olly
[PHP] Update keyword list to include keywords added in PHP releases up to 5.3.
2011-11-25: wsfulton
[C#] Provide an easy way to override the default visibility for the proxy class pointer
constructors and getCPtr() method. The visibility is 'internal' by default and if multiple
SWIG modules are being used and compiled into different assemblies, then they need to be
'public' in order to use the constructor or getCPtr() method from a different assembly.
Use the following macros to change the visibilities in the proxy and type wrapper class:
[Java] Provide an easy way to override the default visibility for the proxy class pointer
constructors and getCPtr() method. The visibility is 'protected' by default and if multiple
SWIG modules are being used and compiled into different packages, then they need to be
'public' in order to use the constructor or getCPtr() method from a different package.
Use the following macros to change the visibilities in the proxy and type wrapper class:
The default for Java has changed from public to protected for the proxy classes. Use the
SWIG_JAVABODY_PROXY macro above to restore to the previous visibilities.
2011-11-22: szager
[python] Bug 3440044: #ifdef out SWIG_Python_NonDynamicSetAttr if -builtin
isn't being used, to avoid unnecessary binary incompatibilities between
python installations.
2011-11-17: wsfulton
Bug fix: Remove root directory from directory search list in Windows.
2011-11-13: wsfulton
[Ruby] Apply patch #3421876 from Robin Stocker to fix #3416818 - same class name in
different namespaces confusion when using multiple modules.
2011-11-11: wsfulton
Fix to work with non-compressed tarballs - problem reported by Adrian Blakely.
2011-11-03: wsfulton
Expand special variables in typemap warnings, eg:
%typemap(in, warning="1000:Test warning for 'in' typemap for $1_type $1_name") int "..."
2011-11-01: wsfulton
Fix named output typemaps not being used when the symbol uses a qualifier and contains
a number, eg:
%typemap(out) double ABC::m1 "..."
2011-10-24: talby
[perl5] SF bug #3423119 - overload dispatch stack corruption fix. Better, but more research
is needed on a stable path for tail calls in XS.
Also, fix for large long longs in 32 bit perl.
2011-10-13: xavier98
[octave] Allow Octave modules to be re-loaded after a "clear all".
2011-09-19: wsfulton
Fix regression introduced in swig-2.0.1 reported by Teemu Ikonone leading to uncompilable code
when using typedef and function pointer references, for example:
typedef int FN(const int &a, int b);
void *typedef_call1(FN *& precallback, FN * postcallback);
2011-09-14: wsfulton
[Lua] Patch #3408012 from Raman Gopalan - add support for embedded Lua (eLua)
including options for targeting Lua Tiny RAM (LTR).
2011-09-14: wsfulton
[C#] Add boost_intrusive_ptr.i library contribution from patch #3401571.
2011-09-13: wsfulton
Add warnings for badly named destructors, eg:
struct KStruct {
~NOT_KStruct() {}
cpp_extend_destructors.i:92: Warning 521: Illegal destructor name ~NOT_KStruct. Ignored.
2011-09-13: wsfulton
Fix %extend and destructors for templates. The destructor in %extend was not always wrapped,
for example:
%extend FooT {
~FooT() { delete $self; } // was not wrapped as expected
template<class T> class FooT {};
%template(FooTi) FooT<int>;
2011-09-13: wsfulton
Fix special variables such as "$decl" and "$fulldecl" in destructors to include the ~ character.
2011-09-10: talby
[perl5] SF bug #1481958 - Improve range checking for integer types.
2011-09-08: wsfulton
Fix %extend on typedef classes in a namespace using the typedef name, for example:
namespace Space {
%extend CStruct {
typedef struct tagCStruct { ... } CStruct;
2011-08-31: xavier98
[octave] patches from Karl Wette: improvements to module loading behavior;
added example of friend operator to operator example; fixed octave panic/crash in 3.0.5;
documentation improvements
2011-08-30: szager
[python] Bug 3400486, fix error signalling for built-in constructors.
2011-08-26: wsfulton
[Go] Fix file/line number display for "gotype" when using typemap debugging options
-tmsearch and -tmused.
2011-08-26: wsfulton
[C#, D] Fix %callback which was generating uncompilable code.
2011-08-25: wsfulton
Fix constructors in named typedef class declarations as reported by Gregory Bronner:
typedef struct A {
A(){} // Constructor which was not accepted by SWIG
B(){} // NOT a constructor --illegal, but was accepted by SWIG
} B;
For C code, the fix now results in the use of 'struct A *' instead of just 'B *' in
the generated code when wrapping members in A, but ultimately this does not matter, as
they are the same thing.
2011-08-23: wsfulton
Fix %newobject when used in conjunction with %feature("ref") as reported by Jan Becker. The
code from the "ref" feature was not always being generated for the function specified by %newobject.
Documentation for "ref" and "unref" moved from Python to the C++ chapter.
2011-08-22: szager
[python] Fixed memory leak with --builtin option (bug 3385089).
2011-08-22: wsfulton
[Lua] SF patch #3394339 from Torsten Landschoff - new option -nomoduleglobal to disable installing
the module table into the global namespace. Require call also returns the module table instead
of a string.
2011-08-09: xavier98
Fix bug 3387394; Octave patches for 3.4.0 compatibility, etc. (from Karl Wette)
2011-08-04: wsfulton
Add in $symname expansion for director methods.
2011-07-29: olly
[PHP] Don't generate "return $r;" in cases where $r hasn't been set.
This was basically harmless, except it generated a PHP E_NOTICE if
the calling code had enabled them.
2011-07-26: wsfulton
Fix scoping of forward class declarations nested within a class (for C++). Previously the symbol
was incorrectly put into the outer namespace, eg
namespace std {
template<class Key, class T> struct map {
class iterator;
iterator was scoped as std::iterator, but now it is correctly std::map<Key, T>::iterator;
Also fixed is %template and template parameters that are a typedef when the template contains
default template parameters, eg:
namespace Std {
template<class Key, class T, class C = int> struct Map {
typedef Key key_type;
typedef T mapped_type;
typedef double DOUBLE;
%template(MM) Std::Map<int, DOUBLE>;
All symbols within Map will be resolved correctly, eg key_type and mapped_type no matter if the
wrapped code uses Std::Map<int, double> or std::Map<int, DOUBLE> or Std::Map<int, double, int>
Also fixes bug #3378145 - regression introduced in 2.0.4 - %template using traits.
2011-07-20 szager
[python] Fix closure for tp_call slot.
2011-07-16: wsfulton
[python] Fix director typemap using PyObject *.
2011-07-13: szager
[python] SF patch #3365908 - Add all template parameters to map support code in std_map.i
2011-07-13: szager
[python] Fix for bug 3324753: %rename member variables with -builtin.
2011-07-01: wsfulton
Fix some scope and symbol lookup problems when template default parameters are being
used with typedef. For example:
template<typename XX, typename TT = SomeType> struct Foo {
typedef XX X;
typedef TT T;
template<typename TT> struct UsesFoo {
void x(typename Foo<TT>::T, typename Foo<TT>::X);
Also fixes use of std::vector<int>::size_type for Python as reported by Aubrey Barnard.
2011-06-23: olly
[PHP] Fix director code to work when PHP is built with ZTS enabled,
which is the standard configuration on Microsoft Windows.
2011-06-21: mutandiz
- various small tweaks and bug fixes.
- Avoid name conflicts between smart pointer wrappers and the wrappers for
the actual class.
- Fix default typemaps for C bindings, which were incorrectly attempting to
call non-existent destructors on user-defined types.
- New feature, feature:aclmixins, for adding superclass to the foreign class
- Improve longlong typemaps.
2011-06-19: wsfulton
Fix incorrect typemaps being used for a symbol within a templated type, eg:
A<int>::value_type would incorrectly use a typemap for type A.
2011-06-18: olly
[Tcl] Fix variable declarations in middle of blocks which isn't
permitted in C90 (issue probably introduced in 2.0.3 by patch #3224663).
Reported by Paul Obermeier in SF#3288586.
2011-06-17: wsfulton
[Java] SF #3312505 - slightly easier to wrap char[] or char[ANY] with a Java byte[]
using arrays_java.i.
2011-06-13: wsfulton
[Ruby, Octave] SF #3310528 Autodoc fixes similar to those described below for Python.
2011-06-10: wsfulton
[Python] Few subtle bugfixes in autodoc documentation generation,
- Unnamed argument names fix for autodoc levels > 0.
- Display of template types fixed for autodoc levels > 1.
- Fix SF #3310528 - display of typedef structs for autodoc levels > 1.
- Add missing type for self for autodoc levels 1 and 3.
- autodoc levels 2 and 3 documented.
- Minor tweaks to autodoc style to conform with PEP8.
2011-05-30: olly
[PHP] Fix handling of directors when -prefix is used.
2011-05-24: olly
[PHP] Fix handling of methods of classes with a virtual base class (SF#3124665).
Version 2.0.4 (21 May 2011)
2011-05-19: wsfulton
[Guile] Patch #3191625 fixing overloading of integer types.
2011-05-19: wsfulton
[Perl] Patch #3260265 fixing overloading of non-primitive types and integers in
Perl 5.12 and later.
2011-05-19: wsfulton
[Ruby] Fix %import where one of the imported files %include one of the STL include
files such as std_vector.i.
2011-05-17: wsfulton
[Java] Apply #3289851 from Alan Harder to fix memory leak in directors when checking
for pending exceptions.
2011-05-17: wsfulton
[Tcl] Apply #3300072 from Christian Delbaere to fix multiple module loading not
always sharing variables across modules.
2011-05-16: xavier98
[octave] Fix an incompatibility with never versions of Octave. Case on Octave
API >= 40 to handle rename of Octave_map to octave_map.
[octave] Add support for y.__rop__(x) operators when x.__op__(y) doesn't exist.
[octave] Allow global operators to be defined by SWIG-wrapped functions.
[octave] Fix several bugs around module namespaces; add -global, -noglobal,
-globals <name> command line options to the module.
2011-05-14: wsfulton
%varargs when used with a numeric argument used to create an additional argument
which was intended to provide a guaranteed sentinel value. This never worked and now
the additional argument is not generated.
2011-05-13: wsfulton
[python] Additional fixes for python3.2 support.
2011-05-07: szager
[python] Fixed PyGetSetDescr for python3.2.
2011-05-05: wsfulton
[Lua, Python, Tcl] C/C++ prototypes shown in error message when calling an overloaded
method with incorrect arguments improved to show always show fully qualified name
and if a const method.
Also fixed other Lua error messages in generated code which weren't consistently
using the fully qualified C++ name - requested by Gedalia Pasternak.
2011-04-29: szager
Bug 2635919: Convenience method to convert std::map to a python dict.
2011-04-29: szager
[Python] Fixed bug 2811549: return non-const iterators from STL
methods begin(), end(), rbegin(), rend().
2011-04-25: szager
[Python] Fixed bug 1498929: Access to member fields in map elements
2011-04-23: klickverbot
[D] nspace: Correctly generate identifiers for base classes when
not in split proxy mode.
2011-04-13: szager
Fixed bug 3286333: infinite recursion with mutual 'using namespace' clauses.
2011-04-12: szager
Fixed bug 1163440: vararg typemaps.
2011-04-12: szager
Fixed bug #3285386: parse error from 'operator T*&()'. Added operator_pointer_ref
test case to demonstrate.
2011-04-11: szager
[Python] Fixed PyVarObject_HEAD_INIT to eliminate VC++ compiler errors about
static initialization of struct members with pointers.
2011-04-11: wsfulton
[Tcl] Apply patch #3284326 from Colin McDonald to fix some compiler warnings.
2011-04-11: szager
[Python] Fixed PyVarObject_HEAD_INIT to eliminate VC++ compiler errors about
static initialization of struct members with pointers.
2011-04-10: klickverbot
[D] Fixed wrapping of enums that are type char, for example:
enum { X = 'X'; } (this was already in 2.0.3 for C# and Java)
2011-04-10: klickverbot
[D] nspace: Fixed referencing types in the root namespace when
not in split proxy mode.
2011-04-09: szager
[Python] Applied patch #1932484: migrate PyCObject to PyCapsule.
2011-04-09: szager
[Python] Added preprocessor guards for python functions PyUnicode_AsWideChar and
PySlice_GetIndices, which changed signatures in python3.2.
2011-04-07: wsfulton
Fix wrapping of const array typedefs which were generating uncompilable code as
reported by Karl Wette.
2011-04-03: szager
[Python] Fixed the behavior of %pythonnondynamic to conform to the spec in Lib/pyuserdir.swg.
2011-04-03: szager
[Python] Merged in the szager-python-builtin branch, adding the -builtin feature
for python. The -builtin option may provide a significant performance gain
in python wrappers. For full details and limitations, refer to Doc/Manual/Python.html.
A small test suite designed to demonstrate the performance gain is in
2011-04-01: wsfulton
Add in missing wrappers for friend functions for some target languages, mostly
the non-scripting languages like Java and C#.
Version 2.0.3 (29 March 2011)
2011-03-29: wsfulton
[R] Apply patch #3239076 from Marie White fixing strings for R >= 2.7.0
2011-03-29: wsfulton
[Tcl] Apply patch #3248280 from Christian Delbaere which adds better error messages when
the incorrect number or type of arguments are passed to overloaded methods.
2011-03-29: wsfulton
[Tcl] Apply patch #3224663 from Christian Delbaere.
1. Fix when function returns a NULL value, a "NULL" command will be created in the Tcl interpreter
and calling this command will cause a segmentation fault.
2. Previous implementation searches for class methods using a linear search causing performance issues
in wrappers for classes with many member functions. The patch adds a method hash table to classes and
changes method name lookup to use the hash table instead of doing a linear search.
2011-03-26: wsfulton
[C#, Java] SF bug #3195112 - fix wrapping of enums that are type char, for example:
enum { X = 'X'; }
2011-03-21: vadz
Allow setting PCRE_CFLAGS and PCRE_LIBS during configuration to override the values returned by
pcre-config, e.g. to allow using a static version of PCRE library.
2011-03-17: wsfulton
[UTL] Add missing headers in generated STL wrappers to fix compilation with gcc-4.6.
2011-03-17: wsfulton
Fix regression introduced in swig-2.0.2 where filenames with spaces were not found
when used with %include and %import. Reported by Shane Liesegang.
2011-03-15: wsfulton
[UTL] Fix overloading when using const char[], problem reported by David Maxwell.
Similarly for char[ANY] and const char[ANY].
2011-03-15: wsfulton
[C#] Apply patch #3212624 fixing std::map Keys property.
2011-03-14: olly
[PHP] Fix handling of overloaded methods/functions where some
return void and others don't - whether this worked or not depended
on the order they were encountered in (SF#3208299).
2011-03-13: klickverbot
[D] Extended support for C++ namespaces (nspace feature).
2011-03-12: olly
[PHP] Fix sharing of type information between multiple SWIG-wrapped
modules (SF#3202463).
2011-03-09: wsfulton
[Python] Fix SF #3194294 - corner case bug when 'NULL' is used as the default value
for a primitive type parameter in a method declaration.
2011-03-07: olly
[PHP] Don't use zend_error_noreturn() for cases where the function
returns void - now this issue can only matter if you have a function
or method which is directed and returns non-void.
2011-03-06: olly
[PHP] Add casts to the typemaps for long long and unsigned long
long to avoid issues when they are used with shorter types via
2011-03-02: wsfulton
Templated smart pointers overloaded with both const and non const operator-> generated uncompilable
code when the pointee was a class with either public member variables or static methods.
Regression in 2.0.x reported as working in 1.3.40 by xantares on swig-user mailing list.
Version 2.0.2 (20 February 2011)
2011-02-19: wsfulton
[PHP] Add missing INPUT, OUTPUT and INOUT typemaps in the typemaps.i library
for primitive reference types as well as signed char * and bool *.
2011-02-19: olly
[PHP] Address bug in PHP on some platforms/architectures which
results in zend_error_noreturn() not being available using
SWIG_ZEND_ERROR_NORETURN which defaults to zend_error_noreturn but
can be overridden when building the module by passing
-DSWIG_ZEND_ERROR_NORETURN=zend_error to the compiler. This may
result in compiler warnings, but should at least allow a module
to be built on those platforms/architectures (SF#3166423).
2011-02-18: wsfulton
Fix #3184549 - vararg functions and function overloading when using the -fastdispatch option.
2011-02-18: olly
[PHP] An overloaded method which can return an object or a
primitive type no longer causes SWIG to segfault. Reported by Paul
Colby in SF#3168531.
2011-02-18: olly
[PHP] Fix invalid erase during iteration of std::map in generated
director code. Reported by Cory Bennett in SF#3175820.
2011-02-17: wsfulton
Preprocessing now warns if extra tokens appear after #else and #end.
2011-02-16: wsfulton
Fix #1653092 Preprocessor does not error out when #elif is missing an expression.
This and other cases of missing preprocessor expressions now result in an error.
2011-02-14: wsfulton
[Ocaml] Apply patch #3151788 from Joel Reymont. Brings Ocaml support up to date
(ver 3.11 and 3.12), including std::string.
2011-02-13: wsfulton
[Ruby] Apply patch #3176274 from James Masters - typecheck typemap for time_t.
2011-02-13: wsfulton
Apply patch #3171793 from szager - protected director methods failing when -fvirtual is used.
2011-02-13: wsfulton
Fix #1927852 - #include directives don't preprocess the file passed to it. The fix is for
#include with -importall or -includeall, %include and %import, for example:
#define FILENAME "abc.h"
%include FILENAME
2011-02-12: wsfulton
Fix #1940536, overactive preprocessor which was expanding defined(...) outside of #if and #elif
preprocessor directives.
2011-02-05: wsfulton
[MzScheme] SF #2942899 Add user supplied documentation to help getting started with MzScheme.
Update chapter name to MzScheme/Racket accounting for the rename of MzScheme to Racket.
2011-02-05: wsfulton
[C#] SF #3085906 - Possible fix running test-suite on Mac OS X.
2011-02-05: wsfulton
SF #3173367 Better information during configure about Boost prerequisite for running
the test-suite.
2011-02-05: wsfulton
SF #3127633 Fix infinite loop in recursive typedef resolution.
2011-02-04: wsfulton
[R] SF #3168676 Fix %rename not working for member variables and methods.
2011-02-04: wsfulton
[clisp] SF #3148200 Fix segfault parsing nested unions.
2011-02-01: wsfulton
[C#] Directors - a call to a method being defined in the base class, not
overridden in a subclass, but again overridden in a class derived from
the first subclass was not being dispatched correctly to the most derived class.
See director_alternating.i for an example.
2011-02-01: wsfulton
[C#, Java] Any 'using' statements in the protected section of a class were previously
ignored with director protected (dirprot) mode.
2011-01-30: wsfulton
Fix overloading with const pointer reference (SWIGTYPE *const&) parameters for a
number of scripting languages.
2011-01-17: wsfulton
New warning for smart pointers if only some of the classes in the inheritance
chain are marked as smart pointer, eg, %shared_ptr should be used for all classes
in an inheritance hierarchy, so this new warning highlights code where this is
not the case.
example.i:12: Warning 520: Base class 'A' of 'B' is not similarly marked as a smart pointer.
example.i:16: Warning 520: Derived class 'C' of 'B' is not similarly marked as a smart pointer.
2011-01-14: wsfulton
Added some missing multi-argument typemaps: (char *STRING, size_t LENGTH) and
(char *STRING, int LENGTH). Documentation for this updated. Java patch from
Volker Grabsch.
2011-01-11: iant
Require Go version 7077 or later.
2010-12-30: klickverbot
[C#, D, Java] Check for collision of parameter names with target
language keywords when generating the director glue code.
The situation in which the generated could would previously be
invalid is illustrated in the new 'director_keywords' test case.
2010-12-23: wsfulton
[C#] Fix $csinput special variable not being expanded for csvarin typemaps
when used for global variables. Reported by Vadim Zeitlin.
2010-12-14: wsfulton
Fix $basemangle expansion in array typemaps. For example if type is int *[3],
$basemangle expands to _p_int.
2010-12-07: iant
Check that we are using a sufficiently new version of the
6g or 8g Go compiler during configure time. If not, disable Go.
Minimum version is now 6707.
2010-12-06: wsfulton
Fix #3127394 - use of network paths on Windows/MSys.
2010-11-18: klickverbot
[D] Added the D language module.
2010-11-12: vadz
Fix handling of multiple regex-using %renames attached to the same
declaration. For example, now
%rename("%(regex:/^Set(.*)/put\\1/)s") "";
%rename("%(regex:/^Get(.*)/get\\1/)s") "";
works as expected whereas before only the last anonymous rename was
taken into account.
2010-10-17: drjoe
[R] Fix failure in overloaded functions which was breaking
2010-10-14: olly
[PHP] Allow compilation on non-conforming Microsoft C++ compilers
which don't accept: return function_returning_void();
Reported by Frank Vanden Berghen on the SWIG mailing list.
2010-10-12: wsfulton
Fix unary scope operator (::) (global scope) regression introduced in 2.0.0, reported by
Ben Walker. The mangled symbol names were incorrect, sometimes resulting in types being
incorrectly treated as opaque types.
Also fixes #2958781 and some other type problems due to better typedef resolution, eg
std::vector<T *>::value_type didn't resolve to T * when it should have. The mangled type
was incorrectly SWIGTYPE_std__vectorT_Test_p_std__allocatorT_Test_p_t_t__value_type and now
it is correctly SWIGTYPE_p_Test.
Version 2.0.1 (4 October 2010)
2010-10-03: wsfulton
Apply patch #3066958 from Mikael Johansson to fix default smart pointer
handling when the smart pointer contains both a const and non-const operator->.
2010-10-01: wsfulton
Add -pcreversion option to display PCRE version information.
2010-10-01: olly
[Ruby] Avoid segfault when a method node has no parentNode
2010-10-01: olly
[Python] Allow reinitialisation to work with an embedded Python
interpreter (patch from Jim Carroll in SF#3075178).
2010-09-28: wsfulton
[C#] Apply patch from Tomas Dirvanauskas for std::map wrappers to avoid
throwing exceptions with normal usage of iterators.
2010-09-27: olly
[Python] Improve error message given when a parameter of the wrong
type is passed to an overloaded method (SF#3027355).
2010-09-25: wsfulton
Apply SF patch #3075150 - Java directors using static variables in
named namespace.
2010-09-24: wsfulton
More file and line error/warning reporting fixes where SWIG macros
are used within {} braces (where the preprocessor expands macros),
for example macros within %inline {...} and %fragment(...) {...}
and nested structs.
2010-09-18: wsfulton
More file and line error/warning reporting fixes for various inherited
class problems.
2010-09-15: wsfulton
A much improved debugging of SWIG source experience is now available and
documented in the "Debugging SWIG" section in the Doc/Devel/internals.html
file, including a swig.dbg support file for the gdb debugger.
2010-09-11: wsfulton
Fix incorrect line number reporting in errors/warnings when a macro
definition ends with '/' and it is not the end of a C comment.
2010-09-11: wsfulton
Fix incorrect line number reporting in errors/warnings after parsing
macro invocations with parameters given over more than one line.
2010-09-10: wsfulton
Remove extraneous extra line in preprocessed output after including files
which would sometimes lead to error/warning messages two lines after the
end of the file.
2010-09-10: wsfulton
Fix #2149523 - Incorrect line number reporting in errors after parsing macros
containing C++ comments.
2010-09-08: olly
[PHP] Fix handling of OUTPUT typemaps (Patch from Ryan in SF#3058394).
2010-09-03: wsfulton
Fix erroneous line numbers in error messages for macro expansions, for example,
the error message now points to instantiation of the macro, ie the last line here:
#define MACRO2(a, b)
#define MACRO1(NAME) MACRO2(NAME,2,3)
2010-09-02: wsfulton
Fix line numbers in error and warning messages for preprocessor messages within
%inline, for example:
%inline %{
#define FOOBAR 1
#define FOOBAR "hi"
2010-09-02: wsfulton
Fix line numbers in error and warning messages which were cumulatively one
less than they should have been after parsing each %include/%import - bug
introduced in swig-1.3.32. Also fix line numbers in error and warning messages
when new line characters appear between the %include / %import statement and
the filename.
2010-08-30: wsfulton
Fix line number and file name reporting for some macro preprocessor warnings.
The line number of the macro argument has been corrected and the line number
of the start of the macro instead of one past the end of the macro is used.
Some examples:
file.h:11: Error: Illegal macro argument name '..'
file.h:19: Error: Macro 'DUPLICATE' redefined,
file.h:15: Error: previous definition of 'DUPLICATE'.
file.h:25: Error: Variable-length macro argument must be last parameter
file.h:32: Error: Illegal character in macro argument name
file.i:37: Error: Macro 'SIT' expects 2 arguments
2010-08-26: wsfulton
Fix __LINE__ and __FILE__ expansion reported by Camille Gillot. Mostly this
did not work at all. Also fixes SF #2822822.
2010-08-17: wsfulton
[Perl] Fix corner case marshalling of doubles - errno was not being correctly
set before calling strtod - patch from Justin Vallon - SF Bug #3038936.
2010-08-17: wsfulton
Fix make distclean when some of the more obscure languages are detected by
configure - fixes from Torsten Landschoff.
2010-07-28: wsfulton
Restore configuring out of source for the test-suite since it broke in 1.3.37.
As previously, if running 'make check-test-suite' out of source, it needs to be
done by invoking configure with a relative path. Invoking configure with an
absolute path will not work. Running the full 'make check' still needs to be
done in the source tree.
2010-07-16: wsfulton
Fix wrapping of function pointers and member function pointers when the function
returns by reference.
2010-07-13: vadz
Removed support for the old experimental "rxspencer" encoder and
"[not]rxsmatch" in %rename (see the 01/16/2006 entry). The new and
officially supported "regex" encoder and "[not]regexmatch" checks
should be used instead (see the two previous entries). Please
replace "%(rxspencer:[pat][subst])s" with "%(regex:/pat/subst/)s"
when upgrading. Notice that you will also need to replace the back-
references of form "@1" with the more standard "\\1" and may need to
adjust your regular expressions syntax as the new regex encoder uses
Perl-compatible syntax and not (extended) POSIX syntax as the old one.
2010-07-13: vadz
Add "regexmatch", "regextarget" and "notregexmatch" which can be
used to apply %rename directives to the declarations matching the
specified regular expression only. The first two can be used
interchangeably, both of the %renames below do the same thing:
%rename("$ignore", regexmatch$name="Old$") "";
%rename("$ignore", regextarget=1) "Old$";
(namely ignore the declarations having "Old" suffix).
"notregexmatch" restricts the match to only the declarations which
do not match the regular expression, e.g. here is how to rename to
lower case versions all declarations except those consisting from
capital letters only:
%rename("$(lowercase)s", notregexmatch$name="^[A-Z]+$") "";
2010-07-13: vadz
Add the new "regex" encoder that can be used in %rename, e.g.
%rename("regex:/(\\w+)_(.*)/\\2/") "";
to remove any alphabetical prefix from all identifiers. The syntax
of the regular expressions is Perl-like and PCRE library
( is used to implement this feature but notice
that backslashes need to be escaped as usual inside C strings.
Original patch from Torsten Landschoff.
2010-07-08: wsfulton
Fix #3024875 - shared_ptr of classes with non-public destructors. This also fixes
the "unref" feature when used on classes with non-public destructors.
2010-06-17: ianlancetaylor
[Go] Add the Go language module.
2010-06-10: wsfulton
[Lua] Fix SWIG_lua_isnilstring multiply defined when using multiple
modules and wrapping strings. Patch from 'Number Cruncher'.
2010-06-10: olly
[PHP] Fix directors to correctly call a method with has a
different name in PHP to C++ (we were always using the C++ name
in this case).
2010-06-03: wsfulton
Fix uncompilable code when %rename results in two enum items
with the same name. Reported by Vadim Zeitlin.
Version 2.0.0 (2 June 2010)
2010-06-02: wsfulton
[C#] Fix SWIG_STD_VECTOR_ENHANCED macro used in std::vector to work with
types containing commas, for example:
SWIG_STD_VECTOR_ENHANCED(std::pair< double, std::string >)
2010-06-01: wsfulton
Add in std_shared_ptr.i for wrapping std::shared_ptr. Requires the %shared_ptr
macro like in the boost_shared_ptr.i library. std::tr1::shared_ptr can also be
wrapped if the following macro is defined:
%include <std_shared_ptr.i>
shared_ptr is also documented in Library.html now.
2010-05-27: wsfulton
Add the ability for $typemap special variable macros to call other $typemap
special variable macros, for example:
%typemap(cstype) CC "CC"
%typemap(cstype) BB "$typemap(cstype, CC)"
%typemap(cstype) AA "$typemap(cstype, BB)"
void hah(AA aa);
This also fixes C# std::vector containers of shared_ptr and %shared_ptr.
Also added diagnostics for $typemap with -debug-tmsearch, for example, the
above displays additional diagnostic lines starting "Containing: ":
example.i:34: Searching for a suitable 'cstype' typemap for: AA aa
Looking for: AA aa
Looking for: AA
Using: %typemap(cstype) AA
Containing: $typemap(cstype, BB)
example.i:31: Searching for a suitable 'cstype' typemap for: BB
Looking for: BB
Using: %typemap(cstype) BB
Containing: $typemap(cstype, CC)
example.i:29: Searching for a suitable 'cstype' typemap for: CC
Looking for: CC
Using: %typemap(cstype) CC
2010-05-26: olly
Fix %attribute2ref not to produce a syntax error if the last
argument (AccessorMethod) is omitted. Patch from David Piepgras
in SF#2235756.
2010-05-26: olly
[PHP] When using %throws or %catches, SWIG-generated PHP5 wrappers
now throw PHP Exception objects instead of giving a PHP error of
type E_ERROR.
This change shouldn't cause incompatibility issues, since you can't
set an error handler for E_ERROR, so previously PHP would just exit
which also happens for unhandled exceptions. The benefit is you can
now catch them if you want to.
Fixes SF#2545578 and SF#2955522.
2010-05-25: olly
[PHP] Add missing directorin typemap for const std::string &.
Fixes SF#3006404 reported by t-Legiaw.
2010-05-23: wsfulton
[C#] Fix #2957375 - SWIGStringHelper and SWIGExceptionHelper not always being
initialized before use in .NET 4 as the classes were not marked beforefieldinit.
A static constructor has been added to the intermediary class like this:
%pragma(csharp) imclasscode=%{
static $imclassname() {
If you had added your own custom static constructor to the intermediary class in
the same way as above, you will have to modify your approach to use static variable
initialization or define SWIG_CSHARP_NO_IMCLASS_STATIC_CONSTRUCTOR - See csharphead.swg.
2010-05-23: wsfulton
Fix #2408232. Improve shared_ptr and intrusive_ptr wrappers for classes in an
inheritance hierarchy. No special treatment is needed for derived classes.
The proxy class also no longer needs to be specified, it is automatically
deduced. The following macros are deprecated:
and have been replaced by
Similarly for intrusive_ptr wrappers, the following macro is deprecated:
and have been replaced by
2010-05-21: olly
[PHP] Stop generating a bogus line of code in certain constructors.
This was mostly harmless, but caused a PHP notice to be issued, if
enabled (SF#2985684).
2010-05-18: wsfulton
[Java] Fix member pointers on 64 bit platforms.
2010-05-14: wsfulton
Fix wrapping of C++ enum boolean values reported by Torsten Landschoff:
typedef enum { PLAY = true, STOP = false } play_state;
2010-05-14: olly
[PHP] Fix wrapping of global variables which was producing
uncompilable code in some cases.
2010-05-12: drjoe
[R] Add two more changes from Wil Nolan. Get garbage
collection to work. Implement newfree
2010-05-09: drjoe
Fix bug reported by Wil Nolan change creation of string so
that R 2.7.0+ can use char hashes
2010-05-07: wsfulton
Apply patch #2955146 from Sergey Satskiy to fix expressions containing divide by
operator in constructor initialization lists.
2010-05-05: wsfulton
[R] Memory leak fix handling const std::string & inputs, reported by Will Nolan.
2010-05-01: wsfulton
Typemap matching enhancement for non-default typemaps. Previously all
qualifiers were stripped in one step, now they are stripped one at a time
starting with the left most qualifier. For example, int const*const
is first stripped to int *const then int *.
2010-04-25: bhy
[Python] Fix #2985655 - broken constructor renaming.
2010-04-14: wsfulton
Typemap fragments are now official and documented in Typemaps.html.
2010-04-09: wsfulton
[Ruby] Fix #2048064 and #2408020.
Apply Ubuntu patch to fix Ruby and std::vector wrappers with -minherit.
2010-04-09: wsfulton
[Mzscheme] Apply Ubuntu patch to fix std::map wrappers:
2010-04-09: wsfulton
[Python] Apply patch #2952374 - fix directors and the -nortti option.
2010-04-09: wsfulton
[Lua] Fix #2887254 and #2946032 - SWIG_Lua_typename using wrong stack index.
2010-04-03: wsfulton
[Python] Fix exceptions being thrown with the -threads option based on patch from Arto Vuori.
Fixes bug #2818499.
2010-04-03: wsfulton
Fix Makefile targets: distclean and maintainer-clean
2010-04-02: wsfulton
[Lua] Fix char pointers, wchar_t pointers and char arrays so that nil can be passed as a
valid value. Bug reported by Gedalia Pasternak.
2010-04-01: wsfulton
Numerous subtle typemap matching rule fixes when using the default type. The typemap
matching rules are to take a type and find the best default typemap (SWIGTYPE, SWIGTYPE* etc),
then look for the next best match by reducing the chosen default type. The type deduction
now follows C++ class template partial specialization matching rules.
Below are the set of changes made showing the default type deduction
along with the old reduced type and the new version of the reduced type:
new: SWIGTYPE const &[]
old: SWIGTYPE (&)[ANY]
new: SWIGTYPE const [ANY]
SWIGTYPE const *const [ANY]
new: SWIGTYPE *const [ANY]
old: SWIGTYPE const *[ANY]
SWIGTYPE const *const &
new: SWIGTYPE *const &
old: SWIGTYPE const *&
SWIGTYPE *const *
new: SWIGTYPE const *
old: SWIGTYPE **
SWIGTYPE *const &
new: SWIGTYPE const &
old: SWIGTYPE *&
Additionally, a const SWIGTYPE lookup is used now for any constant type. Some examples, where
T is some reduced type, eg int, struct Foo:
T const
new: SWIGTYPE const
T *const
new: SWIGTYPE *const
T const[]
new: SWIGTYPE const[]
enum T const
new: enum SWIGTYPE const
old: enum SWIGTYPE
T (*const )[]
new: SWIGTYPE (*const )[]
old: SWIGTYPE (*)[]
Reminder: the typemap matching rules can now be seen for any types being wrapped by using
either the -debug-tmsearch or -debug-tmused options.
In practice this leads to some subtle matching rule changes and the majority of users
won't notice any changes, except in the prime area of motivation for this change: Improve
STL containers of const pointers and passing const pointers by reference. This is fixed
because many of the STL containers use a type 'T const&' as parameters and when T is
a const pointer, for example, 'K const*', then the full type is 'K const*const&'. This
means that the 'SWIGTYPE *const&' typemaps now match when T is either a non-const or
const pointer. Furthermore, some target languages incorrectly had 'SWIGTYPE *&' typemaps
when these should have been 'SWIGTYPE *const&'. These have been corrected (Java, C#, Lua, PHP).
2010-03-13: wsfulton
[Java] Some very old deprecated pragma warnings are now errors.
2010-03-13: wsfulton
Improve handling of file names and directories containing double/multiple path separators.
2010-03-10: mutandiz (Mikel Bancroft)
[allegrocl] Use fully qualified symbol name of cl::identity in emit_defun().
2010-03-06: wsfulton
[Java] The intermediary JNI class modifiers are now public by default meaning these
intermediary low level functions are now accessible by default from outside any package
used. The proxy class pointer constructor and getCPtr() methods are also now public.
These are needed in order for the nspace option to work without any other mods.
The previous default of protected access can be restored using:
%pragma(java) jniclassclassmodifiers = "class"
2010-03-06: wsfulton
[C#] Added the nspace feature for C#. Documentation for the nspace feature is now available.
2010-03-04: wsfulton
Added the nspace feature. This adds some improved namespace support. Currently only Java
is supported for target languages, where C++ namespaces are automatically translated into
Java packages. The feature only applies to classes,struct,unions and enums declared within
a namespace. Methods and variables declared in namespaces still effectively have their
namespaces flattened. Example usage:
%feature(nspace) Outer::Inner1::Color;
%feature(nspace) Outer::Inner2::Color;
namespace Outer {
namespace Inner1 {
struct Color {
namespace Inner2 {
struct Color {
For Java, the -package option is also required when using the nspace feature. Say
we use -package com.myco, the two classes can then be accessed as follows from Java:
com.myco.Outer.Inner1.Color and com.myco.Outer.Inner2.Color.
2010-02-27: wsfulton
[Python] Remove -dirvtable from the optimizations included by -O as it this option
currently leads to memory leaks as reported by Johan Blake.
2010-02-27: wsfulton
License code changes: SWIG Source is GPL-v3 and library code license is now clearer
and is provided under a very permissive license. See
2010-02-13: wsfulton
[Ruby] A few fixes for compiling under ruby-1.9.x including patch from 'Nibble'.
2010-02-13: wsfulton
[Ruby] Apply patch from Patrick Bennett to fix RARRAY_LEN and RARRAY_PTR usage for Ruby 1.9.x
used in various STL wrappers.
2010-02-13: wsfulton
[C#, Java] Fix incorrect multiply defined symbol name error when an enum item
and class name have the same name, as reported by Nathan Krieger. Example:
class Vector {};
namespace Text {
enum Preference { Vector };
This also fixes other incorrect corner case target language symbol name clashes.
2010-02-11: wsfulton
Add the -debug-lsymbols option for displaying the target language layer symbols.
2010-02-09: wsfulton
Fix -MM and -MMD options on Windows. They were not omitting files in the SWIG library as
they should be.
2010-02-08: wsfulton
Fix #1807329 - When Makefile dependencies are being generated using the -M family of options
on Windows, the file paths have been corrected to use single backslashes rather than double
backslashes as path separators.
2010-02-06: wsfulton
Fix #2918902 - language specific files not being generated in correct directory on
Windows when using forward slashes for -o, for example:
swig -python -c++ -o subdirectory/theinterface_wrap.cpp subdirectory/theinterface.i
2010-02-05: wsfulton
Fix #2894405 - assertion when using -xmlout.
2010-01-28: wsfulton
Fix typemap matching bug when a templated type has a typemap both specialized and not
specialized. For example:
template<typename T> struct XX { ... };
%typemap(in) const XX & "..."
%typemap(in) const XX< int > & "..."
resulted in the 2nd typemap being applied for all T in XX< T >.
2010-01-22: wsfulton
Fix #2933129 - typemaps not being found when the unary scope operator (::) is used to denote
global scope, the typemap is now used in situations like this:
struct X {};
%typemap(in) const X & "..."
void m(const ::X &);
and this:
struct X {};
%typemap(in) const ::X & "..."
void m(const X &);
2010-01-20: wsfulton
Fix some unary scope operator (::) denoting global scope problems in the types generated
into the C++ layer. Previously the unary scope operator was dropped in the generated code
if the type had any sort of qualifier, for example when using pointers, references, like
::foo*, ::foo&, bar< ::foo* >.
2010-01-13: olly
[PHP] Add datetime to the list of PHP predefined classes (patch
from David Fletcher in SF#2931042).
2010-01-11: wsfulton
Slight change to warning, error and diagnostic reporting. The warning number is no
longer shown within brackets. This is to help default parsing of warning messages by
other tools, vim on Unix in particular.
Example original display using -Fstandard:
example.i:20: Warning(401): Nothing known about base class 'B'. Ignored.
New display:
example.i:20: Warning 401: Nothing known about base class 'B'. Ignored.
Also subtle fix to -Fmicrosoft format adding in missing space. Example original display:
example.i(20): Warning(401): Nothing known about base class 'Base'. Ignored.
New display:
example.i(20) : Warning 401: Nothing known about base class 'Base'. Ignored.
2010-01-10: wsfulton
Fix a few inconsistencies in reporting of file/line numberings including modifying
the overload warnings 509, 512, 516, 474, 475 to now be two line warnings.
2010-01-10: wsfulton
Modify -debug-tags output to use standard file name/line reporting so that editors
can easily navigate to the appropriate lines.
Was typically:
. top . include . include (/usr/share/swig/temp/trunk/Lib/swig.swg:312)
. top . include . include . include (/usr/share/swig/temp/trunk/Lib/swigwarnings.swg:39)
/usr/share/swig/temp/trunk/Lib/swig.swg:312: . top . include . include
/usr/share/swig/temp/trunk/Lib/swigwarnings.swg:39: . top . include . include . include
2010-01-03: wsfulton
Fix missing file/line numbers for typemap warnings and in output from the
-debug-tmsearch/-debug-tmused options.
2010-01-03: wsfulton
Add typemaps used debugging option (-debug-tmused). When used each line displays
the typemap used for each type for which code is being generated including the file
and line number related to the type. This is effectively a condensed form of the
-debug-tmsearch option. Documented in Typemaps.html.
2009-12-23: wsfulton
Fix for %javaexception and directors so that all the appropriate throws clauses
are generated. Problem reported by Peter Greenwood.
2009-12-20: wsfulton
Add -debug-tmsearch option for debugging the typemap pattern matching rules.
Documented in Typemaps.html.
2009-12-12: wsfulton
[Octave] Remove the -api option and use the new OCTAVE_API_VERSION_NUMBER
macro provided in the octave headers for determining the api version instead.
2009-12-04: olly
[Ruby] Improve support for Ruby 1.9 under GCC. Addresses part of
2009-12-04: olly
Fix handling of modulo operator (%) in constant expressions
2009-12-04: olly
[PHP] "empty" is a reserved word in PHP, so rename empty() method
on STL classes to "is_empty()" (previously this was automatically
renamed to "c_empty()").
2009-12-03: olly
[PHP] Add typemaps for long long and unsigned long long, and for
pointer to method.
2009-12-02: olly
[PHP] Fix warning and rename of reserved class name to be case
2009-12-01: wsfulton
Revert support for %extend and memberin typemaps added in swig-1.3.39. The
memberin typemaps are ignored again for member variables within a %extend block.
Documentation inconsistency reported by Torsten Landschoff.
2009-11-29: wsfulton
[Java, C#] Fix generated quoting when using %javaconst(1)/%csconst(1) for
static const char member variables.
%javaconst(1) A;
%csconst(1) A;
struct X {
static const char A = 'A';
2009-11-26: wsfulton
[Java, C#] Fix %javaconst(1)/%csconst(1) for static const member variables to
use the actual constant value if it is specified, rather than the C++ code to
access the member.
%javaconst(1) EN;
%csconst(1) EN;
struct X {
static const int EN = 2;
2009-11-23: wsfulton
C++ nested typedef classes can now be handled too, for example:
struct Outer {
typedef Foo { } FooTypedef1, FooTypedef2;
2009-11-18: wsfulton
The wrappers for C nested structs are now generated in the same order as declared
in the parsed code.
2009-11-18: wsfulton
Fix #491476 - multiple declarations of nested structs, for example:
struct Outer {
struct {
int val;
} inner1, inner2, *inner3, inner4[1];
} outer;
2009-11-17: wsfulton
Fix parsing of enum declaration and initialization, for example:
enum ABC {
} A = a, *pC = &C, array[3] = {a, b, c};
2009-11-17: wsfulton
Fix parsing of struct declaration and initialization, for example:
struct S {
int x;
} instance = { 10 };
2009-11-15: wsfulton
Fix #1960977 - Syntax error parsing derived nested class declaration and member
variable instance.
2009-11-14: wsfulton
Fix #2310483 - function pointer typedef within extern "C" block.
2009-11-13: wsfulton
Fix usage of nested template classes within templated classes so that compilable code
is generated.