summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2015-08-02 22:00:02 +0100
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2015-08-02 22:00:02 +0100
commit5817a1163dd3ec01cbcd2c314484d69f7e4e27cf (patch)
treed2a8632a71c25458e168191dab75d43f37afbd1e
parent8efdf69dfc8eb8820eb19f32a53cf50e5fdbd4fe (diff)
parent892aaf577a6fdb663aafe1e6ada178de312d92f2 (diff)
downloadswig-5817a1163dd3ec01cbcd2c314484d69f7e4e27cf.tar.gz
Merge branch 'master' into travis-osx
* master: Test case warning suppression for visual c++ Cosmetic corrections - Mac OS X testcase warning fix HTML fix in docs Tweak configure output for Java Don't check for all the languages in Travis language-specific builds. Skip check for pep8 if Python is disabled in configure. Make configure --without-alllang option actually useful. Cosmetic: fix wrong configure options indentation in --help. Don't duplicate Java headers path under OS X in configure. Fix potential security exploit in generated Java classes SWIG_LIB fix for out of source MinGW builds Move MinGW mixed path conversion code to the pathconvert tool Use JAVA_HOME value in configure to detect Java. Improve configure output when python is not installed Remove executable permission from appveyor.yml. Ocaml configure changes Consistent memory initialization in php typemaps. Initialise all newly created arrays in arrays.i library. Consistent memory intiailization between C and C++ in typemaps Restored broken ignoring of operators etc. Added more comments. Improve python code indentation warning / error messages Function comment header formatting corrections Improve Python docstring indentation handling Avoid gcc uninitialized variable warnings in Python wrappers. Typemap attribute fixes Add documentation and CHANGES for special variables and typemap attributes. Support special variable expansion in special variable macros in typemap attributes. Enable variable and typemap substitution in typemap kwargs, and a test that verifies this works for directorin:descriptor. refactoring: 2 ways of ignoring symbol in add_symbols() merged for clarity explicitly %ignore'd symbol does not get feature:ignore if it is only added to C symbol table Remove callback function from autodoc unit test. Octave 4.0 fails in Travis Make callback unit test pass for PHP backend. Add changes note for Python tp_doc slot and docstring Clearer variable name in Java director generated code warning fixes String / char * usage in parser fixes const char * fixes in the parser Update CHANGES.current and Octave.html to indicate Octave 4.0.0 support Octave: use correct mkoctfile executable Add octave 4.0 to travis Fix compile flags for Travis C++11 testing Travis testing c++11 and gcc5 c++11 test case fixes Fix default_constructor_runme.m test Add #include <climits> for INT_MAX Update print() signature for octave 4.0 Set class docstring in tp_doc slot for python -builtin Travis testing extended to test c++11 and c++14 with gcc-5 Configuring C++11 compiler flags for testing fix Support for octave 4.0.0 Don't generate constructor wrappers if a base class has a private constructor Test-suite fixes for c++11 compilation by g++-5.1 Fix incorrect test case code Set OCAMLC to empty if Ocaml compiler not found Bump version to 3.0.7 Unused method warning suppression for Javascript v8 Add 3.0.6 release notes and release date Html doc fixes Testcase workaround for Solaris parent_class testcase name warning fixes for PHP Use "mixed" path to source directory under Cygwin.
-rw-r--r--ANNOUNCE8
-rw-r--r--CHANGES210
-rw-r--r--CHANGES.current252
-rw-r--r--Doc/Manual/CSharp.html7
-rw-r--r--Doc/Manual/Contents.html8
-rw-r--r--Doc/Manual/Go.html5
-rw-r--r--Doc/Manual/Java.html22
-rw-r--r--Doc/Manual/Javascript.html10
-rw-r--r--Doc/Manual/Octave.html2
-rw-r--r--Doc/Manual/Python.html4
-rw-r--r--Doc/Manual/Sections.html2
-rw-r--r--Doc/Manual/Typemaps.html72
-rw-r--r--Examples/test-suite/array_typedef_memberin.i11
-rw-r--r--Examples/test-suite/autodoc.i6
-rw-r--r--Examples/test-suite/callback.i10
-rw-r--r--Examples/test-suite/common.mk1
-rw-r--r--Examples/test-suite/cpp11_lambda_functions.i3
-rw-r--r--Examples/test-suite/cpp11_noexcept.i2
-rw-r--r--Examples/test-suite/cpp11_rvalue_reference2.i5
-rw-r--r--Examples/test-suite/csharp/Makefile.in2
-rw-r--r--Examples/test-suite/csharp/default_constructor_runme.cs8
-rw-r--r--Examples/test-suite/csharp/special_variable_attributes_runme.cs32
-rw-r--r--Examples/test-suite/d/default_constructor_runme.1.d13
-rw-r--r--Examples/test-suite/d/default_constructor_runme.2.d2
-rw-r--r--Examples/test-suite/default_constructor.i23
-rw-r--r--Examples/test-suite/errors/Makefile.in2
-rw-r--r--Examples/test-suite/errors/swig_pythoncode_bad.stderr2
-rw-r--r--Examples/test-suite/errors/swig_pythoncode_bad2.stderr2
-rw-r--r--Examples/test-suite/errors/swig_pythoncode_bad3.i7
-rw-r--r--Examples/test-suite/errors/swig_pythoncode_bad3.stderr1
-rw-r--r--Examples/test-suite/go/default_constructor_runme.go3
-rw-r--r--Examples/test-suite/guile/li_std_string_runme.scm2
-rw-r--r--Examples/test-suite/inherit_member.i4
-rw-r--r--Examples/test-suite/java/Makefile.in1
-rw-r--r--Examples/test-suite/java/cpp11_constexpr_runme.java2
-rw-r--r--Examples/test-suite/java/default_constructor_runme.java8
-rw-r--r--Examples/test-suite/java/java_director_ptrclass_runme.java47
-rw-r--r--Examples/test-suite/java_director_ptrclass.i107
-rw-r--r--Examples/test-suite/java_typemaps_proxy.i8
-rw-r--r--Examples/test-suite/java_typemaps_typewrapper.i2
-rw-r--r--Examples/test-suite/octave/default_constructor_runme.m27
-rw-r--r--Examples/test-suite/php/Makefile.in1
-rw-r--r--Examples/test-suite/php/autodoc_runme.php9
-rw-r--r--Examples/test-suite/php/callback_runme.php9
-rw-r--r--Examples/test-suite/python/Makefile.in1
-rw-r--r--Examples/test-suite/python/default_constructor_runme.py9
-rw-r--r--Examples/test-suite/python/python_docstring_runme.py100
-rw-r--r--Examples/test-suite/python_docstring.i98
-rw-r--r--Examples/test-suite/ruby/default_constructor_runme.rb3
-rw-r--r--Examples/test-suite/scilab/default_constructor_runme.sci9
-rw-r--r--Examples/test-suite/special_variable_attributes.i170
-rw-r--r--Examples/test-suite/template_keyword_in_type.i4
-rw-r--r--Lib/carrays.i2
-rw-r--r--Lib/d/carrays.i4
-rw-r--r--Lib/java/arrays_java.i6
-rw-r--r--Lib/java/boost_intrusive_ptr.i8
-rw-r--r--Lib/java/boost_shared_ptr.i6
-rw-r--r--Lib/java/java.swg8
-rw-r--r--Lib/java/various.i4
-rw-r--r--Lib/javascript/v8/javascriptrun.swg36
-rw-r--r--Lib/octave/octcontainer.swg1
-rw-r--r--Lib/octave/octrun.swg54
-rw-r--r--Lib/php/php.swg2
-rw-r--r--Lib/php/typemaps.i2
-rw-r--r--README2
-rw-r--r--RELEASENOTES5
-rw-r--r--Source/CParse/parser.y97
-rw-r--r--Source/Modules/allocate.cxx2
-rw-r--r--Source/Modules/java.cxx8
-rw-r--r--Source/Modules/javascript.cxx2
-rw-r--r--Source/Modules/lang.cxx16
-rw-r--r--Source/Modules/perl5.cxx17
-rw-r--r--Source/Modules/python.cxx268
-rw-r--r--Source/Swig/scanner.c2
-rw-r--r--Source/Swig/typemap.c108
-rwxr-xr-xTools/convertpath21
-rw-r--r--Tools/javascript/Makefile.in2
-rwxr-xr-xTools/testflags.py34
-rw-r--r--[-rwxr-xr-x]appveyor.yml2
-rw-r--r--configure.ac302
80 files changed, 1713 insertions, 666 deletions
diff --git a/ANNOUNCE b/ANNOUNCE
index 96b1904ac..f7d7eb8a9 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,8 +1,8 @@
-*** ANNOUNCE: SWIG 3.0.6 (in progress) ***
+*** ANNOUNCE: SWIG 3.0.7 (in progress) ***
http://www.swig.org
-We're pleased to announce SWIG-3.0.6, the latest SWIG release.
+We're pleased to announce SWIG-3.0.7, the latest SWIG release.
What is SWIG?
=============
@@ -22,11 +22,11 @@ Availability
============
The release is available for download on Sourceforge at
- http://prdownloads.sourceforge.net/swig/swig-3.0.6.tar.gz
+ http://prdownloads.sourceforge.net/swig/swig-3.0.7.tar.gz
A Windows version is also available at
- http://prdownloads.sourceforge.net/swig/swigwin-3.0.6.zip
+ http://prdownloads.sourceforge.net/swig/swigwin-3.0.7.zip
Please report problems with this release to the swig-devel mailing list,
details at http://www.swig.org/mail.html.
diff --git a/CHANGES b/CHANGES
index 4548de0fd..691fa5544 100644
--- a/CHANGES
+++ b/CHANGES
@@ -3,6 +3,208 @@ SWIG (Simplified Wrapper and Interface Generator)
See the CHANGES.current file for changes in the current version.
See the RELEASENOTES file for a summary of changes in each release.
+Version 3.0.6 (5 Jul 2015)
+==========================
+
+2015-07-02: wsfulton
+ Fix syntax error when the template keyword is used in types, eg:
+
+ std::template vector<int> v;
+
+2015-07-02: ngladitz
+ [Lua] Push characters as unformatted 1-character strings to avoid
+ unprintable characters such as (char)127 being converted to
+ "<\127>" with Lua 5.3 and later. (github PR #452)
+
+2015-06-29: olly
+ [Python] Improve handling of whitespace in %pythoncode.
+
+ Previously SWIG looked at the indentation of the first line and
+ removed that many characters from each subsequent line, regardless
+ of what those characters were. This was made worse because SWIG's
+ preprocessor removes any whitespace before a '#'. Fixes github
+ issue #379, reported by Joe Orton.
+
+2015-06-12: wsfulton
+ [R] Fix #430 - call to SWIG_createNewRef in copyToC was incorrectly named.
+
+2015-06-11: sghirate
+ [C#] Patch #427 adds in new command line option -outfile to combine all the
+ generated C# code into a single file.
+
+2015-06-09: wsfulton
+ Fix seg fault processing C++11 type aliasing. Issue #424.
+
+2015-05-28: wsfulton
+ [Python] Add new feature "python:cdefaultargs" to control default argument
+ code generation. By default, SWIG attempts to convert C/C++ default argument values
+ into Python values and generates code into the Python layer with these values.
+ Recent versions of SWIG are able to convert more of these values, however, the
+ new behaviour can be circumvented if desired via this new feature, such that
+ the default argument values are obtained from the C layer and not the Python layer.
+ For example:
+
+ struct CDA {
+ int fff(int a = 1, bool b = false);
+ };
+
+ The default code generation in the Python layer is:
+
+ class CDA(_object):
+ ...
+ def fff(self, a=1, b=False):
+ return _default_args.CDA_fff(self, a, b)
+
+ Adding the feature:
+
+ %feature("python:cdefaultargs") CDA::fff;
+
+ Results in:
+
+ class CDA(_object):
+ ...
+ def fff(self, *args):
+ return _default_args.CDA_fff(self, *args)
+
+ Some code generation modes, eg -builtin and -fastproxy, are unaffected by this as
+ the default values are always obtained from the C layer.
+
+2015-05-27: wsfulton
+ [Python] Deal with an integer as the default value of a typedef to bool
+ parameter in the C++ prototype. See #327. Regression from 3.0.0 onwards.
+
+2015-05-19: olly
+ [Python] Fix warning when compiling generated code with MSVC.
+ (Fixes https://sourceforge.net/p/swig/patches/351/ reported by
+ Mateusz Szyma¿ski).
+
+2015-05-14: wsfulton
+ Fix seg fault wrapping shared_ptr of classes with private constructors and destructors.
+ This also fixes the "unref" feature when used on classes with private destructors.
+
+2015-05-10: wsfulton
+ [Java] Fix multi-argument typemaps (char *STRING, size_t LENGTH)
+ so that they can be applied to a wider range of types. Fixes #385.
+
+2015-05-07: olly
+ [Python] Deal with an integer as the default value of a bool
+ parameter in the C++ prototype. Fixes github #327, reported by
+ Greg Allen.
+
+2015-05-07: LindleyF
+ [Java] Allow feature("director") and feature("ref") to be used
+ together. Github PR#403.
+
+2015-05-05: olly
+ Suppress warning 325 "Nested class not currently supported (Foo
+ ignored)" when Foo has already been explicitly ignored with "%ignore".
+
+2015-05-04: wsfulton
+ Add support for friend templates, including operator overloading - fixes #196. Considering
+ the example below, previously the operator gave a syntax error and friendfunc incorrectly
+ warned with:
+
+ "Warning 503: Can't wrap 'friendfunc<(Type)>' unless renamed to a valid identifier."
+
+ template <class Type> class MyClass {
+ friend int friendfunc <Type>(double is, MyClass <Type> & x);
+ friend int operator<< <Type>(double un, const MyClass <Type> &x);
+ };
+
+ The following also previously incorrectly warned with:
+
+ "Warning 302: Identifier 'template_friend' redefined (ignored),"
+
+ template<typename T> T template_friend(T);
+ struct MyTemplate {
+ template<typename T> friend T template_friend(T);
+ };
+
+2015-05-01: wsfulton
+ Fix handling of conversion operators where the operator is split over multiple
+ lines or has comments within the operator type. Fixes #401.
+
+ Also fix similar problem with normal operators which gave a syntax error if split over
+ multiple lines or had a comment within the operator declaration.
+
+2015-04-30: olly
+ Ignore unknown preprocessor directives which are inside an inactive
+ conditional (github issue #394, reported by Dan Wilcox).
+ Regression introduced in 3.0.3.
+
+2015-04-27: vadz
+ [Python] Fix "default" typemap used after an argument with "numinputs=0" (#377).
+
+2015-04-24: wsfulton
+ [Python] Fix #256. Code generated with '-builtin -modernargs' segfaults for any
+ method taking zero arguments.
+
+ Also fixes: "SystemError: error return without exception set" during error checking
+ when using just -builtin and the incorrect number of arguments is passed to a class
+ method expecting zero arguments.
+
+2015-04-23: wsfulton
+ [Java] Bug #386 - Memory leak fix in (char *STRING, size_t LENGTH) typemaps.
+
+2015-04-23: vadz
+ [Python] Make "default" typemap work again (#330, #377).
+
+2015-04-23: vadz
+ [Python] Fix the use of default values for the pointer types (#365, #376).
+
+2015-04-23: wsfulton
+ Fix 'make check-ccache' which is part of 'make check' when one of the CCACHE_
+ environment variables, for example CCACHE_DISABLE, is set.
+
+2015-04-14: wsfulton
+ Clearer warning message for badly constructed typecheck typemaps. For example, was:
+
+ example.i:3: Warning 467: Overloaded foo(int) not supported (no type checking
+ rule for 'int').
+
+ Now:
+
+ example.i:3: Warning 467: Overloaded foo(int) not supported (incomplete type checking
+ rule - no precedence level in typecheck typemap for 'int').
+
+2015-04-11: wsfulton
+ [Java] Fix #353 - Linker multiple definition of 'ExceptionMatches' when
+ using directors and multiple modules.
+
+2015-04-11: wsfulton
+ Merge #320 - Make __dict__ accessible for Python builtin classes.
+
+2015-04-07: wsfulton
+ Fix #375 - parsing of extern "C" and typedef for example:
+ extern "C" typedef void (*Hook2_t)(int, const char *);
+ extern "C" typedef int Integer;
+
+2015-03-12: olly
+ -DSWIG_DIRECTOR_STATIC is now supported for all languages with
+ director support, not only Python and PHP.
+
+2015-03-02: ianlancetaylor
+ [Go] Add -cgo option, required for Go versions 1.5 and
+ later.
+
+2015-02-26: olly
+ Fix segmentation fault when top==NULL, introduced by nested class
+ handling (reported in issue#346 by Pawe¿ Tomulik).
+
+2015-02-09: wsfulton
+ [Guile] Fix generated code for static const char member variables when
+ defined and declared inline.
+
+2015-02-09: mishas
+ [Go] Fix %import of files in sub directories.
+
+2015-02-05: ianlancetaylor
+ [Go] Ignore Go specific type maps (goin, goout, etc.) if they are empty.
+
+2015-02-05: ianlancetaylor
+ [Go] Generated Go code no longer calls _swig_goallocate or
+ _swig_makegostring, as they will no longer work as of Go 1.5.
+
Version 3.0.5 (31 Jan 2015)
===========================
@@ -1524,7 +1726,7 @@ Version 2.0.6 (30 April 2012)
[Lua] Fix uninitialised variable in SWIGTYPE **OUTPUT typemaps as reported by Jim Anderson.
2012-04-28: wsfulton
- [Python] Fix compilation errors when wrapping STL containers on Mac OSX and possibly other systems.
+ [Python] Fix compilation errors when wrapping STL containers on Mac OS X and possibly other systems.
2012-04-28: wsfulton
[Java] Patch 3521811 from Leo Davis - char **STRING_ARRAY typemaps fixed to handle
@@ -2219,7 +2421,7 @@ Version 2.0.2 (20 February 2011)
Update chapter name to MzScheme/Racket accounting for the rename of MzScheme to Racket.
2011-02-05: wsfulton
- [C#] SF #3085906 - Possible fix running test-suite on Mac OSX.
+ [C#] SF #3085906 - Possible fix running test-suite on Mac OS X.
2011-02-05: wsfulton
SF #3173367 Better information during configure about Boost prerequisite for running
@@ -3872,7 +4074,7 @@ Version 1.3.37 (13 January 2009)
in Allegro CL
2008-07-19: wsfulton
- Fix building of Tcl examples/test-suite on Mac OSX reported by Gideon Simpson.
+ Fix building of Tcl examples/test-suite on Mac OS X reported by Gideon Simpson.
2008-07-17: wsfulton
Fix SF #2019156 Configuring with --without-octave or --without-alllang
@@ -12693,7 +12895,7 @@ Version 1.3.20 (December 17, 2003)
Suggested by Kerim Borchaev.
11/11/2003: beazley
- Configuration changes to make SWIG work on Mac OSX 10.3.x (Panther).
+ Configuration changes to make SWIG work on Mac OS X 10.3.x (Panther).
Tested with Python, Tcl, Perl, and Ruby---all of which seem to work.
11/08/2003: cheetah (William Fulton)
diff --git a/CHANGES.current b/CHANGES.current
index c7b415248..48ccc2036 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -2,204 +2,120 @@ Below are the changes for the current release.
See the CHANGES file for changes in older releases.
See the RELEASENOTES file for a summary of changes in each release.
-Version 3.0.6 (in progress)
+Version 3.0.7 (in progress)
===========================
-2015-07-02: wsfulton
- Fix syntax error when the template keyword is used in types, eg:
+2015-08-02: wsfulton
+ [Java] Fix potential security exploit in generated Java classes.
+ The swigCPtr and swigCMemOwn member variables in the generated Java
+ classes are now declared 'transient' by default. Further details of the exploit
+ in Android is being published in an academic paper as part of USENIX WOOT '15:
+ https://www.usenix.org/conference/woot15/workshop-program/presentation/peles.
- std::template vector<int> v;
+ In the unlikely event that you are relying on these members being serializable,
+ then you will need to override the default javabody and javabody_derived typemaps
+ to generate the old generated code. The relevant typemaps are in the Lib directory
+ in the java.swg, boost_shared_ptr.i and boost_intrusive_ptr.i files. Copy the
+ relevant default typemaps into your interface file and remove the 'transient' keyword.
-2015-07-02: ngladitz
- [Lua] Push characters as unformatted 1-character strings to avoid
- unprintable characters such as (char)127 being converted to
- "<\127>" with Lua 5.3 and later. (github PR #452)
+ *** POTENTIAL INCOMPATIBILITY ***
-2015-06-29: olly
- [Python] Improve handling of whitespace in %pythoncode.
+2015-08-01: vadz
+ Make configure --without-alllang option more useful: it can now be overridden by the following
+ --with-xxx options, allowing to easily enable just one or two languages.
- Previously SWIG looked at the indentation of the first line and
- removed that many characters from each subsequent line, regardless
- of what those characters were. This was made worse because SWIG's
- preprocessor removes any whitespace before a '#'. Fixes github
- issue #379, reported by Joe Orton.
+2015-07-30: wsfulton
+ Fix #440 - Initialise all newly created arrays when using %array_functions and %array_class
+ in the carrays.i library - bug is only relevant when using C++.
-2015-06-12: wsfulton
- [R] Fix #430 - call to SWIG_createNewRef in copyToC was incorrectly named.
+2015-07-29: wsfulton
+ [Python] Improve indentation warning and error messages for code in the following directives:
-2015-06-11: sghirate
- [C#] Patch #427 adds in new command line option -outfile to combine all the
- generated C# code into a single file.
+ %pythonprepend
+ %pythonappend
+ %pythoncode
+ %pythonbegin
+ %feature("shadow")
-2015-06-09: wsfulton
- Fix seg fault processing C++11 type aliasing. Issue #424.
+ Old error example:
+ Error: Line indented less than expected (line 3 of pythoncode)
-2015-05-28: wsfulton
- [Python] Add new feature "python:cdefaultargs" to control default argument
- code generation. By default, SWIG attempts to convert C/C++ default argument values
- into Python values and generates code into the Python layer with these values.
- Recent versions of SWIG are able to convert more of these values, however, the
- new behaviour can be circumvented if desired via this new feature, such that
- the default argument values are obtained from the C layer and not the Python layer.
- For example:
+ New error example:
+ Error: Line indented less than expected (line 3 of %pythoncode or %insert("python") block)
+ as no line should be indented less than the indentation in line 1
- struct CDA {
- int fff(int a = 1, bool b = false);
- };
+ Old warning example:
+ Warning 740: Whitespace prefix doesn't match (line 2 of %pythoncode or %insert("python") block)
- The default code generation in the Python layer is:
+ New warning example:
+ Warning 740: Whitespace indentation is inconsistent compared to earlier lines (line 3 of
+ %pythoncode or %insert("python") block)
- class CDA(_object):
- ...
- def fff(self, a=1, b=False):
- return _default_args.CDA_fff(self, a, b)
+
+2015-07-28: wsfulton
+ [Python] Fix #475. Improve docstring indentation handling.
+
+ SWIG-3.0.5 and earlier sometimes truncated text provided in the docstring feature.
+ This occurred when the indentation (whitespace) in the docstring was less in the
+ second or later lines when compared to the first line.
+ SWIG-3.0.6 gave a 'Line indented less than expected' error instead of truncating
+ the docstring text.
+ Now the indentation for the 'docstring' feature is smarter and is appropriately
+ adjusted so that no truncation occurs.
- Adding the feature:
+2015-07-22: wsfulton
+ Support for special variable expansion in typemap attributes. Example usage expansion
+ in the 'out' attribute (C# specific):
- %feature("python:cdefaultargs") CDA::fff;
+ %typemap(ctype, out="$*1_ltype") unsigned int& "$*1_ltype"
- Results in:
+ is equivalent to the following as $*1_ltype expands to 'unsigned int':
- class CDA(_object):
- ...
- def fff(self, *args):
- return _default_args.CDA_fff(self, *args)
+ %typemap(ctype, out="unsigned int") unsigned int& "unsigned int"
- Some code generation modes, eg -builtin and -fastproxy, are unaffected by this as
- the default values are always obtained from the C layer.
+ Special variables can be used within special variable macros too. Example usage expansion:
-2015-05-27: wsfulton
- [Python] Deal with an integer as the default value of a typedef to bool
- parameter in the C++ prototype. See #327. Regression from 3.0.0 onwards.
+ %typemap(cstype) unsigned int "uint"
+ %typemap(cstype, out="$typemap(cstype, $*1_ltype)") unsigned int& "$typemap(cstype, $*1_ltype)"
-2015-05-19: olly
- [Python] Fix warning when compiling generated code with MSVC.
- (Fixes https://sourceforge.net/p/swig/patches/351/ reported by
- Mateusz Szymański).
+ Special variables are expanded first and hence the above is equivalent to:
-2015-05-14: wsfulton
- Fix seg fault wrapping shared_ptr of classes with private constructors and destructors.
- This also fixes the "unref" feature when used on classes with private destructors.
+ %typemap(cstype, out="$typemap(cstype, unsigned int)") unsigned int& "$typemap(cstype, unsigned int)"
-2015-05-10: wsfulton
- [Java] Fix multi-argument typemaps (char *STRING, size_t LENGTH)
- so that they can be applied to a wider range of types. Fixes #385.
+ which then expands to:
-2015-05-07: olly
- [Python] Deal with an integer as the default value of a bool
- parameter in the C++ prototype. Fixes github #327, reported by
- Greg Allen.
+ %typemap(cstype, out="uint") unsigned int& "uint"
-2015-05-07: LindleyF
- [Java] Allow feature("director") and feature("ref") to be used
- together. Github PR#403.
+2015-07-22: lindleyf
+ Apply patch #439 - support for $typemap() (aka embedded typemaps or special variable
+ macros) in typemap attributes. A simple example where $typemap() is expanded in the
+ 'out' attribute (C# specific):
-2015-05-05: olly
- Suppress warning 325 "Nested class not currently supported (Foo
- ignored)" when Foo has already been explicitly ignored with "%ignore".
+ %typemap(cstype) unsigned int "uint"
+ %typemap(cstype, out="$typemap(cstype, unsigned int)") unsigned int& "$typemap(cstype, unsigned int)"
-2015-05-04: wsfulton
- Add support for friend templates, including operator overloading - fixes #196. Considering
- the example below, previously the operator gave a syntax error and friendfunc incorrectly
- warned with:
+ is equivalent to:
- "Warning 503: Can't wrap 'friendfunc<(Type)>' unless renamed to a valid identifier."
+ %typemap(cstype, out="uint") unsigned int& "uint"
- template <class Type> class MyClass {
- friend int friendfunc <Type>(double is, MyClass <Type> & x);
- friend int operator<< <Type>(double un, const MyClass <Type> &x);
- };
+2015-07-18: m7thon
+ [Python] Docstrings provided via %feature("docstring") are now quoted and added to
+ the tp_doc slot when using python builtin classes (-builtin). When no docstring is
+ provided, the tp_doc slot is set to the fully qualified C/C++ class name.
+ Github issues #445 and #461.
- The following also previously incorrectly warned with:
+2015-07-17: kwwette
+ [octave] Support Octave version 4.0.0 (thanks to patches from Orion Poplawski).
- "Warning 302: Identifier 'template_friend' redefined (ignored),"
+2015-07-07: wsfulton
+ SWIG no longer generates a wrapper for a class' constructor if that class has
+ any base class with a private destructor. This is because your compiler should
+ not allow a class to be instantiated if a base has a private destructor. Some
+ compilers do, so if you need the old behaviour, use the "notabstract" feature, eg:
- template<typename T> T template_friend(T);
- struct MyTemplate {
- template<typename T> friend T template_friend(T);
+ %feature("notabstract") Derived;
+ class Base {
+ ~Base() {}
};
+ struct Derived : Base {};
-2015-05-01: wsfulton
- Fix handling of conversion operators where the operator is split over multiple
- lines or has comments within the operator type. Fixes #401.
-
- Also fix similar problem with normal operators which gave a syntax error if split over
- multiple lines or had a comment within the operator declaration.
-
-2015-04-30: olly
- Ignore unknown preprocessor directives which are inside an inactive
- conditional (github issue #394, reported by Dan Wilcox).
- Regression introduced in 3.0.3.
-
-2015-04-27: vadz
- [Python] Fix "default" typemap used after an argument with "numinputs=0" (#377).
-
-2015-04-24: wsfulton
- [Python] Fix #256. Code generated with '-builtin -modernargs' segfaults for any
- method taking zero arguments.
-
- Also fixes: "SystemError: error return without exception set" during error checking
- when using just -builtin and the incorrect number of arguments is passed to a class
- method expecting zero arguments.
-
-2015-04-23: wsfulton
- [Java] Bug #386 - Memory leak fix in (char *STRING, size_t LENGTH) typemaps.
-
-2015-04-23: vadz
- [Python] Make "default" typemap work again (#330, #377).
-
-2015-04-23: vadz
- [Python] Fix the use of default values for the pointer types (#365, #376).
-
-2015-04-23: wsfulton
- Fix 'make check-ccache' which is part of 'make check' when one of the CCACHE_
- environment variables, for example CCACHE_DISABLE, is set.
-
-2015-04-14: wsfulton
- Clearer warning message for badly constructed typecheck typemaps. For example, was:
-
- example.i:3: Warning 467: Overloaded foo(int) not supported (no type checking
- rule for 'int').
-
- Now:
-
- example.i:3: Warning 467: Overloaded foo(int) not supported (incomplete type checking
- rule - no precedence level in typecheck typemap for 'int').
-
-2015-04-11: wsfulton
- [Java] Fix #353 - Linker multiple definition of 'ExceptionMatches' when
- using directors and multiple modules.
-
-2015-04-11: wsfulton
- Merge #320 - Make __dict__ accessible for Python builtin classes.
-
-2015-04-07: wsfulton
- Fix #375 - parsing of extern "C" and typedef for example:
- extern "C" typedef void (*Hook2_t)(int, const char *);
- extern "C" typedef int Integer;
-
-2015-03-12: olly
- -DSWIG_DIRECTOR_STATIC is now supported for all languages with
- director support, not only Python and PHP.
-
-2015-03-02: ianlancetaylor
- [Go] Add -cgo option, required for Go versions 1.5 and
- later.
-
-2015-02-26: olly
- Fix segmentation fault when top==NULL, introduced by nested class
- handling (reported in issue#346 by Paweł Tomulik).
-
-2015-02-09: wsfulton
- [Guile] Fix generated code for static const char member variables when
- defined and declared inline.
-
-2015-02-09: mishas
- [Go] Fix %import of files in sub directories.
-
-2015-02-05: ianlancetaylor
- [Go] Ignore Go specific type maps (goin, goout, etc.) if they are empty.
-
-2015-02-05: ianlancetaylor
- [Go] Generated Go code no longer calls _swig_goallocate or
- _swig_makegostring, as they will no longer work as of Go 1.5.
diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html
index 0c0d98c0e..18fc3037e 100644
--- a/Doc/Manual/CSharp.html
+++ b/Doc/Manual/CSharp.html
@@ -12,10 +12,8 @@
<li><a href="#CSharp_introduction">Introduction</a>
<ul>
<li><a href="#CSharp_introduction_swig2_compatibility">SWIG 2 Compatibility</a>
-</ul>
-<ul>
<li><a href="#CSharp_commandline">Additional command line options</a>
-</ul
+</ul>
<li><a href="#CSharp_differences_java">Differences to the Java module</a>
<li><a href="#CSharp_void_pointers">Void pointers</a>
<li><a href="#CSharp_arrays">C# Arrays</a>
@@ -85,6 +83,7 @@ In order to minimize name collisions between names generated based on input to S
<H3><a name="CSharp_commandline"></a>20.1.2 Additional command line options</H3>
+
<p>
The following table lists the additional commandline options available for the C# module. They can also be seen by using:
</p>
@@ -93,8 +92,6 @@ The following table lists the additional commandline options available for the C
swig -csharp -help
</pre></div>
-<p></p>
-
<table summary="C# specific options">
<tr>
<th>C# specific options</th>
diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html
index dd0faace6..e8b1e3477 100644
--- a/Doc/Manual/Contents.html
+++ b/Doc/Manual/Contents.html
@@ -441,6 +441,8 @@
<li><a href="Typemaps.html#Typemaps_special_macro_descriptor">$descriptor(type)</a>
<li><a href="Typemaps.html#Typemaps_special_macro_typemap">$typemap(method, typepattern)</a>
</ul>
+<li><a href="Typemaps.html#Typemaps_special_variable_attributes">Special variables and typemap attributes</a>
+<li><a href="Typemaps.html#Typemaps_special_variables_and_macros">Special variables combined with special variable macros</a>
</ul>
<li><a href="Typemaps.html#Typemaps_nn25">Common typemap methods</a>
<ul>
@@ -725,6 +727,7 @@
<li><a href="CSharp.html#CSharp_introduction">Introduction</a>
<ul>
<li><a href="CSharp.html#CSharp_introduction_swig2_compatibility">SWIG 2 Compatibility</a>
+<li><a href="CSharp.html#CSharp_commandline">Additional command line options</a>
</ul>
<li><a href="CSharp.html#CSharp_differences_java">Differences to the Java module</a>
<li><a href="CSharp.html#CSharp_void_pointers">Void pointers</a>
@@ -747,7 +750,7 @@
<li><a href="CSharp.html#CSharp_directors_implementation">Directors implementation</a>
<li><a href="CSharp.html#CSharp_director_caveats">Director caveats</a>
</ul>
-<li><a href="CSharp.html#CSharp_multiple_modules">Multiples modules</a>
+<li><a href="CSharp.html#CSharp_multiple_modules">Multiple modules</a>
<li><a href="CSharp.html#CSharp_typemap_examples">C# Typemap examples</a>
<ul>
<li><a href="CSharp.html#CSharp_memory_management_member_variables">Memory management when returning references to member variables</a>
@@ -1069,7 +1072,7 @@
</ul>
<li><a href="Javascript.html#Javascript_embedded_webkit">Embedded Webkit</a>
<ul>
-<li><a href="Javascript.html#Javascript_osx">OSX</a>
+<li><a href="Javascript.html#Javascript_osx">Mac OS X</a>
<li><a href="Javascript.html#Javascript_gtk">GTK</a>
</ul>
<li><a href="Javascript.html#Javascript_applications_webkit">Creating Applications with node-webkit</a>
@@ -1529,6 +1532,7 @@
<li><a href="Python.html#Python_nn47">Simple pointers</a>
<li><a href="Python.html#Python_nn48">Unbounded C Arrays</a>
<li><a href="Python.html#Python_nn49">String handling</a>
+<li><a href="Python.html#Python_default_args">Default arguments</a>
</ul>
<li><a href="Python.html#Python_nn53">Typemaps</a>
<ul>
diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html
index 0a413b25a..20e923d19 100644
--- a/Doc/Manual/Go.html
+++ b/Doc/Manual/Go.html
@@ -495,8 +495,10 @@ the C++ object when the Go object is freed. It is strongly recommended to read
the <a href="https://golang.org/pkg/runtime/#SetFinalizer">runtime.SetFinalizer
</a> documentation before using this technique to understand the
<tt>runtime.SetFinalizer</tt> limitations.<br>
-<br>
+</p>
+<p>
Common pitfalls with <tt>runtime.SetFinalizer</tt> are:
+</p>
<ul>
<li>
If a hierarchy of C++ objects will be automatically freed by Go finalizers then
@@ -514,7 +516,6 @@ The Go finalizer function typically runs in a different OS thread which can be
problematic with C++ code that uses thread-local storage.
</li>
</ul>
-</p>
<p>
<tt>runtime.SetFinalizer</tt> Example:
diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html
index 3a4f7ee5d..9d5c447f7 100644
--- a/Doc/Manual/Java.html
+++ b/Doc/Manual/Java.html
@@ -2390,8 +2390,8 @@ The default proxy class for our previous example looks like this:
<div class="code">
<pre>
public class Foo {
- private long swigCPtr;
- protected boolean swigCMemOwn;
+ private transient long swigCPtr;
+ protected transient boolean swigCMemOwn;
protected Foo(long cPtr, boolean cMemoryOwn) {
swigCMemOwn = cMemoryOwn;
@@ -2641,8 +2641,8 @@ The base class is generated much like any other proxy class seen so far:
<div class="code"><pre>
public class Base {
- private long swigCPtr;
- protected boolean swigCMemOwn;
+ private transient long swigCPtr;
+ protected transient boolean swigCMemOwn;
protected Base(long cPtr, boolean cMemoryOwn) {
swigCMemOwn = cMemoryOwn;
@@ -2682,7 +2682,7 @@ The <tt>Derived</tt> class extends <tt>Base</tt> mirroring the C++ class inherit
<div class="code"><pre>
public class Derived extends Base {
- private long swigCPtr;
+ private transient long swigCPtr;
protected Derived(long cPtr, boolean cMemoryOwn) {
super(exampleJNI.SWIGDerivedUpcast(cPtr), cMemoryOwn);
@@ -2960,8 +2960,8 @@ and the Java proxy class generated by SWIG:
<div class="code"><pre>
public class Test {
- private long swigCPtr;
- protected boolean swigCMemOwn;
+ private transient long swigCPtr;
+ protected transient boolean swigCMemOwn;
protected Test(long cPtr, boolean cMemoryOwn) {
swigCMemOwn = cMemoryOwn;
@@ -3034,7 +3034,7 @@ The generated type wrapper class, for say an <tt>int *</tt>, looks like this:
<div class="code"><pre>
public class SWIGTYPE_p_int {
- private long swigCPtr;
+ private transient long swigCPtr;
protected SWIGTYPE_p_int(long cPtr, boolean bFutureUse) {
swigCPtr = cPtr;
@@ -5900,8 +5900,8 @@ If you are invoking SWIG more than once and generating the wrapped classes into
<div class="code">
<pre>
%typemap(javabody) SWIGTYPE %{
- private long swigCPtr;
- protected boolean swigCMemOwn;
+ private transient long swigCPtr;
+ protected transient boolean swigCMemOwn;
protected $javaclassname(long cPtr, boolean cMemoryOwn) {
swigCMemOwn = cMemoryOwn;
@@ -5929,7 +5929,7 @@ For the typemap to be used in all type wrapper classes, all the different types
<div class="code">
<pre>
%typemap(javabody) SWIGTYPE *, SWIGTYPE &amp;, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
- private long swigCPtr;
+ private transient long swigCPtr;
protected $javaclassname(long cPtr, boolean bFutureUse) {
swigCPtr = cPtr;
diff --git a/Doc/Manual/Javascript.html b/Doc/Manual/Javascript.html
index 7857d9770..613ca99ed 100644
--- a/Doc/Manual/Javascript.html
+++ b/Doc/Manual/Javascript.html
@@ -25,7 +25,7 @@
</ul>
<li><a href="#Javascript_embedded_webkit">Embedded Webkit</a>
<ul>
-<li><a href="#Javascript_osx">OSX</a>
+<li><a href="#Javascript_osx">Mac OS X</a>
<li><a href="#Javascript_gtk">GTK</a>
</ul>
<li><a href="#Javascript_applications_webkit">Creating Applications with node-webkit</a>
@@ -156,7 +156,7 @@ $ make check-javascript-examples V8_VERSION=0x032530 ENGINE=v8</pre>
<li><p><code>instanceOf</code> does not work under JSC</p></li>
</ul>
-<p>The primary development environment has been Linux (Ubuntu 12.04). Windows and OSX have been tested sporadically. Therefore, the generators might have more issues on those platforms. Please report back any problem you observe to help us improving this module quickly.</p>
+<p>The primary development environment has been Linux (Ubuntu 12.04). Windows and Mac OS X have been tested sporadically. Therefore, the generators might have more issues on those platforms. Please report back any problem you observe to help us improving this module quickly.</p>
<H2><a name="Javascript_integration"></a>26.3 Integration</H2>
@@ -166,7 +166,7 @@ $ make check-javascript-examples V8_VERSION=0x032530 ENGINE=v8</pre>
<H3><a name="Javascript_node_extensions"></a>26.3.1 Creating node.js Extensions</H3>
-<p>To install <code>node.js</code> you can download an installer from their <a href="https://launchpad.net/~chris-lea/+archive/node.js">web-site</a> for OSX and Windows. For Linux you can either build the source yourself and run <code>sudo checkinstall</code> or keep to the (probably stone-age) packaged version. For Ubuntu there is a <a href="https://launchpad.net/~chris-lea/+archive/node.js/">PPA</a> available.</p>
+<p>To install <code>node.js</code> you can download an installer from their <a href="https://launchpad.net/~chris-lea/+archive/node.js">web-site</a> for Mac OS X and Windows. For Linux you can either build the source yourself and run <code>sudo checkinstall</code> or keep to the (probably stone-age) packaged version. For Ubuntu there is a <a href="https://launchpad.net/~chris-lea/+archive/node.js/">PPA</a> available.</p>
<div class="shell">
<pre>
$ sudo add-apt-repository ppa:chris-lea/node.js
@@ -224,9 +224,9 @@ $ sudo apt-get remove gyp</pre>
<H3><a name="Javascript_embedded_webkit"></a>26.3.2 Embedded Webkit</H3>
-<p>Webkit is pre-installed on OSX and available as a library for GTK.</p>
+<p>Webkit is pre-installed on Mac OS X and available as a library for GTK.</p>
-<H4><a name="Javascript_osx"></a>26.3.2.1 OSX</H4>
+<H4><a name="Javascript_osx"></a>26.3.2.1 Mac OS X</H4>
<p>There is general information about programming with WebKit on <a href="https://developer.apple.com/library/mac/documentation/cocoa/conceptual/DisplayWebContent/DisplayWebContent.html">Apple Developer Documentation</a>. Details about <code>Cocoa</code> programming are not covered here.</p>
diff --git a/Doc/Manual/Octave.html b/Doc/Manual/Octave.html
index 46a8941c2..5f8437a6a 100644
--- a/Doc/Manual/Octave.html
+++ b/Doc/Manual/Octave.html
@@ -59,7 +59,7 @@ Also, there are a dozen or so examples in the Examples/octave directory, and hun
<p>
-As of SWIG 3.0.3, the Octave module has been tested with Octave versions 3.2.4, 3.4.3, 3.6.4, and 3.8.1.
+As of SWIG 3.0.7, the Octave module is regularly tested with Octave versions 3.2.4, 3.8.1, and 4.0.0.
Use of older Octave versions is not recommended, as these versions are no longer tested with SWIG.
</p>
diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html
index 0cbb38021..57a2cd3ef 100644
--- a/Doc/Manual/Python.html
+++ b/Doc/Manual/Python.html
@@ -74,6 +74,7 @@
<li><a href="#Python_nn47">Simple pointers</a>
<li><a href="#Python_nn48">Unbounded C Arrays</a>
<li><a href="#Python_nn49">String handling</a>
+<li><a href="#Python_default_args">Default arguments</a>
</ul>
<li><a href="#Python_nn53">Typemaps</a>
<ul>
@@ -4160,7 +4161,8 @@ also be used to extra binary data from arbitrary pointers.
</p>
-<H3><a name="Python_default_args"></a>Default arguments</H3>
+<H3><a name="Python_default_args"></a>36.7.5 Default arguments</H3>
+
<p>
C++ default argument code generation is documented in the main
diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html
index 057d355ec..4bf40c969 100644
--- a/Doc/Manual/Sections.html
+++ b/Doc/Manual/Sections.html
@@ -6,7 +6,7 @@
<body bgcolor="#ffffff">
<H1><a name="Sections"></a>SWIG-3.0 Documentation</H1>
-Last update : SWIG-3.0.6 (in progress)
+Last update : SWIG-3.0.7 (in progress)
<H2>Sections</H2>
diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html
index 5f484531b..51fadb095 100644
--- a/Doc/Manual/Typemaps.html
+++ b/Doc/Manual/Typemaps.html
@@ -48,6 +48,8 @@
<li><a href="#Typemaps_special_macro_descriptor">$descriptor(type)</a>
<li><a href="#Typemaps_special_macro_typemap">$typemap(method, typepattern)</a>
</ul>
+<li><a href="#Typemaps_special_variable_attributes">Special variables and typemap attributes</a>
+<li><a href="#Typemaps_special_variables_and_macros">Special variables combined with special variable macros</a>
</ul>
<li><a href="#Typemaps_nn25">Common typemap methods</a>
<ul>
@@ -2425,6 +2427,76 @@ The result is the following expansion
</pre>
</div>
+
+<H3><a name="Typemaps_special_variable_attributes"></a>11.4.5 Special variables and typemap attributes</H3>
+
+
+<p>
+As of SWIG-3.0.7 typemap attributes will also expand special variables and special variable macros.
+</p>
+
+<p>
+Example usage showing the expansion in the 'out' attribute (C# specific) as well as the main typemap body:
+</p>
+
+<div class="code">
+<pre>
+%typemap(ctype, out="$*1_ltype") unsigned int&amp; "$*1_ltype"
+</pre>
+</div>
+
+<p>
+is equivalent to the following as <tt>$*1_ltype</tt> expands to <tt>unsigned int</tt>:
+</p>
+
+<div class="code">
+<pre>
+%typemap(ctype, out="unsigned int") unsigned int&amp; "unsigned int"
+</pre>
+</div>
+
+<H3><a name="Typemaps_special_variables_and_macros"></a>11.4.6 Special variables combined with special variable macros</H3>
+
+
+<p>
+Special variables can also be used within special variable macros.
+The special variables are expanded before they are used in the special variable macros.
+</p>
+
+<p>
+Consider the following C# typemaps:
+</p>
+
+<div class="code">
+<pre>
+%typemap(cstype) unsigned int "uint"
+%typemap(cstype, out="$typemap(cstype, $*1_ltype)") unsigned int&amp; "$typemap(cstype, $*1_ltype)"
+</pre>
+</div>
+
+<p>
+Special variables are expanded first and hence the above is equivalent to:
+</p>
+
+<div class="code">
+<pre>
+%typemap(cstype) unsigned int "uint"
+%typemap(cstype, out="$typemap(cstype, unsigned int)") unsigned int&amp; "$typemap(cstype, unsigned int)"
+</pre>
+</div>
+
+<p>
+which then expands to:
+</p>
+
+<div class="code">
+<pre>
+%typemap(cstype) unsigned int "uint"
+%typemap(cstype, out="uint") unsigned int&amp; "uint"
+</pre>
+</div>
+
+
<H2><a name="Typemaps_nn25"></a>11.5 Common typemap methods</H2>
diff --git a/Examples/test-suite/array_typedef_memberin.i b/Examples/test-suite/array_typedef_memberin.i
index d9f768ed8..7301057e9 100644
--- a/Examples/test-suite/array_typedef_memberin.i
+++ b/Examples/test-suite/array_typedef_memberin.i
@@ -1,5 +1,9 @@
%module array_typedef_memberin
+#if defined(_MSC_VER)
+ #pragma warning(disable: 4351) // new behavior: elements of array 'xyz' will be default initialized
+#endif
+
#if defined(SWIGSCILAB)
%rename(ExDetail) ExampleDetail;
#endif
@@ -13,13 +17,8 @@ namespace ArrayExample
{
public:
Eight node_list;
-#ifndef _MSC_VER
const Eight node_list2;
ConstEight node_list3;
-#else
- Eight node_list2;
- Eight node_list3;
-#endif
void fn1(Eight a) {}
void fn2(const Eight a) {}
@@ -32,6 +31,8 @@ namespace ArrayExample
void fn7(Eight*& a) {}
void fn8(ConstEight*& a) {}
void fn9(const ConstEight*& a) {}
+
+ ExampleDetail() : node_list(), node_list2(), node_list3() {}
};
}
diff --git a/Examples/test-suite/autodoc.i b/Examples/test-suite/autodoc.i
index d85899756..07afa5794 100644
--- a/Examples/test-suite/autodoc.i
+++ b/Examples/test-suite/autodoc.i
@@ -114,12 +114,6 @@
}
%}
-%callback("%(uppercase)s_CALLBACK") func_cb;
-
-%inline {
- int func_cb(int c, int d) { return c; }
-}
-
// Bug 3310528
%feature("autodoc","1") banana; // names + types
%inline %{
diff --git a/Examples/test-suite/callback.i b/Examples/test-suite/callback.i
index 8e28dad06..4db63353b 100644
--- a/Examples/test-suite/callback.i
+++ b/Examples/test-suite/callback.i
@@ -1,10 +1,18 @@
%module callback
+// Not specifying the callback name is only possible in Python.
+#ifdef SWIGPYTHON
%callback(1) foo;
%callback(1) foof;
%callback(1) A::bar;
%callback(1) A::foom;
-%callback("%s_Cb_Ptr") foo_T; // old style, still works.
+#else
+%callback("%s") foo;
+%callback("%s") foof;
+%callback("%s") A::bar;
+%callback("%s") A::foom;
+#endif
+%callback("%(uppercase)s_Cb_Ptr") foo_T; // this works in Python too
%inline %{
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index 3f3b2216f..cc1ec7464 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -374,6 +374,7 @@ CPP_TEST_CASES += \
smart_pointer_templatevariables \
smart_pointer_typedef \
special_variables \
+ special_variable_attributes \
special_variable_macros \
static_array_member \
static_const_member \
diff --git a/Examples/test-suite/cpp11_lambda_functions.i b/Examples/test-suite/cpp11_lambda_functions.i
index 87c7196d8..161e08c65 100644
--- a/Examples/test-suite/cpp11_lambda_functions.i
+++ b/Examples/test-suite/cpp11_lambda_functions.i
@@ -100,9 +100,6 @@ int runLambdaInline() {
%{
// TODO
-struct LambdaStruct {
- static constexpr auto lambda_struct1 = [=]() { return thing; };
-};
int(*lambda101notauto)(int, int) = [] (int a, int b) { return a + b; };
int lambda102 = [] (int a, int b) mutable { return a + b; }(1, 2);
void lambda_init(int = ([=]{ return 0; })());
diff --git a/Examples/test-suite/cpp11_noexcept.i b/Examples/test-suite/cpp11_noexcept.i
index 6fed5b8df..ef96fd8a7 100644
--- a/Examples/test-suite/cpp11_noexcept.i
+++ b/Examples/test-suite/cpp11_noexcept.i
@@ -13,7 +13,7 @@ struct NoExceptClass {
NoExceptClass() noexcept {}
NoExceptClass(const NoExceptClass&) noexcept {}
NoExceptClass(NoExceptClass&&) noexcept {}
- NoExceptClass& operator=(const NoExceptClass&) noexcept {}
+ NoExceptClass& operator=(const NoExceptClass&) noexcept { return *this; }
~NoExceptClass() noexcept {}
void noex0() noexcept {}
diff --git a/Examples/test-suite/cpp11_rvalue_reference2.i b/Examples/test-suite/cpp11_rvalue_reference2.i
index 4ef871c63..6718a3941 100644
--- a/Examples/test-suite/cpp11_rvalue_reference2.i
+++ b/Examples/test-suite/cpp11_rvalue_reference2.i
@@ -31,14 +31,17 @@ struct Thingy {
// test both primitive and user defined rvalue reference default arguments and compactdefaultargs
void compactDefaultArgs(const bool &&b = (const bool &&)PublicGlobalTrue, const UserDef &&u = (const UserDef &&)PublicUserDef) {}
void privateDefaultArgs(const bool &&b = (const bool &&)PrivateTrue) {}
- operator int &&() {}
+ operator int &&() { return std::move(0); }
+ Thingy(const Thingy& rhs) : val(rhs.val), lvalref(rhs.lvalref), rvalref(copy_int(rhs.rvalref)) {}
Thingy& operator=(const Thingy& rhs) {
val = rhs.val;
lvalref = rhs.lvalref;
rvalref = rhs.rvalref;
+ return *this;
}
private:
static const bool PrivateTrue;
+ int copy_int(int& i) { return i; }
Thingy();
};
const bool Thingy::PrivateTrue = true;
diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in
index d5eac5c03..0c799c7d9 100644
--- a/Examples/test-suite/csharp/Makefile.in
+++ b/Examples/test-suite/csharp/Makefile.in
@@ -73,7 +73,7 @@ setup = \
# Compiles C# files then runs the testcase. A testcase is only run if
# a file is found which has _runme.cs appended after the testcase name.
# Note C# uses LD_LIBRARY_PATH under Unix, PATH under Cygwin/Windows and SHLIB_PATH on HPUX.
-# DYLD_FALLBACK_LIBRARY_PATH is cleared for MacOSX.
+# DYLD_FALLBACK_LIBRARY_PATH is cleared for Mac OS X.
run_testcase = \
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
$(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \
diff --git a/Examples/test-suite/csharp/default_constructor_runme.cs b/Examples/test-suite/csharp/default_constructor_runme.cs
index acd62dc3d..9fc8d754b 100644
--- a/Examples/test-suite/csharp/default_constructor_runme.cs
+++ b/Examples/test-suite/csharp/default_constructor_runme.cs
@@ -12,13 +12,5 @@ public class runme
throw new Exception("Protected destructor exception should have been thrown");
} catch (MethodAccessException) {
}
-
- // calling private destructor test
- try {
- using (FFF f = new FFF()) {
- }
- throw new Exception("Private destructor exception should have been thrown");
- } catch (MethodAccessException) {
- }
}
}
diff --git a/Examples/test-suite/csharp/special_variable_attributes_runme.cs b/Examples/test-suite/csharp/special_variable_attributes_runme.cs
new file mode 100644
index 000000000..0365ba47c
--- /dev/null
+++ b/Examples/test-suite/csharp/special_variable_attributes_runme.cs
@@ -0,0 +1,32 @@
+
+// This is the bool runtime testcase. It checks that the C++ bool type works.
+
+using System;
+using special_variable_attributesNamespace;
+
+public class special_variable_attributes_runme {
+
+ public static void Main() {
+ if (special_variable_attributes.getNumber1() != 111)
+ throw new ApplicationException("getNumber1 failed");
+ if (special_variable_attributes.getNumber2() != 222)
+ throw new ApplicationException("getNumber2 failed");
+ if (special_variable_attributes.getNumber3() != 333)
+ throw new ApplicationException("getNumber3 failed");
+
+ if (special_variable_attributes.bounceNumber1(10) != 110)
+ throw new ApplicationException("bounceNumber1 failed");
+ if (special_variable_attributes.bounceNumber2(10) != 220)
+ throw new ApplicationException("bounceNumber2 failed");
+ if (special_variable_attributes.bounceNumber3(10) != 330)
+ throw new ApplicationException("bounceNumber3 failed");
+
+ if (special_variable_attributes.multi1(12.34) != 12+34)
+ throw new ApplicationException("multi1 failed");
+ if (special_variable_attributes.multi2(12.34) != 12+34+55)
+ throw new ApplicationException("multi2 failed");
+ if (special_variable_attributes.multi3(12.34) != 12+34+77)
+ throw new ApplicationException("multi3 failed");
+ }
+
+}
diff --git a/Examples/test-suite/d/default_constructor_runme.1.d b/Examples/test-suite/d/default_constructor_runme.1.d
index 3640218ae..bd79cdf99 100644
--- a/Examples/test-suite/d/default_constructor_runme.1.d
+++ b/Examples/test-suite/d/default_constructor_runme.1.d
@@ -1,6 +1,5 @@
module default_constructor_runme;
-import default_constructor.FFF;
import default_constructor.G;
void main() {
@@ -15,16 +14,4 @@ void main() {
throw e;
}
}
-
- // Private destructor test.
- try {
- {
- scope f = new FFF();
- }
- throw new Exception("Private destructor exception should have been thrown");
- } catch (Exception e) {
- if (e.msg != "C++ destructor does not have public access") {
- throw e;
- }
- }
}
diff --git a/Examples/test-suite/d/default_constructor_runme.2.d b/Examples/test-suite/d/default_constructor_runme.2.d
index 22f5bffd2..991b4186a 100644
--- a/Examples/test-suite/d/default_constructor_runme.2.d
+++ b/Examples/test-suite/d/default_constructor_runme.2.d
@@ -1,6 +1,5 @@
module default_constructor_runme;
-import default_constructor.FFF;
import default_constructor.G;
void main() {
@@ -8,7 +7,6 @@ void main() {
// destruction yet.
// enforceThrows((){ scope g = new G(); }, "Protected destructor exception should have been thrown");
- // enforceThrows((){ scope f = new FFF(); }, "Private destructor exception should have been thrown");
}
private void enforceThrows(void delegate() dg, string errorMessage) {
diff --git a/Examples/test-suite/default_constructor.i b/Examples/test-suite/default_constructor.i
index f7fc8cfa6..40a088cc9 100644
--- a/Examples/test-suite/default_constructor.i
+++ b/Examples/test-suite/default_constructor.i
@@ -13,6 +13,16 @@
SWIGWARN_D_MULTIPLE_INHERITANCE,
SWIGWARN_PHP_MULTIPLE_INHERITANCE) AD; /* C#, D, Java, PHP multiple inheritance */
+%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
+ SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) GGG; /* C#, D, Java, PHP multiple inheritance */
+
+%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
+ SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) HHH; /* C#, D, Java, PHP multiple inheritance */
+
%warnfilter(SWIGWARN_LANG_FRIEND_IGNORE) F; /* friend function */
%delobject F::destroy;
@@ -104,12 +114,21 @@ public:
void bar(F *) { }
#if defined(_MSC_VER)
- #pragma warning(disable: 4624) // : destructor could not be generated because a base class destructor is inaccessible
+ #pragma warning(disable: 4624) // destructor could not be generated because a base class destructor is inaccessible or deleted
#endif
+
+// Single inheritance, base has private destructor
class FFF : public F {
};
+
+// Multiple inheritance, one base has private destructor
+class GGG : public A, public F {
+};
+class HHH : public F, public A {
+};
+
#if defined(_MSC_VER)
- #pragma warning(default: 4624) // : destructor could not be generated because a base class destructor is inaccessible
+ #pragma warning(default: 4624) // destructor could not be generated because a base class destructor is inaccessible or deleted
#endif
/* A class with a protected destructor */
diff --git a/Examples/test-suite/errors/Makefile.in b/Examples/test-suite/errors/Makefile.in
index 4c61001e7..b5d01a0eb 100644
--- a/Examples/test-suite/errors/Makefile.in
+++ b/Examples/test-suite/errors/Makefile.in
@@ -32,7 +32,7 @@ include $(srcdir)/../common.mk
# Portable dos2unix / todos for stripping CR
TODOS = tr -d '\r'
-#TODOS = sed -e 's/\r$$//' # On OSX behaves as if written 's/r$$//'
+#TODOS = sed -e 's/\r$$//' # On Mac OS X behaves as if written 's/r$$//'
# strip source directory from output, so that diffs compare
STRIP_SRCDIR = sed -e 's|\\|/|g' -e 's|^$(SRCDIR)||'
diff --git a/Examples/test-suite/errors/swig_pythoncode_bad.stderr b/Examples/test-suite/errors/swig_pythoncode_bad.stderr
index 71e5db8da..4bded5677 100644
--- a/Examples/test-suite/errors/swig_pythoncode_bad.stderr
+++ b/Examples/test-suite/errors/swig_pythoncode_bad.stderr
@@ -1 +1 @@
-swig_pythoncode_bad.i:7: Error: Line indented less than expected (line 2 of pythoncode)
+swig_pythoncode_bad.i:7: Error: Line indented less than expected (line 2 of %pythoncode or %insert("python") block) as no line should be indented less than the indentation in line 1
diff --git a/Examples/test-suite/errors/swig_pythoncode_bad2.stderr b/Examples/test-suite/errors/swig_pythoncode_bad2.stderr
index 48ad77e51..4fce40444 100644
--- a/Examples/test-suite/errors/swig_pythoncode_bad2.stderr
+++ b/Examples/test-suite/errors/swig_pythoncode_bad2.stderr
@@ -1 +1 @@
-swig_pythoncode_bad2.i:13: Error: Line indented less than expected (line 3 of pythoncode)
+swig_pythoncode_bad2.i:13: Error: Line indented less than expected (line 3 of %pythoncode or %insert("python") block) as no line should be indented less than the indentation in line 1
diff --git a/Examples/test-suite/errors/swig_pythoncode_bad3.i b/Examples/test-suite/errors/swig_pythoncode_bad3.i
new file mode 100644
index 000000000..5759158d9
--- /dev/null
+++ b/Examples/test-suite/errors/swig_pythoncode_bad3.i
@@ -0,0 +1,7 @@
+%module xxx
+
+%pythoncode %{
+ def extra():
+ print "extra a" # indentation is 2 spaces then tab
+ print "extra b" # indentation is tab then 2 spaces
+%}
diff --git a/Examples/test-suite/errors/swig_pythoncode_bad3.stderr b/Examples/test-suite/errors/swig_pythoncode_bad3.stderr
new file mode 100644
index 000000000..2de4e7d05
--- /dev/null
+++ b/Examples/test-suite/errors/swig_pythoncode_bad3.stderr
@@ -0,0 +1 @@
+swig_pythoncode_bad3.i:7: Warning 740: Whitespace indentation is inconsistent compared to earlier lines (line 3 of %pythoncode or %insert("python") block)
diff --git a/Examples/test-suite/go/default_constructor_runme.go b/Examples/test-suite/go/default_constructor_runme.go
index e5e325475..40a5a6e49 100644
--- a/Examples/test-suite/go/default_constructor_runme.go
+++ b/Examples/test-suite/go/default_constructor_runme.go
@@ -21,9 +21,6 @@ func main() {
f := dc.NewF()
f.Destroy()
- ff := dc.NewFFF()
- ff.Destroy()
-
g := dc.NewG()
dc.GDestroy(g)
diff --git a/Examples/test-suite/guile/li_std_string_runme.scm b/Examples/test-suite/guile/li_std_string_runme.scm
index 83fc2b5e7..fcf2f58d2 100644
--- a/Examples/test-suite/guile/li_std_string_runme.scm
+++ b/Examples/test-suite/guile/li_std_string_runme.scm
@@ -25,7 +25,7 @@
(if (not (try-set-locale "C.UTF-8")) ; Linux
(if (not (try-set-locale "en_US.utf8")) ; Linux
-(if (not (try-set-locale "en_US.UTF-8")) ; Mac OSX
+(if (not (try-set-locale "en_US.UTF-8")) ; Mac OS X
(error "Failed to set any UTF-8 locale")
)))
diff --git a/Examples/test-suite/inherit_member.i b/Examples/test-suite/inherit_member.i
index 9cfba0bb8..c26da6151 100644
--- a/Examples/test-suite/inherit_member.i
+++ b/Examples/test-suite/inherit_member.i
@@ -6,11 +6,11 @@
%inline %{
-struct parent {
+struct parent_class {
std::string pvar;
};
- struct child : public parent {
+ struct child : public parent_class {
std::string cvar;
};
diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in
index 310f1a773..3dc6555ef 100644
--- a/Examples/test-suite/java/Makefile.in
+++ b/Examples/test-suite/java/Makefile.in
@@ -27,6 +27,7 @@ CPP_TEST_CASES = \
java_director_assumeoverride \
java_director_exception_feature \
java_director_exception_feature_nspace \
+ java_director_ptrclass \
java_enums \
java_jnitypes \
java_lib_arrays_dimensionless \
diff --git a/Examples/test-suite/java/cpp11_constexpr_runme.java b/Examples/test-suite/java/cpp11_constexpr_runme.java
index c774e82f8..de1ae8cc3 100644
--- a/Examples/test-suite/java/cpp11_constexpr_runme.java
+++ b/Examples/test-suite/java/cpp11_constexpr_runme.java
@@ -23,7 +23,7 @@ public class cpp11_constexpr_runme {
check(cpp11_constexpr.CCC(), 30);
check(cpp11_constexpr.DDD(), 40);
- ConstExpressions ce = new ConstExpressions();
+ ConstExpressions ce = new ConstExpressions(0);
check(ce.JJJ, 100);
check(ce.KKK, 200);
check(ce.LLL, 300);
diff --git a/Examples/test-suite/java/default_constructor_runme.java b/Examples/test-suite/java/default_constructor_runme.java
index 6473c4099..eb6a2df53 100644
--- a/Examples/test-suite/java/default_constructor_runme.java
+++ b/Examples/test-suite/java/default_constructor_runme.java
@@ -20,13 +20,5 @@ public class default_constructor_runme {
throw new RuntimeException("Protected destructor exception should have been thrown");
} catch (UnsupportedOperationException e) {
}
-
- // calling private destructor test
- try {
- FFF f = new FFF();
- f.delete();
- throw new RuntimeException("Private destructor exception should have been thrown");
- } catch (UnsupportedOperationException e) {
- }
}
}
diff --git a/Examples/test-suite/java/java_director_ptrclass_runme.java b/Examples/test-suite/java/java_director_ptrclass_runme.java
new file mode 100644
index 000000000..2d78a8f2e
--- /dev/null
+++ b/Examples/test-suite/java/java_director_ptrclass_runme.java
@@ -0,0 +1,47 @@
+
+import java_director_ptrclass.*;
+
+public class java_director_ptrclass_runme {
+
+ static {
+ try {
+ System.loadLibrary("java_director_ptrclass");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+ Foo f = new Foo();
+ Foo ft = new TouchingFoo();
+ Baz b = new Baz();
+ if (b.GetTouched()) {
+ throw new RuntimeException ( "Baz should not have been touched yet." );
+ }
+
+ Baz b2 = f.FinalMaybeTouch(b);
+
+ if (b2.GetTouched() || b.GetTouched()) {
+ throw new RuntimeException ( "Baz should not have been touched by Foo." );
+ }
+
+ Baz b3 = ft.FinalMaybeTouch(b);
+
+ if (!b.GetTouched() || !b3.GetTouched() || !b2.GetTouched()) {
+ throw new RuntimeException ( "Baz was not touched by TouchingFoo. This" +
+ " might mean the directorin typemap is not" +
+ " parsing the typemap(jstype, Bar) in its" +
+ " 'descriptor' kwarg correctly." );
+ }
+ }
+}
+
+class TouchingFoo extends Foo {
+ @Override
+ public Baz MaybeTouch(Baz baz_ptr) {
+ baz_ptr.SetTouched();
+ return baz_ptr;
+ }
+}
+
diff --git a/Examples/test-suite/java_director_ptrclass.i b/Examples/test-suite/java_director_ptrclass.i
new file mode 100644
index 000000000..6b4fc1f08
--- /dev/null
+++ b/Examples/test-suite/java_director_ptrclass.i
@@ -0,0 +1,107 @@
+%module(directors="1") java_director_ptrclass
+
+// Tests that custom director typemaps can be used with C++ types that
+// represent a pointer, in such a way that Java perceives this class as
+// equivalent to the underlying type. In particular, this verifies that
+// a typemap lookup within a typemap kwarg, in this case
+// directorin:descriptor, works as expected.
+
+%{
+namespace bar {
+class Baz {
+public:
+ Baz() : touched(false) {}
+ void SetTouched() { touched = true; }
+ bool GetTouched() { return touched; }
+private:
+ bool touched;
+};
+
+template <typename T>
+class Ptr {
+public:
+ Ptr(T* b) : b_(b) {}
+ T* Get() const { return b_; }
+private:
+ T* b_;
+};
+
+class Foo {
+public:
+ // Calling FinalMaybeTouch from Java unambiguously goes through C++ to
+ // reach MaybeTouch.
+ Ptr< bar::Baz > FinalMaybeTouch(Baz* b) {
+ return MaybeTouch(Ptr< bar::Baz >(b));
+ }
+ virtual Ptr< bar::Baz > MaybeTouch(Ptr< bar::Baz > f) {
+ return f; /* Don't touch */
+ }
+ virtual ~Foo() {}
+};
+}
+%}
+
+%feature("director") Foo;
+
+%typemap(jni) bar::Ptr< bar::Baz > "jlong"
+%typemap(jtype) bar::Ptr< bar::Baz > "long"
+%typemap(jstype) bar::Ptr< bar::Baz > "Baz"
+%typemap(in) bar::Ptr< bar::Baz > {
+ $1 = bar::Ptr< bar::Baz >(*( bar::Baz**)&$input);
+}
+%typemap(out) bar::Ptr< bar::Baz > {
+ const bar::Ptr< bar::Baz >& ptr = $1;
+ if (ptr.Get()) {
+ $result = ($typemap(jni, bar::Baz))ptr.Get();
+ } else {
+ $result = 0;
+ }
+}
+%typemap(javain) bar::Ptr< bar::Baz > "$typemap(jstype, bar::Baz).getCPtr($javainput)"
+%typemap(javaout) bar::Ptr< bar::Baz > {
+ long cPtr = $jnicall;
+ return (cPtr == 0) ? null : new $typemap(jstype, bar::Baz)(cPtr, false);
+}
+%typemap(directorin, descriptor="L$packagepath/$typemap(jstype, bar::Baz);") bar::Ptr< bar::Baz >
+%{ *((bar::Baz**)&$input) = ((bar::Ptr< bar::Baz >&)$1).Get(); %}
+%typemap(directorout) bar::Ptr< bar::Baz > {
+ $result = bar::Ptr< bar::Baz >(*( bar::Baz**)&$input);
+}
+%typemap(javadirectorin) bar::Ptr< bar::Baz > %{
+ ((long)$jniinput == 0) ? null : new $typemap(jstype, bar::Baz)($jniinput, false)
+%}
+%typemap(javadirectorout) bar::Ptr< bar::Baz > "$typemap(jstype, bar::Baz).getCPtr($javacall)"
+
+namespace bar {
+class Baz {
+public:
+ Baz() : touched(false) {}
+ void SetTouched() { touched = true; }
+ bool GetTouched() { return touched; }
+private:
+ bool touched;
+};
+
+template <typename T>
+class Ptr {
+public:
+ Ptr(T* b) : b_(b) {}
+ T* Get() { return b_; }
+private:
+ T* b_;
+};
+
+class Foo {
+public:
+ // Calling FinalMaybeTouch from Java unambiguously goes through C++ to
+ // reach MaybeTouch.
+ Ptr< bar::Baz > FinalMaybeTouch(Baz* b) {
+ return MaybeTouch(Ptr< bar::Baz >(b));
+ }
+ virtual Ptr< bar::Baz > MaybeTouch(Ptr< bar::Baz > f) {
+ return f; /* Don't touch */
+ }
+ virtual ~Foo() {}
+};
+}
+
diff --git a/Examples/test-suite/java_typemaps_proxy.i b/Examples/test-suite/java_typemaps_proxy.i
index e315a36b5..3e9b18335 100644
--- a/Examples/test-suite/java_typemaps_proxy.i
+++ b/Examples/test-suite/java_typemaps_proxy.i
@@ -31,8 +31,8 @@ import java.lang.*; // for Exception
// Create a new getCPtr() function which takes Java null and is public
%typemap(javabody) NS::Greeting %{
- private long swigCPtr;
- protected boolean swigCMemOwn;
+ private transient long swigCPtr;
+ protected transient boolean swigCMemOwn;
protected $javaclassname(long cPtr, boolean cMemoryOwn) {
swigCMemOwn = cMemoryOwn;
@@ -46,8 +46,8 @@ import java.lang.*; // for Exception
// Make the pointer constructor public
%typemap(javabody) NS::Farewell %{
- private long swigCPtr;
- protected boolean swigCMemOwn;
+ private transient long swigCPtr;
+ protected transient boolean swigCMemOwn;
public $javaclassname(long cPtr, boolean cMemoryOwn) {
swigCMemOwn = cMemoryOwn;
diff --git a/Examples/test-suite/java_typemaps_typewrapper.i b/Examples/test-suite/java_typemaps_typewrapper.i
index a99ca7b65..b7bf847ef 100644
--- a/Examples/test-suite/java_typemaps_typewrapper.i
+++ b/Examples/test-suite/java_typemaps_typewrapper.i
@@ -39,7 +39,7 @@ import java.lang.*; // for Exception
// Create a new getCPtr() function which takes Java null and is public
// Make the pointer constructor public
%typemap(javabody) Farewell * %{
- private long swigCPtr;
+ private transient long swigCPtr;
public $javaclassname(long cPtr, boolean bFutureUse) {
swigCPtr = cPtr;
diff --git a/Examples/test-suite/octave/default_constructor_runme.m b/Examples/test-suite/octave/default_constructor_runme.m
index 41d0f3f1e..ebe553b20 100644
--- a/Examples/test-suite/octave/default_constructor_runme.m
+++ b/Examples/test-suite/octave/default_constructor_runme.m
@@ -14,24 +14,18 @@ try
catch
end_try_catch
-del_b = dc.delete_B;
-
try
bb = dc.new_BB();
error("Whoa. new_BB created.")
catch
end_try_catch
-del_bb = dc.delete_BB;
-
try
c = dc.new_C();
error("Whoa. new_C created.")
catch
end_try_catch
-del_c = dc.delete_C;
-
cc = dc.new_CC();
dc.delete_CC(cc);
@@ -41,24 +35,18 @@ try
catch
end_try_catch
-del_d = dc.delete_D;
-
try
dd = dc.new_DD();
error("Whoa. new_DD created")
catch
end_try_catch
-dd = dc.delete_DD;
-
try
ad = dc.new_AD();
error("Whoa. new_AD created")
catch
end_try_catch
-del_ad = dc.delete_AD;
-
e = dc.new_E();
dc.delete_E(e);
@@ -71,31 +59,20 @@ try
catch
end_try_catch
-del_eb = dc.delete_EB;
-
f = dc.new_F();
try
- del_f = dc.delete_F;
+ del_f = dc.delete_F(f);
error("Whoa. delete_F created")
catch
end_try_catch
dc.F_destroy(f);
-ff = dc.new_FFF();
-try
- del_ff = dc.delete_FFF;
- error("Whoa. delete_FFF created")
-catch
-end_try_catch
-
-dc.F_destroy(ff);
-
g = dc.new_G();
try
- del_g = dc.delete_G;
+ del_g = dc.delete_G(g);
error("Whoa. delete_G created")
catch
end_try_catch
diff --git a/Examples/test-suite/php/Makefile.in b/Examples/test-suite/php/Makefile.in
index c3f8af5cb..c365d01c3 100644
--- a/Examples/test-suite/php/Makefile.in
+++ b/Examples/test-suite/php/Makefile.in
@@ -10,6 +10,7 @@ top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
CPP_TEST_CASES += \
+ callback \
php_iterator \
php_namewarn_rename \
diff --git a/Examples/test-suite/php/autodoc_runme.php b/Examples/test-suite/php/autodoc_runme.php
deleted file mode 100644
index f2e19d3cb..000000000
--- a/Examples/test-suite/php/autodoc_runme.php
+++ /dev/null
@@ -1,9 +0,0 @@
-<?php
-
-require "tests.php";
-require "autodoc.php";
-// In 2.0.6 and earlier, the constant was misnamed.
-if (gettype(autodoc::FUNC_CB_CALLBACK) !== 'resource') die("autodoc::FUNC_CB_CALLBACK not a resource\n");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php/callback_runme.php b/Examples/test-suite/php/callback_runme.php
new file mode 100644
index 000000000..392d5e598
--- /dev/null
+++ b/Examples/test-suite/php/callback_runme.php
@@ -0,0 +1,9 @@
+<?php
+
+require "tests.php";
+require "callback.php";
+// In 2.0.6 and earlier, the constant was misnamed.
+if (gettype(callback::FOO_I_Cb_Ptr) !== 'resource') die("callback::foo_T<int> not a resource\n");
+
+check::done();
+?>
diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in
index a99c30439..59c8eed9e 100644
--- a/Examples/test-suite/python/Makefile.in
+++ b/Examples/test-suite/python/Makefile.in
@@ -59,6 +59,7 @@ CPP_TEST_CASES += \
python_abstractbase \
python_append \
python_director \
+ python_docstring \
python_nondynamic \
python_overload_simple_cast \
python_pythoncode \
diff --git a/Examples/test-suite/python/default_constructor_runme.py b/Examples/test-suite/python/default_constructor_runme.py
index c80c1e81e..1e877adda 100644
--- a/Examples/test-suite/python/default_constructor_runme.py
+++ b/Examples/test-suite/python/default_constructor_runme.py
@@ -89,15 +89,6 @@ except AttributeError:
dc.F_destroy(f)
-ff = dc.new_FFF()
-try:
- del_ff = dc.delete_FFF
- print "Whoa. delete_FFF created"
-except AttributeError:
- pass
-
-dc.F_destroy(ff)
-
g = dc.new_G()
try:
diff --git a/Examples/test-suite/python/python_docstring_runme.py b/Examples/test-suite/python/python_docstring_runme.py
new file mode 100644
index 000000000..0284ea0de
--- /dev/null
+++ b/Examples/test-suite/python/python_docstring_runme.py
@@ -0,0 +1,100 @@
+from python_docstring import *
+import inspect
+
+def check(got, expected):
+ expected_list = expected.split("\n")
+ got_list = got.split("\n")
+
+ if expected_list != got_list:
+ raise RuntimeError("\n" + "Expected: " + str(expected_list) + "\n" + "Got : " + str(got_list))
+
+# When getting docstrings, use inspect.getdoc(x) instead of x.__doc__ otherwise the different options
+# such as -O, -builtin, -classic produce different initial indentation.
+
+check(inspect.getdoc(DocStrings.docstring1),
+ " line 1\n"
+ "line 2\n"
+ "\n"
+ "\n"
+ "\n"
+ "line 3"
+ )
+
+check(inspect.getdoc(DocStrings.docstring2),
+ "line 1\n"
+ " line 2\n"
+ "\n"
+ "\n"
+ "\n"
+ " line 3"
+ )
+
+check(inspect.getdoc(DocStrings.docstring3),
+ "line 1\n"
+ " line 2\n"
+ "\n"
+ "\n"
+ "\n"
+ " line 3"
+ )
+
+check(inspect.getdoc(DocStrings.docstring4),
+ "line 1\n"
+ " line 2\n"
+ "\n"
+ "\n"
+ "\n"
+ " line 3"
+ )
+
+check(inspect.getdoc(DocStrings.docstring5),
+ "line 1\n"
+ " line 2\n"
+ "\n"
+ "\n"
+ "\n"
+ " line 3"
+ )
+
+check(inspect.getdoc(DocStrings.docstring6),
+ "line 1\n"
+ " line 2\n"
+ "\n"
+ "\n"
+ "\n"
+ " line 3"
+ )
+
+check(inspect.getdoc(DocStrings.docstring7),
+ "line 1\n"
+ "line 2\n"
+ "line 3"
+ )
+
+check(inspect.getdoc(DocStrings.docstringA),
+ "first line\n"
+ "second line"
+ )
+
+check(inspect.getdoc(DocStrings.docstringB),
+ "first line\n"
+ "second line"
+ )
+
+check(inspect.getdoc(DocStrings.docstringC),
+ "first line\n"
+ "second line"
+ )
+
+# One line doc special case, use __doc__
+check(DocStrings.docstringX.__doc__,
+ " one line docs"
+ )
+
+check(inspect.getdoc(DocStrings.docstringX),
+ "one line docs"
+ )
+
+check(inspect.getdoc(DocStrings.docstringY),
+ "one line docs"
+ )
diff --git a/Examples/test-suite/python_docstring.i b/Examples/test-suite/python_docstring.i
new file mode 100644
index 000000000..3b88167eb
--- /dev/null
+++ b/Examples/test-suite/python_docstring.i
@@ -0,0 +1,98 @@
+%module python_docstring
+
+// Test indentation when using the docstring feature.
+// Checks tabs and spaces as input for indentation.
+
+%feature("docstring") docstring1 %{
+ line 1
+line 2
+
+
+
+line 3
+%}
+
+%feature("docstring") docstring2 %{
+line 1
+ line 2
+
+
+
+ line 3
+ %}
+
+%feature("docstring") docstring3 %{
+ line 1
+ line 2
+
+
+
+ line 3
+ %}
+
+%feature("docstring") docstring4 %{
+ line 1
+ line 2
+
+
+
+ line 3
+ %}
+
+%feature("docstring") docstring5
+%{ line 1
+ line 2
+
+
+
+ line 3
+ %}
+
+%feature("docstring") docstring6
+{
+ line 1
+ line 2
+
+
+
+ line 3
+}
+
+%feature("docstring") docstring7
+{
+line 1
+line 2
+line 3
+}
+
+%feature("docstring") docstringA
+%{ first line
+ second line%}
+
+%feature("docstring") docstringB
+%{ first line
+ second line%}
+
+%feature("docstring") docstringC
+%{ first line
+ second line%}
+
+%feature("docstring") docstringX " one line docs"
+%feature("docstring") docstringY "one line docs"
+
+%inline %{
+struct DocStrings {
+ void docstring1() {}
+ void docstring2() {}
+ void docstring3() {}
+ void docstring4() {}
+ void docstring5() {}
+ void docstring6() {}
+ void docstring7() {}
+ void docstringA() {}
+ void docstringB() {}
+ void docstringC() {}
+ void docstringX() {}
+ void docstringY() {}
+};
+%}
diff --git a/Examples/test-suite/ruby/default_constructor_runme.rb b/Examples/test-suite/ruby/default_constructor_runme.rb
index 2706f67ca..5cd675879 100644
--- a/Examples/test-suite/ruby/default_constructor_runme.rb
+++ b/Examples/test-suite/ruby/default_constructor_runme.rb
@@ -144,9 +144,6 @@ end
f = F.new
# This should work fine
-ff = FFF.new
-
-# This should work fine
g = G.new
# This should work fine
diff --git a/Examples/test-suite/scilab/default_constructor_runme.sci b/Examples/test-suite/scilab/default_constructor_runme.sci
index 6c5250bec..26726f1e0 100644
--- a/Examples/test-suite/scilab/default_constructor_runme.sci
+++ b/Examples/test-suite/scilab/default_constructor_runme.sci
@@ -84,15 +84,6 @@ end
F_destroy(f);
-ff = new_FFF();
-try
- del_ff = delete_FFF;
- swigtesterror("delete_FFF created")
-catch
-end
-
-F_destroy(ff);
-
g = new_G();
try
diff --git a/Examples/test-suite/special_variable_attributes.i b/Examples/test-suite/special_variable_attributes.i
new file mode 100644
index 000000000..973a09344
--- /dev/null
+++ b/Examples/test-suite/special_variable_attributes.i
@@ -0,0 +1,170 @@
+%module special_variable_attributes
+
+// Special variable expansion and special variable macros, aka embedded typemaps - expansion tests
+// Tests these are expanded within typemap attributes.
+// Also tests that these are expanded when used together, so that the special variables
+// can be used as the type passed to the special variable macro.
+// C# is used for testing as it is one of the few languages that uses a lot of typemap attributes.
+// Attributes in both 'in' and 'out' typemaps are needed, that is,
+// typemaps targeting both parameters and return values respectively).
+
+#ifdef SWIGCSHARP
+// Check special variable expansion in typemap attributes.
+// This changes return by reference into return by value.
+// Takes advantage of the fact that 'int' is a valid type in both C and C#.
+// This is not a realistic use, just a way to test the variable expansion in the 'out' attribute.
+%typemap(ctype, out="$*1_ltype") int& getNumber1 "_not_used_"
+%typemap(imtype, out="$*1_ltype") int& getNumber1 "_not_used_"
+%typemap(cstype, out="$*1_ltype") int& getNumber1 "_not_used_"
+%typemap(out) int& getNumber1 "$result = *$1;"
+%typemap(csout, excode=SWIGEXCODE) int & getNumber1 {
+ int ret = $imcall;$excode
+ return ret;
+ }
+#endif
+
+%inline %{
+int& getNumber1() {
+ static int num = 111;
+ return num;
+}
+%}
+
+#ifdef SWIGCSHARP
+// Check special variable macro expansion in typemap attributes.
+// This changes return by reference into return by value.
+%typemap(ctype, out="$typemap(ctype, int)") int& getNumber2 "_not_used_"
+%typemap(imtype, out="$typemap(imtype, int)") int& getNumber2 "_not_used_"
+%typemap(cstype, out="$typemap(cstype, int)") int& getNumber2 "_not_used_"
+%typemap(out) int& getNumber2 "$result = *$1;"
+%typemap(csout, excode=SWIGEXCODE) int & getNumber2 {
+ int ret = $imcall;$excode
+ return ret;
+ }
+#endif
+
+%inline %{
+int& getNumber2() {
+ static int num = 222;
+ return num;
+}
+%}
+
+
+#ifdef SWIGCSHARP
+// Check special variable macro expansion and special variable expansion in typemap attributes.
+// This changes return by reference into return by value.
+%typemap(ctype, out="$typemap(ctype, $*1_ltype)") int& getNumber3 "_not_used_"
+%typemap(imtype, out="$typemap(imtype, $*1_ltype)") int& getNumber3 "_not_used_"
+%typemap(cstype, out="$typemap(cstype, $*1_ltype)") int& getNumber3 "_not_used_"
+%typemap(out) int& getNumber3 "$result = *$1;"
+%typemap(csout, excode=SWIGEXCODE) int & getNumber3 {
+ int ret = $imcall;$excode
+ return ret;
+ }
+#endif
+
+%inline %{
+int& getNumber3() {
+ static int num = 333;
+ return num;
+}
+%}
+
+#ifdef SWIGCSHARP
+// Check special variable macro expansion in typemap attributes.
+%typemap(csin,
+ pre=" $typemap(cstype, int) $csinput_scaled = 11;"
+ ) int num1
+%{$csinput * $csinput_scaled %}
+#endif
+
+%inline %{
+int bounceNumber1(int num1) {
+ return num1;
+}
+%}
+
+#ifdef SWIGCSHARP
+// Check special variable expansion in typemap attributes.
+%typemap(csin,
+ pre=" $1_type $csinput_scaled = 22;"
+ ) int num2
+%{$csinput * $csinput_scaled %}
+#endif
+
+%inline %{
+int bounceNumber2(int num2) {
+ return num2;
+}
+%}
+
+#ifdef SWIGCSHARP
+// Check special variable and special variable macro expansion in typemap attributes.
+%typemap(csin,
+ pre=" $typemap(cstype, $1_type) $csinput_scaled = 33;"
+ ) int num3
+%{$csinput * $csinput_scaled %}
+#endif
+
+%inline %{
+int bounceNumber3(int num3) {
+ return num3;
+}
+%}
+
+/////////////////////////////////
+//// Multi-argument typemaps ////
+/////////////////////////////////
+
+// Test expansion of special variables
+#ifdef SWIGCSHARP
+%typemap(ctype) (int intvar, char charvar) "double"
+%typemap(imtype) (int intvar, char charvar) "double"
+%typemap(cstype) (int intvar, char charvar) "double"
+%typemap(in) (int intvar, char charvar)
+%{
+ // split double value a.b into two numbers, a and b*100
+ $1 = (int)$input;
+ $2 = (char)(($input - $1 + 0.005) * 100);
+%}
+%typemap(csin,
+ pre=" $1_type $csinput_$1_type = 50;\n" // $1_type should expand to int
+ " $2_type $csinput_$2_type = 'A';" // $2_type should expand to char
+ ) (int intvar, char charvar)
+%{$csinput + ($csinput_int - 50 + $csinput_char - 'A') + ($csinput_$1_type - 50 + $csinput_$2_type - 'A')%}
+#endif
+
+%inline %{
+int multi1(int intvar, char charvar) {
+ return intvar + charvar;
+}
+%}
+
+#ifdef SWIGCSHARP
+%typemap(csin,
+ pre=" $typemap(cstype, int) $csinput_$typemap(cstype, int) = 50;\n" // also should expand to int
+ " $typemap(cstype, char) $csinput_$typemap(cstype, char) = 'A';" // also should expand to char
+ ) (int intvar, char charvar)
+%{55 + $csinput + ($csinput_int - 50 + $csinput_char - 'A') + ($csinput_$typemap(cstype, int) - 50 + $csinput_$typemap(cstype, char) - 'A')%}
+#endif
+
+%inline %{
+int multi2(int intvar, char charvar) {
+ return intvar + charvar;
+}
+%}
+
+#ifdef SWIGCSHARP
+%typemap(csin,
+ pre=" $typemap(cstype, $1_type) $csinput_$typemap(cstype, $1_type) = 50;\n" // also should expand to int
+ " $typemap(cstype, $2_type) $csinput_$typemap(cstype, $2_type) = 'A';" // also should expand to char
+ ) (int intvar, char charvar)
+%{77 + $csinput + ($csinput_int - 50 + $csinput_char - 'A') + ($csinput_$typemap(cstype, $1_type) - 50 + $csinput_$typemap(cstype, $2_type) - 'A')%}
+#endif
+
+%inline %{
+int multi3(int intvar, char charvar) {
+ return intvar + charvar;
+}
+%}
diff --git a/Examples/test-suite/template_keyword_in_type.i b/Examples/test-suite/template_keyword_in_type.i
index 27765c648..b54b8ad4a 100644
--- a/Examples/test-suite/template_keyword_in_type.i
+++ b/Examples/test-suite/template_keyword_in_type.i
@@ -33,6 +33,10 @@ namespace Alloc {
}
template<typename X> void other1(typename Alloc::template rebind<ListBucket<Val> >::other) {}
+#if !defined(__SUNPRO_CC)
template<typename X> void other2(typename Alloc::template rebind< ::template ListBucket<Val> >::other) {}
+#else
+template<typename X> void other2(typename Alloc::template rebind< :: ListBucket<Val> >::other) {}
+#endif
template<typename X> void other3(Alloc::template rebind<int>) {}
%}
diff --git a/Lib/carrays.i b/Lib/carrays.i
index 201c17cac..3a9c3cfee 100644
--- a/Lib/carrays.i
+++ b/Lib/carrays.i
@@ -81,7 +81,7 @@ typedef struct {
#ifdef __cplusplus
NAME(int nelements) {
- return new TYPE[nelements];
+ return new TYPE[nelements]();
}
~NAME() {
delete [] self;
diff --git a/Lib/d/carrays.i b/Lib/d/carrays.i
index 37b59c871..f2803ea46 100644
--- a/Lib/d/carrays.i
+++ b/Lib/d/carrays.i
@@ -21,7 +21,7 @@
%{
static TYPE *new_##NAME(int nelements) { %}
#ifdef __cplusplus
-%{ return new TYPE[nelements]; %}
+%{ return new TYPE[nelements](); %}
#else
%{ return (TYPE *) calloc(nelements,sizeof(TYPE)); %}
#endif
@@ -78,7 +78,7 @@ typedef struct {} NAME;
%extend NAME {
#ifdef __cplusplus
NAME(int nelements) {
- return new TYPE[nelements];
+ return new TYPE[nelements]();
}
~NAME() {
delete [] self;
diff --git a/Lib/java/arrays_java.i b/Lib/java/arrays_java.i
index 4b780aef9..402f088d5 100644
--- a/Lib/java/arrays_java.i
+++ b/Lib/java/arrays_java.i
@@ -52,7 +52,7 @@ static int SWIG_JavaArrayIn##JFUNCNAME (JNIEnv *jenv, JNITYPE **jarr, CTYPE **ca
#ifdef __cplusplus
%{ *carr = new CTYPE[sz]; %}
#else
-%{ *carr = (CTYPE*) calloc(sz, sizeof(CTYPE)); %}
+%{ *carr = (CTYPE*) malloc(sz * sizeof(CTYPE)); %}
#endif
%{ if (!*carr) {
SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed");
@@ -259,7 +259,7 @@ JAVA_ARRAYS_TYPEMAPS(double, double, jdouble, Double, "[D") /* double[ANY] *
#ifdef __cplusplus
$1 = new $*1_ltype[sz];
#else
- $1 = ($1_ltype) calloc(sz, sizeof($*1_ltype));
+ $1 = ($1_ltype) malloc(sz * sizeof($*1_ltype));
#endif
if (!$1) {
SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed");
@@ -289,7 +289,7 @@ JAVA_ARRAYS_TYPEMAPS(double, double, jdouble, Double, "[D") /* double[ANY] *
#ifdef __cplusplus
$1 = new $*1_ltype[sz];
#else
- $1 = ($1_ltype) calloc(sz, sizeof($*1_ltype));
+ $1 = ($1_ltype) malloc(sz * sizeof($*1_ltype));
#endif
if (!$1) {
SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed");
diff --git a/Lib/java/boost_intrusive_ptr.i b/Lib/java/boost_intrusive_ptr.i
index f9525894f..1d8fa7445 100644
--- a/Lib/java/boost_intrusive_ptr.i
+++ b/Lib/java/boost_intrusive_ptr.i
@@ -263,7 +263,7 @@
// Base proxy classes
%typemap(javabody) TYPE %{
- private long swigCPtr;
+ private transient long swigCPtr;
private boolean swigCMemOwnBase;
PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
@@ -278,7 +278,7 @@
// Derived proxy classes
%typemap(javabody_derived) TYPE %{
- private long swigCPtr;
+ private transient long swigCPtr;
private boolean swigCMemOwnDerived;
PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
@@ -413,7 +413,7 @@
// Base proxy classes
%typemap(javabody) TYPE %{
- private long swigCPtr;
+ private transient long swigCPtr;
private boolean swigCMemOwnBase;
PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
@@ -428,7 +428,7 @@
// Derived proxy classes
%typemap(javabody_derived) TYPE %{
- private long swigCPtr;
+ private transient long swigCPtr;
private boolean swigCMemOwnDerived;
PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
diff --git a/Lib/java/boost_shared_ptr.i b/Lib/java/boost_shared_ptr.i
index e75236993..136570da5 100644
--- a/Lib/java/boost_shared_ptr.i
+++ b/Lib/java/boost_shared_ptr.i
@@ -145,8 +145,8 @@
// Base proxy classes
%typemap(javabody) TYPE %{
- private long swigCPtr;
- private boolean swigCMemOwn;
+ private transient long swigCPtr;
+ private transient boolean swigCMemOwn;
PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
swigCMemOwn = cMemoryOwn;
@@ -160,7 +160,7 @@
// Derived proxy classes
%typemap(javabody_derived) TYPE %{
- private long swigCPtr;
+ private transient long swigCPtr;
private boolean swigCMemOwnDerived;
PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
diff --git a/Lib/java/java.swg b/Lib/java/java.swg
index 22a4884ef..2e106796c 100644
--- a/Lib/java/java.swg
+++ b/Lib/java/java.swg
@@ -1148,8 +1148,8 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
%define SWIG_JAVABODY_PROXY(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...)
// Base proxy classes
%typemap(javabody) TYPE %{
- private long swigCPtr;
- protected boolean swigCMemOwn;
+ private transient long swigCPtr;
+ protected transient boolean swigCMemOwn;
PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
swigCMemOwn = cMemoryOwn;
@@ -1163,7 +1163,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
// Derived proxy classes
%typemap(javabody_derived) TYPE %{
- private long swigCPtr;
+ private transient long swigCPtr;
PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
super($imclassname.$javaclazznameSWIGUpcast(cPtr), cMemoryOwn);
@@ -1179,7 +1179,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
%define SWIG_JAVABODY_TYPEWRAPPER(PTRCTOR_VISIBILITY, DEFAULTCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...)
// Typewrapper classes
%typemap(javabody) TYPE *, TYPE &, TYPE &&, TYPE [] %{
- private long swigCPtr;
+ private transient long swigCPtr;
PTRCTOR_VISIBILITY $javaclassname(long cPtr, @SuppressWarnings("unused") boolean futureUse) {
swigCPtr = cPtr;
diff --git a/Lib/java/various.i b/Lib/java/various.i
index e8042b763..76fb2b129 100644
--- a/Lib/java/various.i
+++ b/Lib/java/various.i
@@ -29,7 +29,7 @@
#ifdef __cplusplus
$1 = new char*[size+1];
#else
- $1 = (char **)calloc(size+1, sizeof(char *));
+ $1 = (char **)malloc((size+1) * sizeof(char *));
#endif
for (i = 0; i<size; i++) {
jstring j_string = (jstring)JCALL2(GetObjectArrayElement, jenv, $input, i);
@@ -37,7 +37,7 @@
#ifdef __cplusplus
$1[i] = new char [strlen(c_string)+1];
#else
- $1[i] = (char *)calloc(strlen(c_string)+1, sizeof(const char *));
+ $1[i] = (char *)malloc((strlen(c_string)+1) * sizeof(const char *));
#endif
strcpy($1[i], c_string);
JCALL2(ReleaseStringUTFChars, jenv, j_string, c_string);
diff --git a/Lib/javascript/v8/javascriptrun.swg b/Lib/javascript/v8/javascriptrun.swg
index b37059cca..dc4d37a48 100644
--- a/Lib/javascript/v8/javascriptrun.swg
+++ b/Lib/javascript/v8/javascriptrun.swg
@@ -101,7 +101,7 @@ typedef v8::PropertyCallbackInfo<v8::Value> SwigV8PropertyCallbackInfo;
#define SWIG_fail goto fail
#define SWIGV8_OVERLOAD false
-static void SWIG_V8_Raise(const char *msg) {
+SWIGINTERN void SWIG_V8_Raise(const char *msg) {
SWIGV8_THROW_EXCEPTION(v8::Exception::Error(SWIGV8_STRING_NEW(msg)));
}
@@ -126,7 +126,7 @@ public:
}
};
// this is used in usually
-static V8ErrorHandler SWIGV8_ErrorHandler;
+SWIGRUNTIME V8ErrorHandler SWIGV8_ErrorHandler;
// instances of this are used in overloaded functions
class OverloadErrorHandler: public V8ErrorHandler {
@@ -198,9 +198,9 @@ public:
#endif
};
-static v8::Persistent<v8::FunctionTemplate> SWIGV8_SWIGTYPE_Proxy_class_templ;
+SWIGRUNTIME v8::Persistent<v8::FunctionTemplate> SWIGV8_SWIGTYPE_Proxy_class_templ;
-static int SWIG_V8_ConvertInstancePtr(v8::Handle<v8::Object> objRef, void **ptr, swig_type_info *info, int flags) {
+SWIGRUNTIME int SWIG_V8_ConvertInstancePtr(v8::Handle<v8::Object> objRef, void **ptr, swig_type_info *info, int flags) {
SWIGV8_HANDLESCOPE();
if(objRef->InternalFieldCount() < 1) return SWIG_ERROR;
@@ -234,22 +234,22 @@ static int SWIG_V8_ConvertInstancePtr(v8::Handle<v8::Object> objRef, void **ptr,
#if (SWIG_V8_VERSION < 0x031710)
-static void SWIGV8_Proxy_DefaultDtor(v8::Persistent< v8::Value > object, void *parameter) {
+SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(v8::Persistent< v8::Value > object, void *parameter) {
SWIGV8_Proxy *proxy = static_cast<SWIGV8_Proxy *>(parameter);
#elif (SWIG_V8_VERSION < 0x031900)
-static void SWIGV8_Proxy_DefaultDtor(v8::Isolate *, v8::Persistent< v8::Value > object, void *parameter) {
+SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(v8::Isolate *, v8::Persistent< v8::Value > object, void *parameter) {
SWIGV8_Proxy *proxy = static_cast<SWIGV8_Proxy *>(parameter);
#elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
-static void SWIGV8_Proxy_DefaultDtor(v8::Isolate *, v8::Persistent< v8::Object > *object, SWIGV8_Proxy *proxy) {
+SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(v8::Isolate *, v8::Persistent< v8::Object > *object, SWIGV8_Proxy *proxy) {
#else
-static void SWIGV8_Proxy_DefaultDtor(const v8::WeakCallbackData<v8::Object, SWIGV8_Proxy> &data) {
+SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(const v8::WeakCallbackData<v8::Object, SWIGV8_Proxy> &data) {
SWIGV8_Proxy *proxy = data.GetParameter();
#endif
delete proxy;
}
-static int SWIG_V8_GetInstancePtr(v8::Handle<v8::Value> valRef, void **ptr) {
+SWIGRUNTIME int SWIG_V8_GetInstancePtr(v8::Handle<v8::Value> valRef, void **ptr) {
if(!valRef->IsObject()) {
return SWIG_TypeError;
}
@@ -273,7 +273,7 @@ static int SWIG_V8_GetInstancePtr(v8::Handle<v8::Value> valRef, void **ptr) {
return SWIG_OK;
}
-static void SWIGV8_SetPrivateData(v8::Handle<v8::Object> obj, void *ptr, swig_type_info *info, int flags) {
+SWIGRUNTIME void SWIGV8_SetPrivateData(v8::Handle<v8::Object> obj, void *ptr, swig_type_info *info, int flags) {
SWIGV8_Proxy *cdata = new SWIGV8_Proxy();
cdata->swigCObject = ptr;
cdata->swigCMemOwn = (flags & SWIG_POINTER_OWN) ? 1 : 0;
@@ -330,7 +330,7 @@ static void SWIGV8_SetPrivateData(v8::Handle<v8::Object> obj, void *ptr, swig_ty
}
-static int SWIG_V8_ConvertPtr(v8::Handle<v8::Value> valRef, void **ptr, swig_type_info *info, int flags) {
+SWIGRUNTIME int SWIG_V8_ConvertPtr(v8::Handle<v8::Value> valRef, void **ptr, swig_type_info *info, int flags) {
SWIGV8_HANDLESCOPE();
/* special case: JavaScript null => C NULL pointer */
@@ -345,7 +345,7 @@ static int SWIG_V8_ConvertPtr(v8::Handle<v8::Value> valRef, void **ptr, swig_typ
return SWIG_V8_ConvertInstancePtr(objRef, ptr, info, flags);
}
-static v8::Handle<v8::Value> SWIG_V8_NewPointerObj(void *ptr, swig_type_info *info, int flags) {
+SWIGRUNTIME v8::Handle<v8::Value> SWIG_V8_NewPointerObj(void *ptr, swig_type_info *info, int flags) {
SWIGV8_HANDLESCOPE_ESC();
v8::Handle<v8::FunctionTemplate> class_templ;
@@ -393,7 +393,7 @@ static v8::Handle<v8::Value> SWIG_V8_NewPointerObj(void *ptr, swig_type_info *in
#define SWIG_GetInstancePtr(obj, ptr) SWIG_V8_GetInstancePtr(obj, ptr)
-static SwigV8ReturnValue _SWIGV8_wrap_equals(const SwigV8Arguments &args) {
+SWIGRUNTIME SwigV8ReturnValue _SWIGV8_wrap_equals(const SwigV8Arguments &args) {
SWIGV8_HANDLESCOPE();
v8::Handle<v8::Value> jsresult;
@@ -423,7 +423,7 @@ fail:
SWIGV8_RETURN(SWIGV8_UNDEFINED());
}
-static SwigV8ReturnValue _wrap_getCPtr(const SwigV8Arguments &args) {
+SWIGRUNTIME SwigV8ReturnValue _wrap_getCPtr(const SwigV8Arguments &args) {
SWIGV8_HANDLESCOPE();
v8::Handle<v8::Value> jsresult;
@@ -512,15 +512,15 @@ int SWIGV8_ConvertPacked(v8::Handle<v8::Value> valRef, void *ptr, size_t sz, swi
}
#if (SWIG_V8_VERSION < 0x031710)
-static void _wrap_SwigV8PackedData_delete(v8::Persistent< v8::Value > object, void *parameter) {
+SWIGRUNTIME void _wrap_SwigV8PackedData_delete(v8::Persistent< v8::Value > object, void *parameter) {
SwigV8PackedData *cdata = static_cast<SwigV8PackedData *>(parameter);
#elif (SWIG_V8_VERSION < 0x031900)
-static void _wrap_SwigV8PackedData_delete(v8::Isolate *isolate, v8::Persistent<v8::Value> object, void *parameter) {
+SWIGRUNTIME void _wrap_SwigV8PackedData_delete(v8::Isolate *isolate, v8::Persistent<v8::Value> object, void *parameter) {
SwigV8PackedData *cdata = static_cast<SwigV8PackedData *>(parameter);
#elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
-static void _wrap_SwigV8PackedData_delete(v8::Isolate *isolate, v8::Persistent<v8::Object> *object, SwigV8PackedData *cdata) {
+SWIGRUNTIME void _wrap_SwigV8PackedData_delete(v8::Isolate *isolate, v8::Persistent<v8::Object> *object, SwigV8PackedData *cdata) {
#else
-static void _wrap_SwigV8PackedData_delete(const v8::WeakCallbackData<v8::Object, SwigV8PackedData> &data) {
+SWIGRUNTIME void _wrap_SwigV8PackedData_delete(const v8::WeakCallbackData<v8::Object, SwigV8PackedData> &data) {
v8::Local<v8::Object> object = data.GetValue();
SwigV8PackedData *cdata = data.GetParameter();
#endif
diff --git a/Lib/octave/octcontainer.swg b/Lib/octave/octcontainer.swg
index 723256ca0..0211b33c6 100644
--- a/Lib/octave/octcontainer.swg
+++ b/Lib/octave/octcontainer.swg
@@ -12,6 +12,7 @@
* ----------------------------------------------------------------------------- */
%{
+#include <climits>
#include <iostream>
%}
diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg
index b5c3e5d86..ddfd48939 100644
--- a/Lib/octave/octrun.swg
+++ b/Lib/octave/octrun.swg
@@ -868,6 +868,17 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
}
#if defined (HAVE_HDF5)
+# if SWIG_OCTAVE_PREREQ(4,0,0)
+ virtual bool
+ save_hdf5 (octave_hdf5_id loc_id, const char *name, bool save_as_floats) {
+ return true;
+ }
+
+ virtual bool
+ load_hdf5 (octave_hdf5_id loc_id, const char *name, bool have_h5giterate_bug) {
+ return true;
+ }
+# else
virtual bool
save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats) {
return true;
@@ -877,6 +888,7 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug) {
return true;
}
+# endif
#endif
virtual octave_value convert_to_str(bool pad = false, bool force = false, char type = '"') const {
@@ -969,7 +981,11 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
return octave_value();
}
+#if SWIG_OCTAVE_PREREQ(4,0,0)
+ void print(std::ostream &os, bool pr_as_read_syntax = false) {
+#else
void print(std::ostream &os, bool pr_as_read_syntax = false) const {
+#endif
if (is_string()) {
os << string_value();
return;
@@ -1089,6 +1105,15 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
{ return ptr->load_binary(is, swap, fmt); }
#if defined (HAVE_HDF5)
+# if SWIG_OCTAVE_PREREQ(4,0,0)
+ virtual bool
+ save_hdf5 (octave_hdf5_id loc_id, const char *name, bool save_as_floats)
+ { return ptr->save_hdf5(loc_id, name, save_as_floats); }
+
+ virtual bool
+ load_hdf5 (octave_hdf5_id loc_id, const char *name, bool have_h5giterate_bug)
+ { return ptr->load_hdf5(loc_id, name, have_h5giterate_bug); }
+# else
virtual bool
save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats)
{ return ptr->save_hdf5(loc_id, name, save_as_floats); }
@@ -1096,6 +1121,7 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
virtual bool
load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug)
{ return ptr->load_hdf5(loc_id, name, have_h5giterate_bug); }
+# endif
#endif
virtual octave_value convert_to_str(bool pad = false, bool force = false, char type = '"') const
@@ -1104,14 +1130,22 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
virtual octave_value convert_to_str_internal(bool pad, bool force, char type) const
{ return ptr->convert_to_str_internal(pad, force, type); }
+#if SWIG_OCTAVE_PREREQ(4,0,0)
+ void print(std::ostream &os, bool pr_as_read_syntax = false)
+#else
void print(std::ostream &os, bool pr_as_read_syntax = false) const
+#endif
{ return ptr->print(os, pr_as_read_syntax); }
private:
+#if !SWIG_OCTAVE_PREREQ(4,0,0)
DECLARE_OCTAVE_ALLOCATOR;
+#endif
DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA;
};
+#if !SWIG_OCTAVE_PREREQ(4,0,0)
DEFINE_OCTAVE_ALLOCATOR(octave_swig_ref);
+#endif
DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(octave_swig_ref, "swig_ref", "swig_ref");
class octave_swig_packed:public octave_base_value {
@@ -1143,7 +1177,11 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
return true;
}
+#if SWIG_OCTAVE_PREREQ(4,0,0)
+ void print(std::ostream &os, bool pr_as_read_syntax = false) {
+#else
void print(std::ostream &os, bool pr_as_read_syntax = false) const {
+#endif
indent(os);
os << "swig packed type: name = " << (type ? type->name : std::string()) << ", len = " << buf.size(); newline(os);
}
@@ -1167,6 +1205,17 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
}
#if defined (HAVE_HDF5)
+# if SWIG_OCTAVE_PREREQ(4,0,0)
+ virtual bool
+ save_hdf5 (octave_hdf5_id loc_id, const char *name, bool save_as_floats) {
+ return true;
+ }
+
+ virtual bool
+ load_hdf5 (octave_hdf5_id loc_id, const char *name, bool have_h5giterate_bug) {
+ return true;
+ }
+# else
virtual bool
save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats) {
return true;
@@ -1176,13 +1225,18 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug) {
return true;
}
+# endif
#endif
private:
+#if !SWIG_OCTAVE_PREREQ(4,0,0)
DECLARE_OCTAVE_ALLOCATOR;
+#endif
DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA;
};
+#if !SWIG_OCTAVE_PREREQ(4,0,0)
DEFINE_OCTAVE_ALLOCATOR(octave_swig_packed);
+#endif
DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(octave_swig_packed, "swig_packed", "swig_packed");
SWIGRUNTIME octave_value_list octave_set_immutable(const octave_value_list &args, int nargout) {
diff --git a/Lib/php/php.swg b/Lib/php/php.swg
index 8b5fb7be3..05d25a1df 100644
--- a/Lib/php/php.swg
+++ b/Lib/php/php.swg
@@ -170,7 +170,7 @@
force=0;
if (arg1==NULL) {
#ifdef __cplusplus
- ptr=new $*1_ltype;
+ ptr=new $*1_ltype();
#else
ptr=($*1_ltype) calloc(1,sizeof($*1_ltype));
#endif
diff --git a/Lib/php/typemaps.i b/Lib/php/typemaps.i
index ca49ec327..0372884a6 100644
--- a/Lib/php/typemaps.i
+++ b/Lib/php/typemaps.i
@@ -299,7 +299,7 @@ INT_TYPEMAP(unsigned long long);
force=0;
if (arg1==NULL) {
#ifdef __cplusplus
- ptr=new $*1_ltype;
+ ptr=new $*1_ltype();
#else
ptr=($*1_ltype) calloc(1,sizeof($*1_ltype));
#endif
diff --git a/README b/README
index 5c85e6c3a..a02c56ea9 100644
--- a/README
+++ b/README
@@ -1,6 +1,6 @@
SWIG (Simplified Wrapper and Interface Generator)
-Version: 3.0.6 (in progress)
+Version: 3.0.7 (in progress)
Tagline: SWIG is a compiler that integrates C and C++ with languages
including Perl, Python, Tcl, Ruby, PHP, Java, C#, D, Go, Lua,
diff --git a/RELEASENOTES b/RELEASENOTES
index 6af303bc8..bb1d82bb9 100644
--- a/RELEASENOTES
+++ b/RELEASENOTES
@@ -4,6 +4,11 @@ and CHANGES files.
Release Notes
=============
+SWIG-3.0.6 summary:
+- Stability and regression fixes.
+- Fixed parsing of C++ corner cases.
+- Language improvements and bug fixes for C#, Go, Java, Lua, Python, R.
+
SWIG-3.0.5 summary:
- Added support for Scilab.
- Important Python regression fix when wrapping C++ default arguments.
diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
index a3c5e73bf..1beaaef27 100644
--- a/Source/CParse/parser.y
+++ b/Source/CParse/parser.y
@@ -51,7 +51,7 @@ static String *Classprefix = 0;
static String *Namespaceprefix = 0;
static int inclass = 0;
static Node *currentOuterClass = 0; /* for nested classes */
-static char *last_cpptype = 0;
+static const char *last_cpptype = 0;
static int inherit_list = 0;
static Parm *template_parameters = 0;
static int extendmode = 0;
@@ -463,18 +463,24 @@ static void add_symbols(Node *n) {
SetFlag(n,"feature:ignore");
}
}
- if (only_csymbol || GetFlag(n,"feature:ignore")) {
+ if (only_csymbol || GetFlag(n,"feature:ignore") || strncmp(Char(symname),"$ignore",7) == 0) {
/* Only add to C symbol table and continue */
Swig_symbol_add(0, n);
- } else if (strncmp(Char(symname),"$ignore",7) == 0) {
- char *c = Char(symname)+7;
- SetFlag(n,"feature:ignore");
- if (strlen(c)) {
- SWIG_WARN_NODE_BEGIN(n);
- Swig_warning(0,Getfile(n), Getline(n), "%s\n",c+1);
- SWIG_WARN_NODE_END(n);
+ if (!only_csymbol && !GetFlag(n, "feature:ignore")) {
+ /* Print the warning attached to $ignore name, if any */
+ char *c = Char(symname) + 7;
+ if (strlen(c)) {
+ SWIG_WARN_NODE_BEGIN(n);
+ Swig_warning(0,Getfile(n), Getline(n), "%s\n",c+1);
+ SWIG_WARN_NODE_END(n);
+ }
+ /* If the symbol was ignored via "rename" and is visible, set also feature:ignore*/
+ SetFlag(n, "feature:ignore");
+ }
+ if (!GetFlag(n, "feature:ignore") && Strcmp(symname,"$ignore") == 0) {
+ /* Add feature:ignore if the symbol was explicitely ignored, regardless of visibility */
+ SetFlag(n, "feature:ignore");
}
- Swig_symbol_add(0, n);
} else {
Node *c;
if ((wrn) && (Len(wrn))) {
@@ -703,14 +709,14 @@ static String *make_class_name(String *name) {
/* Use typedef name as class name */
-static void add_typedef_name(Node *n, Node *decl, String *oldName, Symtab *cscope, String *scpname) {
+static void add_typedef_name(Node *n, Node *declnode, String *oldName, Symtab *cscope, String *scpname) {
String *class_rename = 0;
- SwigType *decltype = Getattr(decl, "decl");
- if (!decltype || !Len(decltype)) {
+ SwigType *decl = Getattr(declnode, "decl");
+ if (!decl || !Len(decl)) {
String *cname;
String *tdscopename;
String *class_scope = Swig_symbol_qualifiedscopename(cscope);
- String *name = Getattr(decl, "name");
+ String *name = Getattr(declnode, "name");
cname = Copy(name);
Setattr(n, "tdname", cname);
tdscopename = class_scope ? NewStringf("%s::%s", class_scope, name) : Copy(name);
@@ -721,7 +727,7 @@ static void add_typedef_name(Node *n, Node *decl, String *oldName, Symtab *cscop
if (!Equal(scpname, tdscopename) && !Getattr(classes_typedefs, tdscopename)) {
Setattr(classes_typedefs, tdscopename, n);
}
- Setattr(n, "decl", decltype);
+ Setattr(n, "decl", decl);
Delete(class_scope);
Delete(cname);
Delete(tdscopename);
@@ -1299,7 +1305,7 @@ static void mark_nodes_as_extend(Node *n) {
%}
%union {
- char *id;
+ const char *id;
List *bases;
struct Define {
String *val;
@@ -1442,7 +1448,7 @@ static void mark_nodes_as_extend(Node *n) {
%type <decl> abstract_declarator direct_abstract_declarator ctor_end;
%type <tmap> typemap_type;
%type <str> idcolon idcolontail idcolonnt idcolontailnt idtemplate idtemplatetemplate stringbrace stringbracesemi;
-%type <id> string stringnum wstring;
+%type <str> string stringnum wstring;
%type <tparms> template_parms;
%type <dtype> cpp_end cpp_vend;
%type <intvalue> rename_namewarn;
@@ -1741,7 +1747,7 @@ echo_directive : ECHO HBLOCK {
}
| ECHO string {
char temp[64];
- String *s = NewString($2);
+ String *s = $2;
Replace(s,"$file",cparse_file, DOH_REPLACE_ANY);
sprintf(temp,"%d", cparse_line);
Replace(s,"$line",temp,DOH_REPLACE_ANY);
@@ -1846,7 +1852,7 @@ fragment_directive: FRAGMENT LPAREN fname COMMA kwargs RPAREN HBLOCK {
include_directive: includetype options string BEGINFILE {
$1.filename = Copy(cparse_file);
$1.line = cparse_line;
- scanner_set_location(NewString($3),1);
+ scanner_set_location($3,1);
if ($2) {
String *maininput = Getattr($2, "maininput");
if (maininput)
@@ -2101,7 +2107,7 @@ pragma_directive : PRAGMA pragma_lang identifier EQUAL pragma_arg {
}
;
-pragma_arg : string { $$ = NewString($1); }
+pragma_arg : string { $$ = $1; }
| HBLOCK { $$ = $1; }
;
@@ -2253,7 +2259,7 @@ feature_directive : FEATURE LPAREN idstring RPAREN declarator cpp_const stringbr
scanner_clear_rename();
}
| FEATURE LPAREN idstring COMMA stringnum RPAREN declarator cpp_const SEMI {
- String *val = Len($5) ? NewString($5) : 0;
+ String *val = Len($5) ? $5 : 0;
new_feature($3, val, 0, $7.id, $7.type, $7.parms, $8.qualifier);
$$ = 0;
scanner_clear_rename();
@@ -2265,7 +2271,7 @@ feature_directive : FEATURE LPAREN idstring RPAREN declarator cpp_const stringbr
scanner_clear_rename();
}
| FEATURE LPAREN idstring COMMA stringnum featattr RPAREN declarator cpp_const SEMI {
- String *val = Len($5) ? NewString($5) : 0;
+ String *val = Len($5) ? $5 : 0;
new_feature($3, val, $6, $8.id, $8.type, $8.parms, $9.qualifier);
$$ = 0;
scanner_clear_rename();
@@ -2279,7 +2285,7 @@ feature_directive : FEATURE LPAREN idstring RPAREN declarator cpp_const stringbr
scanner_clear_rename();
}
| FEATURE LPAREN idstring COMMA stringnum RPAREN SEMI {
- String *val = Len($5) ? NewString($5) : 0;
+ String *val = Len($5) ? $5 : 0;
new_feature($3, val, 0, 0, 0, 0, 0);
$$ = 0;
scanner_clear_rename();
@@ -2291,7 +2297,7 @@ feature_directive : FEATURE LPAREN idstring RPAREN declarator cpp_const stringbr
scanner_clear_rename();
}
| FEATURE LPAREN idstring COMMA stringnum featattr RPAREN SEMI {
- String *val = Len($5) ? NewString($5) : 0;
+ String *val = Len($5) ? $5 : 0;
new_feature($3, val, $6, 0, 0, 0, 0);
$$ = 0;
scanner_clear_rename();
@@ -2668,7 +2674,7 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
String *symname = Swig_name_make(templnode,0,$3,0,0);
*/
- String *symname = $3;
+ String *symname = NewString($3);
Swig_cparse_template_expand(templnode,symname,temparms,tscope);
Setattr(templnode,"sym:name",symname);
} else {
@@ -4662,9 +4668,9 @@ anon_bitfield_type : primitive_type { $$ = $1;
* PRIMITIVES
* ====================================================================== */
extern_string : EXTERN string {
- if (strcmp($2,"C") == 0) {
+ if (Strcmp($2,"C") == 0) {
$$ = "externc";
- } else if (strcmp($2,"C++") == 0) {
+ } else if (Strcmp($2,"C++") == 0) {
$$ = "extern";
} else {
Swig_warning(WARN_PARSE_UNDEFINED_EXTERN,cparse_file, cparse_line,"Unrecognized extern type \"%s\".\n", $2);
@@ -5782,17 +5788,6 @@ definetype : { /* scanner_check_typedef(); */ } expr {
| default_delete {
$$ = $1;
}
-/*
- | string {
- $$.val = NewString($1);
- $$.rawval = NewStringf("\"%(escape)s\"",$$.val);
- $$.type = T_STRING;
- $$.bitfield = 0;
- $$.throws = 0;
- $$.throwf = 0;
- $$.nexcept = 0;
- }
-*/
;
default_delete : deleted_definition {
@@ -5915,7 +5910,7 @@ expr : valexpr { $$ = $1; }
valexpr : exprnum { $$ = $1; }
| string {
- $$.val = NewString($1);
+ $$.val = $1;
$$.type = T_STRING;
}
| SIZEOF LPAREN type parameter_declarator RPAREN {
@@ -5930,7 +5925,7 @@ valexpr : exprnum { $$ = $1; }
}
| exprcompound { $$ = $1; }
| wstring {
- $$.val = NewString($1);
+ $$.val = $1;
$$.rawval = NewStringf("L\"%s\"", $$.val);
$$.type = T_WSTRING;
}
@@ -6440,8 +6435,8 @@ identifier : ID { $$ = $1; }
;
idstring : identifier { $$ = $1; }
- | default_delete { $$ = $1.val; }
- | string { $$ = $1; }
+ | default_delete { $$ = Char($1.val); }
+ | string { $$ = Char($1); }
;
idstringopt : idstring { $$ = $1; }
@@ -6551,30 +6546,24 @@ idcolontailnt : DCOLON identifier idcolontailnt {
/* Concatenated strings */
string : string STRING {
- $$ = (char *) malloc(strlen($1)+strlen($2)+1);
- strcpy($$,$1);
- strcat($$,$2);
+ $$ = NewStringf("%s%s", $1, $2);
}
- | STRING { $$ = $1;}
+ | STRING { $$ = NewString($1);}
;
/* Concatenated wide strings: L"str1" L"str2" */
wstring : wstring WSTRING {
- $$ = (char *) malloc(strlen($1)+strlen($2)+1);
- strcpy($$,$1);
- strcat($$,$2);
+ $$ = NewStringf("%s%s", $1, $2);
}
/* Concatenated wide string and normal string literal: L"str1" "str2" */
/*not all the compilers support this concatenation mode, so perhaps better to postpone it*/
/*| wstring STRING { here $2 comes unescaped, we have to escape it back first via NewStringf("%(escape)s)"
- $$ = (char *) malloc(strlen($1)+strlen($2)+1);
- strcpy($$,$1);
- strcat($$,$2);
+ $$ = NewStringf("%s%s", $1, $2);
}*/
- | WSTRING { $$ = $1;}
+ | WSTRING { $$ = NewString($1);}
;
stringbrace : string {
- $$ = NewString($1);
+ $$ = $1;
}
| LBRACE {
skip_balanced('{','}');
diff --git a/Source/Modules/allocate.cxx b/Source/Modules/allocate.cxx
index dc3820766..f79373d18 100644
--- a/Source/Modules/allocate.cxx
+++ b/Source/Modules/allocate.cxx
@@ -941,6 +941,8 @@ Allocate():
Setattr(inclass, "allocate:default_destructor", "1");
} else if (cplus_mode == PROTECTED) {
Setattr(inclass, "allocate:default_base_destructor", "1");
+ } else if (cplus_mode == PRIVATE) {
+ Setattr(inclass, "allocate:private_destructor", "1");
}
} else {
Setattr(inclass, "allocate:has_destructor", "1");
diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx
index 8fbdb13e4..0109bf41a 100644
--- a/Source/Modules/java.cxx
+++ b/Source/Modules/java.cxx
@@ -3428,7 +3428,7 @@ public:
Printf(f_runtime, "namespace Swig {\n");
Printf(f_runtime, " namespace {\n");
Printf(f_runtime, " jclass jclass_%s = NULL;\n", imclass_name);
- Printf(f_runtime, " jmethodID director_methids[%d];\n", n_methods);
+ Printf(f_runtime, " jmethodID director_method_ids[%d];\n", n_methods);
Printf(f_runtime, " }\n");
Printf(f_runtime, "}\n");
@@ -3445,8 +3445,8 @@ public:
Printf(w->code, "Swig::jclass_%s = (jclass) jenv->NewGlobalRef(jcls);\n", imclass_name);
Printf(w->code, "if (!Swig::jclass_%s) return;\n", imclass_name);
Printf(w->code, "for (i = 0; i < (int) (sizeof(methods)/sizeof(methods[0])); ++i) {\n");
- Printf(w->code, " Swig::director_methids[i] = jenv->GetStaticMethodID(jcls, methods[i].method, methods[i].signature);\n");
- Printf(w->code, " if (!Swig::director_methids[i]) return;\n");
+ Printf(w->code, " Swig::director_method_ids[i] = jenv->GetStaticMethodID(jcls, methods[i].method, methods[i].signature);\n");
+ Printf(w->code, " if (!Swig::director_method_ids[i]) return;\n");
Printf(w->code, "}\n");
Printf(w->code, "}\n");
@@ -4100,7 +4100,7 @@ public:
if (!is_void)
Printf(w->code, "jresult = (%s) ", c_ret_type);
- Printf(w->code, "jenv->%s(Swig::jclass_%s, Swig::director_methids[%s], %s);\n", methop, imclass_name, methid, jupcall_args);
+ Printf(w->code, "jenv->%s(Swig::jclass_%s, Swig::director_method_ids[%s], %s);\n", methop, imclass_name, methid, jupcall_args);
// Generate code to handle any Java exception thrown by director delegation
directorExceptHandler(n, catches_list ? catches_list : throw_parm_list, w);
diff --git a/Source/Modules/javascript.cxx b/Source/Modules/javascript.cxx
index 179ffb28c..6f0fb3afd 100644
--- a/Source/Modules/javascript.cxx
+++ b/Source/Modules/javascript.cxx
@@ -1100,7 +1100,7 @@ int JSEmitter::emitSetter(Node *n, bool is_member, bool is_static) {
* ----------------------------------------------------------------------------- */
int JSEmitter::emitConstant(Node *n) {
- // HACK: somehow it happened under OSX that before everything started
+ // HACK: somehow it happened under Mac OS X that before everything started
// a lot of SWIG internal constants were emitted
// This didn't happen on other platforms yet...
// we ignore those premature definitions
diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx
index 7943dc4c7..aa81581f0 100644
--- a/Source/Modules/lang.cxx
+++ b/Source/Modules/lang.cxx
@@ -3676,14 +3676,26 @@ int Language::abstractClassTest(Node *n) {
return 0;
if (Getattr(n, "allocate:nonew"))
return 1;
+
+ // A class cannot be instantiated if one of its bases has a private destructor
+ // Note that if the above does not hold the class can be instantiated if its own destructor is private
+ List *bases = Getattr(n, "bases");
+ if (bases) {
+ for (int i = 0; i < Len(bases); i++) {
+ Node *b = Getitem(bases, i);
+ if (GetFlag(b, "allocate:private_destructor"))
+ return 1;
+ }
+ }
+
/* now check for the rest */
List *abstracts = Getattr(n, "abstracts");
if (!abstracts)
return 0;
int labs = Len(abstracts);
#ifdef SWIG_DEBUG
- List *bases = Getattr(n, "allbases");
- Printf(stderr, "testing %s %d %d\n", Getattr(n, "name"), labs, Len(bases));
+ List *allbases = Getattr(n, "allbases");
+ Printf(stderr, "testing %s %d %d\n", Getattr(n, "name"), labs, Len(allbases));
#endif
if (!labs)
return 0; /*strange, but need to be fixed */
diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx
index 979f96484..2ff7c6f91 100644
--- a/Source/Modules/perl5.cxx
+++ b/Source/Modules/perl5.cxx
@@ -1045,21 +1045,9 @@ public:
String *tt = Getattr(n, "tmap:varout:type");
if (tt) {
- String *tm = NewStringf("&SWIGTYPE%s", SwigType_manglestr(t));
- if (Replaceall(tt, "$1_descriptor", tm)) {
- SwigType_remember(t);
- }
- Delete(tm);
- SwigType *st = Copy(t);
- SwigType_add_pointer(st);
- tm = NewStringf("&SWIGTYPE%s", SwigType_manglestr(st));
- if (Replaceall(tt, "$&1_descriptor", tm)) {
- SwigType_remember(st);
- }
- Delete(tm);
- Delete(st);
+ tt = NewStringf("&%s", tt);
} else {
- tt = (String *) "0";
+ tt = NewString("0");
}
/* Now add symbol to the PERL interpreter */
if (GetFlag(n, "feature:immutable")) {
@@ -1087,6 +1075,7 @@ public:
if (export_all)
Printf(exported, "$%s ", iname);
+ Delete(tt);
DelWrapper(setf);
DelWrapper(getf);
Delete(getname);
diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
index 652df8974..5670d9581 100644
--- a/Source/Modules/python.cxx
+++ b/Source/Modules/python.cxx
@@ -12,6 +12,7 @@
* ----------------------------------------------------------------------------- */
#include "swigmod.h"
+#include <limits.h>
#include "cparse.h"
#include <ctype.h>
#include <errno.h>
@@ -1299,7 +1300,7 @@ public:
/* ------------------------------------------------------------
* import_name_string()
- * ------------------------------------------------------------ */
+ * ------------------------------------------------------------ */
static String *import_name_string(const String *mainpkg, const String *mainmod, const String *pkg, const String *mod, const String *sym) {
if (!relativeimport) {
@@ -1345,9 +1346,10 @@ public:
/* ------------------------------------------------------------
* funcCall()
- * Emit shadow code to call a function in the extension
- * module. Using proper argument and calling style for
- * given node n.
+ *
+ * Emit shadow code to call a function in the extension
+ * module. Using proper argument and calling style for
+ * given node n.
* ------------------------------------------------------------ */
String *funcCall(String *name, String *parms) {
String *str = NewString("");
@@ -1356,12 +1358,15 @@ public:
return str;
}
-
/* ------------------------------------------------------------
- * pythoncode() - Output python code into the shadow file
+ * indent_pythoncode()
+ *
+ * Format (indent) Python code.
+ * Remove leading whitespace from 'code' and re-indent using
+ * the indentation string in 'indent'.
* ------------------------------------------------------------ */
- String *pythoncode(String *code, const_String_or_char_ptr indent, String * file, int line) {
+ String *indent_pythoncode(const String *code, const_String_or_char_ptr indent, String *file, int line, const char *directive_name) {
String *out = NewString("");
String *temp;
char *t;
@@ -1383,7 +1388,7 @@ public:
// Line number within the pythoncode.
int py_line = 0;
- String * initial = 0;
+ String *initial = 0;
Iterator si;
/* Get the initial indentation. Skip lines which only contain whitespace
@@ -1401,7 +1406,7 @@ public:
const char *c = Char(si.item);
int i;
for (i = 0; isspace((unsigned char)c[i]); i++) {
- // Scan forward until we find a non-space (which may be a nul byte).
+ // Scan forward until we find a non-space (which may be a null byte).
}
char ch = c[i];
if (ch && ch != '#') {
@@ -1423,7 +1428,7 @@ public:
int i;
for (i = 0; isspace((unsigned char)c[i]); i++) {
- // Scan forward until we find a non-space (which may be a nul byte).
+ // Scan forward until we find a non-space (which may be a null byte).
}
char ch = c[i];
if (!ch) {
@@ -1448,7 +1453,7 @@ public:
if (i < Len(initial)) {
// There's non-whitespace in the initial prefix of this line.
- Swig_error(file, line, "Line indented less than expected (line %d of pythoncode)\n", py_line);
+ Swig_error(file, line, "Line indented less than expected (line %d of %s) as no line should be indented less than the indentation in line 1\n", py_line, directive_name);
Printv(out, indent, c, "\n", NIL);
} else {
if (memcmp(c, Char(initial), Len(initial)) == 0) {
@@ -1457,7 +1462,7 @@ public:
continue;
}
Swig_warning(WARN_PYTHON_INDENT_MISMATCH,
- file, line, "Whitespace prefix doesn't match (line %d of pythoncode)\n", py_line);
+ file, line, "Whitespace indentation is inconsistent compared to earlier lines (line %d of %s)\n", py_line, directive_name);
// To avoid gratuitously breaking interface files which worked with
// SWIG <= 3.0.5, we remove a prefix of the same number of bytes for
// lines which start with different whitespace to the line we got
@@ -1469,6 +1474,72 @@ public:
return out;
}
+ /* ------------------------------------------------------------
+ * indent_docstring()
+ *
+ * Format (indent) a Python docstring.
+ * Remove leading whitespace from 'code' and re-indent using
+ * the indentation string in 'indent'.
+ * ------------------------------------------------------------ */
+
+ String *indent_docstring(const String *code, const_String_or_char_ptr indent) {
+ String *out = NewString("");
+ String *temp;
+ char *t;
+ if (!indent)
+ indent = "";
+
+ temp = NewString(code);
+
+ t = Char(temp);
+ if (*t == '{') {
+ Delitem(temp, 0);
+ Delitem(temp, DOH_END);
+ }
+
+ /* Split the input text into lines */
+ List *clist = SplitLines(temp);
+ Delete(temp);
+
+ Iterator si;
+
+ int truncate_characters_count = INT_MAX;
+ for (si = First(clist); si.item; si = Next(si)) {
+ const char *c = Char(si.item);
+ int i;
+ for (i = 0; isspace((unsigned char)c[i]); i++) {
+ // Scan forward until we find a non-space (which may be a null byte).
+ }
+ char ch = c[i];
+ if (ch) {
+ // Found a line which isn't just whitespace
+ if (i < truncate_characters_count)
+ truncate_characters_count = i;
+ }
+ }
+
+ if (truncate_characters_count == INT_MAX)
+ truncate_characters_count = 0;
+
+ for (si = First(clist); si.item; si = Next(si)) {
+ const char *c = Char(si.item);
+
+ int i;
+ for (i = 0; isspace((unsigned char)c[i]); i++) {
+ // Scan forward until we find a non-space (which may be a null byte).
+ }
+ char ch = c[i];
+ if (!ch) {
+ // Line is just whitespace - emit an empty line.
+ Putc('\n', out);
+ continue;
+ }
+
+ Printv(out, indent, c + truncate_characters_count, "\n", NIL);
+ }
+ Delete(clist);
+ return out;
+ }
/* ------------------------------------------------------------
* autodoc level declarations
@@ -1504,8 +1575,9 @@ public:
/* ------------------------------------------------------------
* have_docstring()
- * Check if there is a docstring directive and it has text,
- * or there is an autodoc flag set
+ *
+ * Check if there is a docstring directive and it has text,
+ * or there is an autodoc flag set
* ------------------------------------------------------------ */
bool have_docstring(Node *n) {
@@ -1515,9 +1587,10 @@ public:
/* ------------------------------------------------------------
* docstring()
- * Get the docstring text, stripping off {} if neccessary,
- * and enclose in triple double quotes. If autodoc is also
- * set then it will build a combined docstring.
+ *
+ * Get the docstring text, stripping off {} if neccessary,
+ * and enclose in triple double quotes. If autodoc is also
+ * set then it will build a combined docstring.
* ------------------------------------------------------------ */
String *docstring(Node *n, autodoc_t ad_type, const String *indent, bool use_triple = true) {
@@ -1552,21 +1625,21 @@ public:
if (have_auto && have_ds) { // Both autodoc and docstring are present
doc = NewString("");
Printv(doc, triple_double, "\n",
- pythoncode(autodoc, indent, Getfile(n), Getline(n)), "\n",
- pythoncode(str, indent, Getfile(n), Getline(n)), indent, triple_double, NIL);
+ indent_docstring(autodoc, indent), "\n",
+ indent_docstring(str, indent), indent, triple_double, NIL);
} else if (!have_auto && have_ds) { // only docstring
if (Strchr(str, '\n') == 0) {
doc = NewStringf("%s%s%s", triple_double, str, triple_double);
} else {
doc = NewString("");
- Printv(doc, triple_double, "\n", pythoncode(str, indent, Getfile(n), Getline(n)), indent, triple_double, NIL);
+ Printv(doc, triple_double, "\n", indent_docstring(str, indent), indent, triple_double, NIL);
}
} else if (have_auto && !have_ds) { // only autodoc
if (Strchr(autodoc, '\n') == 0) {
doc = NewStringf("%s%s%s", triple_double, autodoc, triple_double);
} else {
doc = NewString("");
- Printv(doc, triple_double, "\n", pythoncode(autodoc, indent, Getfile(n), Getline(n)), indent, triple_double, NIL);
+ Printv(doc, triple_double, "\n", indent_docstring(autodoc, indent), indent, triple_double, NIL);
}
} else
doc = NewString("");
@@ -1580,8 +1653,9 @@ public:
/* ------------------------------------------------------------
* cdocstring()
- * Get the docstring text as it would appear in C-language
- * source code.
+ *
+ * Get the docstring text as it would appear in C-language
+ * source code.
* ------------------------------------------------------------ */
String *cdocstring(Node *n, autodoc_t ad_type)
@@ -1610,7 +1684,8 @@ public:
/* -----------------------------------------------------------------------------
* addMissingParameterNames()
- * For functions that have not had nameless parameters set in the Language class.
+ *
+ * For functions that have not had nameless parameters set in the Language class.
*
* Inputs:
* plist - entire parameter list
@@ -1635,8 +1710,9 @@ public:
/* ------------------------------------------------------------
* make_autodocParmList()
- * Generate the documentation for the function parameters
- * Parameters:
+ *
+ * Generate the documentation for the function parameters
+ * Parameters:
* func_annotation: Function annotation support
* ------------------------------------------------------------ */
@@ -1743,12 +1819,13 @@ public:
/* ------------------------------------------------------------
* make_autodoc()
- * Build a docstring for the node, using parameter and other
- * info in the parse tree. If the value of the autodoc
- * attribute is "0" then do not include parameter types, if
- * it is "1" (the default) then do. If it has some other
- * value then assume it is supplied by the extension writer
- * and use it directly.
+ *
+ * Build a docstring for the node, using parameter and other
+ * info in the parse tree. If the value of the autodoc
+ * attribute is "0" then do not include parameter types, if
+ * it is "1" (the default) then do. If it has some other
+ * value then assume it is supplied by the extension writer
+ * and use it directly.
* ------------------------------------------------------------ */
String *make_autodoc(Node *n, autodoc_t ad_type) {
@@ -1808,10 +1885,17 @@ public:
// Only do the autodoc if there isn't a docstring for the class
String *str = Getattr(n, "feature:docstring");
if (!str || Len(str) == 0) {
- if (CPlusPlus) {
- Printf(doc, "Proxy of C++ %s class", real_classname);
+ if (builtin) {
+ String *name = Getattr(n, "name");
+ String *rname = add_explicit_scope(SwigType_namestr(name));
+ Printf(doc, "%s", rname);
+ Delete(rname);
} else {
- Printf(doc, "Proxy of C %s struct", real_classname);
+ if (CPlusPlus) {
+ Printf(doc, "Proxy of C++ %s class", real_classname);
+ } else {
+ Printf(doc, "Proxy of C %s struct", real_classname);
+ }
}
}
}
@@ -1880,9 +1964,10 @@ public:
}
/* ------------------------------------------------------------
- * convertDoubleValue()
- * Check if the given string looks like a decimal floating point constant
- * and return it if it does, otherwise return NIL.
+ * convertDoubleValue()
+ *
+ * Check if the given string looks like a decimal floating point constant
+ * and return it if it does, otherwise return NIL.
* ------------------------------------------------------------ */
String *convertDoubleValue(String *v) {
const char *const s = Char(v);
@@ -1924,8 +2009,9 @@ public:
/* ------------------------------------------------------------
* convertValue()
- * Check if string v can be a Python value literal or a
- * constant. Return NIL if it isn't.
+ *
+ * Check if string v can be a Python value literal or a
+ * constant. Return NIL if it isn't.
* ------------------------------------------------------------ */
String *convertValue(String *v, SwigType *type) {
const char *const s = Char(v);
@@ -2047,12 +2133,13 @@ public:
/* ------------------------------------------------------------
* is_representable_as_pyargs()
- * Check if the function parameters default argument values
- * can be represented in Python.
*
- * If this method returns false, the parameters will be translated
- * to a generic "*args" which allows us to deal with default values
- * at C++ code level where they can always be handled.
+ * Check if the function parameters default argument values
+ * can be represented in Python.
+ *
+ * If this method returns false, the parameters will be translated
+ * to a generic "*args" which allows us to deal with default values
+ * at C++ code level where they can always be handled.
* ------------------------------------------------------------ */
bool is_representable_as_pyargs(Node *n) {
ParmList *plist = CopyParmList(Getattr(n, "parms"));
@@ -2094,9 +2181,10 @@ public:
/* ------------------------------------------------------------
* is_real_overloaded()
- * Check if the function is overloaded, but not just have some
- * siblings generated due to the original function have
- * default arguments.
+ *
+ * Check if the function is overloaded, but not just have some
+ * siblings generated due to the original function have
+ * default arguments.
* ------------------------------------------------------------ */
bool is_real_overloaded(Node *n) {
Node *h = Getattr(n, "sym:overloaded");
@@ -2120,8 +2208,9 @@ public:
/* ------------------------------------------------------------
* make_pyParmList()
- * Generate parameter list for Python functions or methods,
- * reuse make_autodocParmList() to do so.
+ *
+ * Generate parameter list for Python functions or methods,
+ * reuse make_autodocParmList() to do so.
* ------------------------------------------------------------ */
String *make_pyParmList(Node *n, bool in_class, bool is_calling, int kw) {
/* Get the original function for a defaultargs copy,
@@ -2167,7 +2256,8 @@ public:
/* ------------------------------------------------------------
* have_pythonprepend()
- * Check if there is a %pythonprepend directive and it has text
+ *
+ * Check if there is a %pythonprepend directive and it has text
* ------------------------------------------------------------ */
bool have_pythonprepend(Node *n) {
@@ -2177,7 +2267,8 @@ public:
/* ------------------------------------------------------------
* pythonprepend()
- * Get the %pythonprepend code, stripping off {} if neccessary
+ *
+ * Get the %pythonprepend code, stripping off {} if neccessary
* ------------------------------------------------------------ */
String *pythonprepend(Node *n) {
@@ -2192,7 +2283,8 @@ public:
/* ------------------------------------------------------------
* have_pythonappend()
- * Check if there is a %pythonappend directive and it has text
+ *
+ * Check if there is a %pythonappend directive and it has text
* ------------------------------------------------------------ */
bool have_pythonappend(Node *n) {
@@ -2204,7 +2296,8 @@ public:
/* ------------------------------------------------------------
* pythonappend()
- * Get the %pythonappend code, stripping off {} if neccessary
+ *
+ * Get the %pythonappend code, stripping off {} if neccessary
* ------------------------------------------------------------ */
String *pythonappend(Node *n) {
@@ -2222,7 +2315,8 @@ public:
/* ------------------------------------------------------------
* have_addtofunc()
- * Check if there is a %addtofunc directive and it has text
+ *
+ * Check if there is a %addtofunc directive and it has text
* ------------------------------------------------------------ */
bool have_addtofunc(Node *n) {
@@ -2232,8 +2326,9 @@ public:
/* ------------------------------------------------------------
* returnTypeAnnotation()
- * Helper function for constructing the function annotation
- * of the returning type, return a empty string for Python 2.x
+ *
+ * Helper function for constructing the function annotation
+ * of the returning type, return a empty string for Python 2.x
* ------------------------------------------------------------ */
String *returnTypeAnnotation(Node *n) {
String *ret = 0;
@@ -2266,9 +2361,10 @@ public:
/* ------------------------------------------------------------
* emitFunctionShadowHelper()
- * Refactoring some common code out of functionWrapper and
- * dispatchFunction that writes the proxy code for non-member
- * functions.
+ *
+ * Refactoring some common code out of functionWrapper and
+ * dispatchFunction that writes the proxy code for non-member
+ * functions.
* ------------------------------------------------------------ */
void emitFunctionShadowHelper(Node *n, File *f_dest, String *name, int kw) {
@@ -2279,10 +2375,10 @@ public:
if (have_docstring(n))
Printv(f_dest, tab4, docstring(n, AUTODOC_FUNC, tab4), "\n", NIL);
if (have_pythonprepend(n))
- Printv(f_dest, pythoncode(pythonprepend(n), tab4, Getfile(n), Getline(n)), "\n", NIL);
+ Printv(f_dest, indent_pythoncode(pythonprepend(n), tab4, Getfile(n), Getline(n), "%pythonprepend or %feature(\"pythonprepend\")"), "\n", NIL);
if (have_pythonappend(n)) {
Printv(f_dest, tab4 "val = ", funcCall(name, callParms), "\n", NIL);
- Printv(f_dest, pythoncode(pythonappend(n), tab4, Getfile(n), Getline(n)), "\n", NIL);
+ Printv(f_dest, indent_pythoncode(pythonappend(n), tab4, Getfile(n), Getline(n), "%pythonappend or %feature(\"pythonappend\")"), "\n", NIL);
Printv(f_dest, tab4 "return val\n", NIL);
} else {
Printv(f_dest, tab4 "return ", funcCall(name, callParms), "\n", NIL);
@@ -2297,7 +2393,8 @@ public:
/* ------------------------------------------------------------
* check_kwargs()
- * check if using kwargs is allowed for this Node
+ *
+ * check if using kwargs is allowed for this Node
* ------------------------------------------------------------ */
int check_kwargs(Node *n) const {
@@ -2378,7 +2475,7 @@ public:
Printv(f->def, linkage, builtin_ctor ? "int " : "PyObject *", wname, "(PyObject *self, PyObject *args) {", NIL);
Wrapper_add_local(f, "argc", "int argc");
- Printf(tmp, "PyObject *argv[%d]", maxargs + 1);
+ Printf(tmp, "PyObject *argv[%d] = {0}", maxargs + 1);
Wrapper_add_local(f, "argv", tmp);
if (!fastunpack) {
@@ -3882,7 +3979,7 @@ public:
else
quoted_symname = NewStringf("\"%s\"", symname);
}
- String *quoted_rname = NewStringf("\"%s\"", rname);
+ String *quoted_tp_doc_str = NewStringf("\"%s\"", getSlot(n, "feature:python:tp_doc"));
char const *tp_init = builtin_tp_init ? Char(builtin_tp_init) : Swig_directorclass(n) ? "0" : "SwigPyBuiltin_BadInit";
String *tp_flags = NewString("Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_CHECKTYPES");
String *py3_tp_flags = NewString("Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE");
@@ -3925,7 +4022,7 @@ public:
Printv(f, "#else\n", NIL);
printSlot(f, tp_flags, "tp_flags");
Printv(f, "#endif\n", NIL);
- printSlot(f, quoted_rname, "tp_doc");
+ printSlot(f, quoted_tp_doc_str, "tp_doc");
printSlot(f, getSlot(n, "feature:python:tp_traverse"), "tp_traverse", "traverseproc");
printSlot(f, getSlot(n, "feature:python:tp_clear"), "tp_clear", "inquiry");
printSlot(f, richcompare_func, "feature:python:tp_richcompare", "richcmpfunc");
@@ -4108,7 +4205,7 @@ public:
Delete(tp_flags);
Delete(py3_tp_flags);
Delete(quoted_symname);
- Delete(quoted_rname);
+ Delete(quoted_tp_doc_str);
Delete(clientdata_klass);
Delete(richcompare_func);
Delete(getset_name);
@@ -4208,6 +4305,11 @@ public:
String *str = cdocstring(n, AUTODOC_CLASS);
Setattr(n, "feature:python:tp_doc", str);
Delete(str);
+ } else {
+ String *name = Getattr(n, "name");
+ String *rname = add_explicit_scope(SwigType_namestr(name));
+ Setattr(n, "feature:python:tp_doc", rname);
+ Delete(rname);
}
} else {
Printv(f_shadow, "class ", class_name, NIL);
@@ -4486,7 +4588,7 @@ public:
have_repr = 1;
}
if (Getattr(n, "feature:shadow")) {
- String *pycode = pythoncode(Getattr(n, "feature:shadow"), tab4, Getfile(n), Getline(n));
+ String *pycode = indent_pythoncode(Getattr(n, "feature:shadow"), tab4, Getfile(n), Getline(n), "%feature(\"shadow\")");
String *pyaction = NewStringf("%s.%s", module, fullname);
Replaceall(pycode, "$action", pyaction);
Delete(pyaction);
@@ -4508,12 +4610,12 @@ public:
Printv(f_shadow, tab8, docstring(n, AUTODOC_METHOD, tab8), "\n", NIL);
if (have_pythonprepend(n)) {
fproxy = 0;
- Printv(f_shadow, pythoncode(pythonprepend(n), tab8, Getfile(n), Getline(n)), "\n", NIL);
+ Printv(f_shadow, indent_pythoncode(pythonprepend(n), tab8, Getfile(n), Getline(n), "%pythonprepend or %feature(\"pythonprepend\")"), "\n", NIL);
}
if (have_pythonappend(n)) {
fproxy = 0;
Printv(f_shadow, tab8, "val = ", funcCall(fullname, callParms), "\n", NIL);
- Printv(f_shadow, pythoncode(pythonappend(n), tab8, Getfile(n), Getline(n)), "\n", NIL);
+ Printv(f_shadow, indent_pythoncode(pythonappend(n), tab8, Getfile(n), Getline(n), "%pythonappend or %feature(\"pythonappend\")"), "\n", NIL);
Printv(f_shadow, tab8, "return val\n\n", NIL);
} else {
Printv(f_shadow, tab8, "return ", funcCall(fullname, callParms), "\n\n", NIL);
@@ -4593,10 +4695,10 @@ public:
if (have_docstring(n))
Printv(f_shadow, tab8, docstring(n, AUTODOC_STATICFUNC, tab8), "\n", NIL);
if (have_pythonprepend(n))
- Printv(f_shadow, pythoncode(pythonprepend(n), tab8, Getfile(n), Getline(n)), "\n", NIL);
+ Printv(f_shadow, indent_pythoncode(pythonprepend(n), tab8, Getfile(n), Getline(n), "%pythonprepend or %feature(\"pythonprepend\")"), "\n", NIL);
if (have_pythonappend(n)) {
Printv(f_shadow, tab8, "val = ", funcCall(Swig_name_member(NSPACE_TODO, class_name, symname), callParms), "\n", NIL);
- Printv(f_shadow, pythoncode(pythonappend(n), tab8, Getfile(n), Getline(n)), "\n", NIL);
+ Printv(f_shadow, indent_pythoncode(pythonappend(n), tab8, Getfile(n), Getline(n), "%pythonappend or %feature(\"pythonappend\")"), "\n", NIL);
Printv(f_shadow, tab8, "return val\n\n", NIL);
} else {
Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(NSPACE_TODO, class_name, symname), callParms), "\n\n", NIL);
@@ -4681,7 +4783,7 @@ public:
if (!have_constructor && handled_as_init) {
if (!builtin) {
if (Getattr(n, "feature:shadow")) {
- String *pycode = pythoncode(Getattr(n, "feature:shadow"), tab4, Getfile(n), Getline(n));
+ String *pycode = indent_pythoncode(Getattr(n, "feature:shadow"), tab4, Getfile(n), Getline(n), "%feature(\"shadow\")");
String *pyaction = NewStringf("%s.%s", module, Swig_name_construct(NSPACE_TODO, symname));
Replaceall(pycode, "$action", pyaction);
Delete(pyaction);
@@ -4710,7 +4812,7 @@ public:
if (have_docstring(n))
Printv(f_shadow, tab8, docstring(n, AUTODOC_CTOR, tab8), "\n", NIL);
if (have_pythonprepend(n))
- Printv(f_shadow, pythoncode(pythonprepend(n), tab8, Getfile(n), Getline(n)), "\n", NIL);
+ Printv(f_shadow, indent_pythoncode(pythonprepend(n), tab8, Getfile(n), Getline(n), "%pythonprepend or %feature(\"pythonprepend\")"), "\n", NIL);
Printv(f_shadow, pass_self, NIL);
if (fastinit) {
Printv(f_shadow, tab8, module, ".", class_name, "_swiginit(self, ", funcCall(Swig_name_construct(NSPACE_TODO, symname), callParms), ")\n", NIL);
@@ -4720,7 +4822,7 @@ public:
tab8, "try:\n", tab8, tab4, "self.this.append(this)\n", tab8, "except:\n", tab8, tab4, "self.this = this\n", NIL);
}
if (have_pythonappend(n))
- Printv(f_shadow, pythoncode(pythonappend(n), tab8, Getfile(n), Getline(n)), "\n\n", NIL);
+ Printv(f_shadow, indent_pythoncode(pythonappend(n), tab8, Getfile(n), Getline(n), "%pythonappend or %feature(\"pythonappend\")"), "\n\n", NIL);
Delete(pass_self);
}
have_constructor = 1;
@@ -4729,7 +4831,7 @@ public:
/* Hmmm. We seem to be creating a different constructor. We're just going to create a
function for it. */
if (Getattr(n, "feature:shadow")) {
- String *pycode = pythoncode(Getattr(n, "feature:shadow"), "", Getfile(n), Getline(n));
+ String *pycode = indent_pythoncode(Getattr(n, "feature:shadow"), "", Getfile(n), Getline(n), "%feature(\"shadow\")");
String *pyaction = NewStringf("%s.%s", module, Swig_name_construct(NSPACE_TODO, symname));
Replaceall(pycode, "$action", pyaction);
Delete(pyaction);
@@ -4743,7 +4845,7 @@ public:
if (have_docstring(n))
Printv(f_shadow_stubs, tab4, docstring(n, AUTODOC_CTOR, tab4), "\n", NIL);
if (have_pythonprepend(n))
- Printv(f_shadow_stubs, pythoncode(pythonprepend(n), tab4, Getfile(n), Getline(n)), "\n", NIL);
+ Printv(f_shadow_stubs, indent_pythoncode(pythonprepend(n), tab4, Getfile(n), Getline(n), "%pythonprepend or %feature(\"pythonprepend\")"), "\n", NIL);
String *subfunc = NULL;
/*
if (builtin)
@@ -4756,7 +4858,7 @@ public:
Printv(f_shadow_stubs, tab4, "val.thisown = 1\n", NIL);
#endif
if (have_pythonappend(n))
- Printv(f_shadow_stubs, pythoncode(pythonappend(n), tab4, Getfile(n), Getline(n)), "\n", NIL);
+ Printv(f_shadow_stubs, indent_pythoncode(pythonappend(n), tab4, Getfile(n), Getline(n), "%pythonappend or %feature(\"pythonappend\")"), "\n", NIL);
Printv(f_shadow_stubs, tab4, "return val\n", NIL);
Delete(subfunc);
}
@@ -4793,7 +4895,7 @@ public:
if (shadow) {
if (Getattr(n, "feature:shadow")) {
- String *pycode = pythoncode(Getattr(n, "feature:shadow"), tab4, Getfile(n), Getline(n));
+ String *pycode = indent_pythoncode(Getattr(n, "feature:shadow"), tab4, Getfile(n), Getline(n), "%feature(\"shadow\")");
String *pyaction = NewStringf("%s.%s", module, Swig_name_destroy(NSPACE_TODO, symname));
Replaceall(pycode, "$action", pyaction);
Delete(pyaction);
@@ -4811,7 +4913,7 @@ public:
if (have_docstring(n))
Printv(f_shadow, tab8, docstring(n, AUTODOC_DTOR, tab8), "\n", NIL);
if (have_pythonprepend(n))
- Printv(f_shadow, pythoncode(pythonprepend(n), tab8, Getfile(n), Getline(n)), "\n", NIL);
+ Printv(f_shadow, indent_pythoncode(pythonprepend(n), tab8, Getfile(n), Getline(n), "%pythonprepend or %feature(\"pythonprepend\")"), "\n", NIL);
#ifdef USE_THISOWN
Printv(f_shadow, tab8, "try:\n", NIL);
Printv(f_shadow, tab8, tab4, "if self.thisown:", module, ".", Swig_name_destroy(NSPACE_TODO, symname), "(self)\n", NIL);
@@ -4819,7 +4921,7 @@ public:
#else
#endif
if (have_pythonappend(n))
- Printv(f_shadow, pythoncode(pythonappend(n), tab8, Getfile(n), Getline(n)), "\n", NIL);
+ Printv(f_shadow, indent_pythoncode(pythonappend(n), tab8, Getfile(n), Getline(n), "%pythonappend or %feature(\"pythonappend\")"), "\n", NIL);
Printv(f_shadow, tab8, "pass\n", NIL);
Printv(f_shadow, "\n", NIL);
}
@@ -4999,12 +5101,12 @@ public:
if (!ImportMode && (Cmp(section, "python") == 0 || Cmp(section, "shadow") == 0)) {
if (shadow) {
- String *pycode = pythoncode(code, shadow_indent, Getfile(n), Getline(n));
+ String *pycode = indent_pythoncode(code, shadow_indent, Getfile(n), Getline(n), "%pythoncode or %insert(\"python\") block");
Printv(f_shadow, pycode, NIL);
Delete(pycode);
}
} else if (!ImportMode && (Cmp(section, "pythonbegin") == 0)) {
- String *pycode = pythoncode(code, "", Getfile(n), Getline(n));
+ String *pycode = indent_pythoncode(code, "", Getfile(n), Getline(n), "%pythonbegin or %insert(\"pythonbegin\") block");
Printv(f_shadow_begin, pycode, NIL);
Delete(pycode);
} else {
diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c
index b0d608c9e..227a1d00c 100644
--- a/Source/Swig/scanner.c
+++ b/Source/Swig/scanner.c
@@ -336,7 +336,7 @@ static void brackets_reset(Scanner *s) {
* Usually called when '(' is found.
* ----------------------------------------------------------------------------- */
static void brackets_push(Scanner *s) {
- int *newInt = malloc(sizeof(int));
+ int *newInt = (int *)malloc(sizeof(int));
*newInt = 0;
Push(s->brackets, NewVoid(newInt, free));
}
diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c
index 23b1e80e9..4c6530061 100644
--- a/Source/Swig/typemap.c
+++ b/Source/Swig/typemap.c
@@ -1318,6 +1318,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
char *cmethod = Char(tmap_method);
int optimal_attribute = 0;
int optimal_substitution = 0;
+ int delete_optimal_attribute = 0;
int num_substitutions = 0;
SwigType *matchtype = 0;
@@ -1372,7 +1373,6 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
Delete(typestr);
}
-
Delete(qpname);
qpname = 0;
Delete(noscope_pname);
@@ -1391,23 +1391,16 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
s = Copy(s); /* Make a local copy of the typemap code */
- /* Attach kwargs - ie the typemap attributes */
- kw = Getattr(tm, "kwargs");
- while (kw) {
- String *value = Copy(Getattr(kw, "value"));
- String *kwtype = Getattr(kw, "type");
- char *ckwname = Char(Getattr(kw, "name"));
- if (kwtype) {
- String *mangle = Swig_string_mangle(kwtype);
- Append(value, mangle);
- Delete(mangle);
+ /* Look in the "out" typemap for the "optimal" attribute */
+ if (Cmp(cmethod, "out") == 0) {
+ kw = Getattr(tm, "kwargs");
+ while (kw) {
+ if (Cmp(Getattr(kw, "name"), "optimal") == 0) {
+ optimal_attribute = GetFlag(kw, "value");
+ break;
+ }
+ kw = nextSibling(kw);
}
- sprintf(temp, "%s:%s", cmethod, ckwname);
- Setattr(node, typemap_method_name(temp), value);
- if (Cmp(temp, "out:optimal") == 0)
- optimal_attribute = (Cmp(value, "0") != 0) ? 1 : 0;
- Delete(value);
- kw = nextSibling(kw);
}
if (optimal_attribute) {
@@ -1438,14 +1431,15 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
}
}
if (!optimal_substitution) {
- Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_IGNORED, Getfile(node), Getline(node), "Method %s usage of the optimal attribute ignored\n", Swig_name_decl(node));
- Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_IGNORED, Getfile(s), Getline(s), "in the out typemap as the following cannot be used to generate optimal code: %s\n", clname);
- Delattr(node, "tmap:out:optimal");
+ Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_IGNORED, Getfile(node), Getline(node), "Method %s usage of the optimal attribute ignored\n", Swig_name_decl(node));
+ Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_IGNORED, Getfile(s), Getline(s), "in the out typemap as the following cannot be used to generate optimal code: %s\n", clname);
+ delete_optimal_attribute = 1;
}
} else {
assert(!f);
}
}
+
if (actioncode) {
assert(f);
Append(f->code, actioncode);
@@ -1486,6 +1480,41 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
Delete(parm_sublist);
}
+ /* Attach kwargs - ie the typemap attributes */
+ kw = Getattr(tm, "kwargs");
+ while (kw) {
+ String *value = Copy(Getattr(kw, "value"));
+ String *kwtype = Getattr(kw, "type");
+ char *ckwname = Char(Getattr(kw, "name"));
+ {
+ /* Expand special variables in typemap attributes. */
+ SwigType *ptype = Getattr(node, "type");
+ String *pname = Getattr(node, "name");
+ SwigType *mtype = Getattr(node, "tmap:match");
+ SwigType *matchtype = mtype ? mtype : ptype;
+ ParmList *parm_sublist;
+ typemap_replace_vars(value, NULL, matchtype, ptype, pname, (char *)lname, 1);
+
+ /* Expand special variable macros (embedded typemaps) in typemap attributes. */
+ parm_sublist = NewParmWithoutFileLineInfo(ptype, pname);
+ Setattr(parm_sublist, "lname", lname);
+ replace_embedded_typemap(value, parm_sublist, NULL, tm);
+ Delete(parm_sublist);
+ }
+ if (kwtype) {
+ String *mangle = Swig_string_mangle(kwtype);
+ Append(value, mangle);
+ Delete(mangle);
+ }
+ sprintf(temp, "%s:%s", cmethod, ckwname);
+ Setattr(node, typemap_method_name(temp), value);
+ Delete(value);
+ kw = nextSibling(kw);
+ }
+
+ if (delete_optimal_attribute)
+ Delattr(node, "tmap:out:optimal");
+
Replace(s, "$name", pname, DOH_REPLACE_ANY);
symname = Getattr(node, "sym:name");
@@ -1558,17 +1587,44 @@ String *Swig_typemap_lookup(const_String_or_char_ptr tmap_method, Node *node, co
* If this hash (tm) contains a linked list of parameters under its "kwargs"
* attribute, add keys for each of those named keyword arguments to this
* parameter for later use.
- * For example, attach the typemap attributes to p:
+ * For example, attach the typemap attributes to firstp (first parameter in parameter list):
* %typemap(in, foo="xyz") ...
- * A new attribute called "tmap:in:foo" with value "xyz" is attached to p.
+ * A new attribute called "tmap:in:foo" with value "xyz" is attached to firstp.
+ * Also expands special variables and special variable macros in the typemap attributes.
* ----------------------------------------------------------------------------- */
-static void typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr tmap_method, Parm *p) {
+static void typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr tmap_method, Parm *firstp, int nmatch) {
String *temp = NewStringEmpty();
Parm *kw = Getattr(tm, "kwargs");
while (kw) {
String *value = Copy(Getattr(kw, "value"));
String *type = Getattr(kw, "type");
+ int i;
+ Parm *p = firstp;
+ /* Expand special variables */
+ for (i = 0; i < nmatch; i++) {
+ SwigType *type = Getattr(p, "type");
+ String *pname = Getattr(p, "name");
+ String *lname = Getattr(p, "lname");
+ SwigType *mtype = Getattr(p, "tmap:match");
+ SwigType *matchtype = mtype ? mtype : type;
+ typemap_replace_vars(value, NULL, matchtype, type, pname, lname, i + 1);
+ p = nextSibling(p);
+ }
+
+ /* Expand special variable macros (embedded typemaps).
+ * Special variable are expanded first above as they might be used in the special variable macros.
+ * For example: $typemap(imtype, $2_type). */
+ p = firstp;
+ for (i = 0; i < nmatch; i++) {
+ SwigType *type = Getattr(p, "type");
+ String *pname = Getattr(p, "name");
+ String *lname = Getattr(p, "lname");
+ ParmList *parm_sublist = NewParmWithoutFileLineInfo(type, pname);
+ Setattr(parm_sublist, "lname", lname);
+ replace_embedded_typemap(value, parm_sublist, NULL, tm);
+ p = nextSibling(p);
+ }
if (type) {
Hash *v = NewHash();
Setattr(v, "type", type);
@@ -1578,13 +1634,13 @@ static void typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr tmap_method
}
Clear(temp);
Printf(temp, "%s:%s", tmap_method, Getattr(kw, "name"));
- Setattr(p, typemap_method_name(temp), value);
+ Setattr(firstp, typemap_method_name(temp), value);
Delete(value);
kw = nextSibling(kw);
}
Clear(temp);
Printf(temp, "%s:match_type", tmap_method);
- Setattr(p, typemap_method_name(temp), Getattr(tm, "type"));
+ Setattr(firstp, typemap_method_name(temp), Getattr(tm, "type"));
Delete(temp);
}
@@ -1779,7 +1835,7 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *p
Setattr(firstp, typemap_method_name(temp), p);
/* Attach kwargs */
- typemap_attach_kwargs(tm, tmap_method, firstp);
+ typemap_attach_kwargs(tm, tmap_method, firstp, nmatch);
/* Replace the argument number */
sprintf(temp, "%d", argnum);
diff --git a/Tools/convertpath b/Tools/convertpath
index fce5ac24b..0cc8b74bb 100755
--- a/Tools/convertpath
+++ b/Tools/convertpath
@@ -1,25 +1,32 @@
#!/bin/sh
-# Unix to Windows relative path conversion in a script.
+# Unix to Windows path conversion in a script.
# Useful for avoiding backslash quoting difficulties in Makefiles.
-# Acts as a much dumbed down 'cygpath -w' tool.
+# Acts as a much dumbed down cygpath tool mainly for use on MinGW.
usage()
{
cat <<EOF
-Usage: $0 [-w|-u|-h] [path]...
+Usage: $0 [-m|-u|-w|-h] [path]...
-Convert Windows and Unix paths (intended for simple relative paths only)
+Convert Windows and Unix paths
- -w Convert backslashes to forward slashes in the paths
- -u Convert forward slashes to backslashes in the paths
+ -m Convert Unix path to mixed path (full paths, MinGW MSYS only)
+ -u Convert forward slashes to backslashes in the paths (relative paths only)
+ -w Convert backslashes to forward slashes in the paths (relative paths only)
EOF
}
option="$1"
case "$option" in
- -w) shift; echo $@ | sed -e 's,/,\\,g' ;;
+ -m) shift
+ case $MACHTYPE in
+ # This echo converts unix to mixed paths. Then zap unexpected trailing space on old versions of MinGW.
+ *-msys) echo `cmd //c echo "$@" | sed -e "s/[ ]*$//"`;;
+ *) echo "The -m option is only supported on MinGW MSYS" 1>&2; exit 1 ;;
+ esac ;;
-u) shift; echo $@ | sed -e 's,\\,/,g' ;;
+ -w) shift; echo $@ | sed -e 's,/,\\,g' ;;
-h) shift; usage; ;;
*) usage; exit 1 ;;
esac
diff --git a/Tools/javascript/Makefile.in b/Tools/javascript/Makefile.in
index 1eec5bc1e..5eeec0785 100644
--- a/Tools/javascript/Makefile.in
+++ b/Tools/javascript/Makefile.in
@@ -14,7 +14,7 @@
all: javascript
CC = @CC@
-# HACK: under OSX a g++ compiled interpreter is seg-faulting when loading module libraries
+# HACK: under Mac OS X a g++ compiled interpreter is seg-faulting when loading module libraries
# with 'c++' it works... probably some missing flags?
JSCXX = @JSINTERPRETERCXX@
CPPFLAGS = @BOOST_CPPFLAGS@
diff --git a/Tools/testflags.py b/Tools/testflags.py
index 23bec9c8d..04bbc1c67 100755
--- a/Tools/testflags.py
+++ b/Tools/testflags.py
@@ -1,6 +1,10 @@
#!/usr/bin/env python
-c_common = "-fdiagnostics-show-option -std=gnu89 -Wno-long-long -Wreturn-type -Wdeclaration-after-statement"
-cflags = {
+
+def get_cflags(language, std):
+ if std == None or len(std) == 0:
+ std = "gnu89"
+ c_common = "-fdiagnostics-show-option -std=" + std + " -Wno-long-long -Wreturn-type -Wdeclaration-after-statement"
+ cflags = {
"csharp":"-Werror " + c_common,
"d":"-Werror " + c_common,
"go":"-Werror " + c_common,
@@ -15,10 +19,18 @@ cflags = {
"ruby":"-Werror " + c_common,
"scilab":"-Werror " + c_common,
"tcl":"-Werror " + c_common,
-}
+ }
+
+ if language not in cflags:
+ raise RuntimeError("{} is not a supported language".format(language))
+
+ return cflags[language]
-cxx_common = "-fdiagnostics-show-option -std=c++98 -Wno-long-long -Wreturn-type"
-cxxflags = {
+def get_cxxflags(language, std):
+ if std == None or len(std) == 0:
+ std = "c++98"
+ cxx_common = "-fdiagnostics-show-option -std=" + std + " -Wno-long-long -Wreturn-type"
+ cxxflags = {
"csharp":"-Werror " + cxx_common,
"d":"-Werror " + cxx_common,
"go":"-Werror " + cxx_common,
@@ -33,7 +45,12 @@ cxxflags = {
"ruby":"-Werror " + cxx_common,
"scilab": cxx_common,
"tcl":"-Werror " + cxx_common,
-}
+ }
+
+ if language not in cxxflags:
+ raise RuntimeError("{} is not a supported language".format(language))
+
+ return cxxflags[language]
import argparse
parser = argparse.ArgumentParser(description="Display CFLAGS or CXXFLAGS to use for testing the SWIG examples and test-suite.")
@@ -41,12 +58,13 @@ parser.add_argument('-l', '--language', required=True, help='set language to sho
flags = parser.add_mutually_exclusive_group(required=True)
flags.add_argument('-c', '--cflags', action='store_true', default=False, help='show CFLAGS')
flags.add_argument('-x', '--cxxflags', action='store_true', default=False, help='show CXXFLAGS')
+parser.add_argument('-s', '--std', required=False, help='language standard flags for the -std= option')
args = parser.parse_args()
if args.cflags:
- print("{}".format(cflags[args.language]))
+ print("{}".format(get_cflags(args.language, args.std)))
elif args.cxxflags:
- print("{}".format(cxxflags[args.language]))
+ print("{}".format(get_cxxflags(args.language, args.std)))
else:
parser.print_help()
exit(1)
diff --git a/appveyor.yml b/appveyor.yml
index 25abcb342..dc96d0bca 100755..100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -65,7 +65,7 @@ build_script:
- set CCCL_OPTIONS=--cccl-muffle /W3
- set CHECK_OPTIONS=CSHARPOPTIONS=-platform:%Platform%
# Open dummy file descriptor to fix error on cygwin: ./configure: line 560: 0: Bad file descriptor
-- bash -c "exec 0</dev/null && ./autogen.sh && time ./configure --disable-dependency-tracking --disable-ccache CC=cccl CXX=cccl CFLAGS='-O2' CXXFLAGS='-O2' LDFLAGS='--cccl-link /LTCG' PCRE_CFLAGS='-I%PCRE_ROOT%/include -DPCRE_STATIC' PCRE_LIBS='-L%PCRE_ROOT%/lib/v110/%PCRE_PLATFORM%/Release/static/utf8 -lpcre8' --with-java='%JAVA_HOME%/bin/java.exe' --with-javac='%JAVA_HOME%/bin/javac.exe' --with-javaincl='%JAVA_HOME%/include' --without-perl5 --without-go --with-boost=C:/Libraries/boost || cat config.log"
+- bash -c "exec 0</dev/null && ./autogen.sh && time ./configure --disable-dependency-tracking --disable-ccache CC=cccl CXX=cccl CFLAGS='-O2' CXXFLAGS='-O2' LDFLAGS='--cccl-link /LTCG' PCRE_CFLAGS='-I%PCRE_ROOT%/include -DPCRE_STATIC' PCRE_LIBS='-L%PCRE_ROOT%/lib/v110/%PCRE_PLATFORM%/Release/static/utf8 -lpcre8' --without-perl5 --without-go --with-boost=C:/Libraries/boost || cat config.log"
- bash -c "time make -s"
test_script:
diff --git a/configure.ac b/configure.ac
index 1eb338617..6d4505875 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script.
dnl The macros which aren't shipped with the autotools are stored in the
dnl Tools/config directory in .m4 files.
-AC_INIT([swig],[3.0.6],[http://www.swig.org])
+AC_INIT([swig],[3.0.7],[http://www.swig.org])
dnl NB: When this requirement is increased to 2.60 or later, AC_PROG_SED
dnl definition below can be removed
@@ -340,6 +340,7 @@ PLATCXXFLAGS="$PLATCFLAGS"
if test x"$enable_cpp11_testing" = xyes; then
AC_LANG_PUSH([C++])
CXXFLAGS_SAVED=$CXXFLAGS
+ CXXFLAGS=
AX_CXX_COMPILE_STDCXX_11([noext], [nostop])
CXXFLAGS=$CXXFLAGS_SAVED
AC_LANG_POP([C++])
@@ -356,7 +357,7 @@ fi
# On darwin 10.7,10.8,10.9 using clang++, need to ensure using
# libc++ for tests and examples to run under mono. May affect
-# other language targets as well - problem is an OSX incompatibility
+# other language targets as well - problem is a Mac OS X incompatibility
# between libraries depending on libstdc++ and libc++.
CLANGXX=
$CXX -v 2>&1 | grep -i clang >/dev/null && CLANGXX=yes
@@ -463,6 +464,12 @@ fi])
AC_ARG_WITH(alllang, AS_HELP_STRING([--without-alllang], [Disable all languages]), with_alllang="$withval")
+if test "$with_alllang" = "no"; then
+ alllang_default=no
+else
+ alllang_default=yes
+fi
+
AC_CHECK_PROGS(PKGCONFIG, [pkg-config])
#--------------------------------------------------------------------
@@ -477,14 +484,14 @@ AC_ARG_WITH(tclconfig, AS_HELP_STRING([--without-tcl], [Disable Tcl])
AS_HELP_STRING([--with-tclconfig=path], [Set location of tclConfig.sh]), [with_tclconfig="$withval"], [with_tclconfig=])
AC_ARG_WITH(tcl,
[ --with-tcl=path Set location of Tcl package],[
- TCLPACKAGE="$withval"], [TCLPACKAGE=yes])
+ TCLPACKAGE="$withval"], [TCLPACKAGE="$alllang_default"])
AC_ARG_WITH(tclincl,[ --with-tclincl=path Set location of Tcl include directory],[
TCLINCLUDE="$ISYSTEM$withval"], [TCLINCLUDE=])
AC_ARG_WITH(tcllib,[ --with-tcllib=path Set location of Tcl library directory],[
TCLLIB="-L$withval"], [TCLLIB=])
# First, check for "--without-tcl" or "--with-tcl=no".
-if test x"${TCLPACKAGE}" = xno -o x"${with_alllang}" = xno; then
+if test x"${TCLPACKAGE}" = xno; then
AC_MSG_NOTICE([Disabling Tcl])
else
AC_MSG_CHECKING([for Tcl configuration])
@@ -605,10 +612,10 @@ PYLINK=
PYPACKAGE=
AC_ARG_WITH(python, AS_HELP_STRING([--without-python], [Disable Python])
-AS_HELP_STRING([--with-python=path], [Set location of Python executable]),[ PYBIN="$withval"], [PYBIN=yes])
+AS_HELP_STRING([--with-python=path], [Set location of Python executable]),[ PYBIN="$withval"], [PYBIN="$alllang_default"])
# First, check for "--without-python" or "--with-python=no".
-if test x"${PYBIN}" = xno -o x"${with_alllang}" = xno ; then
+if test x"${PYBIN}" = xno; then
AC_MSG_NOTICE([Disabling Python])
else
# First figure out the name of the Python executable
@@ -628,7 +635,7 @@ else
fi
fi
- if test $PYVER -le 2; then
+ if test $PYVER -eq 1 -o $PYVER -eq 2; then
AC_MSG_CHECKING(for Python prefix)
PYPREFIX=`($PYTHON -c "import sys; sys.stdout.write(sys.prefix)") 2>/dev/null`
AC_MSG_RESULT($PYPREFIX)
@@ -746,10 +753,10 @@ PY3LINK=
PY3PACKAGE=
AC_ARG_WITH(python3, AS_HELP_STRING([--without-python3], [Disable Python 3.x support])
-AS_HELP_STRING([--with-python3=path], [Set location of Python 3.x executable]),[ PY3BIN="$withval"], [PY3BIN=yes])
+AS_HELP_STRING([--with-python3=path], [Set location of Python 3.x executable]),[ PY3BIN="$withval"], [PY3BIN="$alllang_default"])
# First, check for "--without-python3" or "--with-python3=no".
-if test x"${PY3BIN}" = xno -o x"${with_alllang}" = xno ; then
+if test x"${PY3BIN}" = xno; then
AC_MSG_NOTICE([Disabling Python 3.x support])
else
if test "x$PY3BIN" = xyes; then
@@ -886,13 +893,13 @@ else
;;
*)PYTHON3DYNAMICLINKING="";;
esac
-fi
-AC_SUBST(PY3INCLUDE)
-AC_SUBST(PY3LIB)
-AC_SUBST(PY3LINK)
-AC_SUBST(PYTHON3DYNAMICLINKING)
-AC_CHECK_PROGS(PEP8, pep8)
+ AC_SUBST(PY3INCLUDE)
+ AC_SUBST(PY3LIB)
+ AC_SUBST(PY3LINK)
+ AC_SUBST(PYTHON3DYNAMICLINKING)
+ AC_CHECK_PROGS(PEP8, pep8)
+fi
#----------------------------------------------------------------
# Look for Perl5
@@ -901,10 +908,10 @@ AC_CHECK_PROGS(PEP8, pep8)
PERLBIN=
AC_ARG_WITH(perl5, AS_HELP_STRING([--without-perl5], [Disable Perl5])
-AS_HELP_STRING([--with-perl5=path], [Set location of Perl5 executable]),[ PERLBIN="$withval"], [PERLBIN=yes])
+AS_HELP_STRING([--with-perl5=path], [Set location of Perl5 executable]),[ PERLBIN="$withval"], [PERLBIN="$alllang_default"])
# First, check for "--without-perl5" or "--with-perl5=no".
-if test x"${PERLBIN}" = xno -o x"${with_alllang}" = xno ; then
+if test x"${PERLBIN}" = xno; then
AC_MSG_NOTICE([Disabling Perl5])
PERL=
else
@@ -1012,10 +1019,10 @@ OCTAVEBIN=
OCTAVE_SO=.oct
AC_ARG_WITH(octave, AS_HELP_STRING([--without-octave], [Disable Octave])
-AS_HELP_STRING([--with-octave=path], [Set location of Octave executable]),[OCTAVEBIN="$withval"], [OCTAVEBIN=yes])
+AS_HELP_STRING([--with-octave=path], [Set location of Octave executable]),[OCTAVEBIN="$withval"], [OCTAVEBIN="$alllang_default"])
# First, check for "--without-octave" or "--with-octave=no".
-if test x"${OCTAVEBIN}" = xno -o x"${with_alllang}" = xno ; then
+if test x"${OCTAVEBIN}" = xno; then
AC_MSG_NOTICE([Disabling Octave])
OCTAVE=
@@ -1029,7 +1036,7 @@ fi
if test -n "$OCTAVE"; then
AC_MSG_CHECKING([for mkoctfile])
- mkoctfile="`dirname ${OCTAVE}`/mkoctfile"
+ mkoctfile="$(dirname $OCTAVE)/$(basename $OCTAVE | sed -e 's/octave/mkoctfile/')"
AS_IF([test -x "${mkoctfile}"],[
AC_MSG_RESULT([${mkoctfile}])
],[
@@ -1097,11 +1104,11 @@ AC_SUBST(OCTAVE_LDFLAGS)
#----------------------------------------------------------------
AC_ARG_WITH(scilab, AS_HELP_STRING([--without-scilab], [Disable Scilab])
-AS_HELP_STRING([--with-scilab=path], [Set location of Scilab executable]),[SCILABBIN="$withval"], [SCILABBIN=yes])
+AS_HELP_STRING([--with-scilab=path], [Set location of Scilab executable]),[SCILABBIN="$withval"], [SCILABBIN="$alllang_default"])
AC_ARG_WITH(scilab-inc, [ --with-scilab-inc=path Set location of Scilab include directory], [SCILABINCDIR="$withval"], [SCILABINCDIR=""])
# First, check for "--without-scilab" or "--with-scilab=no".
-if test x"${SCILABBIN}" = xno -o x"${with_alllang}" = xno ; then
+if test x"${SCILABBIN}" = xno; then
AC_MSG_NOTICE([Disabling Scilab])
SCILAB=
else
@@ -1183,23 +1190,97 @@ AC_SUBST(SCILABOPT)
#----------------------------------------------------------------
AC_ARG_WITH(java, AS_HELP_STRING([--without-java], [Disable Java])
-AS_HELP_STRING([--with-java=path], [Set location of java executable]),[JAVABIN="$withval"], [JAVABIN=yes])
+AS_HELP_STRING([--with-java=path], [Set location of java executable]),[JAVABIN="$withval"], [JAVABIN="$alllang_default"])
AC_ARG_WITH(javac, [ --with-javac=path Set location of javac executable],[JAVACBIN="$withval"], [JAVACBIN=])
# First, check for "--without-java" or "--with-java=no".
-if test x"${JAVABIN}" = xno -o x"${with_alllang}" = xno ; then
+if test x"${JAVABIN}" = xno; then
AC_MSG_NOTICE([Disabling Java])
JAVA=
else
+dnl Detect everything we need for Java: java for running Java tests, javac for
+dnl compiling them and C headers for compiling C code.
+dnl
+dnl If JAVA_HOME is defined and contains everything needed, as it's supposed to,
+dnl just use it. Otherwise try to locate the necessary files in the path.
+case $host in
+ *-*-cygwin*)
+ dnl Ensure that JAVA_HOME is in the form we can use, it's typically set to Windows path by the installer.
+ if test -n "$JAVA_HOME"; then
+ JAVA_HOME=`cygpath --mixed "$JAVA_HOME"`
+ fi
+ ;;
+ *-*-mingw*)
+ if test -n "$JAVA_HOME"; then
+ JAVA_HOME=`${srcdir}/Tools/convertpath -u "$JAVA_HOME"`
+ fi
+ ;;
+ *-*-darwin*)
+ dnl Under OS X JAVA_HOME is not set by default, try to use the system default JRE.
+ if test -z "$JAVA_HOME" -a -x /usr/libexec/java_home; then
+ JAVA_HOME=`/usr/libexec/java_home`
+ fi
+ dnl The JAVA_HOME doesn't contain the JDK headers though, but they seem to
+ dnl always be in the same location, according to Apple JNI documentation.
+ JAVA_OSX_STD_INCDIR="/System/Library/Frameworks/JavaVM.framework/Headers"
+ if test -r "$JAVA_OSX_STD_INCDIR/jni.h"; then
+ JAVA_HOME_INCDIR=$JAVA_OSX_STD_INCDIR
+ fi
+ ;;
+esac
+
+AC_MSG_CHECKING(for java JDK)
+if test -n "$JAVA_HOME"; then
+ dnl Don't complain about missing executables/headers if they had been
+ dnl explicitly overridden from the command line, but otherwise verify that we
+ dnl have everything we need.
+ java_home_ok=1
+ if test -z "$JAVABIN" -a ! -x "$JAVA_HOME/bin/java"; then
+ AC_MSG_WARN([No java executable under JAVA_HOME.])
+ java_home_ok=0
+ fi
+ if test -z "$JAVACBIN" -a ! -x "$JAVA_HOME/bin/javac"; then
+ AC_MSG_WARN([No javac executable under JAVA_HOME.])
+ java_home_ok=0
+ fi
+
+ dnl By default the headers are under JAVA_HOME/include, but OS X is special
+ dnl and defines JAVA_HOME_INCDIR differently above.
+ if test -z "$JAVA_HOME_INCDIR"; then
+ JAVA_HOME_INCDIR="$JAVA_HOME/include"
+ fi
+ if test -z "$JAVAINCDIR" -a ! -r "$JAVA_HOME_INCDIR/jni.h"; then
+ AC_MSG_WARN([No java headers under JAVA_HOME (does it point to a JDK and not just JRE?).])
+ java_home_ok=0
+ fi
+ if test "$java_home_ok" = 1; then
+ AC_MSG_RESULT([found (in $JAVA_HOME)])
+ else
+ AC_MSG_RESULT(no)
+ AC_MSG_WARN([JAVA_HOME ($JAVA_HOME) is defined but does not point to a complete JDK installation, ignoring it.])
+ JAVA_HOME=
+ fi
+else
+ AC_MSG_RESULT([no (JAVA_HOME is not defined)])
+fi
+
if test "x$JAVABIN" = xyes; then
- AC_CHECK_PROGS(JAVA, java kaffe guavac)
+ if test -n "$JAVA_HOME"; then
+ JAVA="$JAVA_HOME/bin/java"
+ else
+ AC_CHECK_PROGS(JAVA, java kaffe guavac)
+ fi
else
JAVA="$JAVABIN"
fi
if test -z "$JAVACBIN"; then
- AC_CHECK_PROGS(JAVAC, javac)
+ if test -n "$JAVA_HOME"; then
+ JAVAC="$JAVA_HOME/bin/javac"
+ else
+ AC_CHECK_PROGS(JAVAC, javac)
+ fi
else
JAVAC="$JAVACBIN"
fi
@@ -1209,22 +1290,27 @@ AC_ARG_WITH(javaincl, [ --with-javaincl=path Set location of Java include di
JAVAINC=""
if test -z "$JAVAINCDIR" ; then
- JAVAINCDIR="/usr/j2sdk*/include /usr/local/j2sdk*/include /usr/jdk*/include /usr/local/jdk*/include /opt/j2sdk*/include /opt/jdk*/include /usr/java/include /usr/java/j2sdk*/include /usr/java/jdk*/include /usr/local/java/include /opt/java/include /usr/include/java /usr/local/include/java /usr/lib/java/include /usr/lib/jvm/java*/include /usr/lib64/jvm/java*/include /usr/include/kaffe /usr/local/include/kaffe /usr/include"
+ if test -n "$JAVA_HOME"; then
+ JAVAINCDIR="$JAVA_HOME_INCDIR"
+ JAVAINC=-I\"$JAVAINCDIR\"
+ else
+ JAVAINCDIR="/usr/j2sdk*/include /usr/local/j2sdk*/include /usr/jdk*/include /usr/local/jdk*/include /opt/j2sdk*/include /opt/jdk*/include /usr/java/include /usr/java/j2sdk*/include /usr/java/jdk*/include /usr/local/java/include /opt/java/include /usr/include/java /usr/local/include/java /usr/lib/java/include /usr/lib/jvm/java*/include /usr/lib64/jvm/java*/include /usr/include/kaffe /usr/local/include/kaffe /usr/include"
- # Add in default installation directory on Windows for Cygwin
- case $host in
- *-*-cygwin* | *-*-mingw*) JAVAINCDIR="c:/Program*Files*/Java/jdk*/include d:/Program*Files*/Java/jdk*/include c:/j2sdk*/include d:/j2sdk*/include c:/jdk*/include d:/jdk*/include $JAVAINCDIR";;
- *-*-darwin*) JAVAINCDIR="/System/Library/Frameworks/JavaVM.framework/Headers $JAVAINCDIR";;
- *);;
- esac
+ # Add in default installation directory on Windows for Cygwin
+ case $host in
+ *-*-cygwin* | *-*-mingw*) JAVAINCDIR="c:/Program*Files*/Java/jdk*/include d:/Program*Files*/Java/jdk*/include c:/j2sdk*/include d:/j2sdk*/include c:/jdk*/include d:/jdk*/include $JAVAINCDIR";;
+ *-*-darwin*) JAVAINCDIR="$JAVA_OSX_STD_INCDIR $JAVAINCDIR";;
+ *);;
+ esac
- for d in $JAVAINCDIR ; do
- if test -r "$d/jni.h" ; then
- JAVAINCDIR=$d
- JAVAINC=-I\"$d\"
- break
- fi
- done
+ for d in $JAVAINCDIR ; do
+ if test -r "$d/jni.h" ; then
+ JAVAINCDIR=$d
+ JAVAINC=-I\"$d\"
+ break
+ fi
+ done
+ fi
else
if test -r "$JAVAINCDIR/jni.h" ; then
JAVAINC=-I\"$JAVAINCDIR\"
@@ -1320,10 +1406,10 @@ AC_SUBST(JAVACFLAGS)
#----------------------------------------------------------------
# Look for Javascript
#----------------------------------------------------------------
-AC_ARG_WITH(javascript, AS_HELP_STRING([--without-javascript], [Disable Javascript]), [with_javascript="$withval"], [with_javascript=yes])
+AC_ARG_WITH(javascript, AS_HELP_STRING([--without-javascript], [Disable Javascript]), [with_javascript="$withval"], [with_javascript="$alllang_default"])
# First, check for "--without-javascript" or "--with-javascript=no".
-if test x"${with_javascript}" = xno -o x"${with_alllang}" = xno ; then
+if test x"${with_javascript}" = xno; then
AC_MSG_NOTICE([Disabling Javascript])
JAVASCRIPT=
else
@@ -1367,14 +1453,14 @@ else
# check for include files
AC_MSG_CHECKING(for JavaScriptCore/JavaScript.h)
- AC_ARG_WITH(jscoreinc, [ --with-jscinc=path Set location of Javascript include directory], [JSCOREINCDIR="$withval"], [JSCOREINCDIR=])
+ AC_ARG_WITH(jscoreinc, [ --with-jscinc=path Set location of Javascript include directory], [JSCOREINCDIR="$withval"], [JSCOREINCDIR=])
JSCOREVERSION=
if test -z "$JSCOREINCDIR"; then
JSCOREINCDIR="/usr/include/ /usr/local/include/"
- # Add in default directory for JavaScriptCore headers for Linux and MacOSX
+ # Add in default directory for JavaScriptCore headers for Linux and Mac OS X
case $host in
*-*-linux*)
JSCOREINCDIR="/usr/include/webkit-1.0/ /usr/include/webkitgtk-1.0/ /usr/local/include/webkit-1.0/JavaScriptCore/ $JSCOREINCDIR"
@@ -1401,7 +1487,7 @@ else
fi
# check for JavaScriptCore/Webkit libraries
- AC_ARG_WITH(jscorelib,[ --with-jsclib =path Set location of the JavaScriptCore/Webkit library directory],[JSCORELIB="-L$withval"], [JSCORELIB=])
+ AC_ARG_WITH(jscorelib,[ --with-jsclib=path Set location of the JavaScriptCore/Webkit library directory],[JSCORELIB="-L$withval"], [JSCORELIB=])
if test -z "$JSCORELIB" -a -n "$PKGCONFIG"; then
AC_MSG_CHECKING(for JavaScriptCore/Webkit library)
@@ -1425,11 +1511,11 @@ else
# check for include files
AC_MSG_CHECKING(for V8 Javascript v8.h)
- AC_ARG_WITH(jsv8inc, [ --with-jsv8inc=path Set location of Javascript v8 include directory], [JSV8INCDIR="$withval"])
+ AC_ARG_WITH(jsv8inc, [ --with-jsv8inc=path Set location of Javascript v8 include directory], [JSV8INCDIR="$withval"])
# if not include dir is specified we try to find
if test -z "$JSV8INCDIR"; then
- # Add in default directory for JavaScriptCore headers for Linux and MacOSX
+ # Add in default directory for JavaScriptCore headers for Linux and Mac OS X
case $host in
*-*-linux*)
JSV8INCDIR="/usr/include /usr/local/include/ $JSV8INCDIR"
@@ -1458,7 +1544,7 @@ else
# check for V8 library
AC_MSG_CHECKING(for V8 Javascript library)
- AC_ARG_WITH(jsv8lib,[ --with-jsv8lib=path Set location of V8 Javascript library directory],[JSV8LIBDIR="$withval"], [JSV8LIB=])
+ AC_ARG_WITH(jsv8lib,[ --with-jsv8lib=path Set location of V8 Javascript library directory],[JSV8LIBDIR="$withval"], [JSV8LIB=])
v8libdirs="$JSV8LIBDIR /usr/lib64/ /usr/local/lib64/ /usr/lib/ /usr/local/lib/"
for d in $v8libdirs ; do
@@ -1513,11 +1599,11 @@ AC_SUBST(NODEGYP)
#----------------------------------------------------------------
AC_ARG_WITH(gcj, AS_HELP_STRING([--without-gcj], [Disable GCJ])
-AS_HELP_STRING([--with-gcj=path], [Set location of gcj executable]),[GCJBIN="$withval"], [GCJBIN=yes])
+AS_HELP_STRING([--with-gcj=path], [Set location of gcj executable]),[GCJBIN="$withval"], [GCJBIN="$alllang_default"])
AC_ARG_WITH(gcjh, [ --with-gcjh=path Set location of gcjh executable],[GCJHBIN="$withval"], [GCJHBIN=])
# First, check for "--without-gcj" or "--with-gcj=no".
-if test x"${GCJBIN}" = xno -o x"${with_alllang}" = xno ; then
+if test x"${GCJBIN}" = xno; then
AC_MSG_NOTICE([Disabling GCJ])
else
if test "x$GCJBIN" = xyes; then
@@ -1541,13 +1627,13 @@ AC_SUBST(GCJH)
#----------------------------------------------------------------
AC_ARG_WITH(android, AS_HELP_STRING([--without-android], [Disable Android])
-AS_HELP_STRING([--with-android=path], [Set location of android executable]),[ANDROIDBIN="$withval"], [ANDROIDBIN=yes])
-AC_ARG_WITH(adb, [ --with-adb=path Set location of adb executable - Android Debug Bridge],[ADBBIN="$withval"], [ADBBIN=])
-AC_ARG_WITH(ant, [ --with-ant=path Set location of ant executable for Android],[ANTBIN="$withval"], [ANTBIN=])
-AC_ARG_WITH(ndk-build, [ --with-ndk-build=path Set location of Android ndk-build executable],[NDKBUILDBIN="$withval"], [NDKBUILDBIN=])
+AS_HELP_STRING([--with-android=path], [Set location of android executable]),[ANDROIDBIN="$withval"], [ANDROIDBIN="$alllang_default"])
+AC_ARG_WITH(adb, [ --with-adb=path Set location of adb executable - Android Debug Bridge],[ADBBIN="$withval"], [ADBBIN=])
+AC_ARG_WITH(ant, [ --with-ant=path Set location of ant executable for Android],[ANTBIN="$withval"], [ANTBIN=])
+AC_ARG_WITH(ndk-build, [ --with-ndk-build=path Set location of Android ndk-build executable],[NDKBUILDBIN="$withval"], [NDKBUILDBIN=])
# First, check for "--without-android" or "--with-android=no".
-if test x"${ANDROIDBIN}" = xno -o x"${with_alllang}" = xno ; then
+if test x"${ANDROIDBIN}" = xno; then
AC_MSG_NOTICE([Disabling Android])
ANDROID=
else
@@ -1590,16 +1676,16 @@ GUILE_CFLAGS=
GUILE_LIBS=
AC_ARG_WITH(guile-config, AS_HELP_STRING([--without-guile], [Disable Guile])
- AS_HELP_STRING([--with-guile-config=path], [Set location of guile-config]),[ GUILE_CONFIG="$withval"], [GUILE_CONFIG=])
+AS_HELP_STRING([--with-guile-config=path], [Set location of guile-config]),[ GUILE_CONFIG="$withval"], [GUILE_CONFIG=])
AC_ARG_WITH(guile,[ --with-guile=path Set location of Guile executable],[
- GUILE="$withval"], [GUILE=yes])
+ GUILE="$withval"], [GUILE="$alllang_default"])
AC_ARG_WITH(guile-cflags,[ --with-guile-cflags=cflags Set cflags required to compile against Guile],[
GUILE_CFLAGS="$withval"])
AC_ARG_WITH(guile-libs,[ --with-guile-libs=ldflags Set ldflags needed to link with Guile],[
GUILE_LIBS="$withval"])
# First, check for "--without-guile" or "--with-guile=no".
-if test x"${GUILE}" = xno -o x"${with_alllang}" = xno ; then
+if test x"${GUILE}" = xno; then
AC_MSG_NOTICE([Disabling Guile])
else
if test -z "$GUILE_CONFIG" ; then
@@ -1652,11 +1738,11 @@ AC_SUBST(GUILE_LIBS)
#----------------------------------------------------------------
AC_ARG_WITH(mzscheme, AS_HELP_STRING([--without-mzscheme], [Disable MzScheme])
-AS_HELP_STRING([--with-mzscheme=path], [Set location of MzScheme executable]),[ MZSCHEMEBIN="$withval"], [MZSCHEMEBIN=yes])
+AS_HELP_STRING([--with-mzscheme=path], [Set location of MzScheme executable]),[ MZSCHEMEBIN="$withval"], [MZSCHEMEBIN="$alllang_default"])
AC_ARG_WITH(mzc, AS_HELP_STRING([--with-mzc=path], [Set location of MzScheme's mzc]), [ MZCBIN="$withval"], [MZCBIN=])
# First, check for "--without-mzscheme" or "--with-mzscheme=no".
-if test x"${MZSCHEMEBIN}" = xno -o x"${with_alllang}" = xno ; then
+if test x"${MZSCHEMEBIN}" = xno; then
AC_MSG_NOTICE([Disabling MzScheme])
MZC=
else
@@ -1696,11 +1782,11 @@ AC_SUBST(MZDYNOBJ)
RUBYBIN=
AC_ARG_WITH(ruby, AS_HELP_STRING([--without-ruby], [Disable Ruby])
-AS_HELP_STRING([--with-ruby=path], [Set location of Ruby executable]),[ RUBYBIN="$withval"], [RUBYBIN=yes])
+AS_HELP_STRING([--with-ruby=path], [Set location of Ruby executable]),[ RUBYBIN="$withval"], [RUBYBIN="$alllang_default"])
# First, check for "--without-ruby" or "--with-ruby=no".
RUBYSO=$SO
-if test x"${RUBYBIN}" = xno -o x"${with_alllang}" = xno ; then
+if test x"${RUBYBIN}" = xno; then
AC_MSG_NOTICE([Disabling Ruby])
RUBY=
else
@@ -1824,10 +1910,10 @@ AC_SUBST(RUBYDYNAMICLINKING)
PHPBIN=
AC_ARG_WITH(php, AS_HELP_STRING([--without-php], [Disable PHP])
-AS_HELP_STRING([--with-php=path], [Set location of PHP executable]),[ PHPBIN="$withval"], [PHPBIN=yes])
+AS_HELP_STRING([--with-php=path], [Set location of PHP executable]),[ PHPBIN="$withval"], [PHPBIN="$alllang_default"])
# First, check for "--without-php" or "--with-php=no".
-if test x"${PHPBIN}" = xno -o x"${with_alllang}" = xno ; then
+if test x"${PHPBIN}" = xno; then
AC_MSG_NOTICE([Disabling PHP])
PHP=
else
@@ -1867,7 +1953,7 @@ AC_SUBST(PHPINC)
# Look for ocaml
#----------------------------------------------------------------
-AC_ARG_WITH(ocaml, AS_HELP_STRING([--without-ocaml], [Disable OCaml]), [with_ocaml="$withval"], [with_ocaml=yes])
+AC_ARG_WITH(ocaml, AS_HELP_STRING([--without-ocaml], [Disable OCaml]), [with_ocaml="$withval"], [with_ocaml="$alllang_default"])
AC_ARG_WITH(ocamlc,[ --with-ocamlc=path Set location of ocamlc executable],[ OCAMLC="$withval"], [OCAMLC=])
AC_ARG_WITH(ocamldlgen,[ --with-ocamldlgen=path Set location of ocamldlgen],[ OCAMLDLGEN="$withval" ], [OCAMLDLGEN=])
AC_ARG_WITH(ocamlfind,[ --with-ocamlfind=path Set location of ocamlfind],[OCAMLFIND="$withval"],[OCAMLFIND=])
@@ -1875,33 +1961,33 @@ AC_ARG_WITH(ocamlmktop,[ --with-ocamlmktop=path Set location of ocamlmktop exe
AC_ARG_WITH(camlp4,[ --with-camlp4=path Set location of camlp4 executable],[ CAMLP4="$withval"], [CAMLP4=])
# First, check for "--without-ocaml" or "--with-ocaml=no".
-if test x"${with_ocaml}" = xno -o x"${with_alllang}" = xno ; then
+if test x"${with_ocaml}" = xno; then
AC_MSG_NOTICE([Disabling OCaml])
OCAMLC=
else
AC_MSG_CHECKING(for Ocaml DL load generator)
if test -z "$OCAMLDLGEN"; then
- AC_CHECK_PROGS(OCAMLDLGEN, ocamldlgen, :)
+ AC_CHECK_PROGS(OCAMLDLGEN, ocamldlgen)
fi
AC_MSG_CHECKING(for Ocaml package tool)
if test -z "$OCAMLFIND"; then
- AC_CHECK_PROGS(OCAMLFIND, ocamlfind, :)
+ AC_CHECK_PROGS(OCAMLFIND, ocamlfind)
fi
AC_MSG_CHECKING(for Ocaml compiler)
if test -z "$OCAMLC"; then
- AC_CHECK_PROGS(OCAMLC, ocamlc, :)
+ AC_CHECK_PROGS(OCAMLC, ocamlc)
fi
AC_MSG_CHECKING(for Ocaml toplevel creator)
if test -z "$OCAMLMKTOP"; then
- AC_CHECK_PROGS(OCAMLMKTOP, ocamlmktop, :)
+ AC_CHECK_PROGS(OCAMLMKTOP, ocamlmktop)
fi
AC_MSG_CHECKING(for Ocaml Pre-Processor-Pretty-Printer)
if test -z "$CAMLP4"; then
- AC_CHECK_PROGS(CAMLP4, camlp4, :)
+ AC_CHECK_PROGS(CAMLP4, camlp4)
fi
fi # Disabling ocaml
@@ -1919,10 +2005,10 @@ AC_SUBST(CAMLP4)
# Priority: configure option, automatic search
PIKEBIN=
AC_ARG_WITH(pike, AS_HELP_STRING([--without-pike], [Disable Pike])
-AS_HELP_STRING([--with-pike=path], [Set location of Pike executable]),[PIKEBIN="$withval"], [PIKEBIN=yes])
+AS_HELP_STRING([--with-pike=path], [Set location of Pike executable]),[PIKEBIN="$withval"], [PIKEBIN="$alllang_default"])
# First, check for "--without-pike" or "--with-pike=no".
-if test x"${PIKEBIN}" = xno -o x"${with_alllang}" = xno ; then
+if test x"${PIKEBIN}" = xno; then
AC_MSG_NOTICE([Disabling Pike])
PIKEBIN=
else
@@ -1989,10 +2075,10 @@ CHICKENLIB=
AC_ARG_WITH(chicken, AS_HELP_STRING([--without-chicken], [Disable CHICKEN])
-AS_HELP_STRING([--with-chicken=path], [Set location of CHICKEN executable]),[ CHICKENBIN="$withval"], [CHICKENBIN=yes])
+AS_HELP_STRING([--with-chicken=path], [Set location of CHICKEN executable]),[ CHICKENBIN="$withval"], [CHICKENBIN="$alllang_default"])
# First, check for "--without-chicken" or "--with-chicken=no".
-if test x"${CHICKENBIN}" = xno -o x"${with_alllang}" = xno ; then
+if test x"${CHICKENBIN}" = xno; then
AC_MSG_NOTICE([Disabling CHICKEN])
else
@@ -2083,12 +2169,12 @@ AC_SUBST(CHICKENSHAREDLIB)
# Look for C#
#----------------------------------------------------------------
-AC_ARG_WITH(csharp, AS_HELP_STRING([--without-csharp], [Disable CSharp]), [with_csharp="$withval"], [with_csharp=yes])
+AC_ARG_WITH(csharp, AS_HELP_STRING([--without-csharp], [Disable CSharp]), [with_csharp="$withval"], [with_csharp="$alllang_default"])
AC_ARG_WITH(cil-interpreter, [ --with-cil-interpreter=path Set location of CIL interpreter for CSharp],[CSHARPBIN="$withval"], [CSHARPBIN=])
AC_ARG_WITH(csharp-compiler, [ --with-csharp-compiler=path Set location of CSharp compiler],[CSHARPCOMPILERBIN="$withval"], [CSHARPCOMPILERBIN=])
# First, check for "--without-csharp" or "--with-csharp=no".
-if test x"${with_csharp}" = xno -o x"${with_alllang}" = xno ; then
+if test x"${with_csharp}" = xno; then
AC_MSG_NOTICE([Disabling CSharp])
CSHARPCOMPILER=
else
@@ -2206,14 +2292,14 @@ LUALINK=
# LUABIN will be cleared if certain dependencies cannot be found
AC_ARG_WITH(lua, AS_HELP_STRING([--without-lua], [Disable Lua])
-AS_HELP_STRING([--with-lua=path], [Set location of Lua executable]),[ LUABIN="$withval"], [LUABIN=yes])
+AS_HELP_STRING([--with-lua=path], [Set location of Lua executable]),[ LUABIN="$withval"], [LUABIN="$alllang_default"])
AC_ARG_WITH(luaincl,[ --with-luaincl=path Set location of Lua include directory],[
LUAINCLUDE="$withval"], [LUAINCLUDE=])
AC_ARG_WITH(lualib,[ --with-lualib=path Set location of Lua library directory],[
LUALIB="$withval"], [LUALIB=])
# First, check for "--without-lua" or "--with-lua=no".
-if test x"${LUABIN}" = xno -o x"${with_alllang}" = xno ; then
+if test x"${LUABIN}" = xno; then
AC_MSG_NOTICE([Disabling Lua])
else
@@ -2323,10 +2409,10 @@ AC_SUBST(LUABIN)
ALLEGROCLBIN=
AC_ARG_WITH(allegrocl, AS_HELP_STRING([--without-allegrocl], [Disable Allegro CL])
-AS_HELP_STRING([--with-allegrocl=path], [Set location of Allegro CL executable (alisp)]),[ ALLEGROCLBIN="$withval"], [ALLEGROCLBIN=yes])
+AS_HELP_STRING([--with-allegrocl=path], [Set location of Allegro CL executable (alisp)]),[ ALLEGROCLBIN="$withval"], [ALLEGROCLBIN="$alllang_default"])
# First, check for "--without-allegrocl" or "--with-allegrocl=no".
-if test x"${ALLEGROCLBIN}" = xno -o x"${with_alllang}" = xno ; then
+if test x"${ALLEGROCLBIN}" = xno; then
AC_MSG_NOTICE([Disabling Allegro CL])
ALLEGROCLBIN=
else
@@ -2346,10 +2432,10 @@ AC_SUBST(ALLEGROCLBIN)
CLISPBIN=
AC_ARG_WITH(clisp, AS_HELP_STRING([--without-clisp], [Disable CLISP])
-AS_HELP_STRING([--with-clisp=path], [Set location of CLISP executable (clisp)]),[ CLISPBIN="$withval"], [CLISPBIN=yes])
+AS_HELP_STRING([--with-clisp=path], [Set location of CLISP executable (clisp)]),[ CLISPBIN="$withval"], [CLISPBIN="$alllang_default"])
# First, check for "--without-clisp" or "--with-clisp=no".
-if test x"${CLISPBIN}" = xno -o x"${with_alllang}" = xno ; then
+if test x"${CLISPBIN}" = xno; then
AC_MSG_NOTICE([Disabling CLISP])
CLISPBIN=
else
@@ -2369,10 +2455,10 @@ AC_SUBST(CLISPBIN)
RBIN=
AC_ARG_WITH(r, AS_HELP_STRING([--without-r], [Disable R])
-AS_HELP_STRING([--with-r=path], [Set location of R executable (r)]),[ RBIN="$withval"], [RBIN=yes])
+AS_HELP_STRING([--with-r=path], [Set location of R executable (r)]),[ RBIN="$withval"], [RBIN="$alllang_default"])
# First, check for "--without-r" or "--with-r=no".
-if test x"${RBIN}" = xno -o x"${with_alllang}" = xno ; then
+if test x"${RBIN}" = xno; then
AC_MSG_NOTICE([Disabling R])
RBIN=
else
@@ -2390,9 +2476,9 @@ AC_SUBST(RBIN)
#----------------------------------------------------------------
AC_ARG_WITH(go, AS_HELP_STRING([--without-go], [Disable Go])
-AS_HELP_STRING([--with-go=path], [Set location of Go compiler]),[GOBIN="$withval"], [GOBIN=yes])
+AS_HELP_STRING([--with-go=path], [Set location of Go compiler]),[GOBIN="$withval"], [GOBIN="$alllang_default"])
-if test x"${GOBIN}" = xno -o x"${with_alllang}" = xno ; then
+if test x"${GOBIN}" = xno; then
AC_MSG_NOTICE([Disabling Go])
GO=
GOC=
@@ -2515,13 +2601,13 @@ AC_SUBST(GOVERSIONOPTION)
# Look for D
#----------------------------------------------------------------
-AC_ARG_WITH(d, AS_HELP_STRING([--without-d], [Disable D]), [with_d="$withval"], [with_d=yes])
+AC_ARG_WITH(d, AS_HELP_STRING([--without-d], [Disable D]), [with_d="$withval"], [with_d="$alllang_default"])
AC_ARG_WITH(d1-compiler, [ --with-d1-compiler=path Set location of D1/Tango compiler (DMD compatible)],[D1COMPILERBIN="$withval"], [D1COMPILERBIN=])
AC_ARG_WITH(d2-compiler, [ --with-d2-compiler=path Set location of D2 compiler (DMD compatible)],[D2COMPILERBIN="$withval"], [D2COMPILERBIN=])
# First, check for "--without-d" or "--with-d=no".
-if test x"${with_d}" = xno -o x"${with_alllang}" = xno ; then
+if test x"${with_d}" = xno; then
AC_MSG_NOTICE([Disabling D])
D1COMPILER=
D2COMPILER=
@@ -2790,6 +2876,16 @@ AC_SUBST(SKIP_ANDROID)
ABS_SRCDIR=`(cd ${srcdir} && pwd)`
+dnl Under Cygwin, we may need native absolute path as it is used by SWIG, which
+dnl may be a native, and not a Cygwin, program (this is the case when it's
+dnl built using MinGW or cccl compiler in Cygwin environment). However it may,
+dnl although this is probably more rare, also be built as a Cygwin program.
+dnl Using "mixed" path like we do here allows the path to work in both cases.
+case $host in
+ *-*-mingw* ) ABS_SRCDIR=`${srcdir}/Tools/convertpath -m $ABS_SRCDIR` ;;
+ *-*-cygwin* ) ABS_SRCDIR=`cygpath --mixed $ABS_SRCDIR` ;;
+esac
+
# Root directory
ROOT_DIR=`pwd`
case $host in
@@ -2820,19 +2916,27 @@ AC_SUBST(swig_lib)
AC_DEFINE_DIR(SWIG_LIB, swig_lib, [Directory for SWIG system-independent libraries])
case $build in
- # Windows does not understand unix directories. Convert into a windows directory with drive letter.
- *-*-mingw*) SWIG_LIB_WIN_UNIX=`cmd //c echo $SWIG_LIB | sed -e "s/[ ]*$//"`;; # This echo converts unix to mixed paths. Then zap unexpected trailing space.
- *-*-cygwin*) SWIG_LIB_WIN_UNIX=`cygpath --mixed "$SWIG_LIB"`;;
- *) SWIG_LIB_WIN_UNIX="";;
+ # Windows does not understand unix directories. Convert into a windows directory with drive letter.
+ *-*-mingw*) SWIG_LIB_WIN_UNIX=`${srcdir}/Tools/convertpath -m $SWIG_LIB`;;
+ *-*-cygwin*) SWIG_LIB_WIN_UNIX=`cygpath --mixed "$SWIG_LIB"`;;
+ *) SWIG_LIB_WIN_UNIX="";;
esac
AC_DEFINE_UNQUOTED(SWIG_LIB_WIN_UNIX, ["$SWIG_LIB_WIN_UNIX"], [Directory for SWIG system-independent libraries (Unix install on native Windows)])
-# For testing - Windows builds of SWIG do not need SWIG_LIB set
-AC_EGREP_CPP([yes],
-[#ifdef _WIN32
- yes
-#endif
-], [SWIG_LIB_PREINST=], [SWIG_LIB_PREINST=$ABS_SRCDIR/Lib])
+dnl For testing purposes, don't set SWIG_LIB_PREINST when building SWIG in the
+dnl source directory under Windows because it is supposed to work without
+dnl SWIG_LIB being set at all in this particular case.
+if test "${srcdir}" = "."; then
+ AC_EGREP_CPP([yes],
+ [#ifdef _WIN32
+ yes
+ #endif
+ ], [SWIG_LIB_PREINST=], [SWIG_LIB_PREINST=$ABS_SRCDIR/Lib])
+else
+ dnl When not building in source directory, we must always set SWIG_LIB,
+ dnl even under Windows, as things couldn't work without it.
+ SWIG_LIB_PREINST=$ABS_SRCDIR/Lib
+fi
AC_SUBST(SWIG_LIB_PREINST)
AC_CONFIG_FILES([