diff --git a/ANNOUNCE b/ANNOUNCE index 6f0247f56..825837614 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,8 +1,8 @@ -*** ANNOUNCE: SWIG 2.0.5 (in progress) *** +*** ANNOUNCE: SWIG 2.0.6 (30 April 2012) *** http://www.swig.org -We're pleased to announce SWIG-2.0.5, the latest SWIG release. +We're pleased to announce SWIG-2.0.6, the latest SWIG release. What is SWIG? ============= @@ -21,11 +21,11 @@ Availability ============ The release is available for download on Sourceforge at - http://prdownloads.sourceforge.net/swig/swig-2.0.5.tar.gz + http://prdownloads.sourceforge.net/swig/swig-2.0.6.tar.gz A Windows version is also available at - http://prdownloads.sourceforge.net/swig/swigwin-2.0.5.zip + http://prdownloads.sourceforge.net/swig/swigwin-2.0.6.zip Please report problems with this release to the swig-devel mailing list, details at http://www.swig.org/mail.html. diff --git a/CHANGES b/CHANGES index 185d57d45..70af78333 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,446 @@ SWIG (Simplified Wrapper and Interface Generator) See the CHANGES.current file for changes in the current version. See the RELEASENOTES file for a summary of changes in each release. +Version 2.0.5 (19 April 2012) +============================= + +2012-04-14: wsfulton + [Lua] Apply patch #3517435 from Miles Bader - prefer to use Lua_pushglobaltable + +2012-04-14: wsfulton + [Ruby] Apply patch #3517769 from Robin Stocker to fix compile error on MacRuby using RSTRING_PTR. + +2012-04-13: wsfulton + Apply patch #3511009 from Leif Middelschulte for slightly optimised char * variable wrappers. + +2012-04-13: wsfulton + [Lua] Apply #3219676 from Shane Liesegang which adds: + - support for %factory + - a __tostring method + - a __disown method + +2012-04-13: wsfulton + [Xml] Apply #3513569 which adds a catchlist to the xml output. + +2012-04-05: olly + [Lua] Add support for Lua 5.2 (patch SF#3514593 from Miles Bader) + +2012-03-26: xavier98 + [octave] Apply patch #3425993 from jgillis: add extra logic to the octave_swig_type::dims(void) method: it checks if the user has defined a __dims__ method and uses this in stead of returning (1,1) + [octave] Apply patch #3424833 from jgillis: make is_object return true for swig types + +2012-03-24: wsfulton + [D] Apply #3502431 to fix duplicate symbols in multiple modules. + +2012-03-21: wsfulton + Fix #3494791 - %$isglobal for %rename matching. + +2012-03-20: wsfulton + Fix #3487706 and #3391906 - missing stddef.h include for ptrdiff_t when using %import + for STL containers and compiling with g++-4.6. An include of stddef.h is now only + generated when SWIG generates STL helper templates which require ptrdiff_t. If you + were previously relying on "#include " always being generated when using a + %include of an STL header, you may now need to add this in manually. + +2012-03-16: wsfulton + Apply patch #3392264 from Sebastien Bine to parse (unsigned) long long types in enum value assignment. + +2012-03-16: wsfulton + Apply patch #3505530 from Karl Wette to allow custom allocators in STL string classes for the UTL languages. + +2012-03-13: wsfulton + Apply patch #3468362 from Karl Wette to fix %include inside %define. + +2012-03-13: wsfulton + [Python, Ruby, Octave, R] Fix #3475492 - iterating through std::vector wrappers of enumerations. + +2012-02-27: xavier98 (patches from Karl Wette) + [Octave] Use -globals . to load global variables in module namespace + [Octave] Comment declaration of unimplemented function swig_register_director + [Octave] Fix OCTAVE_PATH in octave Makefiles + [Octave] Add support for std::list - fix li_std_containers_int test + [Octave] Fix imports test + +2012-02-16: wsfulton + [Java] Make generated support functions in arrays_java.i static so that generated code + from multiple instances of SWIG can be compiled and linked together - problem reported by + Evan Krause. + +2012-01-24: wsfulton + Fix crash with bad regex - bug #3474250. + +2012-01-24: wsfulton + [Python] Add Python stepped slicing support to the STL wrappers (std::vector, std::list). + Assigning to a slice, reading a slice and deleting a slice with steps now work. + For example: + + %template(vector_i) std::vector + + vi = vector_i(range(10)) + print list(vi) + vi[1:4:2] = [111, 333] + print list(vi) + del vi[3:10:3] + print list(vi) + print list(vi[::-1]) + + gives (same behaviour as native Python sequences such as list): + + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + [0, 111, 2, 333, 4, 5, 6, 7, 8, 9] + [0, 111, 2, 4, 5, 7, 8] + [8, 7, 5, 4, 2, 111, 0] + +2012-01-23: klickverbot + [D] Correctly annotate function pointers with C linkage. + [D] Exception and Error have become blessed names; removed d_exception_name test case. + +2012-01-20: wsfulton + [Python] Fix some indexing bugs in Python STL wrappers when the index is negative, eg: + + %template(vector_i) std::vector + + iv=vector_i([0,1,2,3,4,5]) + iv[-7:] + + now returns [0, 1, 2, 3, 4, 5] instead of [5]. + + vv[7:9] = [22,33] + + now returns [0, 1, 2, 3, 4, 5, 22, 33] instead of "index out range" error. + + Also fix some segfaults when replacing ranges, eg when il is a std::list wrapper: + + il[0:2] = [11] + +2012-01-17: wsfulton + [Go] Fix forward class declaration within a class when used as a base. + +2012-01-07: wsfulton + [C#] Add support for %nspace when using directors. + +2012-01-06: wsfulton + [Java] Patch #3452560 from Brant Kyser - add support for %nspace when using directors. + +2011-12-21: wsfulton + The 'directorin' typemap now accepts $1, $2 etc expansions instead of having to use workarounds - + $1_name, $2_name etc. + +2011-12-20: wsfulton + [Java] Add (char *STRING, size_t LENGTH) director typemaps. + +2011-12-20: wsfulton + [C#, Go, Java, D] Add support for the 'directorargout' typemap. + +2011-12-20: wsfulton + [Ocaml, Octave, PHP, Python, Ruby] Correct special variables in 'directorargout' typemap. + This change will break any 'directorargout' typemaps you may have written. Please change: + $result to $1 + $input to $result + + Also fix the named 'directorargout' DIRECTOROUT typemaps for these languages which didn't + previously compile and add in $1, $2 etc expansion. + + *** POTENTIAL INCOMPATIBILITY *** + +2011-12-10: talby + [perl5] SWIG_error() now gets decorated with perl source file/line number. + [perl5] error handling now conforms to public XS api (fixes perl v5.14 issue). + +2011-12-10: wsfulton + [Android/Java] Fix directors to compile on Android. + + Added documentation and examples for Android. + +2011-12-08: vadz + Bug fix: Handle methods renamed or ignored in the base class correctly in the derived classes + (they could be sometimes mysteriously not renamed or ignored there before). + +2011-12-03: klickverbot + [D] Fix exception glue code for newer DMD 2 versions. + [D] Do not default to 32 bit glue code for DMD anymore. + [D] Use stdc.config.c_long/c_ulong to represent C long types. + +2011-12-01: szager + [python] Fixed bug 3447426: memory leak in vector.__getitem__. + +2011-11-30: wsfulton + [R] Remove C++ comments from generated C code. + +2011-11-27: olly + [Python] Fix some warnings when compiling generated wrappers with + certain GCC warning options (Debian bug #650246). + +2011-11-28: wsfulton + Fix #3433541 %typemap(in, numinputs=0) with 10+ arguments. + +2011-11-28: olly + [Perl] Fix warnings when compiling generated wrappers with certain + GCC warning options (Debian bug #436711). + +2011-11-28: olly + [PHP] Update keyword list to include keywords added in PHP releases up to 5.3. + +2011-11-25: wsfulton + [C#] Provide an easy way to override the default visibility for the proxy class pointer + constructors and getCPtr() method. The visibility is 'internal' by default and if multiple + SWIG modules are being used and compiled into different assemblies, then they need to be + 'public' in order to use the constructor or getCPtr() method from a different assembly. + Use the following macros to change the visibilities in the proxy and type wrapper class: + + SWIG_CSBODY_PROXY(public, public, SWIGTYPE) + SWIG_CSBODY_TYPEWRAPPER(public, public, public, SWIGTYPE) + + [Java] Provide an easy way to override the default visibility for the proxy class pointer + constructors and getCPtr() method. The visibility is 'protected' by default and if multiple + SWIG modules are being used and compiled into different packages, then they need to be + 'public' in order to use the constructor or getCPtr() method from a different package. + Use the following macros to change the visibilities in the proxy and type wrapper class: + + SWIG_JAVABODY_PROXY(public, public, SWIGTYPE) + SWIG_JAVABODY_TYPEWRAPPER(public, public, public, SWIGTYPE) + + The default for Java has changed from public to protected for the proxy classes. Use the + SWIG_JAVABODY_PROXY macro above to restore to the previous visibilities. + + *** POTENTIAL INCOMPATIBILITY *** + +2011-11-22: szager + [python] Bug 3440044: #ifdef out SWIG_Python_NonDynamicSetAttr if -builtin + isn't being used, to avoid unnecessary binary incompatibilities between + python installations. + +2011-11-17: wsfulton + Bug fix: Remove root directory from directory search list in Windows. + +2011-11-13: wsfulton + [Ruby] Apply patch #3421876 from Robin Stocker to fix #3416818 - same class name in + different namespaces confusion when using multiple modules. + +2011-11-11: wsfulton + Fix pcre-build.sh to work with non-compressed tarballs - problem reported by Adrian Blakely. + +2011-11-03: wsfulton + Expand special variables in typemap warnings, eg: + + %typemap(in, warning="1000:Test warning for 'in' typemap for $1_type $1_name") int "..." + +2011-11-01: wsfulton + Fix named output typemaps not being used when the symbol uses a qualifier and contains + a number, eg: + + %typemap(out) double ABC::m1 "..." + +2011-10-24: talby + [perl5] SF bug #3423119 - overload dispatch stack corruption fix. Better, but more research + is needed on a stable path for tail calls in XS. + + Also, fix for large long longs in 32 bit perl. + +2011-10-13: xavier98 + [octave] Allow Octave modules to be re-loaded after a "clear all". + +2011-09-19: wsfulton + Fix regression introduced in swig-2.0.1 reported by Teemu Ikonone leading to uncompilable code + when using typedef and function pointer references, for example: + + typedef int FN(const int &a, int b); + void *typedef_call1(FN *& precallback, FN * postcallback); + +2011-09-14: wsfulton + [Lua] Patch #3408012 from Raman Gopalan - add support for embedded Lua (eLua) + including options for targeting Lua Tiny RAM (LTR). + +2011-09-14: wsfulton + [C#] Add boost_intrusive_ptr.i library contribution from patch #3401571. + +2011-09-13: wsfulton + Add warnings for badly named destructors, eg: + + struct KStruct { + ~NOT_KStruct() {} + }; + + cpp_extend_destructors.i:92: Warning 521: Illegal destructor name ~NOT_KStruct. Ignored. + +2011-09-13: wsfulton + Fix %extend and destructors for templates. The destructor in %extend was not always wrapped, + for example: + + %extend FooT { + ~FooT() { delete $self; } // was not wrapped as expected + }; + template class FooT {}; + %template(FooTi) FooT; + +2011-09-13: wsfulton + Fix special variables such as "$decl" and "$fulldecl" in destructors to include the ~ character. + +2011-09-10: talby + [perl5] SF bug #1481958 - Improve range checking for integer types. + Enhance li_typemaps_runme.pl + +2011-09-08: wsfulton + Fix %extend on typedef classes in a namespace using the typedef name, for example: + namespace Space { + %extend CStruct { + ... + } + typedef struct tagCStruct { ... } CStruct; + } + +2011-08-31: xavier98 + [octave] patches from Karl Wette: improvements to module loading behavior; + added example of friend operator to operator example; fixed octave panic/crash in 3.0.5; + documentation improvements + +2011-08-30: szager + [python] Bug 3400486, fix error signalling for built-in constructors. + +2011-08-26: wsfulton + [Go] Fix file/line number display for "gotype" when using typemap debugging options + -tmsearch and -tmused. + +2011-08-26: wsfulton + [C#, D] Fix %callback which was generating uncompileable code. + +2011-08-25: wsfulton + Fix constructors in named typedef class declarations as reported by Gregory Bronner: + + typedef struct A { + A(){} // Constructor which was not accepted by SWIG + B(){} // NOT a constructor --illegal, but was accepted by SWIG + } B; + + For C code, the fix now results in the use of 'struct A *' instead of just 'B *' in + the generated code when wrapping members in A, but ultimately this does not matter, as + they are the same thing. + +2011-08-23: wsfulton + Fix %newobject when used in conjunction with %feature("ref") as reported by Jan Becker. The + code from the "ref" feature was not always being generated for the function specified by %newobject. + Documentation for "ref" and "unref" moved from Python to the C++ chapter. + +2011-08-22: szager + [python] Fixed memory leak with --builtin option (bug 3385089). + +2011-08-22: wsfulton + [Lua] SF patch #3394339 from Torsten Landschoff - new option -nomoduleglobal to disable installing + the module table into the global namespace. Require call also returns the module table instead + of a string. + +2011-08-09: xavier98 + Fix bug 3387394; Octave patches for 3.4.0 compatibility, etc. (from Karl Wette) + +2011-08-04: wsfulton + Add in $symname expansion for director methods. + +2011-07-29: olly + [PHP] Don't generate "return $r;" in cases where $r hasn't been set. + This was basically harmless, except it generated a PHP E_NOTICE if + the calling code had enabled them. + +2011-07-26: wsfulton + Fix scoping of forward class declarations nested within a class (for C++). Previously the symbol + was incorrectly put into the outer namespace, eg + + namespace std { + template struct map { + class iterator; + } + } + + iterator was scoped as std::iterator, but now it is correctly std::map::iterator; + + Also fixed is %template and template parameters that are a typedef when the template contains + default template parameters, eg: + + namespace Std { + template struct Map { + typedef Key key_type; + typedef T mapped_type; + } + } + tyepdef double DOUBLE; + %typemap(MM) Std::Map; + + All symbols within Map will be resolved correctly, eg key_type and mapped_type no matter if the + wrapped code uses Std::Map or std::Map or Std::Map + + Also fixes bug #3378145 - regression introduced in 2.0.4 - %template using traits. + +2011-07-20 szager + [python] Fix closure for tp_call slot. + +2011-07-16: wsfulton + [python] Fix director typemap using PyObject *. + +2011-07-13: szager + [python] SF patch #3365908 - Add all template parameters to map support code in std_map.i + +2011-07-13: szager + [python] Fix for bug 3324753: %rename member variables with -builtin. + +2011-07-01: wsfulton + Fix some scope and symbol lookup problems when template default parameters are being + used with typedef. For example: + + template struct Foo { + typedef XX X; + typedef TT T; + }; + template struct UsesFoo { + void x(typename Foo::T, typename Foo::X); + }; + + Also fixes use of std::vector::size_type for Python as reported by Aubrey Barnard. + +2011-06-23: olly + [PHP] Fix director code to work when PHP is built with ZTS enabled, + which is the standard configuration on Microsoft Windows. + +2011-06-21: mutandiz + [allegrocl] + - various small tweaks and bug fixes. + - Avoid name conflicts between smart pointer wrappers and the wrappers for + the actual class. + - Fix default typemaps for C bindings, which were incorrectly attempting to + call non-existent destructors on user-defined types. + - New feature, feature:aclmixins, for adding superclass to the foreign class + wrappers. + - Improve longlong typemaps. + +2011-06-19: wsfulton + Fix incorrect typemaps being used for a symbol within a templated type, eg: + A::value_type would incorrectly use a typemap for type A. + +2011-06-18: olly + [Tcl] Fix variable declarations in middle of blocks which isn't + permitted in C90 (issue probably introduced in 2.0.3 by patch #3224663). + Reported by Paul Obermeier in SF#3288586. + +2011-06-17: wsfulton + [Java] SF #3312505 - slightly easier to wrap char[] or char[ANY] with a Java byte[] + using arrays_java.i. + +2011-06-13: wsfulton + [Ruby, Octave] SF #3310528 Autodoc fixes similar to those described below for Python. + +2011-06-10: wsfulton + [Python] Few subtle bugfixes in autodoc documentation generation, + - Unnamed argument names fix for autodoc levels > 0. + - Display of template types fixed for autodoc levels > 1. + - Fix SF #3310528 - display of typedef structs for autodoc levels > 1. + - Add missing type for self for autodoc levels 1 and 3. + - autodoc levels 2 and 3 documented. + - Minor tweaks to autodoc style to conform with PEP8. + +2011-05-30: olly + [PHP] Fix handling of directors when -prefix is used. + +2011-05-24: olly + [PHP] Fix handling of methods of classes with a virtual base class (SF#3124665). + Version 2.0.4 (21 May 2011) =========================== diff --git a/CHANGES.current b/CHANGES.current index aaadbad7c..cb64a7937 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -2,430 +2,16 @@ Below are the changes for the current release. See the CHANGES file for changes in older releases. See the RELEASENOTES file for a summary of changes in each release. -Version 2.0.5 (in progress) -=========================== +Version 2.0.6 (30 April 2012) +============================= -2012-04-05: olly - [Lua] Add support for Lua 5.2 (patch SF#3514593 from Miles Bader) +2012-04-25: wsfulton + [Lua] Fix uninitialised variable in SWIGTYPE **OUTPUT typemaps as reported by Jim Anderson. -2012-03-26: xavier98 - [octave] Apply patch #3425993 from jgillis: add extra logic to the octave_swig_type::dims(void) method: it checks if the user has defined a __dims__ method and uses this in stead of returning (1,1) - [octave] Apply patch #3424833 from jgillis: make is_object return true for swig types +2012-04-28: wsfulton + [Python] Fix compilation errors when wrapping STL containers on Mac OSX and possibly other systems. -2012-03-24: wsfulton - [D] Apply #3502431 to fix duplicate symbols in multiple modules and compiler errors due to lack - of const in some methods taking char*. - -2012-03-21: wsfulton - Fix #3494791 - %$isglobal for %rename matching. - -2012-03-20: wsfulton - Fix #3487706 and #3391906 - missing stddef.h include for ptrdiff_t when using %import - for STL containers and compiling with g++-4.6. An include of stddef.h is now only - generated when SWIG generates STL helper templates which require ptrdiff_t. If you - were previously relying on "#include " always being generated when using a - %include of an STL header, you may now need to add this in manually. - -2012-03-16: wsfulton - Apply patch #3392264 from Sebastien Bine to parse (unsigned) long long types in enum value assignment. - -2012-03-16: wsfulton - Apply patch #3505530 from Karl Wette to allow custom allocators in STL string classes for the UTL languages. - -2012-03-13: wsfulton - Apply patch #3468362 from Karl Wette to fix %include inside %define. - -2012-03-13: wsfulton - [Python, Ruby, Octave] Fix #3475492 - iterating through std::vector wrappers of enumerations. - -2012-02-27: xavier98 (patches from Karl Wette) - [Octave] Use -globals . to load global variables in module namespace - [Octave] Comment declaration of unimplemented function swig_register_director - [Octave] Fix OCTAVE_PATH in octave Makefiles - [Octave] Add support for nspace feature - fix director_nspace test - [Octave] Add support for std::list - fix li_std_containers_int test - [Octave] Fix imports test - -2012-02-16: wsfulton - [Java] Make generated support functions in arrays_java.i static so that generated code - from multiple instances of SWIG can be compiled and linked together - problem reported by - Evan Krause. - -2012-01-24: wsfulton - Fix crash with bad regex - bug #3474250. - -2012-01-24: wsfulton - [Python] Add Python stepped slicing support to the STL wrappers (std::vector, std::list). - Assigning to a slice, reading a slice and deleting a slice with steps now work. - For example: - - %template(vector_i) std::vector - - vi = vector_i(range(10)) - print list(vi) - vi[1:4:2] = [111, 333] - print list(vi) - del vi[3:10:3] - print list(vi) - print list(vi[::-1]) - - gives (same behaviour as native Python sequences such as list): - - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] - [0, 111, 2, 333, 4, 5, 6, 7, 8, 9] - [0, 111, 2, 4, 5, 7, 8] - [8, 7, 5, 4, 2, 111, 0] - -2012-01-23: klickverbot - [D] Correctly annotate function pointers with C linkage. - [D] Exception and Error have become blessed names; removed d_exception_name test case. - -2012-01-20: wsfulton - [Python] Fix some indexing bugs in Python STL wrappers when the index is negative, eg: - - %template(vector_i) std::vector - - iv=vector_i([0,1,2,3,4,5]) - iv[-7:] - - now returns [0, 1, 2, 3, 4, 5] instead of [5]. - - vv[7:9] = [22,33] - - now returns [0, 1, 2, 3, 4, 5, 22, 33] instead of "index out range" error. - - Also fix some segfaults when replacing ranges, eg when il is a std::list wrapper: - - il[0:2] = [11] - -2012-01-17: wsfulton - [Go] Fix forward class declaration within a class when used as a base. - -2012-01-07: wsfulton - [C#] Add support for %nspace when using directors. - -2012-01-06: wsfulton - [Java] Patch #3452560 from Brant Kyser - add support for %nspace when using directors. - -2011-12-21: wsfulton - The 'directorin' typemap now accepts $1, $2 etc expansions instead of having to use workarounds - - $1_name, $2_name etc. - -2011-12-20: wsfulton - [Java] Add (char *STRING, size_t LENGTH) director typemaps. - -2011-12-20: wsfulton - [C#, Go, Java, D] Add support for the 'directorargout' typemap. - -2011-12-20: wsfulton - [Ocaml, Octave, PHP, Python, Ruby] Correct special variables in 'directorargout' typemap. - This change will break any 'directorargout' typemaps you may have written. Please change: - $result to $1 - $input to $result - - Also fix the named 'directorargout' DIRECTOROUT typemaps for these languages which didn't - previously compile and add in $1, $2 etc expansion. - - *** POTENTIAL INCOMPATIBILITY *** - -2011-12-10: talby - [perl5] SWIG_error() now gets decorated with perl source file/line number. - [perl5] error handling now conforms to public XS api (fixes perl v5.14 issue). - -2011-12-10: wsfulton - [Android/Java] Fix directors to compile on Android. - - Added documentation and examples for Android. - -2011-12-08: vadz - Bug fix: Handle methods renamed or ignored in the base class correctly in the derived classes - (they could be sometimes mysteriously not renamed or ignored there before). - -2011-12-03: klickverbot - [D] Fix exception glue code for newer DMD 2 versions. - [D] Do not default to 32 bit glue code for DMD anymore. - [D] Use stdc.config.c_long/c_ulong to represent C long types. - -2011-12-01: szager - [python] Fixed bug 3447426: memory leak in vector.__getitem__. - -2011-11-30: wsfulton - [R] Remove C++ comments from generated C code. - -2011-11-27: olly - [Python] Fix some warnings when compiling generated wrappers with - certain GCC warning options (Debian bug #650246). - -2011-11-28: wsfulton - Fix #3433541 %typemap(in, numinputs=0) with 10+ arguments. - -2011-11-28: olly - [Perl] Fix warnings when compiling generated wrappers with certain - GCC warning options (Debian bug #436711). - -2011-11-28: olly - [PHP] Update keyword list to include keywords added in PHP releases up to 5.3. - -2011-11-25: wsfulton - [C#] Provide an easy way to override the default visibility for the proxy class pointer - constructors and getCPtr() method. The visibility is 'internal' by default and if multiple - SWIG modules are being used and compiled into different assemblies, then they need to be - 'public' in order to use the constructor or getCPtr() method from a different assembly. - Use the following macros to change the visibilities in the proxy and type wrapper class: - - SWIG_CSBODY_PROXY(public, public, SWIGTYPE) - SWIG_CSBODY_TYPEWRAPPER(public, public, public, SWIGTYPE) - - [Java] Provide an easy way to override the default visibility for the proxy class pointer - constructors and getCPtr() method. The visibility is 'protected' by default and if multiple - SWIG modules are being used and compiled into different packages, then they need to be - 'public' in order to use the constructor or getCPtr() method from a different package. - Use the following macros to change the visibilities in the proxy and type wrapper class: - - SWIG_JAVABODY_PROXY(public, public, SWIGTYPE) - SWIG_JAVABODY_TYPEWRAPPER(public, public, public, SWIGTYPE) - - The default for Java has changed from public to protected for the proxy classes. Use the - SWIG_JAVABODY_PROXY macro above to restore to the previous visibilities. - - *** POTENTIAL INCOMPATIBILITY *** - -2011-11-22: szager - [python] Bug 3440044: #ifdef out SWIG_Python_NonDynamicSetAttr if -builtin - isn't being used, to avoid unnecessary binary incompatibilities between - python installations. - -2011-11-17: wsfulton - Bug fix: Remove root directory from directory search list in Windows. - -2011-11-13: wsfulton - [Ruby] Apply patch #3421876 from Robin Stocker to fix #3416818 - same class name in - different namespaces confusion when using multiple modules. - -2011-11-11: wsfulton - Fix pcre-build.sh to work with non-compressed tarballs - problem reported by Adrian Blakely. - -2011-11-04: szager - [python] Bug 3429388: python unsigned integer handling on 32-bit architectures. - -2011-11-03: wsfulton - Expand special variables in typemap warnings, eg: - - %typemap(in, warning="1000:Test warning for 'in' typemap for $1_type $1_name") int "..." - -2011-11-01: wsfulton - Fix named output typemaps not being used when the symbol uses a qualifier and contains - a number, eg: - - %typemap(out) double ABC::m1 "..." - -2011-10-24: talby - [perl5] SF bug #3423119 - overload dispatch stack corruption fix. Better, but more research - is needed on a stable path for tail calls in XS. - - Also, fix for large long longs in 32 bit perl. - -2011-10-13: xavier98 - [octave] Allow Octave modules to be re-loaded after a "clear all". - -2011-09-19: wsfulton - Fix regression introduced in swig-2.0.1 reported by Teemu Ikonone leading to uncompilable code - when using typedef and function pointer references, for example: - - typedef int FN(const int &a, int b); - void *typedef_call1(FN *& precallback, FN * postcallback); - -2011-09-14: wsfulton - [Lua] Patch #3408012 from Raman Gopalan - add support for embedded Lua (eLua) - including options for targeting Lua Tiny RAM (LTR). - -2011-09-14: wsfulton - [C#] Add boost_intrusive_ptr.i library contribution from patch #3401571. - -2011-09-13: wsfulton - Add warnings for badly named destructors, eg: - - struct KStruct { - ~NOT_KStruct() {} - }; - - cpp_extend_destructors.i:92: Warning 521: Illegal destructor name ~NOT_KStruct. Ignored. - -2011-09-13: wsfulton - Fix %extend and destructors for templates. The destructor in %extend was not always wrapped, - for example: - - %extend FooT { - ~FooT() { delete $self; } // was not wrapped as expected - }; - template class FooT {}; - %template(FooTi) FooT; - -2011-09-13: wsfulton - Fix special variables such as "$decl" and "$fulldecl" in destructors to include the ~ character. - -2011-09-10: talby - [perl5] SF bug #1481958 - Improve range checking for integer types. - Enhance li_typemaps_runme.pl - -2011-09-08: wsfulton - Fix %extend on typedef classes in a namespace using the typedef name, for example: - namespace Space { - %extend CStruct { - ... - } - typedef struct tagCStruct { ... } CStruct; - } - -2011-08-31: xavier98 - [octave] patches from Karl Wette: improvements to module loading behavior; - added example of friend operator to operator example; fixed octave panic/crash in 3.0.5; - documentation improvements - -2011-08-30: szager - [python] Bug 3400486, fix error signalling for built-in constructors. - -2011-08-26: wsfulton - [Go] Fix file/line number display for "gotype" when using typemap debugging options - -tmsearch and -tmused. - -2011-08-26: wsfulton - [C#, D] Fix %callback which was generating uncompileable code. - -2011-08-25: wsfulton - Fix constructors in named typedef class declarations as reported by Gregory Bronner: - - typedef struct A { - A(){} // Constructor which was not accepted by SWIG - B(){} // NOT a constructor --illegal, but was accepted by SWIG - } B; - - For C code, the fix now results in the use of 'struct A *' instead of just 'B *' in - the generated code when wrapping members in A, but ultimately this does not matter, as - they are the same thing. - -2011-08-23: wsfulton - Fix %newobject when used in conjunction with %feature("ref") as reported by Jan Becker. The - code from the "ref" feature was not always being generated for the function specified by %newobject. - Documentation for "ref" and "unref" moved from Python to the C++ chapter. - -2011-08-22: szager - [python] Fixed memory leak with --builtin option (bug 3385089). - -2011-08-22: wsfulton - [Lua] SF patch #3394339 from Torsten Landschoff - new option -nomoduleglobal to disable installing - the module table into the global namespace. Require call also returns the module table instead - of a string. - -2011-08-09: xavier98 - Fix bug 3387394; Octave patches for 3.4.0 compatibility, etc. (from Karl Wette) - -2011-08-04: wsfulton - Add in $symname expansion for director methods. - -2011-07-29: olly - [PHP] Don't generate "return $r;" in cases where $r hasn't been set. - This was basically harmless, except it generated a PHP E_NOTICE if - the calling code had enabled them. - -2011-07-26: wsfulton - Fix scoping of forward class declarations nested within a class (for C++). Previously the symbol - was incorrectly put into the outer namespace, eg - - namespace std { - template struct map { - class iterator; - } - } - - iterator was scoped as std::iterator, but now it is correctly std::map::iterator; - - Also fixed is %template and template parameters that are a typedef when the template contains - default template parameters, eg: - - namespace Std { - template struct Map { - typedef Key key_type; - typedef T mapped_type; - } - } - tyepdef double DOUBLE; - %typemap(MM) Std::Map; - - All symbols within Map will be resolved correctly, eg key_type and mapped_type no matter if the - wrapped code uses Std::Map or std::Map or Std::Map - - Also fixes bug #3378145 - regression introduced in 2.0.4 - %template using traits. - -2011-07-20 szager - [python] Fix closure for tp_call slot. - -2011-07-16: wsfulton - [python] Fix director typemap using PyObject *. - -2011-07-13: szager - [python] SF patch #3365908 - Add all template parameters to map support code in std_map.i - -2011-07-13: szager - [python] Fix for bug 3324753: %rename member variables with -builtin. - -2011-07-01: wsfulton - Fix some scope and symbol lookup problems when template default parameters are being - used with typedef. For example: - - template struct Foo { - typedef XX X; - typedef TT T; - }; - template struct UsesFoo { - void x(typename Foo::T, typename Foo::X); - }; - - Also fixes use of std::vector::size_type for Python as reported by Aubrey Barnard. - -2011-06-23: olly - [PHP] Fix director code to work when PHP is built with ZTS enabled, - which is the standard configuration on Microsoft Windows. - -2011-06-21: mutandiz - [allegrocl] - - various small tweaks and bug fixes. - - Avoid name conflicts between smart pointer wrappers and the wrappers for - the actual class. - - Fix default typemaps for C bindings, which were incorrectly attempting to - call non-existent destructors on user-defined types. - - New feature, feature:aclmixins, for adding superclass to the foreign class - wrappers. - - Improve longlong typemaps. - -2011-06-19: wsfulton - Fix incorrect typemaps being used for a symbol within a templated type, eg: - A::value_type would incorrectly use a typemap for type A. - -2011-06-18: olly - [Tcl] Fix variable declarations in middle of blocks which isn't - permitted in C90 (issue probably introduced in 2.0.3 by patch #3224663). - Reported by Paul Obermeier in SF#3288586. - -2011-06-17: wsfulton - [Java] SF #3312505 - slightly easier to wrap char[] or char[ANY] with a Java byte[] - using arrays_java.i. - -2011-06-13: wsfulton - [Ruby, Octave] SF #3310528 Autodoc fixes similar to those described below for Python. - -2011-06-10: wsfulton - [Python] Few subtle bugfixes in autodoc documentation generation, - - Unnamed argument names fix for autodoc levels > 0. - - Display of template types fixed for autodoc levels > 1. - - Fix SF #3310528 - display of typedef structs for autodoc levels > 1. - - Add missing type for self for autodoc levels 1 and 3. - - autodoc levels 2 and 3 documented. - - Minor tweaks to autodoc style to conform with PEP8. - -2011-05-30: olly - [PHP] Fix handling of directors when -prefix is used. - -2011-05-24: olly - [PHP] Fix handling of methods of classes with a virtual base class (SF#3124665). +2012-04-28: wsfulton + [Java] Patch 3521811 from Leo Davis - char **STRING_ARRAY typemaps fixed to handle + null pointers. diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 105bbcf7e..4af66298c 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -263,8 +263,11 @@
  • Macro Expansion
  • SWIG Macros
  • C99 and GNU Extensions +
  • Preprocessing and delimiters +
  • Preprocessor and Typemaps
  • Viewing preprocessor output
  • The #error and #warning directives diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index a420b2864..8abeada81 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -102,8 +102,8 @@ swig -go -help -gccgo-46 Generate code for gccgo 4.6. The default is set by the configure - script. This generates code that does not use some facilities - that are only available in gccgo 4.7 and later. + script. This generates code that does not use some facilities + that are only available in gccgo 4.7 and later. diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index 8523f8119..ec32c4449 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -67,7 +67,7 @@

    -Lua is an extension programming language designed to support general procedural programming with data description facilities. It also offers good support for object-oriented programming, functional programming, and data-driven programming. Lua is intended to be used as a powerful, light-weight configuration language for any program that needs one. Lua is implemented as a library, written in clean C (that is, in the common subset of ANSI C and C++). Its also a really tiny language, less than 6000 lines of code, which compiles to <100 kilobytes of binary code. It can be found at http://www.lua.org +Lua is an extension programming language designed to support general procedural programming with data description facilities. It also offers good support for object-oriented programming, functional programming, and data-driven programming. Lua is intended to be used as a powerful, light-weight configuration language for any program that needs one. Lua is implemented as a library, written in clean C (that is, in the common subset of ANSI C and C++). It's also a really tiny language, less than 6000 lines of code, which compiles to <100 kilobytes of binary code. It can be found at http://www.lua.org

    eLua stands for Embedded Lua (can be thought of as a flavor of Lua) and offers the full implementation of the Lua programming language to the embedded world, extending it with specific features for efficient and portable software embedded development. eLua runs on smaller devices like microcontrollers and provides the full features of the regular Lua desktop version. More information on eLua can be found here: http://www.eluaproject.net @@ -75,12 +75,14 @@ eLua stands for Embedded Lua (can be thought of as a flavor of Lua) and offers t

    26.1 Preliminaries

    +

    The current SWIG implementation is designed to work with Lua 5.0.x, 5.1.x and 5.2.x. It should work with later versions of Lua, but certainly not with Lua 4.0 due to substantial API changes. It is possible to either static link or dynamic link a Lua module into the interpreter (normally Lua static links its libraries, as dynamic linking is not available on all platforms). SWIG also supports eLua and works with eLua 0.8. SWIG generated code for eLua has been tested on Stellaris ARM Cortex-M3 LM3S and Infineon TriCore.

    26.2 Running SWIG

    +

    Suppose that you defined a SWIG module such as the following:

    @@ -108,7 +110,7 @@ $ swig -c++ -lua example.i This creates a C/C++ source file example_wrap.c or example_wrap.cxx. The generated C source file contains the low-level wrappers that need to be compiled and linked with the rest of your C/C++ application to create an extension module.

    -The name of the wrapper file is derived from the name of the input file. For example, if the input file is example.i, the name of the wrapper file is example_wrap.c. To change this, you can use the -o option. The wrappered module will export one function "int luaopen_example(lua_State* L)" which must be called to register the module with the Lua interpreter. The name "luaopen_example" depends upon the name of the module. +The name of the wrapper file is derived from the name of the input file. For example, if the input file is example.i, the name of the wrapper file is example_wrap.c. To change this, you can use the -o option. The wrapped module will export one function "int luaopen_example(lua_State* L)" which must be called to register the module with the Lua interpreter. The name "luaopen_example" depends upon the name of the module.

    To build an eLua module, run SWIG using -lua and add either -elua or -eluac. @@ -183,7 +185,7 @@ int main(int argc,char* argv[]) } L=lua_open(); luaopen_base(L); // load basic libs (eg. print) - luaopen_example(L); // load the wrappered module + luaopen_example(L); // load the wrapped module if (luaL_loadfile(L,argv[1])==0) // load and run the file lua_pcall(L,0,0,0); else @@ -216,8 +218,7 @@ For eLua, the source must be built along with the wrappers generated by SWIG. Ma _ROM( AUXLIB_MOD, luaopen_mod, mod_map )\ .... -

    -

    +
     /* Sample auxmods.h */
     #define AUXLIB_PIO       "pio"
    @@ -276,10 +277,10 @@ print(a,b,c)
     

    Note: for Lua 5.0:
    -The loadlib() function is in the global namespace, not in package. So its just loadlib(). +The loadlib() function is in the global namespace, not in a package. So it's just loadlib().

    -if 'a' is a function, this its all working fine, all you need to do is call it +if 'a' is a function, this is all working fine, all you need to do is call it

       a()
    @@ -288,7 +289,7 @@ if 'a' is a function, this its all working fine, all you need to do is call it
     to load your library which will add a table 'example' with all the functions added.
     

    -If it doesn't work, look at the error messages, in particular mesage 'b'
    +If it doesn't work, look at the error messages, in particular message 'b'
    The specified module could not be found.
    Means that is cannot find the module, check your the location and spelling of the module.
    The specified procedure could not be found.
    @@ -393,7 +394,7 @@ SWIG will effectively generate two functions example.Foo_set() and 4 5

    -Its is therefore not possible to 'move' the global variable into the global namespace as it is with functions. It is however, possible to rename the module with an assignment, to make it more convenient. +It is therefore not possible to 'move' the global variable into the global namespace as it is with functions. It is however, possible to rename the module with an assignment, to make it more convenient.

     > e=example
    @@ -404,7 +405,7 @@ Its is therefore not possible to 'move' the global variable into the global name
     4
     

    -If a variable is marked with the %immutable directive then any attempts to set this variable will cause an Lua error. Given a global variable: +If a variable is marked with the %immutable directive then any attempts to set this variable will cause a Lua error. Given a global variable:

    %module example
    @@ -510,13 +511,13 @@ When wrapped, you will be able to use the functions in a natural way from Lua. F
     > example.fclose(f)
     

    -Unlike many scripting languages, Lua has had support for pointers to C/C++ object built in for a long time. They are called 'userdata'. Unlike many other SWIG versions which use some kind of encoded character string, all objects will be represented as a userdata. The SWIG-Lua bindings provides a special function swig_type(), which if given a userdata object will return the type of object pointed to as a string (assuming it was a SWIG wrappered object). +Unlike many scripting languages, Lua has had support for pointers to C/C++ object built in for a long time. They are called 'userdata'. Unlike many other SWIG versions which use some kind of encoded character string, all objects will be represented as a userdata. The SWIG-Lua bindings provides a special function swig_type(), which if given a userdata object will return the type of object pointed to as a string (assuming it was a SWIG wrapped object).

     > print(f)
     userdata: 003FDA80
     > print(swig_type(f))
    -FILE * -- its a FILE*
    +FILE * -- it's a FILE*
     

    Lua enforces the integrity of its userdata, so it is virtually impossible to corrupt the data. But as the user of the pointer, you are responsible for freeing it, or closing any resources associated with it (just as you would in a C program). This does not apply so strictly to classes & structs (see below). One final note: if a function returns a NULL pointer, this is not encoded as a userdata, but as a Lua nil. @@ -560,10 +561,10 @@ If you print out the value of p in the above example, you will see something lik userdata: 003FA320

    -Like the pointer in the previous section, this is held as a userdata. However, additional features have been added to make this more usable. SWIG effectivly creates some accessor/mutator functions to get and set the data. These functions will be added to the userdata's metatable. This provides the natural access to the member variables that were shown above (see end of the document for full details). +Like the pointer in the previous section, this is held as a userdata. However, additional features have been added to make this more usable. SWIG effectively creates some accessor/mutator functions to get and set the data. These functions will be added to the userdata's metatable. This provides the natural access to the member variables that were shown above (see end of the document for full details).

    -const members of a structure are read-only. Data members can also be forced to be read-only using the immutable directive. As with other immutable's, setting attempts will be cause an error. For example: +const members of a structure are read-only. Data members can also be forced to be read-only using the immutable directive. As with other immutables, setting attempts will be cause an error. For example:

    struct Foo {
        ...
    @@ -686,7 +687,7 @@ In Lua, the static members can be accessed as follows:
     It is not (currently) possible to access static members of an instance:
     

    -> s=example.Spam()      -- s is a Spam instance
    +> s=example.Spam()              -- s is a Spam instance
     > s.foo()                       -- Spam::foo() via an instance
                                     -- does NOT work
     
    @@ -1183,7 +1184,7 @@ void throw_A() throw(A*) { }

    -SWIG will just convert it (poorly) to a string and use that as its error. (This is not that useful, but it always works). +SWIG will just convert it (poorly) to a string and use that as its error. (This is not that useful, but it always works).

    @@ -1259,7 +1260,7 @@ add exception specification to functions or globally (respectively).
     

    26.4 Typemaps

    -

    This section explains what typemaps are and the usage of them. The default wrapping behaviour of SWIG is enough in most cases. However sometimes SWIG may need a little additional assistance to know which typemap to apply to provide the best wrapping. This section will be explaining how to use typemaps to best effect

    +

    This section explains what typemaps are and how to use them. The default wrapping behaviour of SWIG is enough in most cases. However sometimes SWIG may need a little additional assistance to know which typemap to apply to provide the best wrapping. This section will be explaining how to use typemaps to best effect

    26.4.1 What is a typemap?

    @@ -1355,8 +1356,8 @@ extern void sort_double(double* arr, int len);

    There are basically two ways that SWIG can deal with this. The first way, uses the <carrays.i> library -to create an array in C/C++ then this can be filled within Lua and passed into the function. It works, but its a bit tedious. -More details can be found in the carrays.i documention.

    +to create an array in C/C++ then this can be filled within Lua and passed into the function. It works, but it's a bit tedious. +More details can be found in the carrays.i documentation.

    The second and more intuitive way, would be to pass a Lua table directly into the function, and have SWIG automatically convert between Lua-table and C-array. Within the <typemaps.i> file there are typemaps ready written to perform this task. To use them is again a matter of using %appy in the correct manner.

    @@ -1376,7 +1377,7 @@ extern void sort_int(int* arr, int len); // the function to wrap extern void sort_double(double* arr, int len); // the function to wrap -

    Once wrappered, the functions can both be called, though with different ease of use:

    +

    Once wrapped, the functions can both be called, though with different ease of use:

    require "example"
     ARRAY_SIZE=10
    @@ -1428,7 +1429,7 @@ free(ptr); // dispose of iMath
     

    SWIG has a ready written typemap to deal with such a kind of function in <typemaps.i>. It provides the correct wrapping as well as setting the flag to inform Lua that the object in question should be garbage collected. Therefore the code is simply:

    %include <typemaps.i>
    -%apply SWIGTYPE** OUTPUT{iMath **pptr }; // tell SWIG its an output
    +%apply SWIGTYPE** OUTPUT{iMath **pptr }; // tell SWIG it's an output
     
     struct iMath;    // some structure
     int Create_Math(iMath** pptr); // its creator (assume it mallocs)
    @@ -1436,7 +1437,7 @@ int Create_Math(iMath** pptr); // its creator (assume it mallocs)
     
     

    The usage is as follows:

    -
    ok,ptr=Create_Math() -- ptr is a iMath* which is returned with the int (ok)
    +
    ok,ptr=Create_Math() -- ptr is an iMath* which is returned with the int (ok)
     ptr=nil -- the iMath* will be GC'ed as normal
     
    @@ -1447,7 +1448,7 @@ ptr=nil -- the iMath* will be GC'ed as normal

    Before proceeding, it should be stressed that writing typemaps is rarely needed unless you want to change some aspect of the wrapping, or to achieve an effect which in not available with the default bindings.

    -

    Before proceeding, you should read the previous section on using typemaps, as well as read the ready written typemaps found in luatypemaps.swg and typemaps.i. These are both well documented and fairly easy to read. You should not attempt to write your own typemaps until you have read and can understand both of these files (they may well also give you a idea to base your worn on).

    +

    Before proceeding, you should read the previous section on using typemaps, and look at the existing typemaps found in luatypemaps.swg and typemaps.i. These are both well documented and fairly easy to read. You should not attempt to write your own typemaps until you have read and can understand both of these files (they may well also give you an idea to base your work on).

    26.5.1 Typemaps you can write

    @@ -1543,7 +1544,7 @@ The %native directive in the above example, tells SWIG that there is a

    -As well as adding additional C/C++ code, its also possible to add your own Lua code to the module as well. +As well as adding additional C/C++ code, it's also possible to add your own Lua code to the module as well. This code is executed once all other initialisation, including the %init code has been called.

    @@ -1568,7 +1569,7 @@ module name added.

    Should there be an error in the Lua code, this will not stop loading of the module. -The default behaviour of SWIG is to print a error message to stderr and then continue. +The default behaviour of SWIG is to print an error message to stderr and then continue. It is possible to change this behaviour by using a #define SWIG_DOSTRING_FAIL(STR) to define a different behaviour should the code fail.

    @@ -1655,7 +1656,7 @@ That way when you call 'a=example.Foo', the interpreter looks at the ta As mentioned earlier, classes and structures, are all held as pointer, using the Lua 'userdata' structure. This structure is actually a pointer to a C structure 'swig_lua_userdata', which contains the pointer to the data, a pointer to the swig_type_info (an internal SWIG struct) and a flag which marks if the object is to be disposed of when the interpreter no longer needs it. The actual accessing of the object is done via the metatable attached to this userdata.

    -The metatable is a Lua 5.0 feature (which is also why SWIG cannot wrap Lua 4.0). Its a table which holds a list of functions, operators and attributes. This is what gives the userdata the feeling that it is a real object and not just a hunk of memory. +The metatable is a Lua 5.0 feature (which is also why SWIG cannot wrap Lua 4.0). It's a table which holds a list of functions, operators and attributes. This is what gives the userdata the feeling that it is a real object and not just a hunk of memory.

    Given a class @@ -1672,10 +1673,10 @@ public: };

    -SWIG will create a module excpp, with all the various function inside. However to allow the intuitive use of the userdata is also creates up a set of metatables. As seen in the above section on global variables, use of the metatables allows for wrappers to be used intuitively. To save effort, the code creates one metatable per class and stores it inside Lua's registry. Then when an new object is instantiated, the metatable is found in the registry and the userdata associated to the metatable. Currently derived classes make a complete copy of the base classes table and then add on their own additional function. +SWIG will create a module excpp, with all the various functions inside. However to allow the intuitive use of the userdata, SWIG also creates up a set of metatables. As seen in the above section on global variables, use of the metatables allows for wrappers to be used intuitively. To save effort, the code creates one metatable per class and stores it inside Lua's registry. Then when a new object is instantiated, the metatable is found in the registry and the userdata associated with the metatable. Currently, derived classes make a complete copy of the base class' table and then add on their own additional functions.

    -Some of the internals can be seen by looking at a classes metatable. +Some of the internals can be seen by looking at the metatable of a class:

     > p=excpp.Point()
    @@ -1692,7 +1693,7 @@ __index function: 003FB698
     .fn     table: 003FB528
     

    -The '.type' attribute is the name of the class. The '.get' and '.set' tables work in a similar manner to the modules, the main difference is the '.fn' table which also holds all the member functions. (The '__gc' function is the classes destructor function) +The '.type' attribute is the name of the class. The '.get' and '.set' tables work in a similar manner to the modules, the main difference is the '.fn' table which also holds all the member functions. (The '__gc' function is the class' destructor function)

    The Lua equivalent of the code for enabling functions looks a little like this @@ -1706,7 +1707,7 @@ function __index(obj,name) local f=g[name] -- looks for the get_attribute function -- calls it & returns the value if type(f)=="function" then return f() end - -- ok, so it not an attribute, maybe its a function + -- ok, so it not an attribute, maybe it's a function local fn=m['.fn'] -- gets the function table if not fn then return nil end local f=fn[name] -- looks for the function @@ -1726,7 +1727,7 @@ In theory, you can play with this usertable & add new features, but remember Note: Both the opaque structures (like the FILE*) and normal wrapped classes/structs use the same 'swig_lua_userdata' structure. Though the opaque structures has do not have a metatable attached, or any information on how to dispose of them when the interpreter has finished with them.

    -Note: Operator overloads are basically done in the same way, by adding functions such as '__add' & '__call' to the classes metatable. The current implementation is a bit rough as it will add any member function beginning with '__' into the metatable too, assuming its an operator overload. +Note: Operator overloads are basically done in the same way, by adding functions such as '__add' & '__call' to the class' metatable. The current implementation is a bit rough as it will add any member function beginning with '__' into the metatable too, assuming its an operator overload.

    26.7.3 Memory management

    @@ -1738,7 +1739,7 @@ Lua is very helpful with the memory management. The 'swig_lua_userdata' is fully It is currently not recommended to edit this field or add some user code, to change the behaviour. Though for those who wish to try, here is where to look.

    -It is also currently not possible to change the ownership flag on the data (unlike most other scripting languages, Lua does not permit access to the data from within the interpreter) +It is also currently not possible to change the ownership flag on the data (unlike most other scripting languages, Lua does not permit access to the data from within the interpreter).

    diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html index 8d41efccf..8fcbe9206 100644 --- a/Doc/Manual/Preprocessor.html +++ b/Doc/Manual/Preprocessor.html @@ -16,8 +16,11 @@
  • Macro Expansion
  • SWIG Macros
  • C99 and GNU Extensions +
  • Preprocessing and delimiters +
  • Preprocessor and Typemaps
  • Viewing preprocessor output
  • The #error and #warning directives @@ -306,7 +309,14 @@ interface building. However, they are used internally to implement a number of SWIG directives and are provided to make SWIG more compatible with C99 code.

    -

    7.7 Preprocessing and %{ ... %} & " ... " delimiters

    +

    7.7 Preprocessing and delimiters

    + + +

    +The preprocessor handles { }, " " and %{ %} delimiters differently. +

    + +

    7.7.1 Preprocessing and %{ ... %} & " ... " delimiters

    @@ -331,7 +341,7 @@ the contents of the %{ ... %} block are copied without modification to the output (including all preprocessor directives).

    -

    7.8 Preprocessing and { ... } delimiters

    +

    7.7.2 Preprocessing and { ... } delimiters

    @@ -373,7 +383,7 @@ to actually go into the wrapper file, prefix the preprocessor directives with % and leave the preprocessor directive in the code.

    -

    7.9 Preprocessor and Typemaps

    +

    7.8 Preprocessor and Typemaps

    @@ -444,7 +454,7 @@ would generate

  • -

    7.10 Viewing preprocessor output

    +

    7.9 Viewing preprocessor output

    @@ -454,7 +464,7 @@ Instead the results after the preprocessor has run are displayed. This might be useful as an aid to debugging and viewing the results of macro expansions.

    -

    7.11 The #error and #warning directives

    +

    7.10 The #error and #warning directives

    diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index ebe6fa476..1151de1d5 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -6,7 +6,7 @@

    SWIG-2.0 Documentation

    -Last update : SWIG-2.0.5 (in progress) +Last update : SWIG-2.0.6 (30 April 2012)

    Sections

    diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index b6e8cf3ce..b3b0bc7a9 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -3673,17 +3673,21 @@ generated into the wrapper code before any typemap code that calls it.

    To define a fragment you need a fragment name, a section name for generating the fragment code into, and the code itself. See Code insertion blocks for a full list of section names. -Usually the section name used is "header". Both string and curly braces can be used: +Usually the section name used is "header". Different delimiters can be used:

    +%fragment("my_name", "header") %{ ... %}
     %fragment("my_name", "header") { ... }
     %fragment("my_name", "header") " ... "
     

    +and these follow the usual preprocessing rules mentioned in the +Preprocessing delimiters +section. The following are some rules and guidelines for using fragments:

    @@ -3761,8 +3765,8 @@ A fragment can use one or more additional fragments, for example:
    -%fragment("<limits.h>", "header")  {
    -  #include <limits.h>
    +%fragment("<limits.h>", "header") {
    +  %#include <limits.h>
     }
     
     
    diff --git a/Examples/Makefile.in b/Examples/Makefile.in
    index a948b6a43..31694e754 100644
    --- a/Examples/Makefile.in
    +++ b/Examples/Makefile.in
    @@ -1142,20 +1142,21 @@ R_CFLAGS=-fPIC
     
     # need to compile .cxx files outside of R build system to make sure that
     # we get -fPIC
    +# CMD SHLIB stdout is piped to /dev/null to prevent echo of compiler command
     
     r: $(SRCS)
     	$(SWIG) -r $(SWIGOPT) $(INTERFACEPATH)
     ifneq ($(SRCS),)
     	$(CXX) -g -c $(CFLAGS) $(R_CFLAGS) $(SRCS) $(INCLUDES) 
     endif
    -	+( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) $(OBJS) )
    +	+( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) $(OBJS) > /dev/null )
     
     r_cpp: $(CXXSRCS)
     	$(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACEPATH)
     ifneq ($(CXXSRCS),)
     	$(CXX) -g -c $(CFLAGS) $(R_CFLAGS) $(CXXSRCS) $(INCLUDES) 
     endif
    -	+( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) $(OBJS) )
    +	+( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) $(OBJS) > /dev/null )
     
     r_clean:
     	rm -f *_wrap* *~ .~*
    diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
    index 0b79706cc..7cc410e7a 100644
    --- a/Examples/test-suite/common.mk
    +++ b/Examples/test-suite/common.mk
    @@ -277,6 +277,7 @@ CPP_TEST_CASES += \
             operbool \
     	ordering \
     	overload_copy \
    +	overload_method \
     	overload_extend \
     	overload_rename \
     	overload_return_type \
    @@ -466,7 +467,6 @@ CPP_STD_TEST_CASES += \
     	director_string \
     	ignore_template_constructor \
     	li_std_combinations \
    -	li_std_containers_int \
     	li_std_deque \
     	li_std_except \
     	li_std_map \
    diff --git a/Examples/test-suite/director_binary_string.i b/Examples/test-suite/director_binary_string.i
    index ec64bc4b4..96c835959 100644
    --- a/Examples/test-suite/director_binary_string.i
    +++ b/Examples/test-suite/director_binary_string.i
    @@ -29,12 +29,12 @@ public:
       void delCallback() { delete _callback; _callback = 0; }
       void setCallback(Callback *cb) { delCallback(); _callback = cb; }
       int call() {
    +    int sum = 0;
         if (_callback) {
           char* aa = (char*)malloc(BUFFER_SIZE_AA);
           memset(aa, 9, BUFFER_SIZE_AA);
           char* bb = (char*)malloc(BUFFER_SIZE_BB);
           memset(bb, 13, BUFFER_SIZE_BB);
    -      int sum = 0;
           _callback->run(aa, BUFFER_SIZE_AA, bb, BUFFER_SIZE_BB);
           for (int i = 0; i < BUFFER_SIZE_AA; i++)
             sum += aa[i];
    @@ -42,8 +42,8 @@ public:
             sum += bb[i];
           free(aa);
           free(bb);
    -      return sum;
         }
    +    return sum;
       }
     };
     
    diff --git a/Examples/test-suite/director_nspace.i b/Examples/test-suite/director_nspace.i
    index 9861d9596..6814a43a3 100644
    --- a/Examples/test-suite/director_nspace.i
    +++ b/Examples/test-suite/director_nspace.i
    @@ -36,8 +36,13 @@ namespace Bar
     
     %include 
     
    +// nspace feature only supported by these languages
    +#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD)
     %nspace Bar::Foo;
     %nspace Bar::FooBar;
    +#else
    +#warning nspace feature not yet supported in this target language
    +#endif
     
     %feature("director") Bar::Foo;
     
    diff --git a/Examples/test-suite/disown.i b/Examples/test-suite/disown.i
    index 8b3aeb0ec..884fdaa74 100644
    --- a/Examples/test-suite/disown.i
    +++ b/Examples/test-suite/disown.i
    @@ -42,6 +42,12 @@
           _a = disown;    
           return 5;      
         }
    +
    +    int remove(A *remove) 
    +    {
    +      delete remove;
    +      return 5;      
    +    }
         
       };
     }
    diff --git a/Examples/test-suite/java/java_lib_various_runme.java b/Examples/test-suite/java/java_lib_various_runme.java
    index ab54aced8..203a30ec2 100644
    --- a/Examples/test-suite/java/java_lib_various_runme.java
    +++ b/Examples/test-suite/java/java_lib_various_runme.java
    @@ -45,6 +45,11 @@ public class java_lib_various_runme {
           if ( !langs[i].equals(newLangs[i]) )
             throw new RuntimeException("Languages verify failed " + i + " " + langs[i] + "|" + newLangs[i]);
     
    +    // STRING_ARRAY null
    +    java_lib_various.setLanguages(null);
    +    if (java_lib_various.getLanguages() != null)
    +      throw new RuntimeException("languages should be null");
    +
         // STRING_RET test
         {
           String stringOutArray[] = { "" };
    diff --git a/Examples/test-suite/lua/disown_runme.lua b/Examples/test-suite/lua/disown_runme.lua
    index 72115bbc7..79c3df3c4 100644
    --- a/Examples/test-suite/lua/disown_runme.lua
    +++ b/Examples/test-suite/lua/disown_runme.lua
    @@ -12,3 +12,9 @@ for x=0,100 do
         b:acquire(a)
     end
     collectgarbage() -- this will double delete unless the memory is managed properly
    +
    +a=disown.A()
    +a:__disown()
    +b:remove(a)
    +a=nil
    +collectgarbage() -- this will double delete unless the manual disown call worked
    diff --git a/Examples/test-suite/lua/li_factory_runme.lua b/Examples/test-suite/lua/li_factory_runme.lua
    new file mode 100644
    index 000000000..794959eb6
    --- /dev/null
    +++ b/Examples/test-suite/lua/li_factory_runme.lua
    @@ -0,0 +1,16 @@
    +require("import")  -- the import fn
    +import("li_factory") -- import code
    +
    +-- moving to global
    +for k,v in pairs(li_factory) do _G[k]=v end
    +
    +-- catch "undefined" global variables
    +setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
    +
    +circle = Geometry_create(Geometry_CIRCLE)
    +r = circle:radius()
    +assert(r == 1.5)
    +
    +point = Geometry_create(Geometry_POINT)
    +w = point:width()
    +assert(w == 1.0)
    diff --git a/Examples/test-suite/nspace.i b/Examples/test-suite/nspace.i
    index 65c6aafa1..2e10542d3 100644
    --- a/Examples/test-suite/nspace.i
    +++ b/Examples/test-suite/nspace.i
    @@ -103,5 +103,7 @@ struct GlobalClass {
     void test_classes(Outer::SomeClass c, Outer::Inner2::Color cc) {}
     %}
     
    +#else
    +#warning nspace feature not yet supported in this target language
     #endif
     
    diff --git a/Examples/test-suite/nspace_extend.i b/Examples/test-suite/nspace_extend.i
    index 96e97a4ff..1965ef8f6 100644
    --- a/Examples/test-suite/nspace_extend.i
    +++ b/Examples/test-suite/nspace_extend.i
    @@ -49,5 +49,7 @@ namespace Outer {
                       const Outer::Inner2::Color& col2c) {}
     }
     
    +#else
    +#warning nspace feature not yet supported in this target language
     #endif
     
    diff --git a/Examples/test-suite/octave_dim.i b/Examples/test-suite/octave_dim.i
    index c74285808..f0d05852a 100644
    --- a/Examples/test-suite/octave_dim.i
    +++ b/Examples/test-suite/octave_dim.i
    @@ -127,7 +127,7 @@ public:
     class Baz5 {
     public:
       Array __dims__() const {
    -    Array c(2,1);
    +    Array c(dim_vector(2,1));
         c(0) = 3;
         c(1) = 4;
         return c;
    @@ -137,7 +137,7 @@ public:
     class Baz6 {
     public:
       Array __dims__() const {
    -    Array c(1,2);
    +    Array c(dim_vector(1,2));
         c(0) = 3;
         c(1) = 4;
         return c;
    diff --git a/Examples/test-suite/operator_pointer_ref.i b/Examples/test-suite/operator_pointer_ref.i
    index 1541adbcf..84182da0d 100644
    --- a/Examples/test-suite/operator_pointer_ref.i
    +++ b/Examples/test-suite/operator_pointer_ref.i
    @@ -1,5 +1,11 @@
     %module operator_pointer_ref
     
    +%{
    +#if defined(_MSC_VER)
    +  #pragma warning(disable: 4996) // 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details.
    +#endif
    +%}
    +
     %rename(AsCharStarRef) operator char*&;
     
     %inline %{
    diff --git a/Examples/test-suite/overload_method.i b/Examples/test-suite/overload_method.i
    new file mode 100644
    index 000000000..8b44b8172
    --- /dev/null
    +++ b/Examples/test-suite/overload_method.i
    @@ -0,0 +1,20 @@
    +/* This test confirms the fix to sourceforge bug #3478922 for R */
    +
    +%module overload_method
    +%inline %{
    +class Base
    +   {
    +   public:
    +
    +   Base() : x(42) {}
    +
    +   int method() const { return x; }
    +
    +   void overloaded_method(int aArg) { x = aArg; }
    +   int overloaded_method() const { return x; }
    +
    +   private:
    +
    +   int x;
    +   };
    +%}
    diff --git a/Examples/test-suite/perl5/li_typemaps_runme.pl b/Examples/test-suite/perl5/li_typemaps_runme.pl
    index 194c98ca3..c182cdbb1 100644
    --- a/Examples/test-suite/perl5/li_typemaps_runme.pl
    +++ b/Examples/test-suite/perl5/li_typemaps_runme.pl
    @@ -1,99 +1,74 @@
     #!/usr/bin/perl
     use strict;
     use warnings;
    -use Test::More tests => 631;
    +use Test::More tests => 415;
     BEGIN { use_ok('li_typemaps') }
     require_ok('li_typemaps');
     
    -my @tests = qw(
    -  in inr
    -  out outr
    -  inout inoutr
    -);
    -
    -sub should_pass { my($type, @values) = @_;
    -  # verify that each value passes cleanly
    -  for my $test (@tests) {
    -    my $name = "${test}_${type}";
    -    my $func = li_typemaps->can($name);
    -    for my $val (@values) {
    -      my $rv = eval { $func->($val) };
    -      is($rv, $val, "$name $val");
    +sub batch { my($type, @values) = @_;
    +  # this is a little ugly because I'm trying to be clever and save my
    +  # wrists from hammering out all these tests.
    +  for my $val (@values) {
    +    for my $tst (qw(
    +      in inr
    +      out outr
    +      inout inoutr
    +    )) {
    +      my $func = $tst . '_' . $type;
    +      is(eval { li_typemaps->can($func)->($val) }, $val, "$func $val");
    +      if($@) {
    +        my $err = $@;
    +        $err =~ s/^/#\$\@# /mg;
    +        print $err;
    +      }
         }
       }
     }
     
    -sub should_fail { my($type, @values) = @_;
    -  # verify that all values trigger runtime errors
    -  for my $test (@tests) {
    -    my $name = "${test}_${type}";
    -    my $func = li_typemaps->can($name);
    -    for my $val (@values) {
    -      my $rv = eval { $func->($val) };
    -      like($@, qr/\b(?:Overflow|Type)Error\b/, "overflow $name $val");
    -    }
    -  }
    -}
    +batch('bool', '', 1);
    +# let's assume we're at least on a 32 bit machine
    +batch('int', -0x80000000, -1, 0, 1, 12, 0x7fffffff);
    +# long could be bigger, but it's at least this big
    +batch('long', -0x80000000, -1, 0, 1, 12, 0x7fffffff);
    +batch('short', -0x8000, -1, 0, 1, 12, 0x7fff);
    +batch('uint', 0, 1, 12, 0xffffffff);
    +batch('ushort', 0, 1, 12, 0xffff);
    +batch('ulong', 0, 1, 12, 0xffffffff);
    +batch('uchar', 0, 1, 12, 0xff);
    +batch('schar', -0x80, 0, 1, 12, 0x7f);
     
    -sub pad { my($t, $s, $f) = @_;
    -  my $nbytes = length pack $t, 0;
    -  return unpack $t, $s . ($f x ($nbytes - 1));
    +{
    +	use Math::BigInt qw();
    +	# the pack dance is to get plain old NVs out of the
    +	# Math::BigInt objects.
    +	my $inf = unpack 'd', pack 'd', Math::BigInt->binf();
    +	my $nan = unpack 'd', pack 'd', Math::BigInt->bnan();
    +	batch('float',
    +	  -(2 - 2 ** -23) * 2 ** 127,
    +	  -1, -2 ** -149, 0, 2 ** -149, 1,
    +	  (2 - 2 ** -23) * 2 ** 127,
    +	  $nan);
    +	{ local $TODO = "float typemaps don't pass infinity";
    +	  # it seems as though SWIG is unwilling to pass infinity around
    +	  # because that value always fails bounds checking.  I think that
    +	  # is a bug.
    +	  batch('float', $inf);
    +	}
    +	batch('double',
    +	  -(2 - 2 ** -53) ** 1023,
    +	  -1, -2 ** -1074, 0, 2 ** 1074,
    +	  (2 - 2 ** -53) ** 1023,
    +	  $nan, $inf);
     }
    -
    -# some edge case values:
    -my $nan = unpack 'f>', "\x7f\xc0\x00\x00";
    -my $inf = unpack 'f>', "\x7f\x80\x00\x00";
    -my $char_min   = pad 'c', "\x80";
    -my $char_max   = pad 'c', "\x7f";
    -my $char_umax  = pad 'C', "\xff";
    -my $short_min  = pad 's!>', "\x80", "\x00";
    -my $short_max  = pad 's!>', "\x7f", "\xff";
    -my $short_umax = pad 'S!>', "\xff", "\xff";
    -my $int_min    = pad 'i!>', "\x80", "\x00";
    -my $int_max    = pad 'i!>', "\x7f", "\xff";
    -my $int_umax   = pad 'I!>', "\xff", "\xff";
    -my $long_min   = pad 'l!>', "\x80", "\x00";
    -my $long_max   = pad 'l!>', "\x7f", "\xff";
    -my $long_umax  = pad 'L!>', "\xff", "\xff";
    -
    -should_pass('bool', '', 1);
    -should_pass('int', $int_min, -1, 0, 1, 12, $int_max);
    -should_fail('int', $int_min - 1000, $int_max + 1000, $inf, $nan);
    -should_pass('long', $long_min, -1, 0, 1, 12, $long_max);
    -should_fail('long', $long_min - 8000, $long_max + 8000, $inf, $nan);
    -should_pass('short', $short_min, -1, 0, 1, 12, $short_max);
    -should_fail('short', $short_min - 1, $short_max + 1, $inf, $nan);
    -should_pass('uint', 0, 1, 12, $int_umax);
    -should_fail('uint', -1, $int_umax + 1000, $inf, $nan);
    -should_pass('ushort', 0, 1, 12, $short_umax);
    -should_fail('ushort', -1, $short_umax + 1, $inf, $nan);
    -should_pass('ulong', 0, 1, 12, $long_umax);
    -should_fail('ulong', -1, $long_umax + 8000, $inf, $nan);
    -should_pass('uchar', 0, 1, 12, $char_umax);
    -should_fail('uchar', -1, $char_umax + 1, $inf, $nan);
    -should_pass('schar', $char_min, -1, 0, 1, 12, $char_max);
    -should_fail('schar', $char_min - 1, $char_max + 1, $inf, $nan);
    -should_pass('float', -1, 0, 1, $nan);
    -TODO: {
    -  local $TODO = "typemaps don't allow float infinity";
    -  should_pass('float', -$inf, $inf);
    -}
    -should_pass('double', -$inf, -1, 0, 1, $inf, $nan);
    -should_pass('longlong', -1, 0, 1, 12);
    -should_fail('longlong', $inf, $nan);
    -should_pass('ulonglong', 0, 1, 12);
    -should_fail('ulonglong', -1, $inf, $nan);
    +batch('longlong', -1, 0, 1, 12);
    +batch('ulonglong', 0, 1, 12);
     SKIP: {
    -  my $llong_min  = eval { pad 'q>', "\x80", "\x00" };
    -  my $llong_max  = eval { pad 'q>', "\x7f", "\xff" };
    -  my $llong_umax = eval { pad 'Q>', "\xff", "\xff" };
    -
    -  skip 'not a 64 bit perl', 6 * 6 unless defined $llong_min;
    -
    -  should_pass('longlong', $llong_min, $llong_max);
    -  should_fail('longlong', $llong_min - 8000, $llong_max + 8000);
    -  should_pass('ulonglong', $llong_umax);
    -  should_fail('ulonglong', $llong_umax + 8000);
    +  my $a = "8000000000000000";
    +  my $b = "7fffffffffffffff";
    +  my $c = "ffffffffffffffff";
    +  skip "not a 64bit Perl", 18 unless eval { pack 'q', 1 };
    +  batch('longlong', -hex($a), hex($b));
    +  batch('ulonglong', hex($c));
     }
     
     my($foo, $int) = li_typemaps::out_foo(10);
    @@ -104,3 +79,4 @@ is($int, 20);
     my($a, $b) = li_typemaps::inoutr_int2(13, 31);
     is($a, 13);
     is($b, 31);
    +
    diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in
    index e5d92626e..43ba2717e 100644
    --- a/Examples/test-suite/python/Makefile.in
    +++ b/Examples/test-suite/python/Makefile.in
    @@ -46,6 +46,7 @@ CPP_TEST_CASES += \
     	li_cwstring \
     	li_factory \
     	li_implicit \
    +	li_std_containers_int \
     	li_std_map_member \
     	li_std_multimap \
     	li_std_pair_extra \
    diff --git a/Examples/test-suite/python/autodoc_runme.py b/Examples/test-suite/python/autodoc_runme.py
    index c65ebba24..dc843ae96 100644
    --- a/Examples/test-suite/python/autodoc_runme.py
    +++ b/Examples/test-suite/python/autodoc_runme.py
    @@ -2,7 +2,7 @@ from autodoc import *
     
     def check(got, expected):
       if expected != got:
    -    raise RuntimeError("\n" + "Expected: [" + expected + "]\n" + "Got     : [" + got + "]")
    +    raise RuntimeError("\n" + "Expected: [" + str(expected) + "]\n" + "Got     : [" + str(got) + "]")
     
     check(A.__doc__, "Proxy of C++ A class")
     check(A.funk.__doc__, "just a string")
    diff --git a/Examples/test-suite/python/li_boost_shared_ptr_template_runme.py b/Examples/test-suite/python/li_boost_shared_ptr_template_runme.py
    index 20e7a8060..c10627f36 100644
    --- a/Examples/test-suite/python/li_boost_shared_ptr_template_runme.py
    +++ b/Examples/test-suite/python/li_boost_shared_ptr_template_runme.py
    @@ -8,8 +8,9 @@ if d.bar() != 2:
       raise RuntimeError
     if bar_getter(b) != 1:
       raise RuntimeError
    -if bar_getter(d) != 2:
    -  raise RuntimeError
    +# Fix reverted in rev 12953
    +#if bar_getter(d) != 2:
    +#  raise RuntimeError
     
     b = BaseDefaultInt()
     d = DerivedDefaultInt()
    @@ -22,7 +23,8 @@ if d2.bar2() != 4:
       raise RuntimeError
     if bar2_getter(b) != 3:
       raise RuntimeError
    -if bar2_getter(d) != 4:
    -  raise RuntimeError
    -if bar2_getter(d2) != 4:
    -  raise RuntimeError
    +# Fix reverted in rev 12953
    +#if bar2_getter(d) != 4:
    +#  raise RuntimeError
    +#if bar2_getter(d2) != 4:
    +#  raise RuntimeError
    diff --git a/Examples/test-suite/python/threads_exception_runme.py b/Examples/test-suite/python/threads_exception_runme.py
    index f9b0fddc0..12202e3d3 100644
    --- a/Examples/test-suite/python/threads_exception_runme.py
    +++ b/Examples/test-suite/python/threads_exception_runme.py
    @@ -26,7 +26,7 @@ except threads_exception.Exc,e:
       if e.code != 42:
         raise RuntimeError
       if e.msg != "Hosed":
    -    raise RuntimeError
    +    raise RuntimeError, "bad... msg: %s" % e.msg
     
     for i in range(1,4):
       try:
    diff --git a/Examples/test-suite/r/Makefile.in b/Examples/test-suite/r/Makefile.in
    index 86b19e142..bece71c2f 100644
    --- a/Examples/test-suite/r/Makefile.in
    +++ b/Examples/test-suite/r/Makefile.in
    @@ -10,8 +10,13 @@ srcdir       = @srcdir@
     top_srcdir   = @top_srcdir@
     top_builddir = @top_builddir@
     
    -C_TEST_CASES = r_copy_struct r_legacy
    -CPP_TEST_CASES = r_double_delete  r_overload_array
    +C_TEST_CASES += \
    +	r_copy_struct \
    +	r_legacy
    +
    +CPP_TEST_CASES += \
    +	r_double_delete \
    +	r_overload_array
     
     include $(srcdir)/../common.mk
     
    diff --git a/Examples/test-suite/r/overload_method_runme.R b/Examples/test-suite/r/overload_method_runme.R
    new file mode 100644
    index 000000000..afb590a74
    --- /dev/null
    +++ b/Examples/test-suite/r/overload_method_runme.R
    @@ -0,0 +1,13 @@
    +source("unittest.R")
    +dyn.load(paste("overload_method", .Platform$dynlib.ext, sep=""))
    +source("overload_method.R")
    +cacheMetaData(1)
    +
    +b <- Base()
    +Base_method(b)
    +Base_overloaded_method(b)
    +Base_overloaded_method(b, 43)
    +Base_overloaded_method(b)
    +b$method()
    +
    +b$overloaded_method()
    diff --git a/Examples/test-suite/refcount.i b/Examples/test-suite/refcount.i
    index 28b55545b..d47323482 100644
    --- a/Examples/test-suite/refcount.i
    +++ b/Examples/test-suite/refcount.i
    @@ -97,7 +97,7 @@
         RCPtr _a;
       };
     
    -class B* global_create(A* a)
    +struct B* global_create(A* a)
     {
       return new B(a);
     }
    diff --git a/Examples/test-suite/special_variable_macros.i b/Examples/test-suite/special_variable_macros.i
    index ad61cf7a0..672569508 100644
    --- a/Examples/test-suite/special_variable_macros.i
    +++ b/Examples/test-suite/special_variable_macros.i
    @@ -5,6 +5,12 @@
     
     %warnfilter(SWIGWARN_GO_NAME_CONFLICT);                       /* Ignoring 'NewName' due to Go name ('NewName') conflict with 'Name' */
     
    +%{
    +#if defined(_MSC_VER)
    +  #pragma warning(disable: 4996) // 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details.
    +#endif
    +%}
    +
     %ignore Name::operator=;
     
     %inline %{
    diff --git a/Examples/test-suite/template_default_class_parms_typedef.i b/Examples/test-suite/template_default_class_parms_typedef.i
    index fb64659ba..0767498bf 100644
    --- a/Examples/test-suite/template_default_class_parms_typedef.i
    +++ b/Examples/test-suite/template_default_class_parms_typedef.i
    @@ -21,16 +21,16 @@ namespace Space {
         C method(C c, D d, E e) { return c; }
     
         // Use typedef with classname qualifiers
    -    Bar(bool, Bar::C c, Bar::D d, Bar::E e) {}
    -    Bar::C method_1(Bar::C c, Bar::D d, Bar::E e) { return c; }
    +    Bar(bool, typename Bar::C c, typename Bar::D d, typename Bar::E e) {}
    +    typename Bar::C method_1(typename Bar::C c, typename Bar::D d, typename Bar::E e) { return c; }
     
         // Use typedef with classname and full template parameter qualifiers
    -    Bar(bool, bool, Bar::C c, Bar::D d, Bar::E e) {}
    -    Bar::C method_2(Bar::C c, Bar::D d, Bar::E e) { return c; }
    +    Bar(bool, bool, typename Bar::C c, typename Bar::D d, typename Bar::E e) {}
    +    typename Bar::C method_2(typename Bar::C c, typename Bar::D d, typename Bar::E e) { return c; }
     
         // Use typedef with namespace and classname and full template parameter qualifiers
    -    Bar(bool, bool, bool, Space::Bar::C c, Space::Bar::D d, Space::Bar::E e) {}
    -    Space::Bar::C method_3(Space::Bar::C c, Space::Bar::D d, Space::Bar::E e) { return c; }
    +    Bar(bool, bool, bool, typename Space::Bar::C c, typename Space::Bar::D d, typename Space::Bar::E e) {}
    +    typename Space::Bar::C method_3(typename Space::Bar::C c, typename Space::Bar::D d, typename Space::Bar::E e) { return c; }
       };
       template class Foo {
       public:
    @@ -43,15 +43,15 @@ namespace Space {
     
         // Use typedef with classname qualifiers
         Foo(const T &, T t) {}
    -    Foo::T method_A(Foo::T t) { return t; }
    +    typename Foo::T method_A(typename Foo::T t) { return t; }
     
         // Use typedef with classname and full template parameter qualifiers
    -    Foo(const Foo::T &, const Foo::T &, Foo::T t) {}
    -    Foo::T method_B(Foo::T t) { return t; }
    +    Foo(const typename Foo::T &, const typename Foo::T &, typename Foo::T t) {}
    +    typename Foo::T method_B(typename Foo::T t) { return t; }
     
         // Use typedef with namespace and classname and full template parameter qualifiers
    -    Foo(const Foo::T &, const Foo::T &, const Foo::T &, Foo::T t) {}
    -    Foo::T method_C(Foo::T t) { return t; }
    +    Foo(const typename Foo::T &, const typename Foo::T &, const typename Foo::T &, typename Foo::T t) {}
    +    typename Foo::T method_C(typename Foo::T t) { return t; }
       };
       template class ATemplate {};
     
    diff --git a/Examples/test-suite/template_typedef_class_template.i b/Examples/test-suite/template_typedef_class_template.i
    index 498f83ec5..fc8151ff0 100644
    --- a/Examples/test-suite/template_typedef_class_template.i
    +++ b/Examples/test-suite/template_typedef_class_template.i
    @@ -24,8 +24,8 @@ template class Multimap {
         class const_iterator {};
     
         // test usage of a typedef of a nested class in a template
    -    Standard::Pair equal_range_1(const key_type& kt1) {}
    -    Standard::Pair equal_range_2(const key_type& kt2) const {}
    +    Standard::Pair equal_range_1(const key_type& kt1) { return Standard::Pair(); }
    +    Standard::Pair equal_range_2(const key_type& kt2) const { return Standard::Pair(); }
       };
     }
     %}
    diff --git a/Examples/test-suite/template_typemaps.i b/Examples/test-suite/template_typemaps.i
    index deaf8351a..c68eba730 100644
    --- a/Examples/test-suite/template_typemaps.i
    +++ b/Examples/test-suite/template_typemaps.i
    @@ -3,6 +3,7 @@
     
     %typemap(in) Integer1 
     {
    +  $1 = 0;
       /* do nothing */
     }
     
    @@ -13,6 +14,7 @@
     
     %typemap(in) Integer2 
     {
    +  $1 = 0;
       /* do nothing */
     }
     
    diff --git a/Examples/test-suite/typedef_struct.i b/Examples/test-suite/typedef_struct.i
    index 4380156d1..97456d9a6 100644
    --- a/Examples/test-suite/typedef_struct.i
    +++ b/Examples/test-suite/typedef_struct.i
    @@ -45,10 +45,18 @@ B_t make_b() {
     
     %inline %{
     
    +#ifdef __cplusplus
    +extern "C" {
    +#endif
    +
     typedef struct _Foo {
       enum { NONAME1, NONAME2 } enumvar;
       int foovar;
       void (*fptr)(int);
     } Foo;
     
    +#ifdef __cplusplus
    +}
    +#endif
    +
     %}
    diff --git a/Examples/test-suite/typemap_various.i b/Examples/test-suite/typemap_various.i
    index 58dbe6667..2a1777ea8 100644
    --- a/Examples/test-suite/typemap_various.i
    +++ b/Examples/test-suite/typemap_various.i
    @@ -58,17 +58,17 @@ void foo2(Foo f, const Foo& ff) {}
     
     // Test obscure bug where named typemaps where not being applied when symbol name contained a number
     %typemap(out) double "_typemap_for_double_no_compile_"
    -%typemap(out) double ABC::meth "$1 = 0.0;"
    -%typemap(out) double ABC::m1   "$1 = 0.0;"
    -%typemap(out) double ABC::_x2  "$1 = 0.0;"
    -%typemap(out) double ABC::y_   "$1 = 0.0;"
    -%typemap(out) double ABC::_3   "$1 = 0.0;"
    +%typemap(out) double ABCD::meth "$1 = 0.0;"
    +%typemap(out) double ABCD::m1   "$1 = 0.0;"
    +%typemap(out) double ABCD::_x2  "$1 = 0.0;"
    +%typemap(out) double ABCD::y_   "$1 = 0.0;"
    +%typemap(out) double ABCD::_3   "$1 = 0.0;"
     %inline %{
    -struct ABC {
    -  double meth() {}
    -  double m1() {}
    -  double _x2() {}
    -  double y_() {}
    -  double _3() {}
    +struct ABCD {
    +  double meth() { return 0.0; }
    +  double m1() { return 0.0; }
    +  double _x2() { return 0.0; }
    +  double y_() { return 0.0; }
    +  double _3() { return 0.0; }
     };
     %}
    diff --git a/Lib/d/dhead.swg b/Lib/d/dhead.swg
    index 9b3ec3470..7a2f4fddc 100644
    --- a/Lib/d/dhead.swg
    +++ b/Lib/d/dhead.swg
    @@ -91,31 +91,31 @@ private class SwigExceptionHelper {
           &setNoSuchElementException);
       }
     
    -  static void setException(const char* message) {
    +  static void setException(char* message) {
         auto exception = new object.Exception(tango.stdc.stringz.fromStringz(message).dup);
         exception.next = SwigPendingException.retrieve();
         SwigPendingException.set(exception);
       }
     
    -  static void setIllegalArgumentException(const char* message) {
    +  static void setIllegalArgumentException(char* message) {
         auto exception = new tango.core.Exception.IllegalArgumentException(tango.stdc.stringz.fromStringz(message).dup);
         exception.next = SwigPendingException.retrieve();
         SwigPendingException.set(exception);
       }
     
    -  static void setIllegalElementException(const char* message) {
    +  static void setIllegalElementException(char* message) {
         auto exception = new tango.core.Exception.IllegalElementException(tango.stdc.stringz.fromStringz(message).dup);
         exception.next = SwigPendingException.retrieve();
         SwigPendingException.set(exception);
       }
     
    -  static void setIOException(const char* message) {
    +  static void setIOException(char* message) {
         auto exception = new tango.core.Exception.IOException(tango.stdc.stringz.fromStringz(message).dup);
         exception.next = SwigPendingException.retrieve();
         SwigPendingException.set(exception);
       }
     
    -  static void setNoSuchElementException(const char* message) {
    +  static void setNoSuchElementException(char* message) {
         auto exception = new tango.core.Exception.NoSuchElementException(tango.stdc.stringz.fromStringz(message).dup);
         exception.next = SwigPendingException.retrieve();
         SwigPendingException.set(exception);
    @@ -174,7 +174,7 @@ private:
       alias tango.core.Thread.ThreadLocal!(object.Exception) ThreadLocalData;
       static ThreadLocalData m_sPendingException;
     }
    -alias void function(const char* message) SwigExceptionCallback;
    +alias void function(char* message) SwigExceptionCallback;
     %}
     #else
     %pragma(d) imdmoduleimports=%{
    diff --git a/Lib/java/various.i b/Lib/java/various.i
    index 9e7cf29ca..71569ca32 100644
    --- a/Lib/java/various.i
    +++ b/Lib/java/various.i
    @@ -23,7 +23,8 @@
     %typemap(jtype) char **STRING_ARRAY "String[]"
     %typemap(jstype) char **STRING_ARRAY "String[]"
     %typemap(in) char **STRING_ARRAY (jint size) {
    -    int i = 0;
    +  int i = 0;
    +  if ($input) {
         size = JCALL1(GetArrayLength, jenv, $input);
     #ifdef __cplusplus
         $1 = new char*[size+1];
    @@ -31,51 +32,56 @@
         $1 = (char **)calloc(size+1, sizeof(char *));
     #endif
         for (i = 0; i
    +
    +%define %_factory_dispatch(Type) 
    +if (!dcast) {
    +  Type *dobj = dynamic_cast($1);
    +  if (dobj) {
    +    dcast = 1;
    +    SWIG_NewPointerObj(L, dobj, $descriptor(Type *), $owner); SWIG_arg++;
    +  }   
    +}%enddef
    +
    +%define %factory(Method,Types...)
    +%typemap(out) Method {
    +  int dcast = 0;
    +  %formacro(%_factory_dispatch, Types)
    +  if (!dcast) {
    +    SWIG_NewPointerObj(L, $1, $descriptor, $owner); SWIG_arg++;
    +  }
    +}%enddef
    diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg
    index 6fe0bccce..af3e7a3af 100644
    --- a/Lib/lua/luarun.swg
    +++ b/Lib/lua/luarun.swg
    @@ -33,6 +33,15 @@ extern "C" {
     # define lua_rawlen lua_objlen
     #endif
     
    +
    +/* lua_pushglobaltable is the recommended "future-proof" way to get
    +   the global table for Lua 5.2 and later.  Here we define
    +   lua_pushglobaltable ourselves for Lua versions before 5.2.  */
    +#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 502
    +# define lua_pushglobaltable(L) lua_pushvalue(L, LUA_GLOBALSINDEX)
    +#endif
    +
    +
     /* -----------------------------------------------------------------------------
      * global swig types
      * ----------------------------------------------------------------------------- */
    @@ -469,6 +478,39 @@ SWIGINTERN int  SWIG_Lua_class_destruct(lua_State* L)
       return 0;
     }
     
    +/* the class.__tostring method called by the interpreter and print */
    +SWIGINTERN int  SWIG_Lua_class_tostring(lua_State* L)
    +{
    +/*  there should be 1 param passed in
    +  (1) userdata (not the metatable) */
    +  assert(lua_isuserdata(L,1));  /* just in case */
    +  unsigned long userData = (unsigned long)lua_touserdata(L,1); /* get the userdata address for later */
    +  lua_getmetatable(L,1);    /* get the meta table */
    +  assert(lua_istable(L,-1));  /* just in case */
    +  
    +  lua_getfield(L, -1, ".type");
    +  const char* className = lua_tostring(L, -1);
    +  
    +  char output[256];
    +  sprintf(output, "<%s userdata: %lX>", className, userData);
    +  
    +  lua_pushstring(L, (const char*)output);
    +  return 1;
    +}
    +
    +/* to manually disown some userdata */
    +SWIGINTERN int  SWIG_Lua_class_disown(lua_State* L)
    +{
    +/*  there should be 1 params passed in
    +  (1) userdata (not the meta table) */
    +  swig_lua_userdata* usr;
    +  assert(lua_isuserdata(L,-1));  /* just in case */
    +  usr=(swig_lua_userdata*)lua_touserdata(L,-1);  /* get it */
    +  
    +  usr->own = 0; /* clear our ownership */
    +  return 0;
    +}
    +
     /* gets the swig class registry (or creates it) */
     SWIGINTERN void  SWIG_Lua_get_class_registry(lua_State* L)
     {
    @@ -594,11 +636,15 @@ SWIGINTERN void  SWIG_Lua_class_register(lua_State* L,swig_lua_class* clss)
       /* add a table called ".fn" */
       lua_pushstring(L,".fn");
       lua_newtable(L);
    +  /* add manual disown method */
    +  SWIG_Lua_add_function(L,"__disown",SWIG_Lua_class_disown);
       lua_rawset(L,-3);
       /* add accessor fns for using the .get,.set&.fn */
       SWIG_Lua_add_function(L,"__index",SWIG_Lua_class_get);
       SWIG_Lua_add_function(L,"__newindex",SWIG_Lua_class_set);
       SWIG_Lua_add_function(L,"__gc",SWIG_Lua_class_destruct);
    +  /* add tostring method for better output */
    +  SWIG_Lua_add_function(L,"__tostring",SWIG_Lua_class_tostring);
       /* add it */
       lua_rawset(L,-3);  /* metatable into registry */
       lua_pop(L,1);      /* tidy stack (remove registry) */
    diff --git a/Lib/lua/luaruntime.swg b/Lib/lua/luaruntime.swg
    index 9cf6a14a4..0f59b0476 100644
    --- a/Lib/lua/luaruntime.swg
    +++ b/Lib/lua/luaruntime.swg
    @@ -30,11 +30,7 @@ SWIGEXPORT int SWIG_init(lua_State* L) /* default Lua action */
     #if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC) /* valid for both Lua and eLua */
       int i;
       /* start with global table */
    -#ifdef LUA_RIDX_GLOBALS
    -  lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS);
    -#else
    -  lua_pushvalue(L,LUA_GLOBALSINDEX);
    -#endif
    +  lua_pushglobaltable (L);
       /* SWIG's internal initalisation */
       SWIG_InitializeModule((void*)L);
       SWIG_PropagateClientData();
    diff --git a/Lib/lua/typemaps.i b/Lib/lua/typemaps.i
    index 180d17fd6..63cb49a0d 100644
    --- a/Lib/lua/typemaps.i
    +++ b/Lib/lua/typemaps.i
    @@ -557,7 +557,8 @@ ptr=nil -- the iMath* will be GC'ed as normal
     */
     
     %typemap(in,numinputs=0) SWIGTYPE** OUTPUT ($*ltype temp)
    -%{  $1 = &temp; %}
    +%{ temp = ($*ltype)0;
    +   $1 = &temp; %}
     %typemap(argout) SWIGTYPE** OUTPUT
     %{SWIG_NewPointerObj(L,*$1,$*descriptor,1); SWIG_arg++; %}
     
    diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg
    index 5f1c18af4..b006bfabe 100644
    --- a/Lib/octave/octrun.swg
    +++ b/Lib/octave/octrun.swg
    @@ -424,7 +424,8 @@ namespace Swig {
             if (ndim==1 && c.columns()!=1) ndim = c.columns();
     
             dim_vector d;
    -        d.resize(ndim);
    +        d.resize(ndim < 2 ? 2 : ndim);
    +        d(0) = d(1) = 1;
     
             // Fill in dim_vector 
             for (int k=0;k a = out.int_vector_value();
                if (error_state) return dim_vector(1,1);
                dim_vector d;
    -           d.resize(a.numel());
    +           d.resize(a.numel() < 2 ? 2 : a.numel());
    +           d(0) = d(1) = 1;
                for (int k=0;k=37
     octave_value_list SWIG_atexit_func(const octave_value_list &args, int nargout) {
    -  symbol_table::clear_global_pattern("*");
    +  string_vector vars = symbol_table::global_variable_names();
    +  for (int i = 0; i < vars.length(); i++)
    +    symbol_table::clear_global(vars[i]);
       symbol_table::clear_functions();
       return octave_value();
     }
    diff --git a/Lib/perl5/perlprimtypes.swg b/Lib/perl5/perlprimtypes.swg
    index 9420a2f41..d7ac6f94e 100644
    --- a/Lib/perl5/perlprimtypes.swg
    +++ b/Lib/perl5/perlprimtypes.swg
    @@ -23,7 +23,7 @@ SWIG_AsVal_dec(bool)(SV *obj, bool* val)
         if (val) *val = false;
         return SWIG_OK;
       } else {
    -    if (val) *val = SvTRUE(obj);
    +    if (val) *val = SvTRUE(obj) ? true : false;
         return SWIG_AddCast(SWIG_OK);    
       }
     }
    @@ -171,7 +171,7 @@ SWIG_From_dec(long long)(long long value)
     {
       SV *sv;
       if (value >= IV_MIN && value <= IV_MAX)
    -    sv = newSViv(value);
    +    sv = newSViv((IV)(value));
       else {
         //sv = newSVpvf("%lld", value); doesn't work in non 64bit Perl
         char temp[256];
    @@ -248,7 +248,7 @@ SWIG_From_dec(unsigned long long)(unsigned long long value)
     {
       SV *sv;
       if (value <= UV_MAX)
    -    sv = newSVuv(value);
    +    sv = newSVuv((UV)(value));
       else {
         //sv = newSVpvf("%llu", value); doesn't work in non 64bit Perl
         char temp[256];
    diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg
    index 43dd19537..eb089e98e 100644
    --- a/Lib/python/pycontainer.swg
    +++ b/Lib/python/pycontainer.swg
    @@ -188,8 +188,9 @@ namespace swig {
     }
     
     namespace swig {
    +  template 
       inline size_t
    -  check_index(ptrdiff_t i, size_t size, bool insert = false) {
    +  check_index(Difference i, size_t size, bool insert = false) {
         if ( i < 0 ) {
           if ((size_t) (-i) <= size)
     	return (size_t) (i + size);
    @@ -201,37 +202,38 @@ namespace swig {
         throw std::out_of_range("index out of range");
       }
     
    +  template 
       void
    -  slice_adjust(ptrdiff_t i, ptrdiff_t j, ptrdiff_t step, size_t size, ptrdiff_t &ii, ptrdiff_t &jj, bool insert = false) {
    +  slice_adjust(Difference i, Difference j, Py_ssize_t step, size_t size, Difference &ii, Difference &jj, bool insert = false) {
         if (step == 0) {
           throw std::invalid_argument("slice step cannot be zero");
         } else if (step > 0) {
           // Required range: 0 <= i < size, 0 <= j < size
           if (i < 0) {
             ii = 0;
    -      } else if (i < (ptrdiff_t)size) {
    +      } else if (i < (Difference)size) {
             ii = i;
    -      } else if (insert && (i >= (ptrdiff_t)size)) {
    -        ii = (ptrdiff_t)size;
    +      } else if (insert && (i >= (Difference)size)) {
    +        ii = (Difference)size;
           }
           if ( j < 0 ) {
             jj = 0;
           } else {
    -        jj = (j < (ptrdiff_t)size) ? j : (ptrdiff_t)size;
    +        jj = (j < (Difference)size) ? j : (Difference)size;
           }
         } else {
           // Required range: -1 <= i < size-1, -1 <= j < size-1
           if (i < -1) {
             ii = -1;
    -      } else if (i < (ptrdiff_t) size) {
    +      } else if (i < (Difference) size) {
             ii = i;
    -      } else if (i >= (ptrdiff_t)(size-1)) {
    -        ii = (ptrdiff_t)(size-1);
    +      } else if (i >= (Difference)(size-1)) {
    +        ii = (Difference)(size-1);
           }
           if (j < -1) {
             jj = -1;
           } else {
    -        jj = (j < (ptrdiff_t)size ) ? j : (ptrdiff_t)(size-1);
    +        jj = (j < (Difference)size ) ? j : (Difference)(size-1);
           }
         }
       }
    @@ -272,7 +274,7 @@ namespace swig {
             typename Sequence::const_iterator it = sb;
             while (it!=se) {
               sequence->push_back(*it);
    -          for (typename Sequence::size_type c=0; cpush_back(*it);
    -          for (typename Sequence::size_type c=0; c<-step && it!=se; ++c)
    +          for (Py_ssize_t c=0; c<-step && it!=se; ++c)
                 it++;
             }
           }
    @@ -329,7 +331,7 @@ namespace swig {
             size_t replacecount = (jj - ii + step - 1) / step;
             if (is.size() != replacecount) {
               char msg[1024];
    -          sprintf(msg, "attempt to assign sequence of size %d to extended slice of size %d", is.size(), replacecount);
    +          sprintf(msg, "attempt to assign sequence of size %lu to extended slice of size %lu", (unsigned long)is.size(), (unsigned long)replacecount);
               throw std::invalid_argument(msg);
             }
             typename Sequence::const_iterator isit = is.begin();
    @@ -337,7 +339,7 @@ namespace swig {
             std::advance(it,ii);
             for (size_t rc=0; rcerase(it);
                 if (it==self->end())
                   break;
    -            for (typename Sequence::size_type c=0; c<(step-1); ++c)
    +            for (Py_ssize_t c=0; c<(step-1); ++c)
                   it++;
                 delcount--;
               }
    @@ -399,7 +401,7 @@ namespace swig {
               self->erase((++it).base());
               if (it==self->rend())
                 break;
    -          for (typename Sequence::size_type c=0; c<(-step-1); ++c)
    +          for (Py_ssize_t c=0; c<(-step-1); ++c)
                 it++;
               delcount--;
             }
    @@ -797,8 +799,7 @@ namespace swig
           return swig::getslice(self, i, j, 1);
         }
     
    -    void __setslice__(difference_type i, difference_type j, const Sequence& v = Sequence()) 
    -      throw (std::out_of_range, std::invalid_argument) {
    +    void __setslice__(difference_type i, difference_type j, const Sequence& v = Sequence()) throw (std::out_of_range, std::invalid_argument) {
           swig::setslice(self, i, j, 1, v);
         }
     
    @@ -821,41 +822,46 @@ namespace swig
             SWIG_Error(SWIG_TypeError, "Slice object expected.");
             return NULL;
           }
    -      PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), self->size(), &i, &j, &step);
    -      return swig::getslice(self, i, j, step);
    +      PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step);
    +      Sequence::difference_type id = i;
    +      Sequence::difference_type jd = j;
    +      return swig::getslice(self, id, jd, step);
         }
     
    -    void __setitem__(PySliceObject *slice, const Sequence& v)
    -      throw (std::out_of_range, std::invalid_argument) {
    +    void __setitem__(PySliceObject *slice, const Sequence& v) throw (std::out_of_range, std::invalid_argument) {
           Py_ssize_t i, j, step;
           if( !PySlice_Check(slice) ) {
             SWIG_Error(SWIG_TypeError, "Slice object expected.");
             return;
           }
    -      PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), self->size(), &i, &j, &step);
    -      swig::setslice(self, i, j, step, v);
    +      PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step);
    +      Sequence::difference_type id = i;
    +      Sequence::difference_type jd = j;
    +      swig::setslice(self, id, jd, step, v);
         }
     
    -    void __setitem__(PySliceObject *slice)
    -      throw (std::out_of_range, std::invalid_argument) {
    +    void __setitem__(PySliceObject *slice) throw (std::out_of_range, std::invalid_argument) {
           Py_ssize_t i, j, step;
           if( !PySlice_Check(slice) ) {
             SWIG_Error(SWIG_TypeError, "Slice object expected.");
             return;
           }
    -      PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), self->size(), &i, &j, &step);
    -      swig::delslice(self, i, j, step);
    +      PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step);
    +      Sequence::difference_type id = i;
    +      Sequence::difference_type jd = j;
    +      swig::delslice(self, id, jd, step);
         }
     
    -    void __delitem__(PySliceObject *slice)
    -      throw (std::out_of_range, std::invalid_argument) {
    +    void __delitem__(PySliceObject *slice) throw (std::out_of_range, std::invalid_argument) {
           Py_ssize_t i, j, step;
           if( !PySlice_Check(slice) ) {
             SWIG_Error(SWIG_TypeError, "Slice object expected.");
             return;
           }
    -      PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), self->size(), &i, &j, &step);
    -      swig::delslice(self, i, j, step);
    +      PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step);
    +      Sequence::difference_type id = i;
    +      Sequence::difference_type jd = j;
    +      swig::delslice(self, id, jd, step);
         }
          
       }
    diff --git a/Lib/python/pyhead.swg b/Lib/python/pyhead.swg
    index 206b81a37..803cd0745 100644
    --- a/Lib/python/pyhead.swg
    +++ b/Lib/python/pyhead.swg
    @@ -4,7 +4,6 @@
     #define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type)
     #define PyInt_Check(x) PyLong_Check(x)
     #define PyInt_AsLong(x) PyLong_AsLong(x)
    -#define PyInt_AsUnsignedLongMask(x) PyLong_AsUnsignedLongMask(x)
     #define PyInt_FromLong(x) PyLong_FromLong(x)
     #define PyString_Check(name) PyBytes_Check(name)
     #define PyString_FromString(x) PyUnicode_FromString(x)
    diff --git a/Lib/python/pyprimtypes.swg b/Lib/python/pyprimtypes.swg
    index 43a3375b7..aa5ddaf62 100644
    --- a/Lib/python/pyprimtypes.swg
    +++ b/Lib/python/pyprimtypes.swg
    @@ -100,12 +100,13 @@ SWIGINTERN int
     SWIG_AsVal_dec(unsigned long)(PyObject *obj, unsigned long *val) 
     {
       if (PyInt_Check(obj)) {
    -    unsigned long v = PyInt_AsUnsignedLongMask(obj);
    -    if (!PyErr_Occurred()) {
    +    long v = PyInt_AsLong(obj);
    +    if (v >= 0) {
           if (val) *val = v;
           return SWIG_OK;
    +    } else {
    +      return SWIG_OverflowError;
         }
    -    PyErr_Clear();
       } else if (PyLong_Check(obj)) {
         unsigned long v = PyLong_AsUnsignedLong(obj);
         if (!PyErr_Occurred()) {
    diff --git a/Lib/r/std_common.i b/Lib/r/std_common.i
    index fab7f54d0..8e97521b0 100644
    --- a/Lib/r/std_common.i
    +++ b/Lib/r/std_common.i
    @@ -1,11 +1,16 @@
     %include 
    -%include 
    +
    +
    +/*
    +  Generate the traits for a 'primitive' type, such as 'double',
    +  for which the SWIG_AsVal and SWIG_From methods are already defined.
    +*/
     
     %define %traits_ptypen(Type...)
       %fragment(SWIG_Traits_frag(Type),"header",
    -            fragment=SWIG_AsVal_frag(Type),
    -            fragment=SWIG_From_frag(Type),
    -            fragment="StdTraits") {
    +	    fragment=SWIG_AsVal_frag(Type),
    +	    fragment=SWIG_From_frag(Type),
    +	    fragment="StdTraits") {
     namespace swig {
       template <> struct traits {
         typedef value_category category;
    @@ -27,6 +32,39 @@ namespace swig {
     }
     %enddef
     
    +/* Traits for enums. This is bit of a sneaky trick needed because a generic template specialization of enums
    +   is not possible (unless using template meta-programming which SWIG doesn't support because of the explicit
    +   instantiations required using %template). The STL containers define the 'front' method and the typemap
    +   below is used whenever the front method is wrapped returning an enum. This typemap simply picks up the
    +   standard enum typemap, but additionally drags in a fragment containing the traits_asval and traits_from
    +   required in the generated code for enums. */
    +
    +%define %traits_enum(Type...)
    +  %fragment("SWIG_Traits_enum_"{Type},"header",
    +	    fragment=SWIG_AsVal_frag(int),
    +	    fragment=SWIG_From_frag(int),
    +	    fragment="StdTraits") {
    +namespace swig {
    +  template <>  struct traits_asval {   
    +    typedef Type value_type;
    +    static int asval(SEXP obj, value_type *val) { 
    +      return SWIG_AsVal(int)(obj, (int *)val);
    +    }
    +  };
    +  template <>  struct traits_from {
    +    typedef Type value_type;
    +    static SEXP from(const value_type& val) {
    +      return SWIG_From(int)((int)val);
    +    }
    +  };
    +}
    +}
    +%typemap(out, fragment="SWIG_Traits_enum_"{Type}) const enum SWIGTYPE& front %{$typemap(out, const enum SWIGTYPE&)%}
    +%enddef
    +
    +
    +%include 
    +
     //
     // Generates the traits for all the known primitive
     // C++ types (int, double, ...)
    diff --git a/Lib/r/std_vector.i b/Lib/r/std_vector.i
    index 2d66cdcd4..9fb95c597 100644
    --- a/Lib/r/std_vector.i
    +++ b/Lib/r/std_vector.i
    @@ -192,7 +192,6 @@
       struct traits_asptr < std::vector > {   
         static int asptr(SEXP obj, std::vector **val) {
           std::vector *p;
    -      Rprintf("my asptr\n");
          int res = SWIG_R_ConvertPtr(obj, (void**)&p, type_info< std::vector >(), 0);
           if (SWIG_IsOK(res)) {
     	if (val) *val = p;
    diff --git a/Lib/ruby/rubyrun.swg b/Lib/ruby/rubyrun.swg
    index a8afc6a10..a2d246e97 100644
    --- a/Lib/ruby/rubyrun.swg
    +++ b/Lib/ruby/rubyrun.swg
    @@ -189,7 +189,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags)
             downcast methods. */
           if (obj != Qnil) {
             VALUE value = rb_iv_get(obj, "@__swigtype__");
    -        char* type_name = RSTRING_PTR(value);
    +        const char* type_name = RSTRING_PTR(value);
     				
             if (strcmp(type->name, type_name) == 0) {
               return obj;
    diff --git a/Lib/swig.swg b/Lib/swig.swg
    index b47d4ff2c..97e7c80a4 100644
    --- a/Lib/swig.swg
    +++ b/Lib/swig.swg
    @@ -359,7 +359,7 @@ namespace std {
     
     #ifdef __cplusplus
     %typemap(memberin) char * {
    -  if ($1) delete [] $1;
    +  delete [] $1;
       if ($input) {
          $1 = ($1_type) (new char[strlen((const char *)$input)+1]);
          strcpy((char *)$1, (const char *)$input);
    @@ -376,7 +376,7 @@ namespace std {
       }
     }
     %typemap(globalin) char * {
    -  if ($1) delete [] $1;
    +  delete [] $1;
       if ($input) {
          $1 = ($1_type) (new char[strlen((const char *)$input)+1]);
          strcpy((char *)$1, (const char *)$input);
    @@ -394,7 +394,7 @@ namespace std {
     }
     #else
     %typemap(memberin) char * {
    -  if ($1) free((char *)$1);
    +  free($1);
       if ($input) {
          $1 = ($1_type) malloc(strlen((const char *)$input)+1);
          strcpy((char *)$1, (const char *)$input);
    @@ -411,7 +411,7 @@ namespace std {
       }
     }
     %typemap(globalin) char * {
    -  if ($1) free((char *)$1);
    +  free($1);
       if ($input) {
          $1 = ($1_type) malloc(strlen((const char *)$input)+1);
          strcpy((char *)$1, (const char *)$input);
    diff --git a/README b/README
    index 9eb3bc90c..d846665e3 100644
    --- a/README
    +++ b/README
    @@ -1,6 +1,6 @@
     SWIG (Simplified Wrapper and Interface Generator)
     
    -Version: 2.0.5 (in progress)
    +Version: 2.0.6 (30 April 2012)
     
     Tagline: SWIG is a compiler that integrates C and C++ with languages
              including Perl, Python, Tcl, Ruby, PHP, Java, Ocaml, Lua,
    diff --git a/RELEASENOTES b/RELEASENOTES
    index f517b9db2..faa57bf63 100644
    --- a/RELEASENOTES
    +++ b/RELEASENOTES
    @@ -4,6 +4,22 @@ and CHANGES files.
     
     Release Notes
     =============
    +SWIG-2.0.6 summary:
    +- Regression fix for Python STL wrappers on some systems.
    +
    +SWIG-2.0.5 summary:
    +- Official Android support added including documentation and examples.
    +- Improvements involving templates:
    +  1) Various fixes with templates and typedef types.
    +  2) Some template lookup problems fixed.
    +  3) Templated type fixes to use correct typemaps.
    +- Autodoc documentation generation improvements.
    +- Python STL container wrappers improvements including addition of
    +  stepped slicing.
    +- Approximately 70 fixes and minor enhancements for the following
    +  target languages: AllegroCL, C#, D, Go, Java, Lua, Ocaml, Octave,
    +  Perl, PHP, Python, R, Ruby, Tcl, Xml.
    +
     SWIG-2.0.4 summary:
     - This is mainly a Python oriented release including support for Python
       built-in types for superior performance with the new -builtin option.
    diff --git a/Source/DOH/base.c b/Source/DOH/base.c
    index cfbd2bdc4..db37e147b 100644
    --- a/Source/DOH/base.c
    +++ b/Source/DOH/base.c
    @@ -259,7 +259,7 @@ int DohEqual(const DOH *obj1, const DOH *obj2) {
     
         if (!b1info) {
           return obj1 == obj2;
    -    } else if ((b1info == b2info)) {
    +    } else if (b1info == b2info) {
           return b1info->doh_equal ? (b1info->doh_equal) (b1, b2) : (b1info->doh_cmp ? (b1info->doh_cmp) (b1, b2) == 0 : (b1 == b2));
         } else {
           return 0;
    diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx
    index bf4d15987..bc51cf5ed 100644
    --- a/Source/Modules/d.cxx
    +++ b/Source/Modules/d.cxx
    @@ -4602,7 +4602,7 @@ private:
         co = c + Len(nspace);
     
         while (*c && (c != co)) {
    -      if ((*c == '.')) {
    +      if (*c == '.') {
     	break;
           }
           c++;
    diff --git a/Source/Modules/xml.cxx b/Source/Modules/xml.cxx
    index bcfac1acc..438205f68 100644
    --- a/Source/Modules/xml.cxx
    +++ b/Source/Modules/xml.cxx
    @@ -144,6 +144,8 @@ public:
     	Xml_print_kwargs(Getattr(obj, k));
           } else if (Cmp(k, "parms") == 0 || Cmp(k, "pattern") == 0) {
     	Xml_print_parmlist(Getattr(obj, k));
    +      } else if (Cmp(k, "catchlist") == 0) {
    +	Xml_print_parmlist(Getattr(obj, k), "catchlist");
           } else {
     	DOH *o;
     	print_indent(0);
    @@ -198,10 +200,10 @@ public:
       }
     
     
    -  void Xml_print_parmlist(ParmList *p) {
    +  void Xml_print_parmlist(ParmList *p, const char* markup = "parmlist") {
     
         print_indent(0);
    -    Printf(out, "\n", ++id, p);
    +    Printf(out, "<%s id=\"%ld\" addr=\"%x\" >\n", markup, ++id, p);
         indent_level += 4;
         while (p) {
           print_indent(0);
    @@ -213,7 +215,7 @@ public:
         }
         indent_level -= 4;
         print_indent(0);
    -    Printf(out, "\n");
    +    Printf(out, "\n", markup);
       }
     
       void Xml_print_baselist(List *p) {
    diff --git a/Source/Preprocessor/expr.c b/Source/Preprocessor/expr.c
    index 3e3f39480..e7470378d 100644
    --- a/Source/Preprocessor/expr.c
    +++ b/Source/Preprocessor/expr.c
    @@ -298,16 +298,16 @@ int Preprocessor_expr(DOH *s, int *error) {
     	stack[sp++].op = EXPR_OP;
     	stack[sp].op = EXPR_TOP;
     	stack[sp].svalue = 0;
    -      } else if ((token == SWIG_TOKEN_LPAREN)) {
    +      } else if (token == SWIG_TOKEN_LPAREN) {
     	stack[sp++].op = EXPR_GROUP;
     	stack[sp].op = EXPR_TOP;
     	stack[sp].value = 0;
     	stack[sp].svalue = 0;
           } else if (token == SWIG_TOKEN_ENDLINE) {
    -      } else if ((token == SWIG_TOKEN_STRING)) {
    +      } else if (token == SWIG_TOKEN_STRING) {
     	stack[sp].svalue = NewString(Scanner_text(scan));
     	stack[sp].op = EXPR_VALUE;
    -      } else if ((token == SWIG_TOKEN_ID)) {
    +      } else if (token == SWIG_TOKEN_ID) {
     	stack[sp].value = 0;
     	stack[sp].svalue = 0;
     	stack[sp].op = EXPR_VALUE;
    diff --git a/configure.in b/configure.in
    index 914b523f8..7e6e63844 100644
    --- a/configure.in
    +++ b/configure.in
    @@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script.
     dnl The macros which aren't shipped with the autotools are stored in the
     dnl Tools/config directory in .m4 files.
     
    -AC_INIT([swig],[2.0.5],[http://www.swig.org])
    +AC_INIT([swig],[2.0.6],[http://www.swig.org])
     
     dnl NB: When this requirement is increased to 2.60 or later, AC_PROG_SED
     dnl     definition below can be removed