summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml40
-rw-r--r--ANNOUNCE8
-rw-r--r--CCache/ccache.c13
-rw-r--r--CCache/ccache.h4
-rw-r--r--CCache/execute.c1
-rw-r--r--CCache/stats.c5
-rw-r--r--CCache/unify.c3
-rw-r--r--CCache/util.c9
-rw-r--r--CHANGES240
-rw-r--r--CHANGES.current183
-rw-r--r--Doc/Manual/CPlusPlus11.html49
-rw-r--r--Doc/Manual/Contents.html14
-rw-r--r--Doc/Manual/Makefile1
-rw-r--r--Doc/Manual/Python.html336
-rw-r--r--Doc/Manual/Scilab.html23
-rw-r--r--Doc/Manual/Sections.html2
-rw-r--r--Doc/Manual/Typemaps.html2
-rw-r--r--Examples/Makefile.in24
-rw-r--r--Examples/lua/arrays/example.i9
-rw-r--r--Examples/python/import_packages/Makefile10
-rw-r--r--Examples/python/import_packages/README4
-rw-r--r--Examples/python/import_packages/namespace_pkg/Makefile17
-rw-r--r--Examples/python/import_packages/namespace_pkg/README25
-rw-r--r--Examples/python/import_packages/namespace_pkg/nonpkg.py5
-rw-r--r--Examples/python/import_packages/namespace_pkg/normal.py7
-rw-r--r--Examples/python/import_packages/namespace_pkg/nstest.py45
-rw-r--r--Examples/python/import_packages/namespace_pkg/robin.i7
-rw-r--r--Examples/python/import_packages/namespace_pkg/runme.py17
-rw-r--r--Examples/python/import_packages/namespace_pkg/split.py9
-rw-r--r--Examples/python/import_packages/namespace_pkg/zipsplit.py9
-rw-r--r--Examples/python/import_packages/split_modules/Makefile26
-rw-r--r--Examples/python/import_packages/split_modules/README7
-rw-r--r--Examples/python/import_packages/split_modules/vanilla/Makefile18
-rw-r--r--Examples/python/import_packages/split_modules/vanilla/pkg1/Makefile18
-rw-r--r--Examples/python/import_packages/split_modules/vanilla/pkg1/__init__.py1
-rw-r--r--Examples/python/import_packages/split_modules/vanilla/pkg1/foo.i10
-rw-r--r--Examples/python/import_packages/split_modules/vanilla/runme.py10
-rw-r--r--Examples/python/import_packages/split_modules/vanilla_split/Makefile22
-rw-r--r--Examples/python/import_packages/split_modules/vanilla_split/foo.i10
-rw-r--r--Examples/python/import_packages/split_modules/vanilla_split/pkg1/__init__.py1
-rw-r--r--Examples/python/import_packages/split_modules/vanilla_split/runme.py10
-rw-r--r--Examples/test-suite/common.mk20
-rw-r--r--Examples/test-suite/constant_directive.i3
-rw-r--r--Examples/test-suite/cpp11_type_aliasing.i76
-rw-r--r--Examples/test-suite/csharp/director_pass_by_value_runme.cs43
-rw-r--r--Examples/test-suite/default_args_c.i14
-rw-r--r--Examples/test-suite/director_pass_by_value.i30
-rw-r--r--Examples/test-suite/errors/c_default_error.i4
-rw-r--r--Examples/test-suite/errors/c_default_error.stderr0
-rw-r--r--Examples/test-suite/errors/c_varargs.i3
-rw-r--r--Examples/test-suite/errors/c_varargs.stderr0
-rw-r--r--Examples/test-suite/errors/cpp_inherit_ignored.i19
-rw-r--r--Examples/test-suite/errors/cpp_inherit_ignored.stderr3
-rw-r--r--Examples/test-suite/errors/cpp_overload.i15
-rw-r--r--Examples/test-suite/errors/cpp_overload.stderr0
-rw-r--r--Examples/test-suite/errors/cpp_private_defvalue.i7
-rw-r--r--Examples/test-suite/errors/cpp_private_defvalue.stderr0
-rw-r--r--Examples/test-suite/errors/cpp_template_argname.i8
-rw-r--r--Examples/test-suite/errors/cpp_template_argname.stderr0
-rw-r--r--Examples/test-suite/errors/cpp_template_repeat.i2
-rw-r--r--Examples/test-suite/errors/cpp_using_type_aliasing.stderr3
-rw-r--r--Examples/test-suite/errors/pp_macro_args.i7
-rw-r--r--Examples/test-suite/errors/pp_macro_args.stderr0
-rw-r--r--Examples/test-suite/exception_classname.i3
-rw-r--r--Examples/test-suite/insert_directive.i2
-rw-r--r--Examples/test-suite/java/Makefile.in2
-rw-r--r--Examples/test-suite/java/director_classes_runme.java2
-rw-r--r--Examples/test-suite/java/director_pass_by_value_runme.java48
-rw-r--r--Examples/test-suite/java/smart_pointer_ignore_runme.java19
-rw-r--r--Examples/test-suite/li_boost_array.i2
-rw-r--r--Examples/test-suite/li_boost_shared_ptr_template.i2
-rw-r--r--Examples/test-suite/nested_extend_c.i4
-rw-r--r--Examples/test-suite/operator_overload.i108
-rw-r--r--Examples/test-suite/php/director_pass_by_value_runme.php24
-rw-r--r--Examples/test-suite/preproc_defined.i1
-rw-r--r--Examples/test-suite/python/autodoc_runme.py8
-rw-r--r--Examples/test-suite/python/cpp11_type_aliasing_runme.py32
-rw-r--r--Examples/test-suite/python/cpp_static_runme.py3
-rw-r--r--Examples/test-suite/python/default_args_c_runme.py6
-rw-r--r--Examples/test-suite/python/director_pass_by_value_runme.py13
-rw-r--r--Examples/test-suite/python/exception_classname_runme.py3
-rw-r--r--Examples/test-suite/python/li_boost_shared_ptr_template_runme.py18
-rw-r--r--Examples/test-suite/python/operator_overload_runme.py77
-rw-r--r--Examples/test-suite/python/operbool_runme.py3
-rw-r--r--Examples/test-suite/python/python_abstractbase_runme3.py4
-rw-r--r--Examples/test-suite/python/python_destructor_exception_runme.py6
-rw-r--r--Examples/test-suite/python/template_default_arg_overloaded_extend_runme.py20
-rw-r--r--Examples/test-suite/python/unicode_strings_runme.py12
-rw-r--r--Examples/test-suite/python_abstractbase.i6
-rw-r--r--Examples/test-suite/r/Makefile.in12
-rw-r--r--Examples/test-suite/ruby/Makefile.in3
-rw-r--r--Examples/test-suite/ruby/ruby_manual_proxy_runme.rb49
-rw-r--r--Examples/test-suite/ruby_manual_proxy.i66
-rw-r--r--Examples/test-suite/smart_pointer_ignore.i33
-rw-r--r--Examples/test-suite/template_default_arg_overloaded_extend.i44
-rw-r--r--Examples/test-suite/typemap_manyargs.i1
-rw-r--r--Examples/test-suite/typemap_subst.i2
-rw-r--r--Lib/csharp/boost_intrusive_ptr.i1021
-rw-r--r--Lib/csharp/csharp.swg4
-rw-r--r--Lib/csharp/swiginterface.i2
-rw-r--r--Lib/d/dswigtype.swg4
-rw-r--r--Lib/go/go.swg2
-rw-r--r--Lib/guile/std_map.i34
-rw-r--r--Lib/java/java.swg4
-rw-r--r--Lib/java/swiginterface.i4
-rw-r--r--Lib/perl5/perlinit.swg1
-rw-r--r--Lib/perl5/perlrun.swg4
-rw-r--r--Lib/php/php.swg2
-rw-r--r--Lib/python/pyopers.swg12
-rw-r--r--Lib/python/pyprimtypes.swg4
-rw-r--r--Lib/r/rrun.swg4
-rw-r--r--Lib/r/std_vector.i100
-rw-r--r--Lib/ruby/rubyrun.swg12
-rw-r--r--Lib/swigrun.swg8
-rw-r--r--Lib/typemaps/swigtype.swg2
-rw-r--r--README2
-rw-r--r--RELEASENOTES11
-rw-r--r--Source/CParse/parser.y51
-rw-r--r--Source/Modules/allegrocl.cxx9
-rw-r--r--Source/Modules/go.cxx3
-rw-r--r--Source/Modules/lua.cxx3
-rw-r--r--Source/Modules/octave.cxx1
-rw-r--r--Source/Modules/overload.cxx16
-rw-r--r--Source/Modules/perl5.cxx2
-rw-r--r--Source/Modules/python.cxx83
-rw-r--r--Source/Modules/r.cxx9
-rw-r--r--Source/Modules/ruby.cxx27
-rw-r--r--Source/Modules/scilab.cxx4
-rw-r--r--Source/Modules/typepass.cxx10
-rw-r--r--Source/Swig/include.c1
-rwxr-xr-xTools/mkwindows.sh35
-rwxr-xr-xTools/testflags.py2
-rwxr-xr-xTools/travis-linux-install.sh23
-rw-r--r--configure.ac24
-rw-r--r--[-rwxr-xr-x]preinst-swig.in0
135 files changed, 2581 insertions, 1108 deletions
diff --git a/.travis.yml b/.travis.yml
index 6bf3e3c37..ac97dc6b5 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -9,8 +9,12 @@ matrix:
env: SWIGLANG=
- os: linux
env: SWIGLANG= SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1
+ sudo: required
+ dist: trusty
- os: linux
- env: SWIGLANG= SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP14=1
+ env: SWIGLANG= SWIG_CC=gcc-6 SWIG_CXX=g++-6
+ sudo: required
+ dist: trusty
- compiler: gcc
os: linux
env: SWIGLANG=csharp
@@ -22,6 +26,11 @@ matrix:
env: SWIGLANG=go
- compiler: gcc
os: linux
+ env: SWIGLANG=go VER=1.5
+ sudo: required
+ dist: trusty
+ - compiler: gcc
+ os: linux
env: SWIGLANG=guile
- compiler: gcc
os: linux
@@ -40,6 +49,11 @@ matrix:
env: SWIGLANG=lua
- compiler: gcc
os: linux
+ env: SWIGLANG=lua VER=5.3
+ sudo: required
+ dist: trusty
+ - compiler: gcc
+ os: linux
env: SWIGLANG=octave SWIGJOBS=-j2 # 3.2
- compiler: gcc
os: linux
@@ -79,6 +93,9 @@ matrix:
env: SWIGLANG=python PY3=3 VER=3.5
- compiler: gcc
os: linux
+ env: SWIGLANG=python SWIG_FEATURES=-builtin VER=2.6
+ - compiler: gcc
+ os: linux
env: SWIGLANG=python SWIG_FEATURES=-builtin
- compiler: gcc
os: linux
@@ -88,6 +105,9 @@ matrix:
env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.5
- compiler: gcc
os: linux
+ env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.5 SWIGOPTPY3=
+ - compiler: gcc
+ os: linux
env: SWIGLANG=python SWIG_FEATURES=-O
- compiler: gcc
os: linux
@@ -109,10 +129,28 @@ matrix:
env: SWIGLANG=tcl
- os: linux
env: SWIGLANG=csharp SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1
+ sudo: required
+ dist: trusty
- os: linux
env: SWIGLANG=java SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1
+ sudo: required
+ dist: trusty
- os: linux
env: SWIGLANG=python SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1
+ sudo: required
+ dist: trusty
+ - os: linux
+ env: SWIGLANG=csharp SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1
+ sudo: required
+ dist: trusty
+ - os: linux
+ env: SWIGLANG=java SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1
+ sudo: required
+ dist: trusty
+ - os: linux
+ env: SWIGLANG=python SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1
+ sudo: required
+ dist: trusty
- os: osx
env: SWIGLANG= SWIG_CC=gcc-4.2 SWIG_CXX=g++-4.2
- compiler: clang
diff --git a/ANNOUNCE b/ANNOUNCE
index b06aa53d2..53c5bbc59 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,8 +1,8 @@
-*** ANNOUNCE: SWIG 3.0.9 (in progress) ***
+*** ANNOUNCE: SWIG 3.0.11 (in progress) ***
http://www.swig.org
-We're pleased to announce SWIG-3.0.9, the latest SWIG release.
+We're pleased to announce SWIG-3.0.11, the latest SWIG release.
What is SWIG?
=============
@@ -27,11 +27,11 @@ Availability
============
The release is available for download on Sourceforge at
- http://prdownloads.sourceforge.net/swig/swig-3.0.9.tar.gz
+ http://prdownloads.sourceforge.net/swig/swig-3.0.11.tar.gz
A Windows version is also available at
- http://prdownloads.sourceforge.net/swig/swigwin-3.0.9.zip
+ http://prdownloads.sourceforge.net/swig/swigwin-3.0.11.zip
Please report problems with this release to the swig-devel mailing list,
details at http://www.swig.org/mail.html.
diff --git a/CCache/ccache.c b/CCache/ccache.c
index e7dd1d30a..c5c510388 100644
--- a/CCache/ccache.c
+++ b/CCache/ccache.c
@@ -130,6 +130,7 @@ static void failed(void)
exit(1);
}
args_add_prefix(orig_args, p);
+ free(p);
}
if (ccache_verbose) {
@@ -490,7 +491,9 @@ static void find_hash(ARGS *args)
/* also include the hash of the compiler name - as some compilers
use hard links and behave differently depending on the real name */
if (st.st_nlink > 1) {
- hash_string(str_basename(args->argv[0]));
+ char *path = str_basename(args->argv[0]);
+ hash_string(path);
+ free(path);
}
hash_int(st.st_size);
@@ -523,6 +526,7 @@ static void find_hash(ARGS *args)
input_base, tmp_string(),
i_extension);
x_asprintf(&path_stderr, "%s/tmp.cpp_stderr.%s", temp_dir, tmp_string());
+ free(input_base);
if (!direct_i_file) {
/* run cpp on the input file to obtain the .i */
@@ -781,6 +785,7 @@ static void find_compiler(int argc, char **argv)
/* support user override of the compiler */
if ((path=getenv("CCACHE_CC"))) {
+ free(base);
base = x_strdup(path);
}
@@ -791,8 +796,10 @@ static void find_compiler(int argc, char **argv)
stats_update(STATS_COMPILER);
cc_log("could not find compiler (%s)\n", base);
perror(base);
+ free(base);
exit(1);
}
+ free(base);
}
@@ -1076,6 +1083,7 @@ static void process_args(int argc, char **argv)
if (strlen(p) < 2) {
cc_log("badly formed dependency file %s\n", output_file);
stats_update(STATS_ARGS);
+ free(default_depfile_name);
failed();
return;
}
@@ -1093,6 +1101,7 @@ static void process_args(int argc, char **argv)
strcat(default_depfile_name, ".d");
args_add(stripped_args, "-MF");
args_add(stripped_args, default_depfile_name);
+ free(default_depfile_name);
}
if (!dependency_target_specified) {
@@ -1117,6 +1126,7 @@ static void process_args(int argc, char **argv)
exit(1);
}
args_add_prefix(stripped_args, p);
+ free(p);
}
}
@@ -1305,6 +1315,7 @@ static void setup_uncached_err(void)
if (putenv(buf) == -1) {
cc_log("putenv failed\n");
+ close(uncached_fd);
stats_update(STATS_ERROR);
failed();
}
diff --git a/CCache/ccache.h b/CCache/ccache.h
index dcbb03f0c..a79d88322 100644
--- a/CCache/ccache.h
+++ b/CCache/ccache.h
@@ -20,7 +20,9 @@
#include <sys/wait.h>
#include <sys/mman.h>
#else
-#define _WIN32_WINNT 0x0500
+#ifndef _WIN32_WINNT
+ #define _WIN32_WINNT 0x0500
+#endif
#include <windows.h>
#include <shlobj.h>
#endif
diff --git a/CCache/execute.c b/CCache/execute.c
index 165b91e66..6df025e95 100644
--- a/CCache/execute.c
+++ b/CCache/execute.c
@@ -267,6 +267,7 @@ char *find_executable(const char *name, const char *exclude_name)
}
free(fname);
}
+ free(path);
return NULL;
#endif
diff --git a/CCache/stats.c b/CCache/stats.c
index d2122bcd3..4d01d2afa 100644
--- a/CCache/stats.c
+++ b/CCache/stats.c
@@ -138,7 +138,10 @@ static void stats_update_size(enum stats stat, size_t size, size_t numfiles)
memset(counters, 0, sizeof(counters));
- if (lock_fd(fd) != 0) return;
+ if (lock_fd(fd) != 0) {
+ close(fd);
+ return;
+ }
/* read in the old stats */
stats_read_fd(fd, counters);
diff --git a/CCache/unify.c b/CCache/unify.c
index a93d48a02..7a36476a1 100644
--- a/CCache/unify.c
+++ b/CCache/unify.c
@@ -281,6 +281,7 @@ int unify_hash(const char *fname)
fd = open(fname, O_RDONLY|O_BINARY);
if (fd == -1 || fstat(fd, &st) != 0) {
cc_log("Failed to open preprocessor output %s\n", fname);
+ if (fd != -1) close(fd);
stats_update(STATS_PREPROCESSOR);
return -1;
}
@@ -289,12 +290,12 @@ int unify_hash(const char *fname)
lines in preprocessor output. I have seen lines of over
100k in length, so this is well worth it */
map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
+ close(fd);
if (map == (char *)-1) {
cc_log("Failed to mmap %s\n", fname);
stats_update(STATS_PREPROCESSOR);
return -1;
}
- close(fd);
/* pass it through the unifier */
unify((unsigned char *)map, st.st_size);
diff --git a/CCache/util.c b/CCache/util.c
index 66f9823b9..ef90e2336 100644
--- a/CCache/util.c
+++ b/CCache/util.c
@@ -189,9 +189,11 @@ void copy_fd(int fd_in, int fd_out) {
while ((n = gzread(gz_in, buf, sizeof(buf))) > 0) {
if (write(fd_out, buf, n) != n) {
+ gzclose(gz_in);
fatal("Failed to copy fd");
}
}
+ gzclose(gz_in);
}
static int _copy_file(const char *src, const char *dest, int mode) {
@@ -248,9 +250,11 @@ static int _copy_file(const char *src, const char *dest, int mode) {
}
if (mode == COPY_TO_CACHE) {
- gz_out = gzdopen(dup(fd_out), "wb");
+ int dup_fd_out = dup(fd_out);
+ gz_out = gzdopen(dup_fd_out, "wb");
if (!gz_out) {
gzclose(gz_in);
+ close(dup_fd_out);
close(fd_out);
free(tmp_name);
return -1;
@@ -459,6 +463,7 @@ int create_cachedirtag(const char *dir)
f = fopen(filename, "w");
if (!f) goto error;
if (fwrite(CACHEDIR_TAG, sizeof(CACHEDIR_TAG)-1, 1, f) != 1) {
+ fclose(f);
goto error;
}
if (fclose(f)) goto error;
@@ -485,7 +490,7 @@ void x_asprintf(char **ptr, const char *format, ...)
}
va_end(ap);
- if (!ptr) fatal("out of memory in x_asprintf");
+ if (!*ptr) fatal("out of memory in x_asprintf");
}
/*
diff --git a/CHANGES b/CHANGES
index 198230775..0146ac7ac 100644
--- a/CHANGES
+++ b/CHANGES
@@ -3,6 +3,244 @@ 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.10 (12 Jun 2016)
+============================
+
+2016-06-06: mromberg
+ [Python] Patch #698. Add support for -relativeimport for python 2.7, so -py3 is no
+ longer also required for relative import support.
+
+2016-06-05: mromberg
+ [Python] Patch #694 - Fix package import regressions introduced in swig-3.0.9.
+
+ 1) The code in 3.0.9 did not fall back to 'import _foo' if 'import bar._foo' failed
+ (assuming bar.foo was the main module). Every place _foo is imported now first tries
+ it from the package where foo was found and if that fails tries _foo as a global module.
+
+ 2) The separate block of Python code that injected code to pull in the attributes
+ from _foo when -builtin is used made use of the -py3 switch to either do
+ 'from ._foo import *' or "from _foo import *". This block of code no longer does this
+ and instead checks the Python version at runtime to switch between the two syntaxes.
+
+ In summary, swig-3.0.10 has been modified to ease the creation of wrapper modules
+ that can be fully made part of a Python package. SWIG no longer
+ assumes the dynamically linked C module is a global module.
+ The dynamic module can now be placed into either the same package as the pure Python
+ module or as a global module. Both locations are used by the Python wrapper to
+ locate the C module.
+
+ However, this could cause a backwards incompatibility with some code
+ that was relying on the ability of "from package import _module" to
+ pull attributes out of the package directly. If your code populates a
+ module (which is also a package) with attributes that are SWIG
+ generated modules which were not loaded in a conventional way,
+ swig-3.0.8 and earlier may have worked due to 'from package import
+ _module' bypassing a real import and pulling your module in as an
+ attribute. This will no longer work. Since this is not a common (or
+ even recommended) practice, most folk should not be affected.
+
+ *** POTENTIAL INCOMPATIBILITY ***
+
+2016-05-31: wsfulton
+ Fix #690 - Smart pointer to %ignored class doesn't expose inherited methods.
+ Regression introduced in swig-3.0.9.
+
+Version 3.0.9 (29 May 2016)
+===========================
+
+2016-05-24: mromberg
+ [Python] Patch #612 - Add support for Python's implicit namespace packages.
+
+2016-05-23: wsfulton
+ [Ruby] Fix #602 - Error handling regression of opaque pointers introduced
+ in swig-3.0.8 when C functions explicitly reset a pointer using 'DATA_PTR(self) = 0'.
+ An ObjectPreviouslyDeleted error was incorrectly thrown when the pointer was used
+ as a parameter.
+
+2016-05-17: tamuratak
+ [Ruby] Patch #651 - Correct overloaded function error message when function is
+ using %newobject.
+
+2016-05-17: aurelj
+ [Ruby] Patch #582 - add support for docstring option in %module()
+
+2016-05-14: wsfulton
+ Fix #434 - Passing classes by value as parameters in director methods did not create
+ a copy of the argument leading to invalid memory accesses if the object was used
+ after the upcall into the target language. Passing arguments by value shouldn't give
+ rise to these sorts of memory problems and so the objects are now copied and ownership
+ of their lifetime is controlled by the target language.
+
+2016-05-07: wsfulton
+ Fix #611. Fix assertion handling defaultargs when using %extend for a template
+ class and the extended methods contain default arguments.
+
+2016-05-05: ejulian
+ [Python] Patch #617. Fix operator/ wrappers.
+
+2016-05-02: wsfulton
+ Fix #669. Don't issue warning about ignoring base classes when the derived class is
+ itself ignored.
+
+2016-04-18: ianlancetaylor
+ [Go] Fix use of goout typemap when calling base method by
+ forcing the "type" attribute to the value we need.
+
+2016-04-17: ianlancetaylor
+ [Go] Fixes for Go 1.6: avoid returning Go pointers from
+ directors that return string values; add a trailing 0 byte
+ when treating Go string as C char*.
+
+2016-04-06: smarchetto
+ [Scilab] #552 Make Scilab runtime keep track of pointer types
+ Instead of a Scilab pointer which has no type, SWIG Scilab maps a
+ pointer to a structure tlist containing the pointer adress and its type.
+
+2016-04-02: ahnolds
+ [Python] Apply #598. Fix misleading error message when attempting to read a non-existent
+ attribute. The previous cryptic error message:
+ AttributeError: type object 'object' has no attribute '__getattr__'
+ is now replaced with one mentioning the attribute name, eg:
+ AttributeError: 'Foo' object has no attribute 'bar'
+
+2016-04-02: derkuci
+ [Python] Patch #610 to fix #607.
+ Fix single arguments when using python -builtin -O with %feature("compactdefaultargs")
+
+2016-03-31: wsfulton
+ Fixes #594. Fix assertion for some languages when wrapping a C++11 enum class that
+ is private in a class.
+
+ Also don't wrap private enums for a few languages that attempted to do so.
+
+2016-03-31: wsfulton
+ [Java] unsigned long long marshalling improvements when a negative number
+ is passed from Java to C. A cast to signed long long in the C layer will now
+ result in the expected value. No change for positive numbers passed to C.
+ Fixes #623.
+
+2016-03-22: alexwarg
+ [Lua] #398 Fix lua __getitem + inheritance
+ The new handling of classes in Lua (not merging methods into the derived classes)
+ breaks for classes that provide a __getitem function. The __getitem function
+ prevents method calls to any method defined in a base class. This fix calls
+ __getitem only if the member is not found using recursive lookup.
+
+2016-03-18: ptomulik
+ [Python] #563 Stop generating unnecessary _swigconstant helpers.
+
+2016-03-16: richardbeare
+ [R] #636 Add extra std::vector numeric types
+
+2016-03-14: wsfulton
+ [Java] Add std_array.i for C++11 std::array support.
+
+2016-03-12: wsfulton
+ [Java, C#, D] Fix static const char member variables wrappers with %javaconst(1)
+ %csconst(1) or %dmanifestconst.
+ This fixes the case when an integer is used as the initializer, such as:
+
+ struct W { static const char w = 100; };
+
+ Fix generated code parsing enum values using char escape sequences
+ when these values appear in the Java code (usually when using %javaconst(1))
+ such as:
+
+ enum X { x1 = '\n', x2 = '\1' };
+
+ Similarly for static const member char variables such as:
+
+ struct Y { static const char y = '\n'; }
+
+ Likewise for D and %dmanifestconstant. For C# and %csconst(1), char
+ values in C# are now hex escaped as C# doesn't support C octal escaping.
+
+2016-03-11: wsfulton
+ [Java C#] Add support for treating C++ base classes as Java interfaces
+ instead of Java proxy classes. This enable some sort of support for
+ multiple inheritance. The implementation is in swiginterface.i and
+ provides additional macros (see Java.html for full documentation):
+
+ %interface(CTYPE)
+ %interface_impl(CTYPE)
+ %interface_custom("PROXY", "INTERFACE", CTYPE)
+
+2016-03-01: wsfulton
+ Add rstrip encoder for use in %rename. This is like the strip encoder but
+ strips the symbol's suffix instead of the prefix. The example below
+ will rename SomeThingCls to SomeThing and AnotherThingCls to AnotherThing:
+
+ %rename("%(rstrip:[Cls])s") "";
+
+ class SomeThingCls {};
+ struct AnotherThingCls {};
+
+2016-03-01: olly
+ Fix isfinite() check to work with GCC6. Fixes
+ https://github.com/swig/swig/issues/615 reported by jplesnik.
+
+2016-02-17: olly
+ [Python] Add missing keywords 'as' and 'with' to pythonkw.swg.
+
+2016-02-07: kwwette
+ [Octave] recognise various unary functions
+ * Use __float__() for numeric conversions, e.g. when calling double()
+ * Map various unary functions, e.g. abs() to __abs__(), see full list
+ in section 32.3.10 of manual; only available in Octave 3.8.0 or later
+
+2016-02-07: kwwette
+ [Octave] export function swig_octave_prereq() for testing Octave version
+
+2016-02-06: pjohangustavsson
+ [C#] Fix duplicate symbol problems when linking the source generated
+ from multiple SWIG modules into one shared library for the -namespace
+ option. The namespace is now mangled into the global PInvoke function
+ names.
+
+ *** POTENTIAL INCOMPATIBILITY ***
+
+2016-01-27: ahnolds
+ [Python] Added support for differentiating between Python Bytes
+ and Unicode objects using by defining SWIG_PYTHON_STRICT_BYTE_CHAR
+ and SWIG_PYTHON_STRICT_UNICODE_WCHAR.
+
+2016-01-27: steeve
+ [Go] Ensure structs are properly packed between gc and GCC/clang.
+
+2016-01-25: ahnolds
+ [Python] Support the full Python test suite in -classic mode
+ * Convert long/unsigned long/long long/unsigned long long to PyInt
+ rather than PyLong when possible. Certain python functions like
+ len() require a PyInt when operating on old-style classes.
+ * Add support for static methods in classic mode, including support
+ for pythonappend, pythonprepend, and docstrings.
+ * Removing the use of __swig_getmethods__ for static member methods
+ since they will always be found by the standard argument lookup
+ * Fix a bug where the wrong type of exception was caught when
+ checking for new-style class support
+
+2016-01-23: ahnolds
+ [Go] Enable support for the Go test-suite on OSX:
+ * The linker on OSX requires that all symbols (even weak symbols)
+ are defined at link time. Because the function _cgo_topofstack is
+ only defined starting in Go version 1.4, we explicitly mark it as
+ undefined for older versions of Go on OSX.
+ * Avoid writing empty swigargs structs, since empty structs are not
+ allowed in extern "C" blocks.
+
+2016-01-12: olly
+ [Javascript] Look for "nodejs" as well as "node", as it's packaged
+ as the former on Debian.
+
+2016-01-12: olly
+ [Javascript] For v8 >= 4.3.0, use V8_MAJOR_VERSION.
+ Fixes https://github.com/swig/swig/issues/561.
+
+2016-01-10: ahnolds
+ Improved size_t and ptrdiff_t typemaps to support large values
+ on platforms where sizeof(size_t) > sizeof(unsigned long) and
+ sizeof(ptrdiff_t) > sizeof(long).
+
Version 3.0.8 (31 Dec 2015)
===========================
@@ -587,7 +825,7 @@ Version 3.0.3 (30 Dec 2014)
2014-10-21: wsfulton
Fix issue #242 - Use of the "kwargs" feature no longer automatically turns on the
"compactdefaultargs" feature if the target language does not support kwargs.
- Only Java and Python support kwargs, so this affects all the other languages.
+ This change affects all languages except Python and Ruby.
*** POTENTIAL INCOMPATIBILITY ***
diff --git a/CHANGES.current b/CHANGES.current
index 1627a09ec..b3bb600dc 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -2,164 +2,25 @@ 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.9 (in progress)
-===========================
-
-2016-04-18: ianlancetaylor
- [Go] Fix use of goout typemap when calling base method by
- forcing the "type" attribute to the value we need.
-
-2016-04-17: ianlancetaylor
- [Go] Fixes for Go 1.6: avoid returning Go pointers from
- directors that return string values; add a trailing 0 byte
- when treating Go string as C char*.
-
-2016-04-06: smarchetto
- [Scilab] #552 Make Scilab runtime keep track of pointer types
- Instead of a Scilab pointer which has no type, SWIG Scilab maps a
- pointer to a structure tlist containing the pointer adress and its type.
-
-2016-04-02: ahnolds
- [Python] Apply #598. Fix misleading error message when attempting to read a non-existent
- attribute. The previous cryptic error message:
- AttributeError: type object 'object' has no attribute '__getattr__'
- is now replaced with one mentioning the attribute name, eg:
- AttributeError: 'Foo' object has no attribute 'bar'
-
-2016-04-02: derkuci
- [Python] Patch #610 to fix #607.
- Fix single arguments when using python -builtin -O with %feature("compactdefaultargs")
-
-2016-03-31: wsfulton
- Fixes #594. Fix assertion for some languages when wrapping a C++11 enum class that
- is private in a class.
-
- Also don't wrap private enums for a few languages that attempted to do so.
-
-2016-03-31: wsfulton
- [Java] unsigned long long marshalling improvements when a negative number
- is passed from Java to C. A cast to signed long long in the C layer will now
- result in the expected value. No change for positive numbers passed to C.
- Fixes #623.
-
-2016-03-22: alexwarg
- [Lua] #398 Fix lua __getitem + inheritance
- The new handling of classes in Lua (not merging methods into the derived classes)
- breaks for classes that provide a __getitem function. The __getitem function
- prevents method calls to any method defined in a base class. This fix calls
- __getitem only if the member is not found using recursive lookup.
-
-2016-03-18: ptomulik
- [Python] #563 Stop generating unnecessary _swigconstant helpers.
-
-2016-03-16: richardbeare
- [R] #636 Add extra std::vector numeric types
-
-2016-03-14: wsfulton
- [Java] Add std_array.i for C++11 std::array support.
-
-2016-03-12: wsfulton
- [Java, C#, D] Fix static const char member variables wrappers with %javaconst(1)
- %csconst(1) or %dmanifestconst.
- This fixes the case when an integer is used as the initializer, such as:
-
- struct W { static const char w = 100; };
-
- Fix generated code parsing enum values using char escape sequences
- when these values appear in the Java code (usually when using %javaconst(1))
- such as:
-
- enum X { x1 = '\n', x2 = '\1' };
-
- Similarly for static const member char variables such as:
-
- struct Y { static const char y = '\n'; }
-
- Likewise for D and %dmanifestconstant. For C# and %csconst(1), char
- values in C# are now hex escaped as C# doesn't support C octal escaping.
-
-2016-03-11: wsfulton
- [Java C#] Add support for treating C++ base classes as Java interfaces
- instead of Java proxy classes. This enable some sort of support for
- multiple inheritance. The implementation is in swiginterface.i and
- provides additional macros (see Java.html for full documentation):
-
- %interface(CTYPE)
- %interface_impl(CTYPE)
- %interface_custom("PROXY", "INTERFACE", CTYPE)
-
-2016-03-01: wsfulton
- Add rstrip encoder for use in %rename. This is like the strip encoder but
- strips the symbol's suffix instead of the prefix. The example below
- will rename SomeThingCls to SomeThing and AnotherThingCls to AnotherThing:
-
- %rename("%(rstrip:[Cls])s") "";
-
- class SomeThingCls {};
- struct AnotherThingCls {};
-
-2016-03-01: olly
- Fix isfinite() check to work with GCC6. Fixes
- https://github.com/swig/swig/issues/615 reported by jplesnik.
-
-2016-02-17: olly
- [Python] Add missing keywords 'as' and 'with' to pythonkw.swg.
-
-2016-02-07: kwwette
- [Octave] recognise various unary functions
- * Use __float__() for numeric conversions, e.g. when calling double()
- * Map various unary functions, e.g. abs() to __abs__(), see full list
- in section 32.3.10 of manual; only available in Octave 3.8.0 or later
-
-2016-02-07: kwwette
- [Octave] export function swig_octave_prereq() for testing Octave version
-
-2016-02-06: pjohangustavsson
- [C#] Fix duplicate symbol problems when linking the source generated
- from multiple SWIG modules into one shared library for the -namespace
- option. The namespace is now mangled into the global PInvoke function
- names.
-
- *** POTENTIAL INCOMPATIBILITY ***
-
-2016-01-27: ahnolds
- [Python] Added support for differentiating between Python Bytes
- and Unicode objects using by defining SWIG_PYTHON_STRICT_BYTE_CHAR
- and SWIG_PYTHON_STRICT_UNICODE_WCHAR.
-
-2016-01-27: steeve
- [Go] Ensure structs are properly packed between gc and GCC/clang.
-
-2016-01-25: ahnolds
- [Python] Support the full Python test suite in -classic mode
- * Convert long/unsigned long/long long/unsigned long long to PyInt
- rather than PyLong when possible. Certain python functions like
- len() require a PyInt when operating on old-style classes.
- * Add support for static methods in classic mode, including support
- for pythonappend, pythonprepend, and docstrings.
- * Removing the use of __swig_getmethods__ for static member methods
- since they will always be found by the standard argument lookup
- * Fix a bug where the wrong type of exception was caught when
- checking for new-style class support
-
-2016-01-23: ahnolds
- [Go] Enable support for the Go test-suite on OSX:
- * The linker on OSX requires that all symbols (even weak symbols)
- are defined at link time. Because the function _cgo_topofstack is
- only defined starting in Go version 1.4, we explicitly mark it as
- undefined for older versions of Go on OSX.
- * Avoid writing empty swigargs structs, since empty structs are not
- allowed in extern "C" blocks.
-
-2016-01-12: olly
- [Javascript] Look for "nodejs" as well as "node", as it's packaged
- as the former on Debian.
-
-2016-01-12: olly
- [Javascript] For v8 >= 4.3.0, use V8_MAJOR_VERSION.
- Fixes https://github.com/swig/swig/issues/561.
-
-2016-01-10: ahnolds
- Improved size_t and ptrdiff_t typemaps to support large values
- on platforms where sizeof(size_t) > sizeof(unsigned long) and
- sizeof(ptrdiff_t) > sizeof(long).
+Version 3.0.11 (in progress)
+============================
+
+2016-06-25: mromberg
+ [Python] #711 Fix -castmode and conversion of signed and unsigned integer types.
+ See 2015-12-23 CHANGES entry for details of these improvements when they were
+ implemented for the default options (ie not using -castmode).
+
+2016-06-25: ahnolds
+ Patch #730 - Fix %implicitconv for overloaded functions when using
+ -castmode or -fastdispatch options.
+
+ The result is that in all overload cases where there are multiple possibilities
+ with the same number of arguments, the dispatch function will first check for
+ exact (aka non implicit) matches, and then subsequently check for implicit
+ casting matches. This was already happening in the normal dispatch situation,
+ and in the -fastdispatch case two passes through the candidates were happening,
+ just with SWIG_POINTER_IMPLICIT_CONV always set. After this patch, it is not set
+ on the first pass, and then set on the second pass.
+
+2016-06-25: liorgold
+ Patch #727 - Add support for C++11 type aliasing.
diff --git a/Doc/Manual/CPlusPlus11.html b/Doc/Manual/CPlusPlus11.html
index 714845bba..a4845832e 100644
--- a/Doc/Manual/CPlusPlus11.html
+++ b/Doc/Manual/CPlusPlus11.html
@@ -29,7 +29,7 @@
<li><a href="#CPlusPlus11_strongly_typed_enumerations">Strongly typed enumerations</a>
<li><a href="#CPlusPlus11_double_angle_brackets">Double angle brackets</a>
<li><a href="#CPlusPlus11_explicit_conversion_operators">Explicit conversion operators</a>
-<li><a href="#CPlusPlus11_alias_templates">Alias templates</a>
+<li><a href="#CPlusPlus11_alias_templates">Type alias and alias templates</a>
<li><a href="#CPlusPlus11_unrestricted_unions">Unrestricted unions</a>
<li><a href="#CPlusPlus11_variadic_templates">Variadic templates</a>
<li><a href="#CPlusPlus11_new_string_literals">New string literals</a>
@@ -603,10 +603,30 @@ Conversion operators either with or without <tt>explicit</tt> need renaming to a
them available as a normal proxy method.
</p>
-<H3><a name="CPlusPlus11_alias_templates">7.2.16 Alias templates</a></H3>
+<H3><a name="CPlusPlus11_alias_templates">7.2.16 Type alias and alias templates</a></H3>
<p>
+A type alias is a statement of the form:
+</p>
+
+<div class="code"><pre>
+using PFD = void (*)(double); // New introduced syntax
+</pre></div>
+
+<p>
+which is equivalent to the old style typedef:
+</p>
+
+<div class="code"><pre>
+typedef void (*PFD)(double); // The old style
+</pre></div>
+
+<p>
+SWIG supports type aliasing.
+</p>
+
+<p>
The following is an example of an alias template:
<div class="code"><pre>
@@ -632,31 +652,6 @@ example.i:13: Warning 342: The 'using' keyword in template aliasing is not fully
</pre>
</div>
-<p>
-Similarly for non-template type aliasing:
-</p>
-
-<div class="code"><pre>
-using PFD = void (*)(double); // New introduced syntax
-</pre></div>
-
-<p>
-A warning will be issued:
-</p>
-
-<div class="shell">
-<pre>
-example.i:17: Warning 341: The 'using' keyword in type aliasing is not fully supported yet.
-</pre>
-</div>
-
-
-<p>The equivalent old style typedefs can be used as a workaround:</p>
-
-<div class="code"><pre>
-typedef void (*PFD)(double); // The old style
-</pre></div>
-
<H3><a name="CPlusPlus11_unrestricted_unions">7.2.17 Unrestricted unions</a></H3>
diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html
index 856223ea3..0b456fca7 100644
--- a/Doc/Manual/Contents.html
+++ b/Doc/Manual/Contents.html
@@ -287,7 +287,7 @@
<li><a href="CPlusPlus11.html#CPlusPlus11_strongly_typed_enumerations">Strongly typed enumerations</a>
<li><a href="CPlusPlus11.html#CPlusPlus11_double_angle_brackets">Double angle brackets</a>
<li><a href="CPlusPlus11.html#CPlusPlus11_explicit_conversion_operators">Explicit conversion operators</a>
-<li><a href="CPlusPlus11.html#CPlusPlus11_alias_templates">Alias templates</a>
+<li><a href="CPlusPlus11.html#CPlusPlus11_alias_templates">Type alias and alias templates</a>
<li><a href="CPlusPlus11.html#CPlusPlus11_unrestricted_unions">Unrestricted unions</a>
<li><a href="CPlusPlus11.html#CPlusPlus11_variadic_templates">Variadic templates</a>
<li><a href="CPlusPlus11.html#CPlusPlus11_new_string_literals">New string literals</a>
@@ -1594,6 +1594,14 @@
<li><a href="Python.html#Python_absrelimports">Absolute and relative imports</a>
<li><a href="Python.html#Python_absimport">Enforcing absolute import semantics</a>
<li><a href="Python.html#Python_importfrominit">Importing from __init__.py</a>
+<li><a href="Python.html#Python_implicit_namespace_packages">Implicit Namespace Packages</a>
+<li><a href="Python.html#Python_package_search">Searching for the wrapper module</a>
+<ul>
+<li><a href="Python.html#Python_package_search_both_package_modules">Both modules in the same package</a>
+<li><a href="Python.html#Python_package_search_wrapper_split">Split modules</a>
+<li><a href="Python.html#Python_package_search_both_global_modules">Both modules are global</a>
+<li><a href="Python.html#Python_package_search_static">Statically linked C modules</a>
+</ul>
</ul>
<li><a href="Python.html#Python_python3support">Python 3 Support</a>
<ul>
@@ -1793,11 +1801,12 @@
<li><a href="Scilab.html#Scilab_wrapping_pointers">Pointers</a>
<ul>
<li><a href="Scilab.html#Scilab_wrapping_pointers_pointer_adresses">Utility functions</a>
-<li><a href="Scilab.html#Scilab_wrapping_pointers_null_pointers">Null pointers</a>
+<li><a href="Scilab.html#Scilab_wrapping_pointers_null_pointers">Null pointers:</a>
</ul>
<li><a href="Scilab.html#Scilab_wrapping_structs">Structures</a>
<li><a href="Scilab.html#Scilab_wrapping_cpp_classes">C++ classes</a>
<li><a href="Scilab.html#Scilab_wrapping_cpp_inheritance">C++ inheritance</a>
+<li><a href="Scilab.html#Scilab_wrapping_cpp_overloading">C++ overloading</a>
<li><a href="Scilab.html#Scilab_wrapping_pointers_references_values_arrays">Pointers, references, values, and arrays</a>
<li><a href="Scilab.html#Scilab_wrapping_cpp_templates">C++ templates</a>
<li><a href="Scilab.html#Scilab_wrapping_cpp_operators">C++ operators</a>
@@ -1808,7 +1817,6 @@
<li><a href="Scilab.html#Scilab_typemaps">Type mappings and libraries</a>
<ul>
<li><a href="Scilab.html#Scilab_typemaps_primitive_types">Default primitive type mappings</a>
-<li><a href="Scilab.html#Scilab_typemaps_non-primitive_types">Default type mappings for non-primitive types</a>
<li><a href="Scilab.html#Scilab_typemaps_arrays">Arrays</a>
<li><a href="Scilab.html#Scilab_typemaps_pointer-to-pointers">Pointer-to-pointers</a>
<li><a href="Scilab.html#Scilab_typemaps_matrices">Matrices</a>
diff --git a/Doc/Manual/Makefile b/Doc/Manual/Makefile
index c7769dc97..fb5f67c06 100644
--- a/Doc/Manual/Makefile
+++ b/Doc/Manual/Makefile
@@ -41,6 +41,7 @@ check:
# 3) <pre> <tt> <code> elements do not always select a fixed-width font - try installing the
# Courier font to fix - these have been added to style.css.
generate: SWIGDocumentation.html
+ wkhtmltopdf --version | grep "with patched qt" || (echo "wkhtmltopdf is not the patched qt version and so cannot be used - download it from http://wkhtmltopdf.org/downloads.html" && false)
wkhtmltopdf --margin-top 20mm --margin-bottom 20mm --margin-left 10mm --margin-right 10mm --header-font-size 6 --footer-font-size 6 --header-spacing 6 --footer-spacing 6 --header-center '[doctitle]' --footer-left '[subsection]' --footer-right '[page]' SWIGDocumentation.html SWIGDocumentation.pdf
SWIGDocumentation.html: swightml.book
diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html
index 099d406bf..ce7f9fe5a 100644
--- a/Doc/Manual/Python.html
+++ b/Doc/Manual/Python.html
@@ -116,6 +116,14 @@
<li><a href="#Python_absrelimports">Absolute and relative imports</a>
<li><a href="#Python_absimport">Enforcing absolute import semantics</a>
<li><a href="#Python_importfrominit">Importing from __init__.py</a>
+<li><a href="#Python_implicit_namespace_packages">Implicit Namespace Packages</a>
+<li><a href="#Python_package_search">Searching for the wrapper module</a>
+<ul>
+<li><a href="#Python_package_search_both_package_modules">Both modules in the same package</a>
+<li><a href="#Python_package_search_wrapper_split">Split modules</a>
+<li><a href="#Python_package_search_both_global_modules">Both modules are global</a>
+<li><a href="#Python_package_search_static">Statically linked C modules</a>
+</ul>
</ul>
<li><a href="#Python_python3support">Python 3 Support</a>
<ul>
@@ -4186,7 +4194,7 @@ also be used to extra binary data from arbitrary pointers.
<p>
C++ default argument code generation is documented in the main
-<a href="SWIG.html#SWIGPlus_default_args">Default arguments</a> section.
+<a href="SWIGPlus.html#SWIGPlus_default_args">Default arguments</a> section.
There is also an optional Python specific feature that can be used called the <tt>python:cdefaultargs</tt>
<a href="Customization.html#Customization_feature_flags">feature flag</a>.
By default, SWIG attempts to convert C++ default argument values
@@ -4891,23 +4899,23 @@ A typemap can be used to handle this case as follows :
// is guaranteed to be a List object by SWIG.
%typemap(argout) double *OutValue {
- PyObject *o, *o2, *o3;
- o = PyFloat_FromDouble(*$1);
- if ((!$result) || ($result == Py_None)) {
- $result = o;
- } else {
- if (!PyTuple_Check($result)) {
- PyObject *o2 = $result;
- $result = PyTuple_New(1);
- PyTuple_SetItem(target,0,o2);
- }
- o3 = PyTuple_New(1);
- PyTuple_SetItem(o3,0,o);
- o2 = $result;
- $result = PySequence_Concat(o2,o3);
- Py_DECREF(o2);
- Py_DECREF(o3);
+ PyObject *o, *o2, *o3;
+ o = PyFloat_FromDouble(*$1);
+ if ((!$result) || ($result == Py_None)) {
+ $result = o;
+ } else {
+ if (!PyTuple_Check($result)) {
+ PyObject *o2 = $result;
+ $result = PyTuple_New(1);
+ PyTuple_SetItem($result,0,o2);
}
+ o3 = PyTuple_New(1);
+ PyTuple_SetItem(o3,0,o);
+ o2 = $result;
+ $result = PySequence_Concat(o2,o3);
+ Py_DECREF(o2);
+ Py_DECREF(o3);
+ }
}
int spam(double a, double b, double *OutValue, double *OutValue);
@@ -5520,6 +5528,23 @@ They should be created by other means. Both files (module <tt>*.py</tt> and
directories in order to obtain a desirable package/module hierarchy.
</p>
+<p>
+Python3 adds another option for packages with
+<a href="https://www.python.org/dev/peps/pep-0420/">PEP 0420</a> (implicit
+namespace packages). Implicit namespace packages no longer use
+__init__.py files. SWIG generated Python modules support implicit
+namespace packages. See
+<a href="#Python_implicit_namespace_packages">36.11.5 Implicit Namespace
+Packages</a> for more information.
+</p>
+
+<p>
+If you place a SWIG generated module into a Python package then there
+are details concerning the way SWIG
+<a href="#Python_package_search">searches for the wrapper module</a>
+that you may want to familiarize yourself with.
+</p>
+
<p>The way Python defines its modules and packages impacts SWIG users. Some
users may need to use special features such as the <tt>package</tt> option in the
<tt>%module</tt> directive or import related command line options. These are
@@ -5679,8 +5704,9 @@ class M2(pkg2.mod3.M3): pass
<p>By default, SWIG would generate <tt>mod2.py</tt> proxy file with
<tt>import</tt> directive as in point 1. This can be changed with the
<tt>-relativeimport</tt> command line option. The <tt>-relativeimport</tt> instructs
-SWIG to organize imports as in point 2 (for Python 2.x) or as in point 4 (for
-Python 3, that is when the -py3 command line option is enabled). In short, if you have
+SWIG to organize imports as in point 2 (for Python < 2.7.0) or as in point 4
+for Python 2.7.0 and newer. This is a check done at the time the module is
+imported. In short, if you have
<tt>mod2.i</tt> and <tt>mod3.i</tt> as above, then without
<tt>-relativeimport</tt> SWIG will write</p>
@@ -5694,22 +5720,17 @@ import pkg1.pkg2.mod3
write</p>
<div class="targetlang">
-<pre>
-import pkg2.mod3
-</pre>
-</div>
-
-<p>if <tt>-py3</tt> is not used, or</p>
-
-<div class="targetlang">
-<pre>
-from . import pkg2
-import pkg1.pkg2.mod3
+ <pre>
+from sys import version_info
+if version_info &gt;= (2, 7, 0):
+ from . import pkg2
+ import pkg1.pkg2.mod3
+else:
+ import pkg2.mod3
+del version_info
</pre>
</div>
-<p>when <tt>-py3</tt> is used.</p>
-
<p>You should avoid using relative imports and use absolute ones whenever
possible. There are some cases, however, when relative imports may be
necessary. The first example is, when some (legacy) Python code refers entities
@@ -5865,6 +5886,257 @@ class Bar(pkg3.foo.Foo): pass
effect (note, that the Python 2 case also needs the <tt>-relativeimport</tt>
workaround).</p>
+<H3><a name="Python_implicit_namespace_packages">36.11.5 Implicit Namespace Packages</a></H3>
+
+
+<p> Python 3.3 introduced
+<a href="https://www.python.org/dev/peps/pep-0420/">PEP 0420</a> which
+implements implicit namespace packages. In a nutshell, implicit namespace
+packages remove the requirement of an __init__.py file and allow packages
+to be split across multiple PATH elements. For example:
+</p>
+
+<div class="diagram">
+<pre>
+/fragment1/pkg1/mod1.py
+/fragment2/pkg1/mod2.py
+/fragment3/pkg1/mod3.py
+</pre>
+</div>
+
+<p>If PYTHONPATH is set to "/fragment1:/fragment2:/fragment3", then mod1, mod2
+and mod3 will be part of pkg1. This allows for splitting of packages into
+separate pieces. This can be useful for SWIG generated wrappers in the
+following way.
+</p>
+
+<p> Suppose you create a SWIG wrapper for a module called robin. The SWIG
+generated code consists of two files robin.py and _robin.so. You wish to
+make these modules part of a subpackage (brave.sir). With implicit namespace
+packages you can place these files in the following configurations:
+</p>
+
+<p>Using PYTHONPATH="/some/path"</p>
+<div class="diagram">
+<pre>
+/some/path/brave/sir/robin.py
+/some/path/brave/sir/_robin.so
+</pre>
+</div>
+
+<p>Using PYTHONPATH="/some/path:/some/other/path"
+
+<div class="diagram">
+<pre>
+/some/path/brave/sir/robin.py
+/some/other/path/brave/sir/_robin.so
+</pre>
+</div>
+
+<p> Finally suppose that your pure python code is stored in a .zip file or
+some other way (database, web service connection, etc). Python can load the
+robin.py module using a custom importer. But the _robin.so module will need
+to be located on a file system. Implicit namespace packages make this
+possible. For example, using PYTHONPATH="/some/path/foo.zip:/some/other/path"
+
+<p> Contents of foo.zip</p>
+<div class="diagram">
+<pre>
+brave/
+brave/sir/
+brave/sir/robin.py
+</pre>
+</div>
+
+<p> File system contents</p>
+<div class="diagram">
+<pre>
+/some/other/path/brave/sir/_robin.so
+</pre>
+</div>
+
+<p>Support for implicit namespace packages was added to python-3.3. The
+zipimporter requires python-3.5.1 or newer to work with subpackages.
+</p>
+
+<p>
+<b>Compatibility Note:</b> Support for implicit namespace packages was added in SWIG-3.0.9.
+</p>
+
+
+<H3><a name="Python_package_search">36.11.6 Searching for the wrapper module</a></H3>
+
+
+<p>
+When SWIG creates wrappers from an interface file, say foo.i, two Python modules are
+created. There is a pure Python module module (foo.py) and C/C++ code which is
+built and linked into a dynamically (or statically) loaded module _foo
+(see the <a href="Python.html#Python_nn3">Preliminaries section</a> for details). So, the interface
+file really defines two Python modules. How these two modules are loaded is
+covered next.
+</p>
+
+<p>
+The pure Python module needs to load the C/C++ module in order to link
+to the wrapped C/C++ methods. To do this it must make some assumptions
+about what package the C/C++ module may be located in. The approach the
+pure Python module uses to find the C/C++ module is as follows:
+</p>
+
+<ol>
+ <li><p>The pure Python module, foo.py, tries to load the C/C++ module, _foo, from the same package foo.py is
+ located in. The package name is determined from the <tt>__name__</tt>
+ attribute given to foo.py by the Python loader that imported
+ foo.py. If foo.py is not in a package then _foo is loaded
+ as a global module.</p>
+ </li>
+ <li><p>If the above import of _foo results in an ImportError
+ being thrown, then foo.py makes a final attempt to load _foo
+ as a global module.</p>
+ </li>
+</ol>
+
+<p>
+As an example suppose foo.i is compiled into foo.py and _foo.so. Assuming
+/dir is on PYTHONPATH, then the two modules can be installed and used in the
+following ways:
+</p>
+
+
+<H4><a name="Python_package_search_both_package_modules">36.11.6.1 Both modules in the same package</a></H4>
+
+
+<p>Both modules are in one package:</p>
+<div class="diagram">
+<pre>
+/dir/package/foo.py
+/dir/package/__init__.py
+/dir/package/_foo.so
+</pre>
+</div>
+<p>And imported with</p>
+<div class="diagram">
+<pre>
+from package import foo
+</pre>
+</div>
+
+
+<H4><a name="Python_package_search_wrapper_split">36.11.6.2 Split modules</a></H4>
+
+
+<p>The pure python module is in a package and the C/C++ module is global:</p>
+<div class="diagram">
+<pre>
+/dir/package/foo.py
+/dir/package/__init__.py
+/dir/_foo.so
+</pre>
+</div>
+<p>And imported with</p>
+<div class="diagram">
+<pre>
+from package import foo
+</pre>
+</div>
+
+
+<H4><a name="Python_package_search_both_global_modules">36.11.6.3 Both modules are global</a></H4>
+
+
+<p>Both modules are global:</p>
+<div class="diagram">
+<pre>
+/dir/foo.py
+/dir/_foo.so
+</pre>
+</div>
+<p>And imported with</p>
+<div class="diagram">
+<pre>
+import foo
+</pre>
+</div>
+
+<p>
+If _foo is statically linked into an embedded Python interpreter, then it may or
+may not be in a Python package. This depends in the exact way the module was
+loaded statically. The above search order will still be used for statically
+loaded modules. So, one may place the module either globally or in a package
+as desired.
+</p>
+
+<H4><a name="Python_package_search_static">36.11.6.4 Statically linked C modules</a></H4>
+
+
+<p>It is strongly recommended to use dynamically linked modules for the C
+portion of your pair of Python modules.
+If for some reason you still need
+to link the C module of the pair of Python modules generated by SWIG into
+your interpreter, then this section provides some details on how this impacts
+the pure Python modules ability to locate the other part of the pair.
+Please also see the <a href="Python.html#Python_nn8">Static Linking</a> section.
+</p>
+
+<p>When Python is extended with C code the Python interpreter needs to be
+informed about details of the new C functions that have been linked into
+the executable. The code to do this is created by SWIG and is automatically
+called in the correct way when the module is dynamically loaded. However
+when the code is not dynamically loaded (because it is statically linked)
+Then the initialization method for the module created by SWIG is not
+called automatically and the Python interpreter has no idea that the
+new SWIG C module exists.
+</p>
+
+<p>Before Python 3, one could simply call the init method created by SWIG
+which would have normally been called when the shared object was dynamically
+loaded. The specific name of this method is not given here because statically
+linked modules are not encouraged with SWIG
+(<a href="Python.html#Python_nn8">Static Linking</a>). However one can find this
+init function in the C file generated by SWIG.
+</p>
+
+<p>If you are really keen on static linking there are two ways
+to initialize the SWIG generated C module with the init method. Which way
+you use depends on what version of Python your module is being linked with.
+Python 2 and Python 3 treat this init function differently. And the way
+they treat it affects how the pure Python module will be able to
+locate the C module.
+</p>
+
+<p>The details concerning this are covered completly in the documentation
+for Python itself. Links to the relavent sections follow:
+</p>
+
+<ul>
+ <li><a href="https://docs.python.org/2/extending/extending.html#methodtable">Extending in python2</a></li>
+ <li><a href="https://docs.python.org/3.6/extending/extending.html#the-module-s-method-table-and-initialization-function">Extending in python3</a></li>
+</ul>
+
+<p>There are two keys things to understand. The first is that in
+Python 2 the init() function returns void. In Python 3 the init() function
+returns a PyObject * which points to the new module. Secondly, when
+you call the init() method manually, you are the Python importer. So, you
+determine which package the C module will be located in.
+</p>
+
+<p>So, if you are using Python 3 it is important that you follow what is
+described in the Python documentation linked above. In particular, you can't
+simply call the init() function generated by SWIG and cast the PyObject
+pointer it returns over the side. If you do then Python 3 will have no
+idea that your C module exists and the pure Python half of your wrapper will
+not be able to find it. You need to register your module with the Python
+interpreter as described in the Python docs.
+</p>
+
+<p>With Python 2 things are somewhat more simple. In this case the init function
+returns void. Calling it will register your new C module as a <b>global</b>
+module. The pure Python part of the SWIG wrapper will be able to find it
+because it tries both the pure Python module it is part of and the global
+module. If you wish not to have the statically linked module be a global
+module then you will either need to refer to the Python documentation on how
+to do this (remember you are now the Python importer) or use dynamic linking.
+</p>
<H2><a name="Python_python3support">36.12 Python 3 Support</a></H2>
diff --git a/Doc/Manual/Scilab.html b/Doc/Manual/Scilab.html
index aa4a3e99f..0ac4c059f 100644
--- a/Doc/Manual/Scilab.html
+++ b/Doc/Manual/Scilab.html
@@ -40,12 +40,12 @@
<li><a href="#Scilab_wrapping_pointers">Pointers</a>
<ul>
<li><a href="#Scilab_wrapping_pointers_pointer_adresses">Utility functions</a>
-<li><a href="#Scilab_wrapping_pointers_null_pointers">Null pointers</a>
+<li><a href="#Scilab_wrapping_pointers_null_pointers">Null pointers:</a>
</ul>
<li><a href="#Scilab_wrapping_structs">Structures</a>
<li><a href="#Scilab_wrapping_cpp_classes">C++ classes</a>
<li><a href="#Scilab_wrapping_cpp_inheritance">C++ inheritance</a>
-<li><a href="#Scilab_wrapping_cpp_overloading">C++ overloading</a></li>
+<li><a href="#Scilab_wrapping_cpp_overloading">C++ overloading</a>
<li><a href="#Scilab_wrapping_pointers_references_values_arrays">Pointers, references, values, and arrays</a>
<li><a href="#Scilab_wrapping_cpp_templates">C++ templates</a>
<li><a href="#Scilab_wrapping_cpp_operators">C++ operators</a>
@@ -56,7 +56,6 @@
<li><a href="#Scilab_typemaps">Type mappings and libraries</a>
<ul>
<li><a href="#Scilab_typemaps_primitive_types">Default primitive type mappings</a>
-<li><a href="#Scilab_typemaps_non-primitive_types">Default type mappings for non-primitive types</a>
<li><a href="#Scilab_typemaps_arrays">Arrays</a>
<li><a href="#Scilab_typemaps_pointer-to-pointers">Pointer-to-pointers</a>
<li><a href="#Scilab_typemaps_matrices">Matrices</a>
@@ -764,11 +763,11 @@ Why a native pointer is not mapped to a Scilab pointer (type name: "pointer", ty
<p>
Notes:
+</p>
<ul>
<li>type tracking needs the SWIG runtime to be first initialized with the appropriate function (see the <a href="#Scilab_module_initialization">Module initialization</a> section).</li>
<li>for any reason, if a wrapped pointer type is unknown (or if the SWIG runtime is not initialized), SWIG maps it to a Scilab pointer. Also, a Scilab pointer is always accepted as a pointer argument of a wrapped function. The drawaback is that pointer type is lost.</li>
</ul>
-</p>
<p>
Following is an example of the wrapping of the C <tt>FILE*</tt> pointer:
@@ -854,6 +853,7 @@ ans =
<H4><a name="Scilab_wrapping_pointers_null_pointers">39.3.6.2 Null pointers:</a></H4>
+
<p>
Using the previous <tt>SWIG_this()</tt> and <tt>SWIG_ptr()</tt>, it is possible to create and check null pointers:
</p>
@@ -904,6 +904,7 @@ Several functions are generated:
</ul>
+<p>
Usage example:
</p>
@@ -963,7 +964,7 @@ ans =
<p>
Note: the pointer to the struct works as described in <a href="Scilab_wrapping_pointers">Pointers</a>. For example, the type of the struct pointer can be get with <tt>typeof</tt>, as following:
-<p>
+</p>
<div class="targetlang"><pre>
--&gt; example_Init();
@@ -1027,7 +1028,7 @@ ans =
<p>
Note: like structs, class pointers are mapped as described in <a href="Scilab_wrapping_pointers">Pointers</a>. Let's give an example which shows that each class pointer type is a new type in Scilab that can be used for example (through <a href="https://help.scilab.org/docs/5.5.2/en_US/overloading.html">overloading</a>) to implement a custom print for the <tt>Point</tt> class:
-<p>
+</p>
<div class="targetlang"><pre>
--&gt; function %_p_Point_p(p)
@@ -1120,27 +1121,26 @@ But we can use either use the <tt>get_perimeter()</tt> function of the parent cl
<H3><a name="Scilab_wrapping_cpp_overloading">39.3.10 C++ overloading</a></H3>
+
<p>
As explained in <a href="http://www.swig.org/Doc3.0/SWIGPlus.html#SWIGPlus_overloaded_methods">6.15</a> SWIG provides support for overloaded functions and constructors.
</p>
<p>As SWIG knows pointer types, the overloading works also with pointer types, here is is an example with a function <tt>magnify</tt> overloaded for the previous classes <tt>Shape</tt> and <tt>Circle</tt>:
+</p>
-<p>
<div class="code"><pre>
%module example
void magnify(Square *square, double factor) {
- square->size *= factor;
+ square-&gt;size *= factor;
};
void magnify(Circle *circle, double factor) {
- square->radius *= factor;
+ square-&gt;radius *= factor;
};
</pre></div>
-</p>
-<p>
<div class="targetlang"><pre>
--&gt; example_Init();
--&gt; c = new_Circle(3);
@@ -1157,7 +1157,6 @@ void magnify(Circle *circle, double factor) {
20;
</pre></div>
-</p>
<H3><a name="Scilab_wrapping_pointers_references_values_arrays">39.3.11 Pointers, references, values, and arrays</a></H3>
diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html
index bfa58f1ae..8417bec15 100644
--- a/Doc/Manual/Sections.html
+++ b/Doc/Manual/Sections.html
@@ -8,7 +8,7 @@
<H1><a name="Sections">SWIG-3.0 Documentation</a></H1>
<p>
-Last update : SWIG-3.0.9 (in progress)
+Last update : SWIG-3.0.11 (in progress)
</p>
<H2><a name="Sections_Sections">Sections</a></H2>
diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html
index c365a879b..b074e9f94 100644
--- a/Doc/Manual/Typemaps.html
+++ b/Doc/Manual/Typemaps.html
@@ -750,7 +750,7 @@ code : { ... }
<p>
Note that the preprocessor will expand code within the {} delimiters, but not in the last two styles of delimiters,
-see <a href="Preprocessor.html#Preprocessor_typemap_delimiters">Preprocessor and Typemaps</a>.
+see <a href="Preprocessor.html#Preprocessor_delimiters">Preprocessor and Typemaps</a>.
Here are some examples of valid typemap specifications:
</p>
diff --git a/Examples/Makefile.in b/Examples/Makefile.in
index 6a64520bf..9b510274a 100644
--- a/Examples/Makefile.in
+++ b/Examples/Makefile.in
@@ -327,11 +327,11 @@ else
endif
PYTHON_SO = @PYTHON_SO@
-# SWIG option for Python
+# SWIG option for Python3
ifeq (,$(PY3))
- SWIGPYTHON = $(SWIG) -python
+ SWIGOPTPY3 =
else
- SWIGPYTHON = $(SWIG) -python -py3
+ SWIGOPTPY3 = -py3
endif
PEP8 = @PEP8@
@@ -342,7 +342,7 @@ PEP8_FLAGS = --ignore=E402,E501,E30,W291,W391
# ----------------------------------------------------------------
python: $(SRCDIR_SRCS)
- $(SWIGPYTHON) $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
+ $(SWIG) -python $(SWIGOPTPY3) $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) $(PYTHON_INCLUDE)
$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(PYTHON_DLNK) $(LIBS) -o $(LIBPREFIX)_$(TARGET)$(PYTHON_SO)
@@ -351,7 +351,7 @@ python: $(SRCDIR_SRCS)
# -----------------------------------------------------------------
python_cpp: $(SRCDIR_SRCS)
- $(SWIGPYTHON) -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
+ $(SWIG) -python $(SWIGOPTPY3) -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(PYTHON_INCLUDE)
$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(PYTHON_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)_$(TARGET)$(PYTHON_SO)
@@ -367,12 +367,12 @@ TKINTER =
PYTHON_LIBOPTS = $(PYTHON_LINK) @LIBS@ $(TKINTER) $(SYSLIBS)
python_static: $(SRCDIR_SRCS)
- $(SWIGPYTHON) -lembed.i $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
+ $(SWIG) -python $(SWIGOPTPY3) -lembed.i $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) \
$(PYTHON_INCLUDE) $(LIBS) -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET)
python_static_cpp: $(SRCDIR_SRCS)
- $(SWIGPYTHON) -c++ -lembed.i $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
+ $(SWIG) -python $(SWIGOPTPY3) -c++ -lembed.i $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) \
$(PYTHON_INCLUDE) $(LIBS) -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET)
@@ -429,7 +429,7 @@ python_clean:
##################################################################
# Make sure these locate your Octave installation
-OCTAVE = OCTAVE_HISTFILE=/dev/null @OCTAVE@
+OCTAVE = @OCTAVE@
OCTAVE_CXX = $(DEFS) @OCTAVE_CPPFLAGS@ @OCTAVE_CXXFLAGS@
# Extra Octave specific dynamic linking options
@@ -463,7 +463,7 @@ octave_cpp: $(SRCDIR_SRCS)
# -----------------------------------------------------------------
octave_run:
- $(RUNTOOL) $(OCTAVE) $(OCTAVE_SCRIPT) $(RUNPIPE)
+ OCTAVE_HISTFILE=/dev/null $(RUNTOOL) $(OCTAVE) $(OCTAVE_SCRIPT) $(RUNPIPE)
# -----------------------------------------------------------------
# Version display
@@ -587,6 +587,7 @@ JAVASO =@JAVASO@
JAVALDSHARED = @JAVALDSHARED@
JAVACXXSHARED = @JAVACXXSHARED@
JAVACFLAGS = @JAVACFLAGS@
+JAVAFLAGS = @JAVAFLAGS@
JAVA = @JAVA@
JAVAC = @JAVAC@ -d .
@@ -620,7 +621,7 @@ java_compile: $(SRCDIR_SRCS)
# -----------------------------------------------------------------
java_run:
- env LD_LIBRARY_PATH=$$PWD $(RUNTOOL) $(JAVA) $(RUNME) $(RUNPIPE)
+ env LD_LIBRARY_PATH=$$PWD $(RUNTOOL) $(JAVA) $(JAVAFLAGS) $(RUNME) $(RUNPIPE)
# -----------------------------------------------------------------
# Version display
@@ -1670,6 +1671,7 @@ R = R
RCXXSRCS = $(INTERFACE:.i=_wrap.cpp) #Need to use _wrap.cpp for R build system as it does not understand _wrap.cxx
RRSRC = $(INTERFACE:.i=.R)
R_CFLAGS=-fPIC
+R_OPT = --slave --quiet --no-save --no-restore
R_SCRIPT=$(SRCDIR)$(RUNME).R
# need to compile .cxx files outside of R build system to make sure that
@@ -1702,7 +1704,7 @@ endif
# -----------------------------------------------------------------
r_run:
- $(RUNTOOL) $(R) CMD BATCH $(R_SCRIPT) $(RUNPIPE)
+ $(RUNTOOL) $(R) $(R_OPT) -f $(R_SCRIPT) $(RUNPIPE)
# -----------------------------------------------------------------
# Version display
diff --git a/Examples/lua/arrays/example.i b/Examples/lua/arrays/example.i
index 3d5b60dc6..eafd8ff55 100644
--- a/Examples/lua/arrays/example.i
+++ b/Examples/lua/arrays/example.i
@@ -14,18 +14,19 @@ See the lua code for how they are called
// this adds some lua code directly into the module
// warning: you need the example. prefix if you want it added into the module
-// addmittedly this code is a bit tedious, but its a one off effort
+// admittedly this code is a bit tedious, but its a one off effort
%luacode {
function example.sort_int2(t)
- local len=table.maxn(t) -- the len
+-- local len=table.maxn(t) -- the len - maxn deprecated in 5.3
+ local len=0; for _ in pairs(t) do len=len+1 end
local arr=example.new_int(len)
for i=1,len do
- example.int_setitem(arr,i-1,t[i]) -- note: C index is one less then lua indea
+ example.int_setitem(arr,i-1,t[i]) -- note: C index is one less then lua index
end
example.sort_int(arr,len) -- call the fn
-- copy back
for i=1,len do
- t[i]=example.int_getitem(arr,i-1) -- note: C index is one less then lua indea
+ t[i]=example.int_getitem(arr,i-1) -- note: C index is one less then lua index
end
example.delete_int(arr) -- must delete it
end
diff --git a/Examples/python/import_packages/Makefile b/Examples/python/import_packages/Makefile
index 72b424a90..f428d6f5c 100644
--- a/Examples/python/import_packages/Makefile
+++ b/Examples/python/import_packages/Makefile
@@ -10,11 +10,15 @@ import_packages_subdirs = \
from_init3 \
relativeimport1 \
relativeimport2 \
- relativeimport3
+ relativeimport3 \
+ split_modules \
+ namespace_pkg
+
check: build
if test "x$(SRCDIR)" != x; then \
- for file in `cd $(SRCDIR) && find . -type f -name __init__.py`; do \
+ for file in `cd $(SRCDIR) && find . -type f -name "*.py"`; do \
+ mkdir -p `dirname $$file`; \
cp "${SRCDIR}$$file" "$$file" || exit 1; \
done; \
fi; \
@@ -35,7 +39,7 @@ static:
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
if test "x$(SRCDIR)" != x; then \
- for file in `cd $(SRCDIR) && find . -type f -name __init__.py`; do \
+ for file in `cd $(SRCDIR) && find . -type f -name "*.py"`; do \
rm -f "$$file" || exit 1; \
done; \
fi; \
diff --git a/Examples/python/import_packages/README b/Examples/python/import_packages/README
index 69fe3516e..187a5d64e 100644
--- a/Examples/python/import_packages/README
+++ b/Examples/python/import_packages/README
@@ -1,2 +1,4 @@
These are actually regression tests for SF bug #1297 (GH issue #7).
-See individual READMEs in subdirectories.
+The namespace_pkg is an example of python3's namespace packages.
+
+See individual READMEs in subdirectories. \ No newline at end of file
diff --git a/Examples/python/import_packages/namespace_pkg/Makefile b/Examples/python/import_packages/namespace_pkg/Makefile
new file mode 100644
index 000000000..d86871344
--- /dev/null
+++ b/Examples/python/import_packages/namespace_pkg/Makefile
@@ -0,0 +1,17 @@
+TOP = ../../..
+SWIGEXE = $(TOP)/../swig
+SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
+TARGET = robin
+INTERFACE = robin.i
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
+ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
+ rm -rf path1 path2 path3 path4.zip
diff --git a/Examples/python/import_packages/namespace_pkg/README b/Examples/python/import_packages/namespace_pkg/README
new file mode 100644
index 000000000..8f7297a51
--- /dev/null
+++ b/Examples/python/import_packages/namespace_pkg/README
@@ -0,0 +1,25 @@
+ This is an example (and test) of using swig generated modules in the context
+of python3's namespace packages:
+
+https://www.python.org/dev/peps/pep-0420/
+
+ Consequently, this example requires python (3.3 or newer) to build and run.
+
+ This example creates a simple swig module named robin. The robin.py module
+has a companion C module named _robin.so. The robin module is tested in four
+ways:
+
+ 1) As a non-package module (tested by nonpkg.py)
+
+ 2) With robin.py and _robin.so in the brave package under the path1
+ subdirectory. (tested by normal.py)
+
+ 3) With robin.py in path2/brave and _robin.so in path3/brave
+ (tested by split.py)
+
+ 4) With robin.py contained in a zip file (path4.zip) as brave/robin.py and
+ _robin.so found on the filesystem under path3/brave (tested by zipsplit.py)
+
+Note: Using namespace packages with subpackages (such as brave.sir.robin) where
+ robin.py is located in a zipfile requires python-3.5.1 or newer as
+ python's zipimporter only worked with packages of depth 1 until then. \ No newline at end of file
diff --git a/Examples/python/import_packages/namespace_pkg/nonpkg.py b/Examples/python/import_packages/namespace_pkg/nonpkg.py
new file mode 100644
index 000000000..acf0aedbd
--- /dev/null
+++ b/Examples/python/import_packages/namespace_pkg/nonpkg.py
@@ -0,0 +1,5 @@
+# import robin as a module in the global namespace
+
+import robin
+
+assert(robin.run() == "AWAY!")
diff --git a/Examples/python/import_packages/namespace_pkg/normal.py b/Examples/python/import_packages/namespace_pkg/normal.py
new file mode 100644
index 000000000..fc26c0216
--- /dev/null
+++ b/Examples/python/import_packages/namespace_pkg/normal.py
@@ -0,0 +1,7 @@
+import sys
+# Package brave found under one path
+sys.path.insert(0, 'path1')
+
+from brave import robin
+
+assert(robin.run() == "AWAY!")
diff --git a/Examples/python/import_packages/namespace_pkg/nstest.py b/Examples/python/import_packages/namespace_pkg/nstest.py
new file mode 100644
index 000000000..9b075ad8c
--- /dev/null
+++ b/Examples/python/import_packages/namespace_pkg/nstest.py
@@ -0,0 +1,45 @@
+import sys
+import os
+import shutil
+import zipfile
+
+
+def copyMods():
+ dirs = ['path1', 'path2', 'path3']
+
+ # Clean out any old package paths
+ for d in dirs:
+ if os.path.isdir(d):
+ shutil.rmtree(d)
+
+ for d in dirs:
+ os.mkdir(d)
+ os.mkdir(os.path.join(d, 'brave'))
+
+ shutil.copy('robin.py', os.path.join('path1', 'brave'))
+ os.system('cp _robin.* ' + os.path.join('path1', 'brave'))
+
+ shutil.copy('robin.py', os.path.join('path2', 'brave'))
+ os.system('cp _robin.* ' + os.path.join('path3', 'brave'))
+
+ mkzip()
+
+def mkzip():
+ zf = zipfile.ZipFile("path4.zip", "w")
+ zf.writestr("brave/", b'')
+ zf.write('robin.py', 'brave/robin.py')
+ zf.close()
+
+
+def main():
+ copyMods()
+
+ # Run each test with a separate interpreter
+ os.system(sys.executable + " nonpkg.py")
+ os.system(sys.executable + " normal.py")
+ os.system(sys.executable + " split.py")
+ os.system(sys.executable + " zipsplit.py")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/Examples/python/import_packages/namespace_pkg/robin.i b/Examples/python/import_packages/namespace_pkg/robin.i
new file mode 100644
index 000000000..394922130
--- /dev/null
+++ b/Examples/python/import_packages/namespace_pkg/robin.i
@@ -0,0 +1,7 @@
+%module robin
+
+%inline %{
+const char *run(void) {
+ return "AWAY!";
+}
+%}
diff --git a/Examples/python/import_packages/namespace_pkg/runme.py b/Examples/python/import_packages/namespace_pkg/runme.py
new file mode 100644
index 000000000..9c22d36fb
--- /dev/null
+++ b/Examples/python/import_packages/namespace_pkg/runme.py
@@ -0,0 +1,17 @@
+# These examples rely on namespace packages. Don't
+# run them for old python interpreters.
+import sys
+import os.path
+
+testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
+print "Testing " + testname + " - namespace packages"
+
+if sys.version_info < (3, 3, 0):
+ print " Not importing nstest as Python version is < 3.3"
+ sys.exit(0)
+
+import nstest
+
+print " Finished importing nstest"
+
+nstest.main()
diff --git a/Examples/python/import_packages/namespace_pkg/split.py b/Examples/python/import_packages/namespace_pkg/split.py
new file mode 100644
index 000000000..1b66c2d49
--- /dev/null
+++ b/Examples/python/import_packages/namespace_pkg/split.py
@@ -0,0 +1,9 @@
+import sys
+# Package brave split into two paths.
+# path2/brave/robin.py and path3/brave/_robin.so
+sys.path.insert(0, 'path2')
+sys.path.insert(0, 'path3')
+
+from brave import robin
+
+assert(robin.run() == "AWAY!")
diff --git a/Examples/python/import_packages/namespace_pkg/zipsplit.py b/Examples/python/import_packages/namespace_pkg/zipsplit.py
new file mode 100644
index 000000000..9e35559e3
--- /dev/null
+++ b/Examples/python/import_packages/namespace_pkg/zipsplit.py
@@ -0,0 +1,9 @@
+import sys
+# Package brave split into two paths.
+# brave/robin.py (in path4.zip) and path3/brave/_robin.so
+sys.path.insert(0, 'path4.zip')
+sys.path.insert(0, 'path3')
+
+from brave import robin
+
+assert(robin.run() == "AWAY!")
diff --git a/Examples/python/import_packages/split_modules/Makefile b/Examples/python/import_packages/split_modules/Makefile
new file mode 100644
index 000000000..65d635bb7
--- /dev/null
+++ b/Examples/python/import_packages/split_modules/Makefile
@@ -0,0 +1,26 @@
+TOP = ../../..
+LIBS =
+
+subdirs = vanilla vanilla_split
+
+
+check: build
+ for s in $(subdirs); do \
+ (cd $$s && $(MAKE) check); \
+ done
+
+build:
+ for s in $(subdirs); do \
+ (cd $$s && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build); \
+ done
+
+static:
+ for s in $(subdirs); do \
+ (cd $$s && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static); \
+ done
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
+ for s in $(subdirs); do \
+ (cd $$s && $(MAKE) clean); \
+ done
diff --git a/Examples/python/import_packages/split_modules/README b/Examples/python/import_packages/split_modules/README
new file mode 100644
index 000000000..0cb543e8a
--- /dev/null
+++ b/Examples/python/import_packages/split_modules/README
@@ -0,0 +1,7 @@
+ These examples/tests are for when the SWIG generated wrapper module is split
+between two packages. Specifically the pure python part is part of a package
+and the C/C++ part is not in any package at all. Historically SWIG has
+supported this sort of thing.
+
+vanilla # "plane Jane" module both halves in pkg1
+vanilla_split # python 1/2 in pkg1 C 1/2 in global namespace
diff --git a/Examples/python/import_packages/split_modules/vanilla/Makefile b/Examples/python/import_packages/split_modules/vanilla/Makefile
new file mode 100644
index 000000000..b679d60a0
--- /dev/null
+++ b/Examples/python/import_packages/split_modules/vanilla/Makefile
@@ -0,0 +1,18 @@
+TOP = ../../../..
+SWIGEXE = $(TOP)/../swig
+SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
+SWIGOPT =
+LIBS =
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
+
+build:
+ cd pkg1 && $(MAKE) build
+
+static:
+ cd pkg1 && $(MAKE) static
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean
+ cd pkg1 && $(MAKE) -f $(TOP)/../Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean
diff --git a/Examples/python/import_packages/split_modules/vanilla/pkg1/Makefile b/Examples/python/import_packages/split_modules/vanilla/pkg1/Makefile
new file mode 100644
index 000000000..921bb9951
--- /dev/null
+++ b/Examples/python/import_packages/split_modules/vanilla/pkg1/Makefile
@@ -0,0 +1,18 @@
+TOP = ../../../../..
+SWIGEXE = $(TOP)/../swig
+SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
+SWIGOPT =
+LIBS =
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
+ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
+ SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp
+
+static:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
+ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
+ SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean
diff --git a/Examples/python/import_packages/split_modules/vanilla/pkg1/__init__.py b/Examples/python/import_packages/split_modules/vanilla/pkg1/__init__.py
new file mode 100644
index 000000000..7b1594cc8
--- /dev/null
+++ b/Examples/python/import_packages/split_modules/vanilla/pkg1/__init__.py
@@ -0,0 +1 @@
+# killroy was here
diff --git a/Examples/python/import_packages/split_modules/vanilla/pkg1/foo.i b/Examples/python/import_packages/split_modules/vanilla/pkg1/foo.i
new file mode 100644
index 000000000..60ce16ec3
--- /dev/null
+++ b/Examples/python/import_packages/split_modules/vanilla/pkg1/foo.i
@@ -0,0 +1,10 @@
+%module(package="pkg1") foo
+%{
+static unsigned count(void)
+{
+ return 3;
+}
+%}
+
+unsigned count(void);
+
diff --git a/Examples/python/import_packages/split_modules/vanilla/runme.py b/Examples/python/import_packages/split_modules/vanilla/runme.py
new file mode 100644
index 000000000..a188364f1
--- /dev/null
+++ b/Examples/python/import_packages/split_modules/vanilla/runme.py
@@ -0,0 +1,10 @@
+import os.path
+
+testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
+print "Testing " + testname + " - split modules"
+
+import pkg1.foo
+
+print " Finished importing pkg1.foo"
+
+assert(pkg1.foo.count() == 3)
diff --git a/Examples/python/import_packages/split_modules/vanilla_split/Makefile b/Examples/python/import_packages/split_modules/vanilla_split/Makefile
new file mode 100644
index 000000000..c322b5aec
--- /dev/null
+++ b/Examples/python/import_packages/split_modules/vanilla_split/Makefile
@@ -0,0 +1,22 @@
+TOP = ../../../..
+SWIGEXE = $(TOP)/../swig
+SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
+SWIGOPT = -outdir pkg1
+LIBS =
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
+ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
+ SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp
+
+static:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
+ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
+ SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean
+ cd pkg1 && $(MAKE) -f $(TOP)/../Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean
diff --git a/Examples/python/import_packages/split_modules/vanilla_split/foo.i b/Examples/python/import_packages/split_modules/vanilla_split/foo.i
new file mode 100644
index 000000000..60ce16ec3
--- /dev/null
+++ b/Examples/python/import_packages/split_modules/vanilla_split/foo.i
@@ -0,0 +1,10 @@
+%module(package="pkg1") foo
+%{
+static unsigned count(void)
+{
+ return 3;
+}
+%}
+
+unsigned count(void);
+
diff --git a/Examples/python/import_packages/split_modules/vanilla_split/pkg1/__init__.py b/Examples/python/import_packages/split_modules/vanilla_split/pkg1/__init__.py
new file mode 100644
index 000000000..7b1594cc8
--- /dev/null
+++ b/Examples/python/import_packages/split_modules/vanilla_split/pkg1/__init__.py
@@ -0,0 +1 @@
+# killroy was here
diff --git a/Examples/python/import_packages/split_modules/vanilla_split/runme.py b/Examples/python/import_packages/split_modules/vanilla_split/runme.py
new file mode 100644
index 000000000..a188364f1
--- /dev/null
+++ b/Examples/python/import_packages/split_modules/vanilla_split/runme.py
@@ -0,0 +1,10 @@
+import os.path
+
+testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
+print "Testing " + testname + " - split modules"
+
+import pkg1.foo
+
+print " Finished importing pkg1.foo"
+
+assert(pkg1.foo.count() == 3)
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index d81b62e5a..1658e509b 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -174,7 +174,6 @@ CPP_TEST_CASES += \
director_abstract \
director_alternating \
director_basic \
- director_property \
director_binary_string \
director_classes \
director_classic \
@@ -189,12 +188,14 @@ CPP_TEST_CASES += \
director_ignore \
director_keywords \
director_namespace_clash \
+ director_nested \
director_nspace \
director_nspace_director_name_collision \
- director_nested \
director_overload \
director_overload2 \
+ director_pass_by_value \
director_primitives \
+ director_property \
director_protected \
director_protected_overloaded \
director_redefined \
@@ -363,6 +364,7 @@ CPP_TEST_CASES += \
smart_pointer_const2 \
smart_pointer_const_overload \
smart_pointer_extend \
+ smart_pointer_ignore \
smart_pointer_member \
smart_pointer_multi \
smart_pointer_multi_typedef \
@@ -403,6 +405,7 @@ CPP_TEST_CASES += \
template_default2 \
template_default_arg \
template_default_arg_overloaded \
+ template_default_arg_overloaded_extend \
template_default_arg_virtual_destructor \
template_default_class_parms \
template_default_class_parms_typedef \
@@ -671,6 +674,11 @@ MULTI_CPP_TEST_CASES += \
wallkw.cpptest: SWIGOPT += -Wallkw
preproc_include.ctest: SWIGOPT += -includeall
+# Allow modules to define temporarily failing tests.
+C_TEST_CASES := $(filter-out $(FAILING_C_TESTS),$(C_TEST_CASES))
+CPP_TEST_CASES := $(filter-out $(FAILING_CPP_TESTS),$(CPP_TEST_CASES))
+MULTI_CPP_TEST_CASES := $(filter-out $(FAILING_MULTI_CPP_TESTS),$(MULTI_CPP_TEST_CASES))
+
NOT_BROKEN_TEST_CASES = $(CPP_TEST_CASES:=.cpptest) \
$(C_TEST_CASES:=.ctest) \
@@ -701,6 +709,7 @@ all: $(NOT_BROKEN_TEST_CASES) $(BROKEN_TEST_CASES)
broken: $(BROKEN_TEST_CASES)
check: $(NOT_BROKEN_TEST_CASES)
+ @echo $(words $^) $(LANGUAGE) tests passed
check-c: $(C_TEST_CASES:=.ctest)
@@ -708,6 +717,13 @@ check-cpp: $(CPP_TEST_CASES:=.cpptest)
check-cpp11: $(CPP11_TEST_CASES:=.cpptest)
+check-failing-test = \
+ $(MAKE) -s $1.$2 >/dev/null 2>/dev/null && echo "Failing test $1 passed."
+
+check-failing:
+ +-$(foreach t,$(FAILING_C_TESTS),$(call check-failing-test,$t,ctest);)
+ +-$(foreach t,$(FAILING_CPP_TESTS),$(call check-failing-test,$t,cpptest);)
+ +-$(foreach t,$(FAILING_MULTI_CPP_TESTS),$(call check-failing-test,$t,multicpptest);)
endif
# partialcheck target runs SWIG only, ie no compilation or running of tests (for a subset of languages)
diff --git a/Examples/test-suite/constant_directive.i b/Examples/test-suite/constant_directive.i
index fc6b6cd92..89f13cecc 100644
--- a/Examples/test-suite/constant_directive.i
+++ b/Examples/test-suite/constant_directive.i
@@ -3,6 +3,9 @@
// %constant and struct
%inline %{
+#if defined(_MSC_VER)
+ #pragma warning(disable : 4190) // warning C4190: 'result' has C-linkage specified, but returns UDT 'Type1' which is incompatible with C
+#endif
struct Type1 {
Type1(int val = 0) : val(val) {}
int val;
diff --git a/Examples/test-suite/cpp11_type_aliasing.i b/Examples/test-suite/cpp11_type_aliasing.i
index 87443633a..2f6ea3aa7 100644
--- a/Examples/test-suite/cpp11_type_aliasing.i
+++ b/Examples/test-suite/cpp11_type_aliasing.i
@@ -2,15 +2,6 @@
// Type aliasing seg fault : Github issue #424
-%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) Target;
-%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) Int;
-%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) IntRef;
-%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) IntPtrRef;
-%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) IntRValueRef;
-%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) IntArray;
-%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) HalideTargetPtr1;
-%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) HalideTargetPtr2;
-
%inline %{
namespace Halide {
@@ -53,14 +44,69 @@ public:
%inline %{
-using Int = int;
-using IntRef = int&;
-using IntPtrRef = int*&;
-using IntRValueRef = int&&;
-using IntArray = int[];
-
using HalideTargetPtr1 = Halide::Target*;
namespace Halide {
using HalideTargetPtr2 = Target*;
}
%}
+
+// Define some types
+
+%inline %{
+using Int = int;
+using IntPtr = Int*;
+using IntRef = Int&;
+using IntPtrRef = Int*&;
+using IntRValueRef = Int&&;
+using IntArray = Int[];
+%}
+
+// Test that SWIG understands these new types
+
+%callback("%s_cb");
+Int mult2(Int x);
+%nocallback;
+
+%inline %{
+Int mult2(Int x) { return x * 2; }
+IntPtr allocate_int() { return new Int(12); }
+void free_int(int* ptr) { delete ptr; }
+void inplace_mult2(IntRef x) { x *= 2; }
+Int read_int(IntPtr ptr) { return *ptr; }
+
+template <typename T> class Pair {
+public:
+ using data_t = T;
+
+ data_t a, b;
+
+ Pair() : a(), b() { }
+ Pair(data_t a, data_t b) : a(a), b(b) { }
+ data_t first() { return a; }
+ data_t second() { return b; }
+};
+%}
+
+%template(int_pair) Pair<Int>;
+
+%inline %{
+using PairInt = Pair<Int>;
+
+class PairSubclass : public PairInt {
+public:
+ PairSubclass(data_t a, data_t b) : PairInt(a, b) { }
+
+ using const_ref_data_t = const data_t&;
+};
+
+PairSubclass::data_t plus1(PairSubclass::const_ref_data_t x) { return x + 1; }
+%}
+
+// Test function pointers
+
+%inline %{
+using callback_t = int(*)(int);
+
+callback_t get_callback() { return mult2; }
+int call(callback_t func, int param) { return func(param); }
+%}
diff --git a/Examples/test-suite/csharp/director_pass_by_value_runme.cs b/Examples/test-suite/csharp/director_pass_by_value_runme.cs
new file mode 100644
index 000000000..ba6371590
--- /dev/null
+++ b/Examples/test-suite/csharp/director_pass_by_value_runme.cs
@@ -0,0 +1,43 @@
+using System;
+using director_pass_by_valueNamespace;
+
+public class runme
+{
+ private static void WaitForGC()
+ {
+ System.GC.Collect();
+ System.GC.WaitForPendingFinalizers();
+ System.Threading.Thread.Sleep(10);
+ }
+
+ static void Main()
+ {
+ runme r = new runme();
+ r.run();
+ }
+
+ void run()
+ {
+ Caller caller = new Caller();
+ caller.call_virtualMethod(new director_pass_by_value_Derived());
+ {
+ int countdown = 5;
+ while (true) {
+ WaitForGC();
+ if (--countdown == 0)
+ break;
+ };
+ }
+ // bug was the passByVal 'global' object was destroyed after the call to virtualMethod had finished.
+ int ret = runme.passByVal.getVal();
+ if (ret != 0x12345678)
+ throw new Exception("Bad return value, got " + ret.ToString("x"));
+ }
+ public static PassedByValue passByVal;
+}
+
+class director_pass_by_value_Derived : DirectorPassByValueAbstractBase {
+ public override void virtualMethod(PassedByValue pbv) {
+ runme.passByVal = pbv;
+ }
+}
diff --git a/Examples/test-suite/default_args_c.i b/Examples/test-suite/default_args_c.i
new file mode 100644
index 000000000..e0c0af056
--- /dev/null
+++ b/Examples/test-suite/default_args_c.i
@@ -0,0 +1,14 @@
+%module default_args_c
+
+/* Default arguments for C code */
+int foo1(int x = 42 || 3);
+int foo43(int x = 42 | 3);
+
+%{
+int foo1(int x) {
+ return x;
+}
+int foo43(int x) {
+ return x;
+}
+%}
diff --git a/Examples/test-suite/director_pass_by_value.i b/Examples/test-suite/director_pass_by_value.i
new file mode 100644
index 000000000..31d8ce2d2
--- /dev/null
+++ b/Examples/test-suite/director_pass_by_value.i
@@ -0,0 +1,30 @@
+%module(directors="1") director_pass_by_value
+%director DirectorPassByValueAbstractBase;
+
+%inline %{
+class PassedByValue {
+ int val;
+public:
+ PassedByValue() { val = 0x12345678; }
+ int getVal() { return val; }
+};
+
+int doSomething(int x) {
+ int yy[256];
+ yy[0] =0x9876;
+ return yy[0];
+}
+
+class DirectorPassByValueAbstractBase {
+public:
+ virtual void virtualMethod(PassedByValue pbv) = 0;
+ virtual ~DirectorPassByValueAbstractBase () {}
+};
+
+class Caller {
+public:
+ void call_virtualMethod(DirectorPassByValueAbstractBase &f) {
+ f.virtualMethod(PassedByValue());
+ }
+};
+%}
diff --git a/Examples/test-suite/errors/c_default_error.i b/Examples/test-suite/errors/c_default_error.i
deleted file mode 100644
index f6220e11d..000000000
--- a/Examples/test-suite/errors/c_default_error.i
+++ /dev/null
@@ -1,4 +0,0 @@
-%module xxx
-
-int foo(int x = 42 || 3);
-
diff --git a/Examples/test-suite/errors/c_default_error.stderr b/Examples/test-suite/errors/c_default_error.stderr
deleted file mode 100644
index e69de29bb..000000000
--- a/Examples/test-suite/errors/c_default_error.stderr
+++ /dev/null
diff --git a/Examples/test-suite/errors/c_varargs.i b/Examples/test-suite/errors/c_varargs.i
deleted file mode 100644
index 88f9c2e7d..000000000
--- a/Examples/test-suite/errors/c_varargs.i
+++ /dev/null
@@ -1,3 +0,0 @@
-%module xxx
-
-int foo(int x, ...);
diff --git a/Examples/test-suite/errors/c_varargs.stderr b/Examples/test-suite/errors/c_varargs.stderr
deleted file mode 100644
index e69de29bb..000000000
--- a/Examples/test-suite/errors/c_varargs.stderr
+++ /dev/null
diff --git a/Examples/test-suite/errors/cpp_inherit_ignored.i b/Examples/test-suite/errors/cpp_inherit_ignored.i
new file mode 100644
index 000000000..fdc1c83e3
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_inherit_ignored.i
@@ -0,0 +1,19 @@
+%module xxx
+
+// Only non-ignored classes should warn about Ignored base classes
+%ignore ActualClass;
+%ignore ActualClassNoTemplates;
+
+%{
+struct BaseClassNoTemplates {};
+%}
+%inline %{
+template<typename T>
+class TemplateClass {};
+
+class ActualClass : public TemplateClass<int> {};
+class AktuelKlass : public TemplateClass<int> {};
+
+class ActualClassNoTemplates : public BaseClassNoTemplates {};
+class AktuelKlassNoTemplates : public BaseClassNoTemplates {};
+%}
diff --git a/Examples/test-suite/errors/cpp_inherit_ignored.stderr b/Examples/test-suite/errors/cpp_inherit_ignored.stderr
new file mode 100644
index 000000000..360c1f9fc
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_inherit_ignored.stderr
@@ -0,0 +1,3 @@
+cpp_inherit_ignored.i:15: Warning 401: Nothing known about base class 'TemplateClass< int >'. Ignored.
+cpp_inherit_ignored.i:15: Warning 401: Maybe you forgot to instantiate 'TemplateClass< int >' using %template.
+cpp_inherit_ignored.i:18: Warning 401: Nothing known about base class 'BaseClassNoTemplates'. Ignored.
diff --git a/Examples/test-suite/errors/cpp_overload.i b/Examples/test-suite/errors/cpp_overload.i
deleted file mode 100644
index 34fa3cc25..000000000
--- a/Examples/test-suite/errors/cpp_overload.i
+++ /dev/null
@@ -1,15 +0,0 @@
-%module xxx
-int foo(int x);
-int foo(double x);
-
-class Foo {
-public:
- int bar(int);
- int bar(double);
-};
-
-class Spam {
-public:
- Spam();
- Spam(int);
-};
diff --git a/Examples/test-suite/errors/cpp_overload.stderr b/Examples/test-suite/errors/cpp_overload.stderr
deleted file mode 100644
index e69de29bb..000000000
--- a/Examples/test-suite/errors/cpp_overload.stderr
+++ /dev/null
diff --git a/Examples/test-suite/errors/cpp_private_defvalue.i b/Examples/test-suite/errors/cpp_private_defvalue.i
deleted file mode 100644
index 15542c7bc..000000000
--- a/Examples/test-suite/errors/cpp_private_defvalue.i
+++ /dev/null
@@ -1,7 +0,0 @@
-%module xxx
-
-class foo {
-static const int BAR = 42;
-public:
- int blah(int x = BAR);
-};
diff --git a/Examples/test-suite/errors/cpp_private_defvalue.stderr b/Examples/test-suite/errors/cpp_private_defvalue.stderr
deleted file mode 100644
index e69de29bb..000000000
--- a/Examples/test-suite/errors/cpp_private_defvalue.stderr
+++ /dev/null
diff --git a/Examples/test-suite/errors/cpp_template_argname.i b/Examples/test-suite/errors/cpp_template_argname.i
deleted file mode 100644
index b87c115c1..000000000
--- a/Examples/test-suite/errors/cpp_template_argname.i
+++ /dev/null
@@ -1,8 +0,0 @@
-%module xxx
-
-template<T> T blah(T x);
-
-
-
-
-
diff --git a/Examples/test-suite/errors/cpp_template_argname.stderr b/Examples/test-suite/errors/cpp_template_argname.stderr
deleted file mode 100644
index e69de29bb..000000000
--- a/Examples/test-suite/errors/cpp_template_argname.stderr
+++ /dev/null
diff --git a/Examples/test-suite/errors/cpp_template_repeat.i b/Examples/test-suite/errors/cpp_template_repeat.i
index e63ffe8d9..f170080b7 100644
--- a/Examples/test-suite/errors/cpp_template_repeat.i
+++ b/Examples/test-suite/errors/cpp_template_repeat.i
@@ -4,4 +4,4 @@ template<class T> T blah(T x) { };
%template(iblah) blah<int>;
%template(iiblah) blah<int>;
-
+// The second %template instantiation above should surely be ignored with a warning, but doesn't atm
diff --git a/Examples/test-suite/errors/cpp_using_type_aliasing.stderr b/Examples/test-suite/errors/cpp_using_type_aliasing.stderr
index 3f256652f..e69de29bb 100644
--- a/Examples/test-suite/errors/cpp_using_type_aliasing.stderr
+++ b/Examples/test-suite/errors/cpp_using_type_aliasing.stderr
@@ -1,3 +0,0 @@
-cpp_using_type_aliasing.i:8: Warning 341: The 'using' keyword in type aliasing is not fully supported yet.
-cpp_using_type_aliasing.i:8: Warning 315: Nothing known about 'Okay< int >'.
-cpp_using_type_aliasing.i:8: Warning 315: Nothing known about 'Okay< int >'.
diff --git a/Examples/test-suite/errors/pp_macro_args.i b/Examples/test-suite/errors/pp_macro_args.i
deleted file mode 100644
index 8bbbfb104..000000000
--- a/Examples/test-suite/errors/pp_macro_args.i
+++ /dev/null
@@ -1,7 +0,0 @@
-%module xxx
-
-#define foo(a,x) a x
-
-#if foo
-#endif
-
diff --git a/Examples/test-suite/errors/pp_macro_args.stderr b/Examples/test-suite/errors/pp_macro_args.stderr
deleted file mode 100644
index e69de29bb..000000000
--- a/Examples/test-suite/errors/pp_macro_args.stderr
+++ /dev/null
diff --git a/Examples/test-suite/exception_classname.i b/Examples/test-suite/exception_classname.i
index a5a76e24d..6900581cf 100644
--- a/Examples/test-suite/exception_classname.i
+++ b/Examples/test-suite/exception_classname.i
@@ -1,6 +1,9 @@
%module exception_classname
%warnfilter(SWIGWARN_RUBY_WRONG_NAME);
+#ifdef SWIGPHP
+%rename(ExceptionClass) Exception;
+#endif
%inline %{
class Exception {
diff --git a/Examples/test-suite/insert_directive.i b/Examples/test-suite/insert_directive.i
index 8ad966a99..36c3af6c6 100644
--- a/Examples/test-suite/insert_directive.i
+++ b/Examples/test-suite/insert_directive.i
@@ -34,5 +34,5 @@ int inserted_wrapper(int i) { return inserted_header3(i); }
%init %{
// %inserted code %init
-int inserted_init_value = inserted_wrapper(0);
+int SWIGUNUSED inserted_init_value = inserted_wrapper(0);
%}
diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in
index 64b38702c..e69964352 100644
--- a/Examples/test-suite/java/Makefile.in
+++ b/Examples/test-suite/java/Makefile.in
@@ -5,7 +5,7 @@
LANGUAGE = java
JAVA = @JAVA@
JAVAC = @JAVAC@
-JAVAFLAGS = -Xcheck:jni
+JAVAFLAGS = @JAVAFLAGS@
SCRIPTSUFFIX = _runme.java
srcdir = @srcdir@
diff --git a/Examples/test-suite/java/director_classes_runme.java b/Examples/test-suite/java/director_classes_runme.java
index 013bdc75b..5fbb9ea35 100644
--- a/Examples/test-suite/java/director_classes_runme.java
+++ b/Examples/test-suite/java/director_classes_runme.java
@@ -140,7 +140,7 @@ public class director_classes_runme {
Package packag = klass.getPackage();
String simpleName = null;
if (packag != null)
- simpleName = fullName.replaceAll(packag.getName() + ".", "");
+ simpleName = fullName.replaceAll(packag.getName() + "\\.", "");
else
simpleName = fullName;
return simpleName;
diff --git a/Examples/test-suite/java/director_pass_by_value_runme.java b/Examples/test-suite/java/director_pass_by_value_runme.java
new file mode 100644
index 000000000..24ded2ccf
--- /dev/null
+++ b/Examples/test-suite/java/director_pass_by_value_runme.java
@@ -0,0 +1,48 @@
+
+import director_pass_by_value.*;
+
+public class director_pass_by_value_runme {
+
+ static {
+ try {
+ System.loadLibrary("director_pass_by_value");
+ } 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);
+ }
+ }
+
+ private static void WaitForGC() {
+ System.gc();
+ System.runFinalization();
+ try {
+ java.lang.Thread.sleep(10);
+ } catch (java.lang.InterruptedException e) {
+ }
+ }
+
+ public static void main(String argv[]) {
+ Caller caller = new Caller();
+ caller.call_virtualMethod(new director_pass_by_value_Derived());
+ {
+ int countdown = 5;
+ while (true) {
+ WaitForGC();
+ if (--countdown == 0)
+ break;
+ };
+ }
+ // bug was the passByVal 'global' object was destroyed after the call to virtualMethod had finished.
+ int ret = director_pass_by_value_runme.passByVal.getVal();
+ if (ret != 0x12345678)
+ throw new RuntimeException("Bad return value, got " + Integer.toHexString(ret));
+ }
+
+ static PassedByValue passByVal;
+}
+
+class director_pass_by_value_Derived extends DirectorPassByValueAbstractBase {
+ public void virtualMethod(PassedByValue pbv) {
+ director_pass_by_value_runme.passByVal = pbv;
+ }
+}
diff --git a/Examples/test-suite/java/smart_pointer_ignore_runme.java b/Examples/test-suite/java/smart_pointer_ignore_runme.java
new file mode 100644
index 000000000..f02bf536a
--- /dev/null
+++ b/Examples/test-suite/java/smart_pointer_ignore_runme.java
@@ -0,0 +1,19 @@
+import smart_pointer_ignore.*;
+
+public class smart_pointer_ignore_runme {
+
+ static {
+ try {
+ System.loadLibrary("smart_pointer_ignore");
+ } 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[]) {
+ DerivedPtr d = smart_pointer_ignore.makeDerived();
+ d.base();
+ d.derived();
+ }
+}
diff --git a/Examples/test-suite/li_boost_array.i b/Examples/test-suite/li_boost_array.i
index be51d15e0..e18140a50 100644
--- a/Examples/test-suite/li_boost_array.i
+++ b/Examples/test-suite/li_boost_array.i
@@ -25,6 +25,8 @@ namespace boost {
using std::array;
}
+%ignore std::array::fill; // Some older versions of boost don't have this function
+
%include <std_array.i>
%template(ArrayInt6) std::array<int, 6>;
diff --git a/Examples/test-suite/li_boost_shared_ptr_template.i b/Examples/test-suite/li_boost_shared_ptr_template.i
index e3b735c24..3965a976e 100644
--- a/Examples/test-suite/li_boost_shared_ptr_template.i
+++ b/Examples/test-suite/li_boost_shared_ptr_template.i
@@ -67,7 +67,7 @@ INTEGER bar_getter(Base<INTEGER>& foo) {
// 2nd test - templates with default template parameters
#if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED)
-%shared_ptr(Space::BaseDefault<short>)
+%shared_ptr(Space::BaseDefault<short, int>)
%shared_ptr(Space::DerivedDefault<short>)
%shared_ptr(Space::DerivedDefault2<short>)
diff --git a/Examples/test-suite/nested_extend_c.i b/Examples/test-suite/nested_extend_c.i
index 8fde075a4..032619f8e 100644
--- a/Examples/test-suite/nested_extend_c.i
+++ b/Examples/test-suite/nested_extend_c.i
@@ -98,5 +98,9 @@ typedef struct {
static struct {
int i;
} THING;
+
+int useThing() {
+ return THING.i;
+}
%}
diff --git a/Examples/test-suite/operator_overload.i b/Examples/test-suite/operator_overload.i
index 90f767a84..af884e5b4 100644
--- a/Examples/test-suite/operator_overload.i
+++ b/Examples/test-suite/operator_overload.i
@@ -73,6 +73,10 @@ see bottom for a set of possible tests
%rename(OrOperator) operator ||;
#endif
+#if defined(SWIGPYTHON)
+%feature("python:slot", "tp_str", functype="reprfunc") Op::__str__;
+#endif
+
#ifdef SWIGD
// Due to the way operator overloading is implemented in D1 and D2, the prefix
// increment/decrement operators (D1) resp. the postfix ones (D2) are ignored.
@@ -89,8 +93,6 @@ see bottom for a set of possible tests
#include <iso646.h> /* for named logical operator, eg 'operator or' */
#endif
-#include <assert.h>
-
class Op {
public:
int i;
@@ -109,11 +111,11 @@ public:
return *this;
}
// +=,-=... are member fns
- void operator+=(const Op& o){ i+=o.i;}
- void operator-=(const Op& o){ i-=o.i;}
- void operator*=(const Op& o){ i*=o.i;}
- void operator/=(const Op& o){ i/=o.i;}
- void operator%=(const Op& o){ i%=o.i;}
+ Op &operator+=(const Op& o){ i+=o.i; return *this; }
+ Op &operator-=(const Op& o){ i-=o.i; return *this; }
+ Op &operator*=(const Op& o){ i*=o.i; return *this; }
+ Op &operator/=(const Op& o){ i/=o.i; return *this; }
+ Op &operator%=(const Op& o){ i%=o.i; return *this; }
// the +,-,*,... are friends
// (just to make life harder)
friend Op operator+(const Op& a,const Op& b){return Op(a.i+b.i);}
@@ -245,8 +247,8 @@ public:
%{
-
-#include <assert.h>
+#include <stdexcept>
+#define ASSERT(X) { if (!(X)) { throw std::runtime_error(#X); } }
void Op::sanity_check()
{
@@ -258,66 +260,66 @@ void Op::sanity_check()
Op dd=d; // assignment operator
// test equality
- assert(a!=b);
- assert(b==c);
- assert(a!=d);
- assert(d==dd);
+ ASSERT(a!=b);
+ ASSERT(b==c);
+ ASSERT(a!=d);
+ ASSERT(d==dd);
// test <
- assert(a<b);
- assert(a<=b);
- assert(b<=c);
- assert(b>=c);
- assert(b>d);
- assert(b>=d);
+ ASSERT(a<b);
+ ASSERT(a<=b);
+ ASSERT(b<=c);
+ ASSERT(b>=c);
+ ASSERT(b>d);
+ ASSERT(b>=d);
// test +=
Op e=3;
e+=d;
- assert(e==b);
+ ASSERT(e==b);
e-=c;
- assert(e==a);
+ ASSERT(e==a);
e=Op(1);
e*=b;
- assert(e==c);
+ ASSERT(e==c);
e/=d;
- assert(e==d);
+ ASSERT(e==d);
e%=c;
- assert(e==d);
+ ASSERT(e==d);
// test +
Op f(1),g(1);
- assert(f+g==Op(2));
- assert(f-g==Op(0));
- assert(f*g==Op(1));
- assert(f/g==Op(1));
- assert(f%g==Op(0));
+ ASSERT(f+g==Op(2));
+ ASSERT(f-g==Op(0));
+ ASSERT(f*g==Op(1));
+ ASSERT(f/g==Op(1));
+ ASSERT(f%g==Op(0));
// test unary operators
- assert(!a==true);
- assert(!b==false);
- assert(-a==a);
- assert(-b==Op(-5));
+ ASSERT(!a==true);
+ ASSERT(!b==false);
+ ASSERT(-a==a);
+ ASSERT(-b==Op(-5));
// test []
Op h=3;
- assert(h[0]==3);
- assert(h[1]==0);
+ ASSERT(h[0]==3);
+ ASSERT(h[1]==0);
h[0]=2; // set
- assert(h[0]==2);
+ ASSERT(h[0]==2);
h[1]=2; // ignored
- assert(h[0]==2);
- assert(h[1]==0);
+ ASSERT(h[0]==2);
+ ASSERT(h[1]==0);
// test ()
Op i=3;
- assert(i()==3);
- assert(i(1)==4);
- assert(i(1,2)==6);
+ ASSERT(i()==3);
+ ASSERT(i(1)==4);
+ ASSERT(i(1,2)==6);
// plus add some code to check the __str__ fn
- //assert(str(Op(1))=="Op(1)");
- //assert(str(Op(-3))=="Op(-3)");
+ //ASSERT(str(Op(1))=="Op(1)");
+ //ASSERT(str(Op(-3))=="Op(-3)");
// test ++ and --
Op j(100);
@@ -325,36 +327,36 @@ void Op::sanity_check()
{
Op newOp = j++;
int newInt = original++;
- assert(j.i == original);
- assert(newOp.i == newInt);
+ ASSERT(j.i == original);
+ ASSERT(newOp.i == newInt);
}
{
Op newOp = j--;
int newInt = original--;
- assert(j.i == original);
- assert(newOp.i == newInt);
+ ASSERT(j.i == original);
+ ASSERT(newOp.i == newInt);
}
{
Op newOp = ++j;
int newInt = ++original;
- assert(j.i == original);
- assert(newOp.i == newInt);
+ ASSERT(j.i == original);
+ ASSERT(newOp.i == newInt);
}
{
Op newOp = --j;
int newInt = --original;
- assert(j.i == original);
- assert(newOp.i == newInt);
+ ASSERT(j.i == original);
+ ASSERT(newOp.i == newInt);
}
// cast operators
Op k=3;
int check_k = k;
- assert (check_k == 3);
+ ASSERT (check_k == 3);
Op l=4;
double check_l = l;
- assert (check_l == 4);
+ ASSERT (check_l == 4);
}
%}
diff --git a/Examples/test-suite/php/director_pass_by_value_runme.php b/Examples/test-suite/php/director_pass_by_value_runme.php
new file mode 100644
index 000000000..8a8b84d67
--- /dev/null
+++ b/Examples/test-suite/php/director_pass_by_value_runme.php
@@ -0,0 +1,24 @@
+<?php
+
+require "tests.php";
+require "director_pass_by_value.php";
+
+$passByVal = null;
+
+class director_pass_by_value_Derived extends DirectorPassByValueAbstractBase {
+ function virtualMethod($b) {
+ global $passByVal;
+ $passByVal = $b;
+ }
+}
+
+# bug was the passByVal global object was destroyed after the call to virtualMethod had finished.
+$caller = new Caller();
+$caller->call_virtualMethod(new director_pass_by_value_Derived());
+$ret = $passByVal->getVal();
+if ($ret != 0x12345678) {
+ check::fail("Bad return value, got " . dechex($ret));
+}
+
+check::done();
+?>
diff --git a/Examples/test-suite/preproc_defined.i b/Examples/test-suite/preproc_defined.i
index 0a91bd98a..e1958515d 100644
--- a/Examples/test-suite/preproc_defined.i
+++ b/Examples/test-suite/preproc_defined.i
@@ -102,6 +102,7 @@ ANOTHER_MACRO(int)
void another_macro_checking(void) {
struct Defined d;
d.defined = 10;
+ (void)d;
thing(10);
stuff(10);
bumpf(10);
diff --git a/Examples/test-suite/python/autodoc_runme.py b/Examples/test-suite/python/autodoc_runme.py
index ce0aae0eb..af04c8c0e 100644
--- a/Examples/test-suite/python/autodoc_runme.py
+++ b/Examples/test-suite/python/autodoc_runme.py
@@ -15,11 +15,19 @@ def check(got, expected, expected_builtin=None, skip=False):
def is_new_style_class(cls):
return hasattr(cls, "__class__")
+def is_fastproxy(module):
+ return "new_instancemethod" in module
+
if not is_new_style_class(A):
# Missing static methods make this hard to test... skip if -classic is
# used!
sys.exit(0)
+if is_fastproxy(dir()):
+ # Detect when -fastproxy is specified and skip test as it changes the function names making it
+ # hard to test... skip until the number of options are reduced in SWIG-3.1 and autodoc is improved
+ sys.exit(0)
+
# skip builtin check - the autodoc is missing, but it probably should not be
skip = True
diff --git a/Examples/test-suite/python/cpp11_type_aliasing_runme.py b/Examples/test-suite/python/cpp11_type_aliasing_runme.py
new file mode 100644
index 000000000..52cc81d1c
--- /dev/null
+++ b/Examples/test-suite/python/cpp11_type_aliasing_runme.py
@@ -0,0 +1,32 @@
+from cpp11_type_aliasing import *
+
+if get_host_target().bits != 32:
+ raise RuntimeError("get_host_target().bits should return 32")
+
+if mult2(10) != 20:
+ raise RuntimeError("mult2(10) should return 20")
+
+int_ptr = allocate_int()
+inplace_mult2(int_ptr)
+if read_int(int_ptr) != 24:
+ raise RuntimeError("read_int should return 24")
+free_int(int_ptr)
+
+pair = PairSubclass(3, 4)
+if pair.first() != 3:
+ raise RuntimeError("pair.first() should return 3")
+
+if pair.second() != 4:
+ raise RuntimeError("pair.second() should return 4")
+
+if pair.a != 3:
+ raise RuntimeError("pair.a should be 3")
+
+if plus1(5) != 6:
+ raise RuntimeError("plus1(5) should return 6")
+
+if call(mult2_cb, 7) != 14:
+ raise RuntimeError("call(mult2_cb, 7) should return 14")
+
+if call(get_callback(), 7) != 14:
+ raise RuntimeError("call(get_callback(), 7) should return 14")
diff --git a/Examples/test-suite/python/cpp_static_runme.py b/Examples/test-suite/python/cpp_static_runme.py
index b742de285..1c7705f3e 100644
--- a/Examples/test-suite/python/cpp_static_runme.py
+++ b/Examples/test-suite/python/cpp_static_runme.py
@@ -14,4 +14,5 @@ else:
StaticFunctionTest().static_func_2(1)
StaticFunctionTest().static_func_3(1, 2)
StaticMemberTest.static_int = 10
-assert StaticMemberTest.static_int == 10
+if not StaticMemberTest.static_int == 10:
+ raise RuntimeError("static_int not 10")
diff --git a/Examples/test-suite/python/default_args_c_runme.py b/Examples/test-suite/python/default_args_c_runme.py
new file mode 100644
index 000000000..5985fd75c
--- /dev/null
+++ b/Examples/test-suite/python/default_args_c_runme.py
@@ -0,0 +1,6 @@
+import default_args_c
+
+if default_args_c.foo1() != 1:
+ raise RuntimeError("failed")
+if default_args_c.foo43() != 43:
+ raise RuntimeError("failed")
diff --git a/Examples/test-suite/python/director_pass_by_value_runme.py b/Examples/test-suite/python/director_pass_by_value_runme.py
new file mode 100644
index 000000000..7744db962
--- /dev/null
+++ b/Examples/test-suite/python/director_pass_by_value_runme.py
@@ -0,0 +1,13 @@
+import director_pass_by_value
+
+passByVal = None
+class director_pass_by_value_Derived(director_pass_by_value.DirectorPassByValueAbstractBase):
+ def virtualMethod(self, b):
+ global passByVal
+ passByVal = b
+
+# bug was the passByVal global object was destroyed after the call to virtualMethod had finished.
+director_pass_by_value.Caller().call_virtualMethod(director_pass_by_value_Derived())
+ret = passByVal.getVal();
+if ret != 0x12345678:
+ raise RuntimeError("Bad return value, got " + hex(ret))
diff --git a/Examples/test-suite/python/exception_classname_runme.py b/Examples/test-suite/python/exception_classname_runme.py
index c78f4e68b..9a82c9105 100644
--- a/Examples/test-suite/python/exception_classname_runme.py
+++ b/Examples/test-suite/python/exception_classname_runme.py
@@ -1,4 +1,5 @@
import exception_classname
a = exception_classname.Exception()
-assert a.testfunc() == 42
+if a.testfunc() != 42:
+ raise RuntimeError("Not 42!")
diff --git a/Examples/test-suite/python/li_boost_shared_ptr_template_runme.py b/Examples/test-suite/python/li_boost_shared_ptr_template_runme.py
index 6b56ec479..eab7e282a 100644
--- a/Examples/test-suite/python/li_boost_shared_ptr_template_runme.py
+++ b/Examples/test-suite/python/li_boost_shared_ptr_template_runme.py
@@ -8,9 +8,8 @@ if d.bar() != 2:
raise RuntimeError
if bar_getter(b) != 1:
raise RuntimeError
-# Fix reverted in rev 12953
-# if bar_getter(d) != 2:
-# raise RuntimeError
+if bar_getter(d) != 2:
+ raise RuntimeError
b = BaseDefaultInt()
d = DerivedDefaultInt()
@@ -23,8 +22,11 @@ if d2.bar2() != 4:
raise RuntimeError
if bar2_getter(b) != 3:
raise RuntimeError
-# Fix reverted in rev 12953
-# if bar2_getter(d) != 4:
-# raise RuntimeError
-# if bar2_getter(d2) != 4:
-# raise RuntimeError
+# SWIG fix reverted in Subversion rev 12953
+# Testcase has now been modified to mask the problem by providing the default parameter 'int' in:
+# %shared_ptr(Space::BaseDefault<short, int>)
+# If this is not done then d fails to convert to BaseDefault<short>&
+if bar2_getter(d) != 4:
+ raise RuntimeError
+if bar2_getter(d2) != 4:
+ raise RuntimeError
diff --git a/Examples/test-suite/python/operator_overload_runme.py b/Examples/test-suite/python/operator_overload_runme.py
new file mode 100644
index 000000000..cf4277f35
--- /dev/null
+++ b/Examples/test-suite/python/operator_overload_runme.py
@@ -0,0 +1,77 @@
+from operator_overload import *
+
+# first check all the operators are implemented correctly from pure C++ code
+Op_sanity_check()
+
+pop = Op(6)/Op(3)
+
+# test routine:
+a=Op()
+b=Op(5)
+c=Op(b) # copy construct
+d=Op(2)
+dd=d # assignment operator
+
+# test equality
+if not a!=b:
+ raise RuntimeError("a!=b")
+if not b==c:
+ raise RuntimeError("b==c")
+if not a!=d:
+ raise RuntimeError("a!=d")
+if not d==dd:
+ raise RuntimeError("d==dd")
+
+# test <
+if not a<b:
+ raise RuntimeError("a<b")
+if not a<=b:
+ raise RuntimeError("a<=b")
+if not b<=c:
+ raise RuntimeError("b<=c")
+if not b>=c:
+ raise RuntimeError("b>=c")
+if not b>d:
+ raise RuntimeError("b>d")
+if not b>=d:
+ raise RuntimeError("b>=d")
+
+# test +=
+e=Op(3)
+e+=d
+if not e==b:
+ raise RuntimeError("e==b (%s==%s)" % (e.i, b.i))
+e-=c
+if not e==a:
+ raise RuntimeError("e==a")
+e=Op(1)
+e*=b
+if not e==c:
+ raise RuntimeError("e==c")
+e/=d
+if not e==d:
+ raise RuntimeError("e==d")
+e%=c;
+if not e==d:
+ raise RuntimeError("e==d")
+
+# test +
+f=Op(1)
+g=Op(1)
+if not f+g==Op(2):
+ raise RuntimeError("f+g==Op(2)")
+if not f-g==Op(0):
+ raise RuntimeError("f-g==Op(0)")
+if not f*g==Op(1):
+ raise RuntimeError("f*g==Op(1)")
+if not f/g==Op(1):
+ raise RuntimeError("f/g==Op(1)")
+if not f%g==Op(0):
+ raise RuntimeError("f%g==Op(0)")
+
+# test unary operators
+if not -a==a:
+ raise RuntimeError("-a==a")
+if not -b==Op(-5):
+ raise RuntimeError("-b==Op(-5)")
+
diff --git a/Examples/test-suite/python/operbool_runme.py b/Examples/test-suite/python/operbool_runme.py
index 708dea786..cdef85abc 100644
--- a/Examples/test-suite/python/operbool_runme.py
+++ b/Examples/test-suite/python/operbool_runme.py
@@ -1,3 +1,4 @@
#!/usr/bin/env python
import operbool
-assert not operbool.Test()
+if operbool.Test():
+ raise RuntimeError("operbool failed")
diff --git a/Examples/test-suite/python/python_abstractbase_runme3.py b/Examples/test-suite/python/python_abstractbase_runme3.py
index b4a20f085..4fdc79935 100644
--- a/Examples/test-suite/python/python_abstractbase_runme3.py
+++ b/Examples/test-suite/python/python_abstractbase_runme3.py
@@ -6,6 +6,10 @@ from collections import *
if is_python_builtin():
exit(0)
+# Python abc is only turned on when -py3 option is passed to SWIG
+if not is_swig_py3:
+ exit(0)
+
assert issubclass(Mapii, MutableMapping)
assert issubclass(Multimapii, MutableMapping)
assert issubclass(IntSet, MutableSet)
diff --git a/Examples/test-suite/python/python_destructor_exception_runme.py b/Examples/test-suite/python/python_destructor_exception_runme.py
index 671eff3cc..ee71ab33b 100644
--- a/Examples/test-suite/python/python_destructor_exception_runme.py
+++ b/Examples/test-suite/python/python_destructor_exception_runme.py
@@ -26,8 +26,10 @@ def test1():
sys.stderr.flush()
sys.stderr = stderr_saved
- assert attributeErrorOccurred
- assert buffer.getvalue().count("I am the ClassWithThrowingDestructor dtor doing bad things") >= 1
+ if not attributeErrorOccurred:
+ raise RuntimeError("attributeErrorOccurred failed")
+ if not buffer.getvalue().count("I am the ClassWithThrowingDestructor dtor doing bad things") >= 1:
+ raise RuntimeError("ClassWithThrowingDestructor dtor doing bad things failed")
class VectorHolder(object):
def __init__(self, v):
diff --git a/Examples/test-suite/python/template_default_arg_overloaded_extend_runme.py b/Examples/test-suite/python/template_default_arg_overloaded_extend_runme.py
new file mode 100644
index 000000000..1f71066cb
--- /dev/null
+++ b/Examples/test-suite/python/template_default_arg_overloaded_extend_runme.py
@@ -0,0 +1,20 @@
+from template_default_arg_overloaded_extend import *
+
+def check(flag):
+ if not flag:
+ raise RuntimeError("failed")
+
+rs = ResultSet()
+
+check(rs.go_get_method(0, SearchPoint()) == -1)
+check(rs.go_get_method(0, SearchPoint(), 100) == 100)
+
+check(rs.go_get_template(0, SearchPoint()) == -2)
+check(rs.go_get_template(0, SearchPoint(), 100) == 100)
+
+check(rs.over() == "over(int)")
+check(rs.over(10) == "over(int)")
+check(rs.over(SearchPoint()) == "over(giai2::SearchPoint, int)")
+check(rs.over(SearchPoint(), 10) == "over(giai2::SearchPoint, int)")
+check(rs.over(True, SearchPoint()) == "over(bool, gaia2::SearchPoint, int)")
+check(rs.over(True, SearchPoint(), 10) == "over(bool, gaia2::SearchPoint, int)")
diff --git a/Examples/test-suite/python/unicode_strings_runme.py b/Examples/test-suite/python/unicode_strings_runme.py
index 3ce98bcdb..fa9c51437 100644
--- a/Examples/test-suite/python/unicode_strings_runme.py
+++ b/Examples/test-suite/python/unicode_strings_runme.py
@@ -13,11 +13,15 @@ if sys.version_info[0:2] >= (3, 1):
if unicode_strings.non_utf8_std_string() != test_string:
raise ValueError('Test comparison mismatch')
+def check(s1, s2):
+ if s1 != s2:
+ raise RuntimeError("{} != {}".format(s1, s2))
+
# Testing SWIG_PYTHON_2_UNICODE flag which allows unicode strings to be passed to C
if sys.version_info[0:2] < (3, 0):
- assert unicode_strings.charstring("hello1") == "hello1"
- assert unicode_strings.charstring(str(u"hello2")) == "hello2"
- assert unicode_strings.charstring(u"hello3") == "hello3"
- assert unicode_strings.charstring(unicode("hello4")) == "hello4"
+ check(unicode_strings.charstring("hello1"), "hello1")
+ check(unicode_strings.charstring(str(u"hello2")), "hello2")
+ check(unicode_strings.charstring(u"hello3"), "hello3")
+ check(unicode_strings.charstring(unicode("hello4")), "hello4")
unicode_strings.charstring(u"hell\xb05")
unicode_strings.charstring(u"hell\u00f66")
diff --git a/Examples/test-suite/python_abstractbase.i b/Examples/test-suite/python_abstractbase.i
index 65f3d9931..2146e758e 100644
--- a/Examples/test-suite/python_abstractbase.i
+++ b/Examples/test-suite/python_abstractbase.i
@@ -24,3 +24,9 @@ bool is_python_builtin() { return true; }
bool is_python_builtin() { return false; }
#endif
%}
+
+#ifdef SWIGPYTHON_PY3 // set when using -py3
+#define is_swig_py3 1
+#else
+#define is_swig_py3 0
+#endif
diff --git a/Examples/test-suite/r/Makefile.in b/Examples/test-suite/r/Makefile.in
index 312834a51..bc12ba671 100644
--- a/Examples/test-suite/r/Makefile.in
+++ b/Examples/test-suite/r/Makefile.in
@@ -5,7 +5,8 @@
LANGUAGE = r
SCRIPTSUFFIX = _runme.R
WRAPSUFFIX = .R
-RUNR = R CMD BATCH --no-save --no-restore '--args $(SCRIPTDIR)'
+R_OPT = --quiet --no-save --no-restore
+RUNR = R CMD BATCH $(R_OPT) '--args $(SCRIPTDIR)'
srcdir = @srcdir@
top_srcdir = @top_srcdir@
@@ -51,18 +52,17 @@ include $(srcdir)/../common.mk
# check for syntactic correctness
run_testcase = \
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
- env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PATH=.:"$$PATH" $(RUNTOOL) $(RUNR) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PATH=.:"$$PATH" $(RUNTOOL) $(RUNR) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) || (cat $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)out ; false); \
else \
- $(RUNTOOL) $(RUNR) ./$(SCRIPTPREFIX)$*$(WRAPSUFFIX); \
+ $(RUNTOOL) $(RUNR) ./$(SCRIPTPREFIX)$*$(WRAPSUFFIX) || (cat ./$(SCRIPTPREFIX)$*$(WRAPSUFFIX)out ; false); \
fi
run_multitestcase = \
for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX) ]; then \
- env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PATH=.:"$$PATH" \
- $(RUNTOOL) $(RUNR) $(SCRIPTDIR)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX); \
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PATH=.:"$$PATH" $(RUNTOOL) $(RUNR) $(SCRIPTDIR)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX) || (cat $(SCRIPTDIR)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX)out ; false); \
else \
- $(RUNTOOL) $(RUNR) ./$(SCRIPTPREFIX)$${f}$(WRAPSUFFIX); \
+ $(RUNTOOL) $(RUNR) ./$(SCRIPTPREFIX)$${f}$(WRAPSUFFIX) || (cat ./$(SCRIPTPREFIX)$${f}$(WRAPSUFFIX)out ; false); \
fi; \
done
# Clean
diff --git a/Examples/test-suite/ruby/Makefile.in b/Examples/test-suite/ruby/Makefile.in
index 847c95919..d94ac7061 100644
--- a/Examples/test-suite/ruby/Makefile.in
+++ b/Examples/test-suite/ruby/Makefile.in
@@ -30,7 +30,8 @@ CPP_TEST_CASES = \
# stl_new
C_TEST_CASES += \
- li_cstring
+ li_cstring \
+ ruby_manual_proxy \
include $(srcdir)/../common.mk
diff --git a/Examples/test-suite/ruby/ruby_manual_proxy_runme.rb b/Examples/test-suite/ruby/ruby_manual_proxy_runme.rb
new file mode 100644
index 000000000..c1cee2d13
--- /dev/null
+++ b/Examples/test-suite/ruby/ruby_manual_proxy_runme.rb
@@ -0,0 +1,49 @@
+#!/usr/bin/env ruby
+#
+# The Subversion bindings use this manually written proxy class approach
+# to the Ruby bindings. Note that in C the struct svn_fs_t is an
+# opaque pointer and the Ruby FileSystem proxy class is hand written around it.
+# This testcase tests this and the C close function and subsequent error
+# handling.
+
+require 'swig_assert'
+require 'ruby_manual_proxy'
+
+module Svn
+ module Fs
+ module_function
+ def create(path)
+ f = Ruby_manual_proxy::svn_fs_create(path)
+ return f
+ end
+
+ FileSystem = SWIG::TYPE_p_svn_fs_t
+ class FileSystem
+ class << self
+ def create(*args)
+ Fs.create(*args)
+ end
+ end
+ def path
+ Ruby_manual_proxy::svn_fs_path(self)
+ end
+ end
+ end
+end
+
+f = Svn::Fs::FileSystem.create("/tmp/myfile")
+path = f.path
+f.close
+begin
+ # regression in swig-3.0.8 meant ObjectPreviouslyDeleted error was thrown instead
+ path = f.path
+ raise RuntimeError.new("IOError (1) not thrown")
+rescue IOError
+end
+
+file = nil
+begin
+ path = Ruby_manual_proxy::svn_fs_path(file)
+ raise RuntimeError.new("IOError (2) not thrown")
+rescue IOError
+end
diff --git a/Examples/test-suite/ruby_manual_proxy.i b/Examples/test-suite/ruby_manual_proxy.i
new file mode 100644
index 000000000..2cb154e6a
--- /dev/null
+++ b/Examples/test-suite/ruby_manual_proxy.i
@@ -0,0 +1,66 @@
+%module ruby_manual_proxy
+
+
+%typemap(in, numinputs=0) SWIGTYPE ** ($*1_ltype temp) "$1 = &temp;";
+
+%typemap(argout) SWIGTYPE **OUTPARAM {
+ $result = SWIG_Ruby_AppendOutput($result, SWIG_NewPointerObj(*$1, $*1_descriptor, 0));
+}
+
+%apply SWIGTYPE **OUTPARAM {
+ svn_fs_t **
+};
+
+%typemap(check) svn_fs_t * {
+ if (!$1) {
+ svn_swig_rb_raise_svn_fs_already_close();
+ }
+}
+
+%{
+typedef struct svn_fs_t {
+ char path[256];
+} svn_fs_t;
+
+void svn_fs_create(svn_fs_t **fs_p, const char *path) {
+ svn_fs_t *fs = (svn_fs_t *)malloc(sizeof(svn_fs_t));
+ strncpy(fs->path, path, 256);
+ *fs_p = fs;
+}
+const char *svn_fs_path(svn_fs_t *fs) {
+ return fs->path;
+}
+%}
+
+typedef struct svn_fs_t svn_fs_t;
+void svn_fs_create(svn_fs_t **fs_p, const char *path);
+const char *svn_fs_path(svn_fs_t *fs);
+
+%{
+static void svn_swig_rb_raise_svn_fs_already_close(void) {
+ rb_raise(rb_eIOError, "already closed");
+}
+
+static VALUE svn_fs_swig_rb_close(VALUE self) {
+ if (!DATA_PTR(self)) {
+ svn_swig_rb_raise_svn_fs_already_close();
+ }
+
+ DATA_PTR(self) = NULL;
+
+ return Qnil;
+}
+
+static VALUE svn_fs_swig_rb_closed(VALUE self) {
+ return DATA_PTR(self) ? Qfalse : Qtrue;
+}
+%}
+
+%insert("init") %{
+ {
+ VALUE cSvnfs;
+ cSvnfs = rb_const_get(_mSWIG, rb_intern("TYPE_p_svn_fs_t"));
+ rb_define_method(cSvnfs, "close",
+ VALUEFUNC(svn_fs_swig_rb_close), 0);
+ }
+%}
diff --git a/Examples/test-suite/smart_pointer_ignore.i b/Examples/test-suite/smart_pointer_ignore.i
new file mode 100644
index 000000000..f369de782
--- /dev/null
+++ b/Examples/test-suite/smart_pointer_ignore.i
@@ -0,0 +1,33 @@
+%module smart_pointer_ignore
+
+
+%ignore Derived;
+
+%inline %{
+class Base {
+ public:
+ void base() {}
+};
+
+class Derived : public Base {
+ public:
+ void derived() {}
+};
+
+template <class T>
+class Ptr {
+public:
+ Ptr(T *t) : ptr(t) {}
+ T * operator->() const { return ptr; }
+private:
+ T *ptr;
+};
+%}
+
+%template(DerivedPtr) Ptr<Derived>;
+
+%inline %{
+Ptr<Derived> makeDerived() {
+ return Ptr<Derived>(new Derived());
+}
+%}
diff --git a/Examples/test-suite/template_default_arg_overloaded_extend.i b/Examples/test-suite/template_default_arg_overloaded_extend.i
new file mode 100644
index 000000000..67d66c2fa
--- /dev/null
+++ b/Examples/test-suite/template_default_arg_overloaded_extend.i
@@ -0,0 +1,44 @@
+%module template_default_arg_overloaded_extend
+
+%inline %{
+namespace gaia2 {
+
+struct Filter {};
+struct SearchPoint {};
+struct DataSet {};
+
+template <typename SearchPointType, typename DataSetType>
+class BaseSearchSpace {};
+
+template <typename SearchPointType, typename DataSetType>
+class BaseResultSet {
+public:
+ const char *over(int i = 0) {
+ return "over(int)";
+ }
+};
+}
+%}
+
+// Specialized template extend
+%extend gaia2::BaseResultSet<gaia2::SearchPoint, gaia2::DataSet> {
+ int go_get_method(int n, gaia2::SearchPoint, int offset = -1) {
+ return offset;
+ }
+ const char *over(gaia2::SearchPoint, int x = 0) {
+ return "over(giai2::SearchPoint, int)";
+ }
+}
+
+// Generic extend for all template instantiations
+%extend gaia2::BaseResultSet {
+ int go_get_template(int n, SearchPointType sss, int offset = -2) {
+ return offset;
+ }
+ const char *over(bool b, SearchPointType, int x = 0) {
+ return "over(bool, SearchPointType, int)";
+ }
+}
+
+%template(ResultSet) gaia2::BaseResultSet<gaia2::SearchPoint, gaia2::DataSet>;
+
diff --git a/Examples/test-suite/typemap_manyargs.i b/Examples/test-suite/typemap_manyargs.i
index d26e97714..426fcca1b 100644
--- a/Examples/test-suite/typemap_manyargs.i
+++ b/Examples/test-suite/typemap_manyargs.i
@@ -13,6 +13,7 @@
$9 = &temp9;
$10 = &temp10; // the code generated for this was arg20 = &temp10; and arg20 does not exist.
int $10_ptr = 0; // Was arg20_ptr
+ (void)$10_ptr;
}
%inline %{
diff --git a/Examples/test-suite/typemap_subst.i b/Examples/test-suite/typemap_subst.i
index 91ac62020..946384840 100644
--- a/Examples/test-suite/typemap_subst.i
+++ b/Examples/test-suite/typemap_subst.i
@@ -27,12 +27,14 @@
(void)c;
(void)d;
(void)e;
+ (void)f;
}
{ /* Test locals */
basetemp.member = 0;
startemp = &basetemp;
temp = &startemp;
amptemp = &temp;
+ (void)amptemp;
}
{ /* Test descriptors */
void *desc = $descriptor;
diff --git a/Lib/csharp/boost_intrusive_ptr.i b/Lib/csharp/boost_intrusive_ptr.i
index 1cc5efda7..d0a048d16 100644
--- a/Lib/csharp/boost_intrusive_ptr.i
+++ b/Lib/csharp/boost_intrusive_ptr.i
@@ -1,511 +1,510 @@
-// Users can provide their own SWIG_INTRUSIVE_PTR_TYPEMAPS or SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP macros before including this file to change the
-// visibility of the constructor and getCPtr method if desired to public if using multiple modules.
-#ifndef SWIG_INTRUSIVE_PTR_TYPEMAPS
-#define SWIG_INTRUSIVE_PTR_TYPEMAPS(CONST, TYPE...) SWIG_INTRUSIVE_PTR_TYPEMAPS_IMPLEMENTATION(internal, internal, CONST, TYPE)
-#endif
-#ifndef SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP
-#define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(CONST, TYPE...) SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP_IMPLEMENTATION(internal, internal, CONST, TYPE)
-#endif
-
-%include <intrusive_ptr.i>
-
-// Language specific macro implementing all the customisations for handling the smart pointer
-%define SWIG_INTRUSIVE_PTR_TYPEMAPS_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...)
-
-// %naturalvar is as documented for member variables
-%naturalvar TYPE;
-%naturalvar SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >;
-
-// destructor wrapper customisation
-%feature("unref") TYPE "(void)arg1; delete smartarg1;"
-
-// Typemap customisations...
-
-%typemap(in, canthrow=1) CONST TYPE ($&1_type argp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
- // plain value
- argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0;
- if (!argp) {
- SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null $1_type", 0);
- return $null;
- }
- $1 = *argp;
-%}
-%typemap(out, fragment="SWIG_intrusive_deleter") CONST TYPE %{
- //plain value(out)
- $1_ltype* resultp = new $1_ltype(($1_ltype &)$1);
- intrusive_ptr_add_ref(resultp);
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(resultp, SWIG_intrusive_deleter< CONST TYPE >());
-%}
-
-%typemap(in, canthrow=1) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
- // plain pointer
- smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input;
- $1 = (TYPE *)(smartarg ? smartarg->get() : 0);
-%}
-%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE * %{
- //plain pointer(out)
- #if ($owner)
- if ($1) {
- intrusive_ptr_add_ref($1);
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >());
- } else {
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
- }
- #else
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0;
- #endif
-%}
-
-%typemap(in, canthrow=1) CONST TYPE & (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
- // plain reference
- $1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
- if(!$1) {
- SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type reference is null", 0);
- return $null;
- }
-%}
-%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE & %{
- //plain reference(out)
- #if ($owner)
- if ($1) {
- intrusive_ptr_add_ref($1);
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >());
- } else {
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
- }
- #else
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0;
- #endif
-%}
-
-%typemap(in) TYPE *CONST& ($*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
- // plain pointer by reference
- temp = ($*1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
- $1 = &temp;
-%}
-%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") TYPE *CONST& %{
- // plain pointer by reference(out)
- #if ($owner)
- if (*$1) {
- intrusive_ptr_add_ref(*$1);
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1, SWIG_intrusive_deleter< CONST TYPE >());
- } else {
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
- }
- #else
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_0);
- #endif
-%}
-
-%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
- // intrusive_ptr by value
- smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
- if (smartarg) {
- $1 = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
- }
-%}
-%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > %{
- if ($1) {
- intrusive_ptr_add_ref($1.get());
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1.get(), SWIG_intrusive_deleter< CONST TYPE >());
- } else {
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
- }
-%}
-
-%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{
- // shared_ptr by value
- smartarg = *($&1_ltype*)&$input;
- if (smartarg) $1 = *smartarg;
-%}
-%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{
- *($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0;
-%}
-
-%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
- // intrusive_ptr by reference
- if ( $input ) {
- smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
- temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
- $1 = &temp;
- } else {
- $1 = &tempnull;
- }
-%}
-%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{
- delete &($1);
- if ($self) {
- SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * temp = new SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(*$input);
- $1 = *temp;
- }
-%}
-%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{
- if (*$1) {
- intrusive_ptr_add_ref($1->get());
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >());
- } else {
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
- }
-%}
-
-%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
- // intrusive_ptr by pointer
- if ( $input ) {
- smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
- temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
- $1 = &temp;
- } else {
- $1 = &tempnull;
- }
-%}
-%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{
- delete $1;
- if ($self) $1 = new SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(*$input);
-%}
-%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{
- if ($1 && *$1) {
- intrusive_ptr_add_ref($1->get());
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >());
- } else {
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
- }
- if ($owner) delete $1;
-%}
-
-%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& (SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > temp, $*1_ltype tempp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
- // intrusive_ptr by pointer reference
- smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
- if ($input) {
- temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
- }
- tempp = &temp;
- $1 = &tempp;
-%}
-%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{
- if ($self) $1 = *$input;
-%}
-%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{
- if (*$1 && **$1) {
- intrusive_ptr_add_ref((*$1)->get());
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >((*$1)->get(), SWIG_intrusive_deleter< CONST TYPE >());
- } else {
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
- }
-%}
-
-// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug
-%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
-#error "typemaps for $1_type not available"
-%}
-%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
-#error "typemaps for $1_type not available"
-%}
-
-
-%typemap (ctype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
- SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
- SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
- SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
- SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "void *"
-%typemap (imtype, out="global::System.IntPtr") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
- SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
- SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
- SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
- SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "global::System.Runtime.InteropServices.HandleRef"
-%typemap (cstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
- SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
- SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
- SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
- SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "$typemap(cstype, TYPE)"
-%typemap(csin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
- SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
- SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
- SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
- SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "$typemap(cstype, TYPE).getCPtr($csinput)"
-
-%typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > {
- global::System.IntPtr cPtr = $imcall;
- $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
- return ret;
- }
-%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
- global::System.IntPtr cPtr = $imcall;
- $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
- return ret;
- }
-%typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & {
- global::System.IntPtr cPtr = $imcall;
- $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
- return ret;
- }
-%typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * {
- global::System.IntPtr cPtr = $imcall;
- $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
- return ret;
- }
-%typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& {
- global::System.IntPtr cPtr = $imcall;
- $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
- return ret;
- }
-%typemap(csvarout, excode=SWIGEXCODE2) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > %{
- get {
- $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
- return ret;
- } %}
-%typemap(csvarout, excode=SWIGEXCODE2) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >& %{
- get {
- $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
- return ret;
- } %}
-%typemap(csvarout, excode=SWIGEXCODE2) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >* %{
- get {
- $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
- return ret;
- } %}
-
-
-%typemap(csout, excode=SWIGEXCODE) CONST TYPE {
- $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
- return ret;
- }
-%typemap(csout, excode=SWIGEXCODE) CONST TYPE & {
- $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
- return ret;
- }
-%typemap(csout, excode=SWIGEXCODE) CONST TYPE * {
- global::System.IntPtr cPtr = $imcall;
- $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
- return ret;
- }
-%typemap(csout, excode=SWIGEXCODE) TYPE *CONST& {
- global::System.IntPtr cPtr = $imcall;
- $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
- return ret;
- }
-
-// Base proxy classes
-%typemap(csbody) TYPE %{
- private global::System.Runtime.InteropServices.HandleRef swigCPtr;
- private bool swigCMemOwnBase;
-
- PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) {
- swigCMemOwnBase = cMemoryOwn;
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- }
-
- CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
- return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
- }
-%}
-
-// Derived proxy classes
-%typemap(csbody_derived) TYPE %{
- private global::System.Runtime.InteropServices.HandleRef swigCPtr;
- private bool swigCMemOwnDerived;
-
- PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) {
- swigCMemOwnDerived = cMemoryOwn;
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- }
-
- CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
- return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
- }
-%}
-
-%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE {
- lock(this) {
- if (swigCPtr.Handle != global::System.IntPtr.Zero) {
- if (swigCMemOwnBase) {
- swigCMemOwnBase = false;
- $imcall;
- }
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
- }
- global::System.GC.SuppressFinalize(this);
- }
- }
-
-%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE {
- lock(this) {
- if (swigCPtr.Handle != global::System.IntPtr.Zero) {
- if (swigCMemOwnDerived) {
- swigCMemOwnDerived = false;
- $imcall;
- }
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
- }
- global::System.GC.SuppressFinalize(this);
- base.Dispose();
- }
- }
-
-// CONST version needed ???? also for C#
-%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "global::System.Runtime.InteropServices.HandleRef"
-%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "global::System.Runtime.InteropServices.HandleRef"
-
-
-%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
-%template() SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >;
-%enddef
-
-
-/////////////////////////////////////////////////////////////////////
-
-
-%include <shared_ptr.i>
-
-%define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...)
-
-%naturalvar TYPE;
-%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
-
-// destructor mods
-%feature("unref") TYPE "(void)arg1; delete smartarg1;"
-
-
-// plain value
-%typemap(in, canthrow=1) CONST TYPE ($&1_type argp = 0) %{
- argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0;
- if (!argp) {
- SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null $1_type", 0);
- return $null;
- }
- $1 = *argp; %}
-%typemap(out) CONST TYPE
-%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %}
-
-// plain pointer
-%typemap(in) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
- smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input;
- $1 = (TYPE *)(smartarg ? smartarg->get() : 0); %}
-%typemap(out, fragment="SWIG_null_deleter") CONST TYPE * %{
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0;
-%}
-
-// plain reference
-%typemap(in, canthrow=1) CONST TYPE & %{
- $1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
- if (!$1) {
- SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type reference is null", 0);
- return $null;
- } %}
-%typemap(out, fragment="SWIG_null_deleter") CONST TYPE &
-%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %}
-
-// plain pointer by reference
-%typemap(in) TYPE *CONST& ($*1_ltype temp = 0)
-%{ temp = ($*1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
- $1 = &temp; %}
-%typemap(out, fragment="SWIG_null_deleter") TYPE *CONST&
-%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %}
-
-%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{
- // shared_ptr by value
- smartarg = *($&1_ltype*)&$input;
- if (smartarg) $1 = *smartarg;
-%}
-%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{
- *($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0;
-%}
-
-// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug
-%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
-#error "typemaps for $1_type not available"
-%}
-%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
-#error "typemaps for $1_type not available"
-%}
-
-
-%typemap (ctype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "void *"
-%typemap (imtype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "void *"
-%typemap (cstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "$typemap(cstype, TYPE)"
-%typemap (csin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "$typemap(cstype, TYPE).getCPtr($csinput)"
-%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
- global::System.IntPtr cPtr = $imcall;
- return (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);
- }
-
-%typemap(csout, excode=SWIGEXCODE) CONST TYPE {
- return new $typemap(cstype, TYPE)($imcall, true);
- }
-%typemap(csout, excode=SWIGEXCODE) CONST TYPE & {
- return new $typemap(cstype, TYPE)($imcall, true);
- }
-%typemap(csout, excode=SWIGEXCODE) CONST TYPE * {
- global::System.IntPtr cPtr = $imcall;
- return (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);
- }
-%typemap(csout, excode=SWIGEXCODE) TYPE *CONST& {
- global::System.IntPtr cPtr = $imcall;
- return (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);
- }
-
-// Base proxy classes
-%typemap(csbody) TYPE %{
- private global::System.Runtime.InteropServices.HandleRef swigCPtr;
- private bool swigCMemOwnBase;
-
- PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) {
- swigCMemOwnBase = cMemoryOwn;
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- }
-
- CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
- return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
- }
-%}
-
-// Derived proxy classes
-%typemap(csbody_derived) TYPE %{
- private global::System.Runtime.InteropServices.HandleRef swigCPtr;
- private bool swigCMemOwnDerived;
-
- PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) {
- swigCMemOwnDerived = cMemoryOwn;
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- }
-
- CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
- return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
- }
-%}
-
-%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE {
- lock(this) {
- if (swigCPtr.Handle != global::System.IntPtr.Zero) {
- if (swigCMemOwnBase) {
- swigCMemOwnBase = false;
- $imcall;
- }
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
- }
- global::System.GC.SuppressFinalize(this);
- }
- }
-
-%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE {
- lock(this) {
- if (swigCPtr.Handle != global::System.IntPtr.Zero) {
- if (swigCMemOwnDerived) {
- swigCMemOwnDerived = false;
- $imcall;
- }
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
- }
- global::System.GC.SuppressFinalize(this);
- base.Dispose();
- }
- }
-
-
-// CONST version needed ???? also for C#
-%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "global::System.Runtime.InteropServices.HandleRef"
-%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "global::System.Runtime.InteropServices.HandleRef"
-
-
-%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
-%enddef
-
+// Users can provide their own SWIG_INTRUSIVE_PTR_TYPEMAPS or SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP macros before including this file to change the
+// visibility of the constructor and getCPtr method if desired to public if using multiple modules.
+#ifndef SWIG_INTRUSIVE_PTR_TYPEMAPS
+#define SWIG_INTRUSIVE_PTR_TYPEMAPS(CONST, TYPE...) SWIG_INTRUSIVE_PTR_TYPEMAPS_IMPLEMENTATION(internal, internal, CONST, TYPE)
+#endif
+#ifndef SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP
+#define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(CONST, TYPE...) SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP_IMPLEMENTATION(internal, internal, CONST, TYPE)
+#endif
+
+%include <intrusive_ptr.i>
+
+// Language specific macro implementing all the customisations for handling the smart pointer
+%define SWIG_INTRUSIVE_PTR_TYPEMAPS_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...)
+
+// %naturalvar is as documented for member variables
+%naturalvar TYPE;
+%naturalvar SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >;
+
+// destructor wrapper customisation
+%feature("unref") TYPE "(void)arg1; delete smartarg1;"
+
+// Typemap customisations...
+
+%typemap(in, canthrow=1) CONST TYPE ($&1_type argp = 0) %{
+ // plain value
+ argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0;
+ if (!argp) {
+ SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null $1_type", 0);
+ return $null;
+ }
+ $1 = *argp;
+%}
+%typemap(out, fragment="SWIG_intrusive_deleter") CONST TYPE %{
+ //plain value(out)
+ $1_ltype* resultp = new $1_ltype(($1_ltype &)$1);
+ intrusive_ptr_add_ref(resultp);
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(resultp, SWIG_intrusive_deleter< CONST TYPE >());
+%}
+
+%typemap(in, canthrow=1) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
+ // plain pointer
+ smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input;
+ $1 = (TYPE *)(smartarg ? smartarg->get() : 0);
+%}
+%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE * %{
+ //plain pointer(out)
+ #if ($owner)
+ if ($1) {
+ intrusive_ptr_add_ref($1);
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >());
+ } else {
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
+ }
+ #else
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0;
+ #endif
+%}
+
+%typemap(in, canthrow=1) CONST TYPE & %{
+ // plain reference
+ $1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
+ if(!$1) {
+ SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type reference is null", 0);
+ return $null;
+ }
+%}
+%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE & %{
+ //plain reference(out)
+ #if ($owner)
+ if ($1) {
+ intrusive_ptr_add_ref($1);
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >());
+ } else {
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
+ }
+ #else
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0;
+ #endif
+%}
+
+%typemap(in) TYPE *CONST& ($*1_ltype temp = 0) %{
+ // plain pointer by reference
+ temp = ($*1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
+ $1 = &temp;
+%}
+%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") TYPE *CONST& %{
+ // plain pointer by reference(out)
+ #if ($owner)
+ if (*$1) {
+ intrusive_ptr_add_ref(*$1);
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1, SWIG_intrusive_deleter< CONST TYPE >());
+ } else {
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
+ }
+ #else
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_0);
+ #endif
+%}
+
+%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
+ // intrusive_ptr by value
+ smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
+ if (smartarg) {
+ $1 = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
+ }
+%}
+%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > %{
+ if ($1) {
+ intrusive_ptr_add_ref($1.get());
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1.get(), SWIG_intrusive_deleter< CONST TYPE >());
+ } else {
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
+ }
+%}
+
+%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{
+ // shared_ptr by value
+ smartarg = *($&1_ltype*)&$input;
+ if (smartarg) $1 = *smartarg;
+%}
+%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{
+ *($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0;
+%}
+
+%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
+ // intrusive_ptr by reference
+ if ( $input ) {
+ smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
+ temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
+ $1 = &temp;
+ } else {
+ $1 = &tempnull;
+ }
+%}
+%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{
+ delete &($1);
+ if ($self) {
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * temp = new SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(*$input);
+ $1 = *temp;
+ }
+%}
+%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{
+ if (*$1) {
+ intrusive_ptr_add_ref($1->get());
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >());
+ } else {
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
+ }
+%}
+
+%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
+ // intrusive_ptr by pointer
+ if ( $input ) {
+ smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
+ temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
+ $1 = &temp;
+ } else {
+ $1 = &tempnull;
+ }
+%}
+%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{
+ delete $1;
+ if ($self) $1 = new SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(*$input);
+%}
+%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{
+ if ($1 && *$1) {
+ intrusive_ptr_add_ref($1->get());
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >());
+ } else {
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
+ }
+ if ($owner) delete $1;
+%}
+
+%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& (SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > temp, $*1_ltype tempp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
+ // intrusive_ptr by pointer reference
+ smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
+ if ($input) {
+ temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
+ }
+ tempp = &temp;
+ $1 = &tempp;
+%}
+%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{
+ if ($self) $1 = *$input;
+%}
+%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{
+ if (*$1 && **$1) {
+ intrusive_ptr_add_ref((*$1)->get());
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >((*$1)->get(), SWIG_intrusive_deleter< CONST TYPE >());
+ } else {
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
+ }
+%}
+
+// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug
+%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
+#error "typemaps for $1_type not available"
+%}
+%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
+#error "typemaps for $1_type not available"
+%}
+
+
+%typemap (ctype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "void *"
+%typemap (imtype, out="global::System.IntPtr") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "global::System.Runtime.InteropServices.HandleRef"
+%typemap (cstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "$typemap(cstype, TYPE)"
+%typemap(csin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "$typemap(cstype, TYPE).getCPtr($csinput)"
+
+%typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > {
+ global::System.IntPtr cPtr = $imcall;
+ $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
+ return ret;
+ }
+%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
+ global::System.IntPtr cPtr = $imcall;
+ $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
+ return ret;
+ }
+%typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & {
+ global::System.IntPtr cPtr = $imcall;
+ $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
+ return ret;
+ }
+%typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * {
+ global::System.IntPtr cPtr = $imcall;
+ $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
+ return ret;
+ }
+%typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& {
+ global::System.IntPtr cPtr = $imcall;
+ $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
+ return ret;
+ }
+%typemap(csvarout, excode=SWIGEXCODE2) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > %{
+ get {
+ $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
+ return ret;
+ } %}
+%typemap(csvarout, excode=SWIGEXCODE2) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >& %{
+ get {
+ $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
+ return ret;
+ } %}
+%typemap(csvarout, excode=SWIGEXCODE2) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >* %{
+ get {
+ $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
+ return ret;
+ } %}
+
+
+%typemap(csout, excode=SWIGEXCODE) CONST TYPE {
+ $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
+ return ret;
+ }
+%typemap(csout, excode=SWIGEXCODE) CONST TYPE & {
+ $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
+ return ret;
+ }
+%typemap(csout, excode=SWIGEXCODE) CONST TYPE * {
+ global::System.IntPtr cPtr = $imcall;
+ $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
+ return ret;
+ }
+%typemap(csout, excode=SWIGEXCODE) TYPE *CONST& {
+ global::System.IntPtr cPtr = $imcall;
+ $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
+ return ret;
+ }
+
+// Base proxy classes
+%typemap(csbody) TYPE %{
+ private global::System.Runtime.InteropServices.HandleRef swigCPtr;
+ private bool swigCMemOwnBase;
+
+ PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) {
+ swigCMemOwnBase = cMemoryOwn;
+ swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
+ }
+
+ CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
+ return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
+ }
+%}
+
+// Derived proxy classes
+%typemap(csbody_derived) TYPE %{
+ private global::System.Runtime.InteropServices.HandleRef swigCPtr;
+ private bool swigCMemOwnDerived;
+
+ PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) {
+ swigCMemOwnDerived = cMemoryOwn;
+ swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
+ }
+
+ CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
+ return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
+ }
+%}
+
+%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE {
+ lock(this) {
+ if (swigCPtr.Handle != global::System.IntPtr.Zero) {
+ if (swigCMemOwnBase) {
+ swigCMemOwnBase = false;
+ $imcall;
+ }
+ swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+ }
+ global::System.GC.SuppressFinalize(this);
+ }
+ }
+
+%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE {
+ lock(this) {
+ if (swigCPtr.Handle != global::System.IntPtr.Zero) {
+ if (swigCMemOwnDerived) {
+ swigCMemOwnDerived = false;
+ $imcall;
+ }
+ swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+ }
+ global::System.GC.SuppressFinalize(this);
+ base.Dispose();
+ }
+ }
+
+// CONST version needed ???? also for C#
+%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "global::System.Runtime.InteropServices.HandleRef"
+%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "global::System.Runtime.InteropServices.HandleRef"
+
+
+%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
+%template() SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >;
+%enddef
+
+
+/////////////////////////////////////////////////////////////////////
+
+
+%include <shared_ptr.i>
+
+%define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...)
+
+%naturalvar TYPE;
+%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
+
+// destructor mods
+%feature("unref") TYPE "(void)arg1; delete smartarg1;"
+
+
+// plain value
+%typemap(in, canthrow=1) CONST TYPE ($&1_type argp = 0) %{
+ argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0;
+ if (!argp) {
+ SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null $1_type", 0);
+ return $null;
+ }
+ $1 = *argp; %}
+%typemap(out) CONST TYPE
+%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %}
+
+// plain pointer
+%typemap(in) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
+ smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input;
+ $1 = (TYPE *)(smartarg ? smartarg->get() : 0); %}
+%typemap(out, fragment="SWIG_null_deleter") CONST TYPE * %{
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0;
+%}
+
+// plain reference
+%typemap(in, canthrow=1) CONST TYPE & %{
+ $1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
+ if (!$1) {
+ SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type reference is null", 0);
+ return $null;
+ } %}
+%typemap(out, fragment="SWIG_null_deleter") CONST TYPE &
+%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %}
+
+// plain pointer by reference
+%typemap(in) TYPE *CONST& ($*1_ltype temp = 0)
+%{ temp = ($*1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
+ $1 = &temp; %}
+%typemap(out, fragment="SWIG_null_deleter") TYPE *CONST&
+%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %}
+
+%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{
+ // shared_ptr by value
+ smartarg = *($&1_ltype*)&$input;
+ if (smartarg) $1 = *smartarg;
+%}
+%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{
+ *($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0;
+%}
+
+// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug
+%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
+#error "typemaps for $1_type not available"
+%}
+%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
+#error "typemaps for $1_type not available"
+%}
+
+
+%typemap (ctype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "void *"
+%typemap (imtype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "void *"
+%typemap (cstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "$typemap(cstype, TYPE)"
+%typemap (csin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "$typemap(cstype, TYPE).getCPtr($csinput)"
+%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
+ global::System.IntPtr cPtr = $imcall;
+ return (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);
+ }
+
+%typemap(csout, excode=SWIGEXCODE) CONST TYPE {
+ return new $typemap(cstype, TYPE)($imcall, true);
+ }
+%typemap(csout, excode=SWIGEXCODE) CONST TYPE & {
+ return new $typemap(cstype, TYPE)($imcall, true);
+ }
+%typemap(csout, excode=SWIGEXCODE) CONST TYPE * {
+ global::System.IntPtr cPtr = $imcall;
+ return (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);
+ }
+%typemap(csout, excode=SWIGEXCODE) TYPE *CONST& {
+ global::System.IntPtr cPtr = $imcall;
+ return (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);
+ }
+
+// Base proxy classes
+%typemap(csbody) TYPE %{
+ private global::System.Runtime.InteropServices.HandleRef swigCPtr;
+ private bool swigCMemOwnBase;
+
+ PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) {
+ swigCMemOwnBase = cMemoryOwn;
+ swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
+ }
+
+ CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
+ return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
+ }
+%}
+
+// Derived proxy classes
+%typemap(csbody_derived) TYPE %{
+ private global::System.Runtime.InteropServices.HandleRef swigCPtr;
+ private bool swigCMemOwnDerived;
+
+ PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) {
+ swigCMemOwnDerived = cMemoryOwn;
+ swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
+ }
+
+ CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
+ return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
+ }
+%}
+
+%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE {
+ lock(this) {
+ if (swigCPtr.Handle != global::System.IntPtr.Zero) {
+ if (swigCMemOwnBase) {
+ swigCMemOwnBase = false;
+ $imcall;
+ }
+ swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+ }
+ global::System.GC.SuppressFinalize(this);
+ }
+ }
+
+%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE {
+ lock(this) {
+ if (swigCPtr.Handle != global::System.IntPtr.Zero) {
+ if (swigCMemOwnDerived) {
+ swigCMemOwnDerived = false;
+ $imcall;
+ }
+ swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+ }
+ global::System.GC.SuppressFinalize(this);
+ base.Dispose();
+ }
+ }
+
+
+// CONST version needed ???? also for C#
+%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "global::System.Runtime.InteropServices.HandleRef"
+%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "global::System.Runtime.InteropServices.HandleRef"
+
+
+%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
+%enddef
diff --git a/Lib/csharp/csharp.swg b/Lib/csharp/csharp.swg
index f7b7927ba..d94336194 100644
--- a/Lib/csharp/csharp.swg
+++ b/Lib/csharp/csharp.swg
@@ -409,8 +409,8 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
#endif
%typemap(directorin) SWIGTYPE
-%{ $input = (void *)&$1; %}
-%typemap(csdirectorin) SWIGTYPE "new $&csclassname($iminput, false)"
+%{ $input = (void *)new $1_ltype((const $1_ltype &)$1); %}
+%typemap(csdirectorin) SWIGTYPE "new $&csclassname($iminput, true)"
%typemap(csdirectorout) SWIGTYPE "$&csclassname.getCPtr($cscall).Handle"
/* Generic pointers and references */
diff --git a/Lib/csharp/swiginterface.i b/Lib/csharp/swiginterface.i
index 3741b87ac..e5bfd23a4 100644
--- a/Lib/csharp/swiginterface.i
+++ b/Lib/csharp/swiginterface.i
@@ -31,7 +31,7 @@
$*csclassname ret = (cPtr == global::System.IntPtr.Zero) ? null : new $*csclassname(cPtr, $owner);$excode
return ($*csinterfacename)ret;
}
-%typemap(csdirectorin) CTYPE "($&csinterfacename)new $&csclassname($iminput, false)"
+%typemap(csdirectorin) CTYPE "($&csinterfacename)new $&csclassname($iminput, true)"
%typemap(csdirectorin) CTYPE & "($csinterfacename)new $csclassname($iminput, false)"
%typemap(csdirectorin) CTYPE *, CTYPE [] "($iminput == global::System.IntPtr.Zero) ? null : ($csinterfacename)new $csclassname($iminput, false)"
%typemap(csdirectorin) CTYPE *const& "($iminput == global::System.IntPtr.Zero) ? null : ($*csinterfacename)new $*csclassname($iminput, false)"
diff --git a/Lib/d/dswigtype.swg b/Lib/d/dswigtype.swg
index 41336dc91..f91d6dfe6 100644
--- a/Lib/d/dswigtype.swg
+++ b/Lib/d/dswigtype.swg
@@ -57,7 +57,7 @@
#endif
%typemap(directorin) SWIGTYPE
- "$input = (void *)&$1;"
+ "$input = (void *)new $1_ltype((const $1_ltype &)$1);"
%typemap(directorout) SWIGTYPE
%{ if (!$input) {
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "Unexpected null return for type $1_type");
@@ -65,7 +65,7 @@
}
$result = *($&1_ltype)$input; %}
-%typemap(ddirectorin) SWIGTYPE "new $&dclassname($winput, false)"
+%typemap(ddirectorin) SWIGTYPE "new $&dclassname($winput, true)"
%typemap(ddirectorout) SWIGTYPE "$&dclassname.swigGetCPtr($dcall)"
%typemap(din) SWIGTYPE "$&dclassname.swigGetCPtr($dinput)"
diff --git a/Lib/go/go.swg b/Lib/go/go.swg
index bdd2aedea..53b653f7c 100644
--- a/Lib/go/go.swg
+++ b/Lib/go/go.swg
@@ -584,7 +584,7 @@
%typemap(goout) SWIGTYPE ""
%typemap(directorin) SWIGTYPE
-%{ $input = ($&1_ltype)&$1; %}
+%{ $input = new $1_ltype((const $1_ltype &)$1); %}
%typemap(godirectorin) SWIGTYPE ""
diff --git a/Lib/guile/std_map.i b/Lib/guile/std_map.i
index fefbe2e77..489acc187 100644
--- a/Lib/guile/std_map.i
+++ b/Lib/guile/std_map.i
@@ -41,7 +41,7 @@
namespace std {
template<class K, class T> class map {
- %typemap(in) map<K,T> (std::map<K,T>* m) {
+ %typemap(in) map<K,T> {
if (scm_is_null($input)) {
$1 = std::map< K, T >();
} else if (scm_is_pair($input)) {
@@ -72,10 +72,8 @@ namespace std {
SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0));
}
}
- %typemap(in) const map<K,T>& (std::map<K,T> temp,
- std::map<K,T>* m),
- const map<K,T>* (std::map<K,T> temp,
- std::map<K,T>* m) {
+ %typemap(in) const map<K,T>& (std::map<K,T> temp),
+ const map<K,T>* (std::map<K,T> temp) {
if (scm_is_null($input)) {
temp = std::map< K, T >();
$1 = &temp;
@@ -266,7 +264,7 @@ namespace std {
%define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO)
template<class T> class map<K,T> {
- %typemap(in) map<K,T> (std::map<K,T>* m) {
+ %typemap(in) map<K,T> {
if (scm_is_null($input)) {
$1 = std::map< K, T >();
} else if (scm_is_pair($input)) {
@@ -298,10 +296,8 @@ namespace std {
SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0));
}
}
- %typemap(in) const map<K,T>& (std::map<K,T> temp,
- std::map<K,T>* m),
- const map<K,T>* (std::map<K,T> temp,
- std::map<K,T>* m) {
+ %typemap(in) const map<K,T>& (std::map<K,T> temp),
+ const map<K,T>* (std::map<K,T> temp) {
if (scm_is_null($input)) {
temp = std::map< K, T >();
$1 = &temp;
@@ -480,7 +476,7 @@ namespace std {
%define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO)
template<class K> class map<K,T> {
- %typemap(in) map<K,T> (std::map<K,T>* m) {
+ %typemap(in) map<K,T> {
if (scm_is_null($input)) {
$1 = std::map< K, T >();
} else if (scm_is_pair($input)) {
@@ -511,10 +507,8 @@ namespace std {
SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0));
}
}
- %typemap(in) const map<K,T>& (std::map<K,T> temp,
- std::map<K,T>* m),
- const map<K,T>* (std::map<K,T> temp,
- std::map<K,T>* m) {
+ %typemap(in) const map<K,T>& (std::map<K,T> temp),
+ const map<K,T>* (std::map<K,T> temp) {
if (scm_is_null($input)) {
temp = std::map< K, T >();
$1 = &temp;
@@ -567,7 +561,6 @@ namespace std {
K* k;
SCM head = SCM_CAR($input);
if (scm_is_pair(head)) {
- SCM key = SCM_CAR(head);
SCM val = SCM_CDR(head);
if (SWIG_ConvertPtr(val,(void **) &k,
$descriptor(K *), 0) != 0) {
@@ -609,7 +602,6 @@ namespace std {
K* k;
SCM head = SCM_CAR($input);
if (scm_is_pair(head)) {
- SCM key = SCM_CAR(head);
SCM val = SCM_CDR(head);
if (SWIG_ConvertPtr(val,(void **) &k,
$descriptor(K *), 0) != 0) {
@@ -692,7 +684,7 @@ namespace std {
%define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO,
T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO)
template<> class map<K,T> {
- %typemap(in) map<K,T> (std::map<K,T>* m) {
+ %typemap(in) map<K,T> {
if (scm_is_null($input)) {
$1 = std::map< K, T >();
} else if (scm_is_pair($input)) {
@@ -725,10 +717,8 @@ namespace std {
SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0));
}
}
- %typemap(in) const map<K,T>& (std::map<K,T> temp,
- std::map<K,T>* m),
- const map<K,T>* (std::map<K,T> temp,
- std::map<K,T>* m) {
+ %typemap(in) const map<K,T>& (std::map<K,T> temp),
+ const map<K,T>* (std::map<K,T> temp) {
if (scm_is_null($input)) {
temp = std::map< K, T >();
$1 = &temp;
diff --git a/Lib/java/java.swg b/Lib/java/java.swg
index 96ca562b6..d763c5e6f 100644
--- a/Lib/java/java.swg
+++ b/Lib/java/java.swg
@@ -647,8 +647,8 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
%typemap(directorin,descriptor="L$packagepath/$&javaclassname;") SWIGTYPE
%{ $input = 0;
- *(($&1_ltype*)&$input) = &$1; %}
-%typemap(javadirectorin) SWIGTYPE "new $&javaclassname($jniinput, false)"
+ *(($&1_ltype*)&$input) = new $1_ltype((const $1_ltype &)$1); %}
+%typemap(javadirectorin) SWIGTYPE "new $&javaclassname($jniinput, true)"
%typemap(javadirectorout) SWIGTYPE "$&javaclassname.getCPtr($javacall)"
/* Generic pointers and references */
diff --git a/Lib/java/swiginterface.i b/Lib/java/swiginterface.i
index 169118278..334464157 100644
--- a/Lib/java/swiginterface.i
+++ b/Lib/java/swiginterface.i
@@ -31,7 +31,7 @@
return (cPtr == 0) ? null : ($javainterfacename)new $javaclassname(cPtr, $owner);
}
-%typemap(javadirectorin) CTYPE "($&javainterfacename)new $&javaclassname($jniinput, false)"
+%typemap(javadirectorin) CTYPE "($&javainterfacename)new $&javaclassname($jniinput, true)"
%typemap(javadirectorin) CTYPE & "($javainterfacename)new $javaclassname($jniinput, false)"
%typemap(javadirectorin) CTYPE *, CTYPE [] "($jniinput == 0) ? null : ($javainterfacename)new $javaclassname($jniinput, false)"
%typemap(javadirectorin) CTYPE *const& "($jniinput == 0) ? null : ($*javainterfacename)new $*javaclassname($jniinput, false)"
@@ -40,7 +40,7 @@
%typemap(javadirectorout) CTYPE *const& "$javacall.$*interfacename_GetInterfaceCPtr()"
%typemap(directorin,descriptor="L$packagepath/$&javainterfacename;") CTYPE
%{ $input = 0;
- *(($&1_ltype*)&$input) = &$1; %}
+ *(($&1_ltype*)&$input) = new $1_ltype((const $1_ltype &)$1); %}
%typemap(directorin,descriptor="L$packagepath/$javainterfacename;") CTYPE *, CTYPE []
%{ *(($&1_ltype)&$input) = ($1_ltype) $1; %}
%typemap(directorin,descriptor="L$packagepath/$javainterfacename;") CTYPE &
diff --git a/Lib/perl5/perlinit.swg b/Lib/perl5/perlinit.swg
index cdb73d53a..b49040d26 100644
--- a/Lib/perl5/perlinit.swg
+++ b/Lib/perl5/perlinit.swg
@@ -28,6 +28,7 @@ extern "C"
XS(SWIG_init) {
dXSARGS;
int i;
+ (void)items;
SWIG_InitializeModule(0);
diff --git a/Lib/perl5/perlrun.swg b/Lib/perl5/perlrun.swg
index 876fae268..d1865de0a 100644
--- a/Lib/perl5/perlrun.swg
+++ b/Lib/perl5/perlrun.swg
@@ -144,9 +144,9 @@ typedef int (*SwigMagicFunc)(struct interpreter *, SV *, MAGIC *);
# ifdef PERL_OBJECT
# define SWIG_croak_null() SWIG_Perl_croak_null(pPerl)
-static void SWIG_Perl_croak_null(CPerlObj *pPerl)
+static void SWIGUNUSED SWIG_Perl_croak_null(CPerlObj *pPerl)
# else
-static void SWIG_croak_null()
+static void SWIGUNUSED SWIG_croak_null()
# endif
{
SV *err = get_sv("@", GV_ADD);
diff --git a/Lib/php/php.swg b/Lib/php/php.swg
index 05d25a1df..45dfb0b0d 100644
--- a/Lib/php/php.swg
+++ b/Lib/php/php.swg
@@ -429,7 +429,7 @@
%typemap(directorin) SWIGTYPE
{
- SWIG_SetPointerZval($input, SWIG_as_voidptr(&$1), $&1_descriptor, 2);
+ SWIG_SetPointerZval($input, SWIG_as_voidptr(new $1_ltype((const $1_ltype &)$1)), $&1_descriptor, 1|2);
}
%typemap(out) void "";
diff --git a/Lib/python/pyopers.swg b/Lib/python/pyopers.swg
index 80a0d68c6..292c593a8 100644
--- a/Lib/python/pyopers.swg
+++ b/Lib/python/pyopers.swg
@@ -103,7 +103,11 @@
%pybinoperator(__neg__, *::operator-(), unaryfunc, nb_negative);
%pybinoperator(__neg__, *::operator-() const, unaryfunc, nb_negative);
%pybinoperator(__mul__, *::operator*, binaryfunc, nb_multiply);
-%pybinoperator(__div__, *::operator/, binaryfunc, nb_div);
+#if defined(SWIGPYTHON_PY3)
+%pybinoperator(__truediv__, *::operator/, binaryfunc, nb_divide);
+#else
+%pybinoperator(__div__, *::operator/, binaryfunc, nb_divide);
+#endif
%pybinoperator(__mod__, *::operator%, binaryfunc, nb_remainder);
%pybinoperator(__lshift__, *::operator<<, binaryfunc, nb_lshift);
%pybinoperator(__rshift__, *::operator>>, binaryfunc, nb_rshift);
@@ -117,8 +121,6 @@
%pycompare(__eq__, *::operator==, Py_EQ);
%pycompare(__ne__, *::operator!=, Py_NE);
-%feature("python:slot", "nb_truediv", functype="binaryfunc") *::operator/;
-
/* Special cases */
%rename(__invert__) *::operator~;
%feature("python:slot", "nb_invert", functype="unaryfunc") *::operator~;
@@ -200,7 +202,11 @@ __bool__ = __nonzero__
%pyinplaceoper(__iadd__ , *::operator +=, binaryfunc, nb_inplace_add);
%pyinplaceoper(__isub__ , *::operator -=, binaryfunc, nb_inplace_subtract);
%pyinplaceoper(__imul__ , *::operator *=, binaryfunc, nb_inplace_multiply);
+#if defined(SWIGPYTHON_PY3)
+%pyinplaceoper(__itruediv__ , *::operator /=, binaryfunc, nb_inplace_divide);
+#else
%pyinplaceoper(__idiv__ , *::operator /=, binaryfunc, nb_inplace_divide);
+#endif
%pyinplaceoper(__imod__ , *::operator %=, binaryfunc, nb_inplace_remainder);
%pyinplaceoper(__iand__ , *::operator &=, binaryfunc, nb_inplace_and);
%pyinplaceoper(__ior__ , *::operator |=, binaryfunc, nb_inplace_or);
diff --git a/Lib/python/pyprimtypes.swg b/Lib/python/pyprimtypes.swg
index fb5bbf6df..575b6db88 100644
--- a/Lib/python/pyprimtypes.swg
+++ b/Lib/python/pyprimtypes.swg
@@ -223,6 +223,8 @@ SWIG_AsVal_dec(long long)(PyObject *obj, long long *val)
const double mant_min = -mant_max;
double d;
res = SWIG_AsVal(double)(obj,&d);
+ if (SWIG_IsOK(res) && !SWIG_CanCastAsInteger(&d, mant_min, mant_max))
+ return SWIG_OverflowError;
if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, mant_min, mant_max)) {
if (val) *val = (long long)(d);
return SWIG_AddCast(res);
@@ -280,6 +282,8 @@ SWIG_AsVal_dec(unsigned long long)(PyObject *obj, unsigned long long *val)
const double mant_max = 1LL << DBL_MANT_DIG;
double d;
res = SWIG_AsVal(double)(obj,&d);
+ if (SWIG_IsOK(res) && !SWIG_CanCastAsInteger(&d, 0, mant_max))
+ return SWIG_OverflowError;
if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, mant_max)) {
if (val) *val = (unsigned long long)(d);
return SWIG_AddCast(res);
diff --git a/Lib/r/rrun.swg b/Lib/r/rrun.swg
index 990443e23..823b61ea5 100644
--- a/Lib/r/rrun.swg
+++ b/Lib/r/rrun.swg
@@ -218,10 +218,6 @@ SWIGRUNTIME SEXP
SWIG_MakePtr(void *ptr, const char *typeName, R_SWIG_Owner owner)
{
SEXP external, r_obj;
- const char *p = typeName;
-
- if(typeName[0] == '_')
- p = typeName + 1;
Rf_protect(external = R_MakeExternalPtr(ptr, Rf_install(typeName), R_NilValue));
Rf_protect(r_obj = NEW_OBJECT(MAKE_CLASS((char *) typeName)));
diff --git a/Lib/r/std_vector.i b/Lib/r/std_vector.i
index d8d82f26a..4ec51dc91 100644
--- a/Lib/r/std_vector.i
+++ b/Lib/r/std_vector.i
@@ -544,8 +544,7 @@
struct traits_asptr < std::vector<T> > {
static int asptr(SEXP obj, std::vector<T> **val) {
std::vector<T> *p;
- Rprintf("my asptr\n");
- int res = SWIG_R_ConvertPtr(obj, (void**)&p, type_info< std::vector<T> >(), 0);
+ int res = SWIG_R_ConvertPtr(obj, (void**)&p, type_info< std::vector<T> >(), 0);
if (SWIG_IsOK(res)) {
if (val) *val = p;
}
@@ -839,35 +838,35 @@
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<double>)
%traits_type_name(std::vector<double>)
-%typemap("rtypecheck") std::vector<double>, std::vector<double> const, std::vector<double> const&
+%typemap("rtypecheck") std::vector<double>, std::vector<double> *, std::vector<double> &
%{ is.numeric($arg) %}
%typemap("rtype") std::vector<double> "numeric"
-%typemap("scoercein") std::vector<double>, std::vector<double> const, std::vector<double> const& "";
+%typemap("scoercein") std::vector<double>, std::vector<double> *, std::vector<double> & "$input = as.numeric($input);";
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<float>)
%traits_type_name(std::vector<float>)
// reuse these for float
-%typemap("rtype") std::vector<float> = std::vector<double>;
-%typemap("rtypecheck") std::vector<float> = std::vector<double>;
-%typemap("scoercein") std::vector<float> = std::vector<double>;
+%typemap("rtype") std::vector<float>, std::vector<float> *, std::vector<float> & = std::vector<double>;
+%typemap("rtypecheck") std::vector<float>, std::vector<float> *, std::vector<float> & = std::vector<double>;
+%typemap("scoercein") std::vector<float>, std::vector<float> *, std::vector<float> & = std::vector<double>;
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<bool>);
%traits_type_name(std::vector<bool>);
-%typemap("rtypecheck") std::vector<bool> , std::vector<bool> const, std::vector<bool> const&
+%typemap("rtypecheck") std::vector<bool>, std::vector<bool> *, std::vector<bool> &
%{ is.logical($arg) %}
%typemap("rtype") std::vector<bool> "logical"
-%typemap("scoercein") std::vector<bool> , std::vector<bool> const, std::vector<bool> const& "$input = as.logical($input);";
+%typemap("scoercein") std::vector<bool> , std::vector<bool> & "$input = as.logical($input);";
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<int>);
%traits_type_name(std::vector<int>);
-%typemap("rtypecheck") std::vector<int>, std::vector<int> const, std::vector<int> const &
+%typemap("rtypecheck") std::vector<int>, std::vector<int> *, std::vector<int> &
%{ is.integer($arg) || is.numeric($arg) %}
%typemap("rtype") std::vector<int> "integer"
-%typemap("scoercein") std::vector<int> , std::vector<int> const, std::vector<int> const& "$input = as.integer($input);";
+%typemap("scoercein") std::vector<int> , std::vector<int> *, std::vector<int> & "$input = as.integer($input);";
// strings
%typemap("rtype") std::vector< std::basic_string<char> >,
@@ -928,76 +927,83 @@ std::vector< std::basic_string<char> > *,
// but we can't use %apply as it will copy the C side ones too
// Also note that we don't seem to be able to use types like
// int_least8_t here.
-%typemap("rtype") std::vector<signed char> = std::vector<int>;
-%typemap("rtype") std::vector<signed short> = std::vector<int>;
-%typemap("rtype") std::vector<unsigned char> = std::vector<int>;
-%typemap("rtype") std::vector<unsigned int> = std::vector<int>;
+%typemap("rtype") std::vector<signed char>, std::vector<signed char> *, std::vector<signed char> & = std::vector<int>;
+%typemap("rtype") std::vector<signed short>, std::vector<signed short> *, std::vector<signed short> & = std::vector<int>;
+%typemap("rtype") std::vector<unsigned char>, std::vector<unsigned char> *, std::vector<unsigned char> & = std::vector<int>;
+%typemap("rtype") std::vector<unsigned int>, std::vector<unsigned int> *, std::vector<unsigned int> & = std::vector<int>;
#if defined(SWIGWORDSIZE64)
-%typemap("rtype") std::vector<long int> = std::vector<int>;
-%typemap("rtype") std::vector<unsigned long int> = std::vector<int>;
+%typemap("rtype") std::vector<long int>, std::vector<long int> *, std::vector<long int> & = std::vector<int>;
+%typemap("rtype") std::vector<unsigned long int>, std::vector<unsigned long int> *, std::vector<unsigned long int> & = std::vector<int>;
#else
-%typemap("rtype") std::vector<long long int> = std::vector<int>;
-%typemap("rtype") std::vector<unsigned long long int> = std::vector<int>;
+%typemap("rtype") std::vector<long long int>, std::vector<long long int> *, std::vector<long long int> & = std::vector<int>;
+%typemap("rtype") std::vector<unsigned long long int>, std::vector<unsigned long long int> *, std::vector<unsigned long long int> & = std::vector<int>;
#endif
-%typemap("scoercein") std::vector<signed char> = std::vector<int>;
-%typemap("scoercein") std::vector<signed short> = std::vector<int>;
-%typemap("scoercein") std::vector<unsigned char> = std::vector<int>;
-%typemap("scoercein") std::vector<unsigned int> = std::vector<int>;
+%typemap("scoercein") std::vector<signed char>, std::vector<signed char> *, std::vector<signed char> & = std::vector<int>;
+%typemap("scoercein") std::vector<signed short>, std::vector<signed short> *, std::vector<signed short> & = std::vector<int>;
+%typemap("scoercein") std::vector<unsigned char>, std::vector<unsigned char> *, std::vector<unsigned char> & = std::vector<int>;
+%typemap("scoercein") std::vector<unsigned int>, std::vector<unsigned int> *, std::vector<unsigned int> & = std::vector<int>;
#if defined(SWIGWORDSIZE64)
-%typemap("scoercein") std::vector<long int> = std::vector<int>;
-%typemap("scoercein") std::vector<unsigned long int> = std::vector<int>;
+%typemap("scoercein") std::vector<long int>, std::vector<long int> *, std::vector<long int> & = std::vector<int>;
+%typemap("scoercein") std::vector<unsigned long int>, std::vector<unsigned long int> *, std::vector<unsigned long int> & = std::vector<int>;
#else
-%typemap("scoercein") std::vector<long long int> = std::vector<int>;
-%typemap("scoercein") std::vector<unsigned long long int> = std::vector<int>;
+%typemap("scoercein") std::vector<long long int>, std::vector<long long int> *, std::vector<long long int> & = std::vector<int>;
+%typemap("scoercein") std::vector<unsigned long long int>, std::vector<unsigned long long int> *, std::vector<unsigned long long int> & = std::vector<int>;
#endif
-%typemap("rtypecheck") std::vector<signed char> = std::vector<int>;
-%typemap("rtypecheck") std::vector<signed short> = std::vector<int>;
-%typemap("rtypecheck") std::vector<unsigned char> = std::vector<int>;
-%typemap("rtypecheck") std::vector<unsigned int> = std::vector<int>;
+%typemap("rtypecheck") std::vector<signed char>, std::vector<signed char> *, std::vector<signed char> & = std::vector<int>;
+%typemap("rtypecheck") std::vector<signed short>, std::vector<signed short> *, std::vector<signed short> & = std::vector<int>;
+%typemap("rtypecheck") std::vector<unsigned char>, std::vector<unsigned char> *, std::vector<unsigned char> & = std::vector<int>;
+%typemap("rtypecheck") std::vector<unsigned int>, std::vector<unsigned int> *, std::vector<unsigned int> & = std::vector<int>;
#if defined(SWIGWORDSIZE64)
-%typemap("rtypecheck") std::vector<long int> = std::vector<int>;
-%typemap("rtypecheck") std::vector<unsigned long int> = std::vector<int>;
+%typemap("rtypecheck") std::vector<long int>, std::vector<long int> *, std::vector<long int> & = std::vector<int>;
+%typemap("rtypecheck") std::vector<unsigned long int>, std::vector<unsigned long int> *, std::vector<unsigned long int> & = std::vector<int>;
#else
-%typemap("rtypecheck") std::vector<long long int> = std::vector<int>;
-%typemap("rtypecheck") std::vector<unsigned long long int> = std::vector<int>;
+%typemap("rtypecheck") std::vector<long long int>, std::vector<long long int> *, std::vector<long long int> & = std::vector<int>;
+%typemap("rtypecheck") std::vector<unsigned long long int>, std::vector<unsigned long long int> *, std::vector<unsigned long long int> & = std::vector<int>;
#endif
///////////////////////////////////////////////////////////////
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<std::vector<int> >);
%traits_type_name(std::vector< std::vector<int> >);
-%typemap("rtypecheck") std::vector<std::vector<int> >, std::vector<std::vector<int> > const, std::vector<std::vector<int> >const&
+%typemap("rtypecheck") std::vector<std::vector<int> >, std::vector<std::vector<int> > *, std::vector<std::vector<int> > &
%{ is.list($arg) && all(sapply($arg , is.integer) || sapply($arg, is.numeric)) %}
-%typemap("rtype") std::vector<std::vector<int> > "list"
-%typemap("scoercein") std::vector< std::vector<int> >, std::vector<std::vector<int> > const, std::vector<std::vector<int> >const& "$input = lapply($input, as.integer);";
+%typemap("rtype") std::vector<std::vector<int> >, std::vector<std::vector<int> > *, std::vector<std::vector<int> > & "list"
+%typemap("scoercein") std::vector< std::vector<int> >, std::vector<std::vector<int> > *, std::vector<std::vector<int> > & "$input = lapply($input, as.integer);";
+
+%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<std::vector<unsigned int> >);
+%traits_type_name(std::vector< std::vector<unsigned int> >);
+%typemap("rtypecheck") std::vector<std::vector<unsigned int> >, std::vector<std::vector<unsigned int> > *, std::vector<std::vector<unsigned int> > &
+ %{ is.list($arg) && all(sapply($arg , is.integer) || sapply($arg, is.numeric)) %}
+%typemap("rtype") std::vector<std::vector<unsigned int> >, std::vector<std::vector<unsigned int> > *, std::vector<std::vector<unsigned int> > & "list"
+%typemap("scoercein") std::vector< std::vector<unsigned int> >, std::vector<std::vector<int> > *, std::vector<std::vector<unsigned int> > & "$input = lapply($input, as.integer);";
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<std::vector<float> >);
%traits_type_name(std::vector< std::vector<float> >);
-%typemap("rtypecheck") std::vector<std::vector<float> >, std::vector<std::vector<float> > const, std::vector<std::vector<float> >const&
+%typemap("rtypecheck") std::vector<std::vector<float> >, std::vector<std::vector<float> > *, std::vector<std::vector<float> > &
%{ is.list($arg) && all(sapply($arg , is.integer) || sapply($arg, is.numeric)) %}
-%typemap("rtype") std::vector<std::vector<float> > "list"
-%typemap("scoercein") std::vector< std::vector<float> >, std::vector<std::vector<float> > const, std::vector<std::vector<float> >const& "$input = lapply($input, as.numeric);";
+%typemap("rtype") std::vector<std::vector<float> >, std::vector<std::vector<float> > *, std::vector<std::vector<float> > "list"
+%typemap("scoercein") std::vector< std::vector<float> >, std::vector<std::vector<float> > *, std::vector<std::vector<float> > & "$input = lapply($input, as.numeric);";
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<std::vector<double> >);
%traits_type_name(std::vector< std::vector<double> >);
-%typemap("rtypecheck") std::vector<std::vector<double> >, std::vector<std::vector<double> > const, std::vector<std::vector<double> >const&
+%typemap("rtypecheck") std::vector<std::vector<double> >, std::vector<std::vector<double> > *, std::vector<std::vector<double> > &
%{ is.list($arg) && all(sapply($arg , is.integer) || sapply($arg, is.numeric)) %}
-%typemap("rtype") std::vector<std::vector<double> > "list"
-%typemap("scoercein") std::vector< std::vector<double> >, std::vector<std::vector<double> > const, std::vector<std::vector<double> >const&
+%typemap("rtype") std::vector<std::vector<double> >, std::vector<std::vector<double> > *, std::vector<std::vector<double> > & "list"
+%typemap("scoercein") std::vector< std::vector<double> >, std::vector<std::vector<double> > *, std::vector<std::vector<double> > &
"$input = lapply($input, as.numeric);";
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<std::vector<bool> >);
%traits_type_name(std::vector< std::vector<bool> >);
-%typemap("rtypecheck") std::vector<std::vector<bool> >, std::vector<std::vector<bool> > const, std::vector<std::vector<bool> >const&
+%typemap("rtypecheck") std::vector<std::vector<bool> >, std::vector<std::vector<bool> > *, std::vector<std::vector<bool> > &
%{ is.list($arg) && all(sapply($arg , is.integer) || sapply($arg, is.numeric)) %}
-%typemap("rtype") std::vector<std::vector<bool> > "list"
-%typemap("scoercein") std::vector< std::vector<bool> >, std::vector<std::vector<bool> > const, std::vector<std::vector<bool> >const& "$input = lapply($input, as.logical);";
+%typemap("rtype") std::vector<std::vector<bool> >, std::vector<std::vector<bool> > *, std::vector<std::vector<bool> > & "list"
+%typemap("scoercein") std::vector< std::vector<bool> >, std::vector<std::vector<bool> > *, std::vector<std::vector<bool> > & "$input = lapply($input, as.logical);";
// we don't want these to be given R classes as they
// have already been turned into R vectors.
diff --git a/Lib/ruby/rubyrun.swg b/Lib/ruby/rubyrun.swg
index e18208f90..249494ab0 100644
--- a/Lib/ruby/rubyrun.swg
+++ b/Lib/ruby/rubyrun.swg
@@ -305,6 +305,14 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags,
/* Do type-checking if type info was provided */
if (ty) {
+ if (ty->clientdata) {
+ if (rb_obj_is_kind_of(obj, ((swig_class *) (ty->clientdata))->klass)) {
+ if (vptr == 0) {
+ /* The object has already been deleted */
+ return SWIG_ObjectPreviouslyDeletedError;
+ }
+ }
+ }
if ((c = SWIG_MangleStr(obj)) == NULL) {
return SWIG_ERROR;
}
@@ -312,10 +320,6 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags,
if (!tc) {
return SWIG_ERROR;
} else {
- if (vptr == 0) {
- /* The object has already been deleted */
- return SWIG_ObjectPreviouslyDeletedError;
- }
if (ptr) {
if (tc->type == ty) {
*ptr = vptr;
diff --git a/Lib/swigrun.swg b/Lib/swigrun.swg
index a314bf239..1ef676187 100644
--- a/Lib/swigrun.swg
+++ b/Lib/swigrun.swg
@@ -495,16 +495,16 @@ SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
char d = *(c++);
unsigned char uu;
if ((d >= '0') && (d <= '9'))
- uu = ((d - '0') << 4);
+ uu = (unsigned char)((d - '0') << 4);
else if ((d >= 'a') && (d <= 'f'))
- uu = ((d - ('a'-10)) << 4);
+ uu = (unsigned char)((d - ('a'-10)) << 4);
else
return (char *) 0;
d = *(c++);
if ((d >= '0') && (d <= '9'))
- uu |= (d - '0');
+ uu |= (unsigned char)(d - '0');
else if ((d >= 'a') && (d <= 'f'))
- uu |= (d - ('a'-10));
+ uu |= (unsigned char)(d - ('a'-10));
else
return (char *) 0;
*u = uu;
diff --git a/Lib/typemaps/swigtype.swg b/Lib/typemaps/swigtype.swg
index 40d3ff5e9..d3633eb49 100644
--- a/Lib/typemaps/swigtype.swg
+++ b/Lib/typemaps/swigtype.swg
@@ -415,7 +415,7 @@
}
%typemap(directorin,noblock=1) SWIGTYPE {
- $input = SWIG_NewPointerObj(%as_voidptr(&$1), $&descriptor, %newpointer_flags);
+ $input = SWIG_NewPointerObj(%as_voidptr(new $1_ltype((const $1_ltype &)$1)), $&descriptor, SWIG_POINTER_OWN | %newpointer_flags);
}
%typemap(directorin,noblock=1) SWIGTYPE & {
diff --git a/README b/README
index 792af9e1a..3421b72bf 100644
--- a/README
+++ b/README
@@ -1,6 +1,6 @@
SWIG (Simplified Wrapper and Interface Generator)
-Version: 3.0.9 (in progress)
+Version: 3.0.11 (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 3f08074ab..080bb6066 100644
--- a/RELEASENOTES
+++ b/RELEASENOTES
@@ -7,6 +7,17 @@ Release Notes
Detailed release notes are available with the release and are also
published on the SWIG web site at http://swig.org/release.html.
+SWIG-3.0.10 summary:
+- Regression fixes for smart pointers and importing Python modules.
+
+SWIG-3.0.9 summary:
+- Add support for Python's implicit namespace packages.
+- Fixes to support Go 1.6.
+- C++11 std::array support added for Java.
+- Improved C++ multiple inheritance support for Java/C# wrappers.
+- Various other minor fixes and improvements for C#, D, Go, Java,
+ Javascript, Lua, Python, R, Ruby, Scilab.
+
SWIG-3.0.8 summary:
- pdf documentation enhancements.
- Various Python 3.5 issues fixed.
diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
index 93e26046d..784187c28 100644
--- a/Source/CParse/parser.y
+++ b/Source/CParse/parser.y
@@ -13,11 +13,14 @@
* some point. Beware.
* ----------------------------------------------------------------------------- */
-/*
-Removed until we know more about the min versions of Bison and Yacc required for this
-to work, see Byacc man page: http://invisible-island.net/byacc/manpage/yacc.html
+/* There are 6 known shift-reduce conflicts in this file, fail compilation if any
+ more are introduced.
+
+ Please don't increase the number of the conflicts if at all possible. And if
+ you really have no choice but to do it, make sure you clearly document each
+ new conflict in this file.
+ */
%expect 6
-*/
%{
#define yylex yylex
@@ -142,7 +145,7 @@ static Node *copy_node(Node *n) {
Setattr(nn, key, k.item);
continue;
}
- /* defaultargs will be patched back in later */
+ /* defaultargs will be patched back in later in update_defaultargs() */
if (strcmp(ckey,"defaultargs") == 0) {
Setattr(nn, "needs_defaultargs", "1");
continue;
@@ -657,19 +660,26 @@ static void add_symbols_copy(Node *n) {
}
}
+/* Add in the "defaultargs" attribute for functions in instantiated templates.
+ * n should be any instantiated template (class or start of linked list of functions). */
static void update_defaultargs(Node *n) {
if (n) {
Node *firstdefaultargs = n;
update_defaultargs(firstChild(n));
n = nextSibling(n);
+ /* recursively loop through nodes of all types, but all we really need are the overloaded functions */
while (n) {
update_defaultargs(firstChild(n));
- assert(!Getattr(n, "defaultargs"));
- if (Getattr(n, "needs_defaultargs")) {
- Setattr(n, "defaultargs", firstdefaultargs);
- Delattr(n, "needs_defaultargs");
+ if (!Getattr(n, "defaultargs")) {
+ if (Getattr(n, "needs_defaultargs")) {
+ Setattr(n, "defaultargs", firstdefaultargs);
+ Delattr(n, "needs_defaultargs");
+ } else {
+ firstdefaultargs = n;
+ }
} else {
- firstdefaultargs = n;
+ /* Functions added in with %extend (for specialized template classes) will already have default args patched up */
+ assert(Getattr(n, "defaultargs") == firstdefaultargs);
}
n = nextSibling(n);
}
@@ -2753,7 +2763,11 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
Swig_symbol_setscope(csyms);
}
- /* Merge in %extend methods for this class */
+ /* Merge in %extend methods for this class.
+ This only merges methods within %extend for a template specialized class such as
+ template<typename T> class K {}; %extend K<int> { ... }
+ The copy_node() call above has already added in the generic %extend methods such as
+ template<typename T> class K {}; %extend K { ... } */
/* !!! This may be broken. We may have to add the
%extend methods at the beginning of the class */
@@ -2885,16 +2899,15 @@ c_declaration : c_decl {
SWIG_WARN_NODE_END($$);
}
| USING idcolon EQUAL type plain_declarator SEMI {
- $$ = new_node("using");
- Setattr($$,"name",$2);
+ /* Convert using statement to a typedef statement */
+ $$ = new_node("cdecl");
SwigType_push($4,$5.type);
- Setattr($$,"uname",$4);
+ Setattr($$,"type",$4);
+ Setattr($$,"storage","typedef");
+ Setattr($$,"name",$2);
+ Setattr($$,"decl","");
+ SetFlag($$,"typealias");
add_symbols($$);
- SWIG_WARN_NODE_BEGIN($$);
- Swig_warning(WARN_CPP11_ALIAS_DECLARATION, cparse_file, cparse_line, "The 'using' keyword in type aliasing is not fully supported yet.\n");
- SWIG_WARN_NODE_END($$);
-
- $$ = 0; /* TODO - ignored for now */
}
| TEMPLATE LESSTHAN template_parms GREATERTHAN USING idcolon EQUAL type plain_declarator SEMI {
$$ = new_node("using");
diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx
index 1585180bd..b69e1dd70 100644
--- a/Source/Modules/allegrocl.cxx
+++ b/Source/Modules/allegrocl.cxx
@@ -1893,11 +1893,12 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
} else {
- if (!Getattr(nodes[j].n, "overload:ignore"))
+ if (!Getattr(nodes[j].n, "overload:ignore")) {
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
"using %s instead.\n", Swig_name_decl(nodes[i].n));
+ }
}
}
nodes[j].error = 1;
@@ -1910,11 +1911,12 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
} else {
- if (!Getattr(nodes[j].n, "overload:ignore"))
+ if (!Getattr(nodes[j].n, "overload:ignore")) {
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
"using %s instead.\n", Swig_name_decl(nodes[i].n));
+ }
}
}
nodes[j].error = 1;
@@ -1932,11 +1934,12 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[i].n), Getline(nodes[i].n),
"as it is shadowed by %s.\n", Swig_name_decl(nodes[i].n));
} else {
- if (!Getattr(nodes[j].n, "overload:ignore"))
+ if (!Getattr(nodes[j].n, "overload:ignore")) {
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
"using %s instead.\n", Swig_name_decl(nodes[i].n));
+ }
}
nodes[j].error = 1;
}
diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx
index 6013fa15b..7fa9b2670 100644
--- a/Source/Modules/go.cxx
+++ b/Source/Modules/go.cxx
@@ -4176,7 +4176,6 @@ private:
Wrapper *dummy = NewWrapper();
emit_attach_parmmaps(parms, dummy);
- DelWrapper(dummy);
Swig_typemap_attach_parms("gotype", parms, NULL);
Swig_typemap_attach_parms("imtype", parms, NULL);
@@ -4233,6 +4232,8 @@ private:
Swig_typemap_attach_parms("goin", parms, dummy);
Swig_typemap_attach_parms("goargout", parms, dummy);
+ DelWrapper(dummy);
+
if (!is_ignored) {
// We use an interface to see if this method is defined in Go.
Printv(f_go_wrappers, "type ", interface_name, " interface {\n", NULL);
diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx
index 1b4c8f617..80ea47f3f 100644
--- a/Source/Modules/lua.cxx
+++ b/Source/Modules/lua.cxx
@@ -856,6 +856,9 @@ public:
//Printf(stdout,"Swig_overload_dispatch %s %s '%s' %d\n",symname,wname,dispatch,maxargs);
if (!luaAddSymbol(lua_name, n)) {
+ DelWrapper(f);
+ Delete(dispatch);
+ Delete(tmp);
return SWIG_ERROR;
}
diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx
index 37cfeee64..b977609a8 100644
--- a/Source/Modules/octave.cxx
+++ b/Source/Modules/octave.cxx
@@ -469,7 +469,6 @@ public:
value = Getattr(p, "tmap:doc:value");
}
- // Note: the generated name should be consistent with that in kwnames[]
name = name ? name : Getattr(p, "name");
name = name ? name : Getattr(p, "lname");
name = Swig_name_make(p, 0, name, 0, 0); // rename parameter if a keyword
diff --git a/Source/Modules/overload.cxx b/Source/Modules/overload.cxx
index dd3ca4972..330294efd 100644
--- a/Source/Modules/overload.cxx
+++ b/Source/Modules/overload.cxx
@@ -433,6 +433,7 @@ String *Swig_overload_dispatch_cast(Node *n, const_String_or_char_ptr fmt, int *
int fn = 0;
Node *ni = Getitem(dispatch, i);
Parm *pi = Getattr(ni, "wrap:parms");
+ bool implicitconvtypecheckoff = GetFlag(ni, "implicitconvtypecheckoff") != 0;
int num_required = emit_num_required(pi);
int num_arguments = emit_num_arguments(pi);
if (num_arguments > *maxargs)
@@ -476,6 +477,7 @@ String *Swig_overload_dispatch_cast(Node *n, const_String_or_char_ptr fmt, int *
String *tm = Getattr(pj, "tmap:typecheck");
if (tm) {
+ tm = Copy(tm);
/* normalise for comparison later */
Replaceid(tm, Getattr(pj, "lname"), "_v");
@@ -528,13 +530,14 @@ String *Swig_overload_dispatch_cast(Node *n, const_String_or_char_ptr fmt, int *
String *tmp = NewStringf(argv_template_string, j);
String *conv = Getattr(pj, "implicitconv");
- if (conv) {
+ if (conv && !implicitconvtypecheckoff) {
Replaceall(tm, "$implicitconv", conv);
} else {
Replaceall(tm, "$implicitconv", "0");
}
Replaceall(tm, "$input", tmp);
Printv(f, "{\n", tm, "}\n", NIL);
+ Delete(tm);
fn = i + 1;
Printf(f, "if (!_v) goto check_%d;\n", fn);
Printf(f, "_ranki += _v*_pi;\n");
@@ -574,6 +577,9 @@ String *Swig_overload_dispatch_cast(Node *n, const_String_or_char_ptr fmt, int *
if (fn)
Printf(f, "check_%d:\n\n", fn);
+ if (implicitconvtypecheckoff)
+ Delattr(ni, "implicitconvtypecheckoff");
+
Delete(lfmt);
Delete(coll);
}
@@ -607,6 +613,7 @@ String *Swig_overload_dispatch_fast(Node *n, const_String_or_char_ptr fmt, int *
int fn = 0;
Node *ni = Getitem(dispatch, i);
Parm *pi = Getattr(ni, "wrap:parms");
+ bool implicitconvtypecheckoff = GetFlag(ni, "implicitconvtypecheckoff") != 0;
int num_required = emit_num_required(pi);
int num_arguments = emit_num_arguments(pi);
if (num_arguments > *maxargs)
@@ -646,6 +653,7 @@ String *Swig_overload_dispatch_fast(Node *n, const_String_or_char_ptr fmt, int *
String *tm = Getattr(pj, "tmap:typecheck");
if (tm) {
+ tm = Copy(tm);
/* normalise for comparison later */
Replaceid(tm, Getattr(pj, "lname"), "_v");
@@ -699,13 +707,14 @@ String *Swig_overload_dispatch_fast(Node *n, const_String_or_char_ptr fmt, int *
String *tmp = NewStringf(argv_template_string, j);
String *conv = Getattr(pj, "implicitconv");
- if (conv) {
+ if (conv && !implicitconvtypecheckoff) {
Replaceall(tm, "$implicitconv", conv);
} else {
Replaceall(tm, "$implicitconv", "0");
}
Replaceall(tm, "$input", tmp);
Printv(f, "{\n", tm, "}\n", NIL);
+ Delete(tm);
fn = i + 1;
Printf(f, "if (!_v) goto check_%d;\n", fn);
}
@@ -737,6 +746,9 @@ String *Swig_overload_dispatch_fast(Node *n, const_String_or_char_ptr fmt, int *
if (fn)
Printf(f, "check_%d:\n\n", fn);
+ if (implicitconvtypecheckoff)
+ Delattr(ni, "implicitconvtypecheckoff");
+
Delete(lfmt);
Delete(coll);
}
diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx
index 9182ce46b..406568b16 100644
--- a/Source/Modules/perl5.cxx
+++ b/Source/Modules/perl5.cxx
@@ -2130,6 +2130,8 @@ public:
String *cres = SwigType_lstr(returntype, "c_result");
Printf(w->code, "%s;\n", cres);
Delete(cres);
+ }
+ if (!ignored_method) {
String *pres = NewStringf("SV *%s", Swig_cresult_name());
Wrapper_add_local(w, Swig_cresult_name(), pres);
Delete(pres);
diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
index 82722304e..b42cf022f 100644
--- a/Source/Modules/python.cxx
+++ b/Source/Modules/python.cxx
@@ -517,6 +517,7 @@ public:
fputs(usage3, stdout);
} else if (strcmp(argv[i], "-py3") == 0) {
py3 = 1;
+ Preprocessor_define("SWIGPYTHON_PY3", 0);
Swig_mark_arg(i);
} else if (strcmp(argv[i], "-builtin") == 0) {
builtin = 1;
@@ -809,10 +810,10 @@ public:
mod_docstring = NULL;
}
- Printv(f_shadow, "\nfrom sys import version_info\n", NULL);
+ Printv(f_shadow, "\nfrom sys import version_info as _swig_python_version_info\n", NULL);
if (!builtin && fastproxy) {
- Printv(f_shadow, "if version_info >= (3, 0, 0):\n", NULL);
+ Printv(f_shadow, "if _swig_python_version_info >= (3, 0, 0):\n", NULL);
Printf(f_shadow, tab4 "new_instancemethod = lambda func, inst, cls: %s.SWIG_PyInstanceMethod_New(func)\n", module);
Printv(f_shadow, "else:\n", NULL);
Printv(f_shadow, tab4, "from new import instancemethod as new_instancemethod\n", NULL);
@@ -826,8 +827,30 @@ public:
* in 2.6, and fail in 2.7 onwards), but the relative import syntax
* isn't available in python 2.4 or earlier, so we have to write some
* code conditional on the python version.
+ *
+ * For python 2.7.0 and newer, first determine the shadow wrappers package
+ * based on the __name__ it was given by the importer that loaded it.
+ * Then construct a name for the module based on the package name and the
+ * module name (we know the module name). Use importlib to try and load
+ * it. If an attempt to load the module with importlib fails with an
+ * ImportError then fallback and try and load just the module name from
+ * the global namespace.
*/
- Printv(f_shadow, "if version_info >= (2, 6, 0):\n", NULL);
+ Printv(f_shadow, "if _swig_python_version_info >= (2, 7, 0):\n", NULL);
+ Printv(f_shadow, tab4, "def swig_import_helper():\n", NULL);
+ Printv(f_shadow, tab8, "import importlib\n", NULL);
+ Printv(f_shadow, tab8, "pkg = __name__.rpartition('.')[0]\n", NULL);
+ Printf(f_shadow, tab8 "mname = '.'.join((pkg, '%s')).lstrip('.')\n",
+ module);
+ Printv(f_shadow, tab8, "try:\n", NULL);
+ Printv(f_shadow, tab8, tab4, "return importlib.import_module(mname)\n",
+ NULL);
+ Printv(f_shadow, tab8, "except ImportError:\n", NULL);
+ Printf(f_shadow, tab8 tab4 "return importlib.import_module('%s')\n",
+ module);
+ Printf(f_shadow, tab4 "%s = swig_import_helper()\n", module);
+ Printv(f_shadow, tab4, "del swig_import_helper\n", NULL);
+ Printv(f_shadow, "elif _swig_python_version_info >= (2, 6, 0):\n", NULL);
Printv(f_shadow, tab4, "def swig_import_helper():\n", NULL);
Printv(f_shadow, tab8, "from os.path import dirname\n", NULL);
Printv(f_shadow, tab8, "import imp\n", NULL);
@@ -849,13 +872,36 @@ public:
Printv(f_shadow, "else:\n", NULL);
Printf(f_shadow, tab4 "import %s\n", module);
- /* Delete the version_info symbol since we don't use it elsewhere in the
+ if (builtin) {
+ /*
+ * Pull in all the attributes from the C module.
+ *
+ * An alternative approach to doing this if/else chain was
+ * proposed by Michael Thon. Someone braver than I may try it out.
+ * I fear some current swig user may depend on some side effect
+ * of from _foo import *
+ *
+ * for attr in _foo.__all__:
+ * globals()[attr] = getattr(_foo, attr)
+ *
+ */
+ Printf(f_shadow, "# pull in all the attributes from %s\n", module);
+ Printv(f_shadow, "if __name__.rpartition('.')[0] != '':\n", NULL);
+ Printv(f_shadow, tab4, "if _swig_python_version_info >= (2, 7, 0):\n", NULL);
+ Printv(f_shadow, tab8, "try:\n", NULL);
+ Printf(f_shadow, tab8 tab4 "from .%s import *\n", module);
+ Printv(f_shadow, tab8 "except ImportError:\n", NULL);
+ Printf(f_shadow, tab8 tab4 "from %s import *\n", module);
+ Printv(f_shadow, tab4, "else:\n", NULL);
+ Printf(f_shadow, tab8 "from %s import *\n", module);
+ Printv(f_shadow, "else:\n", NULL);
+ Printf(f_shadow, tab4 "from %s import *\n", module);
+ }
+
+ /* Delete the _swig_python_version_info symbol since we don't use it elsewhere in the
* module. */
- Printv(f_shadow, "del version_info\n", NULL);
+ Printv(f_shadow, "del _swig_python_version_info\n", NULL);
- if (builtin) {
- Printf(f_shadow, "from %s import *\n", module);
- }
if (modern || !classic) {
Printv(f_shadow, "try:\n", tab4, "_swig_property = property\n", "except NameError:\n", tab4, "pass # Python < 2.2 doesn't have 'property'.\n\n", NULL);
}
@@ -1205,13 +1251,14 @@ public:
Printf(out, "import %s%s%s%s\n", apkg, *Char(apkg) ? "." : "", pfx, mod);
Delete(apkg);
} else {
- if (py3) {
- if (py3_rlen1)
- Printf(out, "from . import %.*s\n", py3_rlen1, rpkg);
- Printf(out, "from .%s import %s%s\n", rpkg, pfx, mod);
- } else {
- Printf(out, "import %s%s%s%s\n", rpkg, *Char(rpkg) ? "." : "", pfx, mod);
- }
+ Printf(out, "from sys import version_info as _swig_python_version_info\n");
+ Printf(out, "if _swig_python_version_info >= (2, 7, 0):\n");
+ if (py3_rlen1)
+ Printf(out, tab4 "from . import %.*s\n", py3_rlen1, rpkg);
+ Printf(out, tab4 "from .%s import %s%s\n", rpkg, pfx, mod);
+ Printf(out, "else:\n");
+ Printf(out, tab4 "import %s%s%s%s\n", rpkg, *Char(rpkg) ? "." : "", pfx, mod);
+ Printf(out, "del _swig_python_version_info\n");
Delete(rpkg);
}
return out;
@@ -3463,7 +3510,7 @@ public:
* type but the return-type of function. */
if(!SwigType_isfunction(uqtype) && !SwigType_isfunctionpointer(uqtype)) {
SwigType *basetype = SwigType_base(uqtype);
- result = (bool)SwigType_isclass(basetype);
+ result = SwigType_isclass(basetype) != 0;
Delete(basetype);
}
@@ -4153,9 +4200,9 @@ public:
printSlot(f, getSlot(n, "feature:python:nb_inplace_xor"), "nb_inplace_xor", "binaryfunc");
printSlot(f, getSlot(n, "feature:python:nb_inplace_or"), "nb_inplace_or", "binaryfunc");
printSlot(f, getSlot(n, "feature:python:nb_floor_divide"), "nb_floor_divide", "binaryfunc");
- printSlot(f, getSlot(n, "feature:python:nb_true_divide"), "nb_true_divide", "binaryfunc");
+ printSlot(f, getSlot(n, "feature:python:nb_divide"), "nb_true_divide", "binaryfunc");
printSlot(f, getSlot(n, "feature:python:nb_inplace_floor_divide"), "nb_inplace_floor_divide", "binaryfunc");
- printSlot(f, getSlot(n, "feature:python:nb_inplace_true_divide"), "nb_inplace_true_divide", "binaryfunc");
+ printSlot(f, getSlot(n, "feature:python:nb_inplace_divide"), "nb_inplace_true_divide", "binaryfunc");
Printv(f, "#if PY_VERSION_HEX >= 0x02050000\n", NIL);
printSlot(f, getSlot(n, "feature:python:nb_index"), "nb_index", "unaryfunc");
Printv(f, "#endif\n", NIL);
diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx
index a5aec50eb..301b49f9e 100644
--- a/Source/Modules/r.cxx
+++ b/Source/Modules/r.cxx
@@ -1482,11 +1482,12 @@ List * R::Swig_overload_rank(Node *n,
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
} else {
- if (!Getattr(nodes[j].n, "overload:ignore"))
+ if (!Getattr(nodes[j].n, "overload:ignore")) {
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
"using %s instead.\n", Swig_name_decl(nodes[i].n));
+ }
}
}
nodes[j].error = 1;
@@ -1499,11 +1500,12 @@ List * R::Swig_overload_rank(Node *n,
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
} else {
- if (!Getattr(nodes[j].n, "overload:ignore"))
+ if (!Getattr(nodes[j].n, "overload:ignore")) {
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
"using %s instead.\n", Swig_name_decl(nodes[i].n));
+ }
}
}
nodes[j].error = 1;
@@ -1521,11 +1523,12 @@ List * R::Swig_overload_rank(Node *n,
Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[i].n), Getline(nodes[i].n),
"as it is shadowed by %s.\n", Swig_name_decl(nodes[i].n));
} else {
- if (!Getattr(nodes[j].n, "overload:ignore"))
+ if (!Getattr(nodes[j].n, "overload:ignore")) {
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
"using %s instead.\n", Swig_name_decl(nodes[i].n));
+ }
}
nodes[j].error = 1;
}
diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx
index ddf47c1b0..2a3128472 100644
--- a/Source/Modules/ruby.cxx
+++ b/Source/Modules/ruby.cxx
@@ -1011,6 +1011,8 @@ public:
virtual int top(Node *n) {
+ String *mod_docstring = NULL;
+
/**
* See if any Ruby module options have been specified as options
* to the %module directive.
@@ -1032,6 +1034,7 @@ public:
multipleInheritance = true;
director_multiple_inheritance = 1;
}
+ mod_docstring = Getattr(options, "docstring");
}
}
@@ -1146,6 +1149,15 @@ public:
Printf(f_header, "#define SWIG_init Init_%s\n", feature);
Printf(f_header, "#define SWIG_name \"%s\"\n\n", module);
+
+ if (mod_docstring) {
+ if (Len(mod_docstring)) {
+ Printf(f_header, "/*\n Document-module: %s\n\n%s\n*/\n", module, mod_docstring);
+ }
+ Delete(mod_docstring);
+ mod_docstring = NULL;
+ }
+
Printf(f_header, "static VALUE %s;\n", modvar);
/* Start generating the initialization function */
@@ -1534,7 +1546,8 @@ public:
/* Finish argument marshalling */
Printf(kwargs, " NULL }");
if (allow_kwargs) {
- Printv(f->locals, tab4, "const char *kwnames[] = ", kwargs, ";\n", NIL);
+// kwarg support not implemented
+// Printv(f->locals, tab4, "const char *kwnames[] = ", kwargs, ";\n", NIL);
}
/* Trailing varargs */
@@ -2110,13 +2123,11 @@ public:
// Generate prototype list, go to first node
Node *sibl = n;
- String* type = SwigType_str(Getattr(sibl,"type"),NULL);
-
while (Getattr(sibl, "sym:previousSibling"))
sibl = Getattr(sibl, "sym:previousSibling"); // go all the way up
// Constructors will be treated specially
- const bool isCtor = Cmp(Getattr(sibl,"feature:new"), "1") == 0;
+ const bool isCtor = (!Cmp(Getattr(sibl, "nodeType"), "constructor"));
const bool isMethod = ( Cmp(Getattr(sibl, "ismember"), "1") == 0 &&
(!isCtor) );
@@ -2138,7 +2149,11 @@ public:
String *protoTypes = NewString("");
do {
Append( protoTypes, "\n\" ");
- if ( !isCtor ) Printv( protoTypes, type, " ", NIL );
+ if (!isCtor) {
+ SwigType *type = SwigType_str(Getattr(sibl, "type"), NULL);
+ Printv(protoTypes, type, " ", NIL);
+ Delete(type);
+ }
Printv(protoTypes, methodName, NIL );
Parm* p = Getattr(sibl, "wrap:parms");
if (p && (current == MEMBER_FUNC || current == MEMBER_VAR ||
@@ -2159,7 +2174,6 @@ public:
Append(f->code, "\nreturn Qnil;\n");
Delete(methodName);
- Delete(type);
Delete(protoTypes);
Printv(f->code, "}\n", NIL);
@@ -3460,6 +3474,7 @@ public:
*--------------------------------------------------------------------*/
bool kwargsSupport() const {
+ // kwargs support isn't actually implemented, but changing to return false may break something now as it turns on compactdefaultargs
return true;
}
}; /* class RUBY */
diff --git a/Source/Modules/scilab.cxx b/Source/Modules/scilab.cxx
index 42df12f7c..137adc234 100644
--- a/Source/Modules/scilab.cxx
+++ b/Source/Modules/scilab.cxx
@@ -326,6 +326,7 @@ public:
bool isLastOverloaded = isOverloaded && !Getattr(node, "sym:nextSibling");
if (!isOverloaded && !addSymbol(functionName, node)) {
+ DelWrapper(wrapper);
return SWIG_ERROR;
}
@@ -633,7 +634,10 @@ public:
/* Add function to builder table */
addFunctionToScilab(scilabSetFunctionName, setFunctionName);
+
+ DelWrapper(setFunctionWrapper);
}
+ DelWrapper(getFunctionWrapper);
return SWIG_OK;
}
diff --git a/Source/Modules/typepass.cxx b/Source/Modules/typepass.cxx
index da077fd07..dc4d02bdd 100644
--- a/Source/Modules/typepass.cxx
+++ b/Source/Modules/typepass.cxx
@@ -224,7 +224,7 @@ class TypePass:private Dispatcher {
if (tname)
Delete(tname);
if (!bcls) {
- if (!clsforward) {
+ if (!clsforward && !GetFlag(cls, "feature:ignore")) {
if (ispublic && !Getmeta(bname, "already_warned")) {
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Nothing known about base class '%s'. Ignored.\n", SwigType_namestr(bname));
if (Strchr(bname, '<')) {
@@ -265,7 +265,13 @@ class TypePass:private Dispatcher {
SwigType *bsmart = Copy(smart);
SwigType *rclsname = SwigType_typedef_resolve_all(clsname);
SwigType *rbname = SwigType_typedef_resolve_all(bname);
- Replaceall(bsmart, rclsname, rbname);
+ int replace_count = Replaceall(bsmart, rclsname, rbname);
+ if (replace_count == 0) {
+ // If no replacement made, it will be because rclsname is fully resolved, but the
+ // type in the smartptr feature used a typedef or not fully resolved name.
+ String *firstname = Getattr(first, "name");
+ Replaceall(bsmart, firstname, rbname);
+ }
Delete(rclsname);
Delete(rbname);
String *smartnamestr = SwigType_namestr(smart);
diff --git a/Source/Swig/include.c b/Source/Swig/include.c
index 08226a25c..94df338f0 100644
--- a/Source/Swig/include.c
+++ b/Source/Swig/include.c
@@ -291,6 +291,7 @@ int Swig_insert_file(const_String_or_char_ptr filename, File *outfile) {
while ((nbytes = Read(f, buffer, 4096)) > 0) {
Write(outfile, buffer, nbytes);
}
+ fclose(f);
return 0;
}
diff --git a/Tools/mkwindows.sh b/Tools/mkwindows.sh
index f3a20409a..0651bbd60 100755
--- a/Tools/mkwindows.sh
+++ b/Tools/mkwindows.sh
@@ -11,8 +11,7 @@ zip=
# options for configure
extraconfigureoptions=
-compileflags="-O2"
-extracompileflags=
+compileflags="-O2 -Wall -Wextra"
if test x$1 != x; then
version=$1
@@ -43,17 +42,28 @@ else
if test x$zip = x; then
zip=zip
fi
- extraconfigureoptions="--host=i586-mingw32msvc --build=i686-linux"
- echo "Checking that mingw gcc is installed/available"
- i586-mingw32msvc-gcc --version || exit 1
- i586-mingw32msvc-g++ --version || exit 1
+ echo "Checking that mingw 32-bit gcc is installed/available"
+ if test -n "`which i686-w64-mingw32-gcc`" ; then
+ i686-w64-mingw32-gcc --version || exit 1
+ i686-w64-mingw32-g++ --version || exit 1
+ extraconfigureoptions="--host=i686-w64-mingw32 --build=i686-linux"
+ # Statically link so that libstdc++-6.dll and libgcc_s_sjlj-1.dll don't have to be shipped
+ compileflags="$compileflags -static-libgcc -static-libstdc++"
+ elif test -n "`which i586-mingw32msvc-gcc`" ; then
+ i586-mingw32msvc-gcc --version || exit 1
+ i586-mingw32msvc-g++ --version || exit 1
+ extraconfigureoptions="--host=i586-mingw32msvc --build=i686-linux"
+ else
+ echo "Could not detect mingw gcc - please install mingw-w64 package."
+ exit 1;
+ fi
else
if test "$cygwin"; then
echo "Building native Windows executable on Cygwin"
if test x$zip = x; then
zip=zip
fi
- compileflags="-O2 -mno-cygwin"
+ compileflags="$compileflags -mno-cygwin"
else
echo "Unknown platform. Requires either Linux or MinGW."
exit 1;
@@ -61,6 +71,9 @@ else
fi
fi
+export CFLAGS="$compileflags"
+export CXXFLAGS="$compileflags"
+
swigbasename=swig-$version
swigwinbasename=swigwin-$version
tarball=$swigbasename.tar.gz
@@ -89,10 +102,10 @@ if test -f "$tarball"; then
tar -zxf ../$tarball
cd $swigbasename
(cd ../.. && cp $pcre_tarball $builddir/$swigbasename)
- echo Running: Tools/pcre-build.sh $extraconfigureoptions CFLAGS="$compileflags" CXXFLAGS="$compileflags"
- ./Tools/pcre-build.sh $extraconfigureoptions CFLAGS="$compileflags" CXXFLAGS="$compileflags" || exit 1
- echo Running: ./configure $extraconfigureoptions CFLAGS="$compileflags" CXXFLAGS="$compileflags"
- ./configure $extraconfigureoptions CFLAGS="$compileflags" CXXFLAGS="$compileflags" || exit 1
+ echo Running: Tools/pcre-build.sh $extraconfigureoptions
+ ./Tools/pcre-build.sh $extraconfigureoptions
+ echo Running: ./configure $extraconfigureoptions --without-alllang
+ ./configure $extraconfigureoptions --without-alllang
echo "Compiling (quietly)..."
make > build.log
echo "Simple check to see if swig.exe runs..."
diff --git a/Tools/testflags.py b/Tools/testflags.py
index 53472fd24..981e8d59a 100755
--- a/Tools/testflags.py
+++ b/Tools/testflags.py
@@ -7,7 +7,7 @@ def get_cflags(language, std, compiler):
cflags = {
"csharp":"-Werror " + c_common,
"d":"-Werror " + c_common,
- "go":"-Werror " + c_common,
+ "go":"-Werror " + c_common + " -Wno-declaration-after-statement",
"guile":"-Werror " + c_common,
"java":"-Werror " + c_common,
"javascript":"-Werror " + c_common,
diff --git a/Tools/travis-linux-install.sh b/Tools/travis-linux-install.sh
index 9e2ecadeb..50ac5cd09 100755
--- a/Tools/travis-linux-install.sh
+++ b/Tools/travis-linux-install.sh
@@ -7,13 +7,16 @@ sudo apt-get -qq update
if [[ "$CC" == gcc-5 ]]; then
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- sudo add-apt-repository -y ppa:boost-latest/ppa
sudo apt-get -qq update
- sudo apt-get install -qq g++-5 libboost1.55-dev
-else
- sudo apt-get -qq install libboost-dev
+ sudo apt-get install -qq g++-5
+elif [[ "$CC" == gcc-6 ]]; then
+ sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
+ sudo apt-get -qq update
+ sudo apt-get install -qq g++-6
fi
+sudo apt-get -qq install libboost-dev
+
WITHLANG=$SWIGLANG
case "$SWIGLANG" in
@@ -26,10 +29,6 @@ case "$SWIGLANG" in
sudo dpkg -i dmd_2.066.0-0_amd64.deb
;;
"go")
- # Until configure.ac is fixed
- go env | sed -e 's/^/export /' > goenvsetup
- source goenvsetup
- rm -f goenvsetup
;;
"javascript")
case "$ENGINE" in
@@ -51,7 +50,13 @@ case "$SWIGLANG" in
sudo apt-get -qq install guile-2.0-dev
;;
"lua")
- sudo apt-get -qq install lua5.1 liblua5.1-dev
+ if [[ -z "$VER" ]]; then
+ sudo apt-get -qq install lua5.1 liblua5.1-dev
+ else
+ sudo add-apt-repository -y ppa:ubuntu-cloud-archive/mitaka-staging
+ sudo apt-get -qq update
+ sudo apt-get -qq install lua${VER} liblua${VER}-dev
+ fi
;;
"ocaml")
# configure also looks for ocamldlgen, but this isn't packaged. But it isn't used by default so this doesn't matter.
diff --git a/configure.ac b/configure.ac
index 3688b111f..492d9cc1c 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.9],[http://www.swig.org])
+AC_INIT([swig],[3.0.11],[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
@@ -1377,6 +1377,8 @@ if test -n "$JAVAC"; then
JAVAC=\"$JAVAC\"
fi
+# Turned off due to spurious warnings in later versions of openjdk-1.8
+# JAVAFLAGS=-Xcheck:jni
AC_SUBST(JAVA)
AC_SUBST(JAVAC)
@@ -1386,6 +1388,7 @@ AC_SUBST(JAVALIBRARYPREFIX)
AC_SUBST(JAVASO)
AC_SUBST(JAVALDSHARED)
AC_SUBST(JAVACXXSHARED)
+AC_SUBST(JAVAFLAGS)
AC_SUBST(JAVACFLAGS)
#----------------------------------------------------------------
@@ -1931,8 +1934,10 @@ else
AC_MSG_RESULT(not found)
fi
;;
+ "")
+ AC_MSG_RESULT([could not find $PHPCONFIG or obtain PHP version from it]) ;;
*)
- AC_MSG_RESULT([found PHP $version, but only PHP 5 is supported]) ;;
+ AC_MSG_RESULT([found PHP $php_version, but only PHP 5 is supported]) ;;
esac
fi
AC_SUBST(PHP)
@@ -2299,7 +2304,7 @@ if test "x$LUABIN" = xyes; then
# The search order should match the include-file and library search
# orders below (a Lua shared library built for one version may not
# work with a Lua binary of a different version).
- AC_PATH_PROGS(LUABIN, [lua5.2 lua5.1 lua])
+ AC_PATH_PROGS(LUABIN, [lua5.4 lua5.3 lua5.2 lua5.1 lua])
fi
# check version: we need Lua 5.x
@@ -2342,7 +2347,10 @@ if test "$LUABIN"; then
AC_CHECK_FILE($LUAINCLUDE/lua.h,[LUAFLAGS="$ISYSTEM$LUAINCLUDE"],[LUABIN=])
else
LUA_OK="1"
- AC_CHECK_HEADER(lua.h,[LUAFLAGS=""],[LUA_OK=""])
+ CFLAGS_SAVED=$CFLAGS
+ CFLAGS= # Use empty CFLAGS to avoid failure: "present but cannot be compiled"
+ AC_CHECK_HEADER([lua.h],[LUAFLAGS=""],[LUA_OK=""])
+ CFLAGS=$CFLAGS_SAVED
# if we didn't get it, going to have to look elsewhere (the hard way)
if test -z "$LUA_OK"; then
AC_MSG_CHECKING(for lua.h in other locations)
@@ -2350,7 +2358,7 @@ if test "$LUABIN"; then
# The ordering of the include directories to search should match
# the ordering of libraries to search in the library test below.
inc=/usr/include
- dirs="$inc/lua5.2 $inc/lua5.1 $inc/lua51 $inc/lua5.0 $inc/lua50 /usr/local/include"
+ dirs="$inc/lua5.4 $inc/lua5.3 $inc/lua5.2 $inc/lua5.1 $inc/lua51 $inc/lua5.0 $inc/lua50 /usr/local/include"
for i in $dirs; do
#echo "$i"
if test -r $i/lua.h; then
@@ -2373,7 +2381,7 @@ if test "$LUABIN"; then
if test -n "$LUALIB"; then
AC_CHECK_FILE($LUALIB/liblua.a,[LUALINK="-L$LUALIB -llua"],[LUABIN=])
else
- AC_SEARCH_LIBS(lua_close, [lua lua5.2 lua5.1 lua51 lua5.0 lua50], [LUALINK="-l$ac_lib"],[LUABIN=])
+ AC_SEARCH_LIBS(lua_close, [lua lua5.4 lua5.3 lua5.2 lua5.1 lua51 lua5.0 lua50], [LUALINK="-l$ac_lib"],[LUABIN=])
fi
# adding lualib for lua 5.0
@@ -2512,8 +2520,8 @@ else
esac
AC_MSG_CHECKING([whether go version is too old])
case $go_version in
- go1.0* | go1 )
- AC_MSG_RESULT([yes - minimum version is 1.1])
+ go1.1* | go1.0* | go1 )
+ AC_MSG_RESULT([yes - minimum version is 1.2])
GO=
GOOPT="-intgosize 32"
;;
diff --git a/preinst-swig.in b/preinst-swig.in
index ac00602bb..ac00602bb 100755..100644
--- a/preinst-swig.in
+++ b/preinst-swig.in