blob: d9426512b281b132435c9b2a15a2d8c9bc9f79fc [file] [log] [blame]
SWIG (Simplified Wrapper and Interface Generator)
See CHANGES.current for current version.
Version 1.3.39 (21 March 2009)
2009-03-19: bhy
[Python] Fix the memory leak related to Python 3 unicode and C char* conversion,
which can be shown in the following example before this fix:
from li_cstring import *
while True:
i += 1
n = str(i)*10
This fix affected SWIG_AsCharPtrAndSize() so you cannot call this function with
a null alloc and non-null cptr argument in Python 3, otherwise a runtime error
will be raised.
2009-03-18: wsfulton
[C#] std::vector<T> wrapper improvements for .NET 2 and also providing the
necessary machinery to use the std::vector<T> wrappers with more advanced features such
as LINQ - the C# proxy class now derives from IEnumerable<>. The default is now to
generate code requiring .NET 2 as a minimum, although the C# code can be compiled
for .NET 1 by defining the SWIG_DOTNET_1 C# preprocessor constant. See the
std_vector.i file for more details.
2009-03-12: wsfulton
[Ruby] Fix #2676738 SWIG generated symbol name clashes.
2009-03-01: bhy
[Python] Some fixes for Python 3.0.1 and higher support. In 3.0.1, the C API function
PyObject_Compare is removed, so PyObject_RichCompareBool is used for replacement.
Struct initilization of SwigPyObject and SwigPyObject_as_number changed to reflect
the drop of tp_compare and nb_long.
2009-03-01: bhy
[Python] Fix SF#2583160. Now the importer in Python shadow wrapper take care of the
case that module already imported at other place.
2009-02-28: bhy
[Python] Fix SF#2637352. Move struct declaration of SWIG_module in pyinit.swg before
the method calls, since some C compiler don't allow declaration in middle of function
2009-02-21: wsfulton
[Allegrocl] Fix seg fault wrapping some constant variable (%constant) types.
2009-02-20: wsfulton
[CFFI] Fix seg faults when for %extend and using statements.
2009-02-20: wsfulton
Fix SF #2605955: -co option which broke in 1.3.37.
2009-02-20: wsfulton
New %insert("begin") section added. Also can be used as %begin. This is a new
code section reserved entirely for users and the code within the section is generated
at the top of the C/C++ wrapper file and so provides a means to put custom code
into the wrapper file before anything else that SWIG generates.
2009-02-17: wsfulton
'make clean-test-suite' will now run clean on ALL languages. Previously it only
ran the correctly configured languages. This way it is now possible to clean up
properly after running 'make partialcheck-test-suite'.
2009-02-14: wsfulton
Extend attribute library support for structs/classes and the accessor functions use
pass/return by value semantics. Two new macros are available and usage is identical
to %attribute. These are %attributeval for structs/classes and %attributestring for
string classes, like std::string. See attribute.swg for more details.
2009-02-13: wsfulton
Add support for %extend and memberin typemaps. Previously the memberin typemaps were
ignored for member variables within a %extend block.
2009-02-12: wsfulton
Remove unnecessary temporary variable when wrapping return values that are references.
Example of generated code for wrapping:
struct XYZ {
std::string& refReturn();
used to be:
std::string *result = 0 ;
std::string &_result_ref = (arg1)->refReturn();
result = (std::string *) &_result_ref;
Now it is:
std::string *result = 0 ;
result = (std::string *) &(arg1)->refReturn();
2009-02-08: bhy
Change the SIZE mapped by %pybuffer_mutable_binary and %pybuffer_binary in pybuffer.i from
the length of the buffer to the number of items in the buffer.
2009-02-08: wsfulton
Fix %feature not working for conversion operators, reported by Matt Sprague, for example:
%feature("cs:methodmodifiers") operator bool "protected";
2009-02-07: wsfulton
[MzScheme] Apply #2081967 configure changes for examples to build with recent PLT versions.
Also fixes Makefile errors building SWIG executable when mzscheme package is installed
(version 3.72 approx and later).
2009-02-04: talby
[Perl] Fix SF#2564192 reported by David Kolovratnk.
SWIG_AsCharPtrAndSize() now handles "get" magic.
Version 1.3.38 (31 January 2009)
2009-01-31: bhy
[Python] Fix SF#2552488 reported by Gaetan Lehmann. Now %pythonprepend
and %pythonappend have correct indentation.
2009-01-31: bhy
[Python] Fix SF#2552048 reported by Gaetan Lehmann. The parameter list
of static member function in generated proxy code should not have the
'self' parameter.
2009-01-29: wsfulton
Fix regression introduced in 1.3.37 where the default output directory
for target language specific files (in the absence of -outdir) was no
longer the same directory as the generated c/c++ file.
2009-01-28: wsfulton
[Java, C#] Fix proxy class not being used when the global scope operator
was used for parameters passed by value. Reported by David Piepgrass.
2009-01-15: wsfulton
[Perl] Fix seg fault when running with -v option, reported by John Ky.
Version 1.3.37 (13 January 2009)
2009-01-13: mgossage
[Lua] Added contract support for requiring that unsigned numbers are >=0
Rewrote much of Examples/Lua/embed3.
Added a lot to the Lua documentation.
2009-01-13: wsfulton
Fix compilation error when using directors on protected virtual overloaded
methods reported by Sam Hendley.
2009-01-12: drjoe
[R] Fixed handling of integer arrays
2009-01-10: drjoe
[R] Fix integer handling in r to deal correctly with signed
and unsigned issues
2009-01-10: wsfulton
Patch #1992756 from Colin McDonald - %contract not working for classes
in namespace
2009-01-05: olly
Mark SWIGPERL5, SWIGPHP5, and SWIGTCL8 as deprecated in the source
code and remove documentation of them.
2008-12-30: wsfulton
Bug #2430756. All the languages now define a macro in the generated C/C++
wrapper file indicating which language is being wrapped. The macro name is the
same as those defined when SWIG is run, eg SWIGJAVA, SWIGOCTAVE, SWIGCSHARP etc
and are listed in the "Conditional Compilation" section in the documentation.
2008-12-23: wsfulton
[Java] Fix #2153773 - %nojavaexception was clearing the exception feature
instead of disabling it. Clearing checked Java exceptions also didn't work.
The new %clearjavaexception can be used for clearing the exception feature.
2008-12-22: wsfulton
Fix #2432801 - Make SwigValueWrapper exception safe for when copy constructors
throw exceptions.
2008-12-21: wsfulton
Apply patch #2440046 which fixes possible seg faults for member and global
variable char arrays when the strings are larger than the string array size.
2008-12-20: wsfulton
The ccache compiler cache has been adapted to work with SWIG and
named ccache-swig. It now works with C/C++ compilers as well as SWIG
and can result in impressive speedups when used to recompile unchanged
code with either a C/C++ compiler or SWIG. Documentation is in CCache.html
or the installed ccache-swig man page.
2008-12-12: wsfulton
Apply patch from Kalyanov Dmitry which fixes parsing of nested structs
containing comments.
2008-12-12: wsfulton
Fix error message in some nested struct and %inline parsing error situations
such as unterminated strings and comments.
2008-12-07: olly
[PHP] Fix warnings when compiling generated wrapper with GCC 4.3.
2008-12-06: wsfulton
[PHP] Deprecate %pragma(php4). Please use %pragma(php) instead.
The following two warnings have been renamed:
2008-12-04: bhy
[Python] Applied patch SF#2158938: all the SWIG symbol names started with Py
are changed, since they are inappropriate and discouraged in Python
documentation (from
"All user visible names defined by Python.h (except those defined by
the included standard headers) have one of the prefixes "Py" or "_Py".
Names beginning with "_Py" are for internal use by the Python implementation
and should not be used by extension writers. Structure member names do
not have a reserved prefix.
Important: user code should never define names that begin with "Py" or "_Py".
This confuses the reader, and jeopardizes the portability of the user
code to future Python versions, which may define additional names beginning
with one of these prefixes."
Here is a brief list of what changed:
PySwig* -> SwigPy*
PyObject_ptr -> SwigPtr_PyObject
PyObject_var -> SwigVar_PyObject
PySequence_Base, PySequence_Cont, PySequence_Ref ->
SwigPySequence_Base, SwigPySequence_Cont, SwigPySequence_Ref
PyMap* -> SwigPyMap*
We provided a pyname_compat.i for backward compatibility. Users whose code having
these symbols and do not want to change it could simply include this file
at front of your code. A better solution is to run the converting tool on
your code, which has been put in SWIG's SVN trunk (Tools/ and
you can download it here:
2008-12-02: wsfulton
[Python] Apply patch #2143727 from Serge Monkewitz to fix importing base classes
when the package option is specified in %module and that module is %import'ed.
2008-11-28: wsfulton
[UTL] Fix #2080497. Some incorrect acceptance of types in the STL, eg a double * element
passed into a vector<int *> constructor would be accepted, but the ensuing behaviour
was undefined. Now the type conversion correctly raises an exception.
2008-11-24: wsfulton
Add -outcurrentdir option. This sets the default output directory to the current
directory instead of the path specified by the input file. This option enables
behaviour similar to c/c++ compilers. Note that this controls the output directory,
but only in the absence of the -o and/or -outdir options.
2008-11-23: wsfulton
[ruby] Apply patch #2263850 to fix ruby/file.i ... rubyio.h filename change in
ruby 1.9.
2008-11-23: wsfulton
Apply patch #2319790 from Johan Hake to fix shared_ptr usage in std::tr1 namespace.
2008-11-21: wsfulton
The use of the include path to find the input file is now deprecated.
This makes the behaviour of SWIG the same as C/C++ compilers in preparation
for use with ccache.
2008-11-16: wsfulton
Fix -nopreprocess option to:
- correctly report file names in warning and error messages.
- use the original input filename that created the preprocessed output when
determining the C++ wrapper file name (in the absence of -o). Previously
the name of the input file containing the preprocessed output was used.
2008-11-11: wsfulton
[Java] Add patch #2152691 from MATSUURA Takanori which fixes compiles using the
Intel compiler
2008-11-01: wsfulton
Add patch #2128249 from Anatoly Techtonik which corrects the C/C++ proxy
class being reported for Python docstrings when %rename is used.
2008-11-01: wsfulton
Add the strip encoder patch from Anatoly Techtonik #2130016. This enables an
easy way to rename symbols by stripping a commonly used prefix in all the
function/struct names. It works in the same way as the other encoders, such as
title, lower, command etc outlined in CHANGES file dated 12/30/2005. Example
below will rename wxAnotherWidget to AnotherWidget and wxDoSomething to
%rename("%(strip:[wx])s") "";
struct wxAnotherWidget {
void wxDoSomething();
2008-09-26: mutandiz
Lots of test-suite work.
- Fix ordering of wrapper output and %{ %} header output.
- Fix declarations of local vars in C wrappers.
- Fix declaration of defined constants in C wrappers.
- Fix declaration of EnumValues in C wrappers.
- add some const typemaps to allegrocl.swg
- add rename for operator bool() overloads.
2008-09-25: olly
[PHP5] Fill in typemaps for SWIGTYPE and void * (SF#2095186).
2008-09-22: mutandiz (Mikel Bancroft)
- Support wrapping of types whose definitions are not seen by
SWIG. They are treated as forward-referenced classes and if a
definition is not seen are treated as (* :void).
- Don't wrap the contents of unnamed namespaces.
- More code cleanup. Removed some extraneous warnings.
- start work on having the allegrocl mod pass the cpp test-suite.
2008-09-19: olly
[PHP5] Add typemaps for long long and unsigned long long.
2008-09-18: wsfulton
[C#] Added C# array typemaps provided by Antti Karanta.
The arrays provide a way to use MarshalAs(UnmanagedType.LPArray)
and pinning the array using 'fixed'. See arrays_csharp.i library file
for details.
2008-09-18: wsfulton
Document the optional module attribute in the %import directive,
see Modules.html. Add a warning for Python wrappers when the
module name for an imported base class is missing, requiring the
module attribute to be added to %import, eg
%import(module="FooModule") foo.h
2008-09-18: olly
[PHP5] Change the default input typemap for char * to turn PHP
Null into C NULL (previously it was converted to an empty string).
The new behaviour is consistent with how the corresponding output
typemap works (SF#2025719).
If you want to keep the old behaviour, add the following typemap
to your interface file (PHP's convert_to_string_ex() function does
the converting from PHP Null to an empty string):
%typemap(in) char * {
$1 = Z_STRVAL_PP($input);
2008-09-18: olly
[PHP5] Fix extra code added to proxy class constructors in the case
where the only constructor takes no arguments.
2008-09-18: olly
[PHP5] Fix wrapping of a renamed enumerated value of an enum class
member (SF#2095273).
2008-09-17: mutandiz (Mikel Bancroft)
- Fix how forward reference typedefs are handled, so as not to conflict
with other legit typedefs.
- Don't (for now) perform an ffitype typemap lookup when trying to
when calling compose_foreign_type(). This is actually a useful thing
to do in certain cases, the test cases for which I can't currently
locate :/. It's breaking some wrapping behavior that is more commonly
seen, however. I'll readd in a more appropriate way when I can
recreate the needed test case, or a user complains (which means
they probably have a test case).
- document the -isolate command-line arg in the 'swig -help' output.
It was in the html docs, but not there.
- small amount of code cleanup, removed some unused code.
- some minor aesthetic changes.
2008-09-12: bhy
[Python] Python 3.0 support branch merged into SWIG trunk. Thanks to
Google Summer of Code 2008 for supporting this project! By default
SWIG will generate interface files compatible with both Python 2.x
and 3.0. And there's also some Python 3 new features that can be
enabled by passing a "-py3" command line option to SWIG. These
features are:
- Function annotation support
Also, the parameter list of proxy function will be generated,
even without the "-py3" option. However, the parameter list
will fallback to *args if the function (or method) is overloaded.
- Buffer interface support
- Abstract base class support
For details of Python 3 support and these features, please see the
"Python 3 Support" section in the "SWIG and Python" chapter of the SWIG
The "-apply" command line option and support of generating codes
using apply() is removed. Since this is only required by very old
This merge also patched SWIG's parser to solve a bug. By this patch,
SWIG features able to be correctly applied on C++ conversion operator,
such like this:
%feature("shadow") *::operator bool %{ ... %}
2008-09-02: richardb
[Python] Commit patch #2089149: Director exception handling mangles
returned exception. Exceptions raised by Python code in directors
are now passed through to the caller without change. Also, remove
the ": " prefix which used to be added to other director exceptions
(eg, those due to incorrect return types).
2008-09-02: wsfulton
[Python] Commit patch #1988296 GCItem multiple module linking issue when using
2008-09-02: wsfulton
[C#] Support for 'using' and 'fixed' blocks in the 'csin' typemap is now
possible through the use of the pre attribute and the new terminator attribute, eg
pre=" using (CDate temp$csinput = new CDate($csinput)) {",
terminator=" } // terminate temp$csinput using block",
) const CDate &
See CSharp.html for more info.
2008-09-01: wsfulton
[CFFI] Commit patch #2079381 submitted by Boris Smilga - constant exprs put into
no-eval context in DEFCENUM
2008-08-02: wuzzeb
[Chicken,Allegro] Commit Patch 2019314
Fixes a build error in chicken, and several build errors and other errors
in Allegro CL
2008-07-19: wsfulton
Fix building of Tcl examples/test-suite on Mac OSX reported by Gideon Simpson.
2008-07-17: wsfulton
Fix SF #2019156 Configuring with --without-octave or --without-alllang
did not disable octave.
2008-07-14: wsfulton
[Java, C#] Fix director typemaps for pointers so that NULL pointers are correctly
marshalled to C#/Java null in director methods.
2008-07-04: olly
[PHP] For std_vector.i and std_map.i, rename empty() to is_empty()
since "empty" is a PHP reserved word. Based on patch from Mark Klein
in SF#1943417.
2008-07-04: olly
[PHP] The deprecated command line option "-make" has been removed.
Searches on Google codesearch suggest that nobody is using it now
2008-07-04: olly
[PHP] The SWIG cdata.i library module is now supported.
2008-07-03: olly
[PHP] The deprecated command line option "-phpfull" has been
removed. We recommend building your extension as a dynamically
loadable module.
2008-07-02: olly
[PHP4] Support for PHP4 has been removed. The PHP developers are
no longer making new PHP4 releases, and won't even be providing
patches for critical security issues after 2008-08-08.
2008-07-02: olly
[Python] Import the C extension differently for Python 2.6 and
later so that an implicit relative import doesn't produce a
deprecation warning for 2.6 and a failure for 2.7 and later.
Patch from Richard Boulton in SF#2008229, plus follow-up patches
from Richard and Haoyu Bai.
Version 1.3.36 (24 June 2008)
06/24/2008: wsfulton
Remove deprecated -c commandline option (runtime library generation).
06/24/2008: olly
[PHP] Fix assertion failure when handling %typemap(in,numinputs=0)
(testcase ignore_parameter).
06/24/2008: olly
[PHP] Fix segfault when wrapping a non-class function marked with
%newobject (testcase char_strings).
06/22/2008: wsfulton
[Java] Add a way to use AttachCurrentThreadAsDaemon instead of AttachCurrentThread
in director code. Define the SWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON macro, see
06/21/2008: wsfulton
[Ruby] Fix crashing in the STL wrappers (reject! and delete_if methods)
06/19/2008: wsfulton
[Java, C#] C# and Java keywords will be renamed instead of just issuing a warning
and then generating uncompileable code. Warning 314 gives the new name when a
keyword is found.
06/19/2008: wsfulton
[R] Keyword handling added. R Keywords will be renamed as necessary.
Warning 314 gives the new name when a keyword is found.
06/17/2008: mgossage
[Lua] Added missing support for bool& and bool*. Added runtest for li_typemaps testcase.
(Bug #1938142)
06/07/2008: bhy
Added test case keyword_rename, then made the keyword renaming works properly
by fixing Swig_name_make() for a incomplete condition checking.
06/02/2008: wsfulton
[Java, C#] Fix enum wrappers when using -noproxy.
05/30/2008: bhy
Added std::wstring into Lib/typemaps/primtypes.swg, since it is also a primitive
type in SWIG - fixed SF #1976978.
05/29/2008: wsfulton
[Java, C#] Fix variable wrappers when using -noproxy.
05/29/2008: bhy
[Python] Fixed a typo of %#ifdef in Lib/python/pycontainer.swg, which is related
to -extranative SWIG option - SF #1971977.
05/20/2008: wsfulton
New partialcheck makefile targets for partial testing of the test-suite. These
just invoke SWIG, ie no compilation and no runtime testing. It can be faster
when developing by just doing a directory diff of the files SWIG generates
against those from a previous run. Example usage from the top level directory:
make partialcheck-test-suite
make partialcheck-java-test-suite
This change also encompasses more flexibility in running the test-suite, eg
it is possible to prefix the command line which runs any target language test
with a tool. See the RUNTOOL, COMPILETOOL and SWIGTOOL targets in the
file and makefiles in the test-suite directory. For example it is possible to
run the runtime tests through valgrind using:
make check RUNTOOL="valgrind --leak-check=full"
or invoke SWIG under valgrind using:
make check SWIGTOOL="valgrind --tool=memcheck"
05/19/2008: drjoe
[R] Fixed define that was breaking pre-2.7. Checked in
patch from Soren Sonnenburg that creates strings in
version independent way
05/15/2008: wsfulton
[Java] Fix variable name clash in directors - SF #1963316 reported by Tristan.
05/14/2008: wsfulton
Add an optimisation for functions that return objects by value, reducing
the number of copies of the object that are made. Implemented using an
optional attribute in the "out" typemap called "optimal". Details in
05/11/2008: olly
[PHP] Check for %feature("notabstract") when generating PHP5 class
05/11/2008: wsfulton
Fix SF #1943608 - $self substitution in %contract, patch submitted by
Toon Verstraelen.
05/09/2008: olly
[PHP] Fix char * typemaps to work when applied to signed char * and
unsigned char * (uncovered by testcase apply_strings).
05/09/2008: wsfulton
Fix wrapping of char * member variables when using allprotected mode.
Bug reported by Warren Wang.
05/09/2008: olly
[PHP] Fix bad PHP code generated when wrapping an enum in a
namespace (uncovered by testcase arrays_scope).
05/09/2008: olly
[PHP] SWIG now runs the PHP testsuite using PHP5, not PHP4. PHP4
is essentially obsolete now, so we care much more about solid PHP5
05/07/2008: wsfulton
STL fixes when using %import rather than %include and the Solaris Workshop
compiler and the Roguewave STL.
05/07/2008: wsfulton
Fix wrapping of overloaded protected methods when using allprotected mode.
Bug reported by Warren Wang.
05/03/2008: wsfulton
Commit patch #1956607 to add -MT support from Richard Boulton.
This patch mirrors the gcc -MT option which allows one to change the default
Makefile target being generated when generating makefiles with the -M family
of options. For example:
$ swig -java -MM -MT overiddenname -c++ example.i
overiddenname: \
example.i \
04/30/2008: mgossage
[Lua] Removed generation of _wrap_delete_XXXXX (wrappered destructor)
which was unused and causing warning with g++ -Wall.
Removed other unused warning in typemaps.i and other places.
Added Examples/lua/embed3, and run tests a few test cases.
04/24/2008: olly
[Python] Fix generated code for IBM's C++ compiler on AIX (patch
from Goeran Uddeborg in SF#1928048).
04/24/2008: olly
Rename BSIZE in Examples/test-suite/arrays_scope.i to BBSIZE to
avoid a clash with BSIZE defined by headers on AIX with Perl
(reported in SF#1928048).
04/20/2008: wsfulton
Add the ability to wrap all protected members when using directors.
Previously only the virtual methods were available to the target language.
Now all protected members, (static and non-static variables, non-virtual methods
and static methods) are wrapped when using the allprotected mode. The allprotected
mode is turned on in the module declaration:
%module(directors="1", allprotected="1") modulename
Version 1.3.35 (7 April 2008)
04/07/2008: wsfulton
[Lua] Add missing pointer reference typemaps
04/06/2008: wsfulton
Fix stack overflow when using typemap warning suppression, eg
04/05/2008: wsfulton
[Python] Fix shared_ptr typemaps so that %pythonnondynamic can be used. Also corrects
display of the proxy class type. Reported by Robert Lupton.
04/04/2008: olly
[Python] Add %newobject reference to python memory management subsection of manual
(patch from mdbeachy in SF#1894610).
03/27/2008: wsfulton
[Python] Fix shared_ptr typemaps where the pointer type is a templated type with
with more than one parameter. Reported by Robert Lupton.
03/27/2008: mgossage
[Lua] Added a typemap DISOWN for SWIGTYPE* and SWIGTYPE[], and support for %delobject feature.
Added Examples/lua/owner which demonstrates the use of the memory management.
03/26/2008: wsfulton
[Java] Apply patch #1844301 from Monty Taylor to suppress enum constructor
unused warnings.
03/26/2008: wsfulton
[Python] Apply patch #1924524 from Casey Raymondson which ensures the
"No constructor defined" message is displayed when attempting to call a
constructor on a class that doesn't have a constructor wrapper, eg if
the C++ class is abstract.
03/26/2008: wsfulton
[Python] Apply patch #1925702 from Casey Raymondson which removes warning 512
for std::vector wrappers.
03/26/2008: olly
[Python] Apply GCC 4.3 warnings patch from Philipp Thomas
03/21/2008: wsfulton
[Python] Thread safety patch for STL iterators from Abhinandan Jain.
03/17/2008: mgossage
[Lua] Added %luacode feature to add source code into wrappers.
Updated documentation to document this.
Added Examples/lua/arrays to show its use (and typemaps)
03/17/2008: olly
Fix nonportable sed usage which failed on Mac OS X (and probably
other platforms). Fixes SF#1903612.
03/17/2008: olly
Fix memory leak in SWIG's parser (based on patch from Russell
Bryant in SF#1914023).`
03/12/2008: wsfulton
Fix bug #1878285 - unnecessary cast for C struct creation wrappers.
03/12/2008: wsfulton
[Python] Remove debugging info when using shared_ptr support
03/06/2008: mgossage
[Lua] Updated documentation for Lua exceptions.
Added Examples/lua/exception and Examples/lua/embed2.
Small updates to the typemaps.
03/04/2008: wsfulton
[Java, C#] Add char *& typemaps.
03/04/2008: wsfulton
Fix occasional seg fault when attempting to report overloaded methods as being ignored.
02/29/2008: wsfulton
[Perl] Fix #1904537 Swig causes a Perl warning "x used only once" in Perl 5.10
reported by Ari Jolma
02/29/2008: wsfulton
[Python] Add shared_ptr varin/varout typemaps for wrapping global variables.
02/25/2008: wsfulton
Fix $wrapname to work in %exception (fixes some wrap:name assertions)
Version 1.3.34 (27 February 2008)
02/13/2008: wsfulton
[R] Fix wrapping of global function pointer variables.
02/13/2008: wsfulton
Add new special variables for use within %exception:
$wrapname - language specific wrapper name
$overname - if a method is overloaded this contains the extra mangling used on
the overloaded method
$decl - the fully qualified C/C++ declaration of the method being wrapped
without the return type
$fulldecl - the fully qualified C/C++ declaration of the method being wrapped
including the return type
02/12/2008: drjoe
[R] Now setting S4 flag in SWIG created objects. This
fixes R-SWIG for 2.6 and warning for 2.6 failure has been removed.
02/11/2008: mgossage
[Lua] Added a patch by Torsten Landschoff to fix the unary minus issue
Ran 'astyle --style=kr -2' across lua.cxx to neaten it up
02/10/2008: wsfulton
Bump SWIG_RUNTIME_VERSION to 4. This is because of the recently introduced API
change in the conversion functions, ie change in definition of swig_converter_func.
Anyone calling SWIG_TypeCast must pass in a valid value for the new additional
(third) parameter and then handle the newly created memory if the returned value
is set to SWIG_CAST_NEW_MEMORY else a memory leak will ensue.
02/09/2008: wsfulton
[Python] Experimental shared_ptr typemaps added. Usage is the same as the recently
added Java and C# shared_ptr typemaps. Two macros are available, although these
may well change in a future version:
For base classes or classes not in an inheritance chain:
For derived classes:
The PROXYCLASS is the name of the proxy class, but is only required for Java/C#.
Example usage:
%include "boost_shared_ptr.i"
SWIG_SHARED_PTR(Klass, Space::Klass)
SWIG_SHARED_PTR_DERIVED(KlassDerived, Space::Klass, Space::KlassDerived)
namespace Space {
struct Klass { ... };
struct KlassDerived : Klass { ... };
Further details to follow in future documentation, but the following features
should be noted:
- Not restricted to boost::shared_ptr, eg std::tr1::shared_ptr can also be used.
- Available typemap groups:
(a) Typemaps for shared_ptr passed by value, reference, pointer and pointer
- (b) Typemaps for passing by raw value, raw pointer, raw reference, raw pointer
- The code being wrapped does not even have to use shared_ptr, SWIG can use
shared_ptr as the underlying storage mechanism instead of a raw pointer due to
the typemaps in group (b) above.
- No array support as shared_ptr does not support arrays.
- This works quite differently to the usual SWIG smart pointer support when
operator-> is parsed by SWIG:
- An additional smart pointer class is not generated reducing code bloat in
the wrappers.
- Using smart pointers and raw pointers can be mixed seamlessly.
- Missing constructors for the smart pointers is no longer a problem and so
separate factory type functions do not have to be written and wrapped.
- The implicit C++ shared_ptr< derived class > to shared_ptr< base class >
cast also works in the target language. This negates the necessity to write
an explicit helper cast function providing the upcast which would need
calling prior to passing a derived class to a method taking a shared_ptr to
a base class.
02/09/2008: wsfulton
[Python] Add support for overriding the class registration function via a new
"smartptr" feature. This is a very low level of customisation most users
would never need to know. The feature will typically be used for intrusive
smart pointers along with additional typemaps. Example usage of the feature:
%feature("smartptr", noblock=1) Foo { boost::shared_ptr< Foo > }
class Foo {};
The generated Foo_swigregister function will then register boost::shared < Foo >
(SWIGTYPE_p_boost__shared_ptrTFoo_t instead of SWIGTYPE_p_Foo) as the underlying
type for instantiations of Foo.
02/09/2008: wsfulton
Features now supports the optional 'noblock' attribute for all usage of %feature.
When specified, the { } braces are removed from the feature code. This is identical
in behaviour to usage of 'noblock' in typemaps and is used when the preprocessor
is required to operate on the code in the feature and the enclosing { } braces
are not required. Example:
#define FOO foo
%feature("smartptr", noblock="1") { FOO::bar }
The preprocessor then reduces this as if this had been used instead:
%feature("smartptr") "foo::bar"
02/01/2008: olly
[Python] Fix format string bug (SF#1882220).
01/31/2008: wsfulton
Additions to the %types directive. Now the conversion / casting code can be
overridden to some custom code in the %types directive, like so:
%types(fromtype = totype) %{
... code to convert fromtype to totype and return ...
The special variable $from will be replaced by the name of the parameter of the
type being converted from. The code must return the totype cast to void *. Example:
class Time;
class Date;
Date &Time::dateFromTime();
%types(Time = Date) %{
Time *t = (Time *)$from;
Date &d = t->dateFromTime();
return (void *) &d;
resulting in the conversion / casting code looking something like:
static void *_p_TimeTo_p_Date(void *x) {
Time *t = (Time *)x;
Date &d = t->dateFromTime();
return (void *) &d;
This is advanced usage, please use only if you understand the runtime type system.
01/30/2008: mgossage
Small update to documentation in Typemaps.html, to warn about use of local
variables in typemaps for multiple types.
01/25/2008: wsfulton
[Java] Fix bug reported by Kevin Mills in ARRAYSOFCLASSES typemaps where any
changes made to an array element passed from Java to C are not reflected back
into Java.
01/24/2008: mgossage
More updates to the configure script for detecting lua.
Also looks in /usr/include/lua*
Also changed typemaps.i not to check for NULL before freeing a pointer
01/21/2008: wsfulton
[Python] For STL containers, SWIG no longer attempts to convert from one
STL container to another, eg from std::vector<int> to std::vector<double>
or std::list<int> to std::vector<int> or even std::vector<Foo> to
std::vector<Bar> as it previously did. In fact SWIG no longer attempts to
convert any SWIG wrapped C++ proxy class that is also a Python sequence,
whereas previously it would. Any non-SWIG Python sequence will still be
accepted wherever an STL container is accepted. Overloaded methods using
containers should be faster.
01/18/2008: wsfulton
[C#] Add 'directorinattributes' and 'directoroutattributes' typemap attributes
for the imtype typemap. These should contain C# attributes which will
be generated into the C# director delegate methods.
01/18/2008: olly
Fix handling of byte value 255 in input files on platforms where
char is signed (it was getting mapped to EOF). Fixes SF#1518219.
01/16/2008: wsfulton
Fix template member variables wrapped by a smart pointer. Bug reported
by Robert Lupton.
01/14/2008: mgossage
Substantial changes to configure script for detecting lua.
Code can now link to liblua.a, liblua50.a or liblua51.a
It's also a lot neater now.
12/16/2007: wsfulton
[Perl] Backed out #1798728 - numbers can be passed to functions taking char *
12/16/2007: wsfulton
Fix #1832613 - Templates and some typedefs involving pointers or function pointers
12/12/2007: wsfulton
[Java] Fix #1632625 - Compilation errors on Visual C++ 6 when using directors.
12/12/2007: wsfulton
[Perl] Fix #1798728 - numbers can be passed to functions taking char *.
12/12/2007: wsfulton
Fix #1819847 %template with just one default template parameter
template<typename T = int> class Foo {...};
%template(FooDefault) Foo<>;
12/12/2007: mgossage
[Lua] Small correction on Lua.html
12/09/2007: wsfulton
Apply patch #1838248 from Monty Taylor for vpath builds of SWIG.
12/08/2007: wsfulton
[Lua] Fixes to remove gcc-4.2 warnings
12/06/2007: wsfulton
Fix #1734415 - template template parameters with default arguments such as:
template<typename t_item, template<typename> class t_alloc = pfc::alloc_fast >
class list_t : public list_impl_t<t_item,pfc::array_t<t_item,t_alloc> > { ... };
12/04/2007: mgossage
[lua] Fix a bug in the class hierachy code, where the methods were not propagated,
if the name ordering was in a certain order.
Added new example programs (dual, embed) and runtime tests for test-suite.
11/30/2007: wsfulton
Fix using statements using a base class method where the methods were overloaded.
Depending on the order of the using statements and method declarations, these
were previously generating uncompileable wrappers, eg:
struct Derived : Base {
virtual void funk();
using Base::funk;
Version 1.3.33 (November 23, 2007)
11/21/2007: mikel
[allegrocl] omit private slot type info in the classes/types
defined on the lisp side. Fix bug in mapping of C/++ types
to lisp types. Fix typo in modules generated defpackage form.
Have std::string *'s automatically marshalled between foreign
and lisp strings.
11/20/2007: olly
[Python] Fill in Python Dictionary functions list (patch from
Jelmer Vernooij posted to swig-devel).
11/20/2007: beazley
Fixed a bug in the C scanner related to backslash characters.
11/19/2007: wsfulton
[Perl] Fix broken compilation of C++ wrappers on some compilers.
11/16/2007: olly
[Python] Don't pass Py_ssize_t for a %d printf-like format as
that's undefined behaviour when sizeof(Py_ssize_t) != sizeof(int).
Version 1.3.32 (November 15, 2007)
11/14/2007: wsfulton
[R] Package name and dll name is now the same as the SWIG module
name. It used to be the module name with _wrap as a suffix. The package
and dll names can be modified using the -package and -dll commandline
11/11/2007: wsfulton
[R] Add support for Windows (Visual C++ 8 tested)
11/10/2007: olly
[php] Fix makefile generated by -make (SF#1633679). Update
documentation to mark "-make" as deprecated (none of the other
SWIG backends seem to offer such a feature, it can't realistically
generate a fully portable makefile, and the commands to build an
extension are easy enough to write for the user's preferred build
tool). Also recommend against the use of "-phpfull" (it's only
really useful when static linking, and a dynamically loadable
module is virtually always the better approach).
11/09/2007: olly
Fix --help output to note that `export SWIG_FEATURES' is required.
10/29/2007: wsfulton
[R] Fix seg fault on Windows
[R] Examples R scripts are now platform independent
10/30/2007: mgossage
[lua] fixed bug in template classes which cases template_default2
and template_specialization_defarg to fail.
Added several warning filters into the overload's test cases.
Added runtime tests for several codes.
You can now make check-lua-test-suite with no errors and only a few warnings.
10/30/2007: olly
[guile] Fix the configure test to put GUILELINK in LIBS not LDFLAGS
10/30/2007: olly
[guile] Fix the guile examples on 64-bit platforms.
10/29/2007: wsfulton
[C#] Fix member pointers on 64 bit platforms.
10/28/2007: olly
[lua] Fix swig_lua_class instances to be static to allow multiple
SWIG wrappers to be compiled into the same executable statically.
Patch from Andreas Fredriksson (posted to the swig mailing list).
10/28/2007: olly
[lua] Fix Examples/lua to pass SRCS for C tests rather than CXXSRCS.
The code as it was happened to work on x86, but broke on x86_64 (and
probably any other platforms which require -fPIC).
10/28/2007: wsfulton
[Java, C#] New approach for fixing uninitialised variable usage on error in director
methods using the new templated initialisation function SwigValueInit().
10/28/2007: wsfulton
[Perl] Use more efficient SvPV_nolen(x) instead of SvPV(x,PL_na) if SvPV_nolen is
10/26/2007: wuzzeb
[Chicken] Fix global variables of class member function pointers.
Other minor fixes, so all tests in the chicken test suite now pass
10/25/2007: olly
Fix UTL typecheck macro for a function taking char[] or const
char[] (SF#1820132).
10/22/2007: mkoeppe
[Guile] Filter out -ansi -pedantic from CFLAGS while compiling test programs for Guile
in configure. This enables running the test suite for Guile if it is installed and
10/22/2007: mkoeppe
[Guile -scm] Fix testcases apply_signed_char and apply_strings
by adding explicit casts to the appropriate $ltype.
10/22/2007: wsfulton
[Java, C#] Fix uninitialised variable usage on error in director methods.
10/19/2007: wsfulton
[Java, C#] Bug #1794247 - fix generated code for derived classes when csbase or javabase
typemaps are used with the replace="1" attribute.
10/19/2007: wsfulton
[Python] Docs updated to suggest using distutils. Patch #1796681 from Christopher Barker.
10/19/2007: olly
[perl5] Clear errno before calls to strtol(), strtoul(), strtoll()
and strtoull() which we check errno after to avoid seeing a junk
value of errno if there isn't an error in the call.
10/16/2007: wsfulton
Deprecate %attribute_ref and replace with %attributeref. There is just an argument
order change in order to maintain consistency with %attribute, from:
%attribute_ref(Class, AttributeType, AccessorMethod, AttributeName)
%attributeref(Class, AttributeType, AttributeName, AccessorMethod)
10/16/2007: olly
[Tcl] Fix several ocurrences of "warning: deprecated conversion
from string constant to 'char*'" from GCC 4.2 in generated C/C++
10/16/2007: olly
[PHP] Fix many occurrences of "warning: deprecated conversion from
string constant to 'char*'" from GCC 4.2 in generated C/C++ code
when compiling with a new enough version of PHP 5 (tested with
PHP 5.2.3, but PHP 5.2.1 is probably the minimum requirement).
10/15/2007: wsfulton
Patch #1797133 from David Piepgrass fixes %attribute when the getter has the same name
as the attribute name and no longer generate non-functional setter for read-only attributes.
10/15/2007: olly
[Tcl] Prevent SWIG_Tcl_ConvertPtr from calling the unknown proc.
Add Examples/tcl/std_vector/ which this change fixes. Patch
is from "Cliff C" in SF#1809819.
10/12/2007: wsfulton
[Java] Add DetachCurrentThread back in for directors. See entry dated 08/11/2006 and
search for DetachCurrentThread on the mailing lists for details. The crashes on Solaris
seem to be only present in jdk-1.4.2 and lower (jdk-1.5.0 and jdk-1.6.0 are okay), so
anyone using directors should use a recent jdk on Solaris, or define (see director.swg)
SWIG_JAVA_NO_DETACH_CURRENT_THREAD to the C++ compiler to get old behaviour.
10/12/2007: wsfulton
[Java] Ensure the premature garbage collection prevention parameter (pgcpp) is generated
when there are C comments in the jtype and jstype typemaps.
10/12/2007: wuzzeb
Added a testsuite entry for Bug #1735931
10/09/2007: olly
Automatically rerun if is modified.
10/09/2007: olly
Enhance check-%-test-suite rule and friends to give a more helpful
error message if you try them for a language which doesn't exist
(e.g. "make check-php-test-suite" rather than the correct
"make check-php4-test-suite").
10/09/2007: olly
Add make rule to regenerate Makefile from if it has
10/09/2007: olly
[php] Fix long-standing memory leak in wrapped constructors and
wrapped functions/methods which return an object.
10/08/2007: olly
Fix to read check.list files correctly in a VPATH
10/07/2007: wsfulton
[C#, Java] Experimental shared_ptr typemaps added
09/27/2007: mgossage
[lua] added more verbose error messages for incorrect typechecks.
Added a routine which checks the exact number of parameters passed to a function
(breaks operator_overloading for unary minus operator, currently disabled).
Reorganised the luatypemaps.swg to tidy it up.
Added a lot of %ignores on the operators not supported by lua.
Added support for constant member function pointers & runtest for member_pointer.i
Added first version of wchar.i
09/25/2007: wsfulton
[C#, Java] throws typemaps for std::wstring using C# patch #1799064 from David Piepgrass
09/24/2007: wsfulton
[Tcl] Apply #1771313 to fix bug #1650229 - fixes long long and unsigned long long
09/20/2007: olly
[Java] Eliminate some unnecessary uses of a temporary buffer
allocated using new[]. SF#1796609.
09/19/2007: wsfulton
[C#] The $csinput special variable can be used in the csvarin typemap where it is always
expanded to 'value'.
09/19/2007: wsfulton
[C#] Fix bug reported by Glenn A Watson and #1795260 where the cstype typemap used the 'ref'
keyword in the typemap body, it produced uncompilable C# properties (variable wrappers).
The type for the property now correctly comes from the 'out' attribute in the cstype typemap.
09/19/2007: wsfulton
[Java] Fix const std::wstring& typemaps
09/19/2007: wsfulton
[Java] Ensure the premature garbage collection prevention parameter (pgcpp) is generated
where a parameter is passed by pointer reference, eg in the std::vector wrappers. The pgcpp
is also generated now when user's custom typemaps use a proxy class in the jstype typemap
and a 'long' in the jtype typemap.
09/18/2007: olly
[php] Add typemaps for handling parameters of type std::string &
which are modified by the wrapped function.
09/17/2007: olly
[python] Split potentially long string literals to avoid hitting
MSVC's low fixed limit on string literal length - patch from
SF#1723770, also reported as SF#1630855.
09/17/2007: olly
[ocaml] Fix renaming of overloaded methods in the method_table -
my patch from SF#940399.
09/17/2007: olly
[python] Simpler code for SWIG_AsVal_bool() which fixes a "strict
aliasing" warning from GCC - patch from SF#1724581 by Andrew
09/17/2007: olly
[perl5] Use sv_setpvn() to set a scalar from a pointer and length
- patch from SF#174460 by "matsubaray".
09/17/2007: olly
When wrapping C++ code, generate code which uses
std::string::assign(PTR, LEN) rather than assigning
std::string(PTR, LEN). Using assign generates more efficient code
(tested with GCC 4.1.2).
09/07/2007: wsfulton
Fix %ignore on constructors which are not explicitly declared [SF #1777712]
09/05/2007: wuzzeb (John Lenz)
- Change r_ltype in typesys.c to store a hashtable instead of a single value.
several very subtle bugs were being caused by multiple ltypes being mapped
to a single mangled type, mostly when using typedefed template parameters.
Now, r_ltype stores a hashtable of possible ltypes, and when generating the
type table, all the ltypes are added into the swig_type_info structure.
08/31/2007: wsfulton
SF #1754967 from James Bigler.
- Fix bug in turning on warnings that were turned off by default. Eg 'swig -w+309' will now
turn on the normally suppressed warning 309.
- New -Wextra commandline option which enables the extra warning numbers:
202,309,403,512,321,322 (this is the list of warnings that have always been suppressed by
default). By specifying -Wextra, all warnings will be turned on, but unlike -Wall,
warnings can still be selectively turned on/off using %warnfilter,
#pragma SWIG nowarn or further -w commandline options, eg:
swig -Wextra -w309
will turn on all warnings except 309.
08/28/2007: wsfulton
- New debugging options, -debug-module <n> and -debug-top <n> to display the parse tree at
various stages, where <n> is a comma separated list of stages 1-4.For example, to
display top of parse tree at stages 1 and 3:
swig -debug-top 1,3
- Deprecate the following options which have equivalents below:
-dump_parse_module => -debug-module 1
-dump_module => -debug-module 4
-dump_parse_top => -debug-top 1
-dump_top => -debug-top 4
- Renamed some commandline options for naming consistency across all options:
-debug_template => -debug-template
-debug_typemap => -debug-typemap
-dump_classes => -debug-classes
-dump_tags => -debug-tags
-dump_typedef => -debug-typedef
-dump_memory => -debug-memory
08/25/2007: olly
[PHP5] Fix handling of double or float parameters with an integer
default value.
08/25/2007: olly
[PHP5] Generate __isset() methods for setters for PHP 5.1 and later.
08/20/2007: wsfulton
[Java C#] Fix director bug #1776651 reported by Stephane Routelous which occurred when
the director class name is the same as the start of some other symbols used within
the director class.
08/17/2007: wsfulton
Correct behaviour for templated methods used with %rename or %ignore and the empty
template declaration - %template(). A warning is issued if the method has not been
08/16/2007: mutandiz (Mikel Bancroft)
[allegrocl] Name generated cl file based on input file rather than by
module name. It was possible to end up with a and a test_wrap.c
when parsing a test.i input file. Confusing. Also, include external-format
templates for :fat and :fat-le automatically to avoid these being compiled
at runtime.
08/15/2007: efuzzyone
[cffi] Apply patch #1766076 from Leigh Smith adding support for newly introduced
in cffi :long-long and :unsigned-long-long.
08/10/2007: wsfulton
[Java] Add documentation patch #1743573 from Jeffrey Sorensen. It contains a neat
idea with respect to better memory management by the JVM of C++ allocated memory.
08/10/2007: wsfulton
[Perl] Apply patch #1771410 from Wade Brainerd to fix typedef XS(SwigPerlWrapper) in
perlrun.swg for ActiveState Perl build 822 and Perl 5.8.9 and 5.10 branches.
08/10/2007: wsfulton
[Lua] const enum reference typemaps fixed.
08/09/2007: wsfulton
[C#] Added missing support for C++ class member pointers.
08/09/2007: wsfulton
[C#, Java] Add support for $owner in the "out" typemaps like in the the scripting
language modules. Note that $owner has always been supported in the "javaout" / "csout"
08/01/2007: wsfulton
Fix smart pointer handling for classes that have templated methods within the smart
pointer type. Problem reported by craigdo at
07/31/2007: efuzzyone
[cffi] fixed memory access after being freed bug. thanks to Martin Percossi.
package name clos changed to cl. thanks to Ralf Mattes
07/24/2007: wsfulton
Parallel make support added for the examples and test-suite for developers who have
more than one CPU. Now parallel make can be used for checking in addition to building
the SWIG executable. Some typical checking examples:
make -j8 -k check
make -j4 check-java-test-suite
make -j2 check-java-examples
07/19/2007: mgossage
Fixed bug that stopped configure working on mingw (applied dos2unix to
07/10/2007: mgossage
[lua] Extra compatibility with Lua 5.1 (updated SWIG_init, docs, examples, test suite)
Removed name clash for static link of multiple modules
07/05/2007: mgossage
[lua] Fix a bug in SWIG_ALLOC_ARRAY()
improved the error messages for incorrect arguments.
Changed the output of swig_type() to use the human readable form of the type,
rather than the raw swig type.
07/03/2007: wsfulton
[C#] Fix directors for some overloaded methods where the imtype resulted in identical
methods being generated in the C# director class, eg void foo(int *) and void foo(double *)
used to generated two of these:
private void SwigDirectorfoo(IntPtr p) { ... }
06/25/2007: wsfulton
[Java, C#] Some parameter name changes in std_vector.i allowing better targeting
of typemaps for method parameters (for memory management of containers of pointers).
06/07/2007: mutandiz (Mikel Bancroft)
fix foreign-type constructor to properly look for ffitype typemap
bindings. fix inout_typemaps.i for strings.
06/06/2007: olly
Use whichever of "long" or "long long" is the same size as "void*"
to hold pointers as integers, rather than whichever matches off_t.
Fixes compilation on OS X and GCC warnings on platforms where
sizeof(void*) < sizeof(off_t) (SF patch #1731979).
06/06/2007: olly
Fix handling of a particular case involving overloaded functions
with default parameters.
06/05/2007: mutandiz (Mikel Bancroft)
Fix case where we'd pass fully qualified identifiers
(i.e. NS1::NS2::FOO) to swig-insert-id. All namespaces
should be stripped.
Fix bug in TypedefHandler introduced by last fix.
06/05/2007: olly
Fix reporting of filenames in errors after %include (patch from
Leigh Smith in #1731040; also reported as #1699940).
05/31/2007: olly
Fix "missing initialiser" warning when compiling generated C/C++
wrapper code with Python 2.5 with warnings enabled (patch from
bug#1727668 from Luke Moore).
05/29/2007: olly
Split docstrings into separate string literals at each newline when
generating C/C++ wrapper code (the C/C++ compiler will just combine
them back into a single string literal). This avoids MSVC
complaining that the strings are too long (problem reported by
Bo Peng on the mailing list).
05/28/2007: olly
Escape backslashes in docstrings.
05/26/2007: olly
Fix autodoc generation of enums to be more consistent with how the
enums are wrapped - patch #1697226 from Josh Cherry.
05/26/2007: olly
Fix wrapping of methods and functions which return a pointer to a
class (bug#1700788) and those which have overloaded forms returning
both classes and non-classes (bug#1712717, thanks to Simon
Berthiaume for the patch).
05/25/2007: wsfulton
Fixed %rename inconsistency in conversion operators as reported by Zhong Ren. The matching
is now done on the operator name in the same way as it is done for parameters. For example:
%rename(opABC) Space::ABC::operator ABC() const;
%rename(methodABC) Space::ABC::method(ABC a) const;
namespace Space {
class ABC {
void method(ABC a) const {}
operator ABC() const { ABC a; return a; }
Note that qualifying the conversion operator previously may or may not have matched.
Now it definitely won't, so this will not match:
%rename(opABC) Space::ABC::operator Space::ABC() const;
in the same way that this does not match:
%rename(methodABC) Space::ABC::method(Space::ABC a) const;
The documentation has been improved with respect to %rename, namespaces and templates.
Conversion operators documentation too.
05/16/2007: mutandiz
Fix bad generation of local var ltype's in functionWrapper().
Try to work better with the backward order in which swig
unrolls nested class definitions.
cleaned up a little unnecessary code/debug printf's.
Remove warning when replacing $ldestructor for ff:foreign-pointer
05/12/2007: olly
swig -python -threads now generates C/C++ code which uses Python's
own threading abstraction (from pythread.h) rather than OS specific
code. The old code failed to compile on MS Windows. (See SF patch
tracker #1710341).
05/04/2007: gga
Changed STL renames to be global renames. This fixes
STL functions not being renamed when autorename is on.
This is a not a totally perfect work-around, but better.
Someone really needs to fix the template renaming code.
(See bug #1545634)
05/04/2007 gga
Changed %rename("%(undercase)s") a little so that single
numbers at the end of a function are not undercased. That is:
getSomething -> get_something
get2D -> get_2d
get234 -> get_234
asFloat2 -> as_float2
(Bug #1699714)
05/03/2007: gga
Made __swigtype__ => @__swigtype__ so it can be accessed
from the scripting language (and follows Ruby's official
documentation, just in case).
Made tracking => @__trackings__ for same reason.
Currently storing ivars without the @ seems valid, but
the PickAxe says this is not correct, so just in case...
05/03/2007: gga
Applied patch for -minherit bug and exception classes.
This issue should be revisited more closely, as Multiple
Inheritance in Ruby is still problematic.
(patch/bug #1604878)
05/03/2007: gga
Overloaded functions in ruby will now report to the user
the possible prototypes when the user mistypes the number or
type of a parameter.
05/03/2007: gga
Forgot to document the bug fixing of an old bug regarding
(bug #1458247)
05/03/2007: gga
Fixed Ruby documentation to use the proper css styles for
each section. Added autodoc section to Ruby's docs to
document the features supported by Ruby in documenting its modules.
Made rdoc documentation spit out the full name of the class +
method name. Albeit this will make the current rdoc not recognize
the method, this is still needed to disambiguate between different
classes with similar methods (rdoc was created to document the
ruby source which only contains one class per c file, unlike swig)
I have patched rdoc to make it more friendly to swig. This
patch needs to be merged in the ruby std library now.
05/03/2007: gga
Changed flag -feature to be -init_name to better reflect its
purpose and avoid confusion with -features.
05/03/2007: gga
Improved autodoc generation.
Added autodoc .swg files to Ruby library for easily adding
documentation to common Ruby methods and STL methods.
Fixed autodoc documenting of getters and setters and module.
Made test suite always generate autodocs.
05/03/2007: gga
Removed some warnings from STL and test suite.
05/02/2007: mgossage
[Lua] Fixed issues with C++ classes and hierachies across multiple
source files. Fixed imports test case & added run test.
Added Examples/imports.
Added typename for raw lua_State*
Added documentation on native functions.
05/02/2007: gga
Docstrings are now supported.
%feature("autodoc") and %feature("docstring") are now
properly supported in Ruby. These features will generate
a _wrap.cxx file with rdoc comments in them.
05/02/2007: gga
STL files have been upgraded to follow the new swig/python
Lib/std conventions.
This means std::vector, std::set, std::map, set::multimap,
std::multiset, std::deque and std::string are now properly
supported, including their iterators, support for containing
ruby objects (swig::GC_VALUE) and several other ruby
std::complex, std::ios, std::iostream, std::iostreambuf and
std::sstream are now also supported.
std::wstring, std::wios, std::wiostream, std::wiostreambuf
and std::wsstream are supported verbatim with no unicode
std_vector.i now mimics the behavior of Ruby Arrays much more
closely, supporting slicing, shifting, unshifting,
multiple indexing and proper return values on assignment.
COMPATABILITY NOTE: this changes the older api a little bit in
that improper indexing would previously (incorrectly) raise
exceptions. Now, nil is returned instead, following ruby's
standard Array behavior.
05/02/2007: gga
Changed the value of SWIG_TYPECHECK_BOOL to be 10000 (ie. higher
than that of all integers).
This is because Ruby allows typecasting
integers down to booleans which can make overloaded functions on
bools and integers to fail.
(bug# 1488142)
05/02/2007: gga
Fixed a subtle bug in multiple argouts that could get triggered if
the user returned two or more arguments and the first one was an
05/01/2007: gga
Improved the documentation to document the new features
added, add directorin/out/argout typemaps, etc.
05/01/2007: gga
Added %initstack and %ignorestack directives for director
functions. These allow you to control whether a director
function should re-init the Ruby stack.
This is sometimes needed for an embedded Ruby where the
director method is used as a C++ callback and not called
by the user from ruby code.
Ruby's GC needs to be aware of the running OS stack in order to
mark any VALUE (Ruby objects) it finds there to avoid collection
of them. This allows the ruby API to be very simple and allows
you to write code like "VALUE a = sth" anywhere without needing
to do things like refcounting like python.
By default, the start of the stack is set when ruby_init() is
called. If ruby is inited within main(), as it usually is the
case with the main ruby executable, ruby will be able to calculate
its stack properly. However, when this is not possible, as when
ruby is embedded as a plugin to an application where main is not
available, ruby_init() will be called in the wrong place, and
ruby will be incorrectly tracking the stack from the function
that called ruby_init() forwards only, which can lead to
all sorts of weird crashes or to ruby thinking it has run out of
stack space incorrectly.
To avoid this, director (callback) functions can now be tagged
to try to reset the ruby stack, which will solve the issues.
NOTE: ruby1.8.6 still contains a bug in it in that its function
to reset the stack will not always do so. This bug is triggered
very rarely, when ruby is called from two very distinct places
in memory, like a branch of main() and another dso. This bug
has now been reported to ruby-core and is pending further
(bug #1700535 and patch #1702907)
04/30/2007: wsfulton
Fix #1707582 - Restore building from read-only source directories.
04/30/2007: gga
Ruby will now report the parameter index properly on type
errors as well as the class and value of the incorrect
argument passed.
(feature request #1699670)
04/30/2007: gga
Ruby no longer creates the free_Class function if the class
contains its own user defined free function (%freefunc).
(bug #1702882)
04/30/2007: gga
Made directors raise a ruby exception for incorrect argout
returned values if RUBY_EMBEDDED is set, instead of throwing
an actual SwigDirector exception.
This will prevent crashes when ruby is embedded and unaware
of the SwigDirector exception.
04/30/2007: gga
Removed the need for -DSWIGEXTERN.
Changed swig_ruby_trackings to be a static variable, but also
be kept within a hidden instance variable in the SWIG module.
This allows properly dealing with trackings across multiple
DSOs, which was previously broken.
(bug #1700535 and improvement to patch #1702907)
04/29/2007: gga
[Ruby] Fixed GC memory issues with trackings that could lead
to segfaults when dealing, mainly, with static variables.
(bug #1700535 and patch #1702907)
04/29/2007: gga
Fixed String conversion using old ruby1.6 macros. Now
StringValuePtr() is used if available. This removes warnings
when converting strings with \0 in them.
(bug #1700535 and patch #1702907)
04/29/2007: gga
Fixed the argout count in directors for Ruby. Previously,
ignored or "numinputs=0" typemaps would incorrectly not get
counted towards the argout count.
(bug/patch #1545585)
04/29/2007: gga
Upgraded Ruby converter to recognize "numinputs=0". Previously,
only the old "ignore" flag was checked (which would currently
still work properly, but is deprecated).
04/29/2007: gga
[Ruby - but should be made generic]
%feature("numoutputs","0") added.
This feature allows you to ignore the output of a function so
that it is not added to a list of output values
( ie. argouts ).
This should also become a feature of %typemap(directorout)
as "numoutputs"=0, just like "numinputs"=0 exists.
%include <typemaps.i>
%feature("numoutputs","0") { Class::member_function1 };
%typemap(out) MStatus { // some code, like check mstatus
// and raise exception if wrong };
%inline %{
typedef int MStatus;
class Class {
// one argument returned, but director out code added
// MStatus is discarded as a return (out) parameter.
virtual MStatus member_function1( int& OUTPUT );
// two arguments returned, director out code added
// MStatus is not discarded
virtual MStatus member_function2( int& OUTPUT );
04/21/2007: olly
Fix parsing of float constants with an exponent (e.g. 1e-02f)
(bug #1699646).
04/20/2007: olly
[Python] Fix lack of generation of docstrings when -O is used.
Also, fix generation of docstrings containing a double quote
character. Patch from Richard Boulton in bug#1700146.
04/17/2007: wsfulton
[Java, C#] Support for adding in Java/C# code before and after the intermediary call,
specifically related to the marshalling of the proxy type to the intermediary type.
The javain/csin typemap now supports the 'pre' and 'post' attributes to achieve this.
The javain typemap also supports an optional 'pgcppname' attribute for premature garbage
collection prevention parameter naming and the csin typemap supports an optional 'cshin'
attribute for the parameter type used in a constructor helper generated when the type is used
in a constructor. Details in the Java.html and CSharp.html documentation.
04/16/2007: olly
Don't treat `restrict' as a reserved identifier in C++ mode
04/16/2007: olly
[PHP5] Fix how zend_throw_exception() is called (bug #1700785).
04/10/2007: olly
Define SWIGTEMPLATEDISAMBIGUATOR to template for aCC (reported on
swig-user that this is needed).
04/04/2007: olly
[PHP5] If ZTS is enabled, release <module>_globals_id in MSHUTDOWN
to avoid PHP interpreter crash on shutdown. This solution was
suggested here:
04/03/2007: olly
[PHP4] Add missing ZTS annotations to generated C++ wrapper code
to fix compilation failures when using ZTS enabled SWIG (Linux
distributions tend to disable ZTS, but notably the Windows build
uses it by default).
04/01/2007: efuzzyone
[CFFI] Patch #1684261: fixes handling of unsigned int literals, thanks Leigh Smith.
Also, improved documentation.
03/30/2007: olly
Avoid generating '<:' token when using SwigValueWrapper<> on a type
which starts with '::' (patch #1690948).
03/25/2007: wuzzeb (John Lenz)
[perl5] Add SWIG_fail to the SWIG_exception macro. Fixes a few problems reported
on the mailing list.
03/23/2007: wsfulton
String copying patch from Josh Cherry reducing memory consumption by about 25%.
03/21/2007: wsfulton
[Java] Apply patch #1631987 from Ulrik Peterson - bool INOUT typemaps
fail on big endian machines.
03/16/2007: wsfulton
Fix seg fault given dodgy C++ code: namespace abc::def { }
03/16/2007: wsfulton
[Java] Fixes so that ARRAYSOFCLASSES and ARRAYSOFENUMS in arrays_java.i can be applied
to pointer types.
03/03/2007: olly
[PHP5] When we know the literal numeric value for a constant, use
that to initialise the const member in the PHP wrapper class.
03/02/2007: olly
[PHP5] Fix PHP wrapper code generated for certain cases of
overloaded forms with default arguments.
02/26/2007: efuzzyone
[CFFI] Patch #1656395: fixed hex and octal values bug, thanks to Arthur Smyles.
02/22/2007: mgossage
[Lua] Fixed bug in typemaps which caused derived_byvalue and rname test cases to fail.
Updated derived_byvalue.i to explain how to find and fix the problem
01/25/2007: wsfulton
Fix #1538522 and #1338527, forward templated class declarations without a
name for the templated class parameters, such as:
template <typename, class> class X;
01/23/2007: mgossage
[Lua] Patch #1640862: <malloc.h> replaced by <stdlib.h>
Patch #1598063 Typo in typemaps.i
01/22/2007: mgossage
[Lua] Added a lua specific carrays.i which adds the operator[] support.
modified the main code to make it not emit all the class member functions & accessors
Note: C structs are created using new_XXX() while C++ classes use XXX() (should be standardised)
Updated test case: li_carrays
Updated the documentation.
01/12/2007: wsfulton
[Php] Add support for newfree typemaps (sometimes used by %newobject)
01/12/2007: beazley
New command line option -macroerrors. When supplied, this will force
the C scanner/parser to report proper location information for code contained
inside SWIG macros (defined with %define). By default, SWIG merely reports
errors on the line at which a macro is used. With this option, you
can expand the error back to its source---something which may simplify
01/12/2007: beazley
[Internals] Major overhaul of C/C++ scanning implementation. For quite
some time, SWIG contained two completely independent C/C++ tokenizers--
the legacy scanner in CParse/cscanner.c and a general purpose scanner
in Swig/scanner.c. SWIG still has two scanning modules, but the C parser
scanner (CParse/cscanner.c) now relies upon the general purpose
scanner found in Swig/scanner.c. As a result, it is much smaller and
less complicated. This change also makes it possible to maintain all
of the low-level C tokenizing in one central location instead of two
places as before.
This change may cause problems with accurate line number reporting
as well as error reporting more generally. I have tried to resolve this
as much as possible, but there might be some corner cases.
01/12/2007: mgossage
[Lua] Added typemap throws for std::string*, typemap for SWIGTYPE DYNAMIC,
changed the existing throws typemap to throw a string instead of making a copy of
the object (updating a few test cases to deal with the change).
fixed test case: dynamic_casts, exception_partial_info, li_std_string, size_t
01/03/2007: beazley
[Internals]. Use of swigkeys.c/.h variables is revoked. Please use
simple strings for attribute names.
12/30/2006: beazley
Internal API functions HashGetAttr() and HashCheckAttr() have been revoked.
Please use Getattr() to retrieve attributes. The function Checkattr() can
be used to check attributes. Note: These functions have been revoked
because they only added a marginal performance improvement at the expense
code clarity.
12/26/2006: mgossage
[Lua] Added more STL (more exceptions, map, size_t),
fixed test case: conversion_ns_template.
12/21/2006: mgossage
[Lua] Update to throw errors when setting immutables,
and allowing user addition of module variables.
12/20/2006: wsfulton
Fix typedef'd variable wrappers that use %naturalvar, eg, std::string.
12/14/2006: wsfulton
[C#] Add std::wstring and wchar_t typemaps
12/14/2006: olly
[php] Fix bug #1613673 (bad PHP5 code generated for getters and
12/02/2006: wsfulton, John Lenz, Dave Beazley
Move from cvs to Subversion for source control
11/30/2006: beazley
Cleaned up swigwarnings.swg file not to use nested macro
11/12/2006: wsfulton
[Java, C#] Fix for %extend to work for static member variables.
Version 1.3.31 (November 20, 2006)
11/12/2006: Luigi Ballabio
[Python] Alternate fix for Python exceptions bug #1578346 (the previous one broke Python
properties in modern classes)
11/12/2006: wsfulton
-fakeversion commandline option now generates the fake version into the generated wrappers
as well as displaying it when the -version commandline option is used.
14/11/2006: mgossage
[lua] update to typemap for object by value, to make it c89 compliant
Version 1.3.30 (November 13, 2006)
11/12/2006: wsfulton
[java] Remove DetachCurrentThread patch from 08/11/2006 - it causes segfaults
on some systems.
11/12/2006: wsfulton
[python] Fix #1578346 - Python exceptions with -modern
11/10/2006: wsfulton
Fix #1593291 - Smart pointers and inheriting from templates
11/09/2006: wsfulton
Fix director operator pointer/reference casts - #1592173.
11/07/2006: wsfulton
Add $self special variable for %extend methods. Please use this instead of just 'self'
as the C++ 'this' pointer.
11/07/2006: mutandiz
allegrocl.swg: swig-defvar updated to allow specifying of
non-default foreign type (via :ftype keyword arg).
allegrocl.cxx: Specify proper access type for enum values.
11/03/2006: wsfulton
[Java/C#] Fix const std::string& return types for directors as reported by
Mark Donselzmann
10/29/2006: wsfulton
[Java] Remove DeleteLocalRef from end of director methods for now as it is causing a
seg fault when run on Solaris 8.
10/29/2006: wuzzeb (John Lenz)
[Guile] Patch from Chris Shoemaker to clean up some warnings in the generated code.
10/29/2006: wsfulton
[Java] Important fix to prevent early garbage collection of the Java proxy class
while it is being used in a native method. The finalizer could destroy the underlying
C++ object while it was being used. The problem occurs when the proxy class is no
longer strongly reachable after a native call. The problem seems to occur in
memory stress situations on some JVMs. It does not seem to occur on the
Sun client JVM up to jdk 1.5. However the 1.6 client jdk has a more aggressive garbage
collector and so the problem does occur. It does occur on the Sun server
JVMs (certainly 1.4 onwards). The fix entails passing the proxy class into the native
method in addition to the C++ pointer in the long parameter, as Java classes are not
collected when they are passed into JNI methods. The extra parameter can be suppressed
by setting the nopgcpp attribute in the jtype typemap to "1" or using the new -nopgcpp
commandline option.
See Java.html#java_pgcpp for further details on this topic.
10/24/2006: wsfulton
[C#] Fix smart pointer wrappers. The virtual/override/new keyword is not generated
for each method as the smart pointer class does not mirror the underlying pointer
class inheritance hierarchy. SF #1496535
10/24/2006: mgossage
[lua] added support for native methods & member function pointers.
fixed test cases arrays_dimensionless & cpp_basic. Added new example (functor).
tidied up a little of the code (around classHandler).
10/17/2006: wsfulton
[C#, Java] directorout typemap changes to fall in line with the other director
languages. $result is now used where $1 used to be used. Please change your typemaps
if you have a custom directorout typemap.
10/18/2006: wsfulton
Some fixes for applying the char array typemaps to unsigned char arrays.
10/17/2006: wsfulton
[C#, Java] Add in const size_t& and const std::size_t& typemaps.
10/15/2006: efuzzyone
[CFFI] Suppress generating defctype for enums, thanks to Arthur Smyles. Patch 1560983.
10/14/2006: wuzzeb (John Lenz)
[Chicken] Minor fix to make SWIG work with the (as yet unreleased) chicken 2.5
[Guile,Chicken] Fix SF Bug 1573892. Added an ext_test to the test suite to test
this bug, but this test can not really be made generic because the external code must
plug into the target language interpreter directly.
See Examples/test-suite/chicken/ext_test.i and ext_test_external.cxx
Added a %.externaltest to, and any interested language modules can
copy and slightly modify either the chicken or the guile ext_test.i
10/14/2006: mgossage
[Lua] added OUTPUT& for all number types, added a long long type
fixed several test cases.
update: changed typemaps to use SWIG_ConvertPtr rather than SWIG_MustGetPointer
started spliting lua.swg into smaller parts to make it neater
10/13/2006: wsfulton
[C#, Java] Marginally better support for multiple inheritance only in that you can
control what the base class is. This is done using the new 'replace' attribute in the
javabase/csbase typemap, eg in the following, 'Me' will be the base class,
no matter what Foo is really derived from in the C++ layer.
%typemap(javabase, replace="1") Foo "Me";
%typemap(csbase, replace="1") Foo "Me";
Previously it was not possible for the javabase/csbase typemaps to override the C++ base.
10/12/2006: wsfulton
[Java] Remove potential race condition on the proxy class' delete() method
(it is now a synchronized method, but is now customisable by changing the
methodmodifiers attribute in the the javadestruct or javadestruct_derived typemap)
[C#] Remove potential race condition on the proxy class' Dispose() method,
similar to Java's delete() above.
10/12/2006: wsfulton
[Ruby, Python] Remove redundant director code in %extend methods (%extend
methods cannot be director methods)
10/12/2006: wsfulton
[Ruby, Python] Fix #1505594 - director objects not returned as director objects
in %extend methods.
10/11/2006: wsfulton
[Java] Fix #1238798 - Directors using unsigned long long or any other type
marshalled across the JNI boundary using a Java class (where the jni typemap
contains jobject).
10/06/2006: wsfulton
Fix #1162194 - #include/%include within a structure
10/06/2006: wsfulton
Fix #1450661, string truncation in String_seek truncating Java/C# enums.
10/06/2006: mgossage
[Lua] Fix #1569587. The name is now correct.
10/04/2006: wsfulton
Director fixes for virtual conversion operators
10/04/2006: olly
[php] Fix #1569587 for PHP. Don't use sizeof() except with string
literals. Change some "//" comments to "/* */" for portability.
10/04/2006: mgossage
[Lua] Partial Fix #1569587. The type is now correct, but the name is still not correct.
10/03/2006: wsfulton
[Ruby] Fix #1527885 - Overloaded director virtual methods sometimes produced
uncompileable code when used with the director:except feature.
10/03/2006: wsfulton
Directors: Directors are output in the order in which they are declared in
the C++ class rather than in some pseudo-random order.
10/03/2006: mmatus
Fix #1486281 and #1471039.
10/03/2006: olly
[Perl] Fix for handling strings with zero bytes from Stephen Hutsal.
09/30/2006: efuzzyone
[CFFI] Bitfield support and vararg support due to Arthur Smyles.
C expression to Lisp conversion, thanks to Arthur Smyles for the initial
idea, it now supports conversion for a whole range of C expressions.
09/28/2006: wsfulton
Fix #1508327 - Overloaded methods are hidden when using -fvirtual optimisation.
Overloaded methods are no longer candidates for elimination - this mimics
C++ behaviour where all overloaded methods must be defined and implemented
in a derived class in order for them to be available.
09/25/2006: wsfulton
[Ruby, Python, Ocaml] Fix #1505591 Throwing exceptions in extended directors
09/25/2006: wsfulton
Fix #1056100 - virtual operators.
09/24/2006: olly
Don't accidentally create a "<:" token (which is the same as "[" in C++).
Fixes bug # 1521788.
09/23/2006: olly
[Ruby] Support building with recent versions of the Ruby 1.9
development branch. Fixes bug #1560092.
09/23/2006: olly
Templates can now be instantiated using negative numbers and
constant expressions, e.g.:
template<int q> class x {};
%template(x_minus1) x<-1>;
%template(x_1plus2) x<1+2>;
Also, constant expressions can now include comparisons (>, <, >=,
<=, !=, ==), modulus (%), and ternary conditionals (a ? b : c).
Fixes bugs #646275, #925555, #956282, #994301.
09/22/2006: wsfulton
Fix %ignore on director methods - Bugs #1546254, #1543533
09/20/2006: wsfulton
Fix %ignore on director constructors
09/20/2006: wsfulton
Fix seg faults and asserts when director methods are ignored (#1543533)
09/20/2006: wsfulton
Fix out of source builds - bug #1544718
09/20/2006: olly
Treat a nested class definition as a forward declaration rather
than ignoring it completely, so that we generate correct code for
passing opaque pointers to the nested class (fixes SF bug #909387).
09/20/2006: olly
[php] Overload resolution now works. However to allow this, SWIG
generated wrappers no longer coerce PHP types (which reverts a change
made in 1.3.26). So for example, if a method takes a string, you
can no longer pass a number without explicitly converting it to a
string in PHP using: (string)x
09/18/2006: mgossage
[ALL] fix on swiginit.swg, has been reported to crash on several test cases
found and fixed problem in imports under python (mingw)
09/16/2006: wsfulton
[Python] Patch from Michal Marek for Python 2.5 to fix 64 bit array indexes on
64 bit machines.
09/13/2006: wsfulton
The explicitcall feature has been scrapped. This feature was introduced primarily
to solve recursive director method calls. Director upcall improvements made instead:
[Python, Ruby, Ocaml] The swig_up flag is no longer used. The required mutexes
wrapping this flag are also no longer needed. The recursive calls going from C++
to the target language and back again etc are now avoided by a subtlely different
approach. Instead of using the swig_up flag in each director method to indicate
whether the explicit C++ call to the appropriate base class method or a normal
polymorphic C++ call should be made, the new approach makes one of these calls
directly from the wrapper method.
[Java, C#] The recursive call problem when calling a C++ base class method from
Java/C# is now fixed. The implementation is slightly different to the other languages
as the detection as to whether the explicit call or a normal polymorphic call is made
in the Java/C# layer rather than in the C++ layer.
09/11/2006: mgossage
[ALL] updated swiginit.swg to allow multiple interpreters to use multiple
swig modules at once. This has been tested in Lua (mingw & linux),
perl5 & python (linux) only.
09/11/2006: mgossage
[lua] added support for passing function pointers as well as native lua object
into wrappered function.
Added example funcptr3 to demonstrate this feature
09/05/2006: olly
[php] Rename ErrorCode and ErrorMsg #define-s to SWIG_ErrorCode
and SWIG_ErrorMsg to avoid clashes with code the user might be
wrapping (patch from Darren Warner in SF bug #1466086). Any
user typemaps which use ErrorCode and/or ErrorMsg directly will
need adjusting - you can easily fix them to work with both old
and new SWIG by changing to use SWIG_ErrorMsg and adding:
#ifndef SWIG_ErrorMsg
#define SWIG_ErrorMsg() ErrorMsg()
08/29/2006: olly
[php] Move constant initialisation from RINIT to MINIT to fix a
warning when using Apache and mod_php. We only need to create
PHP constants once when we're first initialised, not for every HTTP
08/21/2006: mgossage
Bugfix #1542466 added code to allow mapping Lua nil's <-> C/C++ NULL's
updated various typemaps to work correctly with the changes
added voidtest_runme.lua to show the features working
08/19/2006: wuzzeb (John Lenz)
[Guile] Add feature:constasvar to export constants as variables instead of functions
that return the constant value.
08/11/2006: wsfulton
[Java] DetachCurrentThread calls have been added so that natively created threads
no longer prevent the JVM from exiting. Bug reported by Thomas Dudziak and
Paul Noll.
08/10/2006: wsfulton
[C#] Fix director protected methods so they work
07/25/2006: mutandiz
more additions to std::string, some tweaks and small bug fixes
-nocwrap mode.
07/21/2006: mgossage
Bugfix #1526022 pdated std::string to support strings with '\0' inside them
updated typemaps.i to add support for pointer to pointers
07/19/2006: mutandiz
- Add std_string.i support.
- Add newobject patch submitted by mkoeppe (thanks!)
- Fix type name mismatch issue for nested type definitions.
specifically typedefs in templated class defns.
07/18/2006: mgossage
Bugfix #1522858
updated lua.cxx to support -external-runtime command
07/14/2006: wuzzeb (John Lenz)
Increment the SWIG_RUNTIME_VERSION to 3, because of the
addition of the owndata member in swig_type_info.
Reported by: Prabhu Ramachandran
07/05/2006: wsfulton
Search path fixes:
- Fix search path for library files to behave as documented in Library.html.
- Fix mingw/msys builds which did not find the SWIG library when installed.
- Windows builds also output the mingw/msys install location when running
swig -swiglib.
- The non-existent and undocumented config directory in the search path has
been removed.
07/05/2006: wsfulton
Fix $symname special variable expansion.
07/04/2006: wuzzeb (John Lenz)
Add %feature("constasvar"), which instead of exporting a constant as a
scheme function, exports the constant as a scheme variable. Update the
documentation as well.
07/04/2006: wsfulton
[See entry of 09/13/2006 - explicitcall feature and documentation to it removed]
New explicitcall feature which generates additional wrappers for virtual methods
that call the method explicitly, not relying on polymorphism to make the method
call. The feature is a feature flag and is enabled like any other feature flag.
It also recognises an attribute, "suffix" for mangling the feature name, see
SWIGPlus.html#SWIGPlus_explicitcall documentation for more details.
[Java, C#]
The explicitcall feature is also a workaround for solving the recursive calls
problem when a director method makes a call to a base class method. See
Java.html#java_directors_explicitcall for updated documentation.
06/28/2006: joe (Joseph Wang)
[r] Initial support for R
06/20/2006: wuzzeb (John Lenz)
Minor fixes to get apply_strings.i testsuite to pass
Remove integers_runme.scm from the testsuite, because SWIG and Chicken does
handle overflows.
06/19/2005: olly
[php] Add support for generating PHP5 class wrappers for C++
classes (use "swig -php5").
06/17/2006: olly
[php] Added some missing keywords to the PHP4 keyword list, and
fixed __LINE__ and __FILE__ which were in the wrong category.
Also added all the keywords new in PHP5, and added comments
noting the PHP4 keywords which aren't keywords in PHP5.
06/17/2006: olly
[php] Don't segfault if PHP Null is passed as this pointer (e.g.
Class_method(Null)) - give a PHP Error instead.
06/15/2006: mutandiz
Add initial support for std::list container class.
Fix a few bugs in helper functions.
05/13/2006: wsfulton
[Java] Replace JNIEXPORT with SWIGEXPORT, thereby enabling the possibility
of using gcc -fvisibility=hidden for potentially smaller faster loading wrappers.
05/13/2006: wsfulton
Fix for Makefiles for autoconf-2.60 beta
05/13/2006: wsfulton
Vladimir Menshakov patch for compiling wrappers with python-2.5 alpha.
05/12/2006: wsfulton
Fix buffer overflow error when using large %feature(docstring) reported
by Joseph Winston.
05/12/2006: wsfulton
[Perl] Operator overload fix from Daniel Moore.
05/25/2006: mutandiz
Fix bug in generation of CLOS type declarations for unions
and equivalent types.
05/24/2006: mutandiz
Don't require a full class definition to generate a CLOS wrapper.
05/20/2006: olly
[php] GCC Visibility support now works with PHP.
05/19/2006: olly
[php] Removed support for -dlname (use -module instead). Fixed
naming of PHP extension module to be consistent with PHP
conventions (no "php_" prefix on Unix; on PHP >= 4.3.0, handle Unix
platforms which use something other than ".so" as the extension.)
05/13/2006: wsfulton
[C#] Director support added
05/07/2006: olly
[php] Don't segfault if PHP Null is passed where a C++ reference
is wanted.
05/05/2006: olly
[php] Fix wrappers generated for global 'char' variables to not
include a terminating zero byte in the PHP string.
05/03/2006: wsfulton
Modify typemaps so that char * can be applied to unsigned char * or signed char *
types and visa versa.
05/03/2006: efuzzyone
[cffi]Thanks to Luke J Crook for this idea.
- a struct/enum/union is replaced with :pointer only if
that slot is actually a pointer to that type. So,:
struct a_struct { int x; } and
struct b_struct { a_struct struct_1; };
will be converted as:
(cffi:defcstruct b_struct
(struct_1 a_struct))
- Other minor fixes in lispifying names.
05/02/2006: wsfulton
Fix possible redefinition of _CRT_SECURE_NO_DEPRECATE for VC++.
04/14/2006: efuzzyone
Thanks to Thomas Weidner for the patch.
- when feature export is set (export 'foo) is
generated for every symbol
- when feature inline is set (declaim (inline foo)) is
generated before every function definition
- when feature intern_function is set
#.(value-of-intern-function "name" "nodeType" package)
is emitted instead of the plain symbol. A sample swig-lispify
is provided.
- every symbol is prefixed by it's package.
04/13/2006: efuzzyone
Fixed the generation of wrappers for global variables.
Added the option [no]swig-lisp which turns on/off generation
of code for swig helper lisp macro, functions, etc.
Version 1.3.29 (March 21, 2006)
04/05/2006: mutandiz
Fix output typemap of char so it produces a character instead
of an integer. Also adds input/output typemaps for 'char *'.
add command-line argument -isolate to generate an interface
file that won't interfere with other SWIG generated files that
may be used in the same application.
03/20/2005: mutandiz
More tweaks to INPUT/OUTPUT typemaps for bool.
Fix constantWrapper for char and string literals.
find-definition keybindings should work in ELI/SLIME.
Output (in-package <module-name>) to lisp wrapper
instead of (in-package #.*swig-module-name*).
slight rework of multiple return values.
doc updates.
03/17/2005: mutandiz
mangle names of constants generated via constantWrapper.
When using OUTPUT typemaps and the function has a non-void
return value, it should be first in the values-list, followed
by the OUTPUT mapped values.
Fix bug with boolean parameters, which needed to be
passed in as int values, rather than T or NIL.
03/15/2006: mutandiz
Generate wrappers for constants when in C++ or -cwrap mode.
Make -cwrap the default, since it is most correct. Users
can use the -nocwrap option to avoid the creation of a .cxx
file when interfacing to C code.
When in -nocwrap mode, improve the handling of converting
infix literals to prefix notation for lisp. This is very
basic and not likely to be improved upon since this only
applies to the -nocwrap case. Literals we can't figure out
will result in a warning and be included in the generated
validIdentifier now more closely approximates what may be
a legal common lisp symbol.
Fix typemap error in allegrocl.swg
03/12/2006: mutandiz
fix up INPUT/OUTPUT typemaps for bool.
Generate c++ style wrapper functions for struct/union members
when -cwrap option specified.
03/10/2006: mutandiz
Fix bug in C wrapper generation introduced by last allegrocl
03/10/2006: wsfulton
Commit #1447337 - Delete LocalRefs at the end of director methods to fix potential leak
03/10/2006: wsfulton
Fix #1444949 - configure does not honor --program-prefix.
Removed non-standard configure option --with-release-suffix. Fix the autoconf standard
options --program-prefix and --program-suffix which were being shown in the help,
but were being ignored. Use --program-suffix instead of --with-release-suffix now.
03/10/2006: wsfulton
Fix #1446319 with patch from andreasth - more than one wstring parameter in director methods
03/07/2006: mkoeppe
Fix for module names containing a "-" in non-"shadow" mode.
Patch from Aaron VanDevender (#1441474).
03/04/2006: mmatus
- Add -O to the main program, which now enables -fastdispatch
- Add the -fastinit option to enable faster __init__
methods. Setting 'this' as 'self.this.append(this)' in the python
code confuses PyLucene. Now the initialization is done in the
the C++ side, as reported by Andi and Robin.
- Add the -fastquery option to enable faster SWIG_TypeQuery via a
python dict cache, as proposed by Andi Vajda
- Avoid to call PyObject_GetAttr inside SWIG_Python_GetSwigThis,
since this confuses PyLucene, as reported by Andi Vajda.
03/02/2006: wsfulton
Removed extra (void *) cast when casting pointers to and from jlong as this
was suppressing gcc's "dereferencing type-punned pointer will break strict-aliasing rules"
warning. This warning could be ignored in versions of gcc prior to 4.0, but now the
warning is useful as gcc -O2 and higher optimisation levels includes -fstrict-aliasing which
generates code that doesn't work with these casts. The assignment is simply never made.
Please use -fno-strict-aliasing to both suppress the warning and fix the bad assembly
code generated. Note that the warning is only generated by the C compiler, but not
the C++ compiler, yet the C++ compiler will also generate broken code. Alternatively use
-Wno-strict-aliasing to suppress the warning for gcc-3.x. The typemaps affected
are the "in" and "out" typemaps in java.swg and arrays_java.swg. Users ought to fix
their own typemaps to do the same. Note that removal of the void * cast simply prevents
suppression of the warning for the C compiler and nothing else. Typical change:
%typemap(in) SWIGTYPE * %{ $1 = *($&1_ltype)(void *)&$input; %}
%typemap(in) SWIGTYPE * %{ $1 = *($&1_ltype)&$input; %}
%typemap(out) SWIGTYPE * %{ *($&1_ltype)(void *)&$result = $1; %}
%typemap(out) SWIGTYPE * %{ *($&1_ltype)&$result = $1; %}
03/02/2006: mkoeppe
[Guile -scm]
Add typemaps for "long long"; whether the generated code compiles, however, depends
on the version and configuration of Guile.
03/02/2006: wsfulton
Add support for inner exceptions. If any of the delegates are called which construct
a pending exception and there is already a pending exception, it will create the new
exception with the pending exception as an inner exception.
03/02/2006: wsfulton
Added support for Php5 exceptions if compiling against Php5 (patch from Olly Betts).
03/01/2006: mmatus
Use the GCC visibility attribute in SWIGEXPORT.
Now you can compile (with gcc 3.4 or later) using
Check the difference for the 'std_containers.i' python
test case:
Exported symbols (nm -D <file>.so | wc -l):
Excecution times:
real 0m0.050s user 0m0.039s sys 0m0.005s
real 0m0.039s user 0m0.026s sys 0m0.007s
Read for more details.
02/27/2006: mutandiz
Add support for INPUT, OUTPUT, and INOUT typemaps.
For OUTPUT variables, the lisp wrapper returns multiple
02/26/2006: mmatus
[Ruby] add argcargv.i library file.
Use it as follow:
%include argcargv.i
%apply (int ARGC, char **ARGV) { (size_t argc, const char **argv) }
%inline {
int mainApp(size_t argc, const char **argv)
return argc;
then in the ruby side:
args = ["asdf", "asdf2"]
n = mainApp(args);
This is the similar to the python version Lib/python/argcargv.i
02/24/2006: mgossage
Small update Lua documents on troubleshooting problems
02/22/2006: mmatus
Fix all the errors reported for 1.3.28.
- fix bug #1158178
- fix bug #1060789
- fix bug #1263457
- fix 'const char*&' typemap in the UTL, reported by Geoff Hutchison
- fixes for python 2.1 and the runtime library
- fix copyctor + template bug #1432125
- fix [ 1432152 ] %rename friend operators in namespace
- fix gcc warning reported by R. Bernstein
- avoid assert when finding a recursive scope inheritance,
emit a warning in the worst case, reported by Nitro
- fix premature object deletion reported by Paul in tcl3d
- fix warning reported by Nitro in VC7
- more fixes for old Solaris compiler
- fix for python 2.3 and gc_refs issue reported by Luigi
- fix fastproxy for methods using kwargs
- fix overload + protected member issue reported by Colin McDonald
- fix seterrormsg as reported by Colin McDonald
- fix directors, now the test-suite runs again using -directors
- fix for friend operator and Visual studio and bug 1432152
- fix bug #1435090
- fix using + %extend as reported by William
- fix bug #1094964
- fix for Py_NotImplemented as reported by Olly and Amaury
- fix nested namespace issue reported by Charlie
and also:
- allow director protected members by default
- delete extra new lines in swigmacros[UTL]
- cosmetic for generated python code
- add the factory.i library for UTL
- add swigregister proxy method and move __repr__ to a
single global module [python]
02/22/2006: mmatus
When using directors, now swig will emit all the virtual
protected methods by default.
In previous releases, you needed to use the 'dirprot'
option to acheive the same.
If you want, you can disable the new default behaviour,
use the 'nodirprot' option:
swig -nodirprot ...
and/or the %nodirector feature for specific methods, i.e.:
%nodirector Foo::bar;
struct Foo {
virtual ~Foo();
virtual void bar();
As before, pure abstract protected members are allways
emitted, independent of the 'dirprot/nodirprot' options.
02/22/2006: mmatus
Add the factory.i library for languages using the UTL (python,tcl,ruby,perl).
factory.i implements a more natural wrap for factory methods.
For example, if you have:
---- geometry.h --------
struct Geometry {
enum GeomType{
virtual ~Geometry() {}
virtual int draw() = 0;
// Factory method for all the Geometry objects
static Geometry *create(GeomType i);
struct Point : Geometry {
int draw() { return 1; }
double width() { return 1.0; }
struct Circle : Geometry {
int draw() { return 2; }
double radius() { return 1.5; }
// Factory method for all the Geometry objects
Geometry *Geometry::create(GeomType type) {
switch (type) {
case POINT: return new Point();
case CIRCLE: return new Circle();
default: return 0;
---- geometry.h --------
You can use the %factory with the Geometry::create method as follows:
%newobject Geometry::create;
%factory(Geometry *Geometry::create, Point, Circle);
%include "geometry.h"
and Geometry::create will return a 'Point' or 'Circle' instance
instead of the plain 'Geometry' type. For example, in python:
circle = Geometry.create(Geometry.CIRCLE)
r = circle.radius()
where 'circle' now is a Circle proxy instance.
02/17/2006: mkoeppe
[MzScheme] Typemaps for all integral types now accept the full range of integral
values, and they signal an error when a value outside the valid range is passed.
[Guile] Typemaps for all integral types now signal an error when a value outside
the valid range is passed.
02/13/2006: mgossage
[Documents] updated the extending documents to give a skeleton swigging code
with a few typemaps.
[Lua] added an extra typemap for void* [in], so a function which requires a void*
can take any kind of pointer
Version 1.3.28 (February 12, 2006)
02/11/2006: mmatus
Fix many issues with line counting and error reports.
02/11/2006: mmatus
[Python] Better static data member support, if you have
struct Foo {
static int bar;
then now is valid to access the static data member, ie:
f = Foo() = 3
just as in C++.
02/11/2006: wsfulton
Fixed code generation to work again with old versions of Perl
(5.004 and later tested)
02/04/2006: mmatus
[Python] Add the %extend_smart_pointer() directive to extend
SWIG smart pointer support in python.
For example, if you have a smart pointer as:
template <class Type> class RCPtr {
RCPtr(Type *p);
Type * operator->() const;
you use the %extend_smart_pointer directive as:
%template(RCPtr_A) RCPtr<A>;
then, if you have something like:
RCPtr<A> make_ptr();
int foo(A *);
you can do the following:
a = make_ptr();
b = foo(a);
ie, swig will accept a RCPtr<A> object where a 'A *' is
Also, when using vectors
%template(RCPtr_A) RCPtr<A>;
%template(vector_A) std::vector<RCPtr<A> >;
you can type
a = A();
v = vector_A(2)
v[0] = a
ie, an 'A *' object is accepted, via implicit conversion,
where a RCPtr<A> object is expected. Additionally
x = v[0]
returns (and sets 'x' as) a copy of v[0], making reference
counting possible and consistent.
%extend_smart_pointer is just a collections of new/old
tricks, including %typemaps and the new %implicitconv
02/02/2006: mgossage
bugfix #1356577, changed double=>lua_number in a few places.
added the std::pair wrapping
01/30/2006: wsfulton
std::string and std::wstring member variables and global variables now use
%naturalvar by default, meaning they will now be wrapped as expected in all languages.
Previously these were wrapped as a pointer rather than a target language string.
It is no longer necessary to add the following workaround to wrap these as strings:
%apply const std::string & { std::string *}
01/28/2006: mkoeppe
[Guile -scm]
Add typemaps for handling of member function pointers.
01/24/2006: mmatus
- Better support for the %naturalvar directive, now it
works with the scripting languages as well as
Now, it can also be applied to class types:
%naturalvar std::string;
%include <std_string.i>
that will tell swig to use the the 'natural' wrapping
mechanism to all std::string global and member
- Add support for the %allowexcept feature along the
scripting languages, which allows the %exception feature
to be applied to the variable access methods. Also, add
the %exceptionvar directive to specify a distintic
exception mechanism only for variables.
- Add more docs for the %delobject directive to mark a method as a
destructor, 'disowning' the first argument. For example:
%newobject create_foo;
%delobject destroy_foo;
Foo *create_foo() { return new Foo(); }
void destroy_foo(Foo *foo) { delete foo; }
or in a member method as:
%delobject Foo::destroy;
class Foo {
void destroy() { delete this;}
01/24/2006: mgossage
- Removed the type swig_lua_command_info & replace with luaL_reg
(which then broke the code), fixed this
- added an additional cast in the typemaps for enum's
due to the issue that VC.Net will not allow casting of
a double to an enum directly. Therefore cast to int then to enum
(thanks to Jason Rego for this observation)
01/16/2006: mmatus (Change disabled... will be back in CVS soon)
Add initial support for regexp via the external library
RxSpencer. SWIG doesn't require this library to compile
and/or run. But if you specify --with-rxspencer, and the
library is found during installation, then swig will use
it in three places:
- In %renames rules, via the new rxsmatch rules, for example:
%rename("%(lowercase)",rxsmatch$name="GSL_.*") "";
%rename("%(lowercase)",rxsmatch$nodeType="enum GSL_.*") "";
rxsmatch is similar to the match rule, it just uses
the RxSpencer regexp library to decide if there is a
match with the provided regexp. As with the match
rule, you can also use the negate rule notrxsmatch.
- In the %rename target name via the rxstarget option, for example:
%rename("%(lowercase)",rxstarget=1) "GSL_.*";
where the target name "GSL.*" is now understood as a
regexp to be matched.
- In the new encoder "rxspencer", which looks like:
where "regexp" is the regular expression and "replace"
is a string used as a replacement, where the @0,@1,...,@9
pseudo arguments are used to represent the
corresponding matching items in the reg expression.
For example:
%(rxspencer:[GSL.*][@0])s <- Hello ->
%(rxspencer:[GSL.*][@0])s <- GSLHello -> GSLHello
%(rxspencer:[GSL(.*)][@1])s <- GSLHello -> Hello
%(rxspencer:[GSL(.*)][gsl@1])s <- GSLHello -> gslHello
Another example could be:
%rename("%(lowercase)s",sourcefmt="%(rxspencer:[GSL_(.*)][@1])s",%$isfunction) "";
which take out the prefix "GSL_" and returns all the
function names in lower cases, as following:
void GSL_Hello(); -> hello();
void GSL_Hi(); -> hi();
const int GSL_MAX; -> GSL_MAX; // no change, is not a function
We use the RxSpencer as an initial test bed to
implemention while we decide which library will be
finally added to swig.
You can obtain the RxSpencer library from (Unix)
or (Windows)
Once installed, use "man rxspencer" to get more info
about the regexp format, or just google rxspencer.
Since now you can enable the rxsmatch rules (see above),
the simple or '|' support for the match rules
(01/12/2006: mmatus) is disabled. Still, if you have
problems with the rxspencer library, you can re-enable
the simple 'match or' support using
01/16/2006: mmatus
Change the %rename predicates to use the prefix '%$', as in:
%rename("%(utitle)s",%$isfunction,%$ismember) "";
to avoid clashings with other swig macros/directives.
01/14/2006: cfisavage
Added support for Ruby bang! methods via a new %bang feature.
Bang methods end in exclamation points and indicate that the
object being processed will be modified in-place as
opposed to being copied.
01/12/2006: cfisavage
Updated the Ruby module to automatically convert
method names to lower_case_with_underscores using the
new %rename functionality.
01/12/2006: mmatus
- Add aliases for 'case' encoders used with %rename/%namewarn
%(uppercase)s hello_world -> HELLO_WORLD
%(lowercase)s HelloWorld -> helloworld
%(camelcase)s hello_world -> HelloWorld
%(undercase)s HelloWorld -> hello_world
01/12/2006: mmatus
- Add the -dump_parse_module and -dump_parse_top options,
which are similar to -dump_module and -dump_top, but they
dump the node trees just after parsing, showing only the
attributes visible at the parsing stage, and not the added
later in typemap.cxx, allocate.cxx, lang.cxx or elsewhere.
Besides debugging porpuses, these options are very useful
if you plan to use %rename in an "advance way", since it
shows only and all the node's attributes you can use
inside the match rules.
01/12/2006: mmatus
- Add predicates to %rename, so, you don't need to
remember, for example, how to match a member function.
Now it is easy, for example to use the 'utitle' encoder
in all the member methods, you type:
%rename("%(utitle)s",%isfunction,%ismember) "";
or to ignore all the enumitems in a given class:
%rename("$ignore", %isenumitem, %classname="MyClass") "";
Available predicates are (see swig.swg):
These predicates correspond to specific 'match'
declarations, which sometimes are not as evident as the
predicates names.
- Add the or '|' operation in %rename match, for
example to capitalize all the constants (%constant or
const cdecl):
%rename("%(upper)s",match="cdecl|constant",%isimmutable) "";
01/12/2006: mgossage
- Partial fixed of errors under C89, bug #1356574
(converted C++ style comments to C style)
- Added patches from #1379988 and #1388343
missing a 'return' statement for error conditions
also updated the %init block bug #1356586
01/10/2006: mmatus
- Add the 'utitle' encoder, as an example of how to add
your own encoder. I added the encoder method in misc.c
but developers can add others, the same way, inside any
target language.
Well, 'utitle' is the reverse of 'ctitle', ie:
%rename("%(ctitle)s") camel_case; -> CamelCase;
%rename("%(utitle)s") CamelCase; -> camel_case;
01/10/2006: cfisavage
Updated Ruby Exception handling. Classes that are specified in throws clauses,
or are marked as %exceptionclass, are now inherited from rb_eRuntimeError.
This allows instances of these classes to be returned to Ruby as exceptions.
Thus if a C++ method throws an instance of MyException, the calling Ruby
method will get back a MyException object. To see an example,
look at ruby/examples/exception_class.
01/10/2006: mmatus
- Add the %catches directive, which complements the %exception
directive in a more automatic way. For example, if you have
int foo() throw(E1);
swig generates the proper try/catch code to dispatch E1.
But if you have:
int barfoo(int i) {
if (i == 1) {
throw E1();
} else {
throw E2();
return 0;
ie, where there is no explicit exception specification in the decl, you
end up doing:
%exception barfoo {
try {
} catch(E1) { ... }
} catch(E2) { ... }
which is very tedious. Well, the %catches directive defines
the list of exceptions to catch, and from swig:
%catches(E1,E2) barfoo(int i);
int barfoo(int i);
is equivalent to
int barfoo(int i) throw(E1,E2);
Note, however, that the %catches list doesn't have to
correspond to the C++ exception specification. For example, if you
struct E {};
struct E1 : E {};
struct E2 : E {};
int barfoo(int i) throw(E1,E2);
you can define
%catches(E) barfoo(int i);
and swig will generate an action code equivalent to
try {
} catch(E &_e) {
<raise _e>;
Of course, you still have to satisfy the C++ restrictions,
and the catches list must be compatible (not the same)
as the original list of types in the exception specification.
Also, you can now specify that you want to catch the
unknown exception '...', for example:
%catches(E1,E2,...) barfoo(int);
In any case, the %catches directive will emit the
code to convert into the target language error/exception
using the 'throws' typemap.
For the '...' case to work, you need to
write the proper typemap in your target language. In the
UTL, this looks like:
%typemap(throws) (...) {
SWIG_exception(SWIG_RuntimeError,"unknown exception");
01/09/2006: mutandiz
Fixes a number of SEGVs primarily in the handling of
various anonymous types. Found in a pass through the
swig test-suite. Still more to do here, but this is a
good checkpoint.
Adds -cwrap and -nocwrap as an allegrocl specific
command-line argument. Controls generating of a C
wrapper file when wrapping C code. By default only a
lisp file is created for C code wrapping.
Doc updates for the command-line arguments and fixes as
pointed out on swig-devel
01/05/2006: wsfulton
[Java] Fix unsigned long long and const unsigned long long & typemaps
- Bug #1398394 with patch from Dries Decock
01/06/2006: mmatus
Add 'named' warning codes, now in addition to:
you can use
just use the same code name found in Source/Include/swigwarn.h
plus the 'SWIG' prefix.
If a developer adds a new warning code, the Lib/swigwarn.swg file
will be generated when running the top level make.
01/05/2006: cfisavage
Reimplemented object tracking for Ruby. The new implementation works
by expanding the swig_class structure for Ruby by adding a trackObjects
field. This field can be set/unset via %trackobjects as explained
in the Ruby documentation. The new implementation is more robust
and takes less code to implement.
01/05/2006: wsfulton
Fix for %extend and static const integral types, eg:
class Foo {
%extend {
static const int bar = 42;
12/30/2005: mmatus
- Add info for old and new debug options:
-dump_top - Print information of the entire node tree, including system nodes
-dump_module - Print information of the module node tree, avoiding system nodes
-dump_classes - Print information about the classes found in the interface
-dump_typedef - Print information about the types and typedefs found in the interface
-dump_tags - Print information about the tags found in the interface
-debug_typemap - Print information for debugging typemaps
-debug_template - Print information for debugging templates
- Add the fakeversion. If you have a project that uses
configure/, or another automatic building system
and requires a specific swig version, let say 1.3.22
you can use:
SWIG_FEATURES="-fakeversion 1.3.22"
swig -fakeversion 1.3.22
and then swig -version will report 1.3.22 instead of the
current version.
Typical use would be
SWIG_FEATURES="-fakeversion 1.3.22" ./configure
12/30/2005: mmatus
- Add option/format support to %rename and %namewarn.
Now %namewarn can force renaming, for example:
%namewarn("314: import is a keyword",rename="_%s") "import";
and rename can also support format forms:
%rename("swig_%s") import;
Now, since the format is processed via swig Printf, you
can use encoders as follows:
%rename("%(title)s") import; -> Import
%rename("%(upper)s") import; -> IMPORT
%rename("%(lower)s") Import; -> import
%rename("%(ctitle)s") camel_case; -> CamelCase
This will allow us to add more encoders, as the
expected one for regular expressions.
- Add the above 'ctitle' encoder, which does the camel case:
camel_case -> CamelCase
- Also, while we get the regexp support, add the 'command' encoder,
you can use it as follows
%rename("%(command:sed -e 's/\([a-z]\)/\U\\1/' <<< )s") import;
then swig will popen the command
"sed -e 's/\([a-z]\)/\U\\1/' <<< import"
see below for anonymous renames for better examples.
- The rename directive now also allows:
- simple match: only apply the rename if a type match
happen, for example
%rename(%(title)s,match="enumitem") hello;
enum Hello {
hi, hello -> hi, Hello
int hello() -> hello;
- extended match: only apply the rename if the 'extended attribute' match
occurred, for example:
// same as simple match
%rename(%(title)s,match$nodeType="enumitem") hello;
enum Hello {
hi, hello -> hi, Hello
Note that the symbol '$' is used to define the attribute name in
a 'recursive' way, for example:
// match only hello in 'enum Hello'
%rename(%(title)s,match$parentNode$type="enum Hello") hello;
enum Hello {
hi, hello -> hi, Hello // match
enum Hi {
hi, hello -> hi, hello // no match
here, for Hello::hi, the "parentNode" is "Hello", and its "type"
is "enum Hello".
- Anonymous renames: you can use 'anonymous' rename directives, for example:
// rename all the enum items in Hello
%rename(%(title)s,match$parentNode$type="enum Hello") "";
enum Hello {
hi, hello -> Hi, Hello // match both
enum Hi {
hi, hello -> hi, hello // no match
// rename all the enum items
%rename(%(title)s,match$nodeType="enumitem") "";
// rename all the items in given command (sloooow, but...)
%rename(%(command:<my external cmd>)s) "";
Anonymous renames with commands can be very powerful, since you
can 'outsource' all the renaming mechanism (or part of it) to an
external program:
// Uppercase all (and only) the names that start with 'i'
%rename("%(command:awk '/^i/{print toupper($1)}' <<<)s") "";
int imported() -> IMPORTED;
int hello() -> hello
Note that if the 'command' encoder returns an empty string, swig
understands that no rename is necessary.
Also note that %rename 'passes' the matched name. For example, in
this case
namespace ns1 {
int foo();
namespace ns2 {
int bar();
the external program only receives "foo" and "bar". If needed,
however, you can request the 'fullname'
%rename("%(command:awk 'awk '/ns1::/{l=split($1,a,"::"); print toupper(a[l])}'' <<<)s",fullname=1) "";
ns1::foo -> FOO
ns2::bar -> bar
- Mixing encoders and matching: of course, you can do mix commands
and match fields, for example:
%rename("%(<my encoder for fncs>)",match="cdecl") "";
%rename("%(<my encoder for enums>)",match="enumitem") "";
%rename("%(<my encoder for enums inside a class>)",match="enumitem",
match$parentNode$parentNode$nodeType="class") "";
Use "swig -dump_parse_module" to see the attribute names you can use to
match a specific case.
- 'sourcefmt' and 'targetfmt': sometimes you need to
process the 'source' name before comparing, for example
%namewarn("314: empty is a keyword",sourcefmt="%(lower)s") "empty";
then if you have
int Empty(); // "Empty" is the source
you will get the keyword warning since 'Empty' will be
lower cased, via the sourcefmt="%(lower)s" option,
before been compared to the 'target' "empty".
There is an additional 'targetfmt' option to process the
'target' before comparing.
- complementing 'match': you can use 'notmatch', for example
%namewarn("314: empty is a keyword",sourcefmt="%(lower)s",notmatch="namespace") "empty";
here, the name warning will be applied to all the symbols except namespaces.
12/30/2005: mmatus
- Add initial support for gcj and Java -> <target language> mechanism.
See examples in:
to see how to use gcj+swig to export java classes into
The idea is to put all the common code for gcj inside
and localize specific types such as jstring, as can be found
Using the UTL, this is very easy, and the perl version for
jstring.i will be next.
12/29/2005: mmatus
- Add the copyctor feature/directive/option to enable the automatic
generation of copy constructors. Use as in:
%copyctor A;
struct A {
then this will work
a1 = A();
a2 = A(a1);
Also, since it is a feature, if you just type
that will enable the automatic generation for all the
classes. It is also equivalent to
swig -copyctor -c++ ...
1.- The feature only works in C++ mode.
2.- The automatic creation of the copy constructor will
usually produce overloading. Hence, if the target
language doesn't support overloading, a special name
will be used (A_copy).
3.- For the overloading reasons above, it is probably not
a good idea to use the flag when, for example, you are
using keywords in Python.
4.- The copyctor automatic mechanism follows more or less
the same rules as the default constructor mechanism,
i.e., a copy constructor will not be added if the
class is abstract or if there is a pertinent non-public
copy ctor in the class or its hierarchy.
Hence, it might be necessary for you to complete the
class declaration with the proper non-public copy ctor
to avoid a wrong constructor addition.
- Fix features/rename for templates ctor/dtor and other
things around while adding the copyctor mechanism.
12/27/2005: mmatus
- Add the 'match' option to typemaps. Assume you have:
%typemap(in) SWIGTYPE * (int res) {..}
%typemap(freearg) SWIGTYPE * { if (res$argnum) ...}
then if you do
%typemap(in) A * {...}
swig will 'overload the 'in' typemap, but the 'freearg'
typemap will be also applied, even when this is wrong. The old
solutions is to write:
%typemap(in) A * {...}
%typemap(freeag) A * "";
overload 'freearg' with an empty definition.
The problem is, however, there is no way to know you need
to do that until you start getting broken C++ code, or
worse, broken runtime code.
The same applies to the infamous 'typecheck' typemap,
which always confuses people, since the first thing you do
is to just write the 'in' typemap.
The 'match' option solves the problem, and if instead you write:
%typemap(in) SWIGTYPE * (int res) {..}
%typemap(freearg,match="in") SWIGTYPE * { if (res$argnum) ...}
%typemap(typecheck,match="in",precedence...) SWIGTYPE * {...}
it will tell swig to apply the 'freearg/typecheck'
typemaps only if they 'match' the type of the 'in'
typemap. The same can be done with other typemaps as:
%typemap(directorout) SWIGTYPE * {...}
%typemap(directorfree,match="directorout") SWIGTYPE * {...}
12/27/2005: mmatus
- Add the 'naturalvar' option/mode/feature to treat member
variables in a more natural way, ie, similar to the global
variable behavior.
You can use it in a global way via the command line
swig -naturalvar ...
or the module mode option
both forms make swig treat all the member variables in the
same way it treats global variables.
Also, you can use it in a case by case approach for
specific member variables using the directive form:
%naturalvar Bar::s;
Then, in the following case for example:
std::string s;
struct Bar {
std::string s;
you can do:
b = Bar()
b.s ="hello"
cvar.s = "hello"
if (b.s != cvar.s):
raise RuntimeError
This is valid for all the languages, and the
implementation is based on forcing the use of the
const SWIGTYPE& (C++)/SWIGTYPE (C) typemaps for the
get/set methods instead of the SWIGTYPE * typemaps.
Hence, for 'naturalvar' to work, each target language
must implement 'typemap(in/out) const Type&' properly.
The 'naturalvar' option replaces or makes workarounds such as:
%apply const std::string & { std::string *}
Note1: If your interface has other kinds of workarounds to
deal with the old 'unnatural' way to deal with member
variables (returning/expecting pointers), the
'naturalvar' option could break them.
Note2: the option has no effect on unnamed types, such
as unnamed nested unions.
12/27/2005: mmatus
- Add more 'expressive' result states for the typemap
In the past, for scripting languages, you would do checking something like:
if (ConvertPtr(obj,&vptr,ty,flags) != -1) {
// success
} else {
// error
Now the result state can carry more information,
- Error state: like the old -1/0, but with error codes from swigerrors.swg.
int res = ConvertPtr(obj,&vptr,ty,flags);
if (SWIG_IsOK(res)) {
// success code
} else {
SWIG_Error(res); // res carries the error code
- Cast rank: when returning a simple successful
conversion, you just return SWIG_OK, but if you need
to do a 'cast', you can add the casting rank, ie:
if (PyFloat_Check(obj)) {
value = PyFloat_AsDouble(obj);
return SWIG_OK;
} else if (PyInt_Check(obj)) {
value = (double) PyInt_AsLong(obj);
return SWIG_AddCast(SWIG_OK);
later, the casting rank is used to properly dispatch
the overloaded function, for example. This of course
requires your language to support and use the new
dispatch cast/rank mechanism (Now mainly supported in
perl and python, and easily expandable to ruby and tcl).
- [UTL] Add support for the new 'expressive' result states.
12/27/2005: mmatus
- Add support for the C++ implicit conversion mechanism, which
required some modifications in parser.y (to recognize
'explicit') and overload.cxx (to replace $implicitconv as
Still, real support in each target language requires each
target language to be modified. Python provides an example,
see below.
- Add support for native C++ implicit conversions, ie, if you
%implicitconv A;
struct A {
int ii;
A() {ii = 1;}
A(int) {ii = 2;}
A(double) {ii = 3;}
explicit A(char *s) {ii = 4;}
int get(const A& a) {return a.ii;}
you can call:
a = A()
ai = A(1)
ad = A(1.0)
as = A("hello")
# old forms
get(a) -> 1
get(ai) -> 2
get(ad) -> 3
get(as) -> 4
#implicit conversions
get(1) -> 2
get(1.0) -> 3
get("hello") -> Error, explicit constructor
Also, as in C++, now implicit conversions are supported in
variable assigments, and if you have:
A ga;
struct Bar {
A a;
you can do: = A(1) = 1 = 1.0 = A("hello")