diff --git a/ANNOUNCE b/ANNOUNCE
index 9ef41142a..770df1b20 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,10 +1,10 @@
-*** ANNOUNCE: SWIG 1.3.40 (in progress) ***
+*** ANNOUNCE: SWIG 1.3.41 (in progress) ***
http://www.swig.org
-We're pleased to announce SWIG-1.3.40, the latest installment in the
-SWIG development effort. SWIG-1.3.40 includes a number of bug fixes
+We're pleased to announce SWIG-1.3.41, the latest installment in the
+SWIG development effort. SWIG-1.3.41 includes a number of bug fixes
and enhancements.
What is SWIG?
@@ -24,11 +24,11 @@ Availability:
-------------
The release is available for download on Sourceforge at
- http://prdownloads.sourceforge.net/swig/swig-1.3.40.tar.gz
+ http://prdownloads.sourceforge.net/swig/swig-1.3.41.tar.gz
A Windows version is also available at
- http://prdownloads.sourceforge.net/swig/swigwin-1.3.40.zip
+ http://prdownloads.sourceforge.net/swig/swigwin-1.3.41.zip
Please report problems with this release to the swig-dev mailing list,
details at http://www.swig.org/mail.html.
diff --git a/CCache/Makefile.in b/CCache/Makefile.in
index 29cf8db1b..ef20f48a0 100644
--- a/CCache/Makefile.in
+++ b/CCache/Makefile.in
@@ -37,7 +37,6 @@ $(PACKAGE_NAME).1: ccache.yo
-yodl2man -o $(PACKAGE_NAME).1 ccache.yo
web/ccache-man.html: ccache.yo
- mkdir -p man
yodl2html -o web/ccache-man.html ccache.yo
install: $(PACKAGE_NAME)$(EXEEXT) $(PACKAGE_NAME).1
@@ -64,8 +63,11 @@ test: test.sh
check: test
distclean: clean distclean-docs
- /bin/rm -f Makefile config.h config.sub config.log build-stamp config.status configure config.h
+ /bin/rm -f Makefile config.h config.sub config.log build-stamp config.status config.h.in ccache_swig_config.h
+maintainer-clean: distclean
+ /bin/rm -f configure
+
# FIXME: To fix this, test.sh needs to be able to take ccache from the
# installed prefix, not from the source dir.
installcheck:
diff --git a/CHANGES b/CHANGES
index d9426512b..509484e2f 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,264 @@ SWIG (Simplified Wrapper and Interface Generator)
See CHANGES.current for current version.
+Version 1.3.40 (18 August 2009)
+===============================
+
+2009-08-17: olly
+ [Perl] Add "#undef do_exec" to our clean up of Perl global
+ namespace pollution.
+
+2009-08-17: olly
+ [PHP] Fix to wrap a resource returned by __get() in a PHP object (SF#2549217).
+
+2009-08-17: wsfulton
+ Fix #2797485 After doing a 'make clean', install fails if yodl2man or yodl2html
+ is not available.
+
+2009-08-16: wsfulton
+ [Octave] Caught exceptions display the type of the C++ exception instead of the
+ generic "c++-side threw an exception" message.
+
+2009-08-16: wsfulton
+ [Java] When %catches is used, fix so that any classes specified in the "throws"
+ attribute of the "throws" typemap are generated into the Java method's throws clause.
+
+2009-08-16: wsfulton
+ [C#] Fix exception handling when %catches is used, reported by Juan Manuel Alvarez.
+
+2009-08-15: wsfulton
+ Fix %template seg fault on some cases of overloading the templated method.
+ Bug reported by Jan Kupec.
+
+2009-08-15: wsfulton
+ [Ruby] Add numerous missing wrapped methods for std::vector specialization
+ as reported by Youssef Jones.
+
+2009-08-14: wsfulton
+ [Perl] Add SWIG_ConvertPtrAndOwn() method into the runtime for smart pointer
+ memory ownership control. shared_ptr support still to be added. Patch from
+ David Fletcher.
+
+2009-08-14: olly
+ [PHP] PHP5 now wraps static member variables as documented.
+
+2009-08-14: olly
+ [PHP] Update the PHP "class" example to work with PHP5 and use
+ modern wrapping features.
+
+2009-08-13: wsfulton
+ [PHP] std::vector wrappers overhaul. They no longer require the
+ specialize_std_vector() macro. Added wrappers for capacity() and reserve().
+
+2009-08-13: wsfulton
+ [PHP] Add const reference typemaps. const reference primitive types are
+ now passed by value rather than pointer like the other target languages.
+ Fixes SF#2524029.
+
+2009-08-08: wsfulton
+ [Python] More user friendly AttributeError is raised when there are
+ no constructors generated for the proxy class in the event that the
+ class is abstract - the error message is now
+ "No constructor defined - class is abstract" whereas if there are no
+ public constructors for any other reason and the class is not abstract,
+ the message remains
+ "No constructor defined".
+ [tcl] Similarly for tcl when using -itcl.
+
+2009-08-04: olly
+ [PHP] Fix generated code to work with PHP 5.3.
+
+2009-08-04: vmiklos
+ [PHP] Various mathematical functions (which would conflict
+ with the built-in PHP ones) are now automatically handled by
+ adding a 'c_' prefix.
+
+2009-08-03: wsfulton
+ [C#] The std::vector implementation is improved and now uses $typemap such
+ that the proxy class for T no longer has to be specified in some macros
+ for correct C# compilation; the following macros are deprecated, where
+ CSTYPE was the C# type for the C++ class CTYPE:
+
+ SWIG_STD_VECTOR_SPECIALIZE_MINIMUM(CSTYPE, CTYPE)
+ usage should be removed altogether
+
+ SWIG_STD_VECTOR_SPECIALIZE(CSTYPE, CTYPE)
+ should be replaced with:
+ SWIG_STD_VECTOR_ENHANCED(CTYPE)
+
+ Some more details in csharp/std_vector.i
+
+ *** POTENTIAL INCOMPATIBILITY ***
+
+2009-07-31: olly
+ [Python] Fix indentation so that we give a useful error if the
+ module can't be loaded. Patch from Gaetan Lehmann in SF#2829853.
+
+2009-07-29: wsfulton
+ Add $typemap(method, typelist) special variable macro. This allows
+ the contents of a typemap to be inserted within another typemap.
+ Fully documented in Typemaps.html.
+
+2009-07-29: vmiklos
+ [PHP] Static member variables are now prefixed with the
+ class name. This allows static member variables with the
+ same name in different classes.
+
+2009-07-29: olly
+ [Python] Add missing locks to std::map wrappers. Patch from
+ Paul Hampson in SF#2813836.
+
+2009-07-29: olly
+ [PHP] Fix memory leak in PHP OUTPUT typemaps. Reported by Hitoshi
+ Amano in SF#2826322.
+
+2009-07-29: olly
+ [PHP] Fix memory leak in PHP resource destructor for classes
+ without a destructor and non-class types. Patch from Hitoshi Amano
+ in SF#2825303.
+
+2009-07-28: olly
+ [PHP] Update warnings about clashes between identifiers and PHP
+ keywords and automatic renaming to work with the PHP5 class
+ wrappers. Fixes SF#1613679.
+
+2009-07-28: vmiklos
+ [PHP] If a member function is not public but it has a base
+ which is public, then now a warning is issued and the member
+ function will be public, as PHP requires this.
+
+2009-07-21: vmiklos
+ [PHP] Director support added.
+
+2009-07-15: olly
+ [Perl] Don't specify Perl prototype "()" for a constructor with a
+ different name to the class, as such constructors can still take
+ parameters.
+
+2009-07-12: xavier98
+ [Octave] Add support for Octave 3.2 API
+
+2009-07-05: olly
+ [PHP] Update the list of PHP keywords - "cfunction" is no longer a
+ keyword in PHP5 and PHP 5.3 added "goto", "namespace", "__DIR__",
+ and "__NAMESPACE__".
+
+2009-07-03: olly
+ [Tcl] To complement USE_TCL_STUBS, add support for USE_TK_STUBS
+ and SWIG_TCL_STUBS_VERSION. Document all three in the Tcl chapter
+ of the manual. Based on patch from SF#2810380 by Christian
+ Gollwitzer.
+
+2009-07-02: vmiklos
+ [PHP] Added factory.i for PHP, see the li_factory testcase
+ for more info on how to use it.
+
+2009-07-02: wsfulton
+ Fix -Wallkw option as reported by Solomon Gibbs.
+
+2009-07-02: wsfulton
+ Fix syntax error when a nested struct contains a comment containing a * followed
+ eventually by a /. Regression from 1.3.37, reported by Solomon Gibbs.
+
+2009-07-01: vmiklos
+ [PHP] Unknown properties are no longer ignored in proxy
+ classes.
+
+2009-07-01: vmiklos
+ [PHP] Fixed %newobject behaviour, previously any method
+ marked with %newobject was handled as a constructor.
+
+2009-06-30: olly
+ [Ruby] Undefine close and connect macros defined by Ruby API
+ headers as we don't need them and they can clash with C++ methods
+ being wrapped. Patch from Vit Ondruch in SF#2814430.
+
+2009-06-26: olly
+ [Ruby] Fix to handle FIXNUM values greater than MAXINT passed for a
+ double parameter.
+
+2009-06-24: wsfulton
+ Fix wrapping methods with default arguments and the compactdefaultargs feature
+ where a class is passed by value and is assigned a default value. The SwigValueWrapper
+ template workaround for a missing default constructor is no longer used as the code
+ generated does not call the default constructor.
+
+2009-06-16: wsfulton
+ [Java,C#] Fix enum marshalling when %ignore is used on one of the enum items.
+ Incorrect enum values were being passed to the C++ layer or compilation errors resulted.
+
+2009-06-02: talby
+ [Perl] Resolved reference.i overload support problem
+ identified by John Potowsky.
+
+2009-05-26: wsfulton
+ [C#] Improved std::map wrappers based on patch from Yuval Baror. The C# proxy
+ now implements System.Collections.Generic.IDictionary<>.
+
+ These std:map wrappers have a non-backwards compatible overhaul to make them
+ like a .NET IDictionary. Some method names have changed as following:
+ set -> setitem (use this[] property now)
+ get -> getitem (use this[] property now)
+ has_key -> ContainsKey
+ del -> Remove
+ clear -> Clear
+
+ The following macros used for std::map wrappers are deprecated and will no longer work:
+ specialize_std_map_on_key
+ specialize_std_map_on_value
+ specialize_std_map_on_both
+
+ *** POTENTIAL INCOMPATIBILITY ***
+
+2009-05-20: vmiklos
+ [PHP] Add the 'thisown' member to classes. The usage of it
+ is the same as the Python thisown one: it's 1 by default and
+ you can set it to 0 if you want to prevent freeing it. (For
+ example to prevent a double free.)
+
+2009-05-14: bhy
+ [Python] Fix the wrong pointer value returned by SwigPyObject_repr().
+
+2009-05-13: mutandiz (Mikel Bancroft)
+ [allegrocl] Minor tweak when wrapping in -nocwrap mode.
+
+2009-05-11: wsfulton
+ [C#] Improved std::vector wrappers on the C# proxy side from Yuval Baror. These
+ implement IList<> instead of IEnumerable<> where possible.
+
+2009-04-29: wsfulton
+ [Java, C#] Add the 'notderived' attribute to the javabase and csbase typemaps.
+ When this attribute is set, the typemap will not apply to classes that are derived
+ from a C++ base class, eg
+ %typemap(csbase, notderived="1") SWIGTYPE "CommonBase"
+
+2009-04-29: olly
+ [Python] Don't attempt to acquire the GIL in situations where we
+ know that it will already be locked. This avoids some dead-locks
+ with mod_python (due to mod_python bugs which are apparently
+ unlikely to ever be fixed), and results in smaller wrappers which
+ run a little faster (in tests with Xapian on x86-64 Ubuntu 9.04,
+ the stripped wrapper library was 11% smaller and ran 2.7% faster).
+
+2009-04-21: wsfulton
+ [C#] Fix #2753469 - bool &OUTPUT and bool *OUTPUT typemaps initialisation.
+
+2009-04-09: wsfulton
+ Fix #2746858 - C macro expression using floating point numbers
+
+2009-03-30: olly
+ [PHP] The default out typemap for char[ANY] now returns the string up to a
+ zero byte, or the end of the array if there is no zero byte. This
+ is the same as Python does, and seems more generally useful than
+ the previous behaviour of returning the whole contents of the array
+ including any zero bytes. If you want the old behaviour, you can provide
+ your own typemap to do this:
+
+ %typemap(out) char [ANY]
+ %{
+ RETVAL_STRINGL($1, $1_dim0, 1);
+ %}
+
Version 1.3.39 (21 March 2009)
==============================
diff --git a/CHANGES.current b/CHANGES.current
index 1021106f1..f435f9cb8 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -1,257 +1,295 @@
-Version 1.3.40 (in progress)
+Version 1.3.41 (in progress)
============================
-2009-08-17: olly
- [Perl] Add "#undef do_exec" to our clean up of Perl global
- namespace pollution.
+2010-01-11: wsfulton
+ Slight change to warning, error and diagnostic reporting. The warning number is no
+ longer shown within brackets. This is to help default parsing of warning messages by
+ other tools, vim on Unix in particular.
-2009-08-17: olly
- [PHP] Fix to wrap a resource returned by __get() in a PHP object (SF#2549217).
+ Example original display using -Fstandard:
+ example.i:20: Warning(401): Nothing known about base class 'B'. Ignored.
+ New display:
+ example.i:20: Warning 401: Nothing known about base class 'B'. Ignored.
-2009-08-17: wsfulton
- Fix #2797485 After doing a 'make clean', install fails if yodl2man or yodl2html
- is not available.
+ Also subtle fix to -Fmicrosoft format adding in missing space. Example original display:
+ example.i(20): Warning(401): Nothing known about base class 'Base'. Ignored.
+ New display:
+ example.i(20) : Warning 401: Nothing known about base class 'Base'. Ignored.
-2009-08-16: wsfulton
- [Octave] Caught exceptions display the type of the C++ exception instead of the
- generic "c++-side threw an exception" message.
+2010-01-10: wsfulton
+ Fix a few inconsistencies in reporting of file/line numberings including modifying
+ the overload warnings 509, 512, 516, 474, 475 to now be two line warnings.
-2009-08-16: wsfulton
- [Java] When %catches is used, fix so that any classes specified in the "throws"
- attribute of the "throws" typemap are generated into the Java method's throws clause.
+2010-01-10: wsfulton
+ Modify -debug-tags output to use standard file name/line reporting so that editors
+ can easily navigate to the appropriate lines.
+ Was typically:
+ . top . include . include (/usr/share/swig/temp/trunk/Lib/swig.swg:312)
+ . top . include . include . include (/usr/share/swig/temp/trunk/Lib/swigwarnings.swg:39)
+ now:
+ /usr/share/swig/temp/trunk/Lib/swig.swg:312: . top . include . include
+ /usr/share/swig/temp/trunk/Lib/swigwarnings.swg:39: . top . include . include . include
-2009-08-16: wsfulton
- [C#] Fix exception handling when %catches is used, reported by Juan Manuel Alvarez.
+2010-01-03: wsfulton
+ Fix missing file/line numbers for typemap warnings and in output from the
+ -debug-tmsearch/-debug-tmused options.
-2009-08-15: wsfulton
- Fix %template seg fault on some cases of overloading the templated method.
- Bug reported by Jan Kupec.
+2010-01-03: wsfulton
+ Add typemaps used debugging option (-debug-tmused). When used each line displays
+ the typemap used for each type for which code is being generated including the file
+ and line number related to the type. This is effectively a condensed form of the
+ -debug-tmsearch option. Documented in Typemaps.html.
-2009-08-15: wsfulton
- [Ruby] Add numerous missing wrapped methods for std::vector specialization
- as reported by Youssef Jones.
+2009-12-23: wsfulton
+ Fix for %javaexception and directors so that all the appropriate throws clauses
+ are generated. Problem reported by Peter Greenwood.
-2009-08-14: wsfulton
- [Perl] Add SWIG_ConvertPtrAndOwn() method into the runtime for smart pointer
- memory ownership control. shared_ptr support still to be added. Patch from
- David Fletcher.
+2009-12-20: wsfulton
+ Add -debug-tmsearch option for debugging the typemap pattern matching rules.
+ Documented in Typemaps.html.
-2009-08-14: olly
- [PHP] PHP5 now wraps static member variables as documented.
+2009-12-12: wsfulton
+ [Octave] Remove the -api option and use the new OCTAVE_API_VERSION_NUMBER
+ macro provided in the octave headers for determining the api version instead.
-2009-08-14: olly
- [PHP] Update the PHP "class" example to work with PHP5 and use
- modern wrapping features.
+2009-12-04: olly
+ [Ruby] Improve support for Ruby 1.9 under GCC. Addresses part of
+ SF#2859614.
-2009-08-13: wsfulton
- [PHP] std::vector wrappers overhaul. They no longer require the
- specialize_std_vector() macro. Added wrappers for capacity() and reserve().
+2009-12-04: olly
+ Fix handling of modulo operator (%) in constant expressions
+ (SF#2818562).
-2009-08-13: wsfulton
- [PHP] Add const reference typemaps. const reference primitive types are
- now passed by value rather than pointer like the other target languages.
- Fixes SF#2524029.
+2009-12-04: olly
+ [PHP] "empty" is a reserved word in PHP, so rename empty() method
+ on STL classes to "is_empty()" (previously this was automatically
+ renamed to "c_empty()").
+ *** POTENTIAL INCOMPATIBILITY ***
-2009-08-08: wsfulton
- [Python] More user friendly AttributeError is raised when there are
- no constructors generated for the proxy class in the event that the
- class is abstract - the error message is now
- "No constructor defined - class is abstract" whereas if there are no
- public constructors for any other reason and the class is not abstract,
- the message remains
- "No constructor defined".
- [tcl] Similarly for tcl when using -itcl.
+2009-12-03: olly
+ [PHP] Add typemaps for long long and unsigned long long, and for
+ pointer to method.
-2009-08-04: olly
- [PHP] Fix generated code to work with PHP 5.3.
+2009-12-02: olly
+ [PHP] Fix warning and rename of reserved class name to be case
+ insensitive.
-2009-08-04: vmiklos
- [PHP] Various mathematical functions (which would conflict
- with the built-in PHP ones) are now automatically handled by
- adding a 'c_' prefix.
+2009-12-01: wsfulton
+ Revert support for %extend and memberin typemaps added in swig-1.3.39. The
+ memberin typemaps are ignored again for member variables within a %extend block.
+ Documentation inconsistency reported by Torsten Landschoff.
-2009-08-03: wsfulton
- [C#] The std::vector implementation is improved and now uses $typemap such
- that the proxy class for T no longer has to be specified in some macros
- for correct C# compilation; the following macros are deprecated, where
- CSTYPE was the C# type for the C++ class CTYPE:
+2009-11-29: wsfulton
+ [Java, C#] Fix generated quoting when using %javaconst(1)/%csconst(1) for
+ static const char member variables.
- SWIG_STD_VECTOR_SPECIALIZE_MINIMUM(CSTYPE, CTYPE)
- usage should be removed altogether
+ %javaconst(1) A;
+ %csconst(1) A;
+ struct X {
+ static const char A = 'A';
+ };
- SWIG_STD_VECTOR_SPECIALIZE(CSTYPE, CTYPE)
- should be replaced with:
- SWIG_STD_VECTOR_ENHANCED(CTYPE)
+2009-11-26: wsfulton
+ [Java, C#] Fix %javaconst(1)/%csconst(1) for static const member variables to
+ use the actual constant value if it is specified, rather than the C++ code to
+ access the member.
- Some more details in csharp/std_vector.i
+ %javaconst(1) EN;
+ %csconst(1) EN;
+ struct X {
+ static const int EN = 2;
+ };
+
+2009-11-23: wsfulton
+ C++ nested typedef classes can now be handled too, for example:
+ struct Outer {
+ typedef Foo { } FooTypedef1, FooTypedef2;
+ };
+
+2009-11-18: wsfulton
+ The wrappers for C nested structs are now generated in the same order as declared
+ in the parsed code.
+
+2009-11-18: wsfulton
+ Fix #491476 - multiple declarations of nested structs, for example:
+ struct Outer {
+ struct {
+ int val;
+ } inner1, inner2, *inner3, inner4[1];
+ } outer;
+
+2009-11-17: wsfulton
+ Fix parsing of enum declaration and initialization, for example:
+
+ enum ABC {
+ a,
+ b,
+ c
+ } A = a, *pC = &C, array[3] = {a, b, c};
+
+2009-11-17: wsfulton
+ Fix parsing of struct declaration and initialization, for example:
+
+ struct S {
+ int x;
+ } instance = { 10 };
+
+2009-11-15: wsfulton
+ Fix #1960977 - Syntax error parsing derived nested class declaration and member
+ variable instance.
+
+2009-11-14: wsfulton
+ Fix #2310483 - function pointer typedef within extern "C" block.
+
+2009-11-13: wsfulton
+ Fix usage of nested template classes within templated classes so that compileable code
+ is generated.
+
+2009-11-13: olly
+ [php] Fix place where class prefix (as specified with -prefix)
+ wasn't being used. Patch from gverbruggen in SF#2892647.
+
+2009-11-12: wsfulton
+ Fix usage of nested template classes so that compileable code is generated - the nested
+ template class is now treated like a normal nested classes, that is, as an opaque type
+ unless the nestedworkaround feature is used.
+
+2009-11-12: wsfulton
+ Replace SWIGWARN_PARSE_NESTED_CLASS with SWIGWARN_PARSE_NAMED_NESTED_CLASS and
+ SWIGWARN_PARSE_UNNAMED_NESTED_CLASS for named and unnamed nested classes respectively.
+
+ Named nested class ignored warnings can now be suppressed by name using %warnfilter, eg:
+
+ %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::Inner;
+
+ but clearly unnamed nested classes cannot and the global suppression is still required, eg:
+
+ #pragma SWIG nowarn=SWIGWARN_PARSE_UNNAMED_NESTED_CLASS
+
+2009-11-11: wsfulton
+ Added the nestedworkaround feature as a way to use the full functionality of a nested class
+ (C++ mode only). It removes the nested class from SWIG's type information so it is as if SWIG
+ had never parsed the nested class. The documented nested class workarounds using a global
+ fake class stopped working when SWIG treated the nested class as an opaque pointer, and
+ this feature reverts this behaviour. The documentation has been updated with details of how
+ to use and implement it, see the "Nested classes" section in SWIGPlus.html.
+
+2009-11-11: wsfulton
+ There were a number of C++ cases where nested classes/structs/unions were being handled
+ as if C code was being parsed which would oftentimes lead to uncompileable code as an
+ attempt was made to wrap the nested structs like it is documented for C code. Now all
+ nested structs/classes/unions are ignored in C++ mode, as was always documented. However,
+ there is an improvement as usage of nested structs/classes/unions is now always treated
+ as an opaque type by default, resulting in generated code that should always compile.
*** POTENTIAL INCOMPATIBILITY ***
-2009-07-31: olly
- [Python] Fix indentation so that we give a useful error if the
- module can't be loaded. Patch from Gaetan Lehmann in SF#2829853.
+2009-11-09: drjoe
+ Fix R for -fcompact and add std_map.i
-2009-07-29: wsfulton
- Add $typemap(method, typelist) special variable macro. This allows
- the contents of a typemap to be inserted within another typemap.
- Fully documented in Typemaps.html.
+2009-11-08: wsfulton
+ Fix inconsistency for nested structs/unions/classes. Uncompileable code was being
+ generated when inner struct and union declarations were used as types within the
+ inner struct. The inner struct/union is now treated as a forward declaration making the
+ behaviour the same as an inner class. (C++ code), eg:
-2009-07-29: vmiklos
- [PHP] Static member variables are now prefixed with the
- class name. This allows static member variables with the
- same name in different classes.
+ struct Outer {
+ struct InnerStruct { int x; };
+ InnerStruct* getInnerStruct();
+ };
-2009-07-29: olly
- [Python] Add missing locks to std::map wrappers. Patch from
- Paul Hampson in SF#2813836.
+2009-11-08: wsfulton
+ Ignored nested class/struct warnings now display the name of the ignored class/struct.
-2009-07-29: olly
- [PHP] Fix memory leak in PHP OUTPUT typemaps. Reported by Hitoshi
- Amano in SF#2826322.
+2009-11-07: wsfulton
+ Bug #1514681 - Fix nested template classes within a namespace generated uncompileable
+ code and introduced strange side effects to other wrapper code especially code
+ after the nested template class. Note that nested template classes are still ignored.
-2009-07-29: olly
- [PHP] Fix memory leak in PHP resource destructor for classes
- without a destructor and non-class types. Patch from Hitoshi Amano
- in SF#2825303.
+2009-11-07: wsfulton
+ Add new debug options:
+ -debug-symtabs - Display symbol tables information
+ -debug-symbols - Display target language symbols in the symbol tables
+ -debug-csymbols - Display C symbols in the symbol tables
-2009-07-28: olly
- [PHP] Update warnings about clashes between identifiers and PHP
- keywords and automatic renaming to work with the PHP5 class
- wrappers. Fixes SF#1613679.
+2009-11-03: wsfulton
+ Fix some usage of global scope operator, for example:
-2009-07-28: vmiklos
- [PHP] If a member function is not public but it has a base
- which is public, then now a warning is issued and the member
- function will be public, as PHP requires this.
+ namespace AA { /* ... */ }
+ using namespace ::AA;
-2009-07-21: vmiklos
- [PHP] Director support added.
+ and bug #1816802 - SwigValueWrapper should be used:
-2009-07-15: olly
- [Perl] Don't specify Perl prototype "()" for a constructor with a
- different name to the class, as such constructors can still take
- parameters.
+ struct CC {
+ CC(int); // no default constructor
+ };
+ ::CC x();
-2009-07-12: xavier98
- [Octave] Add support for Octave 3.2 API
+ and in template parameter specializations:
-2009-07-05: olly
- [PHP] Update the list of PHP keywords - "cfunction" is no longer a
- keyword in PHP5 and PHP 5.3 added "goto", "namespace", "__DIR__",
- and "__NAMESPACE__".
+ struct S {};
+ template struct X { void a() {}; };
+ template <> struct X { void b() {}; };
+ %template(MyTConcrete) X< ::S >;
-2009-07-03: olly
- [Tcl] To complement USE_TCL_STUBS, add support for USE_TK_STUBS
- and SWIG_TCL_STUBS_VERSION. Document all three in the Tcl chapter
- of the manual. Based on patch from SF#2810380 by Christian
- Gollwitzer.
+ plus probably some other corner case usage of ::.
-2009-07-02: vmiklos
- [PHP] Added factory.i for PHP, see the li_factory testcase
- for more info on how to use it.
+2009-11-02: olly
+ [Python] Fix potential memory leak in initialisation code for the
+ generated module.
-2009-07-02: wsfulton
- Fix -Wallkw option as reported by Solomon Gibbs.
+2009-10-23: wsfulton
+ Fix seg fault when using a named nested template instantiation using %template(name)
+ within a class. A warning that these are not supported is now issued plus processing
+ continues as if no name was given.
-2009-07-02: wsfulton
- Fix syntax error when a nested struct contains a comment containing a * followed
- eventually by a /. Regression from 1.3.37, reported by Solomon Gibbs.
+2009-10-20: wsfulton
+ [Python] Fix std::vector. This would previously compile, but not run correctly.
-2009-07-01: vmiklos
- [PHP] Unknown properties are no longer ignored in proxy
- classes.
+2009-10-20: wsfulton
+ Fixed previously fairly poor template partial specialization and explicit
+ specialization support. Numerous bugs in this area have been fixed including:
-2009-07-01: vmiklos
- [PHP] Fixed %newobject behaviour, previously any method
- marked with %newobject was handled as a constructor.
+ - Template argument deduction implemented for template type arguments, eg this now
+ works:
+ template class X {};
+ template class X {};
+ %template(X1) X; // Chooses T * specialization
-2009-06-30: olly
- [Ruby] Undefine close and connect macros defined by Ruby API
- headers as we don't need them and they can clash with C++ methods
- being wrapped. Patch from Vit Ondruch in SF#2814430.
+ and more complex cases with multiple parameters and a mix of template argument
+ deduction and explicitly specialised parameters, eg:
+ template struct TwoParm { void a() {} };
+ template struct TwoParm { void e() {} };
+ %template(E) TwoParm;
-2009-06-26: olly
- [Ruby] Fix to handle FIXNUM values greater than MAXINT passed for a
- double parameter.
-
-2009-06-24: wsfulton
- Fix wrapping methods with default arguments and the compactdefaultargs feature
- where a class is passed by value and is assigned a default value. The SwigValueWrapper
- template workaround for a missing default constructor is no longer used as the code
- generated does not call the default constructor.
-
-2009-06-16: wsfulton
- [Java,C#] Fix enum marshalling when %ignore is used on one of the enum items.
- Incorrect enum values were being passed to the C++ layer or compilation errors resulted.
-
-2009-06-02: talby
- [Perl] Resolved reference.i overload support problem
- identified by John Potowsky.
-
-2009-05-26: wsfulton
- [C#] Improved std::map wrappers based on patch from Yuval Baror. The C# proxy
- now implements System.Collections.Generic.IDictionary<>.
-
- These std:map wrappers have a non-backwards compatible overhaul to make them
- like a .NET IDictionary. Some method names have changed as following:
- set -> setitem (use this[] property now)
- get -> getitem (use this[] property now)
- has_key -> ContainsKey
- del -> Remove
- clear -> Clear
-
- The following macros used for std::map wrappers are deprecated and will no longer work:
- specialize_std_map_on_key
- specialize_std_map_on_value
- specialize_std_map_on_both
+ Note that the primary template must now be in scope, like in C++, when
+ an explicit or partial specialization is instantiated with %template.
*** POTENTIAL INCOMPATIBILITY ***
-2009-05-20: vmiklos
- [PHP] Add the 'thisown' member to classes. The usage of it
- is the same as the Python thisown one: it's 1 by default and
- you can set it to 0 if you want to prevent freeing it. (For
- example to prevent a double free.)
+2009-09-14: wsfulton
+ [C#] Add %csattributes for adding C# attributes to enum values, see docs for example.
-2009-05-14: bhy
- [Python] Fix the wrong pointer value returned by SwigPyObject_repr().
+2009-09-11: wsfulton
+ Fix memmove regression in cdata.i as reported by Adriaan Renting.
-2009-05-13: mutandiz (Mikel Bancroft)
- [allegrocl] Minor tweak when wrapping in -nocwrap mode.
+2009-09-07: wsfulton
+ Fix constant expressions containing <= or >=.
-2009-05-11: wsfulton
- [C#] Improved std::vector wrappers on the C# proxy side from Yuval Baror. These
- implement IList<> instead of IEnumerable<> where possible.
+2009-09-02: wsfulton
+ The following operators in constant expressions now result in type bool for C++
+ wrappers and remain as type int for C wrappers, as per each standard:
-2009-04-29: wsfulton
- [Java, C#] Add the 'notderived' attribute to the javabase and csbase typemaps.
- When this attribute is set, the typemap will not apply to classes that are derived
- from a C++ base class, eg
- %typemap(csbase, notderived="1") SWIGTYPE "CommonBase"
+ && || == != < > <= >= (Actually the last 4 are still broken). For example:
-2009-04-29: olly
- [Python] Don't attempt to acquire the GIL in situations where we
- know that it will already be locked. This avoids some dead-locks
- with mod_python (due to mod_python bugs which are apparently
- unlikely to ever be fixed), and results in smaller wrappers which
- run a little faster (in tests with Xapian on x86-64 Ubuntu 9.04,
- the stripped wrapper library was 11% smaller and ran 2.7% faster).
+ #define A 10
+ #define B 10
+ #define A_EQ_B A == B // now wrapped as type bool for C++
+ #define A_AND_B A && B // now wrapped as type bool for C++
-2009-04-21: wsfulton
- [C#] Fix #2753469 - bool &OUTPUT and bool *OUTPUT typemaps initialisation.
+2009-09-02: wsfulton
+ Fix #2845746. true and false are now recognised keywords (only when wrapping C++).
+ Constants such as the following are now wrapped (as type bool):
+ #define FOO true
+ #define BAR FOO && false
-2009-04-09: wsfulton
- Fix #2746858 - C macro expression using floating point numbers
-
-2009-03-30: olly
- [PHP] The default out typemap for char[ANY] now returns the string up to a
- zero byte, or the end of the array if there is no zero byte. This
- is the same as Python does, and seems more generally useful than
- the previous behaviour of returning the whole contents of the array
- including any zero bytes. If you want the old behaviour, you can provide
- your own typemap to do this:
-
- %typemap(out) char [ANY]
- %{
- RETVAL_STRINGL($1, $1_dim0, 1);
- %}
diff --git a/Doc/Devel/internals.html b/Doc/Devel/internals.html
index ea36f844d..63a8626ff 100644
--- a/Doc/Devel/internals.html
+++ b/Doc/Devel/internals.html
@@ -1070,31 +1070,35 @@ With each is the cast that can be used in the debugger to extract the underlying
String *s;
-(String *)((DohBase *)s)->data
+(struct String *)((DohBase *)s)->data
The underlying char * string can be displayed with
-((String *)((DohBase *)s)->data)->str
+(*(struct String *)(((DohBase *)s)->data)).str
SwigType *t;
-(String *)((DohBase *)t)->data
+(struct String *)((DohBase *)t)->data
The underlying char * string can be displayed with
-((String *)((DohBase *)t)->data)->str
+(*(struct String *)(((DohBase *)t)->data)).str
-
String_or_char *sc;
+const_String_or_char_ptr sc;
Either
-((String *)((DohBase *)sc)->data)->str
+(*(struct String *)(((DohBase *)sc)->data)).str
or
(char *)sc
will work depending on whether the underlying type is really a String * or char *.
+
+Please also read the Debugging Functions section in SWIG Parse Tree Handling for the Swig_print_node(), Swig_print_tree() and Swig_print_tags() functions for displaying node contents. It is often easier to place a few calls to these functions in code of interest and recompile than use the debugger.
+
+
Copyright (C) 1999-2004 SWIG Development Team.
diff --git a/Doc/Devel/tree.html b/Doc/Devel/tree.html
index 64d9d197d..43ad191f6 100644
--- a/Doc/Devel/tree.html
+++ b/Doc/Devel/tree.html
@@ -218,10 +218,10 @@ The following functions are used to help debug SWIG parse trees.
Prints the tag-structure of the parse tree to standard output. node is the top-level parse tree node. prefix is
a string prefix thats added to the start of each line. Normally, you would specify the empty string or NIL for prefix.
-This function is called by the -dump_tags option to SWIG.
+This function is called by the -debug-tags option to SWIG.
-% swig -dump_tags -python example.i
+% swig -debug-tags -python example.i
. top (:1)
. top . include (/Users/beazley/Projects/share/swig/1.3.31/swig.swg:0)
. top . include . include (/Users/beazley/Projects/share/swig/1.3.31/swigwarnings.swg:0)
@@ -243,7 +243,7 @@ Since many language modules include hundreds of typemaps and other information,
Prints the contents of a parse tree node, including all children, to standard output. The output includes all attributes
-and other details. The command line option -dump_tree produces output generated by this function.
+and other details.
@@ -251,8 +251,8 @@ and other details. The command line option -dump_tree produces output
Prints the same output as Swig_print_node() except that it also processes all of the siblings of node. This can
-be used to dump the entire parse tree to standard output. Use the command line option -dump_tree to get
-the output of this function for a SWIG input file.
+be used to dump the entire parse tree to standard output. The command line options -debug-module
+and -debug-top use this function to display the parse tree for a SWIG input file.
diff --git a/Doc/Manual/Allegrocl.html b/Doc/Manual/Allegrocl.html
index cc950db7c..cf70f6c27 100644
--- a/Doc/Manual/Allegrocl.html
+++ b/Doc/Manual/Allegrocl.html
@@ -14,7 +14,7 @@
- Basics
@@ -138,7 +138,7 @@ to it.
17.1 Basics
-17.1.1 Running Swig
+17.1.1 Running SWIG
diff --git a/Doc/Manual/Arguments.html b/Doc/Manual/Arguments.html
index 911e8548e..8ab51faf6 100644
--- a/Doc/Manual/Arguments.html
+++ b/Doc/Manual/Arguments.html
@@ -30,8 +30,6 @@
-Disclaimer: This chapter is under construction.
-
In Chapter 3, SWIG's treatment of basic datatypes and pointers was
described. In particular, primitive types such as int and
diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html
index f747fc213..324be63ec 100644
--- a/Doc/Manual/CSharp.html
+++ b/Doc/Manual/CSharp.html
@@ -55,7 +55,7 @@ The PInvoke interface has been chosen over Microsoft's Managed C++ interface as
PInvoke is part of the ECMA/ISO C# specification.
It is also better suited for robust production environments due to the Managed C++ flaw called the
Mixed DLL Loading Problem.
-Swig C# works equally well on non-Microsoft operating systems such as Linux, Solaris and Apple Mac using
+SWIG C# works equally well on non-Microsoft operating systems such as Linux, Solaris and Apple Mac using
Mono and Portable.NET.
@@ -249,7 +249,9 @@ public static extern IntPtr function(string jarg1);
Support for type attributes.
The 'imtype' and 'cstype' typemaps can have an optional inattributes and outattributes typemap attribute.
-There are C# attributes and typemap attributes, don't get confused!!
+The 'imtype' typemap can also have an optional directorinattributes and directoroutattributes
+typemap attribute which attaches to director delegates, an implementation detail of directors, see directors implementation.
+Note that there are C# attributes and typemap attributes, don't get confused between the two!!
The C# attributes specified in these typemap attributes are generated wherever the type is used in the C# wrappers.
These can be used to specify any C# attribute associated with a C/C++ type, but are more typically used for the C# MarshalAs attribute.
For example:
@@ -293,11 +295,16 @@ These attributes are associated with the C/C++ parameter type or return type, wh
the attribute features and typemaps covered next.
Note that all these different C# attributes can be combined so that a method has more than one attribute.
+
+
+The directorinattributes and directoroutattributes typemap attribute are attached to the delegates in the director class, for example, the SwigDelegateBase_0
+
+
-
-Support for attaching C# attributes to wrapped methods and variables.
+Support for attaching C# attributes to wrapped methods, variables and enum values.
This is done using the %csattributes feature, see %feature directives.
Note that C# attributes are attached to proxy classes and enums using the csattributes typemap.
For example, imagine we have a custom attribute class, ThreadSafeAttribute, for labelling thread safety.
@@ -344,6 +351,38 @@ they can be added using the 'csvarin' and 'csvarout' typemaps respectively.
Note that the type used for the property is specified in the 'cstype' typemap.
If the 'out' attribute exists in this typemap, then the type used is from the 'out' attribute.
+
+
+An example for attaching attributes to the enum and enum values is shown below.
+
+
+
+
+%typemap(csattributes) Couleur "[System.ComponentModel.Description(\"Colours\")]"
+%csattributes Rouge "[System.ComponentModel.Description(\"Red\")]"
+%csattributes Vert "[System.ComponentModel.Description(\"Green\")]"
+%inline %{
+ enum Couleur { Rouge, Orange, Vert };
+%}
+
+
+
+
+which will result in the following C# enum:
+
+
+
+
+[System.ComponentModel.Description("Colours")]
+public enum Couleur {
+ [System.ComponentModel.Description("Red")]
+ Rouge,
+ Orange,
+ [System.ComponentModel.Description("Green")]
+ Vert
+}
+
+
-
@@ -948,7 +987,7 @@ without setting the canthrow attribute you will get a warning message s
-example.i:21: Warning(845): Unmanaged code contains a call to a SWIG_CSharpSetPendingException
+example.i:21: Warning 845: Unmanaged code contains a call to a SWIG_CSharpSetPendingException
method and C# code does not handle pending exceptions via the canthrow attribute.
diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html
index 0e7ebf464..0cda0b8f4 100644
--- a/Doc/Manual/Contents.html
+++ b/Doc/Manual/Contents.html
@@ -346,10 +346,11 @@
- Pattern matching rules
- Code generation rules
-
- Typemaps for multiple languages
+
- Typemaps for multiple target languages
- Optimal code generation when returning by value
- Multi-argument typemaps
- The run-time type checker
@@ -537,7 +538,7 @@
- Typemaps
diff --git a/Doc/Manual/Customization.html b/Doc/Manual/Customization.html
index ec73e5460..82e1c411f 100644
--- a/Doc/Manual/Customization.html
+++ b/Doc/Manual/Customization.html
@@ -53,6 +53,21 @@ The %exception directive allows you to define a general purpose excepti
handler. For example, you can specify the following:
+
+%exception {
+ try {
+ $action
+ }
+ catch (RangeError) {
+ ... handle error ...
+ }
+}
+
+
+
+How the exception is handled depends on the target language, for example, Python:
+
+
%exception {
try {
@@ -60,7 +75,7 @@ handler. For example, you can specify the following:
}
catch (RangeError) {
PyErr_SetString(PyExc_IndexError,"index out-of-bounds");
- return NULL;
+ SWIG_fail;
}
}
diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html
index 0ebaeaa04..040eb65c7 100644
--- a/Doc/Manual/Extending.html
+++ b/Doc/Manual/Extending.html
@@ -48,7 +48,7 @@
Writing a Language Module
-Typemaps
-
+Debugging Options
Guide to parse tree nodes
+Further Development Information
@@ -2471,7 +2473,7 @@ the parsing of command line options, all aspects of code generation are controll
different methods of the Language that must be defined by your module.
-35.10.2 Starting out
+35.10.2 Starting out
@@ -2602,24 +2604,24 @@ void Language::main(int argc, char *argv[]) {
} else {
Swig_arg_error();
}
- } else if (strcmp(argv[i],"-globals") == 0) {
- if (argv[i+1]) {
- global_name = NewString(argv[i+1]);
- Swig_mark_arg(i);
- Swig_mark_arg(i+1);
- i++;
- } else {
- Swig_arg_error();
- }
- } else if ( (strcmp(argv[i],"-proxy") == 0)) {
- proxy_flag = 1;
- Swig_mark_arg(i);
- } else if (strcmp(argv[i],"-keyword") == 0) {
- use_kw = 1;
- Swig_mark_arg(i);
- } else if (strcmp(argv[i],"-help") == 0) {
- fputs(usage,stderr);
- }
+ } else if (strcmp(argv[i],"-globals") == 0) {
+ if (argv[i+1]) {
+ global_name = NewString(argv[i+1]);
+ Swig_mark_arg(i);
+ Swig_mark_arg(i+1);
+ i++;
+ } else {
+ Swig_arg_error();
+ }
+ } else if ( (strcmp(argv[i],"-proxy") == 0)) {
+ proxy_flag = 1;
+ Swig_mark_arg(i);
+ } else if (strcmp(argv[i],"-keyword") == 0) {
+ use_kw = 1;
+ Swig_mark_arg(i);
+ } else if (strcmp(argv[i],"-help") == 0) {
+ fputs(usage,stderr);
+ }
...
}
}
@@ -3053,7 +3055,7 @@ but without the typemaps, there is still work to do.
-At the time of this writing, SWIG supports nearly a dozen languages,
+At the time of this writing, SWIG supports nearly twenty languages,
which means that for continued sanity in maintaining the configuration
files, the language modules need to follow some conventions. These are
outlined here along with the admission that, yes it is ok to violate
@@ -3225,7 +3227,7 @@ The following are the minimum that are usually supported:
Please copy these and modify for any new language.
-35.10.11 Examples and test cases
+35.10.11 User examples
@@ -3254,7 +3256,226 @@ during this process, see the section on configuration
files.
-35.10.12 Documentation
+35.10.12 Test driven development and the test-suite
+
+
+
+A test driven development approach is central to the improvement and development of SWIG.
+Most modifications to SWIG are accompanied by additional regression tests and checking all
+tests to ensure that no regressions have been introduced.
+
+
+
+The regression testing is carried out by the SWIG test-suite.
+The test-suite consists of numerous testcase interface files in the Examples/test-suite directory
+as well as target language specific runtime tests in the Examples/test-suite/[lang] directory.
+When a testcase is run, it will execute the following steps for each testcase:
+
+
+
+- Execute SWIG passing it the testcase interface file.
+- Compile the resulting generated C/C++ code with either the C or C++ compiler into object files.
+- Link the object files into a dynamic library (dll/shared object).
+- Compile any generated and any runtime test target language code with the target language compiler, if the target language supports compilation. This step thus does not apply to the interpreted languages.
+- Execute a runtime test if one exists.
+
+
+
+For example, the ret_by_value testcase consists of two components.
+The first component is the Examples/test-suite/ret_by_value.i interface file.
+The name of the SWIG module must always be the name of the testcase, so the ret_by_value.i interface file thus begins with:
+
+
+
+
+%module ret_by_value
+
+
+
+
+The testcase code will then follow the module declaration,
+usually within a %inline %{ ... %} section for the majority of the tests.
+
+
+
+The second component is the optional runtime tests.
+Any runtime tests are named using the following convention: [testcase]_runme.[ext],
+where [testcase] is the testcase name and [ext] is the normal extension for the target language file.
+In this case, the Java and Python target languages implement a runtime test, so their files are respectively,
+Examples/test-suite/java/ret_by_value_runme.java and
+Examples/test-suite/python/ret_by_value_runme.py.
+
+
+
+The goal of the test-suite is to test as much as possible in a silent manner.
+This way any SWIG or compiler errors or warnings are easily visible.
+Should there be any warnings, changes must be made to either fix them (preferably) or suppress them.
+Compilation or runtime errors result in a testcase failure and will be immediately visible.
+It is therefore essential that the runtime tests are written in a manner that displays nothing to stdout/stderr on success
+but error/exception out with an error message on stderr on failure.
+
+
+35.10.12.1 Running the test-suite
+
+
+
+In order for the test-suite to work for a particular target language, the language must be correctly detected
+and configured during the configure stage so that the correct Makefiles are generated.
+Most development occurs on Linux, so usually it is a matter of installing the development packages for the target language
+and simply configuring as outlined earlier.
+
+
+
+If when running the test-suite commands that follow, you get a message that the test was skipped, it indicates that the
+configure stage is missing information in order to compile and run everything for that language.
+
+
+
+The test-suite can be run in a number of ways.
+The first group of commands are for running multiple testcases in one run and should be executed in the top level directory.
+To run the entire test-suite (can take a long time):
+
+
+
+make -k check-test-suite
+
+
+
+To run the test-suite just for target language [lang], replace [lang] with one of csharp, java, perl5, python, ruby, tcl etc:
+
+
+
+make check-[lang]-test-suite
+
+
+
+Note that if a runtime test is available, a message "(with run test)" is displayed when run. For example:
+
+
+
+$ make check-python-test-suite
+checking python test-suite
+checking testcase argcargvtest (with run test) under python
+checking testcase python_autodoc under python
+checking testcase python_append (with run test) under python
+checking testcase callback (with run test) under python
+
+
+
+The files generated on a previous run can be deleted using the clean targets, either the whole test-suite or for a particular language:
+
+
+
+make clean-test-suite
+make clean-[lang]-test-suite
+
+
+
+The test-suite can be run in a partialcheck mode where just SWIG is executed, that is, the compile,
+link and running of the testcases is not performed.
+Note that the partialcheck does not require the target language to be correctly configured and detected and unlike the other test-suite make targets, is never skipped. Once again, either all the languages can be executed or just a chosen language:
+
+
+
+make partialcheck-test-suite
+make partialcheck-[lang]-test-suite
+
+
+
+If your computer has more than one CPU, you are strongly advised to use parallel make to speed up the execution speed.
+This can be done with any of the make targets that execute more than one testcase.
+For example, a dual core processor can efficiently use 2 parallel jobs:
+
+
+
+make -j2 check-test-suite
+make -j2 check-python-test-suite
+make -j2 partialcheck-java-test-suite
+
+
+
+The second group of commands are for running individual testcases and should be executed in the appropriate
+target language directory, Examples/test-suite/[lang].
+Testcases can contain either C or C++ code and when one is written, a decision must be made as to which of these input
+languages is to be used.
+Replace [testcase] in the commands below with the name of the testcase.
+
+
+
+For a C language testcase, add the testcase under the C_TEST_CASES list in Examples/test-suite/common.mk and
+execute individually as:
+
+
+make -s [testcase].ctest
+
+
+
+For a C++ language testcase, add the testcase under the CPP_TEST_CASES list in Examples/test-suite/common.mk and
+execute individually as:
+
+
+make -s [testcase].cpptest
+
+
+
+A third category of tests are C++ language testcases testing multiple modules (the %import directive).
+These require more than one shared library (dll/shared object) to be built and so are separated out from the normal C++ testcases.
+Add the testcase under the MULTI_CPP_TEST_CASES list in Examples/test-suite/common.mk and
+execute individually as:
+
+
+make -s [testcase].multicpptest
+
+
+
+To delete the generated files, execute:
+
+
+make -s [testcase].clean
+
+
+
+If you would like to see the exact commands being executed, drop the -s option:
+
+
+make [testcase].ctest
+make [testcase].cpptest
+make [testcase].multicpptest
+
+
+
+Some real examples of each:
+
+
+make -s ret_by_value.clean
+make -s ret_by_value.ctest
+make -s bools.cpptest
+make -s imports.multicpptest
+
+
+
+Advanced usage of the test-suite facilitates running tools on some of the five stages.
+The make variables SWIGTOOL and RUNTOOL are used to specify a tool to respectively, invoke SWIG
+and the execution of the runtime test.
+You are advised to view the Examples/test-suite/common.mk file for details but for a short summary,
+the classic usage is to use Valgrind for memory checking.
+For example, checking for memory leaks when running the runtime test in the target language interpreter:
+
+
+
+make ret_by_value.ctest RUNTOOL="valgrind --leak-check=full"
+
+
+
+This will probably make more sense if you look at the output of the above as it will show the exact commands being executed.
+SWIG can be analyzed for bad memory accesses using:
+
+
+
+make ret_by_value.ctest SWIGTOOL="valgrind --tool=memcheck --trace-children=yes"
+
+
+35.10.13 Documentation
@@ -3286,7 +3507,7 @@ Some topics that you'll want to be sure to address include:
if available.
-
35.10.13 Prerequisites for adding a new language module to the SWIG distribution
+35.10.14 Prerequisites for adding a new language module to the SWIG distribution
@@ -3343,7 +3564,7 @@ should be added should there be an area not already covered by
the existing tests.
-35.10.14 Coding style guidelines
+35.10.15 Coding style guidelines
@@ -3367,11 +3588,29 @@ The generated C/C++ code should also follow this style as close as possible. How
should be avoided as unlike the SWIG developers, users will never have consistent tab settings.
-35.11 Typemaps
+35.11 Debugging Options
-35.11.1 Proxy classes
+
+There are various command line options which can aid debugging a SWIG interface as well as debugging the development of a language module. These are as follows:
+
+
+-debug-classes - Display information about the classes found in the interface
+-debug-module <n> - Display module parse tree at stages 1-4, <n> is a csv list of stages
+-debug-symtabs - Display symbol tables information
+-debug-symbols - Display target language symbols in the symbol tables
+-debug-csymbols - Display C symbols in the symbol tables
+-debug-tags - Display information about the tags found in the interface
+-debug-template - Display information for debugging templates
+-debug-top <n> - Display entire parse tree at stages 1-4, <n> is a csv list of stages
+-debug-typedef - Display information about the types and typedefs in the interface
+-debug-typemap - Display information for debugging typemaps
+
+
+
+The complete list of command line options for SWIG are available by running swig -help.
+
35.12 Guide to parse tree nodes
@@ -3781,6 +4020,13 @@ extern "X" { ... } declaration.
+35.13 Further Development Information
+
+
+
+There is further documentation available on the internals of SWIG, API documentation and debugging information.
+This is shipped with SWIG in the Doc/Devel directory.
+
diff --git a/Doc/Manual/Guile.html b/Doc/Manual/Guile.html
index cf7e8da2c..61b5ba7d6 100644
--- a/Doc/Manual/Guile.html
+++ b/Doc/Manual/Guile.html
@@ -814,7 +814,7 @@ Produces the following code at the top of the generated GOOPS guile-module
Module-primitive.scm (with primitive replaced with whatever is given with the -primsuffix
argument. The code to load the .so library should be located in the %scheme directive,
which will then be added to the scmstub file.
-Swig will automatically generate the line (use-modules (Package Module-primitive))
+SWIG will automatically generate the line (use-modules (Package Module-primitive))
into the GOOPS guile-module. So if Module-primitive.scm is on the autoload path for guile, the
%goops directive can be empty. Otherwise, the %goops directive should contain
whatever code is needed to load the Module-primitive.scm file into guile.
@@ -848,7 +848,7 @@ Produces the following code at the top of the generated GOOPS guile-module
Module Linkage: This is very similar to passive linkage with a scmstub file.
-Swig will also automatically generate the line (use-modules
+SWIG will also automatically generate the line (use-modules
(Package Module-primitive)) into the GOOPS guile-module. Again the %goops
directive should contain whatever code is needed to get that module loaded into guile.
diff --git a/Doc/Manual/Introduction.html b/Doc/Manual/Introduction.html
index 099454cf0..df8d03fdf 100644
--- a/Doc/Manual/Introduction.html
+++ b/Doc/Manual/Introduction.html
@@ -334,7 +334,7 @@ major features include:
Currently, the only major C++ feature not supported is nested classes--a limitation
-that will be removed in a future release.
+that should be removed in a future release, but has some workarounds for the moment.
diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html
index fc5646c10..7ab997a11 100644
--- a/Doc/Manual/Java.html
+++ b/Doc/Manual/Java.html
@@ -1772,7 +1772,7 @@ If declarations such as these appear, you will get a warning message like this:
-example.i:12: Warning(515): Overloaded method spam(unsigned short) ignored.
+example.i:12: Warning 515: Overloaded method spam(unsigned short) ignored.
Method spam(int) at example.i:11 used.
diff --git a/Doc/Manual/Library.html b/Doc/Manual/Library.html
index 7293f31fe..833a38393 100644
--- a/Doc/Manual/Library.html
+++ b/Doc/Manual/Library.html
@@ -667,7 +667,7 @@ in order for this to work.
-char *cdata(void *ptr, int nbytes)
+const char *cdata(void *ptr, size_t nbytes)
@@ -676,7 +676,7 @@ pointer.
-void memmove(void *ptr, char *s)
+void memmove(void *ptr, const char *s)
@@ -890,7 +890,10 @@ char *foo();
-This will release the result.
+This will release the result if the appropriate target language support is available.
+SWIG provides the appropriate "newfree" typemap for char * so that the memory is released,
+however, you may need to provide your own "newfree" typemap for other types.
+See Object ownership and %newobject for more details.
8.3.4 cstring.i
diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html
index e66c1c7f3..b236ab9f7 100644
--- a/Doc/Manual/Lua.html
+++ b/Doc/Manual/Lua.html
@@ -684,8 +684,8 @@ void foo(Bar &b);
If declarations such as these appear, you will get a warning message like this:
-example.i:12: Warning(509): Overloaded spam(short) is shadowed by spam(int)
-at example.i:11.
+example.i:12: Warning 509: Overloaded method spam(short) effectively ignored,
+example.i:11: Warning 509: as it is shadowed by spam(int).
To fix this, you either need to ignore or rename one of the methods. For example:
diff --git a/Doc/Manual/Modules.html b/Doc/Manual/Modules.html
index 1b628f802..406bdeaef 100644
--- a/Doc/Manual/Modules.html
+++ b/Doc/Manual/Modules.html
@@ -138,7 +138,7 @@ base class's methods. Typically you will get a warning when the module name is m
-derived_module.i:8: Warning(401): Base class 'base' ignored - unknown module name for base. Either import
+derived_module.i:8: Warning 401: Base class 'base' ignored - unknown module name for base. Either import
the appropriate module interface file or specify the name of the module in the %import directive.
diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html
index 8f74bd1de..40500dc5a 100644
--- a/Doc/Manual/Perl5.html
+++ b/Doc/Manual/Perl5.html
@@ -112,7 +112,7 @@ options are found near the end of the chapter.
-To build a Perl5 module, run Swig using the -perl option as
+To build a Perl5 module, run SWIG using the -perl option as
follows :
diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html
index 7bf158918..b9dcb83c5 100644
--- a/Doc/Manual/Php.html
+++ b/Doc/Manual/Php.html
@@ -48,10 +48,6 @@
-
-Caution: This chapter (and module!) is still under construction
-
-
SWIG supports generating wrappers for PHP5. Support for PHP4 has been removed
as of SWIG 1.3.37. The PHP developers are no longer making new PHP4 releases,
@@ -105,7 +101,7 @@ also contain PHP5 class wrappers.
-Swig can generate PHP extensions from C++ libraries as well when
+SWIG can generate PHP extensions from C++ libraries as well when
given the -c++ option. The support for C++ is discussed in
more detail in section 27.2.6.
diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html
index 5afa59243..2dd79dac5 100644
--- a/Doc/Manual/Preprocessor.html
+++ b/Doc/Manual/Preprocessor.html
@@ -102,8 +102,6 @@ by SWIG when it is parsing the interface:
SWIG Always defined when SWIG is processing a file
SWIGIMPORTED Defined when SWIG is importing a file with %import
-SWIGMAC Defined when running SWIG on the Macintosh
-SWIGWIN Defined when running SWIG under Windows
SWIG_VERSION Hexadecimal number containing SWIG version,
such as 0x010311 (corresponding to SWIG-1.3.11).
diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html
index 8b359bda9..b22a7e30e 100644
--- a/Doc/Manual/Python.html
+++ b/Doc/Manual/Python.html
@@ -69,9 +69,6 @@
Simple pointers
Unbounded C Arrays
String handling
-Arrays
-String arrays
-STL wrappers
Typemaps
@@ -1137,7 +1134,7 @@ simply represented as opaque values using an especial python container object:
>>> print f
-<Swig Object at _08a71808_p_FILE>
+<Swig Object of type 'FILE *' at 0xb7d6f470>
@@ -1147,7 +1144,7 @@ dereference the pointer from Python. Of course, that isn't much of a concern in
-In older versions of Swig (1.3.22 or older), pointers were represented
+In older versions of SWIG (1.3.22 or older), pointers were represented
using a plain string object. If you have an old package that still
requires that representation, or you just feel nostalgic, you can
always retrieve it by casting the pointer object to a string:
@@ -1171,7 +1168,7 @@ integer:
However, the inverse operation is not possible, i.e., you can't build
-a Swig pointer object from a raw integer value.
+a SWIG pointer object from a raw integer value.
@@ -1713,8 +1710,8 @@ If declarations such as these appear, you will get a warning message like this:
-example.i:12: Warning(509): Overloaded spam(short) is shadowed by spam(int)
-at example.i:11.
+example.i:12: Warning 509: Overloaded method spam(short) effectively ignored,
+example.i:11: Warning 509: as it is shadowed by spam(int).
@@ -3854,15 +3851,6 @@ If you need to return binary data, you might use the
also be used to extra binary data from arbitrary pointers.
-31.7.5 Arrays
-
-
-31.7.6 String arrays
-
-
-31.7.7 STL wrappers
-
-
31.8 Typemaps
diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html
index 98fa315d0..3b1e5c45c 100644
--- a/Doc/Manual/Ruby.html
+++ b/Doc/Manual/Ruby.html
@@ -1559,7 +1559,7 @@ you'll see a warning message like:
-
example.i:5: Warning(802): Warning for Derived: Base Base2 ignored.
Multiple inheritance is not supported in Ruby.
+
example.i:5: Warning 802: Warning for Derived: Base Base2 ignored.
Multiple inheritance is not supported in Ruby.
@@ -1810,7 +1810,11 @@ message like this:
-
example.i:12: Warning(509): Overloaded spam(short) is shadowed by spam(int)
at example.i:11.
+
+example.i:12: Warning 509: Overloaded method spam(short) effectively ignored,
+example.i:11: Warning 509: as it is shadowed by spam(int).
+
+
@@ -7097,7 +7101,7 @@ being created.
with Ruby objects. The following functions may prove to be useful.
(These functions plus many more can be found in
Programming
Ruby, by David Thomas and Andrew Hunt.)
-
In addition, we list equivalent functions that Swig defines, which
+
In addition, we list equivalent functions that SWIG defines, which
provide a language neutral conversion (these functions are defined for
each swig language supported). If you are trying to create a swig
file that will work under multiple languages, it is recommended you
@@ -7123,7 +7127,7 @@ across multiple languages.
| RUBY |
- Swig |
+ SWIG |
|
diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html
index 8705fa182..02d0ca3a4 100644
--- a/Doc/Manual/SWIG.html
+++ b/Doc/Manual/SWIG.html
@@ -330,10 +330,13 @@ currently supported:
-- Non-conventional type declarations.
+
-
+
+Non-conventional type declarations.
For example, SWIG does not support declarations such as the following
(even though this is legal C):
+
/* Non-conventional placement of storage specifier (extern) */
@@ -355,15 +358,19 @@ if you're feeling particularly obfuscated, you can certainly break SWIG (althoug
-
- Running SWIG on C++ source files (what would appear in a .C or .cxx file)
-is not recommended. Even though SWIG can parse C++ class declarations,
-it ignores declarations that are decoupled from their
-original class definition (the declarations are parsed, but a lot of warning
-messages may be generated). For example:
+
-
+
+Running SWIG on C++ source files (the code in a .C, .cpp or .cxx file) is not recommended.
+The usual approach is to feed SWIG header files for parsing C++ definitions and declarations.
+The main reason is if SWIG parses a scoped definition or declaration (as is normal for C++ source files),
+it is ignored, unless a declaration for the symbol was parsed earlier.
+For example
+
-/* Not supported by SWIG */
+/* bar not wrapped unless foo has been defined and
+ the declaration of bar within foo has already been parsed */
int foo::bar(int) {
... whatever ...
}
@@ -371,9 +378,12 @@ int foo::bar(int) {
-
- Certain advanced features of C++ such as nested classes
-are not yet supported. Please see the section on using SWIG
-with C++ for more information.
+
-
+
+Certain advanced features of C++ such as nested classes
+are not yet fully supported. Please see the C++ Nested classes section
+for more information.
+
@@ -787,6 +797,12 @@ In this case, the pointer e can change---it's only the value
being pointed to that is read-only.
+
+Please note that for const parameters or return types used in a function, SWIG pretty much ignores
+the fact that these are const, see the section on const-correctness
+for more information.
+
+
Compatibility Note: One reason for changing SWIG to handle
const declarations as read-only variables is that there are
@@ -2489,7 +2505,7 @@ instead of a method. To do this, you might write some code like this:
// Now supply the implementation of the Vector_magnitude_get function
%{
const double Vector_magnitude_get(Vector *v) {
- return (const double) return sqrt(v->x*v->x+v->y*v->y+v->z*v->z);
+ return (const double) sqrt(v->x*v->x+v->y*v->y+v->z*v->z);
}
%}
@@ -2502,41 +2518,53 @@ of the object.
-A similar technique can also be used to work with problematic data members.
+A similar technique can also be used to work with data members that you want to process.
For example, consider this interface:
-struct Person {
- char name[50];
- ...
-}
+typedef struct {
+ char name[50];
+ ...
+} Person;
-By default, the name attribute is read-only because SWIG does not
-normally know how to modify arrays. However, you can rewrite the interface
-as follows to change this:
+Say you wanted to ensure name was always upper case, you can rewrite
+the interface as follows to ensure this occurs whenever a name is read or written to:
-struct Person {
- %extend {
- char *name;
- }
-...
+typedef struct {
+ %extend {
+ char name[50];
+ }
+ ...
+} Person;
+
+%{
+#include <string.h>
+#include <ctype.h>
+
+void make_upper(char *name) {
+ char *c;
+ for (c = name; *c; ++c)
+ *c = (char)toupper((int)*c);
}
-// Specific implementation of set/get functions
-%{
+/* Specific implementation of set/get functions forcing capitalization */
+
char *Person_name_get(Person *p) {
- return p->name;
+ make_upper(p->name);
+ return p->name;
}
+
void Person_name_set(Person *p, char *val) {
- strncpy(p->name,val,50);
+ strncpy(p->name,val,50);
+ make_upper(p->name);
}
%}
@@ -2546,7 +2574,7 @@ void Person_name_set(Person *p, char *val) {
Finally, it should be stressed that even though
%extend
can be used to add new data members, these new members can not require
the allocation of additional storage in the object (e.g., their values must
-be entirely synthesized from existing attributes of the structure).
+be entirely synthesized from existing attributes of the structure or obtained elsewhere).
@@ -2629,10 +2657,16 @@ $o->{intRep}->{ivalue} = 7 # Change value of o.intRep.ivalue
-If you have a lot nested structure declarations, it is
+If you have a lot of nested structure declarations, it is
advisable to double-check them after running SWIG. Although,
there is a good chance that they will work, you may have to
modify the interface file in certain cases.
+
+
+
+Finally, note that nesting is handled differently in C++ mode,
+see Nested classes.
+
5.5.8 Other things to note about structure wrapping
diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html
index ef7487ff8..bd8a7ab5d 100644
--- a/Doc/Manual/SWIGPlus.html
+++ b/Doc/Manual/SWIGPlus.html
@@ -56,7 +56,7 @@
- Smart pointers and operator->()
- Using declarations and inheritance
- Nested classes
-
- A brief rant about const-correctness
+
- A brief rant about const-correctness
- Where to go for more information
@@ -1616,7 +1616,7 @@ warning message like this:
-example.i:18: Warning(401): Nothing known about base class 'Foo'. Ignored.
+example.i:18: Warning 401: Nothing known about base class 'Foo'. Ignored.
@@ -2031,7 +2031,8 @@ Therefore, when SWIG encounters this situation, it may generate a warning messag
-example.i:4: Warning(509): Overloaded foo(long) is shadowed by foo(int) at example.i:3.
+example.i:4: Warning 509: Overloaded method foo(long) effectively ignored,
+example.i:3: Warning 509: as it is shadowed by foo(int).
@@ -2041,7 +2042,8 @@ or for statically typed languages like Java:
-example.i:4: Warning(516): Overloaded method foo(long) ignored. Method foo(int)
+example.i:4: Warning 516: Overloaded method foo(long) ignored,
+example.i:3: Warning 516: using foo(int) instead.
at example.i:3 used.
@@ -2091,7 +2093,7 @@ When wrapping an overloaded function, there is a chance that you will get an err
-example.i:3: Warning(467): Overloaded foo(int) not supported (no type checking
+example.i:3: Warning 467: Overloaded foo(int) not supported (no type checking
rule for 'int').
@@ -3246,22 +3248,39 @@ public:
-SWIG should be able to handle most simple uses of partial specialization. However, it may fail
-to match templates properly in more complicated cases. For example, if you have this code,
+SWIG supports both template explicit specialization and partial specialization. Consider:
-template<class T1, class T2> class Foo<T1, T2 *> { };
+template<class T1, class T2> class Foo { }; // (1) primary template
+template<> class Foo<double *, int *> { }; // (2) explicit specialization
+template<class T1, class T2> class Foo<T1, T2 *> { }; // (3) partial specialization
-SWIG isn't able to match it properly for instantiations like Foo<int *, int *>.
-This problem is not due to parsing, but due to the fact that SWIG does not currently implement all
-of the C++ argument deduction rules.
+SWIG is able to properly match explicit instantiations:
+
+
+Foo<double *, int *> // explicit specialization matching (2)
+
+
+
+
+SWIG implements template argument deduction so that the following partial specialization examples work just like they would with a C++ compiler:
+
+
+
+
+Foo<int *, int *> // partial specialization matching (3)
+Foo<int *, const int *> // partial specialization matching (3)
+Foo<int *, int **> // partial specialization matching (3)
+
+
+
Member function templates are supported. The underlying principle is the same
as for normal templates--SWIG can't create a wrapper unless you provide
@@ -3471,7 +3490,7 @@ instead:
In this case, the default and conversion constructors have the same
-name. Hence, Swig will overload them and define an unique visible
+name. Hence, SWIG will overload them and define an unique visible
constructor, that will dispatch the proper call depending on the argument
type.
@@ -4678,37 +4697,50 @@ public:
-There is limited support for nested structs and unions when wrapping C code, see Nested structures for further details.
-However, there is no nested class/struct/union support when wrapping C++ code (using the -c++ commandline option).
-This may be added at a future date, however, until then some of the following workarounds can be applied.
+There is some support for nested structs and unions when wrapping C code,
+see Nested structures for further details.
+The added complexity of C++ compared to C means this approach does not work well for
+C++ code (when using the -c++ command line option).
+For C++, a nested class is treated much like an opaque pointer, so anything useful within the nested class, such as its
+methods and variables, are not accessible from the target language.
+True nested class support may be added to SWIG in the future, however,
+until then some of the following workarounds can be applied to improve the situation.
-It might be possible to use partial class information. Since
-SWIG does not need the entire class specification to work, conditional
-compilation can be used to comment out the problematic nested class definition, you might do this:
+It might be possible to use partial class information as often you can accept that the nested class is not needed,
+especially if it is not actually used in any methods you need from the target language.
+Imagine you are wrapping the following Outer class which contains a nested class Inner.
+The easiest thing to do is turn a blind eye to the warning that SWIG generates, or simply suppress it:
-class Foo {
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::Inner;
+
+class Outer {
public:
-#ifndef SWIG
- class Bar {
- public:
- ...
- };
-#endif
- Foo();
- ~Foo();
- ...
+ class Inner {
+ public:
+ ...
+ };
+ Inner getInner();
+ void useInner(const Inner& inner);
+ ...
};
-The next workaround assumes you cannot modify the source code as was done above and it provides a solution for methods that use nested class types.
-Imagine we are wrapping the Outer class which contains a nested class Inner:
+Note that if Inner can be used as an opaque type, the default wrapping approach suffices.
+For example, if the nested class does not need to be created from the target language, but can be obtained via a method
+call, such as the getInner() method above, the returned value can then be passed around, such as passed into the
+useInner() method.
+
+
+
+With some more effort the above situation can be improved somewhat and a nested class can be constructed and used
+from the target language much like any other non-nested class. Assuming we have the Outer class in a header file:
@@ -4721,14 +4753,18 @@ public:
int var;
Inner(int v = 0) : var(v) {}
};
- void method(Inner inner);
+ Inner getInner();
+ void useInner(const Inner& inner);
};
-The following interface file works around SWIG nested class limitations by redefining the nested class as a global class.
-A typedef for the compiler is also required in order for the generated wrappers to compile.
+The following interface file works around the nested class limitations by redefining the nested class as a global class.
+A typedef for the compiler and the nestedworkaround
+feature flag is also required in
+order for the generated wrappers to compile. This flag simply removes all the type information from SWIG, so SWIG treats
+the nested class as if it had not been parsed at all.
@@ -4736,9 +4772,6 @@ A typedef for the compiler is also required in order for the generated wrappers
// File : example.i
%module example
-// Suppress SWIG warning
-#pragma SWIG nowarn=SWIGWARN_PARSE_NESTED_CLASS
-
// Redefine nested class in global scope in order for SWIG to generate
// a proxy class. Only SWIG parses this definition.
class Inner {
@@ -4747,25 +4780,64 @@ class Inner {
Inner(int v = 0) : var(v) {}
};
+%nestedworkaround Outer::Inner;
+
%{
#include "outer.h"
%}
%include "outer.h"
+// We've fooled SWIG into thinking that Inner is a global class, so now we need
+// to trick the C++ compiler into understanding this apparent global type.
%{
-// SWIG thinks that Inner is a global class, so we need to trick the C++
-// compiler into understanding this so called global type.
typedef Outer::Inner Inner;
%}
-
-The downside to this approach is having to maintain two definitions of Inner, the real one and the one in the interface file that SWIG parses.
+The downside to this approach is a more complex interface file and having to maintain two definitions of Inner,
+the real one and the one in the interface file that SWIG parses.
+However, the upside is that all the methods/variables in the nested class are available from the target language
+as a proxy class is generated instead of treating the nested class as an opaque type.
+The proxy class can be constructed from the target language and passed into any methods accepting the nested class.
+Also note that the original header file is parsed unmodified.
-6.27 A brief rant about const-correctness
+
+Finally, conditional compilation can be used as a workaround to comment out nested class definitions in the actual headers,
+assuming you are able to modify them.
+
+
+
+
+// File outer.h
+class Outer {
+public:
+#ifndef SWIG
+ class Inner {
+ public:
+ ...
+ };
+#endif
+ ...
+};
+
+
+
+
+This workaround used to be common when SWIG could not deal with nested classes particulary well.
+This should just be a last resort for unusual corner cases now as SWIG can parse nested classes and even handle nested template classes fairly well.
+
+
+
+Compatibility Note: SWIG-1.3.40 and earlier versions did not have the nestedworkaround feature
+and the generated code resulting from parsing nested classes did not always compile.
+Nested class warnings could also not be suppressed using %warnfilter.
+
+
+
+6.27 A brief rant about const-correctness
diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html
index 789efc129..b98661c0d 100644
--- a/Doc/Manual/Sections.html
+++ b/Doc/Manual/Sections.html
@@ -6,7 +6,7 @@
SWIG-1.3 Development Documentation
-Last update : SWIG-1.3.40 (in progress)
+Last update : SWIG-1.3.41 (in progress)
Sections
diff --git a/Doc/Manual/Tcl.html b/Doc/Manual/Tcl.html
index 8b8c74dc0..b37df2853 100644
--- a/Doc/Manual/Tcl.html
+++ b/Doc/Manual/Tcl.html
@@ -1502,8 +1502,8 @@ If declarations such as these appear, you will get a warning message like this:
-example.i:12: Warning(509): Overloaded spam(short) is shadowed by spam(int)
-at example.i:11.
+example.i:12: Warning 509: Overloaded method spam(short) effectively ignored,
+example.i:11: Warning 509: as it is shadowed by spam(int).
diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html
index 226b4ef3e..7fe932828 100644
--- a/Doc/Manual/Typemaps.html
+++ b/Doc/Manual/Typemaps.html
@@ -31,10 +31,11 @@
- Pattern matching rules
- Code generation rules
-
- Typemaps for multiple languages
+
- Typemaps for multiple target languages
- Optimal code generation when returning by value
- Multi-argument typemaps
- The run-time type checker
@@ -88,10 +89,6 @@
-
-Disclaimer: This chapter is under construction!
-
-
10.1 Introduction
@@ -230,14 +227,17 @@ At first glance, this code will look a little confusing.
However, there is really not much to it. The first typemap (the "in"
typemap) is used to convert a value from the target language to C. The second
typemap (the "out" typemap) is used to convert in the other
-direction. The content of each typemap is a small fragment of C code
-that is inserted directly into the SWIG generated wrapper functions. Within
-this code, a number of special variables prefixed with a $ are expanded. These are
-really just placeholders for C variables that are generated in the course
+direction. The content of each typemap is a small fragment of code
+that is inserted directly into the SWIG generated wrapper functions.
+The code is usually C or C++ code which will be generated into the C/C++ wrapper functions.
+Note that this isn't always the case as some target language modules allow target language
+code within the typemaps which gets generated into target language specific files.
+Within this code, a number of special variables prefixed with a $ are expanded. These are
+really just placeholders for C/C++ variables that are generated in the course
of creating the wrapper function. In this case, $input refers to an
-input object that needs to be converted to C and $result
+input object that needs to be converted to C/C++ and $result
refers to an object that is going to be returned by a wrapper
-function. $1 refers to a C variable that has the same type as
+function. $1 refers to a C/C++ variable that has the same type as
specified in the typemap declaration (an int in this
example).
@@ -681,8 +681,9 @@ these methods is described later.
-modifiers is an optional comma separated list of name="value" values. These
-are sometimes to attach extra information to a typemap and is often target-language dependent.
+modifiers is an optional comma separated list of name="value" values.
+These are sometimes to attach extra information to a typemap and is often target-language dependent.
+They are also known as typemap attributes.
@@ -1091,7 +1092,7 @@ void F(int x[1000]); // int [ANY] rule (typemap 5)
-
10.3.2 Typedef reductions
+10.3.2 Typedef reductions
@@ -1246,6 +1247,26 @@ is rather esoteric--there's little practical reason to write a typemap quite lik
to confuse your coworkers even more.
+
+As a point of clarification, it is worth emphasizing that typedef matching is a typedef reduction process only, that is, SWIG does not search for every single possible typedef.
+Given a type in a declaration, it will only reduce the type, it won't build it up looking for typedefs.
+For example, given the type Struct, the typemap below will not be used for the aStruct parameter,
+because Struct is fully reduced:
+
+
+
+
+struct Struct {...};
+typedef Struct StructTypedef;
+
+%typemap(in) StructTypedef {
+ ...
+}
+
+void go(Struct aStruct);
+
+
+
10.3.3 Default typemaps
@@ -1383,7 +1404,7 @@ Expect to see them being used more and more within the various libraries in late
-10.3.5 Multi-arguments typemaps
+10.3.5 Multi-arguments typemaps
@@ -1413,6 +1434,205 @@ but all subsequent arguments must match exactly.
+10.3.6 Debugging typemap pattern matching
+
+
+
+There are two useful debug command line options available for debugging typemaps, -debug-tmsearch and -debug-tmused.
+
+
+
+The -debug-tmsearch option is a verbose option for debugging typemap searches.
+This can be very useful for watching the pattern matching process in action and for debugging which typemaps are used.
+The option displays all the typemaps and types that are looked for until a successful pattern match is made.
+As the display includes searches for each and every type needed for wrapping, the amount of information displayed can be large.
+Normally you would manually search through the displayed information for the particular type that you are interested in.
+
+
+
+For example, consider some of the code used in the Typedef reductions section already covered:
+
+
+
+
+typedef int Integer;
+typedef Integer Row4[4];
+void foo(Row4 rows[10]);
+
+
+
+
+A sample of the debugging output is shown below for the "in" typemap:
+
+
+
+
+swig -perl -debug-tmsearch example.i
+...
+example.h:3: Searching for a suitable 'in' typemap for: Row4 rows[10]
+ Looking for: Row4 rows[10]
+ Looking for: Row4 [10]
+ Looking for: Row4 rows[ANY]
+ Looking for: Row4 [ANY]
+ Looking for: Integer rows[10][4]
+ Looking for: Integer [10][4]
+ Looking for: Integer rows[ANY][ANY]
+ Looking for: Integer [ANY][ANY]
+ Looking for: int rows[10][4]
+ Looking for: int [10][4]
+ Looking for: int rows[ANY][ANY]
+ Looking for: int [ANY][ANY]
+ Looking for: SWIGTYPE rows[ANY][ANY]
+ Looking for: SWIGTYPE [ANY][ANY]
+ Looking for: SWIGTYPE rows[ANY][]
+ Looking for: SWIGTYPE [ANY][]
+ Looking for: SWIGTYPE *rows[ANY]
+ Looking for: SWIGTYPE *[ANY]
+ Looking for: SWIGTYPE rows[ANY]
+ Looking for: SWIGTYPE [ANY]
+ Looking for: SWIGTYPE rows[]
+ Looking for: SWIGTYPE []
+ Using: %typemap(in) SWIGTYPE []
+...
+
+
+
+
+showing that the best default match supplied by SWIG is the SWIGTYPE [] typemap.
+As the example shows, the successful match displays just the typemap method name and type in this format: %typemap(method) type.
+This information might meet your debugging needs, however, you might want to analyze further.
+If you next invoke SWIG with the -E option to display the preprocessed output, and search for this particular typemap,
+you'll find the full typemap contents (example shown below for Python):
+
+
+
+
+%typemap(in, noblock=1) SWIGTYPE [] (void *argp = 0, int res = 0) {
+ res = SWIG_ConvertPtr($input, &argp,$descriptor, $disown | 0 );
+ if (!SWIG_IsOK(res)) {
+ SWIG_exception_fail(SWIG_ArgError(res), "in method '" "$symname" "', argument " "$argnum"" of type '" "$type""'");
+ }
+ $1 = ($ltype)(argp);
+}
+
+
+
+
+The generated code for the foo wrapper will then contain the snippets of the typemap with the special variables expanded.
+The rest of this chapter will need reading though to fully understand all of this, however, the relevant parts of the generated code for the above typemap can be seen below:
+
+
+
+
+SWIGINTERN PyObject *_wrap_foo(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+...
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+...
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_a_4__int, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "foo" "', argument " "1"" of type '" "int [10][4]""'");
+ }
+ arg1 = (int (*)[4])(argp1);
+...
+}
+
+
+
+
+Searches for multi-argument typemaps are not mentioned unless a matching multi-argument typemap does actually exist.
+For example, the output for the code in the previous section is as follows:
+
+
+
+
+...
+example.h:39: Searching for a suitable 'in' typemap for: char *buffer
+ Looking for: char *buffer
+ Multi-argument typemap found...
+ Using: %typemap(in) (char *buffer,int len)
+...
+
+
+
+
+The second option for debugging is -debug-tmused and this displays the typemaps used.
+This option is a less verbose version of the -debug-tmsearch option as it only displays each successfully found typemap on a separate single line.
+The output displays the type, and name if present, the typemap method in brackets and then the actual typemap used.
+Below is the output for the example code at the start of this section on debugging.
+
+
+
+
+$ swig -perl -debug-tmused example.i
+example.h:3: Typemap for Row4 rows[10] (in) : %typemap(in) SWIGTYPE []
+example.h:3: Typemap for Row4 rows[10] (typecheck) : %typemap(typecheck) SWIGTYPE *
+example.h:3: Typemap for Row4 rows[10] (freearg) : %typemap(freearg) SWIGTYPE []
+example.h:3: Typemap for void foo (out) : %typemap(out) void
+
+
+
+
+Now, consider the following interface file:
+
+
+
+
+%module example
+
+%{
+void set_value(const char* val) {}
+%}
+
+%typemap(check) char *NON_NULL {
+ if (!$1) {
+ /* ... error handling ... */
+ }
+}
+
+%apply SWIGTYPE * { const char* val, const char* another_value } // use default pointer handling instead of strings
+
+%typemap(check) const char* val = char* NON_NULL;
+
+%typemap(arginit, noblock=1) const char* val {
+ $1 = "";
+}
+
+void set_value(const char* val);
+
+
+
+
+
+and the output debug:
+
+
+
+
+swig -perl5 -debug-tmused example.i
+example.i:21: Typemap for char const *val (arginit) : %typemap(arginit) char const *val
+example.i:21: Typemap for char const *val (in) : %apply SWIGTYPE * { char const *val }
+example.i:21: Typemap for char const *val (typecheck) : %apply SWIGTYPE * { char const *val }
+example.i:21: Typemap for char const *val (check) : %typemap(check) char const *val = char *NON_NULL
+example.i:21: Typemap for char const *val (freearg) : %apply SWIGTYPE * { char const *val }
+example.i:21: Typemap for void set_value (out) : %typemap(out) void
+
+
+
+
+The following observations about what is displayed can be noted (the same applies for -debug-tmsearch):
+
-
+The relevant typemap is shown, but for typemap copying, the appropriate %typemap or %apply is displayed, for example, the "check" and "in" typemaps.
+
+-
+The typemap modifiers are not shown, eg the noblock=1 modifier in the "arginit" typemap.
+
+-
+The exact %apply statement might look different to what is in the actual code. For example, the const char* another_value is not shown as it is not relevant here.
+Also the types may be displayed slightly differently - char const * and not const char*.
+
+
+
10.4 Code generation rules
@@ -2686,12 +2906,12 @@ rather than blindly passing values to the underlying C/C++ program.
Note: A more advanced constraint checking system is in development. Stay tuned.
-10.7 Typemaps for multiple languages
+10.7 Typemaps for multiple target languages
The code within typemaps is usually language dependent,
-however, many languages support the same typemaps.
+however, many target languages support the same typemaps.
In order to distinguish typemaps across different languages, the preprocessor should be used.
For example, the "in" typemap for Perl and Ruby could be written as:
@@ -2873,8 +3093,8 @@ SWIG can detect when the "optimal" attribute cannot be used and will ignore it a
-example.i:28: Warning(474): Method XX::create() usage of the optimal attribute in the out
-typemap at example.i:14 ignored as the following cannot be used to generate optimal code:
+example.i:28: Warning 474: Method XX::create() usage of the optimal attribute ignored
+example.i:14: Warning 474: in the out typemap as the following cannot be used to generate optimal code:
try {
result = XX::create();
} catch(const std::exception &e) {
@@ -2895,8 +3115,8 @@ In fact SWIG attempts to detect this and will issue a warning something like:
-example.i:21: Warning(475): Multiple calls to XX::create() might be generated due to
-optimal attribute usage in the out typemap at example.i:7.
+example.i:21: Warning 475: Multiple calls to XX::create() might be generated due to optimal attribute usage in
+example.i:7: Warning 475: the out typemap.
@@ -3201,7 +3421,7 @@ language modules.
The run-time type checker is used by many, but not all, of SWIG's supported target languages.
The run-time type checker features
-are not required and are thus not used for strongly typed languages such as Java and C#.
+are not required and are thus not used for statically typed languages such as Java and C#.
The scripting and scheme based languages rely on it and it forms
a critical part of SWIG's operation for these languages.
@@ -4060,6 +4280,7 @@ numerous examples. You should look at these files to get a feel
for how to define typemaps of your own.
Some of the language modules support additional typemaps and further
information is available in the individual chapters for each target language.
+There you may also find more hands-on practical examples.
diff --git a/Doc/Manual/Varargs.html b/Doc/Manual/Varargs.html
index f40a1ff1f..fb34a3ad9 100644
--- a/Doc/Manual/Varargs.html
+++ b/Doc/Manual/Varargs.html
@@ -270,21 +270,37 @@ traceprintf(arg1, NULL);
Arguably, this approach seems to defeat the whole point of variable length arguments. However,
-this actually provides enough support for many simple kinds of varargs functions to still be useful. For
-instance, you could make function calls like this (in Python):
+this actually provides enough support for many simple kinds of varargs functions to still be useful, however it does come with a caveat.
+For instance, you could make function calls like this (in Python):
>>> traceprintf("Hello World")
>>> traceprintf("Hello %s. Your number is %d\n" % (name, num))
+>>> traceprintf("Your result is 90%%.")
Notice how string formatting is being done in Python instead of C.
+The caveat is the strings passed must be safe to use in C though.
+For example if name was to contain a "%" it should be double escaped in order to avoid unpredictable
+behaviour:
+
+
+>>> traceprintf("Your result is 90%.\n") # unpredictable behaviour
+>>> traceprintf("Your result is 90%%.\n") # good
+
+
+
+
+Read on for further solutions.
+
+
+
13.4 Argument replacement using %varargs
diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html
index 95af1ec6b..5409248c9 100644
--- a/Doc/Manual/Warnings.html
+++ b/Doc/Manual/Warnings.html
@@ -44,8 +44,8 @@ During compilation, SWIG may generate a variety of warning messages. For exampl
-example.i:16: Warning(501): Overloaded declaration ignored. bar(double)
-example.i:15: Warning(501): Previous declaration is bar(int)
+example.i:16: Warning 501: Overloaded declaration ignored. bar(double)
+example.i:15: Warning 501: Previous declaration is bar(int)
@@ -344,7 +344,7 @@ These can be overridden using command line options, for example:
$ swig -python -Fstandard example.i
example.i:4: Syntax error in input.
$ swig -python -Fmicrosoft example.i
-example.i(4): Syntax error in input.
+example.i(4) : Syntax error in input.
14.9 Warning number reference
@@ -399,18 +399,20 @@ example.i(4): Syntax error in input.
- 308. Namespace alias 'name' not allowed here. Assuming 'name'
- 309. [private | protected] inheritance ignored.
- 310. Template 'name' was already wrapped as 'name' (ignored)
-
- 311. Template partial specialization not supported.
-
- 312. Nested classes not currently supported (ignored).
+
- 312. Unnamed nested class not currently supported (ignored).
- 313. Unrecognized extern type "name" (ignored).
- 314. 'identifier' is a lang keyword.
- 315. Nothing known about 'identifier'.
- 316. Repeated %module directive.
- 317. Specialization of non-template 'name'.
-
- 318. Instantiation of template name is ambiguous. Using templ at file:line
+
- 318. Instantiation of template 'name' is ambiguous, instantiation templ used, instantiation templ ignored.
- 319. No access specifier given for base class name (ignored).
- 320. Explicit template instantiation ignored.
- 321. identifier conflicts with a built-in name.
- 322. Redundant redeclaration of 'name'.
+
- 323. Recursive scope inheritance of 'name'.
+
- 324. Named nested template instantiations not supported. Processing as if no name was given to %template().
+
- 325. Nested class not currently supported (name ignored).
- 350. operator new ignored.
- 351. operator delete ignored.
- 352. operator+ ignored.
@@ -482,8 +484,8 @@ example.i(4): Syntax error in input.
- 469. No or improper directorin typemap defined for type
- 470. Thread/reentrant unsafe wrapping, consider returning by value instead.
- 471. Unable to use return type type in director method
-
- 474. Method method usage of the optimal attribute in the out typemap at file:line ignored as the following cannot be used to generate optimal code: code
-
- 475. Multiple calls to method might be generated due to optimal attribute usage in the out typemap at file:line.
+
- 474. Method method usage of the optimal attribute ignored in the out typemap as the following cannot be used to generate optimal code: code
+
- 475. Multiple calls to method might be generated due to optimal attribute usage in the out typemap.
@@ -492,22 +494,22 @@ example.i(4): Syntax error in input.
-- 501. Overloaded declaration ignored. decl
-
- 502. Overloaded constructor ignored. decl
+
- 501. Overloaded declaration ignored. decl. Previous declaration is decl.
+
- 502. Overloaded constructor ignored. decl. Previous declaration is decl.
- 503. Can't wrap 'identifier' unless renamed to a valid identifier.
- 504. Function name must have a return type.
- 505. Variable length arguments discarded.
- 506. Can't wrap varargs with keyword arguments enabled.
- 507. Adding native function name not supported (ignored).
-
- 508. Declaration of 'name' shadows declaration accessible via operator->() at file:line.
-
- 509. Overloaded declaration is shadowed by declaration at file:line.
+
- 508. Declaration of 'name' shadows declaration accessible via operator->(), previous declaration of'declaration'.
+
- 509. Overloaded method declaration effectively ignored, as it is shadowed by declaration.
- 510. Friend function 'name' ignored.
- 511. Can't use keyword arguments with overloaded functions.
-
- 512. Overloaded declaration const ignored. Non-const method at file:line used.
+
- 512. Overloaded method declaration ignored, using non-const method declaration instead.
- 513. Can't generate wrappers for unnamed struct/class.
- 514.
- 515.
-
- 516. Overloaded method declaration ignored. Method declaration at file:line used.
+
- 516. Overloaded method declaration ignored, using declaration instead.
- 517.
- 518. Portability warning: File file1 will be overwritten by file2 on case insensitive filesystems such as Windows' FAT32 and NTFS unless the class/module name is renamed.
- 519. %template() contains no name. Template method ignored: declaration
diff --git a/Examples/Makefile.in b/Examples/Makefile.in
index af86ddf1a..aa37eef56 100644
--- a/Examples/Makefile.in
+++ b/Examples/Makefile.in
@@ -1124,11 +1124,11 @@ RRSRC = $(INTERFACE:.i=.R)
r: $(SRCS)
$(SWIG) -r $(SWIGOPT) $(INTERFACEPATH)
- +( PKG_LIBS="$(SRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) )
+ +( PKG_LIBS="$(SRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -fPIC -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) )
r_cpp: $(CXXSRCS)
$(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACEPATH)
- +( PKG_LIBS="$(CXXSRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) )
+ +( PKG_LIBS="$(CXXSRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -fPIC -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) )
r_clean:
rm -f *_wrap* *~ .~*
diff --git a/Examples/java/pointer/index.html b/Examples/java/pointer/index.html
index e20fe3328..5c93d4d58 100644
--- a/Examples/java/pointer/index.html
+++ b/Examples/java/pointer/index.html
@@ -143,7 +143,7 @@ extraction.
diff --git a/Examples/perl5/pointer/index.html b/Examples/perl5/pointer/index.html
index 6f9fd397d..94467bc36 100644
--- a/Examples/perl5/pointer/index.html
+++ b/Examples/perl5/pointer/index.html
@@ -144,7 +144,7 @@ extraction.
diff --git a/Examples/php/cpointer/runme.php b/Examples/php/cpointer/runme.php
index f5ef08a3c..48f0ad631 100644
--- a/Examples/php/cpointer/runme.php
+++ b/Examples/php/cpointer/runme.php
@@ -22,7 +22,7 @@
# Now get the result
$r = intp_value($c);
- print " 38 + 42 = $r\n";
+ print " 37 + 42 = $r\n";
# Clean up the pointers
delete_intp($a);
diff --git a/Examples/python/class/example.i b/Examples/python/class/example.i
index 75700b305..aa28dde80 100644
--- a/Examples/python/class/example.i
+++ b/Examples/python/class/example.i
@@ -1,10 +1,4 @@
/* File : example.i */
%module example
-%{
-#include "example.h"
-%}
-
-/* Let's just grab the original header file here */
-%include "example.h"
-
+int printf(const char *fmt, ...);
diff --git a/Examples/python/class/runme.py b/Examples/python/class/runme.py
index f1272ae81..54543be67 100644
--- a/Examples/python/class/runme.py
+++ b/Examples/python/class/runme.py
@@ -1,51 +1,10 @@
-# file: runme.py
-# This file illustrates the proxy class C++ interface generated
-# by SWIG.
+from example import *
-import example
-
-# ----- Object creation -----
-
-print "Creating some objects:"
-c = example.Circle(10)
-print " Created circle", c
-s = example.Square(10)
-print " Created square", s
-
-# ----- Access a static member -----
-
-print "\nA total of", example.cvar.Shape_nshapes,"shapes were created"
-
-# ----- Member data access -----
-
-# Set the location of the object
-
-c.x = 20
-c.y = 30
-
-s.x = -10
-s.y = 5
-
-print "\nHere is their current position:"
-print " Circle = (%f, %f)" % (c.x,c.y)
-print " Square = (%f, %f)" % (s.x,s.y)
-
-# ----- Call some methods -----
-
-print "\nHere are some properties of the shapes:"
-for o in [c,s]:
- print " ", o
- print " area = ", o.area()
- print " perimeter = ", o.perimeter()
-
-print "\nGuess I'll clean up now"
-
-# Note: this invokes the virtual destructor
-del c
-del s
-
-s = 3
-print example.cvar.Shape_nshapes,"shapes remain"
-print "Goodbye"
+printf("hello\n")
+name = "%shoot"
+num = 22
+printf("Hello %s. Your number is %d\n" % (name, num))
+print("hello there %s." % name);
+printf("Your result is 90%.\n")
diff --git a/Examples/python/pointer/index.html b/Examples/python/pointer/index.html
index ceef30566..b99c8fe4c 100644
--- a/Examples/python/pointer/index.html
+++ b/Examples/python/pointer/index.html
@@ -144,7 +144,7 @@ extraction.
diff --git a/Examples/ruby/pointer/index.html b/Examples/ruby/pointer/index.html
index 2b9c40b35..c9d5b9c32 100644
--- a/Examples/ruby/pointer/index.html
+++ b/Examples/ruby/pointer/index.html
@@ -144,7 +144,7 @@ extraction.
diff --git a/Examples/tcl/pointer/index.html b/Examples/tcl/pointer/index.html
index 874088a72..407380240 100644
--- a/Examples/tcl/pointer/index.html
+++ b/Examples/tcl/pointer/index.html
@@ -144,7 +144,7 @@ extraction.
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index 492378b16..203ea3e72 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -28,12 +28,14 @@
# The 'clean' target cleans up.
#
# Note that the RUNTOOL, COMPILETOOL and SWIGTOOL variables can be used
-# for # invoking tools for the runtime tests and target language
+# for invoking tools for the runtime tests and target language
# compiler (eg javac) respectively. For example, valgrind can be used
# for memory checking of the runtime tests using:
-# make RUNTOOL="valgrind --leak-check-full"
+# make RUNTOOL="valgrind --leak-check=full"
# and valgrind can be used when invoking SWIG using:
-# make SWIGTOOL="valgrind --tool=memcheck"
+# make SWIGTOOL="valgrind --tool=memcheck --trace-children=yes"
+# Note: trace-children needed because of preinst-swig shell wrapper
+# to the swig executable.
#
# The variables below can be overridden after including this makefile
#######################################################################
@@ -78,8 +80,6 @@ CPP_TEST_BROKEN += \
exception_partial_info \
extend_variable \
li_std_vector_ptr \
- namespace_union \
- nested_structs \
overload_complicated \
template_default_pointer \
template_expr
@@ -189,6 +189,7 @@ CPP_TEST_CASES += \
extend_placement \
extend_template \
extend_template_ns \
+ extern_c \
extern_namespace \
extern_throws \
features \
@@ -238,9 +239,12 @@ CPP_TEST_CASES += \
namespace_template \
namespace_typedef_class \
namespace_typemap \
+ namespace_union \
namespace_virtual_method \
naturalvar \
+ nested_class \
nested_comment \
+ nested_workaround \
newobject1 \
null_pointer \
operator_overload \
@@ -255,6 +259,7 @@ CPP_TEST_CASES += \
overload_template \
overload_template_fast \
pointer_reference \
+ preproc_constants \
primitive_ref \
private_assign \
protected_rename \
@@ -297,6 +302,7 @@ CPP_TEST_CASES += \
static_array_member \
static_const_member \
static_const_member_2 \
+ struct_initialization_cpp \
struct_value \
template \
template_arg_replace \
@@ -327,6 +333,8 @@ CPP_TEST_CASES += \
template_inherit_abstract \
template_int_const \
template_methods \
+ template_nested \
+ template_nested_typemaps \
template_ns \
template_ns2 \
template_ns3 \
@@ -336,6 +344,8 @@ CPP_TEST_CASES += \
template_ns_inherit \
template_ns_scope \
template_partial_arg \
+ template_partial_specialization \
+ template_partial_specialization_typedef \
template_qualifier \
template_qualifier \
template_ref_type \
@@ -409,6 +419,7 @@ CPP_STD_TEST_CASES += \
li_std_combinations \
li_std_deque \
li_std_except \
+ li_std_map \
li_std_pair \
li_std_string \
li_std_vector \
@@ -430,6 +441,7 @@ C_TEST_CASES += \
arrays \
char_constant \
const_const \
+ constant_expr \
empty \
enums \
extern_declaration \
@@ -447,17 +459,21 @@ C_TEST_CASES += \
li_cpointer \
li_math \
long_long \
+ memberin_extend_c \
name \
nested \
+ nested_structs \
newobject2 \
overload_extend \
overload_extendc \
preproc \
+ preproc_constants_c \
ret_by_value \
simple_array \
sizeof_pointer \
sneaky1 \
struct_rename \
+ struct_initialization \
typedef_struct \
typemap_subst \
union_parameter \
diff --git a/Examples/test-suite/constant_expr.i b/Examples/test-suite/constant_expr.i
new file mode 100644
index 000000000..47db2d026
--- /dev/null
+++ b/Examples/test-suite/constant_expr.i
@@ -0,0 +1,11 @@
+%module constant_expr;
+/* Tests of constant expressions. */
+
+%inline %{
+
+/* % didn't work in SWIG 1.3.40 and earlier. */
+const int X = 123%7;
+#define FOO 12 % 6
+double d_array[12 % 6];
+
+%}
diff --git a/Examples/test-suite/cpp_broken.i b/Examples/test-suite/cpp_broken.i
index fe109ea43..84d6122e5 100644
--- a/Examples/test-suite/cpp_broken.i
+++ b/Examples/test-suite/cpp_broken.i
@@ -1,36 +1,6 @@
%module cpp_broken
-// bug #1060789
-%inline %{
-#define MASK(shift, size) (((1 << (size)) - 1) << (shift))
-#define SOME_MASK_DEF (80*MASK(8, 10))
-%}
-
-// bug #1060079
-%inline %{
-#define FIELD(name, width) unsigned int name:width
-#define SOME_CONST 2
-#define NEXT_CONST (2 * SOME_CONST)
-
-typedef struct {
-FIELD(a, SOME_CONST);
-FIELD(b, NEXT_CONST);
-} MyStruct_t;
-%}
-
-%{
-#ifdef max
-#undef max
-#endif
-%}
-
-// bug #994301
-%inline %{
-#define max(a,b) ((a) > (b) ? (a) : (b))
-%}
-
-
// bug #940318
%inline %{
typedef enum {
@@ -40,36 +10,3 @@ eZero = 0
%}
-// bug #754443
-
-%inline %{
-#define MAG_STYLE_BORDER_OFFS 0
-#define MAG_STYLE_BORDER_BITS 3
-#define MAG_STYLE_BORDER_MASK (((1UL< vecStr(std::vector v) {
%inline %{
int *makeIntPtr(int v) { return new int(v); }
+ const short *makeConstShortPtr(int v) { return new short(v); }
double *makeDoublePtr(double v) { return new double(v); }
int extractInt(int *p) { return *p; }
+ short extractConstShort(const short *p) { return *p; }
%}
%template(pyvector) std::vector;
namespace std {
- %template(ConstShortVector) vector;
-// %template(ConstIntVector) vector; // interferes with vector... see new testcase li_std_vector_ptr
+ %template(ConstShortPtrVector) vector;
}
%inline %{
diff --git a/Examples/test-suite/li_std_vector_ptr.i b/Examples/test-suite/li_std_vector_ptr.i
index 688cbdd54..292c9d700 100644
--- a/Examples/test-suite/li_std_vector_ptr.i
+++ b/Examples/test-suite/li_std_vector_ptr.i
@@ -1,3 +1,4 @@
+// Bug 2359417
%module li_std_vector_ptr
%include "std_vector.i"
diff --git a/Examples/test-suite/lua/overload_template_fast_runme.lua b/Examples/test-suite/lua/overload_template_fast_runme.lua
index 97078f34d..6663cb0b5 100644
--- a/Examples/test-suite/lua/overload_template_fast_runme.lua
+++ b/Examples/test-suite/lua/overload_template_fast_runme.lua
@@ -2,12 +2,12 @@ require("import") -- the import fn
import("overload_template_fast") -- import code
for k,v in pairs(overload_template_fast) do _G[k]=v end -- move to global
--- lua has only one numeric type, so max(int,int) and max(double,double) are the same
+-- lua has only one numeric type, so maximum(int,int) and maximum(double,double) are the same
-- whichever one was wrapper first will be used (which is int)
f = foo()
-a = max(3,4)
+a = maximum(3,4)
-- mix 1
assert(mix1("hi") == 101)
diff --git a/Examples/test-suite/memberin_extend.i b/Examples/test-suite/memberin_extend.i
index f20617b66..c6eb10526 100644
--- a/Examples/test-suite/memberin_extend.i
+++ b/Examples/test-suite/memberin_extend.i
@@ -1,6 +1,6 @@
%module memberin_extend
-// Tests memberin typemap. The default char * memberin typemap will be used.
+// Tests memberin typemap is not used for %extend.
// The test extends the struct with a pseudo member variable
%inline %{
@@ -12,8 +12,19 @@ struct ExtendMe {
%{
#include