summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Andersson <j.a.e.andersson@gmail.com>2016-07-02 19:05:42 -0500
committerJoel Andersson <j.a.e.andersson@gmail.com>2016-07-02 19:05:42 -0500
commit3703053cbe25655e3e20d7ddc0f621c3e7c6d47d (patch)
treed0b57df47e258ff9ff3d976c20630af91c3d4010
parentb5e75d1891a64000508b511e220483b0547f5428 (diff)
parent36bbeb478dfcecc7739284cd454ada8b4cb96333 (diff)
downloadswig-3703053cbe25655e3e20d7ddc0f621c3e7c6d47d.tar.gz
Merge branch 'master' of https://github.com/swig/swig into matlab
-rw-r--r--.gitignore1
-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.current93
-rw-r--r--Doc/Manual/CPlusPlus11.html49
-rw-r--r--Doc/Manual/CSharp.html4
-rw-r--r--Doc/Manual/Contents.html15
-rw-r--r--Doc/Manual/Go.html2
-rw-r--r--Doc/Manual/Java.html332
-rw-r--r--Doc/Manual/Javascript.html2
-rw-r--r--Doc/Manual/Makefile1
-rw-r--r--Doc/Manual/Preface.html7
-rw-r--r--Doc/Manual/Python.html384
-rw-r--r--Doc/Manual/SWIG.html7
-rw-r--r--Doc/Manual/Scilab.html157
-rw-r--r--Doc/Manual/Sections.html2
-rw-r--r--Doc/Manual/Typemaps.html14
-rw-r--r--Doc/Manual/Warnings.html6
-rw-r--r--Examples/Makefile.in26
-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/apply_strings.i4
-rw-r--r--Examples/test-suite/char_constant.i30
-rw-r--r--Examples/test-suite/chartest.i69
-rw-r--r--Examples/test-suite/common.mk27
-rw-r--r--Examples/test-suite/compactdefaultargs.i1
-rw-r--r--Examples/test-suite/constant_directive.i42
-rw-r--r--Examples/test-suite/cpp11_li_std_array.i2
-rw-r--r--Examples/test-suite/cpp11_strongly_typed_enumerations.i7
-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/csharp/multiple_inheritance_abstract_runme.cs245
-rw-r--r--Examples/test-suite/csharp/multiple_inheritance_interfaces_runme.cs87
-rw-r--r--Examples/test-suite/csharp/multiple_inheritance_nspace_runme.cs246
-rw-r--r--Examples/test-suite/csharp/multiple_inheritance_shared_ptr_runme.cs329
-rw-r--r--Examples/test-suite/default_args.i4
-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/enum_thorough.i103
-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/funcptr_cpp.i2
-rw-r--r--Examples/test-suite/go/go_inout_runme.go10
-rw-r--r--Examples/test-suite/go_inout.i48
-rw-r--r--Examples/test-suite/insert_directive.i2
-rw-r--r--Examples/test-suite/java/Makefile.in11
-rw-r--r--Examples/test-suite/java/constant_directive_runme.java4
-rw-r--r--Examples/test-suite/java/cpp11_li_std_array_runme.java82
-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/long_long_runme.java50
-rw-r--r--Examples/test-suite/java/multiple_inheritance_abstract_runme.java253
-rw-r--r--Examples/test-suite/java/multiple_inheritance_interfaces_runme.java78
-rw-r--r--Examples/test-suite/java/multiple_inheritance_nspace_runme.java255
-rw-r--r--Examples/test-suite/java/multiple_inheritance_shared_ptr_runme.java337
-rw-r--r--Examples/test-suite/java/smart_pointer_ignore_runme.java19
-rw-r--r--Examples/test-suite/javascript/Makefile.in6
-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/li_std_vector.i10
-rw-r--r--Examples/test-suite/long_long.i6
-rw-r--r--Examples/test-suite/lua/Makefile.in1
-rw-r--r--Examples/test-suite/lua/funcptr_cpp_runme.lua1
-rw-r--r--Examples/test-suite/lua/lua_inherit_getitem_runme.lua12
-rw-r--r--Examples/test-suite/lua_inherit_getitem.i19
-rw-r--r--Examples/test-suite/multiple_inheritance_abstract.i328
-rw-r--r--Examples/test-suite/multiple_inheritance_interfaces.i66
-rw-r--r--Examples/test-suite/multiple_inheritance_nspace.i338
-rw-r--r--Examples/test-suite/multiple_inheritance_shared_ptr.i499
-rw-r--r--Examples/test-suite/namespace_typemap.i6
-rw-r--r--Examples/test-suite/nested_extend_c.i4
-rw-r--r--Examples/test-suite/nested_ignore.i24
-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/primitive_types.i1
-rw-r--r--Examples/test-suite/python/Makefile.in4
-rw-r--r--Examples/test-suite/python/autodoc_runme.py8
-rw-r--r--Examples/test-suite/python/compactdefaultargs_runme.py3
-rw-r--r--Examples/test-suite/python/constant_directive_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/default_args_runme.py18
-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/funcptr_cpp_runme.py2
-rw-r--r--Examples/test-suite/python/li_attribute_runme.py10
-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/rename_rstrip_encoder_runme.py5
-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/r/li_std_vector_runme.R19
-rw-r--r--Examples/test-suite/r/unittest.R4
-rw-r--r--Examples/test-suite/rename_rstrip_encoder.i15
-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/scilab/funcptr_cpp_runme.sci1
-rw-r--r--Examples/test-suite/scilab/overload_polymorphic_runme.sci11
-rw-r--r--Examples/test-suite/scilab/overload_simple_runme.sci36
-rw-r--r--Examples/test-suite/scilab/overload_subtype_runme.sci13
-rw-r--r--Examples/test-suite/scilab/template_rename_runme.sci2
-rw-r--r--Examples/test-suite/smart_pointer_ignore.i33
-rw-r--r--Examples/test-suite/string_constants.i44
-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.i63
-rw-r--r--Lib/d/dswigtype.swg4
-rw-r--r--Lib/go/go.swg35
-rw-r--r--Lib/go/goruntime.swg4
-rw-r--r--Lib/go/std_string.i26
-rw-r--r--Lib/guile/std_map.i34
-rw-r--r--Lib/java/java.swg33
-rw-r--r--Lib/java/std_array.i42
-rw-r--r--Lib/java/swiginterface.i74
-rw-r--r--Lib/java/typemaps.i14
-rw-r--r--Lib/lua/luarun.swg55
-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/python/pytypemaps.swg4
-rw-r--r--Lib/r/r.swg4
-rw-r--r--Lib/r/rrun.swg4
-rw-r--r--Lib/r/std_vector.i561
-rw-r--r--Lib/ruby/rubyrun.swg12
-rw-r--r--Lib/scilab/scicontainer.swg17
-rw-r--r--Lib/scilab/scimatrixbool.swg24
-rw-r--r--Lib/scilab/scimatrixdouble.swg24
-rw-r--r--Lib/scilab/scimatrixint.swg24
-rw-r--r--Lib/scilab/scirun.swg154
-rw-r--r--Lib/scilab/scisequence.swg14
-rw-r--r--Lib/scilab/scitypemaps.swg11
-rw-r--r--Lib/scilab/std_basic_string.i1
-rw-r--r--Lib/swigrun.swg8
-rw-r--r--Lib/typemaps/swigtype.swg3
-rw-r--r--README12
-rw-r--r--RELEASENOTES11
-rw-r--r--Source/CParse/parser.y63
-rw-r--r--Source/Include/swigwarn.h2
-rw-r--r--Source/Makefile.am1
-rw-r--r--Source/Modules/allegrocl.cxx12
-rw-r--r--Source/Modules/allocate.cxx2
-rw-r--r--Source/Modules/cffi.cxx5
-rw-r--r--Source/Modules/clisp.cxx3
-rw-r--r--Source/Modules/csharp.cxx440
-rw-r--r--Source/Modules/d.cxx63
-rw-r--r--Source/Modules/go.cxx18
-rw-r--r--Source/Modules/interface.cxx183
-rw-r--r--Source/Modules/java.cxx447
-rw-r--r--Source/Modules/lang.cxx32
-rw-r--r--Source/Modules/lua.cxx6
-rw-r--r--Source/Modules/modula3.cxx30
-rw-r--r--Source/Modules/ocaml.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/php.cxx7
-rw-r--r--Source/Modules/python.cxx137
-rw-r--r--Source/Modules/r.cxx12
-rw-r--r--Source/Modules/ruby.cxx29
-rw-r--r--Source/Modules/scilab.cxx8
-rw-r--r--Source/Modules/swigmod.h12
-rw-r--r--Source/Modules/typepass.cxx10
-rw-r--r--Source/Swig/include.c1
-rw-r--r--Source/Swig/misc.c75
-rw-r--r--Source/Swig/naming.c260
-rw-r--r--Source/Swig/swig.h2
-rwxr-xr-xTools/mkwindows.sh35
-rwxr-xr-xTools/testflags.py4
-rwxr-xr-xTools/travis-linux-install.sh23
-rw-r--r--configure.ac24
-rw-r--r--[-rwxr-xr-x]preinst-swig.in0
227 files changed, 9094 insertions, 1624 deletions
diff --git a/.gitignore b/.gitignore
index bd8a87535..e4724d53d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -47,6 +47,7 @@ CCache/autom4te.cache/
CCache/config.h.in
CCache/configure
Source/Include/swigconfig.h.in
+Source/Include/swigconfig.h.in~
Source/Makefile.in
Tools/config/compile
Tools/config/config.guess
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 4c5ef680e..075c00ef6 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -2,71 +2,28 @@ 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-03-01: olly
- [Python] 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-26: wkalinin
+ [Java, C#] Patch #681 Fix seg fault when ignoring nested classes.
+
+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/CSharp.html b/Doc/Manual/CSharp.html
index 0cbc9ec24..26f0c740e 100644
--- a/Doc/Manual/CSharp.html
+++ b/Doc/Manual/CSharp.html
@@ -233,6 +233,7 @@ javabody -&gt; csbody
javafinalize -&gt; csfinalize
javadestruct -&gt; csdestruct
javadestruct_derived -&gt; csdestruct_derived
+javainterfacecode -&gt; csinterfacecode
</pre></div>
</li>
@@ -300,6 +301,9 @@ $*javaclassname -&gt; $*csclassname
$javaclazzname -&gt; $csclazzname
$javainput -&gt; $csinput
$jnicall -&gt; $imcall
+$javainterfacename -&gt; $csinterfacename
+$&amp;javainterfacename -&gt; $&amp;csinterfacename
+$*javainterfacename -&gt; $*csinterfacename
</pre></div>
</li>
diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html
index 55d16ee1a..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>
@@ -997,6 +997,7 @@
<li><a href="Java.html#Java_proper_enums_classes">Proper Java enum classes</a>
<li><a href="Java.html#Java_typeunsafe_enums_classes">Type unsafe enum classes</a>
</ul>
+<li><a href="Java.html#Java_interfaces">Interfaces</a>
</ul>
<li><a href="Java.html#Java_directors">Cross language polymorphism using directors</a>
<ul>
@@ -1593,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>
@@ -1792,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>
@@ -1807,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/Go.html b/Doc/Manual/Go.html
index ced046c66..f25e9850b 100644
--- a/Doc/Manual/Go.html
+++ b/Doc/Manual/Go.html
@@ -446,7 +446,7 @@ type MyClass interface {
MyMethod() int
}
-MyClassMyFactoryFunction() MyClass {
+func MyClassMyFactoryFunction() MyClass {
// swig magic here
}
</pre>
diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html
index dae6edc01..d3c592674 100644
--- a/Doc/Manual/Java.html
+++ b/Doc/Manual/Java.html
@@ -83,6 +83,7 @@
<li><a href="#Java_proper_enums_classes">Proper Java enum classes</a>
<li><a href="#Java_typeunsafe_enums_classes">Type unsafe enum classes</a>
</ul>
+<li><a href="#Java_interfaces">Interfaces</a>
</ul>
<li><a href="#Java_directors">Cross language polymorphism using directors</a>
<ul>
@@ -2288,7 +2289,7 @@ The <tt>jniclasscode</tt> pragma is quite useful for adding in a static block fo
%pragma(java) jniclasscode=%{
static {
try {
- System.loadLibrary("example");
+ System.loadLibrary("example");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. \n" + e);
System.exit(1);
@@ -3331,6 +3332,251 @@ public final class Beverage {
</pre>
</div>
+<H3><a name="Java_interfaces">25.4.6 Interfaces</a></H3>
+
+
+<p>
+By default SWIG wraps all C++ classes as Java classes.
+As Java only supports derivation from a single base class, SWIG has to ignore all
+bases except the first when a C++ class inherits from more than one base class.
+However, there is a family of SWIG macros that change the default wrapping and allows a C++ class
+to be wrapped as a Java interface instead of a Java class.
+These macros provide a way to support some sort of multiple inheritance as there is no limit to
+the number of interfaces that a Java class can inherit from.
+</p>
+
+<p>
+When a C++ class is wrapped as a Java interface, a Java proxy class is still needed.
+The <tt>swiginterface.i</tt> library file provides three macros for marking a C++ class to be
+wrapped as a Java interface.
+There is more than one macro in order to provide a choice for choosing the Java interface and Java proxy names.
+</p>
+
+<table BORDER summary="Java interface macros">
+<tr VALIGN=TOP>
+ <td><b>Interface Macro Name</b></td>
+ <td><b>Description</b></td>
+</tr>
+<tr>
+ <td><tt>%interface(CTYPE)</tt></td>
+ <td>Proxy class name is unchanged, interface name has <tt>SwigInterface</tt> added as a suffix for C++ class <tt>CTYPE</tt>.</td>
+</tr>
+<tr>
+ <td><tt>%interface_impl(CTYPE)</tt></td>
+ <td>Proxy class name has <tt>SwigImpl</tt> as a suffix, interface name has <tt>SwigInterface</tt> added as a suffix for C++ class <tt>CTYPE</tt>.</td>
+</tr>
+<tr>
+ <td><tt>%interface_custom("PROXY", "INTERFACE", CTYPE)</tt></td>
+ <td>Proxy class name is given by the string <tt>PROXY</tt>, interface name is given by the string <tt>INTERFACE</tt> for C++ class <tt>CTYPE</tt>. The <tt>PROXY</tt> and <tt>INTERFACE</tt> names can use the <a href="SWIG.html#SWIG_advanced_renaming">string formatting functions</a> used in <tt>%rename</tt>.</td>
+</tr>
+</table>
+
+<p>
+The table below has a few examples showing the resulting proxy and interface names.
+</p>
+
+<table BORDER summary="Java interface macro examples">
+<tr VALIGN=TOP>
+ <td><b>Example Usage</b></td>
+ <td><b>Proxy Class Name</b></td>
+ <td><b>Interface Class Name</b></td>
+</tr>
+<tr>
+ <td><tt>%interface(Base)</tt></td>
+ <td><tt>Base</tt></td>
+ <td><tt>BaseSwigInterface</tt></td>
+</tr>
+<tr>
+ <td><tt>%interface_impl(Base)</tt></td>
+ <td><tt>BaseSwigImpl</tt></td>
+ <td><tt>Base</tt></td>
+</tr>
+<tr>
+ <td><tt>%interface_custom("BaseProxy", "IBase", Base)</tt></td>
+ <td><tt>BaseProxy</tt></td>
+ <td><tt>IBase</tt></td>
+</tr>
+<tr>
+ <td><tt>%interface_custom("%sProxy", "IBase", Base)</tt></td>
+ <td><tt>BaseProxy</tt></td>
+ <td><tt>IBase</tt></td>
+</tr>
+<tr>
+ <td><tt>%interface_custom("%sProxy", "%sInterface", Base)</tt></td>
+ <td><tt>BaseProxy</tt></td>
+ <td><tt>BaseProxyInterface</tt></td>
+</tr>
+<tr>
+ <td><tt>%interface_custom("%sProxy", "%(rstrip:[Proxy])sInterface", Base)</tt></td>
+ <td><tt>BaseProxy</tt></td>
+ <td><tt>BaseInterface</tt></td>
+</tr>
+</table>
+
+<p>
+The 2nd last example shows the names used in the string formatting functions.
+The input for <tt>PROXY</tt> that <tt>"%s"</tt> expands to is the proxy name, that is, Base.
+The input for <tt>INTERFACE</tt> that <tt>"%s"</tt> expands to is the proxy name, that is, <tt>BaseProxy</tt>.
+</p>
+<p>
+The last example shows <tt>rstrip</tt> and in this case strips the <tt>Proxy</tt> suffix and then adds on <tt>Interface</tt>.
+</p>
+
+<p>
+Consider the following C++ code:
+</p>
+
+<div class="code">
+<pre>
+namespace Space {
+ struct Base1 {
+ virtual void Method1();
+ };
+ struct Base2 {
+ virtual void Method2();
+ };
+ struct Derived : Base1, Base2 {
+ };
+ void UseBases(const Base1 &amp;b1, const Base2 &amp;b2);
+}
+</pre>
+</div>
+
+<p>
+By default all classes are wrapped and are available in Java, but, <tt>Derived</tt>
+has all bases ignored except the first.
+SWIG generates a warning for the above code:
+</p>
+
+<div class="shell">
+<pre>
+example.i:10: Warning 813: Warning for Derived, base Base2 ignored.
+Multiple inheritance is not supported in Java.
+</pre>
+</div>
+
+<p>
+If we decide to wrap the two base classes as interfaces and add the following before SWIG parses the above example code:
+</p>
+
+<div class="code">
+<pre>
+%include &lt;swiginterface.i&gt;
+%interface_impl(Space::Base1);
+%interface_impl(Space::Base2);
+</pre>
+</div>
+
+<p>
+then two interface files are generated, Base1.java and Base2.java in addition to proxy class files, Base1SwigImpl.java and Base2SwigImpl.java.
+The contents of interface file Base1.java for <tt>Base1</tt> is shown below:
+</p>
+
+<div class="code">
+<pre>
+public interface Base1 {
+ long Base1_GetInterfaceCPtr();
+ void Method1();
+}
+</pre>
+</div>
+
+<p>
+The proxy class in Base1SwigImpl.java for Base1 is as it would have been if <tt>%interface</tt> was not used,
+except the name has changed to <tt>Base1SwigImpl</tt> and it implements the appropriate base:
+</p>
+
+<div class="code">
+<pre>
+public class Base1SwigImpl implements Base1 {
+...
+ public long Base1_GetInterfaceCPtr() {
+ return exampleJNI.Base1SwigImpl_Base1_GetInterfaceCPtr(swigCPtr);
+ }
+
+ public void Method1() {
+ exampleJNI.Base1SwigImpl_Method1(swigCPtr, this);
+ }
+...
+}
+</pre>
+</div>
+
+<p>
+In fact any class deriving from <tt>Base</tt> will now implement the interface instead of
+deriving from it (or ignoring the base in the case of multiple base classes).
+Hence the <tt>Derived</tt> proxy class will now implement both bases:
+</p>
+
+<div class="code">
+<pre>
+public class Derived implements Base1, Base2 {
+...
+ public long Base1_GetInterfaceCPtr() {
+ return exampleJNI.Derived_Base1_GetInterfaceCPtr(swigCPtr);
+ }
+
+ public long Base2_GetInterfaceCPtr() {
+ return exampleJNI.Derived_Base2_GetInterfaceCPtr(swigCPtr);
+ }
+
+ public void Method1() {
+ exampleJNI.Derived_Method1(swigCPtr, this);
+ }
+
+ public void Method2() {
+ exampleJNI.Derived_Method2(swigCPtr, this);
+ }
+...
+}
+</pre>
+</div>
+
+<p>
+Wherever a class marked as an interface is used, such as the <tt>UseBases</tt> method in the example,
+the interface name is used as the type in the Java layer:
+</p>
+
+<div class="code">
+<pre>
+ public static void UseBases(Base1 b1, Base2 b2) {
+ exampleJNI.UseBases(b1.Base1_GetInterfaceCPtr(), b1, b2.Base2_GetInterfaceCPtr(), b2);
+ }
+</pre>
+</div>
+
+<p>
+Note that each Java interface has a method added to obtain the correct C++ pointer for passing to the native function -
+<tt>Base1_GetInterfaceCPtr</tt> for <tt>Base1</tt>.
+This method is similar to the <tt>getCPtr</tt> method in the proxy classes.
+In fact, as shown above in the <tt>Derived</tt> class, the proxy classes implement
+this generated interface by calling a native method (<tt>Derived_Base1_GetInterfaceCPtr</tt>)
+which calls an appropriate C++ cast of the pointer up the inheritance chain.
+</p>
+
+<p>
+The interface macros are implemented using the <tt>interface</tt> feature and typemaps.
+For example:
+</p>
+
+<div class="code">
+<pre>
+%define %interface(CTYPE...)
+%feature("interface", name="%sSwigInterface") CTYPE;
+INTERFACE_TYPEMAPS(CTYPE)
+%enddef
+</pre>
+</div>
+
+<p>
+The feature accepts one attribute called <tt>name</tt>, which is the name of the Java interface mentioned earlier.
+The <tt>INTERFACE_TYPEMAPS</tt> macro implements the typemaps and can be viewed in the
+<tt>swiginterface.i</tt> file and contain
+the usual Java typemaps for generating code plus the <tt>javainterfacecode</tt>
+typemap which is only used when a class is marked with the <tt>interface</tt> feature.
+See <a href="Java.html#Java_code_typemaps">Java code typemaps</a> for details.
+</p>
+
<H2><a name="Java_directors">25.5 Cross language polymorphism using directors</a></H2>
@@ -5585,6 +5831,8 @@ For example, <tt>$javaclassname</tt> is replaced by the proxy classname <tt>Foo<
expands to the proxy classname when wrapping <tt>Foo *&amp;</tt>.
If the type does not have an associated proxy class, it expands to the type wrapper class name, for example,
<tt>SWIGTYPE_p_unsigned_short</tt> is generated when wrapping <tt>unsigned short *</tt>.
+The class name is fully qualified with the package name when using the
+<a href="SWIGPlus.html#SWIGPlus_nspace">nspace feature</a>.
</p>
<p>
@@ -5715,6 +5963,35 @@ This special variable expands to the intermediary class name. Usually this is th
unless the jniclassname attribute is specified in the <a href="Java.html#Java_module_directive">%module directive</a>.
</p>
+<p>
+<b><tt>$javainterfacename</tt></b><br>
+This special variable is only expanded when the <tt>interface</tt> feature is applied to a class.
+It works much like <tt>$javaclassname</tt>, but instead of expanding to the proxy classname,
+it expands to the value in the <tt>name</tt> attribute in the <tt>interface</tt> feature.
+For example:
+</p>
+
+<div class="code"><pre>
+%feature("interface", name="MyInterface") MyClass;
+%typemap(jstype) MyClass "$&amp;javainterfacename"
+%typemap(jstype) MyClass * "$javainterfacename"
+</pre></div>
+
+<p>
+will result in the <tt>jstype</tt> typemap expanding to <tt>MyInterface</tt> for both
+<tt>MyClass</tt> and <tt>MyClass *</tt>.
+The interface name is fully qualified with the package name when using the
+<a href="SWIGPlus.html#SWIGPlus_nspace">nspace feature</a>.
+</p>
+
+<p>
+<b><tt>$interfacename</tt></b><br>
+This special variable is only expanded when the <tt>interface</tt> feature is applied to a class.
+It expands to just the interface name and is thus different to <tt>$javainterfacename</tt>
+in that it is not fully qualified with the package name when using the
+<a href="SWIGPlus.html#SWIGPlus_nspace">nspace feature</a>.
+</p>
+
<H3><a name="Java_typemaps_for_c_and_cpp">25.9.8 Typemaps for both C and C++ compilation</a></H3>
@@ -5848,9 +6125,39 @@ Below shows an example modifying the finalizer, assuming the <tt>delete</tt> met
</div>
+<p><tt>%typemap(javainterfacecode, declaration="...", cptrmethod="...")</tt></p>
+<div class="indent">
+<p>
+The code in this typemap is added to the body of a Java proxy class but only when a class is
+marked with the <tt>interface</tt> feature.
+The typemap is used in the proxy class marked with the interface feature as well as all proxy classes derived from the marked C++ class,
+as they are all generated as implementing the Java interface.
+The default typemap used in the <tt>%interface</tt> family of macros mentioned in
+the <a href="Java.html#Java_interfaces">Java interfaces</a> section,
+where <tt>CTYPE</tt> is the C++ class macro argument,
+is as follows:
+</p>
+
+<div class="code"><pre>
+%typemap(javainterfacecode,
+ declaration=" long $interfacename_GetInterfaceCPtr();\n",
+ cptrmethod="$interfacename_GetInterfaceCPtr") CTYPE %{
+ public long $interfacename_GetInterfaceCPtr() {
+ return $imclassname.$javaclazzname$interfacename_GetInterfaceCPtr(swigCPtr);
+ }
+%}
+</pre></div>
+</div>
+
+<p>
+The special variable <tt>$interfacename</tt> is expanded into the
+name specified in the <tt>interface</tt> feature.
+</p>
+
<p>
<b>Compatibility Note:</b> In SWIG-1.3.21 and earlier releases, typemaps called "javagetcptr" and "javaptrconstructormodifiers" were available.
These are deprecated and the "javabody" typemap can be used instead.
+The <tt>javainterfacecode</tt> typemap and interface feature was introduced in SWIG-3.0.9.
</p>
<p>
@@ -5866,6 +6173,7 @@ In summary the contents of the typemaps make up a proxy class like this:
[ javafinalize typemap ]
public synchronized void <i>delete</i>() [ javadestruct OR javadestruct_derived typemap ]
[ javacode typemap ]
+[ javainterfacecode typemap]
... proxy functions ...
}
</pre>
@@ -5876,6 +6184,11 @@ Note the <tt><i>delete</i>()</tt> methodname and method modifiers are configurab
</p>
<p>
+The <tt>javainterfacecode</tt> typemap is only used when bases are marked by the <tt>interface</tt>
+feature and the <tt>implements</tt> list will also then be expanded to include these Java interfaces.
+</p>
+
+<p>
The type wrapper class is similar in construction:
</p>
@@ -5907,8 +6220,23 @@ The type wrapper class is similar in construction:
The "javaimports" typemap is ignored if the enum class is wrapped by an inner Java class, that is when wrapping an enum declared within a C++ class.
</p>
+<p>The Java interface turned on by the <tt>interface</tt> feature is fairly simple:</p>
+<div class="code">
+<pre>
+[ javaimports typemap ]
+public interface [ javainterfacename ] {
+[ javainterfacecode:cptrmethod typemap attribute ]
+... interface declarations ...
+}
+</pre>
+</div>
+
+<p>
+where <tt>javainterfacename</tt> is the <tt>name</tt> attribute in the <a href="Java.html#Java_interfaces">interface feature</a>.
+</p>
+
<p>
-The defaults can be overridden to tailor these classes.
+The defaults can be overridden to tailor the generated classes.
Here is an example which will change the <tt>getCPtr</tt> method and constructor from the default public access to protected access.
If the classes in one package are not using the classes in another package, then these methods need not be public and removing access to these low level implementation details, is a good thing.
If you are invoking SWIG more than once and generating the wrapped classes into different packages in each invocation, then you cannot do this as you will then have different packages.
diff --git a/Doc/Manual/Javascript.html b/Doc/Manual/Javascript.html
index 405583b4f..16f674892 100644
--- a/Doc/Manual/Javascript.html
+++ b/Doc/Manual/Javascript.html
@@ -101,7 +101,7 @@ that era had a component &gt; 99. For example:</p>
<pre>
$ swig -c++ -javascript -v8 -DV8_VERSION=0x032530 example.i</pre>
</div>
-<p>If you're targetting V8 &gt;= 4.3.0, you would just run swig like so:<p>
+<p>If you're targetting V8 &gt;= 4.3.0, you would just run swig like so:</p>
<div class="shell">
<pre>
$ swig -c++ -javascript -v8 example.i</pre>
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/Preface.html b/Doc/Manual/Preface.html
index 4a9ad5ba9..3b654a6d2 100644
--- a/Doc/Manual/Preface.html
+++ b/Doc/Manual/Preface.html
@@ -267,6 +267,13 @@ the main SWIG distribution. There is no need to download anything else.
<p>
+These installation instructions are for using the distributed tarball,
+for example, <tt>swig-3.0.8.tar.gz</tt>.
+If you wish to build and install from source on Github, extra steps are required.
+Please see the <a href="http://swig.org/svn.html">Bleeding Edge</a> page on the SWIG website.
+</p>
+
+<p>
You must use <a href="http://www.gnu.org/software/make/">GNU make</a> to build and install SWIG.
</p>
diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html
index 1dce1806c..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>
@@ -1161,7 +1169,7 @@ When wrapped, you will be able to use the functions in a natural way from Python
<div class="targetlang">
<pre>
&gt;&gt;&gt; import example
-&gt;&gt;&gt; f = example.fopen("junk","w")
+&gt;&gt;&gt; f = example.fopen("junk", "w")
&gt;&gt;&gt; example.fputs("Hello World\n", f)
&gt;&gt;&gt; example.fclose(f)
</pre>
@@ -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
@@ -4725,7 +4733,7 @@ follows :
<div class="targetlang"><pre>
&gt;&gt;&gt; from argv import *
-&gt;&gt;&gt; print_args(["Dave","Mike","Mary","Jane","John"])
+&gt;&gt;&gt; print_args(["Dave", "Mike", "Mary", "Jane", "John"])
argv[0] = Dave
argv[1] = Mike
argv[2] = Mary
@@ -4763,7 +4771,7 @@ allows the function to be used from Python as follows:
<div class="targetlang">
<pre>
-&gt;&gt;&gt; foo(4, ["foo","bar","spam","1"])
+&gt;&gt;&gt; foo(4, ["foo", "bar", "spam", "1"])
</pre>
</div>
@@ -4817,7 +4825,47 @@ to supply the argument count. This is automatically set by the typemap code. F
<div class="targetlang">
<pre>
-&gt;&gt;&gt; foo(["foo","bar","spam","1"])
+&gt;&gt;&gt; foo(["foo", "bar", "spam", "1"])
+</pre>
+</div>
+
+<p>
+If your function is overloaded in C++, for example:
+</p>
+
+<div class="code">
+<pre>
+int foo(int argc, char **argv);
+int foo();
+</pre>
+</div>
+
+<p>
+don't forget to also provide a suitable <a href="Typemaps.html#Typemaps_overloading">typecheck typemap for overloading</a>
+such as:
+</p>
+
+<div class="code">
+<pre>
+%typecheck(SWIG_TYPECHECK_STRING_ARRAY) (int argc, char **argv) {
+ $1 = PyList_Check($input) ? 1 : 0;
+}
+</pre>
+</div>
+
+<p>
+If you don't you'll get an error message along the lines of:
+</p>
+
+<div class="shell">
+<pre>
+Traceback (most recent call last):
+ File "runme.py", line 3, in &gt;module&lt;
+ example.foo(["foo", "bar", "spam", "1"])
+NotImplementedError: Wrong number or type of arguments for overloaded function 'foo'.
+ Possible C/C++ prototypes are:
+ foo(int,char **)
+ foo()
</pre>
</div>
@@ -4851,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);
@@ -5480,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
@@ -5639,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>
@@ -5654,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
@@ -5825,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/SWIG.html b/Doc/Manual/SWIG.html
index 178247e42..bf1705d20 100644
--- a/Doc/Manual/SWIG.html
+++ b/Doc/Manual/SWIG.html
@@ -1889,6 +1889,13 @@ and a more descriptive one, but the two functions are otherwise equivalent:
<td><tt>wxPrint</tt></td><td><tt>Print</tt></td>
</tr>
<tr>
+ <td><tt>rstrip:[suffix]</tt></td>
+ <td>String without the given suffix or the original string if it doesn't
+ end with this suffix. Note that square brackets should be used
+ literally, e.g. <tt>%rename("rstrip:[Cls]")</tt></td>
+ <td><tt>PrintCls</tt></td><td><tt>Print</tt></td>
+</tr>
+<tr>
<td><span style="white-space: nowrap;"><tt>regex:/pattern/subst/</tt></span></td>
<td>String after (Perl-like) regex substitution operation. This function
allows to apply arbitrary regular expressions to the identifier names. The
diff --git a/Doc/Manual/Scilab.html b/Doc/Manual/Scilab.html
index 3e9e1c1a2..0ac4c059f 100644
--- a/Doc/Manual/Scilab.html
+++ b/Doc/Manual/Scilab.html
@@ -40,11 +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><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>
@@ -55,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>
@@ -752,11 +752,25 @@ typedef enum { RED, BLUE, GREEN } color;
<p>
-C/C++ pointers are fully supported by SWIG. They are mapped to the Scilab pointer type ("pointer", type ID: 128).
+Pointers are supported by SWIG. A pointer can be returned from a wrapped C/C++ function, stored in a Scilab variable, and used in input argument of another C/C++ function.
</p>
+<p>
+Also, thanks to the SWIG runtime which stores informations about types, pointer types are tracked between exchanges Scilab and the native code. Indeed pointer types are stored alongside the pointer adress.
+A pointer is mapped to a Scilab structure (<a href="https://help.scilab.org/docs/5.5.2/en_US/tlist.html">tlist</a>), which contains as fields the pointer address and the pointer type (in fact a pointer to the type information structure in the SWIG runtime).
+<br>
+Why a native pointer is not mapped to a Scilab pointer (type name: "pointer", type ID: 128) ? The big advantage of mapping to a <tt>tlist</tt> is that it exposes a new type for the pointer in Scilab, type which can be acessed in Scilab with the <a href="https://help.scilab.org/docs/5.5.2/en_US/typeof.html">typeof</a> function, and manipulated using the <a href="https://help.scilab.org/docs/5.5.2/en_US/overloading.html">overloading</a> mechanism.
+</p>
+
+<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>
-Given a wrapping of some of the C file functions:
+Following is an example of the wrapping of the C <tt>FILE*</tt> pointer:
</p>
<div class="code"><pre>
@@ -772,21 +786,27 @@ int fclose(FILE *);
</pre></div>
<p>
-These functions can be used in a natural way from Scilab:
+These functions can be used the same way as in C from Scilab:
</p>
<div class="targetlang"><pre>
+--&gt; example_Init();
+
--&gt; f = fopen("junk", "w");
--&gt; typeof(f)
ans =
- pointer
+ _p_FILE
--&gt; fputs("Hello World", f);
--&gt; fclose(f);
</pre></div>
<p>
+Note: the type name <tt>_p_FILE</tt> which means "pointer to FILE".
+</p>
+
+<p>
The user of a pointer is responsible for freeing it or, like in the example, closing any resources associated with it (just as is required in a C program).
</p>
@@ -794,7 +814,7 @@ The user of a pointer is responsible for freeing it or, like in the example, clo
<p>
-Most of time pointer manipulation is not needed in a scripting language such as Scilab.
+As a scripting language, Scilab does not provide functions to manipulate pointers.
However, in some cases it can be useful, such as for testing or debugging.
</p>
@@ -806,7 +826,11 @@ SWIG comes with two pointer utility functions:
<li><tt>SWIG_ptr()</tt>: creates a pointer from an address value</li>
</ul>
-<p>Following illustrates their use on the last example:</p>
+<p>
+Note: a pointer created by <tt>SWIG_ptr()</tt> does not have any type and is mapped as a Scilab pointer.
+</p>
+
+<p>Following we use the utility functions on the previous example:</p>
<div class="targetlang"><pre>
--&gt; f = fopen("junk", "w");
@@ -817,15 +841,21 @@ SWIG comes with two pointer utility functions:
8219088.
--&gt; p = SWIG_ptr(addr);
+--&gt; typeof(p)
+ans =
+
+ pointer
+
--&gt; fputs(" World", p);
--&gt; fclose(f);
</pre></div>
-<H4><a name="Scilab_wrapping_pointers_null_pointers">39.3.6.2 Null pointers</a></H4>
+<H4><a name="Scilab_wrapping_pointers_null_pointers">39.3.6.2 Null pointers:</a></H4>
-<p>By default, Scilab does not provide a way to test or create null pointers.
-But it is possible to have a null pointer by using the previous functions <tt>SWIG_this()</tt> and <tt>SWIG_ptr()</tt>, like this:
+
+<p>
+Using the previous <tt>SWIG_this()</tt> and <tt>SWIG_ptr()</tt>, it is possible to create and check null pointers:
</p>
<div class="targetlang"><pre>
@@ -873,6 +903,7 @@ Several functions are generated:
<li>a destructor function <tt>delete_Foo()</tt> to release the struct pointer.</li>
</ul>
+
<p>
Usage example:
</p>
@@ -931,6 +962,19 @@ ans =
20.
</pre></div>
+<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>
+
+<div class="targetlang"><pre>
+--&gt; example_Init();
+--&gt; b = new_Bar();
+--&gt; typeof(b)
+ ans =
+
+ _p_Bar
+--&gt; delete_Bar(b);
+</pre></div>
<H3><a name="Scilab_wrapping_cpp_classes">39.3.8 C++ classes</a></H3>
@@ -982,6 +1026,24 @@ ans =
--&gt; delete_Point(p2);
</pre></div>
+<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>
+
+<div class="targetlang"><pre>
+--&gt; function %_p_Point_p(p)
+--&gt; mprintf('[%d, %d]\n', Point_x_get(p), Point_y_get(p));
+--&gt; endfunction
+
+--&gt; example_Init();
+--&gt; p = new_Point(1, 2)
+ p =
+
+[1, 2]
+
+--&gt; delete_Point(p);
+</pre></div>
+
<H3><a name="Scilab_wrapping_cpp_inheritance">39.3.9 C++ inheritance</a></H3>
@@ -1057,7 +1119,47 @@ But we can use either use the <tt>get_perimeter()</tt> function of the parent cl
18.84
</pre></div>
-<H3><a name="Scilab_wrapping_pointers_references_values_arrays">39.3.10 Pointers, references, values, and arrays</a></H3>
+<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>
+
+<div class="code"><pre>
+%module example
+
+void magnify(Square *square, double factor) {
+ square-&gt;size *= factor;
+};
+
+void magnify(Circle *circle, double factor) {
+ square-&gt;radius *= factor;
+};
+</pre></div>
+
+<div class="targetlang"><pre>
+--&gt; example_Init();
+--&gt; c = new_Circle(3);
+--&gt; s = new_Square(2);
+
+--&gt; magnify(c, 10);
+--&gt; Circle_get_radius(c)
+ ans =
+
+ 30;
+--&gt; magnify(s, 10);
+--&gt; Square_get_size(s)
+ ans =
+
+ 20;
+</pre></div>
+
+
+<H3><a name="Scilab_wrapping_pointers_references_values_arrays">39.3.11 Pointers, references, values, and arrays</a></H3>
<p>
@@ -1115,7 +1217,7 @@ All these functions will return a pointer to an instance of <tt>Foo</tt>.
As the function <tt>spam7</tt> returns a value, new instance of <tt>Foo</tt> has to be allocated, and a pointer on this instance is returned.
</p>
-<H3><a name="Scilab_wrapping_cpp_templates">39.3.11 C++ templates</a></H3>
+<H3><a name="Scilab_wrapping_cpp_templates">39.3.12 C++ templates</a></H3>
<p>
@@ -1123,8 +1225,7 @@ As in other languages, function and class templates are supported in SWIG Scilab
</p>
<p>
-You have to tell SWIG to create wrappers for a particular
-template instantiation. The <tt>%template</tt> directive is used for this purpose.
+You have to tell SWIG to create wrappers for a particular template instantiation. The <tt>%template</tt> directive is used for this purpose.
For example:
</p>
@@ -1175,7 +1276,7 @@ Then in Scilab:
More details on template support can be found in the <a href="SWIGPlus.html#SWIGPlus_nn30">templates</a> documentation.
</p>
-<H3><a name="Scilab_wrapping_cpp_operators">39.3.12 C++ operators</a></H3>
+<H3><a name="Scilab_wrapping_cpp_operators">39.3.13 C++ operators</a></H3>
<p>
@@ -1228,7 +1329,7 @@ private:
</pre></div>
-<H3><a name="Scilab_wrapping_cpp_namespaces">39.3.13 C++ namespaces</a></H3>
+<H3><a name="Scilab_wrapping_cpp_namespaces">39.3.14 C++ namespaces</a></H3>
<p>
@@ -1306,7 +1407,7 @@ Note: the <a href="SWIGPlus.html#SWIGPlus_nspace">nspace</a> feature is not supp
</p>
-<H3><a name="Scilab_wrapping_cpp_exceptions">39.3.14 C++ exceptions</a></H3>
+<H3><a name="Scilab_wrapping_cpp_exceptions">39.3.15 C++ exceptions</a></H3>
<p>
@@ -1389,7 +1490,7 @@ More complex or custom exception types require specific exception typemaps to be
See the <a href="SWIGPlus.html#SWIGPlus">SWIG C++ documentation</a> for more details.
</p>
-<H3><a name="Scilab_wrapping_cpp_stl">39.3.15 C++ STL</a></H3>
+<H3><a name="Scilab_wrapping_cpp_stl">39.3.16 C++ STL</a></H3>
<p>
@@ -1448,15 +1549,9 @@ The default behaviour is for SWIG to generate code that will give a runtime erro
</ul>
-<H3><a name="Scilab_typemaps_non-primitive_types">39.4.2 Default type mappings for non-primitive types</a></H3>
-
-
-<p>
-The default mapped type for C/C++ non-primitive types is the Scilab pointer, for example for C structs, C++ classes, etc...
-</p>
-<H3><a name="Scilab_typemaps_arrays">39.4.3 Arrays</a></H3>
+<H3><a name="Scilab_typemaps_arrays">39.4.2 Arrays</a></H3>
<p>
@@ -1511,7 +1606,7 @@ void printArray(int values[], int len) {
[ 0 1 2 3 ]
</pre></div>
-<H3><a name="Scilab_typemaps_pointer-to-pointers">39.4.4 Pointer-to-pointers</a></H3>
+<H3><a name="Scilab_typemaps_pointer-to-pointers">39.4.3 Pointer-to-pointers</a></H3>
<p>
@@ -1584,7 +1679,7 @@ void print_matrix(double **M, int nbRows, int nbCols) {
</pre></div>
-<H3><a name="Scilab_typemaps_matrices">39.4.5 Matrices</a></H3>
+<H3><a name="Scilab_typemaps_matrices">39.4.4 Matrices</a></H3>
<p>
@@ -1677,7 +1772,7 @@ The remarks made earlier for arrays also apply here:
<li>There is no control while converting <tt>double</tt> values to integers, <tt>double</tt> values are truncated without any checking or warning.</li>
</ul>
-<H3><a name="Scilab_typemaps_stl">39.4.6 STL</a></H3>
+<H3><a name="Scilab_typemaps_stl">39.4.5 STL</a></H3>
<p>
@@ -1884,8 +1979,8 @@ ans =
The wrapped module contains an initialization function to:
</p>
<ul>
-<li>initialize the SWIG runtime, which is necessary when working with the STL</li>
-<li>initialize in Scilab the module constants and enumerations declared with <tt>%scilabconst()</tt></li>
+<li>initialize the SWIG runtime, needed for pointer type tracking or when working with the STL</li>
+<li>initialize the module constants and enumerations declared with <tt>%scilabconst()</tt></li>
</ul>
<p>
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 0dc725a9f..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>
@@ -3444,7 +3444,7 @@ list of strings like this:
<div class="targetlang">
<pre>
-&gt;&gt;&gt; foo(["ale","lager","stout"])
+&gt;&gt;&gt; foo(["ale", "lager", "stout"])
</pre>
</div>
@@ -3487,6 +3487,11 @@ maps perform the conversion described for the above example:
%typemap(freearg) (int argc, char *argv[]) {
if ($2) free($2);
}
+
+/* Required for C++ method overloading */
+%typecheck(SWIG_TYPECHECK_STRING_ARRAY) (int argc, char *argv[]) {
+ $1 = PyList_Check($input) ? 1 : 0;
+}
</pre>
</div>
@@ -3555,6 +3560,11 @@ Other directives such as <tt>%apply</tt> and <tt>%clear</tt> also work with mult
</div>
<p>
+Don't forget to also provide a suitable <a href="#Typemaps_overloading">typemap for overloaded functions</a>, such as <tt>%typecheck</tt> shown for foo above.
+This is only required if the function is overloaded in C++.
+</p>
+
+<p>
Although multi-argument typemaps may seem like an exotic, little used feature, there
are several situations where they make sense. First, suppose you wanted to wrap
functions similar to the low-level <tt>read()</tt> and <tt>write()</tt> system calls.
diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html
index 3ec1af757..89a8375a5 100644
--- a/Doc/Manual/Warnings.html
+++ b/Doc/Manual/Warnings.html
@@ -546,7 +546,7 @@ example.i(4) : Syntax error in input(1).
<li>810. No jni typemap defined for <em>type</em> (Java).
<li>811. No jtype typemap defined for <em>type</em> (Java).
<li>812. No jstype typemap defined for <em>type</em> (Java).
-<li>813. Warning for <em>classname</em>: Base <em>baseclass</em> ignored. Multiple inheritance is not supported in Java. (Java).
+<li>813. Warning for <em>classname</em>, base <em>baseclass</em> ignored. Multiple inheritance is not supported in Java. (Java).
<li>814.
<li>815. No javafinalize typemap defined for <em>type</em> (Java).
<li>816. No javabody typemap defined for <em>type</em> (Java).
@@ -566,7 +566,7 @@ example.i(4) : Syntax error in input(1).
<li>830. No ctype typemap defined for <em>type</em> (C#).
<li>831. No cstype typemap defined for <em>type</em> (C#).
<li>832. No cswtype typemap defined for <em>type</em> (C#).
-<li>833. Warning for <em>classname</em>: Base <em>baseclass</em> ignored. Multiple inheritance is not supported in C#. (C#).
+<li>833. Warning for <em>classname</em>, base <em>baseclass</em> ignored. Multiple inheritance is not supported in C#. (C#).
<li>834.
<li>835. No csfinalize typemap defined for <em>type</em> (C#).
<li>836. No csbody typemap defined for <em>type</em> (C#).
@@ -582,7 +582,7 @@ example.i(4) : Syntax error in input(1).
</ul>
<ul>
-<li>870. Warning for <em>classname</em>: Base <em>baseclass</em> ignored. Multiple inheritance is not supported in PHP.
+<li>870. Warning for <em>classname</em>: Base <em>baseclass</em> ignored. Multiple inheritance is not supported in PHP. (Php).
<li>871. Unrecognized pragma <em>pragma</em>. (Php).
</ul>
diff --git a/Examples/Makefile.in b/Examples/Makefile.in
index 68a1991cc..5778621fc 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)
@@ -390,7 +390,7 @@ PY2TO3 = 2to3 `2to3 -l | grep -v -E "Available|import$$" | awk '{print "-f "$$0}
python_run: $(PYSCRIPT)
ifneq (,$(PEP8))
- $(PEP8) $(PEP8_FLAGS) $(PYSCRIPT)
+ $(COMPILETOOL) $(PEP8) $(PEP8_FLAGS) $(PYSCRIPT)
endif
env PYTHONPATH=$$PWD $(RUNTOOL) $(PYTHON) $(PYSCRIPT) $(RUNPIPE)
@@ -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
@@ -644,6 +644,7 @@ JAVASO =@JAVASO@
JAVALDSHARED = @JAVALDSHARED@
JAVACXXSHARED = @JAVACXXSHARED@
JAVACFLAGS = @JAVACFLAGS@
+JAVAFLAGS = @JAVAFLAGS@
JAVA = @JAVA@
JAVAC = @JAVAC@ -d .
@@ -677,7 +678,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
@@ -1727,6 +1728,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
@@ -1759,7 +1761,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/apply_strings.i b/Examples/test-suite/apply_strings.i
index 62b578bf2..695dd068f 100644
--- a/Examples/test-suite/apply_strings.i
+++ b/Examples/test-suite/apply_strings.i
@@ -68,6 +68,10 @@ TAscii *DigitsGlobalC;
// Director test
%feature("director");
+#if defined(SWIGGO)
+%typemap(godirectorout) CharPtr, CCharPtr ""
+#endif
+
%inline %{
struct DirectorTest {
virtual UCharPtr UCharFunction(UCharPtr str) { return str; }
diff --git a/Examples/test-suite/char_constant.i b/Examples/test-suite/char_constant.i
index 5235b0581..918456192 100644
--- a/Examples/test-suite/char_constant.i
+++ b/Examples/test-suite/char_constant.i
@@ -12,6 +12,36 @@
#define ESC_CONST '\1'
#define NULL_CONST '\0'
#define SPECIALCHAR 'á'
+#define SPECIALCHAR2 '\n'
+#define SPECIALCHARA 'A'
+#define SPECIALCHARB '\102' // B
+#define SPECIALCHARC '\x43' // C
+#define SPECIALCHARD 0x44 // D
+#define SPECIALCHARE 69 // E
+#define SPECIALCHARAE1 'Æ' // AE (latin1 encoded)
+#define SPECIALCHARAE2 '\306' // AE (latin1 encoded)
+#define SPECIALCHARAE3 '\xC6' // AE (latin1 encoded)
+
+#if defined(SWIGJAVA)
+%javaconst(1);
+#elif SWIGCSHARP
+%csconst(1);
+#elif SWIGD
+%dmanifestconst;
+#endif
+
+#define X_ESC_CONST '\1'
+#define X_NULL_CONST '\0'
+#define X_SPECIALCHAR 'á'
+#define X_SPECIALCHAR2 '\n'
+#define X_SPECIALCHARA 'A'
+#define X_SPECIALCHARB '\102' // B
+#define X_SPECIALCHARC '\x43' // C
+#define X_SPECIALCHARD 0x44 // D
+#define X_SPECIALCHARE 69 // E
+#define X_SPECIALCHARAE1 'Æ' // AE (latin1 encoded)
+#define X_SPECIALCHARAE2 '\306' // AE (latin1 encoded)
+#define X_SPECIALCHARAE3 '\xC6' // AE (latin1 encoded)
%inline
{
diff --git a/Examples/test-suite/chartest.i b/Examples/test-suite/chartest.i
index e81cf54a4..1046fa4d1 100644
--- a/Examples/test-suite/chartest.i
+++ b/Examples/test-suite/chartest.i
@@ -1,6 +1,11 @@
%module chartest
%inline %{
+#if defined(__clang__)
+#pragma clang diagnostic push
+// Suppress: illegal character encoding in character literal
+#pragma clang diagnostic ignored "-Winvalid-source-encoding"
+#endif
char printable_global_char = 'a';
char unprintable_global_char = 0x7F;
@@ -12,4 +17,68 @@ char GetUnprintableChar() {
return 0x7F;
}
+static const char globchar0 = '\0';
+static const char globchar1 = '\1';
+static const char globchar2 = '\n';
+static const char globcharA = 'A';
+static const char globcharB = '\102'; // B
+static const char globcharC = '\x43'; // C
+static const char globcharD = 0x44; // D
+static const char globcharE = 69; // E
+static const char globcharAE1 = 'Æ'; // AE (latin1 encoded)
+static const char globcharAE2 = '\306'; // AE (latin1 encoded)
+static const char globcharAE3 = '\xC6'; // AE (latin1 encoded)
+
+struct CharTestClass {
+ static const char memberchar0 = '\0';
+ static const char memberchar1 = '\1';
+ static const char memberchar2 = '\n';
+ static const char membercharA = 'A';
+ static const char membercharB = '\102'; // B
+ static const char membercharC = '\x43'; // C
+ static const char membercharD = 0x44; // D
+ static const char membercharE = 69; // E
+ static const char membercharAE1 = 'Æ'; // AE (latin1 encoded)
+ static const char membercharAE2 = '\306'; // AE (latin1 encoded)
+ static const char membercharAE3 = '\xC6'; // AE (latin1 encoded)
+};
+%}
+
+#if defined(SWIGJAVA)
+%javaconst(1);
+#elif SWIGCSHARP
+%csconst(1);
+#elif SWIGD
+%dmanifestconst;
+#endif
+
+%inline %{
+static const char x_globchar0 = '\0';
+static const char x_globchar1 = '\1';
+static const char x_globchar2 = '\n';
+static const char x_globcharA = 'A';
+static const char x_globcharB = '\102'; // B
+static const char x_globcharC = '\x43'; // C
+static const char x_globcharD = 0x44; // D
+static const char x_globcharE = 69; // E
+static const char x_globcharAE1 = 'Æ'; // AE (latin1 encoded)
+static const char x_globcharAE2 = '\306'; // AE (latin1 encoded)
+static const char x_globcharAE3 = '\xC6'; // AE (latin1 encoded)
+
+struct X_CharTestClass {
+ static const char memberchar0 = '\0';
+ static const char memberchar1 = '\1';
+ static const char memberchar2 = '\n';
+ static const char membercharA = 'A';
+ static const char membercharB = '\102'; // B
+ static const char membercharC = '\x43'; // C
+ static const char membercharD = 0x44; // D
+ static const char membercharE = 69; // E
+ static const char membercharAE1 = 'Æ'; // AE (latin1 encoded)
+ static const char membercharAE2 = '\306'; // AE (latin1 encoded)
+ static const char membercharAE3 = '\xC6'; // AE (latin1 encoded)
+};
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif
%}
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index 9f948c2ca..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 \
@@ -282,6 +283,10 @@ CPP_TEST_CASES += \
minherit2 \
mixed_types \
multiple_inheritance \
+ multiple_inheritance_abstract \
+ multiple_inheritance_interfaces \
+ multiple_inheritance_nspace \
+ multiple_inheritance_shared_ptr \
name_cxx \
name_warnings \
namespace_class \
@@ -303,6 +308,7 @@ CPP_TEST_CASES += \
nested_class \
nested_directors \
nested_comment \
+ nested_ignore \
nested_scope \
nested_template_base \
nested_workaround \
@@ -341,6 +347,7 @@ CPP_TEST_CASES += \
rename2 \
rename3 \
rename4 \
+ rename_rstrip_encoder \
rename_scope \
rename_simple \
rename_strip_encoder \
@@ -357,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 \
@@ -379,6 +387,7 @@ CPP_TEST_CASES += \
static_array_member \
static_const_member \
static_const_member_2 \
+ string_constants \
struct_initialization_cpp \
struct_value \
symbol_clash \
@@ -396,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 \
@@ -664,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) \
@@ -694,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)
@@ -701,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/compactdefaultargs.i b/Examples/test-suite/compactdefaultargs.i
index b2b07c5f8..af96fbe23 100644
--- a/Examples/test-suite/compactdefaultargs.i
+++ b/Examples/test-suite/compactdefaultargs.i
@@ -30,6 +30,7 @@ public:
static const double PUBLIC_DEFAULT;
Defaults2(int a = PRIVATE_DEFAULT) {}
double ret(double d = PUBLIC_DEFAULT) { return d; }
+ double nodefault(int x) { return x; }
};
%}
diff --git a/Examples/test-suite/constant_directive.i b/Examples/test-suite/constant_directive.i
index 8204720d6..89f13cecc 100644
--- a/Examples/test-suite/constant_directive.i
+++ b/Examples/test-suite/constant_directive.i
@@ -1,28 +1,44 @@
%module constant_directive
// %constant and struct
-%{
- struct Type1 {
- Type1(int val = 0) : val(val) {}
- int val;
- };
- static Type1 TYPE1_CONSTANT1(1);
- static Type1 TYPE1_CONST2(2);
- static Type1 TYPE1_CONST3(3);
-%}
+%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) {}
+ Type1(int val = 0) : val(val) {}
int val;
};
+/* Typedefs for const Type and its pointer */
+typedef const Type1 Type1Const;
+typedef const Type1* Type1Cptr;
-%inline %{
+/* Typedefs for function pointers returning Type1 */
+typedef Type1 (*Type1Fptr)();
+typedef Type1 (* const Type1Cfptr)();
+
+/* Function returning an instance of Type1 */
Type1 getType1Instance() { return Type1(111); }
%}
+%{
+ static Type1 TYPE1_CONSTANT1(1);
+ static Type1 TYPE1_CONST2(2);
+ static Type1 TYPE1_CONST3(3);
+%}
+
%constant Type1 TYPE1_CONSTANT1;
%constant Type1 TYPE1_CONSTANT2 = TYPE1_CONST2;
%constant Type1 *TYPE1_CONSTANT3 = &TYPE1_CONST3;
-
+/* Typedef'ed types */
+%constant Type1Const* TYPE1CONST_CONSTANT1 = &TYPE1_CONSTANT1;
+%constant Type1Cptr TYPE1CPTR_CONSTANT1 = &TYPE1_CONSTANT1;
+/* Function pointers */
+%constant Type1 (*TYPE1FPTR1_CONSTANT1)() = getType1Instance;
+%constant Type1 (* const TYPE1CFPTR1_CONSTANT1)() = getType1Instance;
+/* Typedef'ed function pointers */
+%constant Type1Fptr TYPE1FPTR1DEF_CONSTANT1 = getType1Instance;
+%constant Type1Cfptr TYPE1CFPTR1DEF_CONSTANT1 = getType1Instance;
+/* Regular constant */
%constant int TYPE_INT = 0;
-
diff --git a/Examples/test-suite/cpp11_li_std_array.i b/Examples/test-suite/cpp11_li_std_array.i
index 74e34370c..19304d9e6 100644
--- a/Examples/test-suite/cpp11_li_std_array.i
+++ b/Examples/test-suite/cpp11_li_std_array.i
@@ -1,6 +1,6 @@
%module cpp11_li_std_array
-#if defined(SWIGPYTHON) || defined(SWIGRUBY)
+#if defined(SWIGPYTHON) || defined(SWIGRUBY) || defined(SWIGJAVA)
%{
#include <array>
diff --git a/Examples/test-suite/cpp11_strongly_typed_enumerations.i b/Examples/test-suite/cpp11_strongly_typed_enumerations.i
index 3a4ee107a..64fdd2b6f 100644
--- a/Examples/test-suite/cpp11_strongly_typed_enumerations.i
+++ b/Examples/test-suite/cpp11_strongly_typed_enumerations.i
@@ -214,5 +214,12 @@ Enum1 globalTest1(Enum1 e) { return e; }
Class1::Enum12 globalTest2(Class1::Enum12 e) { return e; }
Class1::Struct1::Enum12 globalTest3(Class1::Struct1::Enum12 e) { return e; }
+class PrivateEnumClass {
+private:
+ enum class Enum {
+ PrivateEnum1,
+ PrivateEnum2
+ };
+};
%}
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/csharp/multiple_inheritance_abstract_runme.cs b/Examples/test-suite/csharp/multiple_inheritance_abstract_runme.cs
new file mode 100644
index 000000000..4584be399
--- /dev/null
+++ b/Examples/test-suite/csharp/multiple_inheritance_abstract_runme.cs
@@ -0,0 +1,245 @@
+using System;
+using multiple_inheritance_abstractNamespace;
+
+public class multiple_inheritance_abstract_runme {
+
+ //Test base class as a parameter in C#
+ int jcbase1b(CBase1 cb1){
+ return cb1.cbase1y();
+ }
+ int jabase1(ABase1 ab1){
+ return ab1.abase1();
+ }
+ int jcbase2(CBase2 cb2){
+ return cb2.cbase2();
+ }
+
+ public static void check(bool fail, string msg) {
+ if (fail)
+ throw new Exception(msg);
+ }
+
+ public static void Main() {
+ //Test Derived1
+ Derived1 d1=new Derived1();
+ check(d1.cbase1y()!=3, "Derived1::cbase1y() failed");
+ check(d1.cbase2()!=4, "Derived1::cbase2() failed");
+
+ //Test Derived2
+ Derived2 d2=new Derived2();
+ check(d2.cbase1y()!=6, "Derived2::cbase1y() failed");
+ check(d2.abase1()!=5, "Derived2::abase1() failed");
+
+ //Test Derived3
+ Derived3 d3=new Derived3();
+ check(d3.cbase1y()!=7, "Derived3::cbase1y() failed");
+ check(d3.cbase2()!=8, "Derived3::cbase2() failed");
+ check(d3.abase1()!=9, "Derived3::abase1() failed");
+
+ //Test Bottom1
+ Bottom1 b1=new Bottom1();
+ check(b1.cbase1y()!=103, "Bottom1::cbase1y() failed");
+ check(b1.cbase2()!=104, "Bottom1::cbase2() failed");
+
+ //Test Bottom2
+ Bottom2 b2=new Bottom2();
+ check(b2.cbase1y()!=206, "Bottom2::cbase1y() failed");
+ check(b2.abase1()!=205, "Bottom2::abase1() failed");
+
+ //Test Bottom3
+ Bottom3 b3=new Bottom3();
+ check(b3.cbase1y()!=307, "Bottom3::cbase1y() failed");
+ check(b3.cbase2()!=308, "Bottom3::cbase2() failed");
+ check(b3.abase1()!=309, "Bottom3::abase1() failed");
+
+ //Test interfaces from c++ classes
+ CBase1 cb1=new CBase1SwigImpl();
+ CBase2 cb2=new CBase2SwigImpl();
+ check(cb1.cbase1y()!=1, "CBase1::cbase1y() failed");
+ check(cb2.cbase2()!=2, "CBase2::cbase2() failed");
+
+ //Test abstract class as return value
+ ABase1 ab1=d3.cloneit();
+ check(ab1.abase1()!=9, "Derived3::abase1() through ABase1 failed");
+
+ //Test concrete base class as return value
+ CBase1 cb6=d2.cloneit();
+ CBase2 cb7=d1.cloneit();
+ check(cb6.cbase1y()!=6, "Derived2::cbase1y() through CBase1 failed");
+ check(cb7.cbase2()!=4, "Derived1:cbase2() through ABase1 failed");
+
+ //Test multi inheritance
+ CBase1 cb3=new Derived1();
+ CBase1 cb4=new Derived3();
+ CBase2 cb5=new Derived3();
+ ABase1 ab6=new Derived2();
+ check(cb3.cbase1y()!=3, "Derived1::cbase1y() through CBase1 failed");
+ check(cb4.cbase1y()!=7, "Derived3::cbase1y() through CBase1 failed");
+ check(cb5.cbase2()!=8, "Derived3::cbase2() through CBase2 failed");
+ check(ab6.abase1()!=5, "Derived2::abase1() through ABase1 failed");
+
+ //Test base classes as parameter in C#
+ multiple_inheritance_abstract_runme mhar=new multiple_inheritance_abstract_runme();
+ check(mhar.jcbase1b(d1)!=3, "jcbase1b() through Derived1 as parameter failed");
+ check(mhar.jcbase1b(d2)!=6, "jcbase1b() through Derived2 as parameter failed");
+ check(mhar.jcbase1b(d3)!=7, "jcbase1b() through Derived3 as parameter failed");
+ check(mhar.jcbase2(d1)!=4, "jcbase2() through Derived1 as parameter failed");
+ check(mhar.jcbase2(d3)!=8, "jcbase2() through Derived3 as parameter failed");
+ check(mhar.jabase1(d2)!=5, "jabase1() through Derived2 as parameter failed");
+ check(mhar.jabase1(d3)!=9, "jabase1() through Derived3 as parameter failed");
+
+ //Value parameters
+ //Test CBase1 CBase2 as parameters (note slicing for Derived and Bottom classes)
+ check(multiple_inheritance_abstract.InputValCBase1(d1)!=1, "InputValCBase1(), Derived1 as a parameter failed");
+ check(multiple_inheritance_abstract.InputValCBase1(d2)!=1, "InputValCBase1(), Derived2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputValCBase1(d3)!=1, "InputValCBase1(), Derived3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputValCBase2(d3)!=2, "InputValCBase2(), Derived3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputValCBase2(d1)!=2, "InputValCBase2(), Derived1 as a parameter failed");
+ check(multiple_inheritance_abstract.InputValCBase1(cb1)!=1, "InputValCBase1(), CBase1 as a parameter failed");
+ check(multiple_inheritance_abstract.InputValCBase2(cb2)!=2, "InputValCBase2(), CBase2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputValCBase1(b1)!=1, "InputValCBase1(), Bottom1 as a parameter failed");
+ check(multiple_inheritance_abstract.InputValCBase1(b2)!=1, "InputValCBase1(), Bottom2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputValCBase1(b3)!=1, "InputValCBase1(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputValCBase2(b3)!=2, "InputValCBase2(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputValCBase2(b1)!=2, "InputValCBase2(), Bottom1 as a parameter failed");
+
+ //Pointer parameters
+ //Test ABase1 as a parameter
+ check(multiple_inheritance_abstract.InputPtrABase1(d2)!=5, "InputPtrABase1() through Derived2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputPtrABase1(d3)!=9, "InputPtrABase1() through Derived3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputPtrABase1(b2)!=205, "InputPtrABase1() through Bottom2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputPtrABase1(b3)!=309, "InputPtrABase1() through Bottom3 as a parameter failed");
+
+ //Test CBase1 CBase2 as parameters
+ check(multiple_inheritance_abstract.InputPtrCBase1(d1)!=3, "InputPtrCBase1(), Derived1 as a parameter failed");
+ check(multiple_inheritance_abstract.InputPtrCBase1(d2)!=6, "InputPtrCBase1(), Derived2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputPtrCBase1(d3)!=7, "InputPtrCBase1(), Derived3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputPtrCBase2(d3)!=8, "InputPtrCBase2(), Derived3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputPtrCBase2(d1)!=4, "InputPtrCBase2(), Derived1 as a parameter failed");
+ check(multiple_inheritance_abstract.InputPtrCBase1(cb1)!=1, "InputPtrCBase1(), CBase1 as a parameter failed");
+ check(multiple_inheritance_abstract.InputPtrCBase2(cb2)!=2, "InputPtrCBase2(), CBase2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputPtrCBase1(b1)!=103, "InputPtrCBase1(), Bottom1 as a parameter failed");
+ check(multiple_inheritance_abstract.InputPtrCBase1(b2)!=206, "InputPtrCBase1(), Bottom2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputPtrCBase1(b3)!=307, "InputPtrCBase1(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputPtrCBase2(b3)!=308, "InputPtrCBase2(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputPtrCBase2(b1)!=104, "InputPtrCBase2(), Bottom1 as a parameter failed");
+
+ //Reference parameters
+ //Test ABase1 as a parameter
+ check(multiple_inheritance_abstract.InputRefABase1(d2)!=5, "InputRefABase1() through Derived2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputRefABase1(d3)!=9, "InputRefABase1() through Derived3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputRefABase1(b2)!=205, "InputRefABase1() through Bottom2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputRefABase1(b3)!=309, "InputRefABase1() through Bottom3 as a parameter failed");
+
+ //Test CBase1 CBase2 as parameters
+ check(multiple_inheritance_abstract.InputRefCBase1(d1)!=3, "InputRefCBase1(), Derived1 as a parameter failed");
+ check(multiple_inheritance_abstract.InputRefCBase1(d2)!=6, "InputRefCBase1(), Derived2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputRefCBase1(d3)!=7, "InputRefCBase1(), Derived3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputRefCBase2(d3)!=8, "InputRefCBase2(), Derived3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputRefCBase2(d1)!=4, "InputRefCBase2(), Derived1 as a parameter failed");
+ check(multiple_inheritance_abstract.InputRefCBase1(cb1)!=1, "InputRefCBase1(), CBase1 as a parameter failed");
+ check(multiple_inheritance_abstract.InputRefCBase2(cb2)!=2, "InputRefCBase2(), CBase2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputRefCBase1(b1)!=103, "InputRefCBase1(), Bottom1 as a parameter failed");
+ check(multiple_inheritance_abstract.InputRefCBase1(b2)!=206, "InputRefCBase1(), Bottom2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputRefCBase1(b3)!=307, "InputRefCBase1(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputRefCBase2(b3)!=308, "InputRefCBase2(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputRefCBase2(b1)!=104, "InputRefCBase2(), Bottom1 as a parameter failed");
+
+ //Const reference pointer parameters
+ //Test ABase1 as a parameter
+ check(multiple_inheritance_abstract.InputCPtrRefABase1(d2)!=5, "InputCPtrRefABase1() through Derived2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputCPtrRefABase1(d3)!=9, "InputCPtrRefABase1() through Derived3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputCPtrRefABase1(b2)!=205, "InputCPtrRefABase1() through Bottom2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputCPtrRefABase1(b3)!=309, "InputCPtrRefABase1() through Bottom3 as a parameter failed");
+
+ //Test CBase1 CBase2 as parameters
+ check(multiple_inheritance_abstract.InputCPtrRefCBase1(d1)!=3, "InputCPtrRefCBase1(), Derived1 as a parameter failed");
+ check(multiple_inheritance_abstract.InputCPtrRefCBase1(d2)!=6, "InputCPtrRefCBase1(), Derived2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputCPtrRefCBase1(d3)!=7, "InputCPtrRefCBase1(), Derived3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputCPtrRefCBase2(d3)!=8, "InputCPtrRefCBase2(), Derived3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputCPtrRefCBase2(d1)!=4, "InputCPtrRefCBase2(), Derived1 as a parameter failed");
+ check(multiple_inheritance_abstract.InputCPtrRefCBase1(cb1)!=1, "InputCPtrRefCBase1(), CBase1 as a parameter failed");
+ check(multiple_inheritance_abstract.InputCPtrRefCBase2(cb2)!=2, "InputCPtrRefCBase2(), CBase2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputCPtrRefCBase1(b1)!=103, "InputCPtrRefCBase1(), Bottom1 as a parameter failed");
+ check(multiple_inheritance_abstract.InputCPtrRefCBase1(b2)!=206, "InputCPtrRefCBase1(), Bottom2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputCPtrRefCBase1(b3)!=307, "InputCPtrRefCBase1(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputCPtrRefCBase2(b3)!=308, "InputCPtrRefCBase2(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputCPtrRefCBase2(b1)!=104, "InputCPtrRefCBase2(), Bottom1 as a parameter failed");
+
+ //Derived classes as parameters
+ check(multiple_inheritance_abstract.InputValDerived1(d1)!=3+4, "InputValDerived1() failed");
+ check(multiple_inheritance_abstract.InputValDerived2(d2)!=6+5, "InputValDerived2() failed");
+ check(multiple_inheritance_abstract.InputValDerived3(d3)!=7+8+9, "InputValDerived3() failed");
+
+ check(multiple_inheritance_abstract.InputRefDerived1(d1)!=3+4, "InputRefDerived1() failed");
+ check(multiple_inheritance_abstract.InputRefDerived2(d2)!=6+5, "InputRefDerived2() failed");
+ check(multiple_inheritance_abstract.InputRefDerived3(d3)!=7+8+9, "InputRefDerived3() failed");
+
+ check(multiple_inheritance_abstract.InputPtrDerived1(d1)!=3+4, "InputPtrDerived1() failed");
+ check(multiple_inheritance_abstract.InputPtrDerived2(d2)!=6+5, "InputPtrDerived2() failed");
+ check(multiple_inheritance_abstract.InputPtrDerived3(d3)!=7+8+9, "InputPtrDerived3() failed");
+
+ check(multiple_inheritance_abstract.InputCPtrRefDerived1(d1)!=3+4, "InputCPtrRefDerived1() failed");
+ check(multiple_inheritance_abstract.InputCPtrRefDerived2(d2)!=6+5, "InputCPtrRefDerived2() failed");
+ check(multiple_inheritance_abstract.InputCPtrRefDerived3(d3)!=7+8+9, "InputCPtrRefDerived3() failed");
+
+ //Bottom classes as Derived parameters
+ check(multiple_inheritance_abstract.InputValDerived1(b1)!=3+4, "InputValDerived1() failed");
+ check(multiple_inheritance_abstract.InputValDerived2(b2)!=6+5, "InputValDerived2() failed");
+ check(multiple_inheritance_abstract.InputValDerived3(b3)!=7+8+9, "InputValDerived3() failed");
+
+ check(multiple_inheritance_abstract.InputRefDerived1(b1)!=103+104, "InputRefDerived1() failed");
+ check(multiple_inheritance_abstract.InputRefDerived2(b2)!=206+205, "InputRefDerived2() failed");
+ check(multiple_inheritance_abstract.InputRefDerived3(b3)!=307+308+309, "InputRefDerived3() failed");
+
+ check(multiple_inheritance_abstract.InputPtrDerived1(b1)!=103+104, "InputPtrDerived1() failed");
+ check(multiple_inheritance_abstract.InputPtrDerived2(b2)!=206+205, "InputPtrDerived2() failed");
+ check(multiple_inheritance_abstract.InputPtrDerived3(b3)!=307+308+309, "InputPtrDerived3() failed");
+
+ check(multiple_inheritance_abstract.InputCPtrRefDerived1(b1)!=103+104, "InputCPtrRefDerived1() failed");
+ check(multiple_inheritance_abstract.InputCPtrRefDerived2(b2)!=206+205, "InputCPtrRefDerived2() failed");
+ check(multiple_inheritance_abstract.InputCPtrRefDerived3(b3)!=307+308+309, "InputCPtrRefDerived3() failed");
+
+ //Bottom classes as Bottom parameters
+ check(multiple_inheritance_abstract.InputValBottom1(b1)!=103+104, "InputValBottom1() failed");
+ check(multiple_inheritance_abstract.InputValBottom2(b2)!=206+205, "InputValBottom2() failed");
+ check(multiple_inheritance_abstract.InputValBottom3(b3)!=307+308+309, "InputValBottom3() failed");
+
+ check(multiple_inheritance_abstract.InputRefBottom1(b1)!=103+104, "InputRefBottom1() failed");
+ check(multiple_inheritance_abstract.InputRefBottom2(b2)!=206+205, "InputRefBottom2() failed");
+ check(multiple_inheritance_abstract.InputRefBottom3(b3)!=307+308+309, "InputRefBottom3() failed");
+
+ check(multiple_inheritance_abstract.InputPtrBottom1(b1)!=103+104, "InputPtrBottom1() failed");
+ check(multiple_inheritance_abstract.InputPtrBottom2(b2)!=206+205, "InputPtrBottom2() failed");
+ check(multiple_inheritance_abstract.InputPtrBottom3(b3)!=307+308+309, "InputPtrBottom3() failed");
+
+ check(multiple_inheritance_abstract.InputCPtrRefBottom1(b1)!=103+104, "InputCPtrRefBottom1() failed");
+ check(multiple_inheritance_abstract.InputCPtrRefBottom2(b2)!=206+205, "InputCPtrRefBottom2() failed");
+ check(multiple_inheritance_abstract.InputCPtrRefBottom3(b3)!=307+308+309, "InputCPtrRefBottom3() failed");
+ // Return pointers
+ check(multiple_inheritance_abstract.MakePtrDerived1_CBase1().cbase1y()!=3, "MakePtrDerived1_CBase1 failed");
+ check(multiple_inheritance_abstract.MakePtrDerived1_CBase2().cbase2()!=4, "MakePtrDerived1_CBase2 failed");
+ check(multiple_inheritance_abstract.MakePtrDerived2_CBase1().cbase1y()!=6, "MakePtrDerived2_CBase1 failed");
+ check(multiple_inheritance_abstract.MakePtrDerived2_ABase1().abase1()!=5, "MakePtrDerived2_ABase1 failed");
+ check(multiple_inheritance_abstract.MakePtrDerived3_ABase1().abase1()!=9, "MakePtrDerived3_ABase1 failed");
+ check(multiple_inheritance_abstract.MakePtrDerived3_CBase1().cbase1y()!=7, "MakePtrDerived3_CBase1 failed");
+ check(multiple_inheritance_abstract.MakePtrDerived3_CBase2().cbase2()!=8, "MakePtrDerived3_CBase2 failed");
+
+ // Return references
+ check(multiple_inheritance_abstract.MakeRefDerived1_CBase1().cbase1y()!=3, "MakeRefDerived1_CBase1 failed");
+ check(multiple_inheritance_abstract.MakeRefDerived1_CBase2().cbase2()!=4, "MakeRefDerived1_CBase2 failed");
+ check(multiple_inheritance_abstract.MakeRefDerived2_CBase1().cbase1y()!=6, "MakeRefDerived2_CBase1 failed");
+ check(multiple_inheritance_abstract.MakeRefDerived2_ABase1().abase1()!=5, "MakeRefDerived2_ABase1 failed");
+ check(multiple_inheritance_abstract.MakeRefDerived3_ABase1().abase1()!=9, "MakeRefDerived3_ABase1 failed");
+ check(multiple_inheritance_abstract.MakeRefDerived3_CBase1().cbase1y()!=7, "MakeRefDerived3_CBase1 failed");
+ check(multiple_inheritance_abstract.MakeRefDerived3_CBase2().cbase2()!=8, "MakeRefDerived3_CBase2 failed");
+
+ // Return by value (sliced objects)
+ check(multiple_inheritance_abstract.MakeValDerived1_CBase1().cbase1y()!=1, "MakeValDerived1_CBase1 failed");
+ check(multiple_inheritance_abstract.MakeValDerived1_CBase2().cbase2()!=2, "MakeValDerived1_CBase2 failed");
+ check(multiple_inheritance_abstract.MakeValDerived2_CBase1().cbase1y()!=1, "MakeValDerived2_CBase1 failed");
+ check(multiple_inheritance_abstract.MakeValDerived3_CBase1().cbase1y()!=1, "MakeValDerived3_CBase1 failed");
+ check(multiple_inheritance_abstract.MakeValDerived3_CBase2().cbase2()!=2, "MakeValDerived3_CBase2 failed");
+
+ }
+}
diff --git a/Examples/test-suite/csharp/multiple_inheritance_interfaces_runme.cs b/Examples/test-suite/csharp/multiple_inheritance_interfaces_runme.cs
new file mode 100644
index 000000000..c786ff9b3
--- /dev/null
+++ b/Examples/test-suite/csharp/multiple_inheritance_interfaces_runme.cs
@@ -0,0 +1,87 @@
+using System;
+using System.Collections.Generic;
+using multiple_inheritance_interfacesNamespace;
+
+public class multiple_inheritance_interfaces_runme {
+
+ static string SortArrayToString(string[] types) {
+ Array.Sort<string>(types);
+ return string.Join(" ", types);
+ }
+
+ static string SortArrayToString(Type[] types) {
+ List<string> stypes = new List<string>();
+ foreach (Type t in types)
+ stypes.Add(t.Name);
+ return SortArrayToString(stypes.ToArray());
+ }
+
+
+ private static void checkBaseAndInterfaces(Type cls, bool interfaceExpected, string baseClass, string[] interfaces) {
+ string[] expectedInterfaces = new string[interfaces.Length + (interfaceExpected ? 0 : 1)];
+ for (int i=0; i<interfaces.Length; ++i)
+ expectedInterfaces[i] = interfaces[i];
+ if (!interfaceExpected)
+ expectedInterfaces[interfaces.Length] = "IDisposable";
+ Type[] actualInterfaces = cls.GetInterfaces();
+ string expectedInterfacesString = SortArrayToString(expectedInterfaces);
+ string actualInterfacesString = SortArrayToString(actualInterfaces);
+ if (expectedInterfacesString != actualInterfacesString)
+ throw new Exception("Expected interfaces for " + cls.Name + ": \n" + expectedInterfacesString + "\n" + "Actual interfaces: \n" + actualInterfacesString);
+
+ string expectedBaseString = null;
+ if (interfaceExpected) {
+ // expecting an interface
+ if (!cls.IsInterface)
+ throw new Exception(cls.Name + " should be an interface but is not");
+ expectedBaseString = string.IsNullOrEmpty(baseClass) ? "" : "multiple_inheritance_interfacesNamespace." + baseClass;
+ } else {
+ // expecting a class
+ if (cls.IsInterface)
+ throw new Exception(cls.Name + " is an interface but it should not be");
+ expectedBaseString = string.IsNullOrEmpty(baseClass) ? "Object" : baseClass;
+ }
+
+ string actualBaseString = cls.BaseType == null ? "" : cls.BaseType.Name;
+ if (expectedBaseString != actualBaseString)
+ throw new Exception("Expected base for " + cls.Name + ": [" + expectedBaseString + "]" + " Actual base: [" + actualBaseString + "]");
+ }
+
+ public static void Main() {
+ // Note that we can't get just the immediate interface
+ // Type.GetInterfaces() returns all interfaces up the inheritance hierarchy
+ checkBaseAndInterfaces(typeof(IA), true, "", new string[] {});
+ checkBaseAndInterfaces(typeof(IB), true, "", new string[] {});
+ checkBaseAndInterfaces(typeof(IC), true, "", new string[] {"IA", "IB"});
+ checkBaseAndInterfaces(typeof(A), false, "", new string[] {"IA"});
+ checkBaseAndInterfaces(typeof(B), false, "", new string[] {"IB"});
+ checkBaseAndInterfaces(typeof(C), false, "", new string[] {"IA", "IB", "IC"});
+ checkBaseAndInterfaces(typeof(D), false, "", new string[] {"IA", "IB", "IC"});
+ checkBaseAndInterfaces(typeof(E), false, "D", new string[] {"IA", "IB", "IC"});
+
+ checkBaseAndInterfaces(typeof(IJ), true, "", new string[] {});
+ checkBaseAndInterfaces(typeof(IK), true, "", new string[] {"IJ"});
+ checkBaseAndInterfaces(typeof(IL), true, "", new string[] {"IJ", "IK"});
+ checkBaseAndInterfaces(typeof(J), false, "", new string[] {"IJ"});
+ checkBaseAndInterfaces(typeof(K), false, "", new string[] {"IJ", "IK"});
+ checkBaseAndInterfaces(typeof(L), false, "", new string[] {"IJ", "IK", "IL"});
+ checkBaseAndInterfaces(typeof(M), false, "", new string[] {"IJ", "IK", "IL"});
+
+ checkBaseAndInterfaces(typeof(P), false, "", new string[] {});
+ checkBaseAndInterfaces(typeof(IQ), true, "", new string[] {});
+ checkBaseAndInterfaces(typeof(Q), false, "", new string[] {"IQ"});
+ checkBaseAndInterfaces(typeof(R), false, "P", new string[] {"IQ"});
+ checkBaseAndInterfaces(typeof(S), false, "P", new string[] {"IQ"});
+ checkBaseAndInterfaces(typeof(T), false, "", new string[] {"IQ"});
+ checkBaseAndInterfaces(typeof(U), false, "R", new string[] {"IQ"});
+ checkBaseAndInterfaces(typeof(V), false, "S", new string[] {"IQ"});
+ checkBaseAndInterfaces(typeof(W), false, "T", new string[] {"IQ"});
+
+ // overloaded methods check
+ D d = new D();
+ d.ia();
+ d.ia(10);
+ d.ia("bye");
+ d.ia("bye", false);
+ }
+}
diff --git a/Examples/test-suite/csharp/multiple_inheritance_nspace_runme.cs b/Examples/test-suite/csharp/multiple_inheritance_nspace_runme.cs
new file mode 100644
index 000000000..6ed13a6ff
--- /dev/null
+++ b/Examples/test-suite/csharp/multiple_inheritance_nspace_runme.cs
@@ -0,0 +1,246 @@
+using System;
+using multiple_inheritance_nspaceNamespace;
+using multiple_inheritance_nspaceNamespace.Space;
+
+public class multiple_inheritance_nspace_runme {
+
+ //Test base class as a parameter in C#
+ int jcbase1b(CBase1SwigInterface cb1){
+ return cb1.cbase1y();
+ }
+ int jabase1(ABase1SwigInterface ab1){
+ return ab1.abase1();
+ }
+ int jcbase2(CBase2SwigInterface cb2){
+ return cb2.cbase2();
+ }
+
+ public static void check(bool fail, string msg) {
+ if (fail)
+ throw new Exception(msg);
+ }
+
+ public static void Main() {
+ //Test Derived1
+ Derived1 d1=new Derived1();
+ check(d1.cbase1y()!=3, "Derived1::cbase1y() failed");
+ check(d1.cbase2()!=4, "Derived1::cbase2() failed");
+
+ //Test Derived2
+ Derived2 d2=new Derived2();
+ check(d2.cbase1y()!=6, "Derived2::cbase1y() failed");
+ check(d2.abase1()!=5, "Derived2::abase1() failed");
+
+ //Test Derived3
+ Derived3 d3=new Derived3();
+ check(d3.cbase1y()!=7, "Derived3::cbase1y() failed");
+ check(d3.cbase2()!=8, "Derived3::cbase2() failed");
+ check(d3.abase1()!=9, "Derived3::abase1() failed");
+
+ //Test Bottom1
+ Bottom1 b1=new Bottom1();
+ check(b1.cbase1y()!=103, "Bottom1::cbase1y() failed");
+ check(b1.cbase2()!=104, "Bottom1::cbase2() failed");
+
+ //Test Bottom2
+ Bottom2 b2=new Bottom2();
+ check(b2.cbase1y()!=206, "Bottom2::cbase1y() failed");
+ check(b2.abase1()!=205, "Bottom2::abase1() failed");
+
+ //Test Bottom3
+ Bottom3 b3=new Bottom3();
+ check(b3.cbase1y()!=307, "Bottom3::cbase1y() failed");
+ check(b3.cbase2()!=308, "Bottom3::cbase2() failed");
+ check(b3.abase1()!=309, "Bottom3::abase1() failed");
+
+ //Test interfaces from c++ classes
+ CBase1SwigInterface cb1=new CBase1();
+ CBase2SwigInterface cb2=new CBase2();
+ check(cb1.cbase1y()!=1, "CBase1::cbase1y() failed");
+ check(cb2.cbase2()!=2, "CBase2::cbase2() failed");
+
+ //Test nspace class as return value
+ ABase1SwigInterface ab1=d3.cloneit();
+ check(ab1.abase1()!=9, "Derived3::abase1() through ABase1 failed");
+
+ //Test concrete base class as return value
+ CBase1SwigInterface cb6=d2.cloneit();
+ CBase2SwigInterface cb7=d1.cloneit();
+ check(cb6.cbase1y()!=6, "Derived2::cbase1y() through CBase1 failed");
+ check(cb7.cbase2()!=4, "Derived1:cbase2() through ABase1 failed");
+
+ //Test multi inheritance
+ CBase1SwigInterface cb3=new Derived1();
+ CBase1SwigInterface cb4=new Derived3();
+ CBase2SwigInterface cb5=new Derived3();
+ ABase1SwigInterface ab6=new Derived2();
+ check(cb3.cbase1y()!=3, "Derived1::cbase1y() through CBase1 failed");
+ check(cb4.cbase1y()!=7, "Derived3::cbase1y() through CBase1 failed");
+ check(cb5.cbase2()!=8, "Derived3::cbase2() through CBase2 failed");
+ check(ab6.abase1()!=5, "Derived2::abase1() through ABase1 failed");
+
+ //Test base classes as parameter in C#
+ multiple_inheritance_nspace_runme mhar=new multiple_inheritance_nspace_runme();
+ check(mhar.jcbase1b(d1)!=3, "jcbase1b() through Derived1 as parameter failed");
+ check(mhar.jcbase1b(d2)!=6, "jcbase1b() through Derived2 as parameter failed");
+ check(mhar.jcbase1b(d3)!=7, "jcbase1b() through Derived3 as parameter failed");
+ check(mhar.jcbase2(d1)!=4, "jcbase2() through Derived1 as parameter failed");
+ check(mhar.jcbase2(d3)!=8, "jcbase2() through Derived3 as parameter failed");
+ check(mhar.jabase1(d2)!=5, "jabase1() through Derived2 as parameter failed");
+ check(mhar.jabase1(d3)!=9, "jabase1() through Derived3 as parameter failed");
+
+ //Value parameters
+ //Test CBase1 CBase2 as parameters (note slicing for Derived and Bottom classes)
+ check(multiple_inheritance_nspace.InputValCBase1(d1)!=1, "InputValCBase1(), Derived1 as a parameter failed");
+ check(multiple_inheritance_nspace.InputValCBase1(d2)!=1, "InputValCBase1(), Derived2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputValCBase1(d3)!=1, "InputValCBase1(), Derived3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputValCBase2(d3)!=2, "InputValCBase2(), Derived3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputValCBase2(d1)!=2, "InputValCBase2(), Derived1 as a parameter failed");
+ check(multiple_inheritance_nspace.InputValCBase1(cb1)!=1, "InputValCBase1(), CBase1 as a parameter failed");
+ check(multiple_inheritance_nspace.InputValCBase2(cb2)!=2, "InputValCBase2(), CBase2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputValCBase1(b1)!=1, "InputValCBase1(), Bottom1 as a parameter failed");
+ check(multiple_inheritance_nspace.InputValCBase1(b2)!=1, "InputValCBase1(), Bottom2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputValCBase1(b3)!=1, "InputValCBase1(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputValCBase2(b3)!=2, "InputValCBase2(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputValCBase2(b1)!=2, "InputValCBase2(), Bottom1 as a parameter failed");
+
+ //Pointer parameters
+ //Test ABase1 as a parameter
+ check(multiple_inheritance_nspace.InputPtrABase1(d2)!=5, "InputPtrABase1() through Derived2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputPtrABase1(d3)!=9, "InputPtrABase1() through Derived3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputPtrABase1(b2)!=205, "InputPtrABase1() through Bottom2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputPtrABase1(b3)!=309, "InputPtrABase1() through Bottom3 as a parameter failed");
+
+ //Test CBase1 CBase2 as parameters
+ check(multiple_inheritance_nspace.InputPtrCBase1(d1)!=3, "InputPtrCBase1(), Derived1 as a parameter failed");
+ check(multiple_inheritance_nspace.InputPtrCBase1(d2)!=6, "InputPtrCBase1(), Derived2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputPtrCBase1(d3)!=7, "InputPtrCBase1(), Derived3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputPtrCBase2(d3)!=8, "InputPtrCBase2(), Derived3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputPtrCBase2(d1)!=4, "InputPtrCBase2(), Derived1 as a parameter failed");
+ check(multiple_inheritance_nspace.InputPtrCBase1(cb1)!=1, "InputPtrCBase1(), CBase1 as a parameter failed");
+ check(multiple_inheritance_nspace.InputPtrCBase2(cb2)!=2, "InputPtrCBase2(), CBase2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputPtrCBase1(b1)!=103, "InputPtrCBase1(), Bottom1 as a parameter failed");
+ check(multiple_inheritance_nspace.InputPtrCBase1(b2)!=206, "InputPtrCBase1(), Bottom2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputPtrCBase1(b3)!=307, "InputPtrCBase1(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputPtrCBase2(b3)!=308, "InputPtrCBase2(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputPtrCBase2(b1)!=104, "InputPtrCBase2(), Bottom1 as a parameter failed");
+
+ //Reference parameters
+ //Test ABase1 as a parameter
+ check(multiple_inheritance_nspace.InputRefABase1(d2)!=5, "InputRefABase1() through Derived2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputRefABase1(d3)!=9, "InputRefABase1() through Derived3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputRefABase1(b2)!=205, "InputRefABase1() through Bottom2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputRefABase1(b3)!=309, "InputRefABase1() through Bottom3 as a parameter failed");
+
+ //Test CBase1 CBase2 as parameters
+ check(multiple_inheritance_nspace.InputRefCBase1(d1)!=3, "InputRefCBase1(), Derived1 as a parameter failed");
+ check(multiple_inheritance_nspace.InputRefCBase1(d2)!=6, "InputRefCBase1(), Derived2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputRefCBase1(d3)!=7, "InputRefCBase1(), Derived3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputRefCBase2(d3)!=8, "InputRefCBase2(), Derived3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputRefCBase2(d1)!=4, "InputRefCBase2(), Derived1 as a parameter failed");
+ check(multiple_inheritance_nspace.InputRefCBase1(cb1)!=1, "InputRefCBase1(), CBase1 as a parameter failed");
+ check(multiple_inheritance_nspace.InputRefCBase2(cb2)!=2, "InputRefCBase2(), CBase2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputRefCBase1(b1)!=103, "InputRefCBase1(), Bottom1 as a parameter failed");
+ check(multiple_inheritance_nspace.InputRefCBase1(b2)!=206, "InputRefCBase1(), Bottom2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputRefCBase1(b3)!=307, "InputRefCBase1(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputRefCBase2(b3)!=308, "InputRefCBase2(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputRefCBase2(b1)!=104, "InputRefCBase2(), Bottom1 as a parameter failed");
+
+ //Const reference pointer parameters
+ //Test ABase1 as a parameter
+ check(multiple_inheritance_nspace.InputCPtrRefABase1(d2)!=5, "InputCPtrRefABase1() through Derived2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputCPtrRefABase1(d3)!=9, "InputCPtrRefABase1() through Derived3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputCPtrRefABase1(b2)!=205, "InputCPtrRefABase1() through Bottom2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputCPtrRefABase1(b3)!=309, "InputCPtrRefABase1() through Bottom3 as a parameter failed");
+
+ //Test CBase1 CBase2 as parameters
+ check(multiple_inheritance_nspace.InputCPtrRefCBase1(d1)!=3, "InputCPtrRefCBase1(), Derived1 as a parameter failed");
+ check(multiple_inheritance_nspace.InputCPtrRefCBase1(d2)!=6, "InputCPtrRefCBase1(), Derived2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputCPtrRefCBase1(d3)!=7, "InputCPtrRefCBase1(), Derived3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputCPtrRefCBase2(d3)!=8, "InputCPtrRefCBase2(), Derived3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputCPtrRefCBase2(d1)!=4, "InputCPtrRefCBase2(), Derived1 as a parameter failed");
+ check(multiple_inheritance_nspace.InputCPtrRefCBase1(cb1)!=1, "InputCPtrRefCBase1(), CBase1 as a parameter failed");
+ check(multiple_inheritance_nspace.InputCPtrRefCBase2(cb2)!=2, "InputCPtrRefCBase2(), CBase2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputCPtrRefCBase1(b1)!=103, "InputCPtrRefCBase1(), Bottom1 as a parameter failed");
+ check(multiple_inheritance_nspace.InputCPtrRefCBase1(b2)!=206, "InputCPtrRefCBase1(), Bottom2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputCPtrRefCBase1(b3)!=307, "InputCPtrRefCBase1(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputCPtrRefCBase2(b3)!=308, "InputCPtrRefCBase2(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputCPtrRefCBase2(b1)!=104, "InputCPtrRefCBase2(), Bottom1 as a parameter failed");
+
+ //Derived classes as parameters
+ check(multiple_inheritance_nspace.InputValDerived1(d1)!=3+4, "InputValDerived1() failed");
+ check(multiple_inheritance_nspace.InputValDerived2(d2)!=6+5, "InputValDerived2() failed");
+ check(multiple_inheritance_nspace.InputValDerived3(d3)!=7+8+9, "InputValDerived3() failed");
+
+ check(multiple_inheritance_nspace.InputRefDerived1(d1)!=3+4, "InputRefDerived1() failed");
+ check(multiple_inheritance_nspace.InputRefDerived2(d2)!=6+5, "InputRefDerived2() failed");
+ check(multiple_inheritance_nspace.InputRefDerived3(d3)!=7+8+9, "InputRefDerived3() failed");
+
+ check(multiple_inheritance_nspace.InputPtrDerived1(d1)!=3+4, "InputPtrDerived1() failed");
+ check(multiple_inheritance_nspace.InputPtrDerived2(d2)!=6+5, "InputPtrDerived2() failed");
+ check(multiple_inheritance_nspace.InputPtrDerived3(d3)!=7+8+9, "InputPtrDerived3() failed");
+
+ check(multiple_inheritance_nspace.InputCPtrRefDerived1(d1)!=3+4, "InputCPtrRefDerived1() failed");
+ check(multiple_inheritance_nspace.InputCPtrRefDerived2(d2)!=6+5, "InputCPtrRefDerived2() failed");
+ check(multiple_inheritance_nspace.InputCPtrRefDerived3(d3)!=7+8+9, "InputCPtrRefDerived3() failed");
+
+ //Bottom classes as Derived parameters
+ check(multiple_inheritance_nspace.InputValDerived1(b1)!=3+4, "InputValDerived1() failed");
+ check(multiple_inheritance_nspace.InputValDerived2(b2)!=6+5, "InputValDerived2() failed");
+ check(multiple_inheritance_nspace.InputValDerived3(b3)!=7+8+9, "InputValDerived3() failed");
+
+ check(multiple_inheritance_nspace.InputRefDerived1(b1)!=103+104, "InputRefDerived1() failed");
+ check(multiple_inheritance_nspace.InputRefDerived2(b2)!=206+205, "InputRefDerived2() failed");
+ check(multiple_inheritance_nspace.InputRefDerived3(b3)!=307+308+309, "InputRefDerived3() failed");
+
+ check(multiple_inheritance_nspace.InputPtrDerived1(b1)!=103+104, "InputPtrDerived1() failed");
+ check(multiple_inheritance_nspace.InputPtrDerived2(b2)!=206+205, "InputPtrDerived2() failed");
+ check(multiple_inheritance_nspace.InputPtrDerived3(b3)!=307+308+309, "InputPtrDerived3() failed");
+
+ check(multiple_inheritance_nspace.InputCPtrRefDerived1(b1)!=103+104, "InputCPtrRefDerived1() failed");
+ check(multiple_inheritance_nspace.InputCPtrRefDerived2(b2)!=206+205, "InputCPtrRefDerived2() failed");
+ check(multiple_inheritance_nspace.InputCPtrRefDerived3(b3)!=307+308+309, "InputCPtrRefDerived3() failed");
+
+ //Bottom classes as Bottom parameters
+ check(multiple_inheritance_nspace.InputValBottom1(b1)!=103+104, "InputValBottom1() failed");
+ check(multiple_inheritance_nspace.InputValBottom2(b2)!=206+205, "InputValBottom2() failed");
+ check(multiple_inheritance_nspace.InputValBottom3(b3)!=307+308+309, "InputValBottom3() failed");
+
+ check(multiple_inheritance_nspace.InputRefBottom1(b1)!=103+104, "InputRefBottom1() failed");
+ check(multiple_inheritance_nspace.InputRefBottom2(b2)!=206+205, "InputRefBottom2() failed");
+ check(multiple_inheritance_nspace.InputRefBottom3(b3)!=307+308+309, "InputRefBottom3() failed");
+
+ check(multiple_inheritance_nspace.InputPtrBottom1(b1)!=103+104, "InputPtrBottom1() failed");
+ check(multiple_inheritance_nspace.InputPtrBottom2(b2)!=206+205, "InputPtrBottom2() failed");
+ check(multiple_inheritance_nspace.InputPtrBottom3(b3)!=307+308+309, "InputPtrBottom3() failed");
+
+ check(multiple_inheritance_nspace.InputCPtrRefBottom1(b1)!=103+104, "InputCPtrRefBottom1() failed");
+ check(multiple_inheritance_nspace.InputCPtrRefBottom2(b2)!=206+205, "InputCPtrRefBottom2() failed");
+ check(multiple_inheritance_nspace.InputCPtrRefBottom3(b3)!=307+308+309, "InputCPtrRefBottom3() failed");
+ // Return pointers
+ check(multiple_inheritance_nspace.MakePtrDerived1_CBase1().cbase1y()!=3, "MakePtrDerived1_CBase1 failed");
+ check(multiple_inheritance_nspace.MakePtrDerived1_CBase2().cbase2()!=4, "MakePtrDerived1_CBase2 failed");
+ check(multiple_inheritance_nspace.MakePtrDerived2_CBase1().cbase1y()!=6, "MakePtrDerived2_CBase1 failed");
+ check(multiple_inheritance_nspace.MakePtrDerived2_ABase1().abase1()!=5, "MakePtrDerived2_ABase1 failed");
+ check(multiple_inheritance_nspace.MakePtrDerived3_ABase1().abase1()!=9, "MakePtrDerived3_ABase1 failed");
+ check(multiple_inheritance_nspace.MakePtrDerived3_CBase1().cbase1y()!=7, "MakePtrDerived3_CBase1 failed");
+ check(multiple_inheritance_nspace.MakePtrDerived3_CBase2().cbase2()!=8, "MakePtrDerived3_CBase2 failed");
+
+ // Return references
+ check(multiple_inheritance_nspace.MakeRefDerived1_CBase1().cbase1y()!=3, "MakeRefDerived1_CBase1 failed");
+ check(multiple_inheritance_nspace.MakeRefDerived1_CBase2().cbase2()!=4, "MakeRefDerived1_CBase2 failed");
+ check(multiple_inheritance_nspace.MakeRefDerived2_CBase1().cbase1y()!=6, "MakeRefDerived2_CBase1 failed");
+ check(multiple_inheritance_nspace.MakeRefDerived2_ABase1().abase1()!=5, "MakeRefDerived2_ABase1 failed");
+ check(multiple_inheritance_nspace.MakeRefDerived3_ABase1().abase1()!=9, "MakeRefDerived3_ABase1 failed");
+ check(multiple_inheritance_nspace.MakeRefDerived3_CBase1().cbase1y()!=7, "MakeRefDerived3_CBase1 failed");
+ check(multiple_inheritance_nspace.MakeRefDerived3_CBase2().cbase2()!=8, "MakeRefDerived3_CBase2 failed");
+
+ // Return by value (sliced objects)
+ check(multiple_inheritance_nspace.MakeValDerived1_CBase1().cbase1y()!=1, "MakeValDerived1_CBase1 failed");
+ check(multiple_inheritance_nspace.MakeValDerived1_CBase2().cbase2()!=2, "MakeValDerived1_CBase2 failed");
+ check(multiple_inheritance_nspace.MakeValDerived2_CBase1().cbase1y()!=1, "MakeValDerived2_CBase1 failed");
+ check(multiple_inheritance_nspace.MakeValDerived3_CBase1().cbase1y()!=1, "MakeValDerived3_CBase1 failed");
+ check(multiple_inheritance_nspace.MakeValDerived3_CBase2().cbase2()!=2, "MakeValDerived3_CBase2 failed");
+
+ }
+}
diff --git a/Examples/test-suite/csharp/multiple_inheritance_shared_ptr_runme.cs b/Examples/test-suite/csharp/multiple_inheritance_shared_ptr_runme.cs
new file mode 100644
index 000000000..13ffc62a4
--- /dev/null
+++ b/Examples/test-suite/csharp/multiple_inheritance_shared_ptr_runme.cs
@@ -0,0 +1,329 @@
+using System;
+using multiple_inheritance_shared_ptrNamespace;
+
+public class multiple_inheritance_shared_ptr_runme {
+
+ //Test base class as a parameter in C#
+ int jcbase1b(CBase1 cb1){
+ return cb1.cbase1y();
+ }
+ int jabase1(ABase1 ab1){
+ return ab1.abase1();
+ }
+ int jcbase2(CBase2 cb2){
+ return cb2.cbase2();
+ }
+
+ public static void check(bool fail, string msg) {
+ if (fail)
+ throw new Exception(msg);
+ }
+
+ public static void Main() {
+ //Test Derived1
+ Derived1 d1=new Derived1();
+ check(d1.cbase1y()!=3, "Derived1::cbase1y() failed");
+ check(d1.cbase2()!=4, "Derived1::cbase2() failed");
+
+ //Test Derived2
+ Derived2 d2=new Derived2();
+ check(d2.cbase1y()!=6, "Derived2::cbase1y() failed");
+ check(d2.abase1()!=5, "Derived2::abase1() failed");
+
+ //Test Derived3
+ Derived3 d3=new Derived3();
+ check(d3.cbase1y()!=7, "Derived3::cbase1y() failed");
+ check(d3.cbase2()!=8, "Derived3::cbase2() failed");
+ check(d3.abase1()!=9, "Derived3::abase1() failed");
+
+ //Test Bottom1
+ Bottom1 b1=new Bottom1();
+ check(b1.cbase1y()!=103, "Bottom1::cbase1y() failed");
+ check(b1.cbase2()!=104, "Bottom1::cbase2() failed");
+
+ //Test Bottom2
+ Bottom2 b2=new Bottom2();
+ check(b2.cbase1y()!=206, "Bottom2::cbase1y() failed");
+ check(b2.abase1()!=205, "Bottom2::abase1() failed");
+
+ //Test Bottom3
+ Bottom3 b3=new Bottom3();
+ check(b3.cbase1y()!=307, "Bottom3::cbase1y() failed");
+ check(b3.cbase2()!=308, "Bottom3::cbase2() failed");
+ check(b3.abase1()!=309, "Bottom3::abase1() failed");
+
+ //Test interfaces from c++ classes
+ CBase1 cb1=new CBase1SwigImpl();
+ CBase2 cb2=new CBase2SwigImpl();
+ check(cb1.cbase1y()!=1, "CBase1::cbase1y() failed");
+ check(cb2.cbase2()!=2, "CBase2::cbase2() failed");
+
+ //Test abstract class as return value
+ ABase1 ab1=d3.cloneit();
+ check(ab1.abase1()!=9, "Derived3::abase1() through ABase1 failed");
+
+ //Test concrete base class as return value
+ CBase1 cb6=d2.cloneit();
+ CBase2 cb7=d1.cloneit();
+ check(cb6.cbase1y()!=6, "Derived2::cbase1y() through CBase1 failed");
+ check(cb7.cbase2()!=4, "Derived1:cbase2() through ABase1 failed");
+
+ //Test multi inheritance
+ CBase1 cb3=new Derived1();
+ CBase1 cb4=new Derived3();
+ CBase2 cb5=new Derived3();
+ ABase1 ab6=new Derived2();
+ check(cb3.cbase1y()!=3, "Derived1::cbase1y() through CBase1 failed");
+ check(cb4.cbase1y()!=7, "Derived3::cbase1y() through CBase1 failed");
+ check(cb5.cbase2()!=8, "Derived3::cbase2() through CBase2 failed");
+ check(ab6.abase1()!=5, "Derived2::abase1() through ABase1 failed");
+
+ //Test base classes as parameter in C#
+ multiple_inheritance_shared_ptr_runme mhar=new multiple_inheritance_shared_ptr_runme();
+ check(mhar.jcbase1b(d1)!=3, "jcbase1b() through Derived1 as parameter failed");
+ check(mhar.jcbase1b(d2)!=6, "jcbase1b() through Derived2 as parameter failed");
+ check(mhar.jcbase1b(d3)!=7, "jcbase1b() through Derived3 as parameter failed");
+ check(mhar.jcbase2(d1)!=4, "jcbase2() through Derived1 as parameter failed");
+ check(mhar.jcbase2(d3)!=8, "jcbase2() through Derived3 as parameter failed");
+ check(mhar.jabase1(d2)!=5, "jabase1() through Derived2 as parameter failed");
+ check(mhar.jabase1(d3)!=9, "jabase1() through Derived3 as parameter failed");
+
+ //Value parameters
+ //Test CBase1 CBase2 as parameters (note slicing for Derived and Bottom classes)
+ check(multiple_inheritance_shared_ptr.InputValCBase1(d1)!=1, "InputValCBase1(), Derived1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputValCBase1(d2)!=1, "InputValCBase1(), Derived2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputValCBase1(d3)!=1, "InputValCBase1(), Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputValCBase2(d3)!=2, "InputValCBase2(), Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputValCBase2(d1)!=2, "InputValCBase2(), Derived1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputValCBase1(cb1)!=1, "InputValCBase1(), CBase1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputValCBase2(cb2)!=2, "InputValCBase2(), CBase2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputValCBase1(b1)!=1, "InputValCBase1(), Bottom1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputValCBase1(b2)!=1, "InputValCBase1(), Bottom2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputValCBase1(b3)!=1, "InputValCBase1(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputValCBase2(b3)!=2, "InputValCBase2(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputValCBase2(b1)!=2, "InputValCBase2(), Bottom1 as a parameter failed");
+
+ //Pointer parameters
+ //Test ABase1 as a parameter
+ check(multiple_inheritance_shared_ptr.InputPtrABase1(d2)!=5, "InputPtrABase1() through Derived2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputPtrABase1(d3)!=9, "InputPtrABase1() through Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputPtrABase1(b2)!=205, "InputPtrABase1() through Bottom2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputPtrABase1(b3)!=309, "InputPtrABase1() through Bottom3 as a parameter failed");
+
+ //Test CBase1 CBase2 as parameters
+ check(multiple_inheritance_shared_ptr.InputPtrCBase1(d1)!=3, "InputPtrCBase1(), Derived1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputPtrCBase1(d2)!=6, "InputPtrCBase1(), Derived2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputPtrCBase1(d3)!=7, "InputPtrCBase1(), Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputPtrCBase2(d3)!=8, "InputPtrCBase2(), Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputPtrCBase2(d1)!=4, "InputPtrCBase2(), Derived1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputPtrCBase1(cb1)!=1, "InputPtrCBase1(), CBase1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputPtrCBase2(cb2)!=2, "InputPtrCBase2(), CBase2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputPtrCBase1(b1)!=103, "InputPtrCBase1(), Bottom1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputPtrCBase1(b2)!=206, "InputPtrCBase1(), Bottom2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputPtrCBase1(b3)!=307, "InputPtrCBase1(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputPtrCBase2(b3)!=308, "InputPtrCBase2(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputPtrCBase2(b1)!=104, "InputPtrCBase2(), Bottom1 as a parameter failed");
+
+ //Reference parameters
+ //Test ABase1 as a parameter
+ check(multiple_inheritance_shared_ptr.InputRefABase1(d2)!=5, "InputRefABase1() through Derived2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputRefABase1(d3)!=9, "InputRefABase1() through Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputRefABase1(b2)!=205, "InputRefABase1() through Bottom2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputRefABase1(b3)!=309, "InputRefABase1() through Bottom3 as a parameter failed");
+
+ //Test CBase1 CBase2 as parameters
+ check(multiple_inheritance_shared_ptr.InputRefCBase1(d1)!=3, "InputRefCBase1(), Derived1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputRefCBase1(d2)!=6, "InputRefCBase1(), Derived2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputRefCBase1(d3)!=7, "InputRefCBase1(), Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputRefCBase2(d3)!=8, "InputRefCBase2(), Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputRefCBase2(d1)!=4, "InputRefCBase2(), Derived1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputRefCBase1(cb1)!=1, "InputRefCBase1(), CBase1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputRefCBase2(cb2)!=2, "InputRefCBase2(), CBase2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputRefCBase1(b1)!=103, "InputRefCBase1(), Bottom1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputRefCBase1(b2)!=206, "InputRefCBase1(), Bottom2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputRefCBase1(b3)!=307, "InputRefCBase1(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputRefCBase2(b3)!=308, "InputRefCBase2(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputRefCBase2(b1)!=104, "InputRefCBase2(), Bottom1 as a parameter failed");
+
+ //Const reference pointer parameters
+ //Test ABase1 as a parameter
+ check(multiple_inheritance_shared_ptr.InputCPtrRefABase1(d2)!=5, "InputCPtrRefABase1() through Derived2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefABase1(d3)!=9, "InputCPtrRefABase1() through Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefABase1(b2)!=205, "InputCPtrRefABase1() through Bottom2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefABase1(b3)!=309, "InputCPtrRefABase1() through Bottom3 as a parameter failed");
+
+ //Test CBase1 CBase2 as parameters
+ check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(d1)!=3, "InputCPtrRefCBase1(), Derived1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(d2)!=6, "InputCPtrRefCBase1(), Derived2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(d3)!=7, "InputCPtrRefCBase1(), Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(d3)!=8, "InputCPtrRefCBase2(), Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(d1)!=4, "InputCPtrRefCBase2(), Derived1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(cb1)!=1, "InputCPtrRefCBase1(), CBase1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(cb2)!=2, "InputCPtrRefCBase2(), CBase2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(b1)!=103, "InputCPtrRefCBase1(), Bottom1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(b2)!=206, "InputCPtrRefCBase1(), Bottom2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(b3)!=307, "InputCPtrRefCBase1(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(b3)!=308, "InputCPtrRefCBase2(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(b1)!=104, "InputCPtrRefCBase2(), Bottom1 as a parameter failed");
+
+ //Shared pointer parameters
+ //Test ABase1 as a parameter
+ check(multiple_inheritance_shared_ptr.InputSharedPtrABase1(d2)!=5, "InputSharedPtrABase1() through Derived2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrABase1(d3)!=9, "InputSharedPtrABase1() through Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrABase1(b2)!=205, "InputSharedPtrABase1() through Bottom2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrABase1(b3)!=309, "InputSharedPtrABase1() through Bottom3 as a parameter failed");
+
+ //Test CBase1 CBase2 as parameters
+ check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(d1)!=3, "InputSharedPtrCBase1(), Derived1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(d2)!=6, "InputSharedPtrCBase1(), Derived2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(d3)!=7, "InputSharedPtrCBase1(), Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(d3)!=8, "InputSharedPtrCBase2(), Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(d1)!=4, "InputSharedPtrCBase2(), Derived1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(cb1)!=1, "InputSharedPtrCBase1(), CBase1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(cb2)!=2, "InputSharedPtrCBase2(), CBase2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(b1)!=103, "InputSharedPtrCBase1(), Bottom1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(b2)!=206, "InputSharedPtrCBase1(), Bottom2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(b3)!=307, "InputSharedPtrCBase1(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(b3)!=308, "InputSharedPtrCBase2(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(b1)!=104, "InputSharedPtrCBase2(), Bottom1 as a parameter failed");
+
+ //Shared pointer reference parameters
+ //Test ABase1 as a parameter
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefABase1(d2)!=5, "InputSharedPtrRefABase1() through Derived2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefABase1(d3)!=9, "InputSharedPtrRefABase1() through Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefABase1(b2)!=205, "InputSharedPtrRefABase1() through Bottom2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefABase1(b3)!=309, "InputSharedPtrRefABase1() through Bottom3 as a parameter failed");
+
+ //Test CBase1 CBase2 as parameters
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(d1)!=3, "InputSharedPtrRefCBase1(), Derived1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(d2)!=6, "InputSharedPtrRefCBase1(), Derived2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(d3)!=7, "InputSharedPtrRefCBase1(), Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(d3)!=8, "InputSharedPtrRefCBase2(), Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(d1)!=4, "InputSharedPtrRefCBase2(), Derived1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(cb1)!=1, "InputSharedPtrRefCBase1(), CBase1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(cb2)!=2, "InputSharedPtrRefCBase2(), CBase2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(b1)!=103, "InputSharedPtrRefCBase1(), Bottom1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(b2)!=206, "InputSharedPtrRefCBase1(), Bottom2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(b3)!=307, "InputSharedPtrRefCBase1(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(b3)!=308, "InputSharedPtrRefCBase2(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(b1)!=104, "InputSharedPtrRefCBase2(), Bottom1 as a parameter failed");
+
+ //Derived classes as parameters
+ check(multiple_inheritance_shared_ptr.InputValDerived1(d1)!=3+4, "InputValDerived1() failed");
+ check(multiple_inheritance_shared_ptr.InputValDerived2(d2)!=6+5, "InputValDerived2() failed");
+ check(multiple_inheritance_shared_ptr.InputValDerived3(d3)!=7+8+9, "InputValDerived3() failed");
+
+ check(multiple_inheritance_shared_ptr.InputRefDerived1(d1)!=3+4, "InputRefDerived1() failed");
+ check(multiple_inheritance_shared_ptr.InputRefDerived2(d2)!=6+5, "InputRefDerived2() failed");
+ check(multiple_inheritance_shared_ptr.InputRefDerived3(d3)!=7+8+9, "InputRefDerived3() failed");
+
+ check(multiple_inheritance_shared_ptr.InputPtrDerived1(d1)!=3+4, "InputPtrDerived1() failed");
+ check(multiple_inheritance_shared_ptr.InputPtrDerived2(d2)!=6+5, "InputPtrDerived2() failed");
+ check(multiple_inheritance_shared_ptr.InputPtrDerived3(d3)!=7+8+9, "InputPtrDerived3() failed");
+
+ check(multiple_inheritance_shared_ptr.InputCPtrRefDerived1(d1)!=3+4, "InputCPtrRefDerived1() failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefDerived2(d2)!=6+5, "InputCPtrRefDerived2() failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefDerived3(d3)!=7+8+9, "InputCPtrRefDerived3() failed");
+
+ check(multiple_inheritance_shared_ptr.InputSharedPtrDerived1(d1)!=3+4, "InputSharedPtrDerived1() failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrDerived2(d2)!=6+5, "InputSharedPtrDerived2() failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrDerived3(d3)!=7+8+9, "InputSharedPtrDerived3() failed");
+
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived1(d1)!=3+4, "InputSharedPtrRefDerived1() failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived2(d2)!=6+5, "InputSharedPtrRefDerived2() failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived3(d3)!=7+8+9, "InputSharedPtrRefDerived3() failed");
+
+ //Bottom classes as Derived parameters
+ check(multiple_inheritance_shared_ptr.InputValDerived1(b1)!=3+4, "InputValDerived1() failed");
+ check(multiple_inheritance_shared_ptr.InputValDerived2(b2)!=6+5, "InputValDerived2() failed");
+ check(multiple_inheritance_shared_ptr.InputValDerived3(b3)!=7+8+9, "InputValDerived3() failed");
+
+ check(multiple_inheritance_shared_ptr.InputRefDerived1(b1)!=103+104, "InputRefDerived1() failed");
+ check(multiple_inheritance_shared_ptr.InputRefDerived2(b2)!=206+205, "InputRefDerived2() failed");
+ check(multiple_inheritance_shared_ptr.InputRefDerived3(b3)!=307+308+309, "InputRefDerived3() failed");
+
+ check(multiple_inheritance_shared_ptr.InputPtrDerived1(b1)!=103+104, "InputPtrDerived1() failed");
+ check(multiple_inheritance_shared_ptr.InputPtrDerived2(b2)!=206+205, "InputPtrDerived2() failed");
+ check(multiple_inheritance_shared_ptr.InputPtrDerived3(b3)!=307+308+309, "InputPtrDerived3() failed");
+
+ check(multiple_inheritance_shared_ptr.InputCPtrRefDerived1(b1)!=103+104, "InputCPtrRefDerived1() failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefDerived2(b2)!=206+205, "InputCPtrRefDerived2() failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefDerived3(b3)!=307+308+309, "InputCPtrRefDerived3() failed");
+
+ check(multiple_inheritance_shared_ptr.InputSharedPtrDerived1(b1)!=103+104, "InputSharedPtrDerived1() failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrDerived2(b2)!=206+205, "InputSharedPtrDerived2() failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrDerived3(b3)!=307+308+309, "InputSharedPtrDerived3() failed");
+
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived1(b1)!=103+104, "InputSharedPtrRefDerived1() failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived2(b2)!=206+205, "InputSharedPtrRefDerived2() failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived3(b3)!=307+308+309, "InputSharedPtrRefDerived3() failed");
+
+ //Bottom classes as Bottom parameters
+ check(multiple_inheritance_shared_ptr.InputValBottom1(b1)!=103+104, "InputValBottom1() failed");
+ check(multiple_inheritance_shared_ptr.InputValBottom2(b2)!=206+205, "InputValBottom2() failed");
+ check(multiple_inheritance_shared_ptr.InputValBottom3(b3)!=307+308+309, "InputValBottom3() failed");
+
+ check(multiple_inheritance_shared_ptr.InputRefBottom1(b1)!=103+104, "InputRefBottom1() failed");
+ check(multiple_inheritance_shared_ptr.InputRefBottom2(b2)!=206+205, "InputRefBottom2() failed");
+ check(multiple_inheritance_shared_ptr.InputRefBottom3(b3)!=307+308+309, "InputRefBottom3() failed");
+
+ check(multiple_inheritance_shared_ptr.InputPtrBottom1(b1)!=103+104, "InputPtrBottom1() failed");
+ check(multiple_inheritance_shared_ptr.InputPtrBottom2(b2)!=206+205, "InputPtrBottom2() failed");
+ check(multiple_inheritance_shared_ptr.InputPtrBottom3(b3)!=307+308+309, "InputPtrBottom3() failed");
+
+ check(multiple_inheritance_shared_ptr.InputCPtrRefBottom1(b1)!=103+104, "InputCPtrRefBottom1() failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefBottom2(b2)!=206+205, "InputCPtrRefBottom2() failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefBottom3(b3)!=307+308+309, "InputCPtrRefBottom3() failed");
+
+ check(multiple_inheritance_shared_ptr.InputSharedPtrBottom1(b1)!=103+104, "InputSharedPtrBottom1() failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrBottom2(b2)!=206+205, "InputSharedPtrBottom2() failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrBottom3(b3)!=307+308+309, "InputSharedPtrBottom3() failed");
+
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefBottom1(b1)!=103+104, "InputSharedPtrRefBottom1() failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefBottom2(b2)!=206+205, "InputSharedPtrRefBottom2() failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefBottom3(b3)!=307+308+309, "InputSharedPtrRefBottom3() failed");
+
+ // Return pointers
+ check(multiple_inheritance_shared_ptr.MakePtrDerived1_CBase1().cbase1y()!=3, "MakePtrDerived1_CBase1 failed");
+ check(multiple_inheritance_shared_ptr.MakePtrDerived1_CBase2().cbase2()!=4, "MakePtrDerived1_CBase2 failed");
+ check(multiple_inheritance_shared_ptr.MakePtrDerived2_CBase1().cbase1y()!=6, "MakePtrDerived2_CBase1 failed");
+ check(multiple_inheritance_shared_ptr.MakePtrDerived2_ABase1().abase1()!=5, "MakePtrDerived2_ABase1 failed");
+ check(multiple_inheritance_shared_ptr.MakePtrDerived3_ABase1().abase1()!=9, "MakePtrDerived3_ABase1 failed");
+ check(multiple_inheritance_shared_ptr.MakePtrDerived3_CBase1().cbase1y()!=7, "MakePtrDerived3_CBase1 failed");
+ check(multiple_inheritance_shared_ptr.MakePtrDerived3_CBase2().cbase2()!=8, "MakePtrDerived3_CBase2 failed");
+
+ // Return references
+ check(multiple_inheritance_shared_ptr.MakeRefDerived1_CBase1().cbase1y()!=3, "MakeRefDerived1_CBase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeRefDerived1_CBase2().cbase2()!=4, "MakeRefDerived1_CBase2 failed");
+ check(multiple_inheritance_shared_ptr.MakeRefDerived2_CBase1().cbase1y()!=6, "MakeRefDerived2_CBase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeRefDerived2_ABase1().abase1()!=5, "MakeRefDerived2_ABase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeRefDerived3_ABase1().abase1()!=9, "MakeRefDerived3_ABase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeRefDerived3_CBase1().cbase1y()!=7, "MakeRefDerived3_CBase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeRefDerived3_CBase2().cbase2()!=8, "MakeRefDerived3_CBase2 failed");
+
+ // Return by value (sliced objects)
+ check(multiple_inheritance_shared_ptr.MakeValDerived1_CBase1().cbase1y()!=1, "MakeValDerived1_CBase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeValDerived1_CBase2().cbase2()!=2, "MakeValDerived1_CBase2 failed");
+ check(multiple_inheritance_shared_ptr.MakeValDerived2_CBase1().cbase1y()!=1, "MakeValDerived2_CBase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeValDerived3_CBase1().cbase1y()!=1, "MakeValDerived3_CBase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeValDerived3_CBase2().cbase2()!=2, "MakeValDerived3_CBase2 failed");
+
+ // Return smart pointers
+ check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived1_CBase1().cbase1y()!=3, "MakeSharedPtrDerived1_CBase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived1_CBase2().cbase2()!=4, "MakeSharedPtrDerived1_CBase2 failed");
+ check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived2_CBase1().cbase1y()!=6, "MakeSharedPtrDerived2_CBase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived2_ABase1().abase1()!=5, "MakeSharedPtrDerived2_ABase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived3_ABase1().abase1()!=9, "MakeSharedPtrDerived3_ABase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived3_CBase1().cbase1y()!=7, "MakeSharedPtrDerived3_CBase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived3_CBase2().cbase2()!=8, "MakeSharedPtrDerived3_CBase2 failed");
+
+ // Return smart pointers
+ check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived1_CBase1().cbase1y()!=3, "MakeSharedPtrRefDerived1_CBase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived1_CBase2().cbase2()!=4, "MakeSharedPtrRefDerived1_CBase2 failed");
+ check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived2_CBase1().cbase1y()!=6, "MakeSharedPtrRefDerived2_CBase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived2_ABase1().abase1()!=5, "MakeSharedPtrRefDerived2_ABase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived3_ABase1().abase1()!=9, "MakeSharedPtrRefDerived3_ABase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived3_CBase1().cbase1y()!=7, "MakeSharedPtrRefDerived3_CBase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived3_CBase2().cbase2()!=8, "MakeSharedPtrRefDerived3_CBase2 failed");
+ }
+}
diff --git a/Examples/test-suite/default_args.i b/Examples/test-suite/default_args.i
index d3014d386..02d860765 100644
--- a/Examples/test-suite/default_args.i
+++ b/Examples/test-suite/default_args.i
@@ -77,6 +77,10 @@
// char
char chartest1(char c = 'x') { return c; }
char chartest2(char c = '\0') { return c; }
+ char chartest3(char c = '\1') { return c; }
+ char chartest4(char c = '\n') { return c; }
+ char chartest5(char c = '\102') { return c; } // 'B'
+ char chartest6(char c = '\x43') { return c; } // 'C'
// namespaces
namespace AType {
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/enum_thorough.i b/Examples/test-suite/enum_thorough.i
index e4624c097..f17a7ee96 100644
--- a/Examples/test-suite/enum_thorough.i
+++ b/Examples/test-suite/enum_thorough.i
@@ -585,7 +585,62 @@ enum {
};
int globalDifferentTypesTest(int n) { return n; }
}
+%}
+
+#if defined(SWIGCSHARP)
+%csconstvalue("1") globalenumchar1;
+%csconstvalue("'B'") globalenumcharB;
+%csconstvalue("1") enumchar1;
+%csconstvalue("'B'") enumcharB;
+#endif
+%inline %{
+#if defined(__clang__)
+#pragma clang diagnostic push
+// Suppress: illegal character encoding in character literal
+#pragma clang diagnostic ignored "-Winvalid-source-encoding"
+#endif
+enum {
+ globalenumchar0 = '\0',
+ globalenumchar1 = '\1',
+ globalenumchar2 = '\n',
+ globalenumcharA = 'A',
+ globalenumcharB = '\102', // B
+ globalenumcharC = '\x43', // C
+ globalenumcharD = 0x44, // D
+ globalenumcharE = 69, // E
+ globalenumcharAE1 = 'Æ', // AE (latin1 encoded)
+ globalenumcharAE2 = '\306', // AE (latin1 encoded)
+ globalenumcharAE3 = '\xC6' // AE (latin1 encoded)
+};
+enum EnumChar {
+ enumchar0 = '\0',
+ enumchar1 = '\1',
+ enumchar2 = '\n',
+ enumcharA = 'A',
+ enumcharB = '\102', // B
+ enumcharC = '\x43', // C
+ enumcharD = 0x44, // D
+ enumcharE = 69, // E
+ enumcharAE1 = 'Æ', // AE (latin1 encoded)
+ enumcharAE2 = '\306', // AE (latin1 encoded)
+ enumcharAE3 = '\xC6' // AE (latin1 encoded)
+};
+struct EnumCharStruct {
+ enum EnumChar {
+ enumchar0 = '\0',
+ enumchar1 = '\1',
+ enumchar2 = '\n',
+ enumcharA = 'A',
+ enumcharB = '\102', // B
+ enumcharC = '\x43', // C
+ enumcharD = 0x44, // D
+ enumcharE = 69, // E
+ enumcharAE1 = 'Æ', // AE (latin1 encoded)
+ enumcharAE2 = '\306', // AE (latin1 encoded)
+ enumcharAE3 = '\xC6' // AE (latin1 encoded)
+ };
+};
%}
#if defined(SWIGJAVA)
@@ -595,6 +650,53 @@ int globalDifferentTypesTest(int n) { return n; }
#endif
%inline %{
+enum {
+ x_globalenumchar0 = '\0',
+ x_globalenumchar1 = '\1',
+ x_globalenumchar2 = '\n',
+ x_globalenumcharA = 'A',
+ x_globalenumcharB = '\102', // B
+ x_globalenumcharC = '\x43', // C
+ x_globalenumcharD = 0x44, // D
+ x_globalenumcharE = 69, // E
+ x_globalenumcharAE1 = 'Æ', // AE (latin1 encoded)
+ x_globalenumcharAE2 = '\306', // AE (latin1 encoded)
+ x_globalenumcharAE3 = '\xC6' // AE (latin1 encoded)
+};
+enum X_EnumChar {
+ x_enumchar0 = '\0',
+ x_enumchar1 = '\1',
+ x_enumchar2 = '\n',
+ x_enumcharA = 'A',
+ x_enumcharB = '\102', // B
+ x_enumcharC = '\x43', // C
+ x_enumcharD = 0x44, // D
+ x_enumcharE = 69, // E
+ x_enumcharAE1 = 'Æ', // AE (latin1 encoded)
+ x_enumcharAE2 = '\306', // AE (latin1 encoded)
+ x_enumcharAE3 = '\xC6' // AE (latin1 encoded)
+};
+struct X_EnumCharStruct {
+ enum X_EnumChar {
+ enumchar0 = '\0',
+ enumchar1 = '\1',
+ enumchar2 = '\n',
+ enumcharA = 'A',
+ enumcharB = '\102', // B
+ enumcharC = '\x43', // C
+ enumcharD = 0x44, // D
+ enumcharE = 69, // E
+ enumcharAE1 = 'Æ', // AE (latin1 encoded)
+ enumcharAE2 = '\306', // AE (latin1 encoded)
+ enumcharAE3 = '\xC6' // AE (latin1 encoded)
+ };
+};
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif
+%}
+
+%inline %{
namespace DifferentSpace {
enum DifferentTypesNoConst {
typeint_noconst = 10,
@@ -614,5 +716,4 @@ enum {
global_typedefaultint_noconst
};
}
-
%}
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/funcptr_cpp.i b/Examples/test-suite/funcptr_cpp.i
index 015164ed9..b63749dc1 100644
--- a/Examples/test-suite/funcptr_cpp.i
+++ b/Examples/test-suite/funcptr_cpp.i
@@ -20,7 +20,7 @@ int call3(int & (*d)(const int &, int), int a, int b) { return d(a, b); }
%constant int (*ADD_BY_VALUE)(const int &, int) = addByValue;
%constant int * (*ADD_BY_POINTER)(const int &, int) = addByPointer;
%constant int & (*ADD_BY_REFERENCE)(const int &, int) = addByReference;
-
+%constant int (* const ADD_BY_VALUE_C)(const int &, int) = addByValue;
%inline %{
typedef int AddByValueTypedef(const int &a, int b);
diff --git a/Examples/test-suite/go/go_inout_runme.go b/Examples/test-suite/go/go_inout_runme.go
index 13c429b87..9aa0cd0c5 100644
--- a/Examples/test-suite/go/go_inout_runme.go
+++ b/Examples/test-suite/go/go_inout_runme.go
@@ -40,4 +40,14 @@ func main() {
fmt.Println("got", a, "want", dwant)
panic(a)
}
+
+ c2 := go_inout.NewC2()
+ pm := c2.M()
+ want = map[string]interface{}{
+ "ID": float64(1),
+ }
+ if !reflect.DeepEqual(*pm, want) {
+ fmt.Println("for c2.M got", pm, "want", want)
+ panic(pm)
+ }
}
diff --git a/Examples/test-suite/go_inout.i b/Examples/test-suite/go_inout.i
index 57e7bf2fb..0bcb979ef 100644
--- a/Examples/test-suite/go_inout.i
+++ b/Examples/test-suite/go_inout.i
@@ -23,7 +23,7 @@ struct RetStruct {
// Write a typemap that calls C++ by converting in and out of JSON.
-%go_import("encoding/json", "bytes", "encoding/binary")
+%go_import("encoding/json", "bytes", "encoding/binary", "reflect", "unsafe")
%insert(go_header)
%{
@@ -68,6 +68,26 @@ type In json.Marshaler
}
%}
+%typemap(gotype) RetStruct* "*map[string]interface{}"
+
+%typemap(imtype) RetStruct* "*string"
+
+%typemap(out,fragment="AllocateString") RetStruct*
+%{
+ $result = (_gostring_*)malloc(sizeof(_gostring_));
+ *$result = Swig_AllocateString($1->str.data(), $1->str.length());
+%}
+
+%typemap(goout,fragment="CopyString") RetStruct*
+%{
+ defer Swig_free(uintptr(unsafe.Pointer($1)))
+ var rm map[string]interface{}
+ if err := json.Unmarshal([]byte(swigCopyString(*$1)), &rm); err != nil {
+ panic(err)
+ }
+ $result = &rm
+%}
+
%inline
%{
@@ -87,6 +107,10 @@ struct MyArray {
std::vector<std::string> strings;
};
+void* Allocate(int n) {
+ return new char[n];
+}
+
static uint64_t getuint64(const char* s) {
uint64_t ret = 0;
for (int i = 0; i < 8; i++, s++) {
@@ -121,7 +145,12 @@ static void putuint64(std::string *s, size_t off, uint64_t v) {
buf.Write(b[:])
buf.WriteString(s)
}
- str := buf.String()
+ bb := buf.Bytes()
+ p := Allocate(len(bb))
+ copy((*[1<<15]byte)(unsafe.Pointer(p))[:len(bb)], bb)
+ var str string
+ (*reflect.StringHeader)(unsafe.Pointer(&str)).Data = uintptr(unsafe.Pointer(p))
+ (*reflect.StringHeader)(unsafe.Pointer(&str)).Len = len(bb)
$result = &str
}
%}
@@ -197,3 +226,18 @@ void DoubleArray(MyArray* v) {
}
}
%}
+
+%inline
+%{
+class C1 {
+ public:
+ RetStruct* M() {
+ RetStruct* r = new RetStruct;
+ r->str = "{\"ID\":1}";
+ return r;
+ }
+};
+
+class C2 : public C1 {
+};
+%}
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 3dc6555ef..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@
@@ -38,7 +38,7 @@ CPP_TEST_CASES = \
java_prepost \
java_throws \
java_typemaps_proxy \
- java_typemaps_typewrapper
+ java_typemaps_typewrapper \
# li_boost_intrusive_ptr
CPP11_TEST_CASES = \
@@ -53,12 +53,13 @@ JAVA_PACKAGEOPT = -package $(JAVA_PACKAGE)
SWIGOPT += $(JAVA_PACKAGEOPT)
# Custom tests - tests with additional commandline options
-java_nspacewithoutpackage.%: JAVA_PACKAGEOPT =
+director_nspace.%: JAVA_PACKAGE = $*Package
+director_nspace_director_name_collision.%: JAVA_PACKAGE = $*Package
java_director_exception_feature_nspace.%: JAVA_PACKAGE = $*Package
+java_nspacewithoutpackage.%: JAVA_PACKAGEOPT =
+multiple_inheritance_nspace.%: JAVA_PACKAGE = $*Package
nspace.%: JAVA_PACKAGE = $*Package
nspace_extend.%: JAVA_PACKAGE = $*Package
-director_nspace.%: JAVA_PACKAGE = $*Package
-director_nspace_director_name_collision.%: JAVA_PACKAGE = $*Package
# Rules for the different types of tests
%.cpptest:
diff --git a/Examples/test-suite/java/constant_directive_runme.java b/Examples/test-suite/java/constant_directive_runme.java
index b5135a499..4b5c3c3d0 100644
--- a/Examples/test-suite/java/constant_directive_runme.java
+++ b/Examples/test-suite/java/constant_directive_runme.java
@@ -18,5 +18,9 @@ public class constant_directive_runme {
throw new RuntimeException("fail");
if (constant_directive.TYPE1_CONSTANT3.getVal() != 3)
throw new RuntimeException("fail");
+ if (constant_directive.TYPE1CONST_CONSTANT1.getVal() != 1)
+ throw new RuntimeException("fail");
+ if (constant_directive.TYPE1CPTR_CONSTANT1.getVal() != 1)
+ throw new RuntimeException("fail");
}
}
diff --git a/Examples/test-suite/java/cpp11_li_std_array_runme.java b/Examples/test-suite/java/cpp11_li_std_array_runme.java
new file mode 100644
index 000000000..2e2a20138
--- /dev/null
+++ b/Examples/test-suite/java/cpp11_li_std_array_runme.java
@@ -0,0 +1,82 @@
+import cpp11_li_std_array.*;
+
+public class cpp11_li_std_array_runme {
+
+ static {
+ try {
+ System.loadLibrary("cpp11_li_std_array");
+ } 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 ArrayInt6 ToArray6(int [] a) {
+ ArrayInt6 ai = new ArrayInt6();
+ if (a.length != 6)
+ throw new RuntimeException("a is incorrect size");
+ for (int i=0; i<6; ++i)
+ ai.set(i, a[i]);
+ return ai;
+ }
+
+ private static void compareContainers(ArrayInt6 actual, int[] expected) {
+ if (actual.size() != expected.length)
+ throw new RuntimeException("Sizes are different: " + actual.size() + " " + expected.length);
+ for (int i=0; i<actual.size(); ++i) {
+ int actualValue = actual.get(i);
+ int expectedValue = expected[i];
+ if (actualValue != expectedValue)
+ throw new RuntimeException("Value is wrong for element " + i + ". Expected " + expectedValue + " got: " + actualValue);
+ }
+ if (actual.isEmpty())
+ throw new RuntimeException("ai should not be empty");
+ }
+
+ public static void main(String argv[]) {
+ ArrayInt6 ai = new ArrayInt6();
+ compareContainers(ai, new int[] {0, 0, 0, 0, 0, 0});
+
+ int[] vals = {10, 20, 30, 40, 50, 60};
+ for (int i=0; i<ai.size(); ++i)
+ ai.set(i, vals[i]);
+ compareContainers(ai, vals);
+
+ // Check return
+ compareContainers(cpp11_li_std_array.arrayOutVal(), new int[] {-2, -1, 0, 0, 1, 2});
+ compareContainers(cpp11_li_std_array.arrayOutConstRef(), new int[] {-2, -1, 0, 0, 1, 2});
+ compareContainers(cpp11_li_std_array.arrayOutRef(), new int[] {-2, -1, 0, 0, 1, 2});
+ compareContainers(cpp11_li_std_array.arrayOutPtr(), new int[] {-2, -1, 0, 0, 1, 2});
+
+ // Check passing arguments
+ ai = cpp11_li_std_array.arrayInVal(ToArray6(new int[] {9, 8, 7, 6, 5, 4}));
+ compareContainers(ai, new int[] {90, 80, 70, 60, 50, 40});
+
+ ai = cpp11_li_std_array.arrayInConstRef(ToArray6(new int[] {9, 8, 7, 6, 5, 4}));
+ compareContainers(ai, new int[] {90, 80, 70, 60, 50, 40});
+
+ ai = new ArrayInt6(ToArray6(new int[] {9, 8, 7, 6, 5, 4}));
+ cpp11_li_std_array.arrayInRef(ai);
+ compareContainers(ai, new int[] {90, 80, 70, 60, 50, 40});
+
+ ai = new ArrayInt6(ToArray6(new int[] {9, 8, 7, 6, 5, 4}));
+ cpp11_li_std_array.arrayInPtr(ai);
+ compareContainers(ai, new int[] {90, 80, 70, 60, 50, 40});
+
+ // fill
+ ai.fill(111);
+ compareContainers(ai, new int[] {111, 111, 111, 111, 111, 111});
+
+ // out of range errors
+ try {
+ ai.set((int)ai.size(), 0);
+ throw new RuntimeException("Out of range exception not caught");
+ } catch(IndexOutOfBoundsException e) {
+ }
+ try {
+ ai.set(-1, 0);
+ throw new RuntimeException("Out of range exception not caught");
+ } catch(IndexOutOfBoundsException e) {
+ }
+ }
+}
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/long_long_runme.java b/Examples/test-suite/java/long_long_runme.java
index 3a967f7a7..76aa0705d 100644
--- a/Examples/test-suite/java/long_long_runme.java
+++ b/Examples/test-suite/java/long_long_runme.java
@@ -3,7 +3,8 @@
// unsigned long long types map correctly to long and BigInteger respectively.
import long_long.*;
-import java.math.*;
+import java.math.BigInteger;
+import java.util.ArrayList;
public class long_long_runme {
@@ -54,12 +55,57 @@ public class long_long_runme {
check_ull(testNumber);
testNumber = testNumber.add(BigInteger.ONE);
}
-
+
try {
long_long.setUll(null);
throw new RuntimeException("null check failed");
} catch (NullPointerException e) {
}
+
+ // UnsignedToSigned - checks that a cast from unsigned long long to long long in C
+ // gives expected value (including -ve numbers)
+
+ long[] nums = {
+ 0x00,
+ 0xFF, 0x80, 0x7F, 0x01,
+ -0xFF, -0x80, -0x7F, -0x01,
+ 0x100, 0x10000,
+ -0x100, -0x10000,
+ 0xFFFF, 0xFF80, 0xFF7F, 0xFF01, 0xFF00,
+ -0xFFFF, -0xFF80, -0xFF7F, -0xFF01, -0xFF00,
+ 0x7FFF, 0x7F80, 0x7F7F, 0x7F01, 0x7F00,
+ -0x7FFF, -0x7F80, -0x7F7F, -0x7F01, -0x7F00,
+ 0x80FF, 0x8080, 0x807F, 0x8001, 0x8000,
+ -0x80FF, -0x8080, -0x807F, -0x8001, -0x8000,
+ Integer.MAX_VALUE, Integer.MIN_VALUE,
+ Integer.MAX_VALUE+1, Integer.MIN_VALUE-1,
+ Long.MAX_VALUE, Long.MIN_VALUE,
+ };
+
+ ArrayList<BigInteger> bigIntegers = new ArrayList<BigInteger>();
+ for (int i=0; i<nums.length; ++i) {
+ BigInteger bi = new BigInteger(new Long(nums[i]).toString());
+ bigIntegers.add(bi);
+ }
+
+ {
+ BigInteger bi = new BigInteger(new Long(Long.MAX_VALUE).toString());
+ bigIntegers.add(bi.add(BigInteger.ONE));
+ bi = new BigInteger(new Long(Long.MIN_VALUE).toString());
+ bigIntegers.add(bi.subtract(BigInteger.ONE));
+ }
+
+ boolean failed = false;
+ for (int i=0; i<bigIntegers.size(); ++i) {
+ BigInteger bi = (BigInteger)bigIntegers.get(i);
+ long longReturn = long_long.UnsignedToSigned(bi);
+ if (bi.longValue() != longReturn) {
+ System.err.println("Conversion to long failed, in:" + bi + " out:" + longReturn);
+ failed = true;
+ }
+ }
+ if (failed)
+ throw new RuntimeException("There were UnsignedToSigned failures");
}
public static void check_ll(long ll) {
diff --git a/Examples/test-suite/java/multiple_inheritance_abstract_runme.java b/Examples/test-suite/java/multiple_inheritance_abstract_runme.java
new file mode 100644
index 000000000..1489d92a7
--- /dev/null
+++ b/Examples/test-suite/java/multiple_inheritance_abstract_runme.java
@@ -0,0 +1,253 @@
+import multiple_inheritance_abstract.*;
+
+public class multiple_inheritance_abstract_runme {
+
+ static {
+ try {
+ System.loadLibrary("multiple_inheritance_abstract");
+ } 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);
+ }
+ }
+
+ //Test base class as a parameter in java
+ int jcbase1b(CBase1 cb1){
+ return cb1.cbase1y();
+ }
+ int jabase1(ABase1 ab1){
+ return ab1.abase1();
+ }
+ int jcbase2(CBase2 cb2){
+ return cb2.cbase2();
+ }
+
+ public static void check(boolean fail, String msg) {
+ if (fail)
+ throw new RuntimeException(msg);
+ }
+
+ public static void main(String argv[]) {
+ //Test Derived1
+ Derived1 d1=new Derived1();
+ check(d1.cbase1y()!=3, "Derived1::cbase1y() failed");
+ check(d1.cbase2()!=4, "Derived1::cbase2() failed");
+
+ //Test Derived2
+ Derived2 d2=new Derived2();
+ check(d2.cbase1y()!=6, "Derived2::cbase1y() failed");
+ check(d2.abase1()!=5, "Derived2::abase1() failed");
+
+ //Test Derived3
+ Derived3 d3=new Derived3();
+ check(d3.cbase1y()!=7, "Derived3::cbase1y() failed");
+ check(d3.cbase2()!=8, "Derived3::cbase2() failed");
+ check(d3.abase1()!=9, "Derived3::abase1() failed");
+
+ //Test Bottom1
+ Bottom1 b1=new Bottom1();
+ check(b1.cbase1y()!=103, "Bottom1::cbase1y() failed");
+ check(b1.cbase2()!=104, "Bottom1::cbase2() failed");
+
+ //Test Bottom2
+ Bottom2 b2=new Bottom2();
+ check(b2.cbase1y()!=206, "Bottom2::cbase1y() failed");
+ check(b2.abase1()!=205, "Bottom2::abase1() failed");
+
+ //Test Bottom3
+ Bottom3 b3=new Bottom3();
+ check(b3.cbase1y()!=307, "Bottom3::cbase1y() failed");
+ check(b3.cbase2()!=308, "Bottom3::cbase2() failed");
+ check(b3.abase1()!=309, "Bottom3::abase1() failed");
+
+ //Test interfaces from c++ classes
+ CBase1 cb1=new CBase1SwigImpl();
+ CBase2 cb2=new CBase2SwigImpl();
+ check(cb1.cbase1y()!=1, "CBase1::cbase1y() failed");
+ check(cb2.cbase2()!=2, "CBase2::cbase2() failed");
+
+ //Test abstract class as return value
+ ABase1 ab1=d3.cloneit();
+ check(ab1.abase1()!=9, "Derived3::abase1() through ABase1 failed");
+
+ //Test concrete base class as return value
+ CBase1 cb6=d2.cloneit();
+ CBase2 cb7=d1.cloneit();
+ check(cb6.cbase1y()!=6, "Derived2::cbase1y() through CBase1 failed");
+ check(cb7.cbase2()!=4, "Derived1:cbase2() through ABase1 failed");
+
+ //Test multi inheritance
+ CBase1 cb3=new Derived1();
+ CBase1 cb4=new Derived3();
+ CBase2 cb5=new Derived3();
+ ABase1 ab6=new Derived2();
+ check(cb3.cbase1y()!=3, "Derived1::cbase1y() through CBase1 failed");
+ check(cb4.cbase1y()!=7, "Derived3::cbase1y() through CBase1 failed");
+ check(cb5.cbase2()!=8, "Derived3::cbase2() through CBase2 failed");
+ check(ab6.abase1()!=5, "Derived2::abase1() through ABase1 failed");
+
+ //Test base classes as parameter in java
+ multiple_inheritance_abstract_runme mhar=new multiple_inheritance_abstract_runme();
+ check(mhar.jcbase1b(d1)!=3, "jcbase1b() through Derived1 as parameter failed");
+ check(mhar.jcbase1b(d2)!=6, "jcbase1b() through Derived2 as parameter failed");
+ check(mhar.jcbase1b(d3)!=7, "jcbase1b() through Derived3 as parameter failed");
+ check(mhar.jcbase2(d1)!=4, "jcbase2() through Derived1 as parameter failed");
+ check(mhar.jcbase2(d3)!=8, "jcbase2() through Derived3 as parameter failed");
+ check(mhar.jabase1(d2)!=5, "jabase1() through Derived2 as parameter failed");
+ check(mhar.jabase1(d3)!=9, "jabase1() through Derived3 as parameter failed");
+
+ //Value parameters
+ //Test CBase1 CBase2 as parameters (note slicing for Derived and Bottom classes)
+ check(multiple_inheritance_abstract.InputValCBase1(d1)!=1, "InputValCBase1(), Derived1 as a parameter failed");
+ check(multiple_inheritance_abstract.InputValCBase1(d2)!=1, "InputValCBase1(), Derived2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputValCBase1(d3)!=1, "InputValCBase1(), Derived3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputValCBase2(d3)!=2, "InputValCBase2(), Derived3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputValCBase2(d1)!=2, "InputValCBase2(), Derived1 as a parameter failed");
+ check(multiple_inheritance_abstract.InputValCBase1(cb1)!=1, "InputValCBase1(), CBase1 as a parameter failed");
+ check(multiple_inheritance_abstract.InputValCBase2(cb2)!=2, "InputValCBase2(), CBase2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputValCBase1(b1)!=1, "InputValCBase1(), Bottom1 as a parameter failed");
+ check(multiple_inheritance_abstract.InputValCBase1(b2)!=1, "InputValCBase1(), Bottom2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputValCBase1(b3)!=1, "InputValCBase1(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputValCBase2(b3)!=2, "InputValCBase2(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputValCBase2(b1)!=2, "InputValCBase2(), Bottom1 as a parameter failed");
+
+ //Pointer parameters
+ //Test ABase1 as a parameter
+ check(multiple_inheritance_abstract.InputPtrABase1(d2)!=5, "InputPtrABase1() through Derived2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputPtrABase1(d3)!=9, "InputPtrABase1() through Derived3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputPtrABase1(b2)!=205, "InputPtrABase1() through Bottom2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputPtrABase1(b3)!=309, "InputPtrABase1() through Bottom3 as a parameter failed");
+
+ //Test CBase1 CBase2 as parameters
+ check(multiple_inheritance_abstract.InputPtrCBase1(d1)!=3, "InputPtrCBase1(), Derived1 as a parameter failed");
+ check(multiple_inheritance_abstract.InputPtrCBase1(d2)!=6, "InputPtrCBase1(), Derived2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputPtrCBase1(d3)!=7, "InputPtrCBase1(), Derived3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputPtrCBase2(d3)!=8, "InputPtrCBase2(), Derived3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputPtrCBase2(d1)!=4, "InputPtrCBase2(), Derived1 as a parameter failed");
+ check(multiple_inheritance_abstract.InputPtrCBase1(cb1)!=1, "InputPtrCBase1(), CBase1 as a parameter failed");
+ check(multiple_inheritance_abstract.InputPtrCBase2(cb2)!=2, "InputPtrCBase2(), CBase2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputPtrCBase1(b1)!=103, "InputPtrCBase1(), Bottom1 as a parameter failed");
+ check(multiple_inheritance_abstract.InputPtrCBase1(b2)!=206, "InputPtrCBase1(), Bottom2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputPtrCBase1(b3)!=307, "InputPtrCBase1(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputPtrCBase2(b3)!=308, "InputPtrCBase2(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputPtrCBase2(b1)!=104, "InputPtrCBase2(), Bottom1 as a parameter failed");
+
+ //Reference parameters
+ //Test ABase1 as a parameter
+ check(multiple_inheritance_abstract.InputRefABase1(d2)!=5, "InputRefABase1() through Derived2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputRefABase1(d3)!=9, "InputRefABase1() through Derived3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputRefABase1(b2)!=205, "InputRefABase1() through Bottom2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputRefABase1(b3)!=309, "InputRefABase1() through Bottom3 as a parameter failed");
+
+ //Test CBase1 CBase2 as parameters
+ check(multiple_inheritance_abstract.InputRefCBase1(d1)!=3, "InputRefCBase1(), Derived1 as a parameter failed");
+ check(multiple_inheritance_abstract.InputRefCBase1(d2)!=6, "InputRefCBase1(), Derived2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputRefCBase1(d3)!=7, "InputRefCBase1(), Derived3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputRefCBase2(d3)!=8, "InputRefCBase2(), Derived3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputRefCBase2(d1)!=4, "InputRefCBase2(), Derived1 as a parameter failed");
+ check(multiple_inheritance_abstract.InputRefCBase1(cb1)!=1, "InputRefCBase1(), CBase1 as a parameter failed");
+ check(multiple_inheritance_abstract.InputRefCBase2(cb2)!=2, "InputRefCBase2(), CBase2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputRefCBase1(b1)!=103, "InputRefCBase1(), Bottom1 as a parameter failed");
+ check(multiple_inheritance_abstract.InputRefCBase1(b2)!=206, "InputRefCBase1(), Bottom2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputRefCBase1(b3)!=307, "InputRefCBase1(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputRefCBase2(b3)!=308, "InputRefCBase2(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputRefCBase2(b1)!=104, "InputRefCBase2(), Bottom1 as a parameter failed");
+
+ //Const reference pointer parameters
+ //Test ABase1 as a parameter
+ check(multiple_inheritance_abstract.InputCPtrRefABase1(d2)!=5, "InputCPtrRefABase1() through Derived2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputCPtrRefABase1(d3)!=9, "InputCPtrRefABase1() through Derived3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputCPtrRefABase1(b2)!=205, "InputCPtrRefABase1() through Bottom2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputCPtrRefABase1(b3)!=309, "InputCPtrRefABase1() through Bottom3 as a parameter failed");
+
+ //Test CBase1 CBase2 as parameters
+ check(multiple_inheritance_abstract.InputCPtrRefCBase1(d1)!=3, "InputCPtrRefCBase1(), Derived1 as a parameter failed");
+ check(multiple_inheritance_abstract.InputCPtrRefCBase1(d2)!=6, "InputCPtrRefCBase1(), Derived2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputCPtrRefCBase1(d3)!=7, "InputCPtrRefCBase1(), Derived3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputCPtrRefCBase2(d3)!=8, "InputCPtrRefCBase2(), Derived3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputCPtrRefCBase2(d1)!=4, "InputCPtrRefCBase2(), Derived1 as a parameter failed");
+ check(multiple_inheritance_abstract.InputCPtrRefCBase1(cb1)!=1, "InputCPtrRefCBase1(), CBase1 as a parameter failed");
+ check(multiple_inheritance_abstract.InputCPtrRefCBase2(cb2)!=2, "InputCPtrRefCBase2(), CBase2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputCPtrRefCBase1(b1)!=103, "InputCPtrRefCBase1(), Bottom1 as a parameter failed");
+ check(multiple_inheritance_abstract.InputCPtrRefCBase1(b2)!=206, "InputCPtrRefCBase1(), Bottom2 as a parameter failed");
+ check(multiple_inheritance_abstract.InputCPtrRefCBase1(b3)!=307, "InputCPtrRefCBase1(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputCPtrRefCBase2(b3)!=308, "InputCPtrRefCBase2(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_abstract.InputCPtrRefCBase2(b1)!=104, "InputCPtrRefCBase2(), Bottom1 as a parameter failed");
+
+ //Derived classes as parameters
+ check(multiple_inheritance_abstract.InputValDerived1(d1)!=3+4, "InputValDerived1() failed");
+ check(multiple_inheritance_abstract.InputValDerived2(d2)!=6+5, "InputValDerived2() failed");
+ check(multiple_inheritance_abstract.InputValDerived3(d3)!=7+8+9, "InputValDerived3() failed");
+
+ check(multiple_inheritance_abstract.InputRefDerived1(d1)!=3+4, "InputRefDerived1() failed");
+ check(multiple_inheritance_abstract.InputRefDerived2(d2)!=6+5, "InputRefDerived2() failed");
+ check(multiple_inheritance_abstract.InputRefDerived3(d3)!=7+8+9, "InputRefDerived3() failed");
+
+ check(multiple_inheritance_abstract.InputPtrDerived1(d1)!=3+4, "InputPtrDerived1() failed");
+ check(multiple_inheritance_abstract.InputPtrDerived2(d2)!=6+5, "InputPtrDerived2() failed");
+ check(multiple_inheritance_abstract.InputPtrDerived3(d3)!=7+8+9, "InputPtrDerived3() failed");
+
+ check(multiple_inheritance_abstract.InputCPtrRefDerived1(d1)!=3+4, "InputCPtrRefDerived1() failed");
+ check(multiple_inheritance_abstract.InputCPtrRefDerived2(d2)!=6+5, "InputCPtrRefDerived2() failed");
+ check(multiple_inheritance_abstract.InputCPtrRefDerived3(d3)!=7+8+9, "InputCPtrRefDerived3() failed");
+
+ //Bottom classes as Derived parameters
+ check(multiple_inheritance_abstract.InputValDerived1(b1)!=3+4, "InputValDerived1() failed");
+ check(multiple_inheritance_abstract.InputValDerived2(b2)!=6+5, "InputValDerived2() failed");
+ check(multiple_inheritance_abstract.InputValDerived3(b3)!=7+8+9, "InputValDerived3() failed");
+
+ check(multiple_inheritance_abstract.InputRefDerived1(b1)!=103+104, "InputRefDerived1() failed");
+ check(multiple_inheritance_abstract.InputRefDerived2(b2)!=206+205, "InputRefDerived2() failed");
+ check(multiple_inheritance_abstract.InputRefDerived3(b3)!=307+308+309, "InputRefDerived3() failed");
+
+ check(multiple_inheritance_abstract.InputPtrDerived1(b1)!=103+104, "InputPtrDerived1() failed");
+ check(multiple_inheritance_abstract.InputPtrDerived2(b2)!=206+205, "InputPtrDerived2() failed");
+ check(multiple_inheritance_abstract.InputPtrDerived3(b3)!=307+308+309, "InputPtrDerived3() failed");
+
+ check(multiple_inheritance_abstract.InputCPtrRefDerived1(b1)!=103+104, "InputCPtrRefDerived1() failed");
+ check(multiple_inheritance_abstract.InputCPtrRefDerived2(b2)!=206+205, "InputCPtrRefDerived2() failed");
+ check(multiple_inheritance_abstract.InputCPtrRefDerived3(b3)!=307+308+309, "InputCPtrRefDerived3() failed");
+
+ //Bottom classes as Bottom parameters
+ check(multiple_inheritance_abstract.InputValBottom1(b1)!=103+104, "InputValBottom1() failed");
+ check(multiple_inheritance_abstract.InputValBottom2(b2)!=206+205, "InputValBottom2() failed");
+ check(multiple_inheritance_abstract.InputValBottom3(b3)!=307+308+309, "InputValBottom3() failed");
+
+ check(multiple_inheritance_abstract.InputRefBottom1(b1)!=103+104, "InputRefBottom1() failed");
+ check(multiple_inheritance_abstract.InputRefBottom2(b2)!=206+205, "InputRefBottom2() failed");
+ check(multiple_inheritance_abstract.InputRefBottom3(b3)!=307+308+309, "InputRefBottom3() failed");
+
+ check(multiple_inheritance_abstract.InputPtrBottom1(b1)!=103+104, "InputPtrBottom1() failed");
+ check(multiple_inheritance_abstract.InputPtrBottom2(b2)!=206+205, "InputPtrBottom2() failed");
+ check(multiple_inheritance_abstract.InputPtrBottom3(b3)!=307+308+309, "InputPtrBottom3() failed");
+
+ check(multiple_inheritance_abstract.InputCPtrRefBottom1(b1)!=103+104, "InputCPtrRefBottom1() failed");
+ check(multiple_inheritance_abstract.InputCPtrRefBottom2(b2)!=206+205, "InputCPtrRefBottom2() failed");
+ check(multiple_inheritance_abstract.InputCPtrRefBottom3(b3)!=307+308+309, "InputCPtrRefBottom3() failed");
+ // Return pointers
+ check(multiple_inheritance_abstract.MakePtrDerived1_CBase1().cbase1y()!=3, "MakePtrDerived1_CBase1 failed");
+ check(multiple_inheritance_abstract.MakePtrDerived1_CBase2().cbase2()!=4, "MakePtrDerived1_CBase2 failed");
+ check(multiple_inheritance_abstract.MakePtrDerived2_CBase1().cbase1y()!=6, "MakePtrDerived2_CBase1 failed");
+ check(multiple_inheritance_abstract.MakePtrDerived2_ABase1().abase1()!=5, "MakePtrDerived2_ABase1 failed");
+ check(multiple_inheritance_abstract.MakePtrDerived3_ABase1().abase1()!=9, "MakePtrDerived3_ABase1 failed");
+ check(multiple_inheritance_abstract.MakePtrDerived3_CBase1().cbase1y()!=7, "MakePtrDerived3_CBase1 failed");
+ check(multiple_inheritance_abstract.MakePtrDerived3_CBase2().cbase2()!=8, "MakePtrDerived3_CBase2 failed");
+
+ // Return references
+ check(multiple_inheritance_abstract.MakeRefDerived1_CBase1().cbase1y()!=3, "MakeRefDerived1_CBase1 failed");
+ check(multiple_inheritance_abstract.MakeRefDerived1_CBase2().cbase2()!=4, "MakeRefDerived1_CBase2 failed");
+ check(multiple_inheritance_abstract.MakeRefDerived2_CBase1().cbase1y()!=6, "MakeRefDerived2_CBase1 failed");
+ check(multiple_inheritance_abstract.MakeRefDerived2_ABase1().abase1()!=5, "MakeRefDerived2_ABase1 failed");
+ check(multiple_inheritance_abstract.MakeRefDerived3_ABase1().abase1()!=9, "MakeRefDerived3_ABase1 failed");
+ check(multiple_inheritance_abstract.MakeRefDerived3_CBase1().cbase1y()!=7, "MakeRefDerived3_CBase1 failed");
+ check(multiple_inheritance_abstract.MakeRefDerived3_CBase2().cbase2()!=8, "MakeRefDerived3_CBase2 failed");
+
+ // Return by value (sliced objects)
+ check(multiple_inheritance_abstract.MakeValDerived1_CBase1().cbase1y()!=1, "MakeValDerived1_CBase1 failed");
+ check(multiple_inheritance_abstract.MakeValDerived1_CBase2().cbase2()!=2, "MakeValDerived1_CBase2 failed");
+ check(multiple_inheritance_abstract.MakeValDerived2_CBase1().cbase1y()!=1, "MakeValDerived2_CBase1 failed");
+ check(multiple_inheritance_abstract.MakeValDerived3_CBase1().cbase1y()!=1, "MakeValDerived3_CBase1 failed");
+ check(multiple_inheritance_abstract.MakeValDerived3_CBase2().cbase2()!=2, "MakeValDerived3_CBase2 failed");
+
+ }
+}
diff --git a/Examples/test-suite/java/multiple_inheritance_interfaces_runme.java b/Examples/test-suite/java/multiple_inheritance_interfaces_runme.java
new file mode 100644
index 000000000..3f2b00000
--- /dev/null
+++ b/Examples/test-suite/java/multiple_inheritance_interfaces_runme.java
@@ -0,0 +1,78 @@
+import multiple_inheritance_interfaces.*;
+import java.util.Arrays;
+
+public class multiple_inheritance_interfaces_runme {
+
+ static {
+ try {
+ System.loadLibrary("multiple_inheritance_interfaces");
+ } 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 checkBaseAndInterfaces(Class cls, boolean interfaceExpected, String base, String[] interfaces) {
+ String[] expectedInterfaces = new String[interfaces.length];
+ for (int i=0; i<interfaces.length; ++i)
+ expectedInterfaces[i] = "interface multiple_inheritance_interfaces." + interfaces[i];
+ Class[] actualInterfaces = cls.getInterfaces();
+ String expectedInterfacesString = Arrays.toString(expectedInterfaces);
+ String actualInterfacesString = Arrays.toString(actualInterfaces);
+ if (!expectedInterfacesString.equals(actualInterfacesString))
+ throw new RuntimeException("Expected interfaces for " + cls.getName() + ": \n" + expectedInterfacesString + "\n" + "Actual interfaces: \n" + actualInterfacesString);
+
+ String expectedBaseString = null;
+ if (interfaceExpected) {
+ // expecting an interface
+ if (!cls.isInterface())
+ throw new RuntimeException(cls.getName() + " should be an interface but is not");
+ expectedBaseString = base.isEmpty() ? "" : "multiple_inheritance_interfaces." + base;
+ } else {
+ // expecting a class
+ if (cls.isInterface())
+ throw new RuntimeException(cls.getName() + " is an interface but it should not be");
+ expectedBaseString = base.isEmpty() ? "java.lang.Object" : "multiple_inheritance_interfaces." + base;
+ }
+
+ String actualBaseString = cls.getSuperclass() == null ? "" : cls.getSuperclass().getName();
+ if (!expectedBaseString.equals(actualBaseString))
+ throw new RuntimeException("Expected base for " + cls.getName() + ": [" + expectedBaseString + "]" + " Actual base: [" + actualBaseString + "]");
+ }
+
+ public static void main(String argv[]) {
+ checkBaseAndInterfaces(IA.class, true, "", new String[] {});
+ checkBaseAndInterfaces(IB.class, true, "", new String[] {});
+ checkBaseAndInterfaces(IC.class, true, "", new String[] {"IA", "IB"});
+ checkBaseAndInterfaces(A.class, false, "", new String[] {"IA"});
+ checkBaseAndInterfaces(B.class, false, "", new String[] {"IB"});
+ checkBaseAndInterfaces(C.class, false, "", new String[] {"IA", "IB", "IC"});
+ checkBaseAndInterfaces(D.class, false, "", new String[] {"IA", "IB", "IC"});
+ checkBaseAndInterfaces(E.class, false, "D", new String[] {});
+
+ checkBaseAndInterfaces(IJ.class, true, "", new String[] {});
+ checkBaseAndInterfaces(IK.class, true, "", new String[] {"IJ"});
+ checkBaseAndInterfaces(IL.class, true, "", new String[] {"IK"});
+ checkBaseAndInterfaces(J.class, false, "", new String[] {"IJ"});
+ checkBaseAndInterfaces(K.class, false, "", new String[] {"IJ", "IK"});
+ checkBaseAndInterfaces(L.class, false, "", new String[] {"IJ", "IK", "IL"});
+ checkBaseAndInterfaces(M.class, false, "", new String[] {"IJ", "IK", "IL"});
+
+ checkBaseAndInterfaces(P.class, false, "", new String[] {});
+ checkBaseAndInterfaces(IQ.class, true, "", new String[] {});
+ checkBaseAndInterfaces(Q.class, false, "", new String[] {"IQ"});
+ checkBaseAndInterfaces(R.class, false, "P", new String[] {"IQ"});
+ checkBaseAndInterfaces(S.class, false, "P", new String[] {"IQ"});
+ checkBaseAndInterfaces(T.class, false, "", new String[] {"IQ"});
+ checkBaseAndInterfaces(U.class, false, "R", new String[] {});
+ checkBaseAndInterfaces(V.class, false, "S", new String[] {});
+ checkBaseAndInterfaces(W.class, false, "T", new String[] {});
+
+ // overloaded methods check
+ D d = new D();
+ d.ia();
+ d.ia(10);
+ d.ia("bye");
+ d.ia("bye", false);
+ }
+}
diff --git a/Examples/test-suite/java/multiple_inheritance_nspace_runme.java b/Examples/test-suite/java/multiple_inheritance_nspace_runme.java
new file mode 100644
index 000000000..461c7a131
--- /dev/null
+++ b/Examples/test-suite/java/multiple_inheritance_nspace_runme.java
@@ -0,0 +1,255 @@
+import multiple_inheritance_nspacePackage.multiple_inheritance_nspace;
+import multiple_inheritance_nspacePackage.multiple_inheritance_nspaceJNI;
+import multiple_inheritance_nspacePackage.Space.*;
+
+public class multiple_inheritance_nspace_runme {
+
+ static {
+ try {
+ System.loadLibrary("multiple_inheritance_nspace");
+ } 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);
+ }
+ }
+
+ //Test base class as a parameter in java
+ int jcbase1b(CBase1SwigInterface cb1){
+ return cb1.cbase1y();
+ }
+ int jabase1(ABase1SwigInterface ab1){
+ return ab1.abase1();
+ }
+ int jcbase2(CBase2SwigInterface cb2){
+ return cb2.cbase2();
+ }
+
+ public static void check(boolean fail, String msg) {
+ if (fail)
+ throw new RuntimeException(msg);
+ }
+
+ public static void main(String argv[]) {
+ //Test Derived1
+ Derived1 d1=new Derived1();
+ check(d1.cbase1y()!=3, "Derived1::cbase1y() failed");
+ check(d1.cbase2()!=4, "Derived1::cbase2() failed");
+
+ //Test Derived2
+ Derived2 d2=new Derived2();
+ check(d2.cbase1y()!=6, "Derived2::cbase1y() failed");
+ check(d2.abase1()!=5, "Derived2::abase1() failed");
+
+ //Test Derived3
+ Derived3 d3=new Derived3();
+ check(d3.cbase1y()!=7, "Derived3::cbase1y() failed");
+ check(d3.cbase2()!=8, "Derived3::cbase2() failed");
+ check(d3.abase1()!=9, "Derived3::abase1() failed");
+
+ //Test Bottom1
+ Bottom1 b1=new Bottom1();
+ check(b1.cbase1y()!=103, "Bottom1::cbase1y() failed");
+ check(b1.cbase2()!=104, "Bottom1::cbase2() failed");
+
+ //Test Bottom2
+ Bottom2 b2=new Bottom2();
+ check(b2.cbase1y()!=206, "Bottom2::cbase1y() failed");
+ check(b2.abase1()!=205, "Bottom2::abase1() failed");
+
+ //Test Bottom3
+ Bottom3 b3=new Bottom3();
+ check(b3.cbase1y()!=307, "Bottom3::cbase1y() failed");
+ check(b3.cbase2()!=308, "Bottom3::cbase2() failed");
+ check(b3.abase1()!=309, "Bottom3::abase1() failed");
+
+ //Test interfaces from c++ classes
+ CBase1SwigInterface cb1=new CBase1();
+ CBase2SwigInterface cb2=new CBase2();
+ check(cb1.cbase1y()!=1, "CBase1::cbase1y() failed");
+ check(cb2.cbase2()!=2, "CBase2::cbase2() failed");
+
+ //Test nspace class as return value
+ ABase1SwigInterface ab1=d3.cloneit();
+ check(ab1.abase1()!=9, "Derived3::abase1() through ABase1 failed");
+
+ //Test concrete base class as return value
+ CBase1SwigInterface cb6=d2.cloneit();
+ CBase2SwigInterface cb7=d1.cloneit();
+ check(cb6.cbase1y()!=6, "Derived2::cbase1y() through CBase1 failed");
+ check(cb7.cbase2()!=4, "Derived1:cbase2() through ABase1 failed");
+
+ //Test multi inheritance
+ CBase1SwigInterface cb3=new Derived1();
+ CBase1SwigInterface cb4=new Derived3();
+ CBase2SwigInterface cb5=new Derived3();
+ ABase1SwigInterface ab6=new Derived2();
+ check(cb3.cbase1y()!=3, "Derived1::cbase1y() through CBase1 failed");
+ check(cb4.cbase1y()!=7, "Derived3::cbase1y() through CBase1 failed");
+ check(cb5.cbase2()!=8, "Derived3::cbase2() through CBase2 failed");
+ check(ab6.abase1()!=5, "Derived2::abase1() through ABase1 failed");
+
+ //Test base classes as parameter in java
+ multiple_inheritance_nspace_runme mhar=new multiple_inheritance_nspace_runme();
+ check(mhar.jcbase1b(d1)!=3, "jcbase1b() through Derived1 as parameter failed");
+ check(mhar.jcbase1b(d2)!=6, "jcbase1b() through Derived2 as parameter failed");
+ check(mhar.jcbase1b(d3)!=7, "jcbase1b() through Derived3 as parameter failed");
+ check(mhar.jcbase2(d1)!=4, "jcbase2() through Derived1 as parameter failed");
+ check(mhar.jcbase2(d3)!=8, "jcbase2() through Derived3 as parameter failed");
+ check(mhar.jabase1(d2)!=5, "jabase1() through Derived2 as parameter failed");
+ check(mhar.jabase1(d3)!=9, "jabase1() through Derived3 as parameter failed");
+
+ //Value parameters
+ //Test CBase1 CBase2 as parameters (note slicing for Derived and Bottom classes)
+ check(multiple_inheritance_nspace.InputValCBase1(d1)!=1, "InputValCBase1(), Derived1 as a parameter failed");
+ check(multiple_inheritance_nspace.InputValCBase1(d2)!=1, "InputValCBase1(), Derived2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputValCBase1(d3)!=1, "InputValCBase1(), Derived3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputValCBase2(d3)!=2, "InputValCBase2(), Derived3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputValCBase2(d1)!=2, "InputValCBase2(), Derived1 as a parameter failed");
+ check(multiple_inheritance_nspace.InputValCBase1(cb1)!=1, "InputValCBase1(), CBase1 as a parameter failed");
+ check(multiple_inheritance_nspace.InputValCBase2(cb2)!=2, "InputValCBase2(), CBase2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputValCBase1(b1)!=1, "InputValCBase1(), Bottom1 as a parameter failed");
+ check(multiple_inheritance_nspace.InputValCBase1(b2)!=1, "InputValCBase1(), Bottom2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputValCBase1(b3)!=1, "InputValCBase1(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputValCBase2(b3)!=2, "InputValCBase2(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputValCBase2(b1)!=2, "InputValCBase2(), Bottom1 as a parameter failed");
+
+ //Pointer parameters
+ //Test ABase1 as a parameter
+ check(multiple_inheritance_nspace.InputPtrABase1(d2)!=5, "InputPtrABase1() through Derived2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputPtrABase1(d3)!=9, "InputPtrABase1() through Derived3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputPtrABase1(b2)!=205, "InputPtrABase1() through Bottom2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputPtrABase1(b3)!=309, "InputPtrABase1() through Bottom3 as a parameter failed");
+
+ //Test CBase1 CBase2 as parameters
+ check(multiple_inheritance_nspace.InputPtrCBase1(d1)!=3, "InputPtrCBase1(), Derived1 as a parameter failed");
+ check(multiple_inheritance_nspace.InputPtrCBase1(d2)!=6, "InputPtrCBase1(), Derived2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputPtrCBase1(d3)!=7, "InputPtrCBase1(), Derived3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputPtrCBase2(d3)!=8, "InputPtrCBase2(), Derived3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputPtrCBase2(d1)!=4, "InputPtrCBase2(), Derived1 as a parameter failed");
+ check(multiple_inheritance_nspace.InputPtrCBase1(cb1)!=1, "InputPtrCBase1(), CBase1 as a parameter failed");
+ check(multiple_inheritance_nspace.InputPtrCBase2(cb2)!=2, "InputPtrCBase2(), CBase2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputPtrCBase1(b1)!=103, "InputPtrCBase1(), Bottom1 as a parameter failed");
+ check(multiple_inheritance_nspace.InputPtrCBase1(b2)!=206, "InputPtrCBase1(), Bottom2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputPtrCBase1(b3)!=307, "InputPtrCBase1(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputPtrCBase2(b3)!=308, "InputPtrCBase2(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputPtrCBase2(b1)!=104, "InputPtrCBase2(), Bottom1 as a parameter failed");
+
+ //Reference parameters
+ //Test ABase1 as a parameter
+ check(multiple_inheritance_nspace.InputRefABase1(d2)!=5, "InputRefABase1() through Derived2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputRefABase1(d3)!=9, "InputRefABase1() through Derived3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputRefABase1(b2)!=205, "InputRefABase1() through Bottom2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputRefABase1(b3)!=309, "InputRefABase1() through Bottom3 as a parameter failed");
+
+ //Test CBase1 CBase2 as parameters
+ check(multiple_inheritance_nspace.InputRefCBase1(d1)!=3, "InputRefCBase1(), Derived1 as a parameter failed");
+ check(multiple_inheritance_nspace.InputRefCBase1(d2)!=6, "InputRefCBase1(), Derived2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputRefCBase1(d3)!=7, "InputRefCBase1(), Derived3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputRefCBase2(d3)!=8, "InputRefCBase2(), Derived3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputRefCBase2(d1)!=4, "InputRefCBase2(), Derived1 as a parameter failed");
+ check(multiple_inheritance_nspace.InputRefCBase1(cb1)!=1, "InputRefCBase1(), CBase1 as a parameter failed");
+ check(multiple_inheritance_nspace.InputRefCBase2(cb2)!=2, "InputRefCBase2(), CBase2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputRefCBase1(b1)!=103, "InputRefCBase1(), Bottom1 as a parameter failed");
+ check(multiple_inheritance_nspace.InputRefCBase1(b2)!=206, "InputRefCBase1(), Bottom2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputRefCBase1(b3)!=307, "InputRefCBase1(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputRefCBase2(b3)!=308, "InputRefCBase2(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputRefCBase2(b1)!=104, "InputRefCBase2(), Bottom1 as a parameter failed");
+
+ //Const reference pointer parameters
+ //Test ABase1 as a parameter
+ check(multiple_inheritance_nspace.InputCPtrRefABase1(d2)!=5, "InputCPtrRefABase1() through Derived2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputCPtrRefABase1(d3)!=9, "InputCPtrRefABase1() through Derived3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputCPtrRefABase1(b2)!=205, "InputCPtrRefABase1() through Bottom2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputCPtrRefABase1(b3)!=309, "InputCPtrRefABase1() through Bottom3 as a parameter failed");
+
+ //Test CBase1 CBase2 as parameters
+ check(multiple_inheritance_nspace.InputCPtrRefCBase1(d1)!=3, "InputCPtrRefCBase1(), Derived1 as a parameter failed");
+ check(multiple_inheritance_nspace.InputCPtrRefCBase1(d2)!=6, "InputCPtrRefCBase1(), Derived2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputCPtrRefCBase1(d3)!=7, "InputCPtrRefCBase1(), Derived3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputCPtrRefCBase2(d3)!=8, "InputCPtrRefCBase2(), Derived3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputCPtrRefCBase2(d1)!=4, "InputCPtrRefCBase2(), Derived1 as a parameter failed");
+ check(multiple_inheritance_nspace.InputCPtrRefCBase1(cb1)!=1, "InputCPtrRefCBase1(), CBase1 as a parameter failed");
+ check(multiple_inheritance_nspace.InputCPtrRefCBase2(cb2)!=2, "InputCPtrRefCBase2(), CBase2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputCPtrRefCBase1(b1)!=103, "InputCPtrRefCBase1(), Bottom1 as a parameter failed");
+ check(multiple_inheritance_nspace.InputCPtrRefCBase1(b2)!=206, "InputCPtrRefCBase1(), Bottom2 as a parameter failed");
+ check(multiple_inheritance_nspace.InputCPtrRefCBase1(b3)!=307, "InputCPtrRefCBase1(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputCPtrRefCBase2(b3)!=308, "InputCPtrRefCBase2(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_nspace.InputCPtrRefCBase2(b1)!=104, "InputCPtrRefCBase2(), Bottom1 as a parameter failed");
+
+ //Derived classes as parameters
+ check(multiple_inheritance_nspace.InputValDerived1(d1)!=3+4, "InputValDerived1() failed");
+ check(multiple_inheritance_nspace.InputValDerived2(d2)!=6+5, "InputValDerived2() failed");
+ check(multiple_inheritance_nspace.InputValDerived3(d3)!=7+8+9, "InputValDerived3() failed");
+
+ check(multiple_inheritance_nspace.InputRefDerived1(d1)!=3+4, "InputRefDerived1() failed");
+ check(multiple_inheritance_nspace.InputRefDerived2(d2)!=6+5, "InputRefDerived2() failed");
+ check(multiple_inheritance_nspace.InputRefDerived3(d3)!=7+8+9, "InputRefDerived3() failed");
+
+ check(multiple_inheritance_nspace.InputPtrDerived1(d1)!=3+4, "InputPtrDerived1() failed");
+ check(multiple_inheritance_nspace.InputPtrDerived2(d2)!=6+5, "InputPtrDerived2() failed");
+ check(multiple_inheritance_nspace.InputPtrDerived3(d3)!=7+8+9, "InputPtrDerived3() failed");
+
+ check(multiple_inheritance_nspace.InputCPtrRefDerived1(d1)!=3+4, "InputCPtrRefDerived1() failed");
+ check(multiple_inheritance_nspace.InputCPtrRefDerived2(d2)!=6+5, "InputCPtrRefDerived2() failed");
+ check(multiple_inheritance_nspace.InputCPtrRefDerived3(d3)!=7+8+9, "InputCPtrRefDerived3() failed");
+
+ //Bottom classes as Derived parameters
+ check(multiple_inheritance_nspace.InputValDerived1(b1)!=3+4, "InputValDerived1() failed");
+ check(multiple_inheritance_nspace.InputValDerived2(b2)!=6+5, "InputValDerived2() failed");
+ check(multiple_inheritance_nspace.InputValDerived3(b3)!=7+8+9, "InputValDerived3() failed");
+
+ check(multiple_inheritance_nspace.InputRefDerived1(b1)!=103+104, "InputRefDerived1() failed");
+ check(multiple_inheritance_nspace.InputRefDerived2(b2)!=206+205, "InputRefDerived2() failed");
+ check(multiple_inheritance_nspace.InputRefDerived3(b3)!=307+308+309, "InputRefDerived3() failed");
+
+ check(multiple_inheritance_nspace.InputPtrDerived1(b1)!=103+104, "InputPtrDerived1() failed");
+ check(multiple_inheritance_nspace.InputPtrDerived2(b2)!=206+205, "InputPtrDerived2() failed");
+ check(multiple_inheritance_nspace.InputPtrDerived3(b3)!=307+308+309, "InputPtrDerived3() failed");
+
+ check(multiple_inheritance_nspace.InputCPtrRefDerived1(b1)!=103+104, "InputCPtrRefDerived1() failed");
+ check(multiple_inheritance_nspace.InputCPtrRefDerived2(b2)!=206+205, "InputCPtrRefDerived2() failed");
+ check(multiple_inheritance_nspace.InputCPtrRefDerived3(b3)!=307+308+309, "InputCPtrRefDerived3() failed");
+
+ //Bottom classes as Bottom parameters
+ check(multiple_inheritance_nspace.InputValBottom1(b1)!=103+104, "InputValBottom1() failed");
+ check(multiple_inheritance_nspace.InputValBottom2(b2)!=206+205, "InputValBottom2() failed");
+ check(multiple_inheritance_nspace.InputValBottom3(b3)!=307+308+309, "InputValBottom3() failed");
+
+ check(multiple_inheritance_nspace.InputRefBottom1(b1)!=103+104, "InputRefBottom1() failed");
+ check(multiple_inheritance_nspace.InputRefBottom2(b2)!=206+205, "InputRefBottom2() failed");
+ check(multiple_inheritance_nspace.InputRefBottom3(b3)!=307+308+309, "InputRefBottom3() failed");
+
+ check(multiple_inheritance_nspace.InputPtrBottom1(b1)!=103+104, "InputPtrBottom1() failed");
+ check(multiple_inheritance_nspace.InputPtrBottom2(b2)!=206+205, "InputPtrBottom2() failed");
+ check(multiple_inheritance_nspace.InputPtrBottom3(b3)!=307+308+309, "InputPtrBottom3() failed");
+
+ check(multiple_inheritance_nspace.InputCPtrRefBottom1(b1)!=103+104, "InputCPtrRefBottom1() failed");
+ check(multiple_inheritance_nspace.InputCPtrRefBottom2(b2)!=206+205, "InputCPtrRefBottom2() failed");
+ check(multiple_inheritance_nspace.InputCPtrRefBottom3(b3)!=307+308+309, "InputCPtrRefBottom3() failed");
+ // Return pointers
+ check(multiple_inheritance_nspace.MakePtrDerived1_CBase1().cbase1y()!=3, "MakePtrDerived1_CBase1 failed");
+ check(multiple_inheritance_nspace.MakePtrDerived1_CBase2().cbase2()!=4, "MakePtrDerived1_CBase2 failed");
+ check(multiple_inheritance_nspace.MakePtrDerived2_CBase1().cbase1y()!=6, "MakePtrDerived2_CBase1 failed");
+ check(multiple_inheritance_nspace.MakePtrDerived2_ABase1().abase1()!=5, "MakePtrDerived2_ABase1 failed");
+ check(multiple_inheritance_nspace.MakePtrDerived3_ABase1().abase1()!=9, "MakePtrDerived3_ABase1 failed");
+ check(multiple_inheritance_nspace.MakePtrDerived3_CBase1().cbase1y()!=7, "MakePtrDerived3_CBase1 failed");
+ check(multiple_inheritance_nspace.MakePtrDerived3_CBase2().cbase2()!=8, "MakePtrDerived3_CBase2 failed");
+
+ // Return references
+ check(multiple_inheritance_nspace.MakeRefDerived1_CBase1().cbase1y()!=3, "MakeRefDerived1_CBase1 failed");
+ check(multiple_inheritance_nspace.MakeRefDerived1_CBase2().cbase2()!=4, "MakeRefDerived1_CBase2 failed");
+ check(multiple_inheritance_nspace.MakeRefDerived2_CBase1().cbase1y()!=6, "MakeRefDerived2_CBase1 failed");
+ check(multiple_inheritance_nspace.MakeRefDerived2_ABase1().abase1()!=5, "MakeRefDerived2_ABase1 failed");
+ check(multiple_inheritance_nspace.MakeRefDerived3_ABase1().abase1()!=9, "MakeRefDerived3_ABase1 failed");
+ check(multiple_inheritance_nspace.MakeRefDerived3_CBase1().cbase1y()!=7, "MakeRefDerived3_CBase1 failed");
+ check(multiple_inheritance_nspace.MakeRefDerived3_CBase2().cbase2()!=8, "MakeRefDerived3_CBase2 failed");
+
+ // Return by value (sliced objects)
+ check(multiple_inheritance_nspace.MakeValDerived1_CBase1().cbase1y()!=1, "MakeValDerived1_CBase1 failed");
+ check(multiple_inheritance_nspace.MakeValDerived1_CBase2().cbase2()!=2, "MakeValDerived1_CBase2 failed");
+ check(multiple_inheritance_nspace.MakeValDerived2_CBase1().cbase1y()!=1, "MakeValDerived2_CBase1 failed");
+ check(multiple_inheritance_nspace.MakeValDerived3_CBase1().cbase1y()!=1, "MakeValDerived3_CBase1 failed");
+ check(multiple_inheritance_nspace.MakeValDerived3_CBase2().cbase2()!=2, "MakeValDerived3_CBase2 failed");
+
+ }
+}
diff --git a/Examples/test-suite/java/multiple_inheritance_shared_ptr_runme.java b/Examples/test-suite/java/multiple_inheritance_shared_ptr_runme.java
new file mode 100644
index 000000000..6472a911e
--- /dev/null
+++ b/Examples/test-suite/java/multiple_inheritance_shared_ptr_runme.java
@@ -0,0 +1,337 @@
+import multiple_inheritance_shared_ptr.*;
+
+public class multiple_inheritance_shared_ptr_runme {
+
+ static {
+ try {
+ System.loadLibrary("multiple_inheritance_shared_ptr");
+ } 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);
+ }
+ }
+
+ //Test base class as a parameter in java
+ int jcbase1b(CBase1 cb1){
+ return cb1.cbase1y();
+ }
+ int jabase1(ABase1 ab1){
+ return ab1.abase1();
+ }
+ int jcbase2(CBase2 cb2){
+ return cb2.cbase2();
+ }
+
+ public static void check(boolean fail, String msg) {
+ if (fail)
+ throw new RuntimeException(msg);
+ }
+
+ public static void main(String argv[]) {
+ //Test Derived1
+ Derived1 d1=new Derived1();
+ check(d1.cbase1y()!=3, "Derived1::cbase1y() failed");
+ check(d1.cbase2()!=4, "Derived1::cbase2() failed");
+
+ //Test Derived2
+ Derived2 d2=new Derived2();
+ check(d2.cbase1y()!=6, "Derived2::cbase1y() failed");
+ check(d2.abase1()!=5, "Derived2::abase1() failed");
+
+ //Test Derived3
+ Derived3 d3=new Derived3();
+ check(d3.cbase1y()!=7, "Derived3::cbase1y() failed");
+ check(d3.cbase2()!=8, "Derived3::cbase2() failed");
+ check(d3.abase1()!=9, "Derived3::abase1() failed");
+
+ //Test Bottom1
+ Bottom1 b1=new Bottom1();
+ check(b1.cbase1y()!=103, "Bottom1::cbase1y() failed");
+ check(b1.cbase2()!=104, "Bottom1::cbase2() failed");
+
+ //Test Bottom2
+ Bottom2 b2=new Bottom2();
+ check(b2.cbase1y()!=206, "Bottom2::cbase1y() failed");
+ check(b2.abase1()!=205, "Bottom2::abase1() failed");
+
+ //Test Bottom3
+ Bottom3 b3=new Bottom3();
+ check(b3.cbase1y()!=307, "Bottom3::cbase1y() failed");
+ check(b3.cbase2()!=308, "Bottom3::cbase2() failed");
+ check(b3.abase1()!=309, "Bottom3::abase1() failed");
+
+ //Test interfaces from c++ classes
+ CBase1 cb1=new CBase1SwigImpl();
+ CBase2 cb2=new CBase2SwigImpl();
+ check(cb1.cbase1y()!=1, "CBase1::cbase1y() failed");
+ check(cb2.cbase2()!=2, "CBase2::cbase2() failed");
+
+ //Test abstract class as return value
+ ABase1 ab1=d3.cloneit();
+ check(ab1.abase1()!=9, "Derived3::abase1() through ABase1 failed");
+
+ //Test concrete base class as return value
+ CBase1 cb6=d2.cloneit();
+ CBase2 cb7=d1.cloneit();
+ check(cb6.cbase1y()!=6, "Derived2::cbase1y() through CBase1 failed");
+ check(cb7.cbase2()!=4, "Derived1:cbase2() through ABase1 failed");
+
+ //Test multi inheritance
+ CBase1 cb3=new Derived1();
+ CBase1 cb4=new Derived3();
+ CBase2 cb5=new Derived3();
+ ABase1 ab6=new Derived2();
+ check(cb3.cbase1y()!=3, "Derived1::cbase1y() through CBase1 failed");
+ check(cb4.cbase1y()!=7, "Derived3::cbase1y() through CBase1 failed");
+ check(cb5.cbase2()!=8, "Derived3::cbase2() through CBase2 failed");
+ check(ab6.abase1()!=5, "Derived2::abase1() through ABase1 failed");
+
+ //Test base classes as parameter in java
+ multiple_inheritance_shared_ptr_runme mhar=new multiple_inheritance_shared_ptr_runme();
+ check(mhar.jcbase1b(d1)!=3, "jcbase1b() through Derived1 as parameter failed");
+ check(mhar.jcbase1b(d2)!=6, "jcbase1b() through Derived2 as parameter failed");
+ check(mhar.jcbase1b(d3)!=7, "jcbase1b() through Derived3 as parameter failed");
+ check(mhar.jcbase2(d1)!=4, "jcbase2() through Derived1 as parameter failed");
+ check(mhar.jcbase2(d3)!=8, "jcbase2() through Derived3 as parameter failed");
+ check(mhar.jabase1(d2)!=5, "jabase1() through Derived2 as parameter failed");
+ check(mhar.jabase1(d3)!=9, "jabase1() through Derived3 as parameter failed");
+
+ //Value parameters
+ //Test CBase1 CBase2 as parameters (note slicing for Derived and Bottom classes)
+ check(multiple_inheritance_shared_ptr.InputValCBase1(d1)!=1, "InputValCBase1(), Derived1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputValCBase1(d2)!=1, "InputValCBase1(), Derived2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputValCBase1(d3)!=1, "InputValCBase1(), Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputValCBase2(d3)!=2, "InputValCBase2(), Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputValCBase2(d1)!=2, "InputValCBase2(), Derived1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputValCBase1(cb1)!=1, "InputValCBase1(), CBase1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputValCBase2(cb2)!=2, "InputValCBase2(), CBase2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputValCBase1(b1)!=1, "InputValCBase1(), Bottom1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputValCBase1(b2)!=1, "InputValCBase1(), Bottom2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputValCBase1(b3)!=1, "InputValCBase1(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputValCBase2(b3)!=2, "InputValCBase2(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputValCBase2(b1)!=2, "InputValCBase2(), Bottom1 as a parameter failed");
+
+ //Pointer parameters
+ //Test ABase1 as a parameter
+ check(multiple_inheritance_shared_ptr.InputPtrABase1(d2)!=5, "InputPtrABase1() through Derived2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputPtrABase1(d3)!=9, "InputPtrABase1() through Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputPtrABase1(b2)!=205, "InputPtrABase1() through Bottom2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputPtrABase1(b3)!=309, "InputPtrABase1() through Bottom3 as a parameter failed");
+
+ //Test CBase1 CBase2 as parameters
+ check(multiple_inheritance_shared_ptr.InputPtrCBase1(d1)!=3, "InputPtrCBase1(), Derived1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputPtrCBase1(d2)!=6, "InputPtrCBase1(), Derived2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputPtrCBase1(d3)!=7, "InputPtrCBase1(), Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputPtrCBase2(d3)!=8, "InputPtrCBase2(), Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputPtrCBase2(d1)!=4, "InputPtrCBase2(), Derived1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputPtrCBase1(cb1)!=1, "InputPtrCBase1(), CBase1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputPtrCBase2(cb2)!=2, "InputPtrCBase2(), CBase2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputPtrCBase1(b1)!=103, "InputPtrCBase1(), Bottom1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputPtrCBase1(b2)!=206, "InputPtrCBase1(), Bottom2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputPtrCBase1(b3)!=307, "InputPtrCBase1(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputPtrCBase2(b3)!=308, "InputPtrCBase2(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputPtrCBase2(b1)!=104, "InputPtrCBase2(), Bottom1 as a parameter failed");
+
+ //Reference parameters
+ //Test ABase1 as a parameter
+ check(multiple_inheritance_shared_ptr.InputRefABase1(d2)!=5, "InputRefABase1() through Derived2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputRefABase1(d3)!=9, "InputRefABase1() through Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputRefABase1(b2)!=205, "InputRefABase1() through Bottom2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputRefABase1(b3)!=309, "InputRefABase1() through Bottom3 as a parameter failed");
+
+ //Test CBase1 CBase2 as parameters
+ check(multiple_inheritance_shared_ptr.InputRefCBase1(d1)!=3, "InputRefCBase1(), Derived1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputRefCBase1(d2)!=6, "InputRefCBase1(), Derived2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputRefCBase1(d3)!=7, "InputRefCBase1(), Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputRefCBase2(d3)!=8, "InputRefCBase2(), Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputRefCBase2(d1)!=4, "InputRefCBase2(), Derived1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputRefCBase1(cb1)!=1, "InputRefCBase1(), CBase1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputRefCBase2(cb2)!=2, "InputRefCBase2(), CBase2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputRefCBase1(b1)!=103, "InputRefCBase1(), Bottom1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputRefCBase1(b2)!=206, "InputRefCBase1(), Bottom2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputRefCBase1(b3)!=307, "InputRefCBase1(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputRefCBase2(b3)!=308, "InputRefCBase2(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputRefCBase2(b1)!=104, "InputRefCBase2(), Bottom1 as a parameter failed");
+
+ //Const reference pointer parameters
+ //Test ABase1 as a parameter
+ check(multiple_inheritance_shared_ptr.InputCPtrRefABase1(d2)!=5, "InputCPtrRefABase1() through Derived2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefABase1(d3)!=9, "InputCPtrRefABase1() through Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefABase1(b2)!=205, "InputCPtrRefABase1() through Bottom2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefABase1(b3)!=309, "InputCPtrRefABase1() through Bottom3 as a parameter failed");
+
+ //Test CBase1 CBase2 as parameters
+ check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(d1)!=3, "InputCPtrRefCBase1(), Derived1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(d2)!=6, "InputCPtrRefCBase1(), Derived2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(d3)!=7, "InputCPtrRefCBase1(), Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(d3)!=8, "InputCPtrRefCBase2(), Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(d1)!=4, "InputCPtrRefCBase2(), Derived1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(cb1)!=1, "InputCPtrRefCBase1(), CBase1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(cb2)!=2, "InputCPtrRefCBase2(), CBase2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(b1)!=103, "InputCPtrRefCBase1(), Bottom1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(b2)!=206, "InputCPtrRefCBase1(), Bottom2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(b3)!=307, "InputCPtrRefCBase1(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(b3)!=308, "InputCPtrRefCBase2(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(b1)!=104, "InputCPtrRefCBase2(), Bottom1 as a parameter failed");
+
+ //Shared pointer parameters
+ //Test ABase1 as a parameter
+ check(multiple_inheritance_shared_ptr.InputSharedPtrABase1(d2)!=5, "InputSharedPtrABase1() through Derived2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrABase1(d3)!=9, "InputSharedPtrABase1() through Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrABase1(b2)!=205, "InputSharedPtrABase1() through Bottom2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrABase1(b3)!=309, "InputSharedPtrABase1() through Bottom3 as a parameter failed");
+
+ //Test CBase1 CBase2 as parameters
+ check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(d1)!=3, "InputSharedPtrCBase1(), Derived1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(d2)!=6, "InputSharedPtrCBase1(), Derived2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(d3)!=7, "InputSharedPtrCBase1(), Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(d3)!=8, "InputSharedPtrCBase2(), Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(d1)!=4, "InputSharedPtrCBase2(), Derived1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(cb1)!=1, "InputSharedPtrCBase1(), CBase1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(cb2)!=2, "InputSharedPtrCBase2(), CBase2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(b1)!=103, "InputSharedPtrCBase1(), Bottom1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(b2)!=206, "InputSharedPtrCBase1(), Bottom2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(b3)!=307, "InputSharedPtrCBase1(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(b3)!=308, "InputSharedPtrCBase2(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(b1)!=104, "InputSharedPtrCBase2(), Bottom1 as a parameter failed");
+
+ //Shared pointer reference parameters
+ //Test ABase1 as a parameter
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefABase1(d2)!=5, "InputSharedPtrRefABase1() through Derived2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefABase1(d3)!=9, "InputSharedPtrRefABase1() through Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefABase1(b2)!=205, "InputSharedPtrRefABase1() through Bottom2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefABase1(b3)!=309, "InputSharedPtrRefABase1() through Bottom3 as a parameter failed");
+
+ //Test CBase1 CBase2 as parameters
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(d1)!=3, "InputSharedPtrRefCBase1(), Derived1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(d2)!=6, "InputSharedPtrRefCBase1(), Derived2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(d3)!=7, "InputSharedPtrRefCBase1(), Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(d3)!=8, "InputSharedPtrRefCBase2(), Derived3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(d1)!=4, "InputSharedPtrRefCBase2(), Derived1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(cb1)!=1, "InputSharedPtrRefCBase1(), CBase1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(cb2)!=2, "InputSharedPtrRefCBase2(), CBase2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(b1)!=103, "InputSharedPtrRefCBase1(), Bottom1 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(b2)!=206, "InputSharedPtrRefCBase1(), Bottom2 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(b3)!=307, "InputSharedPtrRefCBase1(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(b3)!=308, "InputSharedPtrRefCBase2(), Bottom3 as a parameter failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(b1)!=104, "InputSharedPtrRefCBase2(), Bottom1 as a parameter failed");
+
+ //Derived classes as parameters
+ check(multiple_inheritance_shared_ptr.InputValDerived1(d1)!=3+4, "InputValDerived1() failed");
+ check(multiple_inheritance_shared_ptr.InputValDerived2(d2)!=6+5, "InputValDerived2() failed");
+ check(multiple_inheritance_shared_ptr.InputValDerived3(d3)!=7+8+9, "InputValDerived3() failed");
+
+ check(multiple_inheritance_shared_ptr.InputRefDerived1(d1)!=3+4, "InputRefDerived1() failed");
+ check(multiple_inheritance_shared_ptr.InputRefDerived2(d2)!=6+5, "InputRefDerived2() failed");
+ check(multiple_inheritance_shared_ptr.InputRefDerived3(d3)!=7+8+9, "InputRefDerived3() failed");
+
+ check(multiple_inheritance_shared_ptr.InputPtrDerived1(d1)!=3+4, "InputPtrDerived1() failed");
+ check(multiple_inheritance_shared_ptr.InputPtrDerived2(d2)!=6+5, "InputPtrDerived2() failed");
+ check(multiple_inheritance_shared_ptr.InputPtrDerived3(d3)!=7+8+9, "InputPtrDerived3() failed");
+
+ check(multiple_inheritance_shared_ptr.InputCPtrRefDerived1(d1)!=3+4, "InputCPtrRefDerived1() failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefDerived2(d2)!=6+5, "InputCPtrRefDerived2() failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefDerived3(d3)!=7+8+9, "InputCPtrRefDerived3() failed");
+
+ check(multiple_inheritance_shared_ptr.InputSharedPtrDerived1(d1)!=3+4, "InputSharedPtrDerived1() failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrDerived2(d2)!=6+5, "InputSharedPtrDerived2() failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrDerived3(d3)!=7+8+9, "InputSharedPtrDerived3() failed");
+
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived1(d1)!=3+4, "InputSharedPtrRefDerived1() failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived2(d2)!=6+5, "InputSharedPtrRefDerived2() failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived3(d3)!=7+8+9, "InputSharedPtrRefDerived3() failed");
+
+ //Bottom classes as Derived parameters
+ check(multiple_inheritance_shared_ptr.InputValDerived1(b1)!=3+4, "InputValDerived1() failed");
+ check(multiple_inheritance_shared_ptr.InputValDerived2(b2)!=6+5, "InputValDerived2() failed");
+ check(multiple_inheritance_shared_ptr.InputValDerived3(b3)!=7+8+9, "InputValDerived3() failed");
+
+ check(multiple_inheritance_shared_ptr.InputRefDerived1(b1)!=103+104, "InputRefDerived1() failed");
+ check(multiple_inheritance_shared_ptr.InputRefDerived2(b2)!=206+205, "InputRefDerived2() failed");
+ check(multiple_inheritance_shared_ptr.InputRefDerived3(b3)!=307+308+309, "InputRefDerived3() failed");
+
+ check(multiple_inheritance_shared_ptr.InputPtrDerived1(b1)!=103+104, "InputPtrDerived1() failed");
+ check(multiple_inheritance_shared_ptr.InputPtrDerived2(b2)!=206+205, "InputPtrDerived2() failed");
+ check(multiple_inheritance_shared_ptr.InputPtrDerived3(b3)!=307+308+309, "InputPtrDerived3() failed");
+
+ check(multiple_inheritance_shared_ptr.InputCPtrRefDerived1(b1)!=103+104, "InputCPtrRefDerived1() failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefDerived2(b2)!=206+205, "InputCPtrRefDerived2() failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefDerived3(b3)!=307+308+309, "InputCPtrRefDerived3() failed");
+
+ check(multiple_inheritance_shared_ptr.InputSharedPtrDerived1(b1)!=103+104, "InputSharedPtrDerived1() failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrDerived2(b2)!=206+205, "InputSharedPtrDerived2() failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrDerived3(b3)!=307+308+309, "InputSharedPtrDerived3() failed");
+
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived1(b1)!=103+104, "InputSharedPtrRefDerived1() failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived2(b2)!=206+205, "InputSharedPtrRefDerived2() failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived3(b3)!=307+308+309, "InputSharedPtrRefDerived3() failed");
+
+ //Bottom classes as Bottom parameters
+ check(multiple_inheritance_shared_ptr.InputValBottom1(b1)!=103+104, "InputValBottom1() failed");
+ check(multiple_inheritance_shared_ptr.InputValBottom2(b2)!=206+205, "InputValBottom2() failed");
+ check(multiple_inheritance_shared_ptr.InputValBottom3(b3)!=307+308+309, "InputValBottom3() failed");
+
+ check(multiple_inheritance_shared_ptr.InputRefBottom1(b1)!=103+104, "InputRefBottom1() failed");
+ check(multiple_inheritance_shared_ptr.InputRefBottom2(b2)!=206+205, "InputRefBottom2() failed");
+ check(multiple_inheritance_shared_ptr.InputRefBottom3(b3)!=307+308+309, "InputRefBottom3() failed");
+
+ check(multiple_inheritance_shared_ptr.InputPtrBottom1(b1)!=103+104, "InputPtrBottom1() failed");
+ check(multiple_inheritance_shared_ptr.InputPtrBottom2(b2)!=206+205, "InputPtrBottom2() failed");
+ check(multiple_inheritance_shared_ptr.InputPtrBottom3(b3)!=307+308+309, "InputPtrBottom3() failed");
+
+ check(multiple_inheritance_shared_ptr.InputCPtrRefBottom1(b1)!=103+104, "InputCPtrRefBottom1() failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefBottom2(b2)!=206+205, "InputCPtrRefBottom2() failed");
+ check(multiple_inheritance_shared_ptr.InputCPtrRefBottom3(b3)!=307+308+309, "InputCPtrRefBottom3() failed");
+
+ check(multiple_inheritance_shared_ptr.InputSharedPtrBottom1(b1)!=103+104, "InputSharedPtrBottom1() failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrBottom2(b2)!=206+205, "InputSharedPtrBottom2() failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrBottom3(b3)!=307+308+309, "InputSharedPtrBottom3() failed");
+
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefBottom1(b1)!=103+104, "InputSharedPtrRefBottom1() failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefBottom2(b2)!=206+205, "InputSharedPtrRefBottom2() failed");
+ check(multiple_inheritance_shared_ptr.InputSharedPtrRefBottom3(b3)!=307+308+309, "InputSharedPtrRefBottom3() failed");
+
+ // Return pointers
+ check(multiple_inheritance_shared_ptr.MakePtrDerived1_CBase1().cbase1y()!=3, "MakePtrDerived1_CBase1 failed");
+ check(multiple_inheritance_shared_ptr.MakePtrDerived1_CBase2().cbase2()!=4, "MakePtrDerived1_CBase2 failed");
+ check(multiple_inheritance_shared_ptr.MakePtrDerived2_CBase1().cbase1y()!=6, "MakePtrDerived2_CBase1 failed");
+ check(multiple_inheritance_shared_ptr.MakePtrDerived2_ABase1().abase1()!=5, "MakePtrDerived2_ABase1 failed");
+ check(multiple_inheritance_shared_ptr.MakePtrDerived3_ABase1().abase1()!=9, "MakePtrDerived3_ABase1 failed");
+ check(multiple_inheritance_shared_ptr.MakePtrDerived3_CBase1().cbase1y()!=7, "MakePtrDerived3_CBase1 failed");
+ check(multiple_inheritance_shared_ptr.MakePtrDerived3_CBase2().cbase2()!=8, "MakePtrDerived3_CBase2 failed");
+
+ // Return references
+ check(multiple_inheritance_shared_ptr.MakeRefDerived1_CBase1().cbase1y()!=3, "MakeRefDerived1_CBase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeRefDerived1_CBase2().cbase2()!=4, "MakeRefDerived1_CBase2 failed");
+ check(multiple_inheritance_shared_ptr.MakeRefDerived2_CBase1().cbase1y()!=6, "MakeRefDerived2_CBase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeRefDerived2_ABase1().abase1()!=5, "MakeRefDerived2_ABase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeRefDerived3_ABase1().abase1()!=9, "MakeRefDerived3_ABase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeRefDerived3_CBase1().cbase1y()!=7, "MakeRefDerived3_CBase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeRefDerived3_CBase2().cbase2()!=8, "MakeRefDerived3_CBase2 failed");
+
+ // Return by value (sliced objects)
+ check(multiple_inheritance_shared_ptr.MakeValDerived1_CBase1().cbase1y()!=1, "MakeValDerived1_CBase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeValDerived1_CBase2().cbase2()!=2, "MakeValDerived1_CBase2 failed");
+ check(multiple_inheritance_shared_ptr.MakeValDerived2_CBase1().cbase1y()!=1, "MakeValDerived2_CBase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeValDerived3_CBase1().cbase1y()!=1, "MakeValDerived3_CBase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeValDerived3_CBase2().cbase2()!=2, "MakeValDerived3_CBase2 failed");
+
+ // Return smart pointers
+ check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived1_CBase1().cbase1y()!=3, "MakeSharedPtrDerived1_CBase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived1_CBase2().cbase2()!=4, "MakeSharedPtrDerived1_CBase2 failed");
+ check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived2_CBase1().cbase1y()!=6, "MakeSharedPtrDerived2_CBase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived2_ABase1().abase1()!=5, "MakeSharedPtrDerived2_ABase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived3_ABase1().abase1()!=9, "MakeSharedPtrDerived3_ABase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived3_CBase1().cbase1y()!=7, "MakeSharedPtrDerived3_CBase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived3_CBase2().cbase2()!=8, "MakeSharedPtrDerived3_CBase2 failed");
+
+ // Return smart pointers references
+ check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived1_CBase1().cbase1y()!=3, "MakeSharedPtrRefDerived1_CBase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived1_CBase2().cbase2()!=4, "MakeSharedPtrRefDerived1_CBase2 failed");
+ check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived2_CBase1().cbase1y()!=6, "MakeSharedPtrRefDerived2_CBase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived2_ABase1().abase1()!=5, "MakeSharedPtrRefDerived2_ABase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived3_ABase1().abase1()!=9, "MakeSharedPtrRefDerived3_ABase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived3_CBase1().cbase1y()!=7, "MakeSharedPtrRefDerived3_CBase1 failed");
+ check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived3_CBase2().cbase2()!=8, "MakeSharedPtrRefDerived3_CBase2 failed");
+ }
+}
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/javascript/Makefile.in b/Examples/test-suite/javascript/Makefile.in
index c68dd22b2..b430f236f 100644
--- a/Examples/test-suite/javascript/Makefile.in
+++ b/Examples/test-suite/javascript/Makefile.in
@@ -66,18 +66,18 @@ ifeq (node,$(JSENGINE))
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='-javascript $(SWIGOPT) -o $*_wrap.cxx $(srcdir)/../$*.i' swiginvoke && \
- $(NODEGYP) --loglevel=silent --directory $* configure build 1>>/dev/null
+ $(COMPILETOOL) $(NODEGYP) --loglevel=silent --directory $* configure build 1>>/dev/null
swig_and_compile_cpp = \
$(setup_node) && \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='-c++ -javascript $(SWIGOPT) $(srcdir)/../$*.i' swiginvoke && \
- $(NODEGYP) --loglevel=silent --directory $* configure build 1>>/dev/null
+ $(COMPILETOOL) $(NODEGYP) --loglevel=silent --directory $* configure build 1>>/dev/null
run_testcase = \
if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then \
- env NODE_PATH=$$PWD:$(srcdir) $(NODEJS) $(srcdir)/$*$(SCRIPTSUFFIX); \
+ env NODE_PATH=$$PWD:$(srcdir) $(RUNTOOL) $(NODEJS) $(srcdir)/$*$(SCRIPTSUFFIX); \
fi
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/li_std_vector.i b/Examples/test-suite/li_std_vector.i
index 9c76659df..b728c55af 100644
--- a/Examples/test-suite/li_std_vector.i
+++ b/Examples/test-suite/li_std_vector.i
@@ -130,3 +130,13 @@ namespace aa {
std::vector< ::aa::Holder > vec1(std::vector< ::aa::Holder > x) { return x; }
%}
#endif
+
+// exercising vectors of strings
+%inline %{
+std::vector<std::string> RevStringVec (const std::vector<std::string> &In)
+ {
+ std::vector<std::string> result(In);
+ std::reverse(result.begin(), result.end());
+ return(result);
+ }
+%}
diff --git a/Examples/test-suite/long_long.i b/Examples/test-suite/long_long.i
index 74dd87a15..47acc15c6 100644
--- a/Examples/test-suite/long_long.i
+++ b/Examples/test-suite/long_long.i
@@ -38,3 +38,9 @@ unsigned long long ull;
#define lconst5 987654321LL
#define lconst6 987654321ULL
+
+%inline %{
+long long UnsignedToSigned(unsigned long long ull) {
+ return (long long)ull;
+}
+%}
diff --git a/Examples/test-suite/lua/Makefile.in b/Examples/test-suite/lua/Makefile.in
index 7be59214b..7a77bbb9e 100644
--- a/Examples/test-suite/lua/Makefile.in
+++ b/Examples/test-suite/lua/Makefile.in
@@ -14,6 +14,7 @@ top_builddir = @top_builddir@
CPP_TEST_CASES += \
lua_no_module_global \
+ lua_inherit_getitem \
C_TEST_CASES += \
diff --git a/Examples/test-suite/lua/funcptr_cpp_runme.lua b/Examples/test-suite/lua/funcptr_cpp_runme.lua
index 3b8469348..d814e059a 100644
--- a/Examples/test-suite/lua/funcptr_cpp_runme.lua
+++ b/Examples/test-suite/lua/funcptr_cpp_runme.lua
@@ -16,3 +16,4 @@ assert(fc.addByValue(5,10) == 15)
assert(fc.call1(fc.ADD_BY_VALUE, 5, 10) == 15)
assert(fc.call2(fc.ADD_BY_POINTER, 7, 9) == 16)
assert(fc.call3(fc.ADD_BY_REFERENCE, 8, 9) == 17)
+assert(fc.call1(fc.ADD_BY_VALUE_C, 2, 3) == 5)
diff --git a/Examples/test-suite/lua/lua_inherit_getitem_runme.lua b/Examples/test-suite/lua/lua_inherit_getitem_runme.lua
new file mode 100644
index 000000000..21c4796f8
--- /dev/null
+++ b/Examples/test-suite/lua/lua_inherit_getitem_runme.lua
@@ -0,0 +1,12 @@
+require("import") -- the import fn
+import("lua_inherit_getitem") -- import lib
+
+local t = lua_inherit_getitem;
+local base = t.CBase()
+local derived = t.CDerived()
+
+assert(base.Foo ~= nil)
+assert(base:Foo() == "CBase::Foo")
+assert(derived.Foo == base.Foo)
+assert(derived:Foo() == "CBase::Foo")
+
diff --git a/Examples/test-suite/lua_inherit_getitem.i b/Examples/test-suite/lua_inherit_getitem.i
new file mode 100644
index 000000000..82c055dd1
--- /dev/null
+++ b/Examples/test-suite/lua_inherit_getitem.i
@@ -0,0 +1,19 @@
+%module lua_inherit_getitem
+
+%inline %{
+
+class CBase {
+public:
+ const char* Foo(void) {
+ return "CBase::Foo";
+ }
+};
+
+class CDerived : public CBase {
+public:
+ void *__getitem(const char *name) const {
+ return NULL;
+ }
+};
+
+%}
diff --git a/Examples/test-suite/multiple_inheritance_abstract.i b/Examples/test-suite/multiple_inheritance_abstract.i
new file mode 100644
index 000000000..b54a37dea
--- /dev/null
+++ b/Examples/test-suite/multiple_inheritance_abstract.i
@@ -0,0 +1,328 @@
+// This is a copy of the multiple_inheritance_abstract test
+%module multiple_inheritance_abstract
+
+%warnfilter(SWIGWARN_RUBY_MULTIPLE_INHERITANCE,
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE); /* languages not supporting multiple inheritance or %interface */
+
+#if defined(SWIGJAVA) || defined(SWIGCSHARP)
+%include "swiginterface.i"
+%interface_impl(Space::ABase1)
+%interface_impl(Space::CBase1)
+%interface_impl(Space::CBase2)
+#endif
+
+#if defined(SWIGD)
+// Missing multiple inheritance support results in incorrect use of override
+%ignore CBase1;
+%ignore CBase2;
+#endif
+
+%inline %{
+namespace Space {
+ struct CBase1 {
+ virtual void cbase1x() {
+ return;
+ }
+ virtual int cbase1y() {
+ return 1;
+ }
+ int cbase1z() {
+ return 10;
+ }
+ virtual ~CBase1() {
+ }
+ };
+
+ struct CBase2 {
+ virtual int cbase2() {
+ return 2;
+ }
+ virtual ~CBase2() {
+ }
+ };
+
+ struct ABase1 {
+ virtual int abase1() = 0;
+ virtual ~ABase1() {
+ }
+ };
+
+ struct Derived1 : CBase2, CBase1 {
+ virtual void cbase1x() {
+ return;
+ }
+ virtual int cbase1y() {
+ return 3;
+ }
+ virtual int cbase2() {
+ return 4;
+ }
+ virtual CBase2 *cloneit() {
+ return new Derived1(*this);
+ }
+ void derived1() {
+ }
+ };
+
+ struct Derived2 : CBase1, ABase1 {
+ virtual void cbase1x() {
+ return;
+ }
+ virtual int cbase1y() {
+ return 6;
+ }
+ virtual int abase1() {
+ return 5;
+ }
+ virtual CBase1 *cloneit() {
+ return new Derived2(*this);
+ }
+ void derived2() {
+ }
+ };
+
+ struct Derived3 : ABase1, CBase1, CBase2 {
+ virtual int cbase1y() {
+ return 7;
+ }
+ virtual int cbase2() {
+ return 8;
+ }
+ virtual int abase1() {
+ return 9;
+ }
+ virtual void cbase1x() {
+ }
+ virtual ABase1 *cloneit() {
+ return new Derived3(*this);
+ }
+ void derived3() {
+ }
+ };
+
+ struct Bottom1 : Derived1 {
+ virtual void cbase1x() {
+ return;
+ }
+ virtual int cbase1y() {
+ return 103;
+ }
+ virtual int cbase2() {
+ return 104;
+ }
+ };
+
+ struct Bottom2 : Derived2 {
+ virtual int cbase1y() {
+ return 206;
+ }
+ virtual int abase1() {
+ return 205;
+ }
+ };
+
+ struct Bottom3 : Derived3 {
+ virtual int cbase1y() {
+ return 307;
+ }
+ virtual int cbase2() {
+ return 308;
+ }
+ virtual int abase1() {
+ return 309;
+ }
+ };
+
+ // Base classes as input
+ int InputValCBase1(CBase1 cb1) {
+ return cb1.cbase1y();
+ }
+ int InputValCBase2(CBase2 cb2) {
+ return cb2.cbase2();
+ }
+
+ int InputPtrABase1(ABase1 *pab1) {
+ return pab1->abase1();
+ }
+ int InputPtrCBase1(CBase1 *pcb1) {
+ return pcb1->cbase1y();
+ }
+ int InputPtrCBase2(CBase2 *pcb2) {
+ return pcb2->cbase2();
+ }
+
+ int InputRefABase1(ABase1 &rab1) {
+ return rab1.abase1();
+ }
+ int InputRefCBase1(CBase1 &rcb1) {
+ return rcb1.cbase1y();
+ }
+ int InputRefCBase2(CBase2 &rcb2) {
+ return rcb2.cbase2();
+ }
+
+ int InputCPtrRefABase1(ABase1 *const& pab1) {
+ return pab1->abase1();
+ }
+ int InputCPtrRefCBase1(CBase1 *const& pcb1) {
+ return pcb1->cbase1y();
+ }
+ int InputCPtrRefCBase2(CBase2 *const& pcb2) {
+ return pcb2->cbase2();
+ }
+
+ // Derived classes as input
+ int InputValDerived1(Derived1 d) {
+ return d.cbase1y() + d.cbase2();
+ }
+ int InputValDerived2(Derived2 d) {
+ return d.cbase1y() + d.abase1();
+ }
+ int InputValDerived3(Derived3 d) {
+ return d.cbase1y() + d.cbase2() + d.abase1();
+ }
+
+ int InputRefDerived1(Derived1 &d) {
+ return d.cbase1y() + d.cbase2();
+ }
+ int InputRefDerived2(Derived2 &d) {
+ return d.cbase1y() + d.abase1();
+ }
+ int InputRefDerived3(Derived3 &d) {
+ return d.cbase1y() + d.cbase2() + d.abase1();
+ }
+
+ int InputPtrDerived1(Derived1 *d) {
+ return d->cbase1y() + d->cbase2();
+ }
+ int InputPtrDerived2(Derived2 *d) {
+ return d->cbase1y() + d->abase1();
+ }
+ int InputPtrDerived3(Derived3 *d) {
+ return d->cbase1y() + d->cbase2() + d->abase1();
+ }
+
+ int InputCPtrRefDerived1(Derived1 *const& d) {
+ return d->cbase1y() + d->cbase2();
+ }
+ int InputCPtrRefDerived2(Derived2 *const& d) {
+ return d->cbase1y() + d->abase1();
+ }
+ int InputCPtrRefDerived3(Derived3 *const& d) {
+ return d->cbase1y() + d->cbase2() + d->abase1();
+ }
+
+ // Bottom classes as input
+ int InputValBottom1(Bottom1 d) {
+ return d.cbase1y() + d.cbase2();
+ }
+ int InputValBottom2(Bottom2 d) {
+ return d.cbase1y() + d.abase1();
+ }
+ int InputValBottom3(Bottom3 d) {
+ return d.cbase1y() + d.cbase2() + d.abase1();
+ }
+
+ int InputRefBottom1(Bottom1 &d) {
+ return d.cbase1y() + d.cbase2();
+ }
+ int InputRefBottom2(Bottom2 &d) {
+ return d.cbase1y() + d.abase1();
+ }
+ int InputRefBottom3(Bottom3 &d) {
+ return d.cbase1y() + d.cbase2() + d.abase1();
+ }
+
+ int InputPtrBottom1(Bottom1 *d) {
+ return d->cbase1y() + d->cbase2();
+ }
+ int InputPtrBottom2(Bottom2 *d) {
+ return d->cbase1y() + d->abase1();
+ }
+ int InputPtrBottom3(Bottom3 *d) {
+ return d->cbase1y() + d->cbase2() + d->abase1();
+ }
+
+ int InputCPtrRefBottom1(Bottom1 *const& d) {
+ return d->cbase1y() + d->cbase2();
+ }
+ int InputCPtrRefBottom2(Bottom2 *const& d) {
+ return d->cbase1y() + d->abase1();
+ }
+ int InputCPtrRefBottom3(Bottom3 *const& d) {
+ return d->cbase1y() + d->cbase2() + d->abase1();
+ }
+
+ // Return pointers
+ CBase1 *MakePtrDerived1_CBase1() {
+ return new Derived1();
+ }
+ CBase2 *MakePtrDerived1_CBase2() {
+ return new Derived1();
+ }
+ CBase1 *MakePtrDerived2_CBase1() {
+ return new Derived2();
+ }
+ ABase1 *MakePtrDerived2_ABase1() {
+ return new Derived2();
+ }
+ ABase1 *MakePtrDerived3_ABase1() {
+ return new Derived3();
+ }
+ CBase1 *MakePtrDerived3_CBase1() {
+ return new Derived3();
+ }
+ CBase2 *MakePtrDerived3_CBase2() {
+ return new Derived3();
+ }
+
+ // Return references
+ CBase1 &MakeRefDerived1_CBase1() {
+ static Derived1 d;
+ return d;
+ }
+ CBase2 &MakeRefDerived1_CBase2() {
+ static Derived1 d;
+ return d;
+ }
+ CBase1 &MakeRefDerived2_CBase1() {
+ static Derived2 d;
+ return d;
+ }
+ ABase1 &MakeRefDerived2_ABase1() {
+ static Derived2 d;
+ return d;
+ }
+ ABase1 &MakeRefDerived3_ABase1() {
+ static Derived3 d;
+ return d;
+ }
+ CBase1 &MakeRefDerived3_CBase1() {
+ static Derived3 d;
+ return d;
+ }
+ CBase2 &MakeRefDerived3_CBase2() {
+ static Derived3 d;
+ return d;
+ }
+
+ // Return by value (sliced objects)
+ CBase1 MakeValDerived1_CBase1() {
+ return Derived1();
+ }
+ CBase2 MakeValDerived1_CBase2() {
+ return Derived1();
+ }
+ CBase1 MakeValDerived2_CBase1() {
+ return Derived2();
+ }
+ CBase1 MakeValDerived3_CBase1() {
+ return Derived3();
+ }
+ CBase2 MakeValDerived3_CBase2() {
+ return Derived3();
+ }
+}
+
+%}
diff --git a/Examples/test-suite/multiple_inheritance_interfaces.i b/Examples/test-suite/multiple_inheritance_interfaces.i
new file mode 100644
index 000000000..2972922fb
--- /dev/null
+++ b/Examples/test-suite/multiple_inheritance_interfaces.i
@@ -0,0 +1,66 @@
+%module multiple_inheritance_interfaces
+
+%warnfilter(SWIGWARN_RUBY_MULTIPLE_INHERITANCE,
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE); /* languages not supporting multiple inheritance or %interface */
+
+#if defined(SWIGJAVA) || defined(SWIGCSHARP)
+%include "swiginterface.i"
+%interface_custom("A", "IA", IA)
+%interface_custom("B", "IB", IB)
+%interface_custom("%(strip:[I])s", "I%s", IC) // same as %interface_custom("C", "IC", IC)
+#endif
+
+%inline %{
+struct IA {
+ virtual void ia() {};
+ virtual void ia(const char *s, bool b = true) {}
+ virtual void ia(int i) {}
+ virtual ~IA() {}
+};
+struct IB { virtual ~IB() {} virtual void ib() {} };
+struct IC : IA, IB {};
+struct D : IC {};
+struct E : D {};
+%}
+
+#if defined(SWIGJAVA) || defined(SWIGCSHARP)
+%interface_custom("J", "IJ", IJ)
+%interface_custom("K", "IK", IK)
+%interface_custom("L", "IL", IL)
+#endif
+%inline %{
+struct IJ { virtual ~IJ() {}; virtual void ij() {} };
+struct IK : IJ {};
+struct IL : IK {};
+struct M : IL {};
+%}
+
+#if defined(SWIGJAVA) || defined(SWIGCSHARP)
+%interface_custom("Q", "IQ", IQ)
+#endif
+%inline %{
+struct P { virtual ~P() {} virtual void p() {} };
+struct IQ { virtual ~IQ() {} virtual void iq() {} };
+struct R : IQ, P {};
+struct S : P, IQ {};
+struct T : IQ {};
+struct U : R {};
+struct V : S {};
+struct W : T {};
+%}
+
+#if defined(SWIGJAVA) || defined(SWIGCSHARP)
+%interface_impl(BaseOverloaded);
+#endif
+%inline %{
+struct BaseOverloaded {
+ typedef P PTypedef;
+ virtual ~BaseOverloaded() {}
+ virtual void identical_overload(int i, const PTypedef &pp = PTypedef()) {}
+};
+
+struct DerivedOverloaded : public BaseOverloaded {
+ virtual void identical_overload(int i, const PTypedef &p = PTypedef()) {}
+};
+%}
diff --git a/Examples/test-suite/multiple_inheritance_nspace.i b/Examples/test-suite/multiple_inheritance_nspace.i
new file mode 100644
index 000000000..4faef5749
--- /dev/null
+++ b/Examples/test-suite/multiple_inheritance_nspace.i
@@ -0,0 +1,338 @@
+// This is a copy of the multiple_inheritance_abstract test
+%module multiple_inheritance_nspace
+
+%warnfilter(SWIGWARN_RUBY_MULTIPLE_INHERITANCE,
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE); /* languages not supporting multiple inheritance or %interface */
+
+// nspace feature only supported by these languages
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD) || defined(SWIGLUA) || defined(SWIGJAVASCRIPT)
+%nspace;
+#endif
+
+#if defined(SWIGJAVA) || defined(SWIGCSHARP)
+%include "swiginterface.i"
+%interface(Space::ABase1)
+%interface(Space::CBase1)
+%interface(Space::CBase2)
+#endif
+
+#if defined(SWIGD)
+// Missing multiple inheritance support results in incorrect use of override
+%ignore CBase1;
+%ignore CBase2;
+#endif
+
+#if defined(SWIGJAVA)
+SWIG_JAVABODY_PROXY(public, public, SWIGTYPE)
+#endif
+
+%inline %{
+namespace Space {
+ struct CBase1 {
+ virtual void cbase1x() {
+ return;
+ }
+ virtual int cbase1y() {
+ return 1;
+ }
+ int cbase1z() {
+ return 10;
+ }
+ virtual ~CBase1() {
+ }
+ };
+
+ struct CBase2 {
+ virtual int cbase2() {
+ return 2;
+ }
+ virtual ~CBase2() {
+ }
+ };
+
+ struct ABase1 {
+ virtual int abase1() = 0;
+ virtual ~ABase1() {
+ }
+ };
+
+ struct Derived1 : CBase2, CBase1 {
+ virtual void cbase1x() {
+ return;
+ }
+ virtual int cbase1y() {
+ return 3;
+ }
+ virtual int cbase2() {
+ return 4;
+ }
+ virtual CBase2 *cloneit() {
+ return new Derived1(*this);
+ }
+ void derived1() {
+ }
+ };
+
+ struct Derived2 : CBase1, ABase1 {
+ virtual void cbase1x() {
+ return;
+ }
+ virtual int cbase1y() {
+ return 6;
+ }
+ virtual int abase1() {
+ return 5;
+ }
+ virtual CBase1 *cloneit() {
+ return new Derived2(*this);
+ }
+ void derived2() {
+ }
+ };
+
+ struct Derived3 : ABase1, CBase1, CBase2 {
+ virtual int cbase1y() {
+ return 7;
+ }
+ virtual int cbase2() {
+ return 8;
+ }
+ virtual int abase1() {
+ return 9;
+ }
+ virtual void cbase1x() {
+ }
+ virtual ABase1 *cloneit() {
+ return new Derived3(*this);
+ }
+ void derived3() {
+ }
+ };
+
+ struct Bottom1 : Derived1 {
+ virtual void cbase1x() {
+ return;
+ }
+ virtual int cbase1y() {
+ return 103;
+ }
+ virtual int cbase2() {
+ return 104;
+ }
+ };
+
+ struct Bottom2 : Derived2 {
+ virtual int cbase1y() {
+ return 206;
+ }
+ virtual int abase1() {
+ return 205;
+ }
+ };
+
+ struct Bottom3 : Derived3 {
+ virtual int cbase1y() {
+ return 307;
+ }
+ virtual int cbase2() {
+ return 308;
+ }
+ virtual int abase1() {
+ return 309;
+ }
+ };
+
+ // Base classes as input
+ int InputValCBase1(CBase1 cb1) {
+ return cb1.cbase1y();
+ }
+ int InputValCBase2(CBase2 cb2) {
+ return cb2.cbase2();
+ }
+
+ int InputPtrABase1(ABase1 *pab1) {
+ return pab1->abase1();
+ }
+ int InputPtrCBase1(CBase1 *pcb1) {
+ return pcb1->cbase1y();
+ }
+ int InputPtrCBase2(CBase2 *pcb2) {
+ return pcb2->cbase2();
+ }
+
+ int InputRefABase1(ABase1 &rab1) {
+ return rab1.abase1();
+ }
+ int InputRefCBase1(CBase1 &rcb1) {
+ return rcb1.cbase1y();
+ }
+ int InputRefCBase2(CBase2 &rcb2) {
+ return rcb2.cbase2();
+ }
+
+ int InputCPtrRefABase1(ABase1 *const& pab1) {
+ return pab1->abase1();
+ }
+ int InputCPtrRefCBase1(CBase1 *const& pcb1) {
+ return pcb1->cbase1y();
+ }
+ int InputCPtrRefCBase2(CBase2 *const& pcb2) {
+ return pcb2->cbase2();
+ }
+
+ // Derived classes as input
+ int InputValDerived1(Derived1 d) {
+ return d.cbase1y() + d.cbase2();
+ }
+ int InputValDerived2(Derived2 d) {
+ return d.cbase1y() + d.abase1();
+ }
+ int InputValDerived3(Derived3 d) {
+ return d.cbase1y() + d.cbase2() + d.abase1();
+ }
+
+ int InputRefDerived1(Derived1 &d) {
+ return d.cbase1y() + d.cbase2();
+ }
+ int InputRefDerived2(Derived2 &d) {
+ return d.cbase1y() + d.abase1();
+ }
+ int InputRefDerived3(Derived3 &d) {
+ return d.cbase1y() + d.cbase2() + d.abase1();
+ }
+
+ int InputPtrDerived1(Derived1 *d) {
+ return d->cbase1y() + d->cbase2();
+ }
+ int InputPtrDerived2(Derived2 *d) {
+ return d->cbase1y() + d->abase1();
+ }
+ int InputPtrDerived3(Derived3 *d) {
+ return d->cbase1y() + d->cbase2() + d->abase1();
+ }
+
+ int InputCPtrRefDerived1(Derived1 *const& d) {
+ return d->cbase1y() + d->cbase2();
+ }
+ int InputCPtrRefDerived2(Derived2 *const& d) {
+ return d->cbase1y() + d->abase1();
+ }
+ int InputCPtrRefDerived3(Derived3 *const& d) {
+ return d->cbase1y() + d->cbase2() + d->abase1();
+ }
+
+ // Bottom classes as input
+ int InputValBottom1(Bottom1 d) {
+ return d.cbase1y() + d.cbase2();
+ }
+ int InputValBottom2(Bottom2 d) {
+ return d.cbase1y() + d.abase1();
+ }
+ int InputValBottom3(Bottom3 d) {
+ return d.cbase1y() + d.cbase2() + d.abase1();
+ }
+
+ int InputRefBottom1(Bottom1 &d) {
+ return d.cbase1y() + d.cbase2();
+ }
+ int InputRefBottom2(Bottom2 &d) {
+ return d.cbase1y() + d.abase1();
+ }
+ int InputRefBottom3(Bottom3 &d) {
+ return d.cbase1y() + d.cbase2() + d.abase1();
+ }
+
+ int InputPtrBottom1(Bottom1 *d) {
+ return d->cbase1y() + d->cbase2();
+ }
+ int InputPtrBottom2(Bottom2 *d) {
+ return d->cbase1y() + d->abase1();
+ }
+ int InputPtrBottom3(Bottom3 *d) {
+ return d->cbase1y() + d->cbase2() + d->abase1();
+ }
+
+ int InputCPtrRefBottom1(Bottom1 *const& d) {
+ return d->cbase1y() + d->cbase2();
+ }
+ int InputCPtrRefBottom2(Bottom2 *const& d) {
+ return d->cbase1y() + d->abase1();
+ }
+ int InputCPtrRefBottom3(Bottom3 *const& d) {
+ return d->cbase1y() + d->cbase2() + d->abase1();
+ }
+
+ // Return pointers
+ CBase1 *MakePtrDerived1_CBase1() {
+ return new Derived1();
+ }
+ CBase2 *MakePtrDerived1_CBase2() {
+ return new Derived1();
+ }
+ CBase1 *MakePtrDerived2_CBase1() {
+ return new Derived2();
+ }
+ ABase1 *MakePtrDerived2_ABase1() {
+ return new Derived2();
+ }
+ ABase1 *MakePtrDerived3_ABase1() {
+ return new Derived3();
+ }
+ CBase1 *MakePtrDerived3_CBase1() {
+ return new Derived3();
+ }
+ CBase2 *MakePtrDerived3_CBase2() {
+ return new Derived3();
+ }
+
+ // Return references
+ CBase1 &MakeRefDerived1_CBase1() {
+ static Derived1 d;
+ return d;
+ }
+ CBase2 &MakeRefDerived1_CBase2() {
+ static Derived1 d;
+ return d;
+ }
+ CBase1 &MakeRefDerived2_CBase1() {
+ static Derived2 d;
+ return d;
+ }
+ ABase1 &MakeRefDerived2_ABase1() {
+ static Derived2 d;
+ return d;
+ }
+ ABase1 &MakeRefDerived3_ABase1() {
+ static Derived3 d;
+ return d;
+ }
+ CBase1 &MakeRefDerived3_CBase1() {
+ static Derived3 d;
+ return d;
+ }
+ CBase2 &MakeRefDerived3_CBase2() {
+ static Derived3 d;
+ return d;
+ }
+
+ // Return by value (sliced objects)
+ CBase1 MakeValDerived1_CBase1() {
+ return Derived1();
+ }
+ CBase2 MakeValDerived1_CBase2() {
+ return Derived1();
+ }
+ CBase1 MakeValDerived2_CBase1() {
+ return Derived2();
+ }
+ CBase1 MakeValDerived3_CBase1() {
+ return Derived3();
+ }
+ CBase2 MakeValDerived3_CBase2() {
+ return Derived3();
+ }
+}
+
+%}
+
diff --git a/Examples/test-suite/multiple_inheritance_shared_ptr.i b/Examples/test-suite/multiple_inheritance_shared_ptr.i
new file mode 100644
index 000000000..5a08e5e6e
--- /dev/null
+++ b/Examples/test-suite/multiple_inheritance_shared_ptr.i
@@ -0,0 +1,499 @@
+// This is a copy of the multiple_inheritance_abstract test and extended for testing %shared_ptr and %interface_impl
+%module multiple_inheritance_shared_ptr
+
+%warnfilter(SWIGWARN_RUBY_MULTIPLE_INHERITANCE,
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE); /* languages not supporting multiple inheritance or %interface */
+
+// Typemap changes required to mix %shared_ptr and %interface_impl
+// Note we don't have a way to use $javainterfacename/$csinterfacename (yet),
+// so we improvise somewhat by adding the SwigImpl suffix
+%define SWIG_SHARED_PTR_INTERFACE_TYPEMAPS(CONST, TYPE...)
+#if defined(SWIGJAVA)
+%typemap(javain) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "($javainput == null) ? 0 : $javainput.$typemap(jstype, TYPE)_GetInterfaceCPtr()"
+%typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& {
+ long cPtr = $jnicall;
+ return (cPtr == 0) ? null : ($typemap(jstype, TYPE))new $typemap(jstype, TYPE)SwigImpl(cPtr, true);
+ }
+#elif defined(SWIGCSHARP)
+%typemap(csin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "$csinput == null ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : $csinput.GetInterfaceCPtr()"
+%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *,
+ 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)SwigImpl(cPtr, true);$excode
+ return ret;
+ }
+#endif
+%enddef
+
+#if defined(SWIGJAVA) || defined(SWIGCSHARP)
+%include <boost_shared_ptr.i>
+%shared_ptr(Space::ABase1)
+%shared_ptr(Space::CBase1)
+%shared_ptr(Space::CBase2)
+%shared_ptr(Space::Derived1)
+%shared_ptr(Space::Derived2)
+%shared_ptr(Space::Derived3)
+%shared_ptr(Space::Bottom1)
+%shared_ptr(Space::Bottom2)
+%shared_ptr(Space::Bottom3)
+
+%include "swiginterface.i"
+SWIG_SHARED_PTR_INTERFACE_TYPEMAPS(SWIGEMPTYHACK, Space::ABase1)
+SWIG_SHARED_PTR_INTERFACE_TYPEMAPS(SWIGEMPTYHACK, Space::CBase1)
+SWIG_SHARED_PTR_INTERFACE_TYPEMAPS(SWIGEMPTYHACK, Space::CBase2)
+%interface_impl(Space::ABase1)
+%interface_impl(Space::CBase1)
+%interface_impl(Space::CBase2)
+#endif
+
+#if defined(SWIGD)
+// Missing multiple inheritance support results in incorrect use of override
+%ignore CBase1;
+%ignore CBase2;
+#endif
+
+%inline %{
+#include <boost/shared_ptr.hpp>
+
+namespace Space {
+ struct CBase1 {
+ virtual void cbase1x() {
+ return;
+ }
+ virtual int cbase1y() {
+ return 1;
+ }
+ int cbase1z() {
+ return 10;
+ }
+ virtual ~CBase1() {
+ }
+ };
+
+ struct CBase2 {
+ virtual int cbase2() {
+ return 2;
+ }
+ virtual ~CBase2() {
+ }
+ };
+
+ struct ABase1 {
+ virtual int abase1() = 0;
+ virtual ~ABase1() {
+ }
+ };
+
+ struct Derived1 : CBase2, CBase1 {
+ virtual void cbase1x() {
+ return;
+ }
+ virtual int cbase1y() {
+ return 3;
+ }
+ virtual int cbase2() {
+ return 4;
+ }
+ virtual CBase2 *cloneit() {
+ return new Derived1(*this);
+ }
+ void derived1() {
+ }
+ };
+
+ struct Derived2 : CBase1, ABase1 {
+ virtual void cbase1x() {
+ return;
+ }
+ virtual int cbase1y() {
+ return 6;
+ }
+ virtual int abase1() {
+ return 5;
+ }
+ virtual CBase1 *cloneit() {
+ return new Derived2(*this);
+ }
+ void derived2() {
+ }
+ };
+
+ struct Derived3 : ABase1, CBase1, CBase2 {
+ virtual int cbase1y() {
+ return 7;
+ }
+ virtual int cbase2() {
+ return 8;
+ }
+ virtual int abase1() {
+ return 9;
+ }
+ virtual void cbase1x() {
+ }
+ virtual ABase1 *cloneit() {
+ return new Derived3(*this);
+ }
+ void derived3() {
+ }
+ };
+
+ struct Bottom1 : Derived1 {
+ virtual void cbase1x() {
+ return;
+ }
+ virtual int cbase1y() {
+ return 103;
+ }
+ virtual int cbase2() {
+ return 104;
+ }
+ };
+
+ struct Bottom2 : Derived2 {
+ virtual int cbase1y() {
+ return 206;
+ }
+ virtual int abase1() {
+ return 205;
+ }
+ };
+
+ struct Bottom3 : Derived3 {
+ virtual int cbase1y() {
+ return 307;
+ }
+ virtual int cbase2() {
+ return 308;
+ }
+ virtual int abase1() {
+ return 309;
+ }
+ };
+
+ typedef boost::shared_ptr<ABase1> ABase1_SharedPtr;
+ typedef boost::shared_ptr<CBase1> CBase1_SharedPtr;
+ typedef boost::shared_ptr<CBase2> CBase2_SharedPtr;
+ typedef boost::shared_ptr<Derived1> Derived1_SharedPtr;
+ typedef boost::shared_ptr<Derived2> Derived2_SharedPtr;
+ typedef boost::shared_ptr<Derived3> Derived3_SharedPtr;
+ typedef boost::shared_ptr<Bottom1> Bottom1_SharedPtr;
+ typedef boost::shared_ptr<Bottom2> Bottom2_SharedPtr;
+ typedef boost::shared_ptr<Bottom3> Bottom3_SharedPtr;
+
+ // Base classes as input
+ int InputValCBase1(CBase1 cb1) {
+ return cb1.cbase1y();
+ }
+ int InputValCBase2(CBase2 cb2) {
+ return cb2.cbase2();
+ }
+
+ int InputPtrABase1(ABase1 *pab1) {
+ return pab1->abase1();
+ }
+ int InputPtrCBase1(CBase1 *pcb1) {
+ return pcb1->cbase1y();
+ }
+ int InputPtrCBase2(CBase2 *pcb2) {
+ return pcb2->cbase2();
+ }
+
+ int InputRefABase1(ABase1 &rab1) {
+ return rab1.abase1();
+ }
+ int InputRefCBase1(CBase1 &rcb1) {
+ return rcb1.cbase1y();
+ }
+ int InputRefCBase2(CBase2 &rcb2) {
+ return rcb2.cbase2();
+ }
+
+ int InputCPtrRefABase1(ABase1 *const& pab1) {
+ return pab1->abase1();
+ }
+ int InputCPtrRefCBase1(CBase1 *const& pcb1) {
+ return pcb1->cbase1y();
+ }
+ int InputCPtrRefCBase2(CBase2 *const& pcb2) {
+ return pcb2->cbase2();
+ }
+
+ int InputSharedPtrABase1(ABase1_SharedPtr pab1) {
+ return pab1->abase1();
+ }
+ int InputSharedPtrCBase1(CBase1_SharedPtr pcb1) {
+ return pcb1->cbase1y();
+ }
+ int InputSharedPtrCBase2(CBase2_SharedPtr pcb2) {
+ return pcb2->cbase2();
+ }
+
+ int InputSharedPtrRefABase1(ABase1_SharedPtr &pab1) {
+ return pab1->abase1();
+ }
+ int InputSharedPtrRefCBase1(CBase1_SharedPtr &pcb1) {
+ return pcb1->cbase1y();
+ }
+ int InputSharedPtrRefCBase2(CBase2_SharedPtr &pcb2) {
+ return pcb2->cbase2();
+ }
+
+ // Derived classes as input
+ int InputValDerived1(Derived1 d) {
+ return d.cbase1y() + d.cbase2();
+ }
+ int InputValDerived2(Derived2 d) {
+ return d.cbase1y() + d.abase1();
+ }
+ int InputValDerived3(Derived3 d) {
+ return d.cbase1y() + d.cbase2() + d.abase1();
+ }
+
+ int InputRefDerived1(Derived1 &d) {
+ return d.cbase1y() + d.cbase2();
+ }
+ int InputRefDerived2(Derived2 &d) {
+ return d.cbase1y() + d.abase1();
+ }
+ int InputRefDerived3(Derived3 &d) {
+ return d.cbase1y() + d.cbase2() + d.abase1();
+ }
+
+ int InputPtrDerived1(Derived1 *d) {
+ return d->cbase1y() + d->cbase2();
+ }
+ int InputPtrDerived2(Derived2 *d) {
+ return d->cbase1y() + d->abase1();
+ }
+ int InputPtrDerived3(Derived3 *d) {
+ return d->cbase1y() + d->cbase2() + d->abase1();
+ }
+
+ int InputCPtrRefDerived1(Derived1 *const& d) {
+ return d->cbase1y() + d->cbase2();
+ }
+ int InputCPtrRefDerived2(Derived2 *const& d) {
+ return d->cbase1y() + d->abase1();
+ }
+ int InputCPtrRefDerived3(Derived3 *const& d) {
+ return d->cbase1y() + d->cbase2() + d->abase1();
+ }
+
+ int InputSharedPtrDerived1(Derived1_SharedPtr d) {
+ return d->cbase1y() + d->cbase2();
+ }
+ int InputSharedPtrDerived2(Derived2_SharedPtr d) {
+ return d->cbase1y() + d->abase1();
+ }
+ int InputSharedPtrDerived3(Derived3_SharedPtr d) {
+ return d->cbase1y() + d->cbase2() + d->abase1();
+ }
+
+ int InputSharedPtrRefDerived1(Derived1_SharedPtr &d) {
+ return d->cbase1y() + d->cbase2();
+ }
+ int InputSharedPtrRefDerived2(Derived2_SharedPtr &d) {
+ return d->cbase1y() + d->abase1();
+ }
+ int InputSharedPtrRefDerived3(Derived3_SharedPtr &d) {
+ return d->cbase1y() + d->cbase2() + d->abase1();
+ }
+
+ // Bottom classes as input
+ int InputValBottom1(Bottom1 d) {
+ return d.cbase1y() + d.cbase2();
+ }
+ int InputValBottom2(Bottom2 d) {
+ return d.cbase1y() + d.abase1();
+ }
+ int InputValBottom3(Bottom3 d) {
+ return d.cbase1y() + d.cbase2() + d.abase1();
+ }
+
+ int InputRefBottom1(Bottom1 &d) {
+ return d.cbase1y() + d.cbase2();
+ }
+ int InputRefBottom2(Bottom2 &d) {
+ return d.cbase1y() + d.abase1();
+ }
+ int InputRefBottom3(Bottom3 &d) {
+ return d.cbase1y() + d.cbase2() + d.abase1();
+ }
+
+ int InputPtrBottom1(Bottom1 *d) {
+ return d->cbase1y() + d->cbase2();
+ }
+ int InputPtrBottom2(Bottom2 *d) {
+ return d->cbase1y() + d->abase1();
+ }
+ int InputPtrBottom3(Bottom3 *d) {
+ return d->cbase1y() + d->cbase2() + d->abase1();
+ }
+
+ int InputCPtrRefBottom1(Bottom1 *const& d) {
+ return d->cbase1y() + d->cbase2();
+ }
+ int InputCPtrRefBottom2(Bottom2 *const& d) {
+ return d->cbase1y() + d->abase1();
+ }
+ int InputCPtrRefBottom3(Bottom3 *const& d) {
+ return d->cbase1y() + d->cbase2() + d->abase1();
+ }
+
+ int InputSharedPtrBottom1(Bottom1_SharedPtr d) {
+ return d->cbase1y() + d->cbase2();
+ }
+ int InputSharedPtrBottom2(Bottom2_SharedPtr d) {
+ return d->cbase1y() + d->abase1();
+ }
+ int InputSharedPtrBottom3(Bottom3_SharedPtr d) {
+ return d->cbase1y() + d->cbase2() + d->abase1();
+ }
+
+ int InputSharedPtrRefBottom1(Bottom1_SharedPtr &d) {
+ return d->cbase1y() + d->cbase2();
+ }
+ int InputSharedPtrRefBottom2(Bottom2_SharedPtr &d) {
+ return d->cbase1y() + d->abase1();
+ }
+ int InputSharedPtrRefBottom3(Bottom3_SharedPtr &d) {
+ return d->cbase1y() + d->cbase2() + d->abase1();
+ }
+
+ // Return pointers
+ CBase1 *MakePtrDerived1_CBase1() {
+ return new Derived1();
+ }
+ CBase2 *MakePtrDerived1_CBase2() {
+ return new Derived1();
+ }
+ CBase1 *MakePtrDerived2_CBase1() {
+ return new Derived2();
+ }
+ ABase1 *MakePtrDerived2_ABase1() {
+ return new Derived2();
+ }
+ ABase1 *MakePtrDerived3_ABase1() {
+ return new Derived3();
+ }
+ CBase1 *MakePtrDerived3_CBase1() {
+ return new Derived3();
+ }
+ CBase2 *MakePtrDerived3_CBase2() {
+ return new Derived3();
+ }
+
+ // Return references
+ CBase1 &MakeRefDerived1_CBase1() {
+ static Derived1 d;
+ return d;
+ }
+ CBase2 &MakeRefDerived1_CBase2() {
+ static Derived1 d;
+ return d;
+ }
+ CBase1 &MakeRefDerived2_CBase1() {
+ static Derived2 d;
+ return d;
+ }
+ ABase1 &MakeRefDerived2_ABase1() {
+ static Derived2 d;
+ return d;
+ }
+ ABase1 &MakeRefDerived3_ABase1() {
+ static Derived3 d;
+ return d;
+ }
+ CBase1 &MakeRefDerived3_CBase1() {
+ static Derived3 d;
+ return d;
+ }
+ CBase2 &MakeRefDerived3_CBase2() {
+ static Derived3 d;
+ return d;
+ }
+
+ // Return by value (sliced objects)
+ CBase1 MakeValDerived1_CBase1() {
+ return Derived1();
+ }
+ CBase2 MakeValDerived1_CBase2() {
+ return Derived1();
+ }
+ CBase1 MakeValDerived2_CBase1() {
+ return Derived2();
+ }
+ CBase1 MakeValDerived3_CBase1() {
+ return Derived3();
+ }
+ CBase2 MakeValDerived3_CBase2() {
+ return Derived3();
+ }
+
+ // Return smart pointers
+ CBase1_SharedPtr MakeSharedPtrDerived1_CBase1() {
+ return CBase1_SharedPtr(new Derived1());
+ }
+ CBase2_SharedPtr MakeSharedPtrDerived1_CBase2() {
+ return CBase2_SharedPtr(new Derived1());
+ }
+ CBase1_SharedPtr MakeSharedPtrDerived2_CBase1() {
+ return CBase1_SharedPtr(new Derived2());
+ }
+ ABase1_SharedPtr MakeSharedPtrDerived2_ABase1() {
+ return ABase1_SharedPtr(new Derived2());
+ }
+ ABase1_SharedPtr MakeSharedPtrDerived3_ABase1() {
+ return ABase1_SharedPtr(new Derived3());
+ }
+ CBase1_SharedPtr MakeSharedPtrDerived3_CBase1() {
+ return CBase1_SharedPtr(new Derived3());
+ }
+ CBase2_SharedPtr MakeSharedPtrDerived3_CBase2() {
+ return CBase2_SharedPtr(new Derived3());
+ }
+
+ // Return smart pointer references
+ CBase1_SharedPtr MakeSharedPtrRefDerived1_CBase1() {
+ static CBase1_SharedPtr s(new Derived1());
+ return s;
+ }
+ CBase2_SharedPtr MakeSharedPtrRefDerived1_CBase2() {
+ static CBase2_SharedPtr s(new Derived1());
+ return s;
+ }
+ CBase1_SharedPtr MakeSharedPtrRefDerived2_CBase1() {
+ static CBase1_SharedPtr s(new Derived2());
+ return s;
+ }
+ ABase1_SharedPtr MakeSharedPtrRefDerived2_ABase1() {
+ static ABase1_SharedPtr s(new Derived2());
+ return s;
+ }
+ ABase1_SharedPtr MakeSharedPtrRefDerived3_ABase1() {
+ static ABase1_SharedPtr s(new Derived3());
+ return s;
+ }
+ CBase1_SharedPtr MakeSharedPtrRefDerived3_CBase1() {
+ static CBase1_SharedPtr s(new Derived3());
+ return s;
+ }
+ CBase2_SharedPtr MakeSharedPtrRefDerived3_CBase2() {
+ static CBase2_SharedPtr s(new Derived3());
+ return s;
+ }
+}
+
+%}
diff --git a/Examples/test-suite/namespace_typemap.i b/Examples/test-suite/namespace_typemap.i
index 8ead78c6c..7f474bd9c 100644
--- a/Examples/test-suite/namespace_typemap.i
+++ b/Examples/test-suite/namespace_typemap.i
@@ -109,7 +109,11 @@ namespace test {
#ifdef SWIGGO
%typemap(gotype) string_class * "string"
%typemap(in) string_class * {
- $1 = new string_class($input.p);
+ char* buf = new char[$input.n + 1];
+ memcpy(buf, $input.p, $input.n);
+ buf[$input.n] = '\0';
+ $1 = new string_class(buf);
+ delete[] buf;
}
%typemap(freearg) string_class * {
delete $1;
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/nested_ignore.i b/Examples/test-suite/nested_ignore.i
new file mode 100644
index 000000000..e271eca7d
--- /dev/null
+++ b/Examples/test-suite/nested_ignore.i
@@ -0,0 +1,24 @@
+%module nested_ignore
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) B::C::D;
+
+%rename($ignore) B::C;
+
+%inline %{
+namespace B {
+ class C {
+ public:
+ struct D {
+ };
+ };
+
+ class E {
+ public:
+ typedef C::D D;
+ };
+
+ struct F
+ {
+ const E::D foo(){ return E::D(); }
+ };
+}
+%}
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/primitive_types.i b/Examples/test-suite/primitive_types.i
index 8eb2a13f2..b9b973a2b 100644
--- a/Examples/test-suite/primitive_types.i
+++ b/Examples/test-suite/primitive_types.i
@@ -2,6 +2,7 @@
%module(directors="1") primitive_types
#if defined(SWIGSCILAB)
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) ovr_str;
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) ovr_val;
%rename(TestDir) TestDirector;
#endif
diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in
index 0c47d19ce..a7993b0b8 100644
--- a/Examples/test-suite/python/Makefile.in
+++ b/Examples/test-suite/python/Makefile.in
@@ -130,11 +130,11 @@ py2_runme = $(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX)
py3_runme = $(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX)
ifneq (,$(PEP8))
-check_pep8 = $(PEP8) $(PEP8_FLAGS) $(SCRIPTPREFIX)$*.py
+check_pep8 = $(COMPILETOOL) $(PEP8) $(PEP8_FLAGS) $(SCRIPTPREFIX)$*.py
check_pep8_multi_cpp = \
for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \
- $(PEP8) $(PEP8_FLAGS) $$f.py; \
+ $(COMPILETOOL) $(PEP8) $(PEP8_FLAGS) $$f.py; \
done
endif
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/compactdefaultargs_runme.py b/Examples/test-suite/python/compactdefaultargs_runme.py
index e81c8d173..1096619f4 100644
--- a/Examples/test-suite/python/compactdefaultargs_runme.py
+++ b/Examples/test-suite/python/compactdefaultargs_runme.py
@@ -17,3 +17,6 @@ if defaults2.ret(10.0) != 10.0:
if defaults2.ret() != -1.0:
raise RuntimeError
+
+if defaults2.nodefault(-2) != -2:
+ raise RuntimeError
diff --git a/Examples/test-suite/python/constant_directive_runme.py b/Examples/test-suite/python/constant_directive_runme.py
index a7ed82b8b..e223cd261 100644
--- a/Examples/test-suite/python/constant_directive_runme.py
+++ b/Examples/test-suite/python/constant_directive_runme.py
@@ -18,3 +18,11 @@ if constant_directive.TYPE1_CONSTANT2.val != 2:
if constant_directive.TYPE1_CONSTANT3.val != 3:
raise RuntimeError("constant_directive.TYPE1_CONSTANT3.val is %r (should be 3)" %
constant_directive.TYPE1_CONSTANT3.val)
+
+if constant_directive.TYPE1CONST_CONSTANT1.val != 1:
+ raise RuntimeError("constant_directive.TYPE1CONST_CONSTANT1.val is %r (should be 1)" %
+ constant_directive.TYPE1CONST_CONSTANT1.val)
+
+if constant_directive.TYPE1CPTR_CONSTANT1.val != 1:
+ raise RuntimeError("constant_directive.TYPE1CPTR_CONSTANT1.val is %r (should be 1)" %
+ constant_directive.TYPE1CPTR_CONSTANT1.val)
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/default_args_runme.py b/Examples/test-suite/python/default_args_runme.py
index 6610a4ec4..9d275e4a1 100644
--- a/Examples/test-suite/python/default_args_runme.py
+++ b/Examples/test-suite/python/default_args_runme.py
@@ -136,5 +136,23 @@ def run(module_name):
if default_args.CDA().cdefaultargs_test2() != 1:
raise RuntimeError
+ if default_args.chartest1() != 'x':
+ raise RuntimeError
+
+ if default_args.chartest2() != '\0':
+ raise RuntimeError
+
+ if default_args.chartest3() != '\1':
+ raise RuntimeError
+
+ if default_args.chartest4() != '\n':
+ raise RuntimeError
+
+ if default_args.chartest5() != 'B':
+ raise RuntimeError
+
+ if default_args.chartest6() != 'C':
+ raise RuntimeError
+
if __name__ == "__main__":
run('default_args')
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/funcptr_cpp_runme.py b/Examples/test-suite/python/funcptr_cpp_runme.py
index 08e85ad7b..eb113d226 100644
--- a/Examples/test-suite/python/funcptr_cpp_runme.py
+++ b/Examples/test-suite/python/funcptr_cpp_runme.py
@@ -6,3 +6,5 @@ if call2(ADD_BY_POINTER, 12, 13) != 25:
raise RuntimeError
if call3(ADD_BY_REFERENCE, 14, 15) != 29:
raise RuntimeError
+if call1(ADD_BY_VALUE_C, 2, 3) != 5:
+ raise RuntimeError
diff --git a/Examples/test-suite/python/li_attribute_runme.py b/Examples/test-suite/python/li_attribute_runme.py
index 13a01c97d..80e793618 100644
--- a/Examples/test-suite/python/li_attribute_runme.py
+++ b/Examples/test-suite/python/li_attribute_runme.py
@@ -71,3 +71,13 @@ if myStringyClass.ReadWriteString != "changed string":
raise RuntimeError
if myStringyClass.ReadOnlyString != "changed string":
raise RuntimeError
+
+# Check a proper AttributeError is raised for non-existent attributes, old versions used to raise unhelpful error:
+# AttributeError: type object 'object' has no attribute '__getattr__'
+try:
+ x = myFoo.does_not_exist
+ raise RuntimeError
+except AttributeError, e:
+ if str(e).find("does_not_exist") == -1:
+ raise RuntimeError
+
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/rename_rstrip_encoder_runme.py b/Examples/test-suite/python/rename_rstrip_encoder_runme.py
new file mode 100644
index 000000000..84072f7f2
--- /dev/null
+++ b/Examples/test-suite/python/rename_rstrip_encoder_runme.py
@@ -0,0 +1,5 @@
+from rename_rstrip_encoder import *
+
+s = SomeThing()
+a = AnotherThing()
+a.DoClsX()
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/r/li_std_vector_runme.R b/Examples/test-suite/r/li_std_vector_runme.R
new file mode 100644
index 000000000..bd02d840a
--- /dev/null
+++ b/Examples/test-suite/r/li_std_vector_runme.R
@@ -0,0 +1,19 @@
+clargs <- commandArgs(trailing=TRUE)
+source(file.path(clargs[1], "unittest.R"))
+
+dyn.load(paste("li_std_vector", .Platform$dynlib.ext, sep=""))
+source("li_std_vector.R")
+cacheMetaData(1)
+
+testvec <- c(1, 2, 3)
+
+unittest(half(testvec), testvec/2)
+unittest(average(testvec), mean(testvec))
+## string vector test
+vlen <- 13
+stringvec <- paste(letters[1:vlen], as.character(rnorm(vlen)))
+unittest(rev(stringvec), RevStringVec(stringvec))
+q(save="no")
+
+
+
diff --git a/Examples/test-suite/r/unittest.R b/Examples/test-suite/r/unittest.R
index 0633c7715..b55b4a3f3 100644
--- a/Examples/test-suite/r/unittest.R
+++ b/Examples/test-suite/r/unittest.R
@@ -1,5 +1,5 @@
unittest <- function (x,y) {
- if (x==y) {
+ if (all(x==y)) {
print("PASS")
} else {
print("FAIL")
@@ -8,7 +8,7 @@ unittest <- function (x,y) {
}
unittesttol <- function(x,y,z) {
- if (abs(x-y) < z) {
+ if (all(abs(x-y) < z)) {
print("PASS")
} else {
print("FAIL")
diff --git a/Examples/test-suite/rename_rstrip_encoder.i b/Examples/test-suite/rename_rstrip_encoder.i
new file mode 100644
index 000000000..4ecbe129f
--- /dev/null
+++ b/Examples/test-suite/rename_rstrip_encoder.i
@@ -0,0 +1,15 @@
+%module rename_rstrip_encoder
+
+// strip the Cls suffix from all identifiers
+%rename("%(rstrip:[Cls])s") "";
+
+%inline %{
+
+class SomeThingCls {
+};
+
+struct AnotherThingCls {
+ void DoClsXCls() {}
+};
+
+%}
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/scilab/funcptr_cpp_runme.sci b/Examples/test-suite/scilab/funcptr_cpp_runme.sci
index cb4c3cd0d..2065fb1df 100644
--- a/Examples/test-suite/scilab/funcptr_cpp_runme.sci
+++ b/Examples/test-suite/scilab/funcptr_cpp_runme.sci
@@ -3,5 +3,6 @@ exec("swigtest.start", -1);
checkequal(call1(ADD_BY_VALUE_get(), 10, 11), 21, "ADD_BY_VALUE");
checkequal(call2(ADD_BY_POINTER_get(), 12, 13), 25, "ADD_BY_POINTER");
checkequal(call3(ADD_BY_REFERENCE_get(), 14, 15), 29, "ADD_BY_REFERENCE");
+checkequal(call1(ADD_BY_VALUE_C_get(), 2, 3), 5, "ADD_BY_VALUE_C");
exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/overload_polymorphic_runme.sci b/Examples/test-suite/scilab/overload_polymorphic_runme.sci
new file mode 100644
index 000000000..cae65405c
--- /dev/null
+++ b/Examples/test-suite/scilab/overload_polymorphic_runme.sci
@@ -0,0 +1,11 @@
+exec("swigtest.start", -1);
+
+derived = new_Derived();
+
+checkequal(test(derived), 0, "test(derived)");
+checkequal(test2(derived), 1, "test2(derived)");
+
+delete_Derived(derived);
+
+exec("swigtest.quit", -1);
+
diff --git a/Examples/test-suite/scilab/overload_simple_runme.sci b/Examples/test-suite/scilab/overload_simple_runme.sci
index 23be43db9..ad353e847 100644
--- a/Examples/test-suite/scilab/overload_simple_runme.sci
+++ b/Examples/test-suite/scilab/overload_simple_runme.sci
@@ -1,16 +1,17 @@
exec("swigtest.start", -1);
+f = new_Foo();
+b = new_Bar();
+v = malloc_void(32);
+
// Functions
checkequal(foo(int32(3)), "foo:int", "foo(int)");
checkequal(foo(3), "foo:double", "foo(double)");
checkequal(foo("hello"), "foo:char *", "foo(char* )");
-f = new_Foo();
checkequal(foo(f), "foo:Foo *", "foo(Foo *)");
-//b = new_Bar();
-//checkequal(foo(b), "foo:Bar *", "foo(Bar *)");
-//v = malloc_void(32);
-//checkequal(foo(v), "foo:void *", "foo(void *)");
+checkequal(foo(b), "foo:Bar *", "foo(Bar *)");
+checkequal(foo(v), "foo:void *", "foo(void *)");
// Class methods
@@ -19,8 +20,8 @@ checkequal(Spam_foo(s, int32(3)), "foo:int", "Spam::foo(int)");
checkequal(Spam_foo(s, 3), "foo:double", "Spam::foo(double)");
checkequal(Spam_foo(s, "hello"), "foo:char *", "Spam::foo(char *)");
checkequal(Spam_foo(s, f), "foo:Foo *", "Spam::foo(Foo *)");
-//checkequal(Spam_foo(s, b), "foo:Bar *", "Spam::foo(Bar *)");
-//checkequal(Spam_foo(s, v), "foo:void *", "Spam::foo(void *)");
+checkequal(Spam_foo(s, b), "foo:Bar *", "Spam::foo(Bar *)");
+checkequal(Spam_foo(s, v), "foo:void *", "Spam::foo(void *)");
delete_Spam(s);
// Static class methods
@@ -29,8 +30,8 @@ checkequal(Spam_bar(int32(3)), "bar:int", "Spam::bar(int)");
checkequal(Spam_bar(3.1), "bar:double", "Spam::bar(double)");
checkequal(Spam_bar("hello"), "bar:char *", "Spam::bar(char *)");
checkequal(Spam_bar(f), "bar:Foo *", "Spam::bar(Foo *)");
-//checkequal(Spam_bar(b), "bar:Bar *", "Spam::bar(Bar *)");
-//checkequal(Spam_bar(b), "bar:void *", "Spam::bar(void *)");
+checkequal(Spam_bar(b), "bar:Bar *", "Spam::bar(Bar *)");
+checkequal(Spam_bar(v), "bar:void *", "Spam::bar(void *)");
// Constructors
@@ -54,20 +55,21 @@ s = new_Spam(f);
checkequal(Spam_type_get(s), "Foo *", "Spam::Spam(Foo *)");
delete_Spam(s);
-//s = new_Spam(b);
-//checkequal(Spam_type_get(s), "Bar *", "Spam::Spam(Bar *)");
-//delete_Spam(s);
+s = new_Spam(b);
+checkequal(Spam_type_get(s), "Bar *", "Spam::Spam(Bar *)");
+delete_Spam(s);
-//s = new_Spam(v);
-//checkequal(Spam_type_get(s), "void *", "Spam::Spam(void *)");
-//delete_Spam(s);
+s = new_Spam(v);
+checkequal(Spam_type_get(s), "void *", "Spam::Spam(void *)");
+delete_Spam(s);
delete_Foo(f);
-//delete_Bar(b);
-//free_void(v);
+delete_Bar(b);
+free_void(v);
a = new_ClassA();
b = ClassA_method1(a, 1);
+delete_ClassA(a);
exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/overload_subtype_runme.sci b/Examples/test-suite/scilab/overload_subtype_runme.sci
new file mode 100644
index 000000000..e644f56b9
--- /dev/null
+++ b/Examples/test-suite/scilab/overload_subtype_runme.sci
@@ -0,0 +1,13 @@
+exec("swigtest.start", -1);
+
+f = new_Foo();
+b = new_Bar();
+
+checkequal(spam(f), 1, "spam(f)");
+checkequal(spam(b), 2, "spam(b)");
+
+delete_Foo(f);
+delete_Bar(b);
+
+exec("swigtest.quit", -1);
+
diff --git a/Examples/test-suite/scilab/template_rename_runme.sci b/Examples/test-suite/scilab/template_rename_runme.sci
index 9c9512930..7b6b0de84 100644
--- a/Examples/test-suite/scilab/template_rename_runme.sci
+++ b/Examples/test-suite/scilab/template_rename_runme.sci
@@ -6,7 +6,7 @@ checkequal(iFoo_spam_test(i, 5), 5, "iFoo_spam_test(i, 5) test fails");
checkequal(iFoo_groki_test(i, 6), 6, "iFoo_groki_test(i, 6) test fails");
delete_iFoo(i);
-d = new_iFoo();
+d = new_dFoo();
checkequal(dFoo_blah_test(d, 4), 4, "dFoo_blah_test(d, 4) test fails");
checkequal(dFoo_spam(d, 5), 5, "dFoo_spam_test(d, 5) test fails");
checkequal(dFoo_grok_test(d, 6), 6, "dFoo_groki_test(d, 6) test fails");
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/string_constants.i b/Examples/test-suite/string_constants.i
new file mode 100644
index 000000000..60f8c1859
--- /dev/null
+++ b/Examples/test-suite/string_constants.i
@@ -0,0 +1,44 @@
+%module string_constants
+// Test unusual string constants
+
+%warnfilter(SWIGWARN_TYPEMAP_CHARLEAK);
+
+#if defined(SWIGCSHARP)
+%csconst(1);
+%csconstvalue("\"AEIOU\\n\"") SS1;
+%csconstvalue("\"AEIOU\\n\"") SS2;
+#endif
+#if defined(SWIGJAVA)
+%javaconst(1);
+#endif
+%inline %{
+#define SS1 "ÆÎOU\n"
+#define AA1 "A\rB\nC"
+#define EE1 "\124\125\126"
+#define XX1 "\x57\x58\x59"
+#define ZS1 "\0"
+#define ES1 ""
+%}
+%constant SS2="ÆÎOU\n";
+%constant AA2="A\rB\nC";
+%constant EE2="\124\125\126";
+%constant XX2="\x57\x58\x59";
+%constant ZS2="\0";
+%constant ES2="";
+
+%inline %{
+static const char *SS3 = "ÆÎOU\n";
+static const char *AA3 = "A\rB\nC";
+static const char *EE3 = "\124\125\126";
+static const char *XX3 = "\x57\x58\x59";
+static const char *ZS3 = "\0";
+static const char *ES3 = "";
+struct things {
+ const char * defarguments1(const char *SS4 = "ÆÎOU\n") { return SS4; }
+ const char * defarguments2(const char *AA4 = "A\rB\nC") { return AA4; }
+ const char * defarguments3(const char *EE4 = "\124\125\126") { return EE4; }
+ const char * defarguments4(const char *XX4 = "\x57\x58\x59") { return XX4; }
+ const char * defarguments5(const char *ZS4 = "\0") { return ZS4; }
+ const char * defarguments6(const char *ES4 = "") { return ES4; }
+};
+%}
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
new file mode 100644
index 000000000..e5bfd23a4
--- /dev/null
+++ b/Lib/csharp/swiginterface.i
@@ -0,0 +1,63 @@
+/* -----------------------------------------------------------------------------
+ * swiginterface.i
+ *
+ * SWIG interface feature and typemaps implementation providing:
+ * %interface
+ * %interface_impl
+ * %interface_custom
+ * ----------------------------------------------------------------------------- */
+
+%define INTERFACE_TYPEMAPS(CTYPE...)
+%typemap(cstype) CTYPE "$&csinterfacename"
+%typemap(cstype) CTYPE *, CTYPE [], CTYPE & "$csinterfacename"
+%typemap(cstype) CTYPE *const& "$*csinterfacename"
+%typemap(csin) CTYPE, CTYPE & "$csinput.GetInterfaceCPtr()"
+%typemap(csin) CTYPE *, CTYPE *const&, CTYPE [] "$csinput == null ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : $csinput.GetInterfaceCPtr()"
+%typemap(csout, excode=SWIGEXCODE) CTYPE {
+ $&csclassname ret = new $&csclassname($imcall, true);$excode
+ return ($&csinterfacename)ret;
+ }
+%typemap(csout, excode=SWIGEXCODE) CTYPE & {
+ $csclassname ret = new $csclassname($imcall, $owner);$excode
+ return ($csinterfacename)ret;
+ }
+%typemap(csout, excode=SWIGEXCODE) CTYPE *, CTYPE [] {
+ global::System.IntPtr cPtr = $imcall;
+ $csclassname ret = (cPtr == global::System.IntPtr.Zero) ? null : new $csclassname(cPtr, $owner);$excode
+ return ($csinterfacename)ret;
+ }
+%typemap(csout, excode=SWIGEXCODE) CTYPE *const& {
+ global::System.IntPtr cPtr = $imcall;
+ $*csclassname ret = (cPtr == global::System.IntPtr.Zero) ? null : new $*csclassname(cPtr, $owner);$excode
+ return ($*csinterfacename)ret;
+ }
+%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)"
+%typemap(csdirectorout) CTYPE, CTYPE *, CTYPE *const&, CTYPE [], CTYPE & "$cscall.GetInterfaceCPtr()"
+%typemap(csinterfacecode, declaration=" [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]\n global::System.Runtime.InteropServices.HandleRef GetInterfaceCPtr();\n", cptrmethod="$interfacename_GetInterfaceCPtr") CTYPE %{
+ [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
+ global::System.Runtime.InteropServices.HandleRef $interfacename.GetInterfaceCPtr() {
+ return new global::System.Runtime.InteropServices.HandleRef(this, $imclassname.$csclazzname$interfacename_GetInterfaceCPtr(swigCPtr.Handle));
+ }
+%}
+%enddef
+
+%define %interface(CTYPE...)
+%feature("interface", name="%sSwigInterface") CTYPE;
+INTERFACE_TYPEMAPS(CTYPE)
+%enddef
+
+%define %interface_impl(CTYPE...)
+%rename("%sSwigImpl") CTYPE;
+%feature("interface", name="%(rstrip:[SwigImpl])s") CTYPE;
+INTERFACE_TYPEMAPS(CTYPE)
+%enddef
+
+%define %interface_custom(PROXY, INTERFACE, CTYPE...)
+%rename(PROXY) CTYPE;
+%feature("interface", name=INTERFACE) CTYPE;
+INTERFACE_TYPEMAPS(CTYPE)
+%enddef
+
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 24f1b73f7..53b653f7c 100644
--- a/Lib/go/go.swg
+++ b/Lib/go/go.swg
@@ -435,10 +435,23 @@
%typemap(in)
char *, char[ANY], char[]
-%{ $1 = ($1_ltype)$input.p; %}
+%{
+ $1 = ($1_ltype)malloc($input.n + 1);
+ memcpy($1, $input.p, $input.n);
+ $1[$input.n] = '\0';
+%}
-%typemap(in) char *&
-%{ $1 = ($1_ltype)$input.p; %}
+%typemap(in) char *& (char *temp)
+%{
+ temp = (char *)malloc($input.n + 1);
+ memcpy(temp, $input.p, $input.n);
+ temp[$input.n] = '\0';
+ $1 = ($1_ltype)&temp;
+%}
+
+%typemap(freearg)
+ char *, char *&, char[ANY], char[]
+%{ free($1); %}
%typemap(out,fragment="AllocateString")
char *, char *&, char[ANY], char[]
@@ -460,7 +473,19 @@
$result = swigCopyString($input)
%}
-%typemap(directorout)
+%typemap(godirectorout)
+ char *, char *&, char[ANY], char[]
+%{
+ {
+ p := Swig_malloc(len($input) + 1)
+ s := (*[1<<30]byte)(unsafe.Pointer(p))[:len($input) + 1]
+ copy(s, $input)
+ s[len($input)] = 0
+ $result = *(*string)(unsafe.Pointer(&s))
+ }
+%}
+
+%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG)
char *, char *&, char[ANY], char[]
%{ $result = ($1_ltype)$input.p; %}
@@ -559,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/go/goruntime.swg b/Lib/go/goruntime.swg
index e7a33adc4..dc6193d04 100644
--- a/Lib/go/goruntime.swg
+++ b/Lib/go/goruntime.swg
@@ -8,6 +8,10 @@
static void Swig_free(void* p) {
free(p);
}
+
+static void* Swig_malloc(int c) {
+ return malloc(c);
+}
%}
%insert(runtime) %{
diff --git a/Lib/go/std_string.i b/Lib/go/std_string.i
index 068c688cb..099ae84d4 100644
--- a/Lib/go/std_string.i
+++ b/Lib/go/std_string.i
@@ -24,8 +24,21 @@ class string;
%typemap(in) string
%{ $1.assign($input.p, $input.n); %}
+%typemap(godirectorout) string
+%{
+ {
+ p := Swig_malloc(len($input))
+ s := (*[1<<30]byte)(unsafe.Pointer(p))[:len($input)]
+ copy(s, $input)
+ $result = *(*string)(unsafe.Pointer(&s))
+ }
+%}
+
%typemap(directorout) string
-%{ $result.assign($input.p, $input.n); %}
+%{
+ $result.assign($input.p, $input.n);
+ free($input.p);
+%}
%typemap(out,fragment="AllocateString") string
%{ $result = Swig_AllocateString($1.data(), $1.length()); %}
@@ -45,10 +58,21 @@ class string;
$1 = &$1_str;
%}
+%typemap(godirectorout) const string &
+%{
+ {
+ p := Swig_malloc(len($input))
+ s := (*[1<<30]byte)(unsafe.Pointer(p))[:len($input)]
+ copy(s, $input)
+ $result = *(*string)(unsafe.Pointer(&s))
+ }
+%}
+
%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string &
%{
static $*1_ltype $1_str;
$1_str.assign($input.p, $input.n);
+ free($input.p);
$result = &$1_str;
%}
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 0ff487d80..d763c5e6f 100644
--- a/Lib/java/java.swg
+++ b/Lib/java/java.swg
@@ -310,8 +310,11 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
bae = JCALL2(GetByteArrayElements, jenv, ba, 0);
sz = JCALL1(GetArrayLength, jenv, ba);
$1 = 0;
- for(i=0; i<sz; i++) {
- $1 = ($1 << 8) | ($1_type)(unsigned char)bae[i];
+ if (sz > 0) {
+ $1 = ($1_type)(signed char)bae[0];
+ for(i=1; i<sz; i++) {
+ $1 = ($1 << 8) | ($1_type)(unsigned char)bae[i];
+ }
}
JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0);
}
@@ -334,8 +337,11 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
bae = JCALL2(GetByteArrayElements, jenv, ba, 0);
sz = JCALL1(GetArrayLength, jenv, ba);
$result = 0;
- for(i=0; i<sz; i++) {
- $result = ($result << 8) | ($1_type)(unsigned char)bae[i];
+ if (sz > 0) {
+ $result = ($1_type)(signed char)bae[0];
+ for(i=1; i<sz; i++) {
+ $result = ($result << 8) | ($1_type)(unsigned char)bae[i];
+ }
}
JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0);
}
@@ -406,7 +412,6 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
if (!$input) return $null;
}
Swig::LocalRefGuard $1_refguard(jenv, $input);
-// boohoo
}
%typemap(freearg, noblock=1) char * { if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, (const char *)$1); }
@@ -553,8 +558,11 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
sz = JCALL1(GetArrayLength, jenv, ba);
$1 = &temp;
temp = 0;
- for(i=0; i<sz; i++) {
- temp = (temp << 8) | ($*1_ltype)(unsigned char)bae[i];
+ if (sz > 0) {
+ temp = ($*1_ltype)(signed char)bae[0];
+ for(i=1; i<sz; i++) {
+ temp = (temp << 8) | ($*1_ltype)(unsigned char)bae[i];
+ }
}
JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0);
}
@@ -579,8 +587,11 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
sz = JCALL1(GetArrayLength, jenv, ba);
$result = &temp;
temp = 0;
- for(i=0; i<sz; i++) {
- temp = (temp << 8) | ($*1_ltype)(unsigned char)bae[i];
+ if (sz > 0) {
+ temp = ($*1_ltype)(signed char)bae[0];
+ for(i=1; i<sz; i++) {
+ temp = (temp << 8) | ($*1_ltype)(unsigned char)bae[i];
+ }
}
JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0);
}
@@ -636,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/std_array.i b/Lib/java/std_array.i
new file mode 100644
index 000000000..cbacfe673
--- /dev/null
+++ b/Lib/java/std_array.i
@@ -0,0 +1,42 @@
+/* -----------------------------------------------------------------------------
+ * std_array.i
+ * ----------------------------------------------------------------------------- */
+
+%include <std_common.i>
+
+namespace std {
+
+ template<class T, size_t N> class array {
+ public:
+ typedef T& reference;
+ typedef const T& const_reference;
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef T value_type;
+ typedef T* pointer;
+ typedef const T* const_pointer;
+ array();
+ array(const array& other);
+ size_type size() const;
+ %rename(isEmpty) empty;
+ bool empty() const;
+ void fill(const T& u);
+ %extend {
+ const_reference get(int i) throw (std::out_of_range) {
+ int size = int(self->size());
+ if (i>=0 && i<size)
+ return (*self)[i];
+ else
+ throw std::out_of_range("array index out of range");
+ }
+ void set(int i, const value_type& val) throw (std::out_of_range) {
+ int size = int(self->size());
+ if (i>=0 && i<size)
+ (*self)[i] = val;
+ else
+ throw std::out_of_range("array index out of range");
+ }
+ }
+ };
+}
+
diff --git a/Lib/java/swiginterface.i b/Lib/java/swiginterface.i
new file mode 100644
index 000000000..334464157
--- /dev/null
+++ b/Lib/java/swiginterface.i
@@ -0,0 +1,74 @@
+/* -----------------------------------------------------------------------------
+ * swiginterface.i
+ *
+ * SWIG interface feature and typemaps implementation providing:
+ * %interface
+ * %interface_impl
+ * %interface_custom
+ * ----------------------------------------------------------------------------- */
+
+%define INTERFACE_TYPEMAPS(CTYPE...)
+%typemap(jtype) CTYPE, CTYPE *, CTYPE *const&, CTYPE [], CTYPE & "long"
+%typemap(jstype) CTYPE "$&javainterfacename"
+%typemap(jstype) CTYPE *, CTYPE [], CTYPE & "$javainterfacename"
+%typemap(jstype) CTYPE *const& "$*javainterfacename"
+%typemap(javain) CTYPE "$javainput.$&interfacename_GetInterfaceCPtr()"
+%typemap(javain) CTYPE & "$javainput.$interfacename_GetInterfaceCPtr()"
+%typemap(javain) CTYPE *, CTYPE [] "($javainput == null) ? 0 : $javainput.$interfacename_GetInterfaceCPtr()"
+%typemap(javain) CTYPE *const& "($javainput == null) ? 0 : $javainput.$*interfacename_GetInterfaceCPtr()"
+%typemap(javaout) CTYPE {
+ return ($&javainterfacename)new $&javaclassname($jnicall, true);
+ }
+%typemap(javaout) CTYPE & {
+ return ($javainterfacename)new $javaclassname($jnicall, $owner);
+ }
+%typemap(javaout) CTYPE *, CTYPE [] {
+ long cPtr = $jnicall;
+ return (cPtr == 0) ? null : ($javainterfacename)new $javaclassname(cPtr, $owner);
+ }
+%typemap(javaout) CTYPE *const& {
+ long cPtr = $jnicall;
+ return (cPtr == 0) ? null : ($javainterfacename)new $javaclassname(cPtr, $owner);
+ }
+
+%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)"
+%typemap(javadirectorout) CTYPE "$javacall.$&interfacename_GetInterfaceCPtr()"
+%typemap(javadirectorout) CTYPE *, CTYPE [], CTYPE & "$javacall.$interfacename_GetInterfaceCPtr()"
+%typemap(javadirectorout) CTYPE *const& "$javacall.$*interfacename_GetInterfaceCPtr()"
+%typemap(directorin,descriptor="L$packagepath/$&javainterfacename;") CTYPE
+%{ $input = 0;
+ *(($&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 &
+%{ *($&1_ltype)&$input = ($1_ltype) &$1; %}
+%typemap(directorin,descriptor="L$packagepath/$*javainterfacename;") CTYPE *const&
+%{ *($&1_ltype)&$input = ($1_ltype) &$1; %}
+
+%typemap(javainterfacecode, declaration=" long $interfacename_GetInterfaceCPtr();\n", cptrmethod="$interfacename_GetInterfaceCPtr") CTYPE %{
+ public long $interfacename_GetInterfaceCPtr() {
+ return $imclassname.$javaclazzname$interfacename_GetInterfaceCPtr(swigCPtr);
+ }
+%}
+%enddef
+
+%define %interface(CTYPE...)
+%feature("interface", name="%sSwigInterface") CTYPE;
+INTERFACE_TYPEMAPS(CTYPE)
+%enddef
+
+%define %interface_impl(CTYPE...)
+%rename("%sSwigImpl") CTYPE;
+%feature("interface", name="%(rstrip:[SwigImpl])s") CTYPE;
+INTERFACE_TYPEMAPS(CTYPE)
+%enddef
+
+%define %interface_custom(PROXY, INTERFACE, CTYPE...)
+%rename(PROXY) CTYPE;
+%feature("interface", name=INTERFACE) CTYPE;
+INTERFACE_TYPEMAPS(CTYPE)
+%enddef
+
diff --git a/Lib/java/typemaps.i b/Lib/java/typemaps.i
index e71790bcc..041cb24e0 100644
--- a/Lib/java/typemaps.i
+++ b/Lib/java/typemaps.i
@@ -109,8 +109,11 @@ INPUT_TYPEMAP(double, jdouble, double, "D");
bae = JCALL2(GetByteArrayElements, jenv, ba, 0);
sz = JCALL1(GetArrayLength, jenv, ba);
temp = 0;
- for(i=0; i<sz; i++) {
- temp = (temp << 8) | ($*1_ltype)(unsigned char)bae[i];
+ if (sz > 0) {
+ temp = ($*1_ltype)(signed char)bae[0];
+ for(i=1; i<sz; i++) {
+ temp = (temp << 8) | ($*1_ltype)(unsigned char)bae[i];
+ }
}
JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0);
$1 = &temp;
@@ -416,8 +419,11 @@ INOUT_TYPEMAP(double, jdouble, double, Double, "[Ljava/lang/Double;", jdoubleArr
bae = JCALL2(GetByteArrayElements, jenv, ba, 0);
sz = JCALL1(GetArrayLength, jenv, ba);
temp = 0;
- for(i=0; i<sz; i++) {
- temp = (temp << 8) | ($*1_ltype)(unsigned char)bae[i];
+ if (sz > 0) {
+ temp = ($*1_ltype)(signed char)bae[0];
+ for(i=1; i<sz; i++) {
+ temp = (temp << 8) | ($*1_ltype)(unsigned char)bae[i];
+ }
}
JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0);
$1 = &temp;
diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg
index 721fac22b..660dbbf86 100644
--- a/Lib/lua/luarun.swg
+++ b/Lib/lua/luarun.swg
@@ -810,6 +810,44 @@ SWIGINTERN int SWIG_Lua_iterate_bases(lua_State *L, swig_type_info * SWIGUNUSED
* It returns an error code. Number of function return values is passed inside 'ret'.
* first_arg is not used in this function because function always has 2 arguments.
*/
+SWIGINTERN int SWIG_Lua_class_do_get_item(lua_State *L, swig_type_info *type, int SWIGUNUSED first_arg, int *ret)
+{
+/* there should be 2 params passed in
+ (1) userdata (not the meta table)
+ (2) string name of the attribute
+*/
+ int bases_search_result;
+ int substack_start = lua_gettop(L)-2;
+ assert(first_arg == substack_start+1);
+ lua_checkstack(L,5);
+ assert(lua_isuserdata(L,-2)); /* just in case */
+ lua_getmetatable(L,-2); /* get the meta table */
+ assert(lua_istable(L,-1)); /* just in case */
+ /* NEW: looks for the __getitem() fn
+ this is a user provided get fn */
+ SWIG_Lua_get_table(L,"__getitem"); /* find the __getitem fn */
+ if (lua_iscfunction(L,-1)) /* if its there */
+ { /* found it so call the fn & return its value */
+ lua_pushvalue(L,substack_start+1); /* the userdata */
+ lua_pushvalue(L,substack_start+2); /* the parameter */
+ lua_call(L,2,1); /* 2 value in (userdata),1 out (result) */
+ lua_remove(L,-2); /* stack tidy, remove metatable */
+ if(ret) *ret = 1;
+ return SWIG_OK;
+ }
+ lua_pop(L,1);
+ /* Remove the metatable */
+ lua_pop(L,1);
+ /* Search in base classes */
+ bases_search_result = SWIG_Lua_iterate_bases(L,type,substack_start+1,SWIG_Lua_class_do_get_item,ret);
+ return bases_search_result; /* sorry not known */
+}
+
+
+/* The class.get method helper, performs the lookup of class attributes.
+ * It returns an error code. Number of function return values is passed inside 'ret'.
+ * first_arg is not used in this function because function always has 2 arguments.
+ */
SWIGINTERN int SWIG_Lua_class_do_get(lua_State *L, swig_type_info *type, int SWIGUNUSED first_arg, int *ret)
{
/* there should be 2 params passed in
@@ -853,19 +891,6 @@ SWIGINTERN int SWIG_Lua_class_do_get(lua_State *L, swig_type_info *type, int SW
return SWIG_OK;
}
lua_pop(L,1); /* remove whatever was there */
- /* NEW: looks for the __getitem() fn
- this is a user provided get fn */
- SWIG_Lua_get_table(L,"__getitem"); /* find the __getitem fn */
- if (lua_iscfunction(L,-1)) /* if its there */
- { /* found it so call the fn & return its value */
- lua_pushvalue(L,substack_start+1); /* the userdata */
- lua_pushvalue(L,substack_start+2); /* the parameter */
- lua_call(L,2,1); /* 2 value in (userdata),1 out (result) */
- lua_remove(L,-2); /* stack tidy, remove metatable */
- if(ret) *ret = 1;
- return SWIG_OK;
- }
- lua_pop(L,1);
/* Remove the metatable */
lua_pop(L,1);
/* Search in base classes */
@@ -892,6 +917,10 @@ SWIGINTERN int SWIG_Lua_class_get(lua_State *L)
if(result == SWIG_OK)
return ret;
+ result = SWIG_Lua_class_do_get_item(L,type,1,&ret);
+ if(result == SWIG_OK)
+ return ret;
+
return 0;
}
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/python/pytypemaps.swg b/Lib/python/pytypemaps.swg
index 2341980f2..48b0bcdc8 100644
--- a/Lib/python/pytypemaps.swg
+++ b/Lib/python/pytypemaps.swg
@@ -79,10 +79,12 @@
/* Consttab, needed for callbacks, it should be removed later */
-%typemap(consttab) SWIGTYPE ((*)(ANY))
+%typemap(consttab) SWIGTYPE ((*)(ANY))
{ SWIG_PY_POINTER, (char*)"$symname", 0, 0, (void *)($value), &$descriptor }
+%typemap(consttab) SWIGTYPE ((* const)(ANY)) = SWIGTYPE ((*)(ANY));
%typemap(constcode) SWIGTYPE ((*)(ANY)) "";
+%typemap(constcode) SWIGTYPE ((* const)(ANY)) = SWIGTYPE ((*)(ANY));
/* Smart Pointers */
diff --git a/Lib/r/r.swg b/Lib/r/r.swg
index a6014965e..cf1cfc8f9 100644
--- a/Lib/r/r.swg
+++ b/Lib/r/r.swg
@@ -264,8 +264,8 @@ x
setAs('ExternalReference', 'character',
function(from) {if (!is.null(from$"__str__")) from$"__str__"()})
-suppressWarnings(setMethod('print', 'ExternalReference',
-function(x) {print(as(x, "character"))}))
+suppressMessages(suppressWarnings(setMethod('print', 'ExternalReference',
+function(x) {print(as(x, "character"))})))
%}
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 836c95b53..4ec51dc91 100644
--- a/Lib/r/std_vector.i
+++ b/Lib/r/std_vector.i
@@ -34,10 +34,68 @@
return(result);
}
};
- // vectors of unsigned int
+ // vectors of unsigned 8bit int
+ template <>
+ struct traits_from_ptr<std::vector<unsigned char> > {
+ static SEXP from (std::vector<unsigned char > *val, int owner = 0) {
+ SEXP result;
+ PROTECT(result = Rf_allocVector(INTSXP, val->size()));
+ for (unsigned pos = 0; pos < val->size(); pos++)
+ {
+ INTEGER_POINTER(result)[pos] = ((*val)[pos]);
+ }
+ UNPROTECT(1);
+ return(result);
+ }
+ };
+ // vectors of 8bit int
+ template <>
+ struct traits_from_ptr<std::vector<signed char> > {
+ static SEXP from (std::vector<signed char > *val, int owner = 0) {
+ SEXP result;
+ PROTECT(result = Rf_allocVector(INTSXP, val->size()));
+ for (unsigned pos = 0; pos < val->size(); pos++)
+ {
+ INTEGER_POINTER(result)[pos] = ((*val)[pos]);
+ }
+ UNPROTECT(1);
+ return(result);
+ }
+ };
+
+ // vectors of unsigned 16bit int
+ template <>
+ struct traits_from_ptr<std::vector<unsigned short int> > {
+ static SEXP from (std::vector<unsigned short int > *val, int owner = 0) {
+ SEXP result;
+ PROTECT(result = Rf_allocVector(INTSXP, val->size()));
+ for (unsigned pos = 0; pos < val->size(); pos++)
+ {
+ INTEGER_POINTER(result)[pos] = ((*val)[pos]);
+ }
+ UNPROTECT(1);
+ return(result);
+ }
+ };
+ // vectors of 16bit int
+ template <>
+ struct traits_from_ptr<std::vector<short int> > {
+ static SEXP from (std::vector<short int > *val, int owner = 0) {
+ SEXP result;
+ PROTECT(result = Rf_allocVector(INTSXP, val->size()));
+ for (unsigned pos = 0; pos < val->size(); pos++)
+ {
+ INTEGER_POINTER(result)[pos] = ((*val)[pos]);
+ }
+ UNPROTECT(1);
+ return(result);
+ }
+ };
+
+ // vectors of 32 bit unsigned int
template <>
struct traits_from_ptr<std::vector<unsigned int> > {
- static SEXP from (std::vector<unsigned int > *val, int owner = 0) {
+ static SEXP from (std::vector<unsigned int> *val, int owner = 0) {
SEXP result;
PROTECT(result = Rf_allocVector(INTSXP, val->size()));
for (unsigned pos = 0; pos < val->size(); pos++)
@@ -48,7 +106,8 @@
return(result);
}
};
- // vectors of int
+
+ // vectors of 32bit int
template <>
struct traits_from_ptr<std::vector<int> > {
static SEXP from (std::vector<int > *val, int owner = 0) {
@@ -63,6 +122,64 @@
}
};
+ // vectors of 64 bit unsigned int
+#if defined(SWIGWORDSIZE64)
+ template <>
+ struct traits_from_ptr<std::vector<unsigned long int> > {
+ static SEXP from (std::vector<unsigned long int> *val, int owner = 0) {
+ SEXP result;
+ PROTECT(result = Rf_allocVector(INTSXP, val->size()));
+ for (unsigned pos = 0; pos < val->size(); pos++)
+ {
+ INTEGER_POINTER(result)[pos] = ((*val)[pos]);
+ }
+ UNPROTECT(1);
+ return(result);
+ }
+ };
+ // vectors of 64 bit int
+ template <>
+ struct traits_from_ptr<std::vector<long int> > {
+ static SEXP from (std::vector<long int> *val, int owner = 0) {
+ SEXP result;
+ PROTECT(result = Rf_allocVector(INTSXP, val->size()));
+ for (unsigned pos = 0; pos < val->size(); pos++)
+ {
+ INTEGER_POINTER(result)[pos] = ((*val)[pos]);
+ }
+ UNPROTECT(1);
+ return(result);
+ }
+ };
+#else
+ template <>
+ struct traits_from_ptr<std::vector<unsigned long long int> > {
+ static SEXP from (std::vector<unsigned long long int> *val, int owner = 0) {
+ SEXP result;
+ PROTECT(result = Rf_allocVector(INTSXP, val->size()));
+ for (unsigned pos = 0; pos < val->size(); pos++)
+ {
+ INTEGER_POINTER(result)[pos] = ((*val)[pos]);
+ }
+ UNPROTECT(1);
+ return(result);
+ }
+ };
+ // vectors of 64 bit int
+ template <>
+ struct traits_from_ptr<std::vector<long long int> > {
+ static SEXP from (std::vector<long long int> *val, int owner = 0) {
+ SEXP result;
+ PROTECT(result = Rf_allocVector(INTSXP, val->size()));
+ for (unsigned pos = 0; pos < val->size(); pos++)
+ {
+ INTEGER_POINTER(result)[pos] = ((*val)[pos]);
+ }
+ UNPROTECT(1);
+ return(result);
+ }
+ };
+#endif
// vectors of bool
template <>
struct traits_from_ptr<std::vector<bool> > {
@@ -75,9 +192,9 @@
}
UNPROTECT(1);
return(result);
- //return SWIG_R_NewPointerObj(val, type_info< std::vector<T > >(), owner);
}
};
+
// vectors of strings
template <>
struct traits_from_ptr<std::vector<std::basic_string<char> > > {
@@ -90,7 +207,6 @@
}
UNPROTECT(1);
return(result);
- //return SWIG_R_NewPointerObj(val, type_info< std::vector<T > >(), owner);
}
};
@@ -101,7 +217,7 @@
return SWIG_R_NewPointerObj(val, type_info< std::vector< T > >(), owner);
}
};
-
+ /////////////////////////////////////////////////
template <>
struct traits_asptr < std::vector<double> > {
static int asptr(SEXP obj, std::vector<double> **val) {
@@ -142,6 +258,98 @@
}
};
+ // 8 bit integer types
+ template <>
+ struct traits_asptr < std::vector<unsigned char> > {
+ static int asptr(SEXP obj, std::vector<unsigned char> **val) {
+ std::vector<unsigned char> *p;
+ unsigned int sexpsz = Rf_length(obj);
+ p = new std::vector<unsigned char>(sexpsz);
+ SEXP coerced;
+ PROTECT(coerced = Rf_coerceVector(obj, INTSXP));
+ int *S = INTEGER_POINTER(coerced);
+ for (unsigned pos = 0; pos < p->size(); pos++)
+ {
+ (*p)[pos] = static_cast<unsigned char>(S[pos]);
+ }
+ int res = SWIG_OK;
+ if (SWIG_IsOK(res)) {
+ if (val) *val = p;
+ }
+ UNPROTECT(1);
+ return res;
+ }
+ };
+
+ template <>
+ struct traits_asptr < std::vector<signed char> > {
+ static int asptr(SEXP obj, std::vector<signed char> **val) {
+ std::vector<signed char> *p;
+ // not sure how to check the size of the SEXP obj is correct
+ int sexpsz = Rf_length(obj);
+ p = new std::vector<signed char>(sexpsz);
+ SEXP coerced;
+ PROTECT(coerced = Rf_coerceVector(obj, INTSXP));
+ int *S = INTEGER_POINTER(coerced);
+ for (unsigned pos = 0; pos < p->size(); pos++)
+ {
+ (*p)[pos] = static_cast<signed char>(S[pos]);
+ }
+ int res = SWIG_OK;
+ if (SWIG_IsOK(res)) {
+ if (val) *val = p;
+ }
+ UNPROTECT(1);
+ return res;
+ }
+ };
+
+ // 16 bit integer types
+ template <>
+ struct traits_asptr < std::vector<unsigned short int> > {
+ static int asptr(SEXP obj, std::vector<unsigned short int> **val) {
+ std::vector<unsigned short int> *p;
+ unsigned int sexpsz = Rf_length(obj);
+ p = new std::vector<unsigned short int>(sexpsz);
+ SEXP coerced;
+ PROTECT(coerced = Rf_coerceVector(obj, INTSXP));
+ int *S = INTEGER_POINTER(coerced);
+ for (unsigned pos = 0; pos < p->size(); pos++)
+ {
+ (*p)[pos] = static_cast<unsigned short int>(S[pos]);
+ }
+ int res = SWIG_OK;
+ if (SWIG_IsOK(res)) {
+ if (val) *val = p;
+ }
+ UNPROTECT(1);
+ return res;
+ }
+ };
+
+ template <>
+ struct traits_asptr < std::vector<short int> > {
+ static int asptr(SEXP obj, std::vector<short int> **val) {
+ std::vector<short int> *p;
+ // not sure how to check the size of the SEXP obj is correct
+ int sexpsz = Rf_length(obj);
+ p = new std::vector<short int>(sexpsz);
+ SEXP coerced;
+ PROTECT(coerced = Rf_coerceVector(obj, INTSXP));
+ int *S = INTEGER_POINTER(coerced);
+ for (unsigned pos = 0; pos < p->size(); pos++)
+ {
+ (*p)[pos] = static_cast<short int>(S[pos]);
+ }
+ int res = SWIG_OK;
+ if (SWIG_IsOK(res)) {
+ if (val) *val = p;
+ }
+ UNPROTECT(1);
+ return res;
+ }
+ };
+ // 32 bit integer types
template <>
struct traits_asptr < std::vector<unsigned int> > {
static int asptr(SEXP obj, std::vector<unsigned int> **val) {
@@ -187,6 +395,102 @@
}
};
+#if defined(SWIGWORDSIZE64)
+ // 64 bit integer types
+ template <>
+ struct traits_asptr < std::vector<unsigned long int> > {
+ static int asptr(SEXP obj, std::vector<unsigned long int> **val) {
+ std::vector<unsigned long int> *p;
+ unsigned int sexpsz = Rf_length(obj);
+ p = new std::vector<unsigned long int>(sexpsz);
+ SEXP coerced;
+ PROTECT(coerced = Rf_coerceVector(obj, INTSXP));
+ int *S = INTEGER_POINTER(coerced);
+ for (unsigned pos = 0; pos < p->size(); pos++)
+ {
+ (*p)[pos] = static_cast<unsigned long int>(S[pos]);
+ }
+ int res = SWIG_OK;
+ if (SWIG_IsOK(res)) {
+ if (val) *val = p;
+ }
+ UNPROTECT(1);
+ return res;
+ }
+ };
+
+ template <>
+ struct traits_asptr < std::vector<long int> > {
+ static int asptr(SEXP obj, std::vector<long int> **val) {
+ std::vector<long int> *p;
+ // not sure how to check the size of the SEXP obj is correct
+ int sexpsz = Rf_length(obj);
+ p = new std::vector<long int>(sexpsz);
+ SEXP coerced;
+ PROTECT(coerced = Rf_coerceVector(obj, INTSXP));
+ int *S = INTEGER_POINTER(coerced);
+ for (unsigned pos = 0; pos < p->size(); pos++)
+ {
+ (*p)[pos] = static_cast<long int>(S[pos]);
+ }
+ int res = SWIG_OK;
+ if (SWIG_IsOK(res)) {
+ if (val) *val = p;
+ }
+ UNPROTECT(1);
+ return res;
+ }
+ };
+
+#else
+ // 64 bit integer types
+ template <>
+ struct traits_asptr < std::vector<unsigned long long int> > {
+ static int asptr(SEXP obj, std::vector<unsigned long long int> **val) {
+ std::vector<unsigned long long int> *p;
+ unsigned int sexpsz = Rf_length(obj);
+ p = new std::vector<unsigned long long int>(sexpsz);
+ SEXP coerced;
+ PROTECT(coerced = Rf_coerceVector(obj, INTSXP));
+ int *S = INTEGER_POINTER(coerced);
+ for (unsigned pos = 0; pos < p->size(); pos++)
+ {
+ (*p)[pos] = static_cast<unsigned long long int>(S[pos]);
+ }
+ int res = SWIG_OK;
+ if (SWIG_IsOK(res)) {
+ if (val) *val = p;
+ }
+ UNPROTECT(1);
+ return res;
+ }
+ };
+
+ template <>
+ struct traits_asptr < std::vector<long long int> > {
+ static int asptr(SEXP obj, std::vector<long long int> **val) {
+ std::vector<long long int> *p;
+ // not sure how to check the size of the SEXP obj is correct
+ int sexpsz = Rf_length(obj);
+ p = new std::vector<long long int>(sexpsz);
+ SEXP coerced;
+ PROTECT(coerced = Rf_coerceVector(obj, INTSXP));
+ int *S = INTEGER_POINTER(coerced);
+ for (unsigned pos = 0; pos < p->size(); pos++)
+ {
+ (*p)[pos] = static_cast<long long int>(S[pos]);
+ }
+ int res = SWIG_OK;
+ if (SWIG_IsOK(res)) {
+ if (val) *val = p;
+ }
+ UNPROTECT(1);
+ return res;
+ }
+ };
+
+#endif
+
template <>
struct traits_asptr < std::vector<bool> > {
static int asptr(SEXP obj, std::vector<bool> **val) {
@@ -210,13 +514,37 @@
}
};
+ template <>
+ struct traits_asptr < std::vector<std::basic_string<char> > > {
+ static int asptr(SEXP obj, std::vector<std::basic_string<char> > **val) {
+ std::vector<std::basic_string<char> > *p;
+ // R character vectors are STRSXP containing CHARSXP
+ // access a CHARSXP using STRING_ELT
+ int sexpsz = Rf_length(obj);
+ p = new std::vector<std::basic_string<char> >(sexpsz);
+ SEXP coerced;
+ PROTECT(coerced = Rf_coerceVector(obj, STRSXP));
+ //SEXP *S = CHARACTER_POINTER(coerced);
+ for (unsigned pos = 0; pos < p->size(); pos++)
+ {
+ const char * thecstring = CHAR(STRING_ELT(coerced, pos));
+ (*p)[pos] = std::basic_string<char>(thecstring);
+ }
+ int res = SWIG_OK;
+ if (SWIG_IsOK(res)) {
+ if (val) *val = p;
+ }
+ UNPROTECT(1);
+ return res;
+ }
+ };
+
// catchall for R to vector conversion
template <typename T>
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;
}
@@ -228,7 +556,7 @@
// catch all that does everything with vectors
template <>
struct traits_from_ptr<std::vector<std::vector<unsigned int> > > {
- static SEXP from (std::vector< std::vector<unsigned int > > *val, int owner = 0) {
+ static SEXP from (std::vector< std::vector<unsigned int> > *val, int owner = 0) {
SEXP result;
// allocate the R list
PROTECT(result = Rf_allocVector(VECSXP, val->size()));
@@ -247,6 +575,7 @@
}
};
+
template <>
struct traits_from_ptr<std::vector<std::vector<int> > > {
static SEXP from (std::vector< std::vector<int > > *val, int owner = 0) {
@@ -338,6 +667,8 @@
}
};
+ /////////////////////////////////////////////////////////////////
+
// R side
template <>
struct traits_asptr < std::vector< std::vector<unsigned int> > > {
@@ -507,86 +838,202 @@
%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>)
-%typemap("rtypecheck") std::vector<float>, std::vector<float> const, std::vector<float> const&
- %{ is.numeric($arg) %}
-%typemap("rtype") std::vector<float> "numeric"
-%typemap("scoercein") std::vector<double>, std::vector<float> const, std::vector<float> const& "";
+
+// reuse these for float
+%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> >,
+std::vector< std::basic_string<char> > *,
+ std::vector< std::basic_string<char> > & "character"
+
+%typemap("rtypecheck") std::vector< std::basic_string<char> >,
+std::vector< std::basic_string<char> > *,
+ std::vector< std::basic_string<char> > &
+ %{ is.character($arg) %}
+
+%typemap("scoercein") std::vector< std::basic_string<char> >,
+std::vector< std::basic_string<char> > *,
+ std::vector< std::basic_string<char> > & "$input = as.character($input);";
+
+%typemap("scoerceout") std::vector< std::basic_string<char> >,
+std::vector< std::basic_string<char> > *,
+ std::vector< std::basic_string<char> > &
+%{ %}
+
+%apply std::vector< std::basic_string<char> > { std::vector< std::string> };
+
+// all the related integer vectors
+// signed
+%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<signed char>);
+%traits_type_name(std::vector<signed char>);
+
+%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<signed short>);
+%traits_type_name(std::vector<signed short>);
+
+#if defined(SWIGWORDSIZE64)
+%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<long int>);
+%traits_type_name(std::vector<long int>);
+#else
+%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<long long int>);
+%traits_type_name(std::vector<long long int>);
+#endif
+
+// unsigned
+%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<unsigned char>);
+%traits_type_name(std::vector<unsigned char>);
+
+%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<unsigned short>);
+%traits_type_name(std::vector<unsigned short>);
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<unsigned int>);
%traits_type_name(std::vector<unsigned int>);
-%typemap("rtypecheck") std::vector<unsigned int>, std::vector<unsigned int> const, std::vector<unsigned int> const&
-%{ is.integer($arg) || is.numeric($arg) %}
-%typemap("rtype") std::vector<unsigned int> "integer"
-%typemap("scoercein") std::vector<unsigned int>, std::vector<unsigned int> const, std::vector<unsigned int> const& "$input = as.integer($input);";
-%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> > const, std::vector<std::vector<unsigned int> >const&
- %{ is.list($arg) && all(sapply($arg , is.integer) || sapply($arg, is.numeric)) %}
-%typemap("rtype") std::vector<std::vector<unsigned int> > "list"
-%typemap("scoercein") std::vector< std::vector<unsigned int> >, std::vector<std::vector<unsigned int> > const, std::vector<std::vector<unsigned int> >const& "$input = lapply($input, as.integer);";
+#if defined(SWIGWORDSIZE64)
+%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<unsigned long int>);
+%traits_type_name(std::vector<unsigned long int>);
+#else
+%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<unsigned long long int>);
+%traits_type_name(std::vector<unsigned long long int>);
+#endif
+
+// These R side typemaps are common for integer types
+// 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<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<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<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<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<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<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<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<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<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.
%typemap(scoerceout) std::vector<double>,
- std::vector<double> *,
- std::vector<double> &,
- std::vector<bool>,
- std::vector<bool> *,
- std::vector<bool> &,
+ std::vector<double>*,
+ std::vector<double>&,
+ std::vector<float> ,
+ std::vector<float>*,
+ std::vector<float> ,
+ std::vector<signed char>,
+ std::vector<signed char>*,
+ std::vector<signed char>&,
+ std::vector<signed short>,
+ std::vector<signed short>*,
+ std::vector<signed short>&,
+ std::vector<int>,
+ std::vector<int>*,
+ std::vector<int>&,
+ std::vector<unsigned char>,
+ std::vector<unsigned char>*,
+ std::vector<unsigned char>&,
+ std::vector<unsigned short>,
+ std::vector<unsigned short>*,
+ std::vector<unsigned short>&,
std::vector<unsigned int>,
- std::vector<unsigned int> *,
- std::vector<unsigned int> &,
+ std::vector<unsigned int>*,
+ std::vector<unsigned int>&,
+ std::vector<bool>,
+ std::vector<bool>*,
+ std::vector<bool>&,
// vectors of vectors
std::vector< std::vector<unsigned int> >,
std::vector< std::vector<unsigned int> >*,
@@ -603,6 +1050,24 @@
std::vector< std::vector<bool> >,
std::vector< std::vector<bool> >*,
std::vector< std::vector<bool> >&
+ %{ %}
+#if defined(SWIGWORDSIZE64)
+%typemap(scoerceout) std::vector<long int>,
+ std::vector<long int>*,
+ std::vector<long int>&,
+ std::vector<unsigned long int>,
+ std::vector<unsigned long int>*,
+ std::vector<unsigned long int>&
+ %{ %}
+#else
+%typemap(scoerceout) std::vector<long long int>,
+ std::vector<long long int>*,
+ std::vector<long long int>&,
+ std::vector<unsigned long long int>,
+ std::vector<unsigned long long int>*,
+ std::vector<unsigned long long int>&
%{ %}
+
+#endif
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/scilab/scicontainer.swg b/Lib/scilab/scicontainer.swg
index 529d27888..2cc44b8e5 100644
--- a/Lib/scilab/scicontainer.swg
+++ b/Lib/scilab/scicontainer.swg
@@ -60,14 +60,7 @@ namespace swig
operator T () const
{
- try
- {
- return traits_asval_sequenceitem<T>::asval(_seq, piSeqAddr, _index);
- }
- catch (std::exception& e)
- {
- SWIG_exception(SWIG_RuntimeError, e.what());
- }
+ return traits_asval_sequenceitem<T>::asval(_seq, piSeqAddr, _index);
}
SciSequence_Ref& operator=(const T& v)
@@ -391,14 +384,19 @@ namespace swig {
}
else
{
- return true;
+ return SWIG_ERROR;
}
}
catch (std::exception& e)
{
SWIG_exception(SWIG_RuntimeError, e.what());
+ return SWIG_ERROR;
}
}
+ else
+ {
+ return SWIG_ERROR;
+ }
}
};
@@ -438,6 +436,7 @@ namespace swig {
catch (std::exception& e)
{
SWIG_exception(SWIG_RuntimeError, e.what());
+ return SWIG_ERROR;
}
}
};
diff --git a/Lib/scilab/scimatrixbool.swg b/Lib/scilab/scimatrixbool.swg
index 3b1f8cb77..a43886b4f 100644
--- a/Lib/scilab/scimatrixbool.swg
+++ b/Lib/scilab/scimatrixbool.swg
@@ -27,24 +27,24 @@
%typemap(in, noblock=1, fragment="SWIG_SciBoolean_AsBoolArrayAndSize") (bool *IN, int IN_SIZE) (int rowCount, int colCount)
{
- if (SWIG_SciBoolean_AsBoolArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$1, fname) == SWIG_OK) {
- $2 = rowCount * colCount;
- }
- else {
- return SWIG_ERROR;
- }
+ if (SWIG_SciBoolean_AsBoolArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$1, fname) == SWIG_OK) {
+ $2 = rowCount * colCount;
+ }
+ else {
+ return SWIG_ERROR;
+ }
}
// in (int IN_SIZE, bool *IN)
%typemap(in, noblock=1) (int IN_SIZE, bool *IN) (int rowCount, int colCount)
{
- if (SWIG_SciBoolean_AsBoolArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$2, fname) == SWIG_OK) {
- $1 = rowCount * colCount;
- }
- else {
- return SWIG_ERROR;
- }
+ if (SWIG_SciBoolean_AsBoolArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$2, fname) == SWIG_OK) {
+ $1 = rowCount * colCount;
+ }
+ else {
+ return SWIG_ERROR;
+ }
}
// out (bool **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
diff --git a/Lib/scilab/scimatrixdouble.swg b/Lib/scilab/scimatrixdouble.swg
index b8272e9a6..9444a8078 100644
--- a/Lib/scilab/scimatrixdouble.swg
+++ b/Lib/scilab/scimatrixdouble.swg
@@ -27,24 +27,24 @@
%typemap(in, noblock=1, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") (double *IN, int IN_SIZE) (int rowCount, int colCount)
{
- if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$1, fname) == SWIG_OK) {
- $2 = rowCount * colCount;
- }
- else {
- return SWIG_ERROR;
- }
+ if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$1, fname) == SWIG_OK) {
+ $2 = rowCount * colCount;
+ }
+ else {
+ return SWIG_ERROR;
+ }
}
// in (int IN_SIZE, double *IN)
%typemap(in, noblock=1, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") (int IN_SIZE, double *IN) (int rowCount, int colCount)
{
- if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$2, fname) == SWIG_OK) {
- $1 = rowCount * colCount;
- }
- else {
- return SWIG_ERROR;
- }
+ if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$2, fname) == SWIG_OK) {
+ $1 = rowCount * colCount;
+ }
+ else {
+ return SWIG_ERROR;
+ }
}
// out (double **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
diff --git a/Lib/scilab/scimatrixint.swg b/Lib/scilab/scimatrixint.swg
index b7270d5d5..e304d4f64 100644
--- a/Lib/scilab/scimatrixint.swg
+++ b/Lib/scilab/scimatrixint.swg
@@ -29,12 +29,12 @@
%typemap(in, noblock=1, fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") (int *IN, int IN_SIZE) (int rowCount, int colCount)
{
- if (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$1, fname) == SWIG_OK) {
- $2 = rowCount * colCount;
- }
- else {
- return SWIG_ERROR;
- }
+ if (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$1, fname) == SWIG_OK) {
+ $2 = rowCount * colCount;
+ }
+ else {
+ return SWIG_ERROR;
+ }
}
@@ -42,12 +42,12 @@
%typemap(in, noblock=1, fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") (int IN_SIZE, int *IN) (int rowCount, int colCount)
{
- if (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$2, fname) == SWIG_OK) {
- $1 = rowCount * colCount;
- }
- else {
- return SWIG_ERROR;
- }
+ if (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$2, fname) == SWIG_OK) {
+ $1 = rowCount * colCount;
+ }
+ else {
+ return SWIG_ERROR;
+ }
}
// out (int **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
diff --git a/Lib/scilab/scirun.swg b/Lib/scilab/scirun.swg
index 71641e074..5625b5298 100644
--- a/Lib/scilab/scirun.swg
+++ b/Lib/scilab/scirun.swg
@@ -17,7 +17,9 @@ extern "C" {
#define __USE_DEPRECATED_STACK_FUNCTIONS__
#include "stack-c.h"
#endif
+#if SWIG_SCILAB_VERSION < 600
#include "MALLOC.h"
+#endif
#include "Scierror.h"
#include "localization.h"
#include "freeArrayOfString.h"
@@ -98,14 +100,64 @@ SWIG_Scilab_SetOutput(void *pvApiCtx, SwigSciObject output) {
return SWIG_OK;
}
-
/* Pointer conversion functions */
SWIGINTERN int
-SwigScilabPtrToObject(void *pvApiCtx, int iVar, void **pObjValue, swig_type_info *descriptor, int flags, char *fname) {
+SwigScilabCheckPtr(void *pvApiCtx, int iVar, swig_type_info *descriptor, char *fname) {
SciErr sciErr;
+ int *piAddrVar = NULL;
int iType = 0;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (iType == sci_tlist) {
+ int iItemCount = 0;
+ void *pvTypeinfo = NULL;
+
+ sciErr = getListItemNumber(pvApiCtx, piAddrVar, &iItemCount);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iItemCount < 3) {
+ return SWIG_ERROR;
+ }
+
+ sciErr = getPointerInList(pvApiCtx, piAddrVar, 2, &pvTypeinfo);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (descriptor) {
+ swig_cast_info *cast = SWIG_TypeCheck(SWIG_TypeName((swig_type_info*)pvTypeinfo), descriptor);
+ return (cast != NULL);
+ }
+ else {
+ return SWIG_ERROR;
+ }
+ }
+ else {
+ return (iType == sci_pointer);
+ }
+}
+
+SWIGINTERN int
+SwigScilabPtrToObject(void *pvApiCtx, int iVar, void **pvObj, swig_type_info *descriptor, int flags, char *fname) {
+ SciErr sciErr;
int *piAddrVar = NULL;
+ int iType = 0;
+ void *pvPtr = NULL;
sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
if (sciErr.iErr) {
@@ -119,8 +171,48 @@ SwigScilabPtrToObject(void *pvApiCtx, int iVar, void **pObjValue, swig_type_info
return SWIG_ERROR;
}
- if (iType == sci_pointer) {
- sciErr = getPointer(pvApiCtx, piAddrVar, pObjValue);
+ if (iType == sci_tlist) {
+ int iItemCount = 0;
+ void *pvTypeinfo = NULL;
+
+ sciErr = getListItemNumber(pvApiCtx, piAddrVar, &iItemCount);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iItemCount < 3) {
+ return SWIG_ERROR;
+ }
+
+ sciErr = getPointerInList(pvApiCtx, piAddrVar, 2, &pvTypeinfo);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getPointerInList(pvApiCtx, piAddrVar, 3, &pvPtr);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (pvPtr) {
+ if (descriptor) {
+ swig_cast_info *cast = SWIG_TypeCheck(SWIG_TypeName((swig_type_info *)pvTypeinfo), descriptor);
+ if (cast) {
+ int newmemory = 0;
+ pvPtr = SWIG_TypeCast(cast, pvPtr, &newmemory);
+ // TODO newmemory
+ }
+ else {
+ return SWIG_ERROR;
+ }
+ }
+ }
+ }
+ else if (iType == sci_pointer) {
+ sciErr = getPointer(pvApiCtx, piAddrVar, &pvPtr);
if (sciErr.iErr) {
printError(&sciErr, 0);
return SWIG_ERROR;
@@ -130,22 +222,63 @@ SwigScilabPtrToObject(void *pvApiCtx, int iVar, void **pObjValue, swig_type_info
return SWIG_ERROR;
}
- return SWIG_OK;
+ if (pvObj) {
+ *pvObj = pvPtr;
+ return SWIG_OK;
+ }
+ else {
+ return SWIG_ERROR;
+ }
}
SWIGRUNTIMEINLINE int
-SwigScilabPtrFromObject(void *pvApiCtx, int iVarOut, void *obj, swig_type_info *descriptor, int flags) {
+SwigScilabPtrFromObject(void *pvApiCtx, int iVarOut, void *pvObj, swig_type_info *descriptor, int flags) {
SciErr sciErr;
- sciErr = createPointer(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, (void *)obj);
- if (sciErr.iErr) {
- printError(&sciErr, 0);
- return SWIG_ERROR;
+ if (descriptor) {
+ int *piTListAddr = NULL;
+ const char *pstString;
+
+ sciErr = createTList(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, 3, &piTListAddr);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ pstString = SWIG_TypeName(descriptor);
+ sciErr = createMatrixOfStringInList(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, piTListAddr, 1, 1, 1, &pstString);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ sciErr = createPointerInList(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, piTListAddr, 2, descriptor);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+
+ sciErr = createPointerInList(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, piTListAddr, 3, pvObj);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ }
+ else {
+ sciErr = createPointer(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, pvObj);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
}
return SWIG_OK;
}
+/* Pointer argument conversions */
+
+
SWIGRUNTIME int
SWIG_Scilab_ConvertPacked(void *pvApiCtx, int iVar, void *ptr, int sz, swig_type_info *ty, char *fname) {
swig_cast_info *tc;
@@ -324,4 +457,3 @@ int SWIG_ptr(SWIG_GatewayParameters) {
return SWIG_ERROR;
}
}
-
diff --git a/Lib/scilab/scisequence.swg b/Lib/scilab/scisequence.swg
index cc9da1fab..5fe0fdbe2 100644
--- a/Lib/scilab/scisequence.swg
+++ b/Lib/scilab/scisequence.swg
@@ -47,21 +47,21 @@ namespace swig {
// Error returned for sequence containers of default item type
template <typename T> struct traits_as_sequence {
static int check(SwigSciObject obj) {
- SWIG_Error(SWIG_TypeError, type_name<T>());
+ throw std::invalid_argument("The container data type is not supported.");
}
static int get(SwigSciObject obj, void **sequence) {
- SWIG_Error(SWIG_TypeError, type_name<T>());
+ throw std::invalid_argument("The container data type is not supported.");
}
static int size(SwigSciObject obj, int *size) {
- SWIG_Error(SWIG_TypeError, type_name<T>());
+ throw std::invalid_argument("The container data type is not supported.");
}
};
template <typename T> struct traits_from_sequence {
static int create(int size, void **sequence) {
- SWIG_Error(SWIG_TypeError, type_name<T>());
+ throw std::invalid_argument("The container data type is not supported.");
}
static SwigSciObject set(int size, void *sequence) {
- SWIG_Error(SWIG_TypeError, type_name<T>());
+ throw std::invalid_argument("The container data type is not supported.");
}
};
@@ -136,12 +136,12 @@ namespace swig {
// Error returned for sequence containers of default item type
template <typename T> struct traits_asval_sequenceitem {
static T asval(SwigSciObject obj, void *pSequence, int iItemIndex) {
- SWIG_Error(SWIG_TypeError, type_name<T>());
+ throw std::invalid_argument("The container data type is not supported.");
}
};
template <typename T> struct traits_from_sequenceitem {
static int from(void *pSequence, int iItemIndex, T itemValue) {
- SWIG_Error(SWIG_TypeError, type_name<T>());
+ throw std::invalid_argument("The container data type is not supported.");
}
};
diff --git a/Lib/scilab/scitypemaps.swg b/Lib/scilab/scitypemaps.swg
index 62a819f35..175a41b51 100644
--- a/Lib/scilab/scitypemaps.swg
+++ b/Lib/scilab/scitypemaps.swg
@@ -147,11 +147,18 @@
}
%enddef
+%define %scilab_typecheck_pointer(PRECEDENCE, TYPE)
+%typecheck(PRECEDENCE) TYPE {
+ $1 = SwigScilabCheckPtr(pvApiCtx, $input, $descriptor, SWIG_Scilab_GetFuncName());
+}
+%enddef
+
+
// Double (and Float) have priority over before Integer type.
// Primitive types
-%scilab_typecheck_generic(SWIG_TYPECHECK_VOIDPTR, isPointerType, SWIGTYPE *)
-%scilab_typecheck_generic(SWIG_TYPECHECK_POINTER, isPointerType, SWIGTYPE *)
+%scilab_typecheck_pointer(SWIG_TYPECHECK_VOIDPTR, SWIGTYPE *)
+%scilab_typecheck_pointer(SWIG_TYPECHECK_POINTER, SWIGTYPE *)
%scilab_typecheck_generic(SWIG_TYPECHECK_BOOL, isBooleanType, bool)
%scilab_typecheck_generic(16, isDoubleType, double)
%scilab_typecheck_generic(17, isDoubleType, float)
diff --git a/Lib/scilab/std_basic_string.i b/Lib/scilab/std_basic_string.i
index 4922abd35..43b660db6 100644
--- a/Lib/scilab/std_basic_string.i
+++ b/Lib/scilab/std_basic_string.i
@@ -16,7 +16,6 @@ SWIG_AsPtr_dec(std::basic_string<char>)(int _iVar, std::basic_string<char> **_ps
if (buf) {
if (_pstValue) {
*_pstValue = new std::string(buf, len - 1);
- sciprint("%s\n", (*_pstValue)->c_str());
}
if (alloc == SWIG_NEWOBJ) {
delete[] buf;
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 e8124df9c..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 & {
@@ -625,6 +625,7 @@
%typemap(constcode, noblock=1) SWIGTYPE ((*)(ANY)){
%set_constant("$symname", SWIG_NewFunctionPtrObj((void *)$value, $descriptor));
}
+%typemap(constcode) SWIGTYPE ((* const)(ANY)) = SWIGTYPE ((*)(ANY));
#if defined(SWIG_DIRECTOR_TYPEMAPS)
diff --git a/README b/README
index b24475d61..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,
@@ -68,9 +68,13 @@ than one version of SWIG.
Installation
============
Please read the Doc/Manual/Preface.html#Preface_installation for
-full installation instructions for Windows, Unix and Mac OS X.
-The INSTALL file has generic build and installation instructions for
-Unix users.
+full installation instructions for Windows, Unix and Mac OS X
+using the release tarball/zip file. The INSTALL file has generic
+build and installation instructions for Unix users.
+Users wishing to build and install code from Github should
+visit http://swig.org/svn.html to obtain the more detailed
+instructions required for building code obtained from Github - extra
+steps are required compared to building from the release tarball.
Testing
=======
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 621d43421..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");
@@ -2926,6 +2939,14 @@ c_decl : storage_class type declarator initializer c_decl_tail {
Setattr($$,"throws",$4.throws);
Setattr($$,"throw",$4.throwf);
Setattr($$,"noexcept",$4.nexcept);
+ if ($4.val && $4.type) {
+ /* store initializer type as it might be different to the declared type */
+ SwigType *valuetype = NewSwigType($4.type);
+ if (Len(valuetype) > 0)
+ Setattr($$,"valuetype",valuetype);
+ else
+ Delete(valuetype);
+ }
if (!$5) {
if (Len(scanner_ccode)) {
String *code = Copy(scanner_ccode);
@@ -6131,11 +6152,11 @@ exprcompound : expr PLUS expr {
}
/* Sadly this causes 2 reduce-reduce conflicts with templates. FIXME resolve these.
| expr GREATERTHAN expr {
- $$.val = NewStringf("%s < %s", $1.val, $3.val);
+ $$.val = NewStringf("%s > %s", $1.val, $3.val);
$$.type = cparse_cplusplus ? T_BOOL : T_INT;
}
| expr LESSTHAN expr {
- $$.val = NewStringf("%s > %s", $1.val, $3.val);
+ $$.val = NewStringf("%s < %s", $1.val, $3.val);
$$.type = cparse_cplusplus ? T_BOOL : T_INT;
}
*/
diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h
index bc54bc774..865655896 100644
--- a/Source/Include/swigwarn.h
+++ b/Source/Include/swigwarn.h
@@ -256,6 +256,7 @@
#define WARN_JAVA_TYPEMAP_JAVAIN_UNDEF 818
#define WARN_JAVA_TYPEMAP_JAVADIRECTORIN_UNDEF 819
#define WARN_JAVA_TYPEMAP_JAVADIRECTOROUT_UNDEF 820
+#define WARN_JAVA_TYPEMAP_INTERFACECODE_UNDEF 821
#define WARN_JAVA_COVARIANT_RET 822
#define WARN_JAVA_TYPEMAP_JAVACONSTRUCT_UNDEF 823
#define WARN_JAVA_TYPEMAP_DIRECTORIN_NODESC 824
@@ -275,6 +276,7 @@
#define WARN_CSHARP_TYPEMAP_CSIN_UNDEF 838
#define WARN_CSHARP_TYPEMAP_CSDIRECTORIN_UNDEF 839
#define WARN_CSHARP_TYPEMAP_CSDIRECTOROUT_UNDEF 840
+#define WARN_CSHARP_TYPEMAP_INTERFACECODE_UNDEF 841
#define WARN_CSHARP_COVARIANT_RET 842
#define WARN_CSHARP_TYPEMAP_CSCONSTRUCT_UNDEF 843
#define WARN_CSHARP_EXCODE 844
diff --git a/Source/Makefile.am b/Source/Makefile.am
index a316b83d1..d14865ee0 100644
--- a/Source/Makefile.am
+++ b/Source/Makefile.am
@@ -47,6 +47,7 @@ eswig_SOURCES = CParse/cscanner.c \
Modules/emit.cxx \
Modules/go.cxx \
Modules/guile.cxx \
+ Modules/interface.cxx \
Modules/java.cxx \
Modules/javascript.cxx \
Modules/lang.cxx \
diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx
index fae255b7f..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;
}
@@ -3166,6 +3169,9 @@ int ALLEGROCL::enumDeclaration(Node *n) {
Printf(stderr, "enumDeclaration %s\n", Getattr(n, "name"));
#endif
+ if (getCurrentClass() && (cplus_mode != PUBLIC))
+ return SWIG_NOWRAP;
+
if (Getattr(n, "sym:name")) {
add_defined_foreign_type(n);
}
diff --git a/Source/Modules/allocate.cxx b/Source/Modules/allocate.cxx
index f79373d18..3d382b378 100644
--- a/Source/Modules/allocate.cxx
+++ b/Source/Modules/allocate.cxx
@@ -729,6 +729,8 @@ Allocate():
}
}
+ Swig_interface_propagate_methods(n);
+
/* Only care about default behavior. Remove temporary values */
Setattr(n, "allocate:visit", "1");
Swig_symbol_setscope(symtab);
diff --git a/Source/Modules/cffi.cxx b/Source/Modules/cffi.cxx
index 5d2b8435c..c355e452a 100644
--- a/Source/Modules/cffi.cxx
+++ b/Source/Modules/cffi.cxx
@@ -688,6 +688,9 @@ int CFFI::typedefHandler(Node *n) {
}
int CFFI::enumDeclaration(Node *n) {
+ if (getCurrentClass() && (cplus_mode != PUBLIC))
+ return SWIG_NOWRAP;
+
String *name = Getattr(n, "sym:name");
bool slot_name_keywords;
String *lisp_name = 0;
@@ -1107,7 +1110,7 @@ String *CFFI::convert_literal(String *literal, String *type, bool try_to_split)
return num;
} else if (SwigType_type(type) == T_CHAR) {
/* Use CL syntax for character literals */
- String* result = NewStringf("#\\%c", s[0]);
+ String* result = NewStringf("#\\%s", s);
Delete(num);
return result;
} else if (SwigType_type(type) == T_STRING) {
diff --git a/Source/Modules/clisp.cxx b/Source/Modules/clisp.cxx
index 7d7c69a50..d7f197197 100644
--- a/Source/Modules/clisp.cxx
+++ b/Source/Modules/clisp.cxx
@@ -242,6 +242,9 @@ int CLISP::typedefHandler(Node *n) {
}
int CLISP::enumDeclaration(Node *n) {
+ if (getCurrentClass() && (cplus_mode != PUBLIC))
+ return SWIG_NOWRAP;
+
is_function = 0;
String *name = Getattr(n, "sym:name");
diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx
index 8a047c46d..01fd5435b 100644
--- a/Source/Modules/csharp.cxx
+++ b/Source/Modules/csharp.cxx
@@ -52,6 +52,7 @@ class CSHARP:public Language {
String *imclass_class_code; // intermediary class code
String *proxy_class_def;
String *proxy_class_code;
+ String *interface_class_code; // if %feature("interface") was declared for a class, here goes the interface declaration
String *module_class_code;
String *proxy_class_name; // proxy class name
String *full_imclass_name; // fully qualified intermediary class name when using nspace feature, otherwise same as imclass_name
@@ -126,6 +127,7 @@ public:
imclass_class_code(NULL),
proxy_class_def(NULL),
proxy_class_code(NULL),
+ interface_class_code(NULL),
module_class_code(NULL),
proxy_class_name(NULL),
full_imclass_name(NULL),
@@ -186,8 +188,12 @@ public:
String *symname = Copy(Getattr(n, "sym:name"));
if (symname && !GetFlag(n, "feature:flatnested")) {
for (Node *outer_class = Getattr(n, "nested:outer"); outer_class; outer_class = Getattr(outer_class, "nested:outer")) {
- Push(symname, ".");
- Push(symname, Getattr(outer_class, "sym:name"));
+ if (String* name = Getattr(outer_class, "sym:name")) {
+ Push(symname, ".");
+ Push(symname, name);
+ }
+ else
+ return NULL;
}
}
if (nspace) {
@@ -272,6 +278,7 @@ public:
SWIG_config_file("csharp.swg");
allow_overloading();
+ Swig_interface_feature_enable();
}
/* ---------------------------------------------------------------------
@@ -1317,7 +1324,7 @@ public:
const char *val = Equal(Getattr(n, "enumvalue"), "true") ? "1" : "0";
Setattr(n, "enumvalue", val);
} else if (swigtype == T_CHAR) {
- String *val = NewStringf("'%s'", Getattr(n, "enumvalue"));
+ String *val = NewStringf("'%(hexescape)s'", Getattr(n, "enumvalue"));
Setattr(n, "enumvalue", val);
Delete(val);
}
@@ -1441,6 +1448,7 @@ public:
virtual int constantWrapper(Node *n) {
String *symname = Getattr(n, "sym:name");
SwigType *t = Getattr(n, "type");
+ SwigType *valuetype = Getattr(n, "valuetype");
ParmList *l = Getattr(n, "parms");
String *tm;
String *return_type = NewString("");
@@ -1493,13 +1501,15 @@ public:
Swig_warning(WARN_CSHARP_TYPEMAP_CSWTYPE_UNDEF, input_file, line_number, "No cstype typemap defined for %s\n", SwigType_str(t, 0));
}
+ // Default (octal) escaping is no good - change to hex escaped value
+ String *hexescaped_value = Getattr(n, "rawvalue") ? NewStringf("%(hexescape)s", Getattr(n, "rawvalue")) : 0;
// Add the stripped quotes back in
String *new_value = NewString("");
if (SwigType_type(t) == T_STRING) {
- Printf(new_value, "\"%s\"", Copy(Getattr(n, "value")));
+ Printf(new_value, "\"%s\"", hexescaped_value ? hexescaped_value : Copy(Getattr(n, "value")));
Setattr(n, "value", new_value);
} else if (SwigType_type(t) == T_CHAR) {
- Printf(new_value, "\'%s\'", Copy(Getattr(n, "value")));
+ Printf(new_value, "\'%s\'", hexescaped_value ? hexescaped_value : Copy(Getattr(n, "value")));
Setattr(n, "value", new_value);
}
@@ -1540,10 +1550,14 @@ public:
} else {
// Alternative constant handling will use the C syntax to make a true C# constant and hope that it compiles as C# code
if (Getattr(n, "wrappedasconstant")) {
- if (SwigType_type(t) == T_CHAR)
- Printf(constants_code, "\'%s\';\n", Getattr(n, "staticmembervariableHandler:value"));
- else
+ if (SwigType_type(t) == T_CHAR) {
+ if (SwigType_type(valuetype) == T_CHAR)
+ Printf(constants_code, "\'%(hexescape)s\';\n", Getattr(n, "staticmembervariableHandler:value"));
+ else
+ Printf(constants_code, "(char)%s;\n", Getattr(n, "staticmembervariableHandler:value"));
+ } else {
Printf(constants_code, "%s;\n", Getattr(n, "staticmembervariableHandler:value"));
+ }
} else {
Printf(constants_code, "%s;\n", Getattr(n, "value"));
}
@@ -1644,6 +1658,119 @@ public:
}
/* -----------------------------------------------------------------------------
+ * getQualifiedInterfaceName()
+ * ----------------------------------------------------------------------------- */
+
+ String *getQualifiedInterfaceName(Node *n) {
+ String *ret = Getattr(n, "interface:qname");
+ if (!ret) {
+ String *nspace = Getattr(n, "sym:nspace");
+ String *interface_name = Getattr(n, "interface:name");
+ if (nspace) {
+ if (namespce)
+ ret = NewStringf("%s.%s.%s", namespce, nspace, interface_name);
+ else
+ ret = NewStringf("%s.%s", nspace, interface_name);
+ } else {
+ ret = Copy(interface_name);
+ }
+ Setattr(n, "interface:qname", ret);
+ }
+ return ret;
+ }
+
+ /* -----------------------------------------------------------------------------
+ * getInterfaceName()
+ * ----------------------------------------------------------------------------- */
+
+ String *getInterfaceName(SwigType *t, bool qualified) {
+ String *interface_name = NULL;
+ if (proxy_flag) {
+ Node *n = classLookup(t);
+ if (n && Getattr(n, "interface:name"))
+ interface_name = qualified ? getQualifiedInterfaceName(n) : Getattr(n, "interface:name");
+ }
+ return interface_name;
+ }
+
+ /* -----------------------------------------------------------------------------
+ * addInterfaceNameAndUpcasts()
+ * ----------------------------------------------------------------------------- */
+
+ void addInterfaceNameAndUpcasts(SwigType *smart, String *interface_list, String *interface_upcasts, Hash *base_list, String *c_classname) {
+ List *keys = Keys(base_list);
+ for (Iterator it = First(keys); it.item; it = Next(it)) {
+ Node *base = Getattr(base_list, it.item);
+ String *c_baseclass = SwigType_namestr(Getattr(base, "name"));
+ String *interface_name = Getattr(base, "interface:name");
+ if (Len(interface_list))
+ Append(interface_list, ", ");
+ Append(interface_list, interface_name);
+
+ Node *attributes = NewHash();
+ String *interface_code = Copy(typemapLookup(base, "csinterfacecode", Getattr(base, "classtypeobj"), WARN_CSHARP_TYPEMAP_INTERFACECODE_UNDEF, attributes));
+ String *cptr_method_name = 0;
+ if (interface_code) {
+ Replaceall(interface_code, "$interfacename", interface_name);
+ Printv(interface_upcasts, interface_code, NIL);
+ cptr_method_name = Copy(Getattr(attributes, "tmap:csinterfacecode:cptrmethod"));
+ }
+ if (!cptr_method_name)
+ cptr_method_name = NewStringf("%s_GetInterfaceCPtr", interface_name);
+ Replaceall(cptr_method_name, ".", "_");
+ Replaceall(cptr_method_name, "$interfacename", interface_name);
+
+ String *upcast_method_name = Swig_name_member(getNSpace(), proxy_class_name, cptr_method_name);
+ upcastsCode(smart, upcast_method_name, c_classname, c_baseclass);
+
+ Delete(upcast_method_name);
+ Delete(cptr_method_name);
+ Delete(interface_code);
+ Delete(c_baseclass);
+ }
+ Delete(keys);
+ }
+
+ /* -----------------------------------------------------------------------------
+ * upcastsCode()
+ *
+ * Add code for C++ casting to base class
+ * ----------------------------------------------------------------------------- */
+
+ void upcastsCode(SwigType *smart, String *upcast_method_name, String *c_classname, String *c_baseclass) {
+ String *wname = Swig_name_wrapper(upcast_method_name);
+
+ Printv(imclass_cppcasts_code, "\n [global::System.Runtime.InteropServices.DllImport(\"", dllimport, "\", EntryPoint=\"", wname, "\")]\n", NIL);
+ Printf(imclass_cppcasts_code, " public static extern global::System.IntPtr %s(global::System.IntPtr jarg1);\n", upcast_method_name);
+
+ Replaceall(imclass_cppcasts_code, "$csclassname", proxy_class_name);
+
+ if (smart) {
+ SwigType *bsmart = Copy(smart);
+ SwigType *rclassname = SwigType_typedef_resolve_all(c_classname);
+ SwigType *rbaseclass = SwigType_typedef_resolve_all(c_baseclass);
+ Replaceall(bsmart, rclassname, rbaseclass);
+ Delete(rclassname);
+ Delete(rbaseclass);
+ String *smartnamestr = SwigType_namestr(smart);
+ String *bsmartnamestr = SwigType_namestr(bsmart);
+ Printv(upcasts_code,
+ "SWIGEXPORT ", bsmartnamestr, " * SWIGSTDCALL ", wname, "(", smartnamestr, " *jarg1) {\n",
+ " return jarg1 ? new ", bsmartnamestr, "(*jarg1) : 0;\n"
+ "}\n", "\n", NIL);
+ Delete(bsmartnamestr);
+ Delete(smartnamestr);
+ Delete(bsmart);
+ } else {
+ Printv(upcasts_code,
+ "SWIGEXPORT ", c_baseclass, " * SWIGSTDCALL ", wname, "(", c_classname, " *jarg1) {\n",
+ " return (", c_baseclass, " *)jarg1;\n"
+ "}\n", "\n", NIL);
+ }
+ Delete(wname);
+ }
+
+ /* -----------------------------------------------------------------------------
* emitProxyClassDefAndCPPCasts()
* ----------------------------------------------------------------------------- */
@@ -1652,9 +1779,12 @@ public:
String *c_baseclass = NULL;
String *baseclass = NULL;
String *c_baseclassname = NULL;
+ String *interface_list = NewStringEmpty();
+ String *interface_upcasts = NewStringEmpty();
SwigType *typemap_lookup_type = Getattr(n, "classtypeobj");
bool feature_director = Swig_directorclass(n) ? true : false;
bool has_outerclass = Getattr(n, "nested:outer") != 0 && !GetFlag(n, "feature:flatnested");
+ SwigType *smart = Swig_cparse_smartptr(n);
// Inheritance from pure C# classes
Node *attributes = NewHash();
@@ -1667,31 +1797,29 @@ public:
if (!purebase_replace) {
List *baselist = Getattr(n, "bases");
if (baselist) {
- Iterator base = First(baselist);
- while (base.item && GetFlag(base.item, "feature:ignore")) {
- base = Next(base);
- }
- if (base.item) {
- c_baseclassname = Getattr(base.item, "name");
- baseclass = Copy(getProxyName(c_baseclassname));
- if (baseclass)
- c_baseclass = SwigType_namestr(Getattr(base.item, "name"));
- base = Next(base);
- /* Warn about multiple inheritance for additional base class(es) */
- while (base.item) {
- if (GetFlag(base.item, "feature:ignore")) {
- base = Next(base);
- continue;
- }
- String *proxyclassname = Getattr(n, "classtypeobj");
- String *baseclassname = Getattr(base.item, "name");
- Swig_warning(WARN_CSHARP_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
- "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in C#.\n", SwigType_namestr(proxyclassname), SwigType_namestr(baseclassname));
- base = Next(base);
- }
- }
+ Iterator base = First(baselist);
+ while (base.item) {
+ if (!(GetFlag(base.item, "feature:ignore") || Getattr(base.item, "feature:interface"))) {
+ String *baseclassname = Getattr(base.item, "name");
+ if (!c_baseclassname) {
+ c_baseclassname = baseclassname;
+ baseclass = Copy(getProxyName(baseclassname));
+ if (baseclass)
+ c_baseclass = SwigType_namestr(baseclassname);
+ } else {
+ /* Warn about multiple inheritance for additional base class(es) */
+ String *proxyclassname = Getattr(n, "classtypeobj");
+ Swig_warning(WARN_CSHARP_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
+ "Warning for %s, base %s ignored. Multiple inheritance is not supported in C#.\n", SwigType_namestr(proxyclassname), SwigType_namestr(baseclassname));
+ }
+ }
+ base = Next(base);
+ }
}
}
+ Hash *interface_bases = Getattr(n, "interface:bases");
+ if (interface_bases)
+ addInterfaceNameAndUpcasts(smart, interface_list, interface_upcasts, interface_bases, c_classname);
bool derived = baseclass && getProxyName(c_baseclassname);
if (derived && purebase_notderived)
@@ -1707,12 +1835,15 @@ public:
Swig_error(Getfile(n), Getline(n), "The csbase typemap for proxy %s must contain just one of the 'replace' or 'notderived' attributes.\n", typemap_lookup_type);
} else if (Len(pure_baseclass) > 0 && Len(baseclass) > 0) {
Swig_warning(WARN_CSHARP_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
- "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in C#. "
+ "Warning for %s, base %s ignored. Multiple inheritance is not supported in C#. "
"Perhaps you need one of the 'replace' or 'notderived' attributes in the csbase typemap?\n", typemap_lookup_type, pure_baseclass);
}
// Pure C# interfaces
const String *pure_interfaces = typemapLookup(n, derived ? "csinterfaces_derived" : "csinterfaces", typemap_lookup_type, WARN_NONE);
+ if (*Char(interface_list) && *Char(pure_interfaces))
+ Append(interface_list, ", ");
+ Append(interface_list, pure_interfaces);
// Start writing the proxy class
if (!has_outerclass)
Printv(proxy_class_def, typemapLookup(n, "csimports", typemap_lookup_type, WARN_NONE), // Import statements
@@ -1725,8 +1856,8 @@ public:
Printv(proxy_class_def, typemapLookup(n, "csclassmodifiers", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
" $csclassname", // Class name and base class
- (*Char(wanted_base) || *Char(pure_interfaces)) ? " : " : "", wanted_base, (*Char(wanted_base) && *Char(pure_interfaces)) ? // Interfaces
- ", " : "", pure_interfaces, " {", derived ? typemapLookup(n, "csbody_derived", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF) : // main body of class
+ (*Char(wanted_base) || *Char(interface_list)) ? " : " : "", wanted_base, (*Char(wanted_base) && *Char(interface_list)) ? // Interfaces
+ ", " : "", interface_list, " {", derived ? typemapLookup(n, "csbody_derived", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF) : // main body of class
typemapLookup(n, "csbody", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF), // main body of class
NIL);
@@ -1771,6 +1902,8 @@ public:
Printv(proxy_class_def, "\n ", destruct_methodmodifiers, " ", derived ? "override" : "virtual", " void ", destruct_methodname, "() ", destruct, "\n",
NIL);
}
+ if (*Char(interface_upcasts))
+ Printv(proxy_class_def, interface_upcasts, NIL);
if (feature_director) {
// Generate director connect method
@@ -1852,6 +1985,8 @@ public:
Delete(director_connect_method_name);
}
+ Delete(interface_upcasts);
+ Delete(interface_list);
Delete(attributes);
Delete(destruct);
@@ -1859,54 +1994,92 @@ public:
Printv(proxy_class_def, typemapLookup(n, "cscode", typemap_lookup_type, WARN_NONE), // extra C# code
"\n", NIL);
- // Add code to do C++ casting to base class (only for classes in an inheritance hierarchy)
if (derived) {
- SwigType *smart = Swig_cparse_smartptr(n);
- String *upcast_method = Swig_name_member(getNSpace(), getClassPrefix(), smart != 0 ? "SWIGSmartPtrUpcast" : "SWIGUpcast");
- String *wname = Swig_name_wrapper(upcast_method);
-
- Printv(imclass_cppcasts_code, "\n [global::System.Runtime.InteropServices.DllImport(\"", dllimport, "\", EntryPoint=\"", wname, "\")]\n", NIL);
- Printf(imclass_cppcasts_code, " public static extern global::System.IntPtr %s(global::System.IntPtr jarg1);\n", upcast_method);
-
- Replaceall(imclass_cppcasts_code, "$csclassname", proxy_class_name);
-
- if (smart) {
- SwigType *bsmart = Copy(smart);
- SwigType *rclassname = SwigType_typedef_resolve_all(c_classname);
- SwigType *rbaseclass = SwigType_typedef_resolve_all(c_baseclass);
- Replaceall(bsmart, rclassname, rbaseclass);
- Delete(rclassname);
- Delete(rbaseclass);
- String *smartnamestr = SwigType_namestr(smart);
- String *bsmartnamestr = SwigType_namestr(bsmart);
- Printv(upcasts_code,
- "SWIGEXPORT ", bsmartnamestr, " * SWIGSTDCALL ", wname, "(", smartnamestr, " *jarg1) {\n",
- " return jarg1 ? new ", bsmartnamestr, "(*jarg1) : 0;\n"
- "}\n", "\n", NIL);
- Delete(bsmartnamestr);
- Delete(smartnamestr);
- Delete(bsmart);
- } else {
- Printv(upcasts_code,
- "SWIGEXPORT ", c_baseclass, " * SWIGSTDCALL ", wname, "(", c_classname, " *jarg1) {\n",
- " return (", c_baseclass, " *)jarg1;\n"
- "}\n", "\n", NIL);
- }
- Delete(wname);
- Delete(upcast_method);
- Delete(smart);
+ String *upcast_method_name = Swig_name_member(getNSpace(), getClassPrefix(), smart != 0 ? "SWIGSmartPtrUpcast" : "SWIGUpcast");
+ upcastsCode(smart, upcast_method_name, c_classname, c_baseclass);
+ Delete(upcast_method_name);
}
+
+ Delete(smart);
Delete(baseclass);
}
/* ----------------------------------------------------------------------
+ * emitInterfaceDeclaration()
+ * ---------------------------------------------------------------------- */
+
+ void emitInterfaceDeclaration(Node *n, String *interface_name, File *f_interface) {
+ Printv(f_interface, typemapLookup(n, "csimports", Getattr(n, "classtypeobj"), WARN_NONE), "\n", NIL);
+ Printf(f_interface, "public interface %s", interface_name);
+ if (List *baselist = Getattr(n, "bases")) {
+ String *bases = 0;
+ for (Iterator base = First(baselist); base.item; base = Next(base)) {
+ if (GetFlag(base.item, "feature:ignore") || !Getattr(base.item, "feature:interface"))
+ continue; // TODO: warn about skipped non-interface bases
+ String *base_iname = Getattr(base.item, "interface:name");
+ if (!bases)
+ bases = NewStringf(" : %s", base_iname);
+ else {
+ Append(bases, ", ");
+ Append(bases, base_iname);
+ }
+ }
+ if (bases) {
+ Printv(f_interface, bases, NIL);
+ Delete(bases);
+ }
+ }
+ Printf(f_interface, " {\n");
+
+ Node *attributes = NewHash();
+ String *interface_code = Copy(typemapLookup(n, "csinterfacecode", Getattr(n, "classtypeobj"), WARN_CSHARP_TYPEMAP_INTERFACECODE_UNDEF, attributes));
+ if (interface_code) {
+ String *interface_declaration = Copy(Getattr(attributes, "tmap:csinterfacecode:declaration"));
+ if (interface_declaration) {
+ Replaceall(interface_declaration, "$interfacename", interface_name);
+ Printv(f_interface, interface_declaration, NIL);
+ Delete(interface_declaration);
+ }
+ Delete(interface_code);
+ }
+ }
+
+ /* ----------------------------------------------------------------------
+ * calculateDirectBase()
+ * ---------------------------------------------------------------------- */
+
+ void calculateDirectBase(Node* n) {
+ Node* direct_base = 0;
+ // C++ inheritance
+ Node *attributes = NewHash();
+ SwigType *typemap_lookup_type = Getattr(n, "classtypeobj");
+ const String *pure_baseclass = typemapLookup(n, "csbase", typemap_lookup_type, WARN_NONE, attributes);
+ bool purebase_replace = GetFlag(attributes, "tmap:csbase:replace") ? true : false;
+ bool purebase_notderived = GetFlag(attributes, "tmap:csbase:notderived") ? true : false;
+ Delete(attributes);
+ if (!purebase_replace) {
+ if (List *baselist = Getattr(n, "bases")) {
+ Iterator base = First(baselist);
+ while (base.item && (GetFlag(base.item, "feature:ignore") || Getattr(base.item, "feature:interface")))
+ base = Next(base);
+ direct_base = base.item;
+ }
+ if (!direct_base && purebase_notderived)
+ direct_base = symbolLookup(const_cast<String*>(pure_baseclass));
+ } else {
+ direct_base = symbolLookup(const_cast<String*>(pure_baseclass));
+ }
+ Setattr(n, "direct_base", direct_base);
+ }
+
+ /* ----------------------------------------------------------------------
* classHandler()
* ---------------------------------------------------------------------- */
virtual int classHandler(Node *n) {
-
String *nspace = getNSpace();
File *f_proxy = NULL;
+ File *f_interface = NULL;
// save class local variables
String *old_proxy_class_name = proxy_class_name;
String *old_full_imclass_name = full_imclass_name;
@@ -1915,9 +2088,12 @@ public:
String *old_proxy_class_def = proxy_class_def;
String *old_proxy_class_code = proxy_class_code;
bool has_outerclass = Getattr(n, "nested:outer") && !GetFlag(n, "feature:flatnested");
+ String *old_interface_class_code = interface_class_code;
+ interface_class_code = 0;
if (proxy_flag) {
proxy_class_name = NewString(Getattr(n, "sym:name"));
+ String *interface_name = Getattr(n, "feature:interface") ? Getattr(n, "interface:name") : 0;
if (Node *outer = Getattr(n, "nested:outer")) {
String *outerClassesPrefix = Copy(Getattr(outer, "sym:name"));
for (outer = Getattr(outer, "nested:outer"); outer != 0; outer = Getattr(outer, "nested:outer")) {
@@ -1927,13 +2103,16 @@ public:
String *fnspace = nspace ? NewStringf("%s.%s", nspace, outerClassesPrefix) : outerClassesPrefix;
if (!addSymbol(proxy_class_name, n, fnspace))
return SWIG_ERROR;
+ if (interface_name && !addInterfaceSymbol(interface_name, n, fnspace))
+ return SWIG_ERROR;
if (nspace)
Delete(fnspace);
Delete(outerClassesPrefix);
- }
- else {
+ } else {
if (!addSymbol(proxy_class_name, n, nspace))
return SWIG_ERROR;
+ if (interface_name && !addInterfaceSymbol(interface_name, n, nspace))
+ return SWIG_ERROR;
}
if (!nspace) {
@@ -1960,13 +2139,25 @@ public:
f_proxy = getOutputFile(output_directory, proxy_class_name);
addOpenNamespace(nspace, f_proxy);
+ Delete(output_directory);
}
else
++nesting_depth;
+
proxy_class_def = NewString("");
proxy_class_code = NewString("");
destructor_call = NewString("");
proxy_class_constants_code = NewString("");
+
+ if (Getattr(n, "feature:interface")) {
+ interface_class_code = NewString("");
+ String *output_directory = outputDirectory(nspace);
+ f_interface = getOutputFile(output_directory, interface_name);
+ addOpenNamespace(nspace, f_interface);
+ emitInterfaceDeclaration(n, interface_name, interface_class_code);
+ Delete(output_directory);
+ }
+ calculateDirectBase(n);
}
Language::classHandler(n);
@@ -1980,22 +2171,28 @@ public:
Replaceall(proxy_class_def, "$csclassname", proxy_class_name);
Replaceall(proxy_class_code, "$csclassname", proxy_class_name);
Replaceall(proxy_class_constants_code, "$csclassname", proxy_class_name);
+ Replaceall(interface_class_code, "$csclassname", proxy_class_name);
Replaceall(proxy_class_def, "$csclazzname", csclazzname);
Replaceall(proxy_class_code, "$csclazzname", csclazzname);
Replaceall(proxy_class_constants_code, "$csclazzname", csclazzname);
+ Replaceall(interface_class_code, "$csclazzname", csclazzname);
Replaceall(proxy_class_def, "$module", module_class_name);
Replaceall(proxy_class_code, "$module", module_class_name);
Replaceall(proxy_class_constants_code, "$module", module_class_name);
+ Replaceall(interface_class_code, "$module", module_class_name);
Replaceall(proxy_class_def, "$imclassname", full_imclass_name);
Replaceall(proxy_class_code, "$imclassname", full_imclass_name);
Replaceall(proxy_class_constants_code, "$imclassname", full_imclass_name);
+ Replaceall(interface_class_code, "$imclassname", full_imclass_name);
Replaceall(proxy_class_def, "$dllimport", dllimport);
Replaceall(proxy_class_code, "$dllimport", dllimport);
Replaceall(proxy_class_constants_code, "$dllimport", dllimport);
+ Replaceall(interface_class_code, "$dllimport", dllimport);
+
if (!has_outerclass)
Printv(f_proxy, proxy_class_def, proxy_class_code, NIL);
else {
@@ -2058,8 +2255,18 @@ public:
Delete(downcast_method);
}
+ if (f_interface) {
+ Printv(f_interface, interface_class_code, "}\n", NIL);
+ addCloseNamespace(nspace, f_interface);
+ if (f_interface != f_single_out)
+ Delete(f_interface);
+ f_interface = 0;
+ }
+
emitDirectorExtraMethods(n);
+ Delete(interface_class_code);
+ interface_class_code = old_interface_class_code;
Delete(csclazzname);
Delete(proxy_class_name);
proxy_class_name = old_proxy_class_name;
@@ -2145,6 +2352,8 @@ public:
String *pre_code = NewString("");
String *post_code = NewString("");
String *terminator_code = NewString("");
+ bool is_interface = Getattr(parentNode(n), "feature:interface") != 0
+ && !static_flag && Getattr(n, "interface:owner") == 0;
if (!proxy_flag)
return;
@@ -2217,8 +2426,21 @@ public:
Printf(function_code, " %s ", methodmods);
if (!is_smart_pointer()) {
// Smart pointer classes do not mirror the inheritance hierarchy of the underlying pointer type, so no virtual/override/new required.
- if (Getattr(n, "override"))
- Printf(function_code, "override ");
+ if (Node *base_ovr = Getattr(n, "override")) {
+ if (GetFlag(n, "isextendmember"))
+ Printf(function_code, "override ");
+ else {
+ Node* base = parentNode(base_ovr);
+ bool ovr = false;
+ for (Node* direct_base = Getattr(parentNode(n), "direct_base"); direct_base; direct_base = Getattr(direct_base, "direct_base")) {
+ if (direct_base == base) { // "override" only applies if the base was not discarded (e.g. in case of multiple inheritance or via "ignore")
+ ovr = true;
+ break;
+ }
+ }
+ Printf(function_code, ovr ? "override " : "virtual ");
+ }
+ }
else if (checkAttribute(n, "storage", "virtual"))
Printf(function_code, "virtual ");
if (Getattr(n, "hides"))
@@ -2228,6 +2450,9 @@ public:
if (static_flag)
Printf(function_code, "static ");
Printf(function_code, "%s %s(", return_type, proxy_function_name);
+ if (is_interface)
+ Printf(interface_class_code, " %s %s(", return_type, proxy_function_name);
+
Printv(imcall, full_imclass_name, ".$imfuncname(", NIL);
if (!static_flag)
@@ -2307,10 +2532,15 @@ public:
}
/* Add parameter to proxy function */
- if (gencomma >= 2)
+ if (gencomma >= 2) {
Printf(function_code, ", ");
+ if (is_interface)
+ Printf(interface_class_code, ", ");
+ }
gencomma = 2;
Printf(function_code, "%s %s", param_type, arg);
+ if (is_interface)
+ Printf(interface_class_code, "%s %s", param_type, arg);
Delete(arg);
Delete(param_type);
@@ -2320,6 +2550,8 @@ public:
Printf(imcall, ")");
Printf(function_code, ")");
+ if (is_interface)
+ Printf(interface_class_code, ");\n");
// Transform return type used in PInvoke function (in intermediary class) to type used in C# wrapper function (in proxy class)
if ((tm = Swig_typemap_lookup("csout", n, "", 0))) {
@@ -3188,6 +3420,50 @@ public:
substitution_performed = true;
Delete(classnametype);
}
+ if (Strstr(tm, "$csinterfacename")) {
+ SwigType *interfacenametype = Copy(strippedtype);
+ substituteInterfacenameSpecialVariable(interfacenametype, tm, "$csinterfacename", true);
+ substitution_performed = true;
+ Delete(interfacenametype);
+ }
+ if (Strstr(tm, "$*csinterfacename")) {
+ SwigType *interfacenametype = Copy(strippedtype);
+ Delete(SwigType_pop(interfacenametype));
+ if (Len(interfacenametype) > 0) {
+ substituteInterfacenameSpecialVariable(interfacenametype, tm, "$*csinterfacename", true);
+ substitution_performed = true;
+ }
+ Delete(interfacenametype);
+ }
+ if (Strstr(tm, "$&csinterfacename")) {
+ SwigType *interfacenametype = Copy(strippedtype);
+ SwigType_add_pointer(interfacenametype);
+ substituteInterfacenameSpecialVariable(interfacenametype, tm, "$&csinterfacename", true);
+ substitution_performed = true;
+ Delete(interfacenametype);
+ }
+ if (Strstr(tm, "$interfacename")) {
+ SwigType *interfacenametype = Copy(strippedtype);
+ substituteInterfacenameSpecialVariable(interfacenametype, tm, "$interfacename", false);
+ substitution_performed = true;
+ Delete(interfacenametype);
+ }
+ if (Strstr(tm, "$*interfacename")) {
+ SwigType *interfacenametype = Copy(strippedtype);
+ Delete(SwigType_pop(interfacenametype));
+ if (Len(interfacenametype) > 0) {
+ substituteInterfacenameSpecialVariable(interfacenametype, tm, "$*interfacename", false);
+ substitution_performed = true;
+ }
+ Delete(interfacenametype);
+ }
+ if (Strstr(tm, "$&interfacename")) {
+ SwigType *interfacenametype = Copy(strippedtype);
+ SwigType_add_pointer(interfacenametype);
+ substituteInterfacenameSpecialVariable(interfacenametype, tm, "$&interfacename", false);
+ substitution_performed = true;
+ Delete(interfacenametype);
+ }
Delete(strippedtype);
Delete(type);
@@ -3234,6 +3510,20 @@ public:
}
/* -----------------------------------------------------------------------------
+ * substituteInterfacenameSpecialVariable()
+ * ----------------------------------------------------------------------------- */
+
+ void substituteInterfacenameSpecialVariable(SwigType *interfacenametype, String *tm, const char *interfacenamespecialvariable, bool qualified) {
+
+ String *interfacename = getInterfaceName(interfacenametype, qualified);
+ if (interfacename) {
+ String *replacementname = Copy(interfacename);
+ Replaceall(tm, interfacenamespecialvariable, replacementname);
+ Delete(replacementname);
+ }
+ }
+
+ /* -----------------------------------------------------------------------------
* emitTypeWrapperClass()
* ----------------------------------------------------------------------------- */
diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx
index 5fc21ad18..ec66ebed2 100644
--- a/Source/Modules/d.cxx
+++ b/Source/Modules/d.cxx
@@ -910,7 +910,7 @@ public:
const char *val = Equal(Getattr(n, "enumvalue"), "true") ? "1" : "0";
Setattr(n, "enumvalue", val);
} else if (swigtype == T_CHAR) {
- String *val = NewStringf("'%s'", Getattr(n, "enumvalue"));
+ String *val = NewStringf("'%(escape)s'", Getattr(n, "enumvalue"));
Setattr(n, "enumvalue", val);
Delete(val);
}
@@ -1423,6 +1423,7 @@ public:
String *constants_code = NewString("");
SwigType *t = Getattr(n, "type");
+ SwigType *valuetype = Getattr(n, "valuetype");
ParmList *l = Getattr(n, "parms");
// Attach the non-standard typemaps to the parameter list.
@@ -1470,16 +1471,21 @@ public:
Printf(constants_code, "%s;\n", override_value);
} else {
// Just take the value from the C definition and hope it compiles in D.
- String* value = Getattr(n, "wrappedasconstant") ?
- Getattr(n, "staticmembervariableHandler:value") : Getattr(n, "value");
-
- // Add the stripped quotes back in.
- if (SwigType_type(t) == T_STRING) {
- Printf(constants_code, "\"%s\";\n", value);
- } else if (SwigType_type(t) == T_CHAR) {
- Printf(constants_code, "\'%s\';\n", value);
+ if (Getattr(n, "wrappedasconstant")) {
+ if (SwigType_type(valuetype) == T_CHAR)
+ Printf(constants_code, "\'%(escape)s\';\n", Getattr(n, "staticmembervariableHandler:value"));
+ else
+ Printf(constants_code, "%s;\n", Getattr(n, "staticmembervariableHandler:value"));
} else {
- Printf(constants_code, "%s;\n", value);
+ // Add the stripped quotes back in.
+ String* value = Getattr(n, "value");
+ if (SwigType_type(t) == T_STRING) {
+ Printf(constants_code, "\"%s\";\n", value);
+ } else if (SwigType_type(t) == T_CHAR) {
+ Printf(constants_code, "\'%s\';\n", value);
+ } else {
+ Printf(constants_code, "%s;\n", value);
+ }
}
}
@@ -3123,28 +3129,23 @@ private:
List *baselist = Getattr(n, "bases");
if (baselist) {
Iterator base = First(baselist);
- while (base.item && GetFlag(base.item, "feature:ignore")) {
- base = Next(base);
- }
- if (base.item) {
- basenode = base.item;
- c_baseclassname = Getattr(base.item, "name");
- basename = createProxyName(c_baseclassname);
- if (basename)
- c_baseclass = SwigType_namestr(Getattr(base.item, "name"));
- base = Next(base);
- /* Warn about multiple inheritance for additional base class(es) */
- while (base.item) {
- if (GetFlag(base.item, "feature:ignore")) {
- base = Next(base);
- continue;
+ while (base.item) {
+ if (!GetFlag(base.item, "feature:ignore")) {
+ String *baseclassname = Getattr(base.item, "name");
+ if (!c_baseclassname) {
+ basenode = base.item;
+ c_baseclassname = baseclassname;
+ basename = createProxyName(c_baseclassname);
+ if (basename)
+ c_baseclass = SwigType_namestr(baseclassname);
+ } else {
+ /* Warn about multiple inheritance for additional base class(es) */
+ String *proxyclassname = Getattr(n, "classtypeobj");
+ Swig_warning(WARN_D_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
+ "Base %s of class %s ignored: multiple inheritance is not supported in D.\n", SwigType_namestr(baseclassname), SwigType_namestr(proxyclassname));
}
- String *proxyclassname = SwigType_str(Getattr(n, "classtypeobj"), 0);
- String *baseclassname = SwigType_str(Getattr(base.item, "name"), 0);
- Swig_warning(WARN_D_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
- "Base %s of class %s ignored: multiple inheritance is not supported in D.\n", baseclassname, proxyclassname);
- base = Next(base);
}
+ base = Next(base);
}
}
}
@@ -3169,7 +3170,7 @@ private:
}
} else if (basename && Len(pure_baseclass) > 0) {
Swig_warning(WARN_D_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
- "Warning for %s proxy: Base class %s ignored. Multiple inheritance is not supported in D. "
+ "Warning for %s, base class %s ignored. Multiple inheritance is not supported in D. "
"Perhaps you need one of the 'replace' or 'notderived' attributes in the dbase typemap?\n", typemap_lookup_type, pure_baseclass);
}
diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx
index 002247fe5..7fa9b2670 100644
--- a/Source/Modules/go.cxx
+++ b/Source/Modules/go.cxx
@@ -1362,6 +1362,10 @@ private:
goargout(info->parms);
if (SwigType_type(info->result) != T_VOID) {
+
+ Swig_save("cgoGoWrapper", info->n, "type", "tmap:goout", NULL);
+ Setattr(info->n, "type", info->result);
+
String *goout = goTypemapLookup("goout", info->n, "swig_r");
if (goout == NULL) {
Printv(f_go_wrappers, "\treturn swig_r\n", NULL);
@@ -1374,6 +1378,8 @@ private:
Printv(f_go_wrappers, goout, "\n", NULL);
Printv(f_go_wrappers, "\treturn swig_r_1\n", NULL);
}
+
+ Swig_restore(info->n);
}
Printv(f_go_wrappers, "}\n\n", NULL);
@@ -1618,8 +1624,13 @@ private:
receiver = NULL;
}
+ Swig_save("cgoGoWrapper", n, "type", "tmap:goout", NULL);
+ Setattr(n, "type", result);
+
String *goout = goTypemapLookup("goout", n, "swig_r");
+ Swig_restore(n);
+
bool add_to_interface = (interfaces && !is_constructor && !is_destructor && !is_static && !overname && checkFunctionVisibility(n, NULL));
bool needs_wrapper = (gccgo_flag || receiver || is_constructor || is_destructor || parm_count > required_count);
@@ -2712,6 +2723,9 @@ private:
* ---------------------------------------------------------------------- */
virtual int enumDeclaration(Node *n) {
+ if (getCurrentClass() && (cplus_mode != PUBLIC))
+ return SWIG_NOWRAP;
+
String *name = goEnumName(n);
if (Strcmp(name, "int") != 0) {
if (!ImportMode || !imported_package) {
@@ -2792,6 +2806,7 @@ private:
} else if (SwigType_type(type) == T_CHAR) {
quote = '\'';
} else if (SwigType_type(type) == T_STRING) {
+ Printv(get, "(char *)", NULL);
quote = '"';
} else {
quote = '\0';
@@ -4161,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);
@@ -4218,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/interface.cxx b/Source/Modules/interface.cxx
new file mode 100644
index 000000000..f6d4c955b
--- /dev/null
+++ b/Source/Modules/interface.cxx
@@ -0,0 +1,183 @@
+/* -----------------------------------------------------------------------------
+ * This file is part of SWIG, which is licensed as a whole under version 3
+ * (or any later version) of the GNU General Public License. Some additional
+ * terms also apply to certain portions of SWIG. The full details of the SWIG
+ * license and copyrights can be found in the LICENSE and COPYRIGHT files
+ * included with the SWIG source code as distributed by the SWIG developers
+ * and at http://www.swig.org/legal.html.
+ *
+ * interface.cxx
+ *
+ * This module contains support for the interface feature.
+ * This feature is used in language modules where the target language does not
+ * naturally support C++ style multiple inheritance, but does support inheritance
+ * from multiple interfaces.
+ * ----------------------------------------------------------------------------- */
+
+#include "swigmod.h"
+
+static bool interface_feature_enabled = false;
+
+/* -----------------------------------------------------------------------------
+ * collect_interface_methods()
+ *
+ * Create a list of all the methods from the base classes of class n that are
+ * marked as an interface. The resulting list is thus the list of methods that
+ * need to be implemented in order for n to be non-abstract.
+ * ----------------------------------------------------------------------------- */
+
+static List *collect_interface_methods(Node *n) {
+ List *methods = NewList();
+ if (Hash *bases = Getattr(n, "interface:bases")) {
+ List *keys = Keys(bases);
+ for (Iterator base = First(keys); base.item; base = Next(base)) {
+ Node *cls = Getattr(bases, base.item);
+ if (cls == n)
+ continue;
+ for (Node *child = firstChild(cls); child; child = nextSibling(child)) {
+ if (Cmp(nodeType(child), "cdecl") == 0) {
+ if (GetFlag(child, "feature:ignore") || Getattr(child, "interface:owner"))
+ continue; // skip methods propagated to bases
+ Node *m = Copy(child);
+ set_nextSibling(m, NIL);
+ set_previousSibling(m, NIL);
+ Setattr(m, "interface:owner", cls);
+ Append(methods, m);
+ }
+ }
+ }
+ Delete(keys);
+ }
+ return methods;
+}
+
+/* -----------------------------------------------------------------------------
+ * collect_interface_bases
+ * ----------------------------------------------------------------------------- */
+
+static void collect_interface_bases(Hash *bases, Node *n) {
+ if (Getattr(n, "feature:interface")) {
+ String *name = Getattr(n, "interface:name");
+ if (!Getattr(bases, name))
+ Setattr(bases, name, n);
+ }
+
+ if (List *baselist = Getattr(n, "bases")) {
+ for (Iterator base = First(baselist); base.item; base = Next(base)) {
+ if (!GetFlag(base.item, "feature:ignore")) {
+ if (Getattr(base.item, "feature:interface"))
+ collect_interface_bases(bases, base.item);
+ }
+ }
+ }
+}
+
+/* -----------------------------------------------------------------------------
+ * collect_interface_base_classes()
+ *
+ * Create a hash containing all the classes up the inheritance hierarchy
+ * marked with feature:interface (including this class n).
+ * Stops going up the inheritance chain as soon as a class is found without
+ * feature:interface.
+ * The idea is to find all the base interfaces that a class must implement.
+ * ----------------------------------------------------------------------------- */
+
+static void collect_interface_base_classes(Node *n) {
+ if (Getattr(n, "feature:interface")) {
+ // check all bases are also interfaces
+ if (List *baselist = Getattr(n, "bases")) {
+ for (Iterator base = First(baselist); base.item; base = Next(base)) {
+ if (!GetFlag(base.item, "feature:ignore")) {
+ if (!Getattr(base.item, "feature:interface")) {
+ Swig_error(Getfile(n), Getline(n), "Base class '%s' of '%s' is not similarly marked as an interface.\n", SwigType_namestr(Getattr(base.item, "name")), SwigType_namestr(Getattr(n, "name")));
+ SWIG_exit(EXIT_FAILURE);
+ }
+ }
+ }
+ }
+ }
+
+ Hash *interface_bases = NewHash();
+ collect_interface_bases(interface_bases, n);
+ if (Len(interface_bases) == 0)
+ Delete(interface_bases);
+ else
+ Setattr(n, "interface:bases", interface_bases);
+}
+
+/* -----------------------------------------------------------------------------
+ * process_interface_name()
+ * ----------------------------------------------------------------------------- */
+
+static void process_interface_name(Node *n) {
+ if (Getattr(n, "feature:interface")) {
+ String *interface_name = Getattr(n, "feature:interface:name");
+ if (!Len(interface_name)) {
+ Swig_error(Getfile(n), Getline(n), "The interface feature for '%s' is missing the name attribute.\n", SwigType_namestr(Getattr(n, "name")));
+ SWIG_exit(EXIT_FAILURE);
+ }
+ if (Strchr(interface_name, '%')) {
+ String *name = NewStringf(interface_name, Getattr(n, "sym:name"));
+ Setattr(n, "interface:name", name);
+ } else {
+ Setattr(n, "interface:name", interface_name);
+ }
+ }
+}
+
+/* -----------------------------------------------------------------------------
+ * Swig_interface_propagate_methods()
+ *
+ * Find all the base classes marked as an interface (with feature:interface) for
+ * class node n. For each of these, add all of its methods as methods of n so that
+ * n is not abstract. If class n is also marked as an interface, it will remain
+ * abstract and not have any methods added.
+ * ----------------------------------------------------------------------------- */
+
+void Swig_interface_propagate_methods(Node *n) {
+ if (interface_feature_enabled) {
+ process_interface_name(n);
+ collect_interface_base_classes(n);
+ List *methods = collect_interface_methods(n);
+ bool is_interface = Getattr(n, "feature:interface") != 0;
+ for (Iterator mi = First(methods); mi.item; mi = Next(mi)) {
+ if (!is_interface && GetFlag(mi.item, "abstract"))
+ continue;
+ String *this_decl = Getattr(mi.item, "decl");
+ String *this_decl_resolved = SwigType_typedef_resolve_all(this_decl);
+ bool identically_overloaded_method = false; // true when a base class' method is implemented in n
+ if (SwigType_isfunction(this_decl_resolved)) {
+ String *name = Getattr(mi.item, "name");
+ for (Node *child = firstChild(n); child; child = nextSibling(child)) {
+ if (Getattr(child, "interface:owner"))
+ break; // at the end of the list are newly appended methods
+ if (checkAttribute(child, "name", name)) {
+ String *decl = SwigType_typedef_resolve_all(Getattr(child, "decl"));
+ identically_overloaded_method = Strcmp(decl, this_decl_resolved) == 0;
+ Delete(decl);
+ if (identically_overloaded_method)
+ break;
+ }
+ }
+ }
+ Delete(this_decl_resolved);
+ if (!identically_overloaded_method) {
+ // TODO: Fix if the method is overloaded with different arguments / has default args
+ appendChild(n, mi.item);
+ } else {
+ Delete(mi.item);
+ }
+ }
+ Delete(methods);
+ }
+}
+
+/* -----------------------------------------------------------------------------
+ * Swig_interface_feature_enable()
+ *
+ * Turn on interface feature support
+ * ----------------------------------------------------------------------------- */
+
+void Swig_interface_feature_enable() {
+ interface_feature_enabled = true;
+}
diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx
index afe8ca841..eb809ff59 100644
--- a/Source/Modules/java.cxx
+++ b/Source/Modules/java.cxx
@@ -53,6 +53,7 @@ class JAVA:public Language {
String *imclass_class_code; // intermediary class code
String *proxy_class_def;
String *proxy_class_code;
+ String *interface_class_code; // if %feature("interface") was declared for a class, here goes the interface declaration
String *module_class_code;
String *proxy_class_name; // proxy class name
String *full_proxy_class_name;// fully qualified proxy class name when using nspace feature, otherwise same as proxy_class_name
@@ -125,6 +126,7 @@ public:
imclass_class_code(NULL),
proxy_class_def(NULL),
proxy_class_code(NULL),
+ interface_class_code(NULL),
module_class_code(NULL),
proxy_class_name(NULL),
full_proxy_class_name(NULL),
@@ -208,10 +210,14 @@ public:
String *nspace = Getattr(n, "sym:nspace");
String *symname = Copy(Getattr(n, "sym:name"));
if (symname && !GetFlag(n, "feature:flatnested")) {
- for (Node *outer_class = Getattr(n, "nested:outer"); outer_class; outer_class = Getattr(outer_class, "nested:outer")) {
- Push(symname, jnidescriptor ? "$" : ".");
- Push(symname, Getattr(outer_class, "sym:name"));
- }
+ for (Node *outer_class = Getattr(n, "nested:outer"); outer_class; outer_class = Getattr(outer_class, "nested:outer")) {
+ if (String* name = Getattr(outer_class, "sym:name")) {
+ Push(symname, jnidescriptor ? "$" : ".");
+ Push(symname, name);
+ }
+ else
+ return NULL;
+ }
}
if (nspace) {
if (package && !jnidescriptor)
@@ -303,6 +309,7 @@ public:
SWIG_config_file("java.swg");
allow_overloading();
+ Swig_interface_feature_enable();
}
/* ---------------------------------------------------------------------
@@ -1288,8 +1295,10 @@ public:
// Add extra indentation
Replaceall(enum_code, "\n", "\n ");
Replaceall(enum_code, " \n", "\n");
-
- Printv(proxy_class_constants_code, " ", enum_code, "\n\n", NIL);
+ if (GetFlag(getCurrentClass(), "feature:interface"))
+ Printv(interface_class_code, " ", enum_code, "\n\n", NIL);
+ else
+ Printv(proxy_class_constants_code, " ", enum_code, "\n\n", NIL);
} else {
// Global enums are defined in their own file
String *output_directory = outputDirectory(nspace);
@@ -1375,7 +1384,7 @@ public:
const char *val = Equal(Getattr(n, "enumvalue"), "true") ? "1" : "0";
Setattr(n, "enumvalue", val);
} else if (swigtype == T_CHAR) {
- String *val = NewStringf("'%s'", Getattr(n, "enumvalue"));
+ String *val = NewStringf("'%(escape)s'", Getattr(n, "enumvalue"));
Setattr(n, "enumvalue", val);
Delete(val);
}
@@ -1481,6 +1490,7 @@ public:
virtual int constantWrapper(Node *n) {
String *symname = Getattr(n, "sym:name");
SwigType *t = Getattr(n, "type");
+ SwigType *valuetype = Getattr(n, "valuetype");
ParmList *l = Getattr(n, "parms");
String *tm;
String *return_type = NewString("");
@@ -1572,8 +1582,8 @@ public:
} else {
// Alternative constant handling will use the C syntax to make a true Java constant and hope that it compiles as Java code
if (Getattr(n, "wrappedasconstant")) {
- if (SwigType_type(t) == T_CHAR)
- Printf(constants_code, "\'%s\';\n", Getattr(n, "staticmembervariableHandler:value"));
+ if (SwigType_type(valuetype) == T_CHAR)
+ Printf(constants_code, "\'%(escape)s\';\n", Getattr(n, "staticmembervariableHandler:value"));
else
Printf(constants_code, "%s;\n", Getattr(n, "staticmembervariableHandler:value"));
} else {
@@ -1724,6 +1734,125 @@ public:
}
/* -----------------------------------------------------------------------------
+ * getQualifiedInterfaceName()
+ * ----------------------------------------------------------------------------- */
+
+ String *getQualifiedInterfaceName(Node *n) {
+ String *ret = Getattr(n, "interface:qname");
+ if (!ret) {
+ String *nspace = Getattr(n, "sym:nspace");
+ String *symname = Getattr(n, "interface:name");
+ if (nspace) {
+ if (package)
+ ret = NewStringf("%s.%s.%s", package, nspace, symname);
+ else
+ ret = NewStringf("%s.%s", nspace, symname);
+ } else {
+ ret = Copy(symname);
+ }
+ Setattr(n, "interface:qname", ret);
+ }
+ return ret;
+ }
+
+ /* -----------------------------------------------------------------------------
+ * getInterfaceName()
+ * ----------------------------------------------------------------------------- */
+
+ String *getInterfaceName(SwigType *t, bool qualified) {
+ String *interface_name = NULL;
+ if (proxy_flag) {
+ Node *n = classLookup(t);
+ if (n && Getattr(n, "interface:name"))
+ interface_name = qualified ? getQualifiedInterfaceName(n) : Getattr(n, "interface:name");
+ }
+ return interface_name;
+ }
+
+ /* -----------------------------------------------------------------------------
+ * addInterfaceNameAndUpcasts()
+ * ----------------------------------------------------------------------------- */
+
+ void addInterfaceNameAndUpcasts(SwigType *smart, String *interface_list, String *interface_upcasts, Hash *base_list, String *c_classname) {
+ List *keys = Keys(base_list);
+ for (Iterator it = First(keys); it.item; it = Next(it)) {
+ Node *base = Getattr(base_list, it.item);
+ String *c_baseclass = SwigType_namestr(Getattr(base, "name"));
+ String *interface_name = Getattr(base, "interface:name");
+ if (Len(interface_list))
+ Append(interface_list, ", ");
+ Append(interface_list, interface_name);
+
+ Node *attributes = NewHash();
+ String *interface_code = Copy(typemapLookup(base, "javainterfacecode", Getattr(base, "classtypeobj"), WARN_JAVA_TYPEMAP_INTERFACECODE_UNDEF, attributes));
+ String *cptr_method_name = 0;
+ if (interface_code) {
+ Replaceall(interface_code, "$interfacename", interface_name);
+ Printv(interface_upcasts, interface_code, NIL);
+ cptr_method_name = Copy(Getattr(attributes, "tmap:javainterfacecode:cptrmethod"));
+ }
+ if (!cptr_method_name)
+ cptr_method_name = NewStringf("%s_GetInterfaceCPtr", interface_name);
+ Replaceall(cptr_method_name, ".", "_");
+ Replaceall(cptr_method_name, "$interfacename", interface_name);
+
+ String *upcast_method_name = Swig_name_member(getNSpace(), proxy_class_name, cptr_method_name);
+ upcastsCode(smart, upcast_method_name, c_classname, c_baseclass);
+ Delete(upcast_method_name);
+ Delete(cptr_method_name);
+ Delete(interface_code);
+ Delete(c_baseclass);
+ }
+ Delete(keys);
+ }
+
+ /* -----------------------------------------------------------------------------
+ * upcastsCode()
+ *
+ * Add code for C++ casting to base class
+ * ----------------------------------------------------------------------------- */
+
+ void upcastsCode(SwigType *smart, String *upcast_method_name, String *c_classname, String *c_baseclass) {
+ String *jniname = makeValidJniName(upcast_method_name);
+ String *wname = Swig_name_wrapper(jniname);
+ Printf(imclass_cppcasts_code, " public final static native long %s(long jarg1);\n", upcast_method_name);
+ if (smart) {
+ SwigType *bsmart = Copy(smart);
+ SwigType *rclassname = SwigType_typedef_resolve_all(c_classname);
+ SwigType *rbaseclass = SwigType_typedef_resolve_all(c_baseclass);
+ Replaceall(bsmart, rclassname, rbaseclass);
+ Delete(rclassname);
+ Delete(rbaseclass);
+ String *smartnamestr = SwigType_namestr(smart);
+ String *bsmartnamestr = SwigType_namestr(bsmart);
+ Printv(upcasts_code,
+ "SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n",
+ " jlong baseptr = 0;\n"
+ " ", smartnamestr, " *argp1;\n"
+ " (void)jenv;\n"
+ " (void)jcls;\n"
+ " argp1 = *(", smartnamestr, " **)&jarg1;\n"
+ " *(", bsmartnamestr, " **)&baseptr = argp1 ? new ", bsmartnamestr, "(*argp1) : 0;\n"
+ " return baseptr;\n"
+ "}\n", "\n", NIL);
+ Delete(bsmartnamestr);
+ Delete(smartnamestr);
+ Delete(bsmart);
+ } else {
+ Printv(upcasts_code,
+ "SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n",
+ " jlong baseptr = 0;\n"
+ " (void)jenv;\n"
+ " (void)jcls;\n"
+ " *(", c_baseclass, " **)&baseptr = *(", c_classname, " **)&jarg1;\n"
+ " return baseptr;\n"
+ "}\n", "\n", NIL);
+ }
+ Delete(wname);
+ Delete(jniname);
+ }
+
+ /* -----------------------------------------------------------------------------
* emitProxyClassDefAndCPPCasts()
* ----------------------------------------------------------------------------- */
@@ -1732,9 +1861,12 @@ public:
String *c_baseclass = NULL;
String *baseclass = NULL;
String *c_baseclassname = NULL;
+ String *interface_list = NewStringEmpty();
+ String *interface_upcasts = NewStringEmpty();
SwigType *typemap_lookup_type = Getattr(n, "classtypeobj");
bool feature_director = Swig_directorclass(n) ? true : false;
bool has_outerclass = Getattr(n, "nested:outer") != 0 && !GetFlag(n, "feature:flatnested");
+ SwigType *smart = Swig_cparse_smartptr(n);
// Inheritance from pure Java classes
Node *attributes = NewHash();
@@ -1747,32 +1879,31 @@ public:
if (!purebase_replace) {
List *baselist = Getattr(n, "bases");
if (baselist) {
- Iterator base = First(baselist);
- while (base.item && GetFlag(base.item, "feature:ignore")) {
- base = Next(base);
- }
- if (base.item) {
- c_baseclassname = Getattr(base.item, "name");
- baseclass = Copy(getProxyName(c_baseclassname));
- if (baseclass)
- c_baseclass = SwigType_namestr(Getattr(base.item, "name"));
- base = Next(base);
- /* Warn about multiple inheritance for additional base class(es) */
- while (base.item) {
- if (GetFlag(base.item, "feature:ignore")) {
- base = Next(base);
- continue;
- }
- String *proxyclassname = Getattr(n, "classtypeobj");
- String *baseclassname = Getattr(base.item, "name");
- Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
- "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java.\n", SwigType_namestr(proxyclassname), SwigType_namestr(baseclassname));
- base = Next(base);
- }
- }
+ Iterator base = First(baselist);
+ while (base.item) {
+ if (!(GetFlag(base.item, "feature:ignore") || Getattr(base.item, "feature:interface"))) {
+ String *baseclassname = Getattr(base.item, "name");
+ if (!c_baseclassname) {
+ c_baseclassname = baseclassname;
+ baseclass = Copy(getProxyName(baseclassname));
+ if (baseclass)
+ c_baseclass = SwigType_namestr(baseclassname);
+ } else {
+ /* Warn about multiple inheritance for additional base class(es) */
+ String *proxyclassname = Getattr(n, "classtypeobj");
+ Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
+ "Warning for %s, base %s ignored. Multiple inheritance is not supported in Java.\n", SwigType_namestr(proxyclassname), SwigType_namestr(baseclassname));
+ }
+ }
+ base = Next(base);
+ }
}
}
+ Hash *interface_bases = Getattr(n, "interface:bases");
+ if (interface_bases)
+ addInterfaceNameAndUpcasts(smart, interface_list, interface_upcasts, interface_bases, c_classname);
+
bool derived = baseclass && getProxyName(c_baseclassname);
if (derived && purebase_notderived)
pure_baseclass = empty_string;
@@ -1787,13 +1918,15 @@ public:
Swig_error(Getfile(n), Getline(n), "The javabase typemap for proxy %s must contain just one of the 'replace' or 'notderived' attributes.\n", typemap_lookup_type);
} else if (Len(pure_baseclass) > 0 && Len(baseclass) > 0) {
Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
- "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java. "
+ "Warning for %s, base %s ignored. Multiple inheritance is not supported in Java. "
"Perhaps you need one of the 'replace' or 'notderived' attributes in the javabase typemap?\n", typemap_lookup_type, pure_baseclass);
}
// Pure Java interfaces
const String *pure_interfaces = typemapLookup(n, "javainterfaces", typemap_lookup_type, WARN_NONE);
-
+ if (*Char(interface_list) && *Char(pure_interfaces))
+ Append(interface_list, ", ");
+ Append(interface_list, pure_interfaces);
// Start writing the proxy class
if (!has_outerclass) // Import statements
Printv(proxy_class_def, typemapLookup(n, "javaimports", typemap_lookup_type, WARN_NONE),"\n", NIL);
@@ -1801,8 +1934,8 @@ public:
Printv(proxy_class_def, "static ", NIL); // C++ nested classes correspond to static java classes
Printv(proxy_class_def, typemapLookup(n, "javaclassmodifiers", typemap_lookup_type, WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
" $javaclassname", // Class name and bases
- (*Char(wanted_base)) ? " extends " : "", wanted_base, *Char(pure_interfaces) ? // Pure Java interfaces
- " implements " : "", pure_interfaces, " {", derived ? typemapLookup(n, "javabody_derived", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF) : // main body of class
+ (*Char(wanted_base)) ? " extends " : "", wanted_base, *Char(interface_list) ? // Pure Java interfaces
+ " implements " : "", interface_list, " {", derived ? typemapLookup(n, "javabody_derived", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF) : // main body of class
typemapLookup(n, "javabody", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF), // main body of class
NIL);
@@ -1845,6 +1978,8 @@ public:
if (*Char(destruct))
Printv(proxy_class_def, "\n ", destruct_methodmodifiers, " void ", destruct_methodname, "()", destructor_throws_clause, " ", destruct, "\n", NIL);
}
+ if (*Char(interface_upcasts))
+ Printv(proxy_class_def, interface_upcasts, NIL);
/* Insert directordisconnect typemap, if this class has directors enabled */
/* Also insert the swigTakeOwnership and swigReleaseOwnership methods */
@@ -1866,6 +2001,8 @@ public:
Delete(take_jnicall);
}
+ Delete(interface_upcasts);
+ Delete(interface_list);
Delete(attributes);
Delete(destruct);
@@ -1873,60 +2010,80 @@ public:
Printv(proxy_class_def, typemapLookup(n, "javacode", typemap_lookup_type, WARN_NONE), // extra Java code
"\n", NIL);
- // Add code to do C++ casting to base class (only for classes in an inheritance hierarchy)
if (derived) {
- SwigType *smart = Swig_cparse_smartptr(n);
- String *upcast_method = Swig_name_member(getNSpace(), getClassPrefix(), smart != 0 ? "SWIGSmartPtrUpcast" : "SWIGUpcast");
- String *jniname = makeValidJniName(upcast_method);
- String *wname = Swig_name_wrapper(jniname);
- Printf(imclass_cppcasts_code, " public final static native long %s(long jarg1);\n", upcast_method);
- if (smart) {
- SwigType *bsmart = Copy(smart);
- SwigType *rclassname = SwigType_typedef_resolve_all(c_classname);
- SwigType *rbaseclass = SwigType_typedef_resolve_all(c_baseclass);
- Replaceall(bsmart, rclassname, rbaseclass);
- Delete(rclassname);
- Delete(rbaseclass);
- String *smartnamestr = SwigType_namestr(smart);
- String *bsmartnamestr = SwigType_namestr(bsmart);
- Printv(upcasts_code,
- "SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n",
- " jlong baseptr = 0;\n"
- " ", smartnamestr, " *argp1;\n"
- " (void)jenv;\n"
- " (void)jcls;\n"
- " argp1 = *(", smartnamestr, " **)&jarg1;\n"
- " *(", bsmartnamestr, " **)&baseptr = argp1 ? new ", bsmartnamestr, "(*argp1) : 0;\n"
- " return baseptr;\n"
- "}\n", "\n", NIL);
- Delete(bsmartnamestr);
- Delete(smartnamestr);
- Delete(bsmart);
- } else {
- Printv(upcasts_code,
- "SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n",
- " jlong baseptr = 0;\n"
- " (void)jenv;\n"
- " (void)jcls;\n"
- " *(", c_baseclass, " **)&baseptr = *(", c_classname, " **)&jarg1;\n"
- " return baseptr;\n"
- "}\n", "\n", NIL);
- }
- Delete(wname);
- Delete(jniname);
- Delete(upcast_method);
- Delete(smart);
+ String *upcast_method_name = Swig_name_member(getNSpace(), getClassPrefix(), smart != 0 ? "SWIGSmartPtrUpcast" : "SWIGUpcast");
+ upcastsCode(smart, upcast_method_name, c_classname, c_baseclass);
+ Delete(upcast_method_name);
}
+
+ Delete(smart);
Delete(baseclass);
}
/* ----------------------------------------------------------------------
- * classHandler()
+ * emitInterfaceDeclaration()
* ---------------------------------------------------------------------- */
- virtual int classHandler(Node *n) {
+ void emitInterfaceDeclaration(Node *n, String *interface_name, File *f_interface, String *nspace) {
+ if (package || nspace) {
+ Printf(f_interface, "package ");
+ if (package)
+ Printv(f_interface, package, nspace ? "." : "", NIL);
+ if (nspace)
+ Printv(f_interface, nspace, NIL);
+ Printf(f_interface, ";\n");
+ }
+
+ Printv(f_interface, typemapLookup(n, "javaimports", Getattr(n, "classtypeobj"), WARN_NONE), "\n", NIL);
+ Printf(f_interface, "public interface %s", interface_name);
+ if (List *baselist = Getattr(n, "bases")) {
+ String *bases = 0;
+ for (Iterator base = First(baselist); base.item; base = Next(base)) {
+ if (GetFlag(base.item, "feature:ignore") || !Getattr(base.item, "feature:interface"))
+ continue; // TODO: warn about skipped non-interface bases
+ String *base_iname = Getattr(base.item, "interface:name");
+ if (!bases)
+ bases = Copy(base_iname);
+ else {
+ Append(bases, ", ");
+ Append(bases, base_iname);
+ }
+ }
+ if (bases) {
+ Printv(f_interface, " extends ", bases, NIL);
+ Delete(bases);
+ }
+ }
+ Printf(f_interface, " {\n");
+
+ Node *attributes = NewHash();
+ String *interface_code = Copy(typemapLookup(n, "javainterfacecode", Getattr(n, "classtypeobj"), WARN_JAVA_TYPEMAP_INTERFACECODE_UNDEF, attributes));
+ if (interface_code) {
+ String *interface_declaration = Copy(Getattr(attributes, "tmap:javainterfacecode:declaration"));
+ if (interface_declaration) {
+ Replaceall(interface_declaration, "$interfacename", interface_name);
+ Printv(f_interface, interface_declaration, NIL);
+ Delete(interface_declaration);
+ }
+ Delete(interface_code);
+ }
+ }
+ /* ----------------------------------------------------------------------
+ * classDeclaration()
+ * ---------------------------------------------------------------------- */
+
+ int classDeclaration(Node *n) {
+ return Language::classDeclaration(n);
+ }
+
+ /* ----------------------------------------------------------------------
+ * classHandler()
+ * ---------------------------------------------------------------------- */
+
+ virtual int classHandler(Node *n) {
File *f_proxy = NULL;
+ File *f_interface = NULL;
String *old_proxy_class_name = proxy_class_name;
String *old_full_proxy_class_name = full_proxy_class_name;
String *old_full_imclass_name = full_imclass_name;
@@ -1936,6 +2093,8 @@ public:
String *old_proxy_class_def = proxy_class_def;
String *old_proxy_class_code = proxy_class_code;
bool has_outerclass = Getattr(n, "nested:outer") && !GetFlag(n, "feature:flatnested");
+ String *old_interface_class_code = interface_class_code;
+ interface_class_code = 0;
if (proxy_flag) {
proxy_class_name = NewString(Getattr(n, "sym:name"));
@@ -1976,17 +2135,21 @@ public:
}
}
+ String *interface_name = Getattr(n, "feature:interface") ? Getattr(n, "interface:name") : 0;
if (outerClassesPrefix) {
String *fnspace = nspace ? NewStringf("%s.%s", nspace, outerClassesPrefix) : outerClassesPrefix;
if (!addSymbol(proxy_class_name, n, fnspace))
return SWIG_ERROR;
+ if (interface_name && !addInterfaceSymbol(interface_name, n, fnspace))
+ return SWIG_ERROR;
if (nspace)
Delete(fnspace);
Delete(outerClassesPrefix);
- }
- else {
+ } else {
if (!addSymbol(proxy_class_name, n, nspace))
return SWIG_ERROR;
+ if (interface_name && !addInterfaceSymbol(interface_name, n, nspace))
+ return SWIG_ERROR;
}
// Each outer proxy class goes into a separate file
@@ -2022,11 +2185,27 @@ public:
destructor_call = NewString("");
destructor_throws_clause = NewString("");
proxy_class_constants_code = NewString("");
+
+ if (Getattr(n, "feature:interface")) {
+ interface_class_code = NewString("");
+ String *output_directory = outputDirectory(nspace);
+ String *filen = NewStringf("%s%s.java", output_directory, interface_name);
+ f_interface = NewFile(filen, "w", SWIG_output_files());
+ if (!f_interface) {
+ FileErrorDisplay(filen);
+ SWIG_exit(EXIT_FAILURE);
+ }
+ Append(filenames_list, filen); // file name ownership goes to the list
+ emitBanner(f_interface);
+ emitInterfaceDeclaration(n, interface_name, interface_class_code, nspace);
+ Delete(filen);
+ Delete(output_directory);
+ }
}
+
Language::classHandler(n);
if (proxy_flag) {
-
emitProxyClassDefAndCPPCasts(n);
String *javaclazzname = Swig_name_member(getNSpace(), getClassPrefix(), ""); // mangled full proxy class name
@@ -2034,18 +2213,22 @@ public:
Replaceall(proxy_class_def, "$javaclassname", proxy_class_name);
Replaceall(proxy_class_code, "$javaclassname", proxy_class_name);
Replaceall(proxy_class_constants_code, "$javaclassname", proxy_class_name);
+ Replaceall(interface_class_code, "$javaclassname", proxy_class_name);
Replaceall(proxy_class_def, "$javaclazzname", javaclazzname);
Replaceall(proxy_class_code, "$javaclazzname", javaclazzname);
Replaceall(proxy_class_constants_code, "$javaclazzname", javaclazzname);
+ Replaceall(interface_class_code, "$javaclazzname", javaclazzname);
Replaceall(proxy_class_def, "$module", module_class_name);
Replaceall(proxy_class_code, "$module", module_class_name);
Replaceall(proxy_class_constants_code, "$module", module_class_name);
+ Replaceall(interface_class_code, "$module", module_class_name);
Replaceall(proxy_class_def, "$imclassname", full_imclass_name);
Replaceall(proxy_class_code, "$imclassname", full_imclass_name);
Replaceall(proxy_class_constants_code, "$imclassname", full_imclass_name);
+ Replaceall(interface_class_code, "$imclassname", full_imclass_name);
if (!has_outerclass)
Printv(f_proxy, proxy_class_def, proxy_class_code, NIL);
@@ -2110,8 +2293,16 @@ public:
Delete(downcast_method);
}
+ if (f_interface) {
+ Printv(f_interface, interface_class_code, "}\n", NIL);
+ Delete(f_interface);
+ f_interface = 0;
+ }
+
emitDirectorExtraMethods(n);
+ Delete(interface_class_code);
+ interface_class_code = old_interface_class_code;
Delete(javaclazzname);
Delete(proxy_class_name);
proxy_class_name = old_proxy_class_name;
@@ -2203,6 +2394,8 @@ public:
bool setter_flag = false;
String *pre_code = NewString("");
String *post_code = NewString("");
+ bool is_interface = Getattr(parentNode(n), "feature:interface") != 0
+ && !static_flag && Getattr(n, "interface:owner") == 0;
if (!proxy_flag)
return;
@@ -2252,6 +2445,9 @@ public:
if (static_flag)
Printf(function_code, "static ");
Printf(function_code, "%s %s(", return_type, proxy_function_name);
+
+ if (is_interface)
+ Printf(interface_class_code, " %s %s(", return_type, proxy_function_name);
Printv(imcall, full_imclass_name, ".$imfuncname(", NIL);
if (!static_flag) {
@@ -2339,10 +2535,15 @@ public:
}
/* Add parameter to proxy function */
- if (gencomma >= 2)
+ if (gencomma >= 2) {
Printf(function_code, ", ");
+ if (is_interface)
+ Printf(interface_class_code, ", ");
+ }
gencomma = 2;
Printf(function_code, "%s %s", param_type, arg);
+ if (is_interface)
+ Printf(interface_class_code, "%s %s", param_type, arg);
if (prematureGarbageCollectionPreventionParameter(pt, p)) {
String *pgcppname = Getattr(p, "tmap:javain:pgcppname");
@@ -2364,6 +2565,8 @@ public:
Printf(imcall, ")");
Printf(function_code, ")");
+ if (is_interface)
+ Printf(interface_class_code, ");\n");
// Transform return type used in JNI function (in intermediary class) to type used in Java wrapper function (in proxy class)
if ((tm = Swig_typemap_lookup("javaout", n, "", 0))) {
@@ -3068,6 +3271,50 @@ public:
substitution_performed = true;
Delete(classnametype);
}
+ if (Strstr(tm, "$javainterfacename")) {
+ SwigType *interfacenametype = Copy(strippedtype);
+ substituteInterfacenameSpecialVariable(interfacenametype, tm, "$javainterfacename", jnidescriptor, true);
+ substitution_performed = true;
+ Delete(interfacenametype);
+ }
+ if (Strstr(tm, "$*javainterfacename")) {
+ SwigType *interfacenametype = Copy(strippedtype);
+ Delete(SwigType_pop(interfacenametype));
+ if (Len(interfacenametype) > 0) {
+ substituteInterfacenameSpecialVariable(interfacenametype, tm, "$*javainterfacename", jnidescriptor, true);
+ substitution_performed = true;
+ }
+ Delete(interfacenametype);
+ }
+ if (Strstr(tm, "$&javainterfacename")) {
+ SwigType *interfacenametype = Copy(strippedtype);
+ SwigType_add_pointer(interfacenametype);
+ substituteInterfacenameSpecialVariable(interfacenametype, tm, "$&javainterfacename", jnidescriptor, true);
+ substitution_performed = true;
+ Delete(interfacenametype);
+ }
+ if (Strstr(tm, "$interfacename")) {
+ SwigType *interfacenametype = Copy(strippedtype);
+ substituteInterfacenameSpecialVariable(interfacenametype, tm, "$interfacename", jnidescriptor, false);
+ substitution_performed = true;
+ Delete(interfacenametype);
+ }
+ if (Strstr(tm, "$*interfacename")) {
+ SwigType *interfacenametype = Copy(strippedtype);
+ Delete(SwigType_pop(interfacenametype));
+ if (Len(interfacenametype) > 0) {
+ substituteInterfacenameSpecialVariable(interfacenametype, tm, "$*interfacename", jnidescriptor, false);
+ substitution_performed = true;
+ }
+ Delete(interfacenametype);
+ }
+ if (Strstr(tm, "$&interfacename")) {
+ SwigType *interfacenametype = Copy(strippedtype);
+ SwigType_add_pointer(interfacenametype);
+ substituteInterfacenameSpecialVariable(interfacenametype, tm, "$&interfacename", jnidescriptor, false);
+ substitution_performed = true;
+ Delete(interfacenametype);
+ }
Delete(strippedtype);
Delete(type);
@@ -3117,6 +3364,24 @@ public:
}
/* -----------------------------------------------------------------------------
+ * substituteInterfacenameSpecialVariable()
+ * ----------------------------------------------------------------------------- */
+
+ void substituteInterfacenameSpecialVariable(SwigType *interfacenametype, String *tm, const char *interfacenamespecialvariable, bool jnidescriptor, bool qualified) {
+
+ String *interfacename = getInterfaceName(interfacenametype/*, jnidescriptor*/, qualified);
+ if (interfacename) {
+ String *replacementname = Copy(interfacename);
+
+ if (jnidescriptor)
+ Replaceall(replacementname,".","/");
+ Replaceall(tm, interfacenamespecialvariable, replacementname);
+
+ Delete(replacementname);
+ }
+ }
+
+ /* -----------------------------------------------------------------------------
* emitTypeWrapperClass()
* ----------------------------------------------------------------------------- */
@@ -3273,7 +3538,7 @@ public:
* ----------------------------------------------------------------------------- */
String *prematureGarbageCollectionPreventionParameter(SwigType *t, Parm *p) {
- String *proxyClassName = 0;
+ String *pgcpp_java_type = 0;
String *jtype = NewString(Getattr(p, "tmap:jtype"));
// Strip C comments
@@ -3290,11 +3555,9 @@ public:
if (Cmp(jtype, "long") == 0) {
if (proxy_flag) {
if (!GetFlag(p, "tmap:jtype:nopgcpp") && !nopgcpp_flag) {
- String *proxyname = getProxyName(t);
- if (proxyname) {
- // Found a struct/class parameter passed by value, reference, pointer, or pointer reference
- proxyClassName = proxyname;
- } else {
+ String *interface_name = getInterfaceName(t, true);
+ pgcpp_java_type = interface_name ? interface_name : getProxyName(t);
+ if (!pgcpp_java_type) {
// Look for proxy class parameters passed to C++ layer using non-default typemaps, ie not one of above types
String *jstype = NewString(Getattr(p, "tmap:jstype"));
if (jstype) {
@@ -3316,7 +3579,7 @@ public:
if (cls && !Getattr(cls, "feature:ignore")) {
String *symname = Getattr(cls, "sym:name");
if (symname && Strcmp(symname, jstype) == 0) {
- proxyClassName = symname;
+ pgcpp_java_type = symname;
}
}
}
@@ -3328,7 +3591,7 @@ public:
}
}
Delete(jtype);
- return proxyClassName;
+ return pgcpp_java_type;
}
/* -----------------------------------------------------------------------------
diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx
index aa81581f0..9b1173443 100644
--- a/Source/Modules/lang.cxx
+++ b/Source/Modules/lang.cxx
@@ -1649,6 +1649,9 @@ int Language::externDeclaration(Node *n) {
* ---------------------------------------------------------------------- */
int Language::enumDeclaration(Node *n) {
+ if (CurrentClass && (cplus_mode != PUBLIC))
+ return SWIG_NOWRAP;
+
String *oldNSpace = NSpace;
NSpace = Getattr(n, "sym:nspace");
@@ -3119,6 +3122,31 @@ int Language::addSymbol(const String *s, const Node *n, const_String_or_char_ptr
}
/* -----------------------------------------------------------------------------
+ * Language::addInterfaceSymbol()
+ *
+ * Adds a symbol entry into the target language symbol tables - for the interface
+ * feature only.
+ * Returns 1 if the symbol is added successfully.
+ * The scope is as per addSymbol.
+ * ----------------------------------------------------------------------------- */
+
+int Language::addInterfaceSymbol(const String *interface_name, Node *n, const_String_or_char_ptr scope) {
+ if (interface_name) {
+ Node *existing_symbol = symbolLookup(interface_name, scope);
+ if (existing_symbol) {
+ String *proxy_class_name = Getattr(n, "sym:name");
+ Swig_error(input_file, line_number, "The interface feature name '%s' for proxy class '%s' is already defined in the generated target language module in scope '%s'.\n",
+ interface_name, proxy_class_name, scope);
+ Swig_error(Getfile(existing_symbol), Getline(existing_symbol), "Previous declaration of '%s'\n", interface_name);
+ return 0;
+ }
+ if (!addSymbol(interface_name, n, scope))
+ return 0;
+ }
+ return 1;
+}
+
+/* -----------------------------------------------------------------------------
* Language::symbolAddScope()
*
* Creates a scope (symbols Hash) for given name. This method is auxiliary,
@@ -3214,7 +3242,7 @@ void Language::dumpSymbols() {
* Language::symbolLookup()
* ----------------------------------------------------------------------------- */
-Node *Language::symbolLookup(String *s, const_String_or_char_ptr scope) {
+Node *Language::symbolLookup(const String *s, const_String_or_char_ptr scope) {
Hash *symbols = Getattr(symtabs, scope ? scope : "");
if (!symbols) {
return NULL;
@@ -3797,6 +3825,7 @@ String *Language::defaultExternalRuntimeFilename() {
/* -----------------------------------------------------------------------------
* Language::replaceSpecialVariables()
+ *
* Language modules should implement this if special variables are to be handled
* correctly in the $typemap(...) special variable macro.
* method - typemap method name
@@ -3816,3 +3845,4 @@ Language *Language::instance() {
Hash *Language::getClassHash() const {
return classhash;
}
+
diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx
index 12e8d10ba..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;
}
@@ -1157,6 +1160,9 @@ public:
* ------------------------------------------------------------ */
virtual int enumDeclaration(Node *n) {
+ if (getCurrentClass() && (cplus_mode != PUBLIC))
+ return SWIG_NOWRAP;
+
current[STATIC_CONST] = true;
current[ENUM_CONST] = true;
// There is some slightly specific behaviour with enums. Basically,
diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx
index 307c7857d..9983e69d2 100644
--- a/Source/Modules/modula3.cxx
+++ b/Source/Modules/modula3.cxx
@@ -2176,20 +2176,24 @@ MODULA3():
/* Deal with inheritance */
List *baselist = Getattr(n, "bases");
- if (baselist != NIL) {
+ if (baselist) {
Iterator base = First(baselist);
- if (base.item) {
- c_baseclassname = Getattr(base.item, "name");
- baseclass = Copy(getProxyName(c_baseclassname));
- if (baseclass) {
- c_baseclass = SwigType_namestr(Getattr(base.item, "name"));
+ while (base.item) {
+ if (!GetFlag(base.item, "feature:ignore")) {
+ String *baseclassname = Getattr(base.item, "name");
+ if (!c_baseclassname) {
+ c_baseclassname = baseclassname;
+ baseclass = Copy(getProxyName(baseclassname));
+ if (baseclass)
+ c_baseclass = SwigType_namestr(baseclassname);
+ } else {
+ /* Warn about multiple inheritance for additional base class(es) */
+ String *proxyclassname = Getattr(n, "classtypeobj");
+ Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
+ "Warning for %s, base %s ignored. Multiple inheritance is not supported in Modula 3.\n", SwigType_namestr(proxyclassname), SwigType_namestr(baseclassname));
+ }
}
base = Next(base);
- if (base.item != NIL) {
- Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
- "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n",
- name, Getattr(base.item, "name"));
- }
}
}
@@ -2201,7 +2205,7 @@ MODULA3():
const String *pure_baseclass = typemapLookup(n, "m3base", name, WARN_NONE);
if (hasContent(pure_baseclass) && hasContent(baseclass)) {
Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
- "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n", name, pure_baseclass);
+ "Warning for %s, base %s ignored. Multiple inheritance is not supported in Modula 3.\n", name, pure_baseclass);
}
// Pure Modula 3 interfaces
const String *pure_interfaces = typemapLookup(n, derived ? "m3interfaces_derived" : "m3interfaces",
@@ -2431,7 +2435,7 @@ MODULA3():
base = Next(base);
if (base.item) {
Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
- "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n",
+ "Warning for %s, base %s ignored. Multiple inheritance is not supported in Modula 3.\n",
proxy_class_name, Getattr(base.item, "name"));
}
}
diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx
index 1c5ceefaa..9df6a9551 100644
--- a/Source/Modules/ocaml.cxx
+++ b/Source/Modules/ocaml.cxx
@@ -1287,6 +1287,9 @@ public:
* typedef enum and enum are handled. I need to produce consistent names,
* which means looking up and registering by typedef and enum name. */
int enumDeclaration(Node *n) {
+ if (getCurrentClass() && (cplus_mode != PUBLIC))
+ return SWIG_NOWRAP;
+
String *name = Getattr(n, "name");
if (name) {
String *oname = NewString(name);
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/php.cxx b/Source/Modules/php.cxx
index fbece2715..02bd827f8 100644
--- a/Source/Modules/php.cxx
+++ b/Source/Modules/php.cxx
@@ -1904,7 +1904,7 @@ done:
enumvalue = GetChar(n, "enumvalueex");
}
- if (enumvalue) {
+ if (enumvalue && *Char(enumvalue)) {
// Check for a simple constant expression which is valid in PHP.
// If we find one, initialise the const member with it; otherwise
// we initialise it using the C/C++ wrapped constant.
@@ -1916,7 +1916,8 @@ done:
break;
}
}
- if (!*p) set_to = enumvalue;
+ if (!*p)
+ set_to = enumvalue;
}
if (wrapping_member_constant) {
@@ -2018,7 +2019,7 @@ done:
String *proxyclassname = SwigType_str(Getattr(n, "classtypeobj"), 0);
String *baseclassname = SwigType_str(Getattr(base.item, "name"), 0);
Swig_warning(WARN_PHP_MULTIPLE_INHERITANCE, input_file, line_number,
- "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in PHP.\n", proxyclassname, baseclassname);
+ "Warning for %s, base %s ignored. Multiple inheritance is not supported in PHP.\n", proxyclassname, baseclassname);
base = Next(base);
}
}
diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
index 18824ac1d..0852ce241 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);
}
@@ -897,15 +943,11 @@ public:
"\n", "def _swig_setattr(self, class_type, name, value):\n", tab4, "return _swig_setattr_nondynamic(self, class_type, name, value, 0)\n\n", NIL);
Printv(f_shadow,
- "\n", "def _swig_getattr_nondynamic(self, class_type, name, static=1):\n",
+ "\n", "def _swig_getattr(self, class_type, name):\n",
tab4, "if (name == \"thisown\"):\n", tab8, "return self.this.own()\n",
tab4, "method = class_type.__swig_getmethods__.get(name, None)\n",
tab4, "if method:\n", tab8, "return method(self)\n",
- tab4, "if (not static):\n",
- tab4, tab4, "return object.__getattr__(self, name)\n",
- tab4, "else:\n",
- tab4, tab4, "raise AttributeError(name)\n\n",
- "def _swig_getattr(self, class_type, name):\n", tab4, "return _swig_getattr_nondynamic(self, class_type, name, 0)\n\n", NIL);
+ tab4, "raise AttributeError(\"'%s' object has no attribute '%s'\" % (class_type.__name__, name))\n\n", NIL);
Printv(f_shadow,
"\n", "def _swig_repr(self):\n",
@@ -1209,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;
@@ -2728,7 +2771,8 @@ public:
int noargs = funpack && (tuple_required == 0 && tuple_arguments == 0);
int onearg = funpack && (tuple_required == 1 && tuple_arguments == 1);
- if (builtin && funpack && !overname && !builtin_ctor && !GetFlag(n, "feature:compactdefaultargs")) {
+ if (builtin && funpack && !overname && !builtin_ctor &&
+ !(GetFlag(n, "feature:compactdefaultargs") && (tuple_arguments > tuple_required || varargs))) {
String *argattr = NewStringf("%d", tuple_arguments);
Setattr(n, "python:argcount", argattr);
Delete(argattr);
@@ -3454,6 +3498,28 @@ public:
* constantWrapper()
* ------------------------------------------------------------ */
+ /* Determine if the node requires the _swigconstant code to be generated */
+ bool needs_swigconstant(Node* n) {
+ SwigType *type = Getattr(n, "type");
+ SwigType *qtype = SwigType_typedef_resolve_all(type);
+ SwigType *uqtype = SwigType_strip_qualifiers(qtype);
+ bool result = false;
+
+ /* Note, that we need special handling for function pointers, as
+ * SwigType_base(fptr) does not return the underlying pointer-to-function
+ * type but the return-type of function. */
+ if(!SwigType_isfunction(uqtype) && !SwigType_isfunctionpointer(uqtype)) {
+ SwigType *basetype = SwigType_base(uqtype);
+ result = SwigType_isclass(basetype) != 0;
+ Delete(basetype);
+ }
+
+ Delete(qtype);
+ Delete(uqtype);
+
+ return result;
+ }
+
virtual int constantWrapper(Node *n) {
String *name = Getattr(n, "name");
String *iname = Getattr(n, "sym:name");
@@ -3496,8 +3562,15 @@ public:
Replaceall(tm, "$source", value);
Replaceall(tm, "$target", name);
Replaceall(tm, "$value", value);
- if (!builtin && (shadow) && (!(shadow & PYSHADOW_MEMBER)) && (!in_class || !Getattr(n, "feature:python:callback"))) {
- // Generate method which registers the new constant
+ if (needs_swigconstant(n) && !builtin && (shadow) && (!(shadow & PYSHADOW_MEMBER)) && (!in_class || !Getattr(n, "feature:python:callback"))) {
+ // Generate `*_swigconstant()` method which registers the new constant.
+ //
+ // *_swigconstant methods are required for constants of class type.
+ // Class types are registered in shadow file (see *_swigregister). The
+ // instances of class must be created (registered) after the type is
+ // registered, so we can't let SWIG_init() to register constants of
+ // class type (the SWIG_init() is called before shadow classes are
+ // defined and registered).
Printf(f_wrappers, "SWIGINTERN PyObject *%s_swigconstant(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n", iname);
Printf(f_wrappers, tab2 "PyObject *module;\n", tm);
Printf(f_wrappers, tab2 "PyObject *d;\n");
@@ -3537,13 +3610,17 @@ public:
if (!builtin && (shadow) && (!(shadow & PYSHADOW_MEMBER))) {
if (!in_class) {
- Printv(f_shadow, "\n",NIL);
- Printv(f_shadow, module, ".", iname, "_swigconstant(",module,")\n", NIL);
+ if(needs_swigconstant(n)) {
+ Printv(f_shadow, "\n",NIL);
+ Printv(f_shadow, module, ".", iname, "_swigconstant(",module,")\n", NIL);
+ }
Printv(f_shadow, iname, " = ", module, ".", iname, "\n", NIL);
} else {
if (!(Getattr(n, "feature:python:callback"))) {
- Printv(f_shadow_stubs, "\n",NIL);
- Printv(f_shadow_stubs, module, ".", iname, "_swigconstant(", module, ")\n", NIL);
+ if(needs_swigconstant(n)) {
+ Printv(f_shadow_stubs, "\n",NIL);
+ Printv(f_shadow_stubs, module, ".", iname, "_swigconstant(", module, ")\n", NIL);
+ }
Printv(f_shadow_stubs, iname, " = ", module, ".", iname, "\n", NIL);
}
}
@@ -4123,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 758cb00ee..301b49f9e 100644
--- a/Source/Modules/r.cxx
+++ b/Source/Modules/r.cxx
@@ -1179,6 +1179,9 @@ int R::OutputArrayMethod(String *className, List *el, File *out) {
tdname is the typedef of the enumeration, i.e. giving its name.
*************************************************************/
int R::enumDeclaration(Node *n) {
+ if (getCurrentClass() && (cplus_mode != PUBLIC))
+ return SWIG_NOWRAP;
+
String *name = Getattr(n, "name");
String *tdname = Getattr(n, "tdname");
@@ -1479,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;
@@ -1496,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;
@@ -1518,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 62a6d960c..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);
@@ -2473,7 +2487,7 @@ public:
String *proxyclassname = SwigType_str(Getattr(n, "classtypeobj"), 0);
String *baseclassname = SwigType_str(Getattr(base.item, "name"), 0);
Swig_warning(WARN_RUBY_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
- "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Ruby.\n", proxyclassname, baseclassname);
+ "Warning for %s, base %s ignored. Multiple inheritance is not supported in Ruby.\n", proxyclassname, baseclassname);
base = Next(base);
}
}
@@ -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 63f689eaa..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;
}
@@ -884,7 +888,7 @@ public:
Printf(builderCode, "libs = [];\n");
// Flags from command line arguments
- Printf(builderCode, "cflags = [];\n");
+ Printf(builderCode, "cflags = \"\";\n");
for (int i = 0; i < Len(cflags); i++) {
String *cflag = Getitem(cflags, i);
Printf(builderCode, "cflags = cflags + \" %s\";\n", cflag);
@@ -900,7 +904,7 @@ public:
}
}
} else {
- Printf(builderCode, "ldflags = [];\n");
+ Printf(builderCode, "ldflags = \"\";\n");
}
// External script to set flags
diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h
index c4007be51..34763cc09 100644
--- a/Source/Modules/swigmod.h
+++ b/Source/Modules/swigmod.h
@@ -208,8 +208,9 @@ public:
/* Miscellaneous */
virtual int validIdentifier(String *s); /* valid identifier? */
virtual int addSymbol(const String *s, const Node *n, const_String_or_char_ptr scope = ""); /* Add symbol */
+ virtual int addInterfaceSymbol(const String *interface_name, Node *n, const_String_or_char_ptr scope = "");
virtual void dumpSymbols();
- virtual Node *symbolLookup(String *s, const_String_or_char_ptr scope = ""); /* Symbol lookup */
+ virtual Node *symbolLookup(const String *s, const_String_or_char_ptr scope = ""); /* Symbol lookup */
virtual Hash* symbolAddScope(const_String_or_char_ptr scope);
virtual Hash* symbolScopeLookup(const_String_or_char_ptr scope);
virtual Hash* symbolScopePseudoSymbolLookup(const_String_or_char_ptr scope);
@@ -422,19 +423,24 @@ extern "C" {
}
/* Contracts */
-
void Swig_contracts(Node *n);
void Swig_contract_mode_set(int flag);
int Swig_contract_mode_get();
/* Browser */
-
void Swig_browser(Node *n, int);
void Swig_default_allocators(Node *n);
void Swig_process_types(Node *n);
+
+/* Nested classes */
void Swig_nested_process_classes(Node *n);
void Swig_nested_name_unnamed_c_structs(Node *n);
+/* Interface feature */
+void Swig_interface_feature_enable();
+void Swig_interface_propagate_methods(Node *n);
+
+/* Miscellaneous */
template <class T> class save_value {
T _value;
T& _value_ptr;
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/Source/Swig/misc.c b/Source/Swig/misc.c
index c552ac2cb..91f05c0a2 100644
--- a/Source/Swig/misc.c
+++ b/Source/Swig/misc.c
@@ -309,6 +309,7 @@ int Swig_storage_isstatic(Node *n) {
* Swig_string_escape()
*
* Takes a string object and produces a string with escape codes added to it.
+ * Octal escaping is used.
* ----------------------------------------------------------------------------- */
String *Swig_string_escape(String *s) {
@@ -342,6 +343,43 @@ String *Swig_string_escape(String *s) {
return ns;
}
+/* -----------------------------------------------------------------------------
+ * Swig_string_hexescape()
+ *
+ * Takes a string object and produces a string with escape codes added to it.
+ * Hex escaping is used.
+ * ----------------------------------------------------------------------------- */
+
+String *Swig_string_hexescape(String *s) {
+ String *ns;
+ int c;
+ ns = NewStringEmpty();
+
+ while ((c = Getc(s)) != EOF) {
+ if (c == '\n') {
+ Printf(ns, "\\n");
+ } else if (c == '\r') {
+ Printf(ns, "\\r");
+ } else if (c == '\t') {
+ Printf(ns, "\\t");
+ } else if (c == '\\') {
+ Printf(ns, "\\\\");
+ } else if (c == '\'') {
+ Printf(ns, "\\'");
+ } else if (c == '\"') {
+ Printf(ns, "\\\"");
+ } else if (c == ' ') {
+ Putc(c, ns);
+ } else if (!isgraph(c)) {
+ if (c < 0)
+ c += UCHAR_MAX + 1;
+ Printf(ns, "\\x%X", c);
+ } else {
+ Putc(c, ns);
+ }
+ }
+ return ns;
+}
/* -----------------------------------------------------------------------------
* Swig_string_upper()
@@ -1148,6 +1186,39 @@ String *Swig_string_strip(String *s) {
}
/* -----------------------------------------------------------------------------
+ * Swig_string_rstrip()
+ *
+ * Strip given suffix from identifiers
+ *
+ * Printf(stderr,"%(rstrip:[Cls])s","HelloCls") -> Hello
+ * ----------------------------------------------------------------------------- */
+
+String *Swig_string_rstrip(String *s) {
+ String *ns;
+ int len = Len(s);
+ if (!len) {
+ ns = NewString(s);
+ } else {
+ const char *cs = Char(s);
+ const char *ce = Strchr(cs, ']');
+ if (*cs != '[' || !ce) {
+ ns = NewString(s);
+ } else {
+ String *fmt = NewStringf("%%.%ds", ce-cs-1);
+ String *suffix = NewStringf(fmt, cs+1);
+ int suffix_len = Len(suffix);
+ if (0 == Strncmp(cs+len-suffix_len, suffix, suffix_len)) {
+ int copy_len = len-suffix_len-(ce+1-cs);
+ ns = NewStringWithSize(ce+1, copy_len);
+ } else {
+ ns = NewString(ce+1);
+ }
+ }
+ }
+ return ns;
+}
+
+/* -----------------------------------------------------------------------------
* Swig_offset_string()
*
* Insert number tabs before each new line in s
@@ -1328,7 +1399,7 @@ String *replace_captures(int num_captures, const char *input, String *subst, int
*
* Executes a regular expression substitution. For example:
*
- * Printf(stderr,"gsl%(regex:/GSL_.*_/\\1/)s","GSL_Hello_") -> gslHello
+ * Printf(stderr,"gsl%(regex:/GSL_(.*)_/\\1/)s", "GSL_Hello_") -> gslHello
* ----------------------------------------------------------------------------- */
String *Swig_string_regex(String *s) {
const int pcre_options = 0;
@@ -1392,6 +1463,7 @@ String *Swig_pcre_version(void) {
void Swig_init() {
/* Set some useful string encoding methods */
DohEncoding("escape", Swig_string_escape);
+ DohEncoding("hexescape", Swig_string_hexescape);
DohEncoding("upper", Swig_string_upper);
DohEncoding("lower", Swig_string_lower);
DohEncoding("title", Swig_string_title);
@@ -1403,6 +1475,7 @@ void Swig_init() {
DohEncoding("command", Swig_string_command);
DohEncoding("schemify", Swig_string_schemify);
DohEncoding("strip", Swig_string_strip);
+ DohEncoding("rstrip", Swig_string_rstrip);
DohEncoding("regex", Swig_string_regex);
/* aliases for the case encoders */
diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c
index 2d1effa18..c7f187177 100644
--- a/Source/Swig/naming.c
+++ b/Source/Swig/naming.c
@@ -50,6 +50,13 @@ void Swig_name_unregister(const_String_or_char_ptr method) {
}
}
+/* Return naming format for the specified method or the default format if none was explicitly registered */
+static String* get_naming_format_for(const char *method, const char *def_format) {
+ String* f = naming_hash ? Getattr(naming_hash, method) : NULL;
+
+ return f ? Copy(f) : NewString(def_format);
+}
+
static int name_mangle(String *r) {
char *c;
int special;
@@ -172,18 +179,8 @@ String *Swig_name_mangle(const_String_or_char_ptr s) {
* ----------------------------------------------------------------------------- */
String *Swig_name_wrapper(const_String_or_char_ptr fname) {
- String *r;
- String *f;
+ String *r = get_naming_format_for("wrapper", "_wrap_%f");
- r = NewStringEmpty();
- if (!naming_hash)
- naming_hash = NewHash();
- f = Getattr(naming_hash, "wrapper");
- if (!f) {
- Append(r, "_wrap_%f");
- } else {
- Append(r, f);
- }
Replace(r, "%f", fname, DOH_REPLACE_ANY);
name_mangle(r);
return r;
@@ -198,20 +195,11 @@ String *Swig_name_wrapper(const_String_or_char_ptr fname) {
String *Swig_name_member(const_String_or_char_ptr nspace, const_String_or_char_ptr classname, const_String_or_char_ptr membername) {
String *r;
- String *f;
String *rclassname;
char *cname;
rclassname = SwigType_namestr(classname);
- r = NewStringEmpty();
- if (!naming_hash)
- naming_hash = NewHash();
- f = Getattr(naming_hash, "member");
- if (!f) {
- Append(r, "%n%c_%m");
- } else {
- Append(r, f);
- }
+ r = get_naming_format_for("member", "%n%c_%m");
cname = Char(rclassname);
if ((strncmp(cname, "struct ", 7) == 0) || ((strncmp(cname, "class ", 6) == 0)) || ((strncmp(cname, "union ", 6) == 0))) {
cname = strchr(cname, ' ') + 1;
@@ -231,23 +219,12 @@ String *Swig_name_member(const_String_or_char_ptr nspace, const_String_or_char_p
* ----------------------------------------------------------------------------- */
String *Swig_name_get(const_String_or_char_ptr nspace, const_String_or_char_ptr vname) {
- String *r;
- String *f;
+ String *r = get_naming_format_for("get", "%n%v_get");
#ifdef SWIG_DEBUG
Printf(stdout, "Swig_name_get: '%s'\n", vname);
#endif
- r = NewStringEmpty();
- if (!naming_hash)
- naming_hash = NewHash();
- f = Getattr(naming_hash, "get");
- if (!f) {
- Append(r, "%n%v_get");
- } else {
- Append(r, f);
- }
-
replace_nspace(r, nspace);
Replace(r, "%v", vname, DOH_REPLACE_ANY);
/* name_mangle(r); */
@@ -261,18 +238,7 @@ String *Swig_name_get(const_String_or_char_ptr nspace, const_String_or_char_ptr
* ----------------------------------------------------------------------------- */
String *Swig_name_set(const_String_or_char_ptr nspace, const_String_or_char_ptr vname) {
- String *r;
- String *f;
-
- r = NewStringEmpty();
- if (!naming_hash)
- naming_hash = NewHash();
- f = Getattr(naming_hash, "set");
- if (!f) {
- Append(r, "%n%v_set");
- } else {
- Append(r, f);
- }
+ String *r = get_naming_format_for("set", "%n%v_set");
replace_nspace(r, nspace);
Replace(r, "%v", vname, DOH_REPLACE_ANY);
@@ -280,28 +246,14 @@ String *Swig_name_set(const_String_or_char_ptr nspace, const_String_or_char_ptr
return r;
}
-/* -----------------------------------------------------------------------------
- * Swig_name_construct()
- *
- * Returns the name of the accessor function used to create an object.
- * ----------------------------------------------------------------------------- */
-
-String *Swig_name_construct(const_String_or_char_ptr nspace, const_String_or_char_ptr classname) {
+/* Common implementation of all Swig_name_<special-method>() functions below. */
+static String *make_full_name_for(const char *method, const char *def_format, const_String_or_char_ptr nspace, const_String_or_char_ptr classname) {
String *r;
- String *f;
String *rclassname;
char *cname;
rclassname = SwigType_namestr(classname);
- r = NewStringEmpty();
- if (!naming_hash)
- naming_hash = NewHash();
- f = Getattr(naming_hash, "construct");
- if (!f) {
- Append(r, "new_%n%c");
- } else {
- Append(r, f);
- }
+ r = get_naming_format_for(method, def_format);
cname = Char(rclassname);
if ((strncmp(cname, "struct ", 7) == 0) || ((strncmp(cname, "class ", 6) == 0)) || ((strncmp(cname, "union ", 6) == 0))) {
@@ -314,6 +266,16 @@ String *Swig_name_construct(const_String_or_char_ptr nspace, const_String_or_cha
return r;
}
+/* -----------------------------------------------------------------------------
+ * Swig_name_construct()
+ *
+ * Returns the name of the accessor function used to create an object.
+ * ----------------------------------------------------------------------------- */
+
+String *Swig_name_construct(const_String_or_char_ptr nspace, const_String_or_char_ptr classname) {
+ return make_full_name_for("construct", "new_%n%c", nspace, classname);
+}
+
/* -----------------------------------------------------------------------------
* Swig_name_copyconstructor()
@@ -322,31 +284,7 @@ String *Swig_name_construct(const_String_or_char_ptr nspace, const_String_or_cha
* ----------------------------------------------------------------------------- */
String *Swig_name_copyconstructor(const_String_or_char_ptr nspace, const_String_or_char_ptr classname) {
- String *r;
- String *f;
- String *rclassname;
- char *cname;
-
- rclassname = SwigType_namestr(classname);
- r = NewStringEmpty();
- if (!naming_hash)
- naming_hash = NewHash();
- f = Getattr(naming_hash, "copy");
- if (!f) {
- Append(r, "copy_%n%c");
- } else {
- Append(r, f);
- }
-
- cname = Char(rclassname);
- if ((strncmp(cname, "struct ", 7) == 0) || ((strncmp(cname, "class ", 6) == 0)) || ((strncmp(cname, "union ", 6) == 0))) {
- cname = strchr(cname, ' ') + 1;
- }
-
- replace_nspace(r, nspace);
- Replace(r, "%c", cname, DOH_REPLACE_ANY);
- Delete(rclassname);
- return r;
+ return make_full_name_for("copy", "copy_%n%c", nspace, classname);
}
/* -----------------------------------------------------------------------------
@@ -356,30 +294,7 @@ String *Swig_name_copyconstructor(const_String_or_char_ptr nspace, const_String_
* ----------------------------------------------------------------------------- */
String *Swig_name_destroy(const_String_or_char_ptr nspace, const_String_or_char_ptr classname) {
- String *r;
- String *f;
- String *rclassname;
- char *cname;
- rclassname = SwigType_namestr(classname);
- r = NewStringEmpty();
- if (!naming_hash)
- naming_hash = NewHash();
- f = Getattr(naming_hash, "destroy");
- if (!f) {
- Append(r, "delete_%n%c");
- } else {
- Append(r, f);
- }
-
- cname = Char(rclassname);
- if ((strncmp(cname, "struct ", 7) == 0) || ((strncmp(cname, "class ", 6) == 0)) || ((strncmp(cname, "union ", 6) == 0))) {
- cname = strchr(cname, ' ') + 1;
- }
-
- replace_nspace(r, nspace);
- Replace(r, "%c", cname, DOH_REPLACE_ANY);
- Delete(rclassname);
- return r;
+ return make_full_name_for("destroy", "delete_%n%c", nspace, classname);
}
@@ -390,30 +305,7 @@ String *Swig_name_destroy(const_String_or_char_ptr nspace, const_String_or_char_
* ----------------------------------------------------------------------------- */
String *Swig_name_disown(const_String_or_char_ptr nspace, const_String_or_char_ptr classname) {
- String *r;
- String *f;
- String *rclassname;
- char *cname;
- rclassname = SwigType_namestr(classname);
- r = NewStringEmpty();
- if (!naming_hash)
- naming_hash = NewHash();
- f = Getattr(naming_hash, "disown");
- if (!f) {
- Append(r, "disown_%n%c");
- } else {
- Append(r, f);
- }
-
- cname = Char(rclassname);
- if ((strncmp(cname, "struct ", 7) == 0) || ((strncmp(cname, "class ", 6) == 0)) || ((strncmp(cname, "union ", 6) == 0))) {
- cname = strchr(cname, ' ') + 1;
- }
-
- replace_nspace(r, nspace);
- Replace(r, "%c", cname, DOH_REPLACE_ANY);
- Delete(rclassname);
- return r;
+ return make_full_name_for("disown", "disown_%n%c", nspace, classname);
}
@@ -466,8 +358,7 @@ static DOH *get_object(Hash *n, String *decl) {
return rn;
}
-static
-DOH *name_object_get(Hash *namehash, String *tname, SwigType *decl, SwigType *ncdecl) {
+static DOH *name_object_get(Hash *namehash, String *tname, SwigType *decl, SwigType *ncdecl) {
DOH *rn = 0;
Hash *n = Getattr(namehash, tname);
if (n) {
@@ -646,8 +537,7 @@ static void merge_features(Hash *features, Node *n) {
* the declaration, decl.
* ----------------------------------------------------------------------------- */
-static
-void features_get(Hash *features, const String *tname, SwigType *decl, SwigType *ncdecl, Node *node) {
+static void features_get(Hash *features, const String *tname, SwigType *decl, SwigType *ncdecl, Node *node) {
Node *n = Getattr(features, tname);
#ifdef SWIG_DEBUG
Printf(stdout, " features_get: %s\n", tname);
@@ -844,41 +734,41 @@ void Swig_feature_set(Hash *features, const_String_or_char_ptr name, SwigType *d
* ----------------------------------------------------------------------------- */
static Hash *namewarn_hash = 0;
-Hash *Swig_name_namewarn_hash() {
+static Hash *name_namewarn_hash() {
if (!namewarn_hash)
namewarn_hash = NewHash();
return namewarn_hash;
}
static Hash *rename_hash = 0;
-Hash *Swig_name_rename_hash() {
+static Hash *name_rename_hash() {
if (!rename_hash)
rename_hash = NewHash();
return rename_hash;
}
static List *namewarn_list = 0;
-List *Swig_name_namewarn_list() {
+static List *name_namewarn_list() {
if (!namewarn_list)
namewarn_list = NewList();
return namewarn_list;
}
static List *rename_list = 0;
-List *Swig_name_rename_list() {
+static List *name_rename_list() {
if (!rename_list)
rename_list = NewList();
return rename_list;
}
/* -----------------------------------------------------------------------------
- * int Swig_need_name_warning(Node *n)
+ * int need_name_warning(Node *n)
*
* Detects if a node needs name warnings
*
* ----------------------------------------------------------------------------- */
-int Swig_need_name_warning(Node *n) {
+static int need_name_warning(Node *n) {
int need = 1;
/*
We don't use name warnings for:
@@ -1061,13 +951,13 @@ int Swig_need_protected(Node *n) {
}
/* -----------------------------------------------------------------------------
- * void Swig_name_nameobj_add()
+ * void name_nameobj_add()
*
* Add nameobj (rename/namewarn)
*
* ----------------------------------------------------------------------------- */
-static List *Swig_make_attrlist(const char *ckey) {
+static List *make_attrlist(const char *ckey) {
List *list = NewList();
const char *cattr = strchr(ckey, '$');
if (cattr) {
@@ -1089,7 +979,7 @@ static List *Swig_make_attrlist(const char *ckey) {
return list;
}
-static void Swig_name_object_attach_keys(const char *keys[], Hash *nameobj) {
+static void name_object_attach_keys(const char *keys[], Hash *nameobj) {
Node *kw = nextSibling(nameobj);
List *matchlist = 0;
while (kw) {
@@ -1105,7 +995,7 @@ static void Swig_name_object_attach_keys(const char *keys[], Hash *nameobj) {
|| (isregexmatch = (strncmp(ckey, "regexmatch", 10) == 0))
|| (isnotmatch = isregexmatch = (strncmp(ckey, "notregexmatch", 13) == 0))) {
Hash *mi = NewHash();
- List *attrlist = Swig_make_attrlist(ckey);
+ List *attrlist = make_attrlist(ckey);
if (!matchlist)
matchlist = NewList();
Setattr(mi, "value", Getattr(kw, "value"));
@@ -1135,7 +1025,7 @@ static void Swig_name_object_attach_keys(const char *keys[], Hash *nameobj) {
}
}
-void Swig_name_nameobj_add(Hash *name_hash, List *name_list, String *prefix, String *name, SwigType *decl, Hash *nameobj) {
+static void name_nameobj_add(Hash *name_hash, List *name_list, String *prefix, String *name, SwigType *decl, Hash *nameobj) {
String *nname = 0;
if (name && Len(name)) {
String *target_fmt = Getattr(nameobj, "targetfmt");
@@ -1164,13 +1054,13 @@ void Swig_name_nameobj_add(Hash *name_hash, List *name_list, String *prefix, Str
}
/* -----------------------------------------------------------------------------
- * int Swig_name_match_nameobj()
+ * int name_match_nameobj()
*
* Apply and check the nameobj's math list to the node
*
* ----------------------------------------------------------------------------- */
-static DOH *Swig_get_lattr(Node *n, List *lattr) {
+static DOH *get_lattr(Node *n, List *lattr) {
DOH *res = 0;
int ilen = Len(lattr);
int i;
@@ -1192,7 +1082,7 @@ static DOH *Swig_get_lattr(Node *n, List *lattr) {
#ifdef HAVE_PCRE
#include <pcre.h>
-int Swig_name_regexmatch_value(Node *n, String *pattern, String *s) {
+static int name_regexmatch_value(Node *n, String *pattern, String *s) {
pcre *compiled_pat;
const char *err;
int errpos;
@@ -1224,7 +1114,7 @@ int Swig_name_regexmatch_value(Node *n, String *pattern, String *s) {
#else /* !HAVE_PCRE */
-int Swig_name_regexmatch_value(Node *n, String *pattern, String *s) {
+static int name_regexmatch_value(Node *n, String *pattern, String *s) {
(void)pattern;
(void)s;
Swig_error("SWIG", Getline(n),
@@ -1234,7 +1124,7 @@ int Swig_name_regexmatch_value(Node *n, String *pattern, String *s) {
#endif /* HAVE_PCRE/!HAVE_PCRE */
-int Swig_name_match_value(String *mvalue, String *value) {
+static int name_match_value(String *mvalue, String *value) {
#if defined(SWIG_USE_SIMPLE_MATCHOR)
int match = 0;
char *cvalue = Char(value);
@@ -1260,12 +1150,11 @@ int Swig_name_match_value(String *mvalue, String *value) {
#endif
}
-
-int Swig_name_match_nameobj(Hash *rn, Node *n) {
+static int name_match_nameobj(Hash *rn, Node *n) {
int match = 1;
List *matchlist = Getattr(rn, "matchlist");
#ifdef SWIG_DEBUG
- Printf(stdout, "Swig_name_match_nameobj: %s\n", Getattr(n, "name"));
+ Printf(stdout, "name_match_nameobj: %s\n", Getattr(n, "name"));
#endif
if (matchlist) {
int ilen = Len(matchlist);
@@ -1273,14 +1162,14 @@ int Swig_name_match_nameobj(Hash *rn, Node *n) {
for (i = 0; match && (i < ilen); ++i) {
Node *mi = Getitem(matchlist, i);
List *lattr = Getattr(mi, "attrlist");
- String *nval = Swig_get_lattr(n, lattr);
+ String *nval = get_lattr(n, lattr);
int notmatch = GetFlag(mi, "notmatch");
int regexmatch = GetFlag(mi, "regexmatch");
match = 0;
if (nval) {
String *kwval = Getattr(mi, "value");
- match = regexmatch ? Swig_name_regexmatch_value(n, kwval, nval)
- : Swig_name_match_value(kwval, nval);
+ match = regexmatch ? name_regexmatch_value(n, kwval, nval)
+ : name_match_value(kwval, nval);
#ifdef SWIG_DEBUG
Printf(stdout, "val %s %s %d %d \n", nval, kwval, match, ilen);
#endif
@@ -1290,19 +1179,19 @@ int Swig_name_match_nameobj(Hash *rn, Node *n) {
}
}
#ifdef SWIG_DEBUG
- Printf(stdout, "Swig_name_match_nameobj: %d\n", match);
+ Printf(stdout, "name_match_nameobj: %d\n", match);
#endif
return match;
}
/* -----------------------------------------------------------------------------
- * Hash *Swig_name_nameobj_lget()
+ * Hash *name_nameobj_lget()
*
* Get a nameobj (rename/namewarn) from the list of filters
*
* ----------------------------------------------------------------------------- */
-Hash *Swig_name_nameobj_lget(List *namelist, Node *n, String *prefix, String *name, String *decl) {
+static Hash *name_nameobj_lget(List *namelist, Node *n, String *prefix, String *name, String *decl) {
Hash *res = 0;
if (namelist) {
int len = Len(namelist);
@@ -1313,7 +1202,7 @@ Hash *Swig_name_nameobj_lget(List *namelist, Node *n, String *prefix, String *na
String *rdecl = Getattr(rn, "decl");
if (rdecl && (!decl || !Equal(rdecl, decl))) {
continue;
- } else if (Swig_name_match_nameobj(rn, n)) {
+ } else if (name_match_nameobj(rn, n)) {
String *tname = Getattr(rn, "targetname");
if (tname) {
String *sfmt = Getattr(rn, "sourcefmt");
@@ -1336,8 +1225,8 @@ Hash *Swig_name_nameobj_lget(List *namelist, Node *n, String *prefix, String *na
DohIncref(name);
}
}
- match = regextarget ? Swig_name_regexmatch_value(n, tname, sname)
- : Swig_name_match_value(tname, sname);
+ match = regextarget ? name_regexmatch_value(n, tname, sname)
+ : name_match_value(tname, sname);
Delete(sname);
} else {
/* Applying the renaming rule may fail if it contains a %(regex)s expression that doesn't match the given name. */
@@ -1367,23 +1256,23 @@ Hash *Swig_name_nameobj_lget(List *namelist, Node *n, String *prefix, String *na
void Swig_name_namewarn_add(String *prefix, String *name, SwigType *decl, Hash *namewrn) {
const char *namewrn_keys[] = { "rename", "error", "fullname", "sourcefmt", "targetfmt", 0 };
- Swig_name_object_attach_keys(namewrn_keys, namewrn);
- Swig_name_nameobj_add(Swig_name_namewarn_hash(), Swig_name_namewarn_list(), prefix, name, decl, namewrn);
+ name_object_attach_keys(namewrn_keys, namewrn);
+ name_nameobj_add(name_namewarn_hash(), name_namewarn_list(), prefix, name, decl, namewrn);
}
/* -----------------------------------------------------------------------------
- * Hash *Swig_name_namewarn_get()
+ * Hash *name_namewarn_get()
*
* Return the namewarn object, if there is one.
*
* ----------------------------------------------------------------------------- */
-Hash *Swig_name_namewarn_get(Node *n, String *prefix, String *name, SwigType *decl) {
+static Hash *name_namewarn_get(Node *n, String *prefix, String *name, SwigType *decl) {
if (!namewarn_hash && !namewarn_list)
return 0;
if (n) {
/* Return in the obvious cases */
- if (!name || !Swig_need_name_warning(n)) {
+ if (!name || !need_name_warning(n)) {
return 0;
} else {
String *access = Getattr(n, "access");
@@ -1395,11 +1284,11 @@ Hash *Swig_name_namewarn_get(Node *n, String *prefix, String *name, SwigType *de
}
if (name) {
/* Check to see if the name is in the hash */
- Hash *wrn = Swig_name_object_get(Swig_name_namewarn_hash(), prefix, name, decl);
- if (wrn && !Swig_name_match_nameobj(wrn, n))
+ Hash *wrn = Swig_name_object_get(name_namewarn_hash(), prefix, name, decl);
+ if (wrn && !name_match_nameobj(wrn, n))
wrn = 0;
if (!wrn) {
- wrn = Swig_name_nameobj_lget(Swig_name_namewarn_list(), n, prefix, name, decl);
+ wrn = name_nameobj_lget(name_namewarn_list(), n, prefix, name, decl);
}
if (wrn && Getattr(wrn, "error")) {
if (n) {
@@ -1422,7 +1311,7 @@ Hash *Swig_name_namewarn_get(Node *n, String *prefix, String *name, SwigType *de
* ----------------------------------------------------------------------------- */
String *Swig_name_warning(Node *n, String *prefix, String *name, SwigType *decl) {
- Hash *wrn = Swig_name_namewarn_get(n, prefix, name, decl);
+ Hash *wrn = name_namewarn_get(n, prefix, name, decl);
return (name && wrn) ? Getattr(wrn, "name") : 0;
}
@@ -1434,7 +1323,7 @@ String *Swig_name_warning(Node *n, String *prefix, String *name, SwigType *decl)
* ----------------------------------------------------------------------------- */
static void single_rename_add(String *prefix, String *name, SwigType *decl, Hash *newname) {
- Swig_name_nameobj_add(Swig_name_rename_hash(), Swig_name_rename_list(), prefix, name, decl, newname);
+ name_nameobj_add(name_rename_hash(), name_rename_list(), prefix, name, decl, newname);
}
/* Add a new rename. Works much like new_feature including default argument handling. */
@@ -1443,7 +1332,7 @@ void Swig_name_rename_add(String *prefix, String *name, SwigType *decl, Hash *ne
ParmList *declparms = declaratorparms;
const char *rename_keys[] = { "fullname", "sourcefmt", "targetfmt", "continue", "regextarget", 0 };
- Swig_name_object_attach_keys(rename_keys, newname);
+ name_object_attach_keys(rename_keys, newname);
/* Add the name */
single_rename_add(prefix, name, decl, newname);
@@ -1556,11 +1445,10 @@ String *Swig_name_make(Node *n, String *prefix, const_String_or_char_ptr cname,
}
}
-
if (rename_hash || rename_list || namewarn_hash || namewarn_list) {
- Hash *rn = Swig_name_object_get(Swig_name_rename_hash(), prefix, name, decl);
- if (!rn || !Swig_name_match_nameobj(rn, n)) {
- rn = Swig_name_nameobj_lget(Swig_name_rename_list(), n, prefix, name, decl);
+ Hash *rn = Swig_name_object_get(name_rename_hash(), prefix, name, decl);
+ if (!rn || !name_match_nameobj(rn, n)) {
+ rn = name_nameobj_lget(name_rename_list(), n, prefix, name, decl);
if (rn) {
String *sfmt = Getattr(rn, "sourcefmt");
int fullname = GetFlag(rn, "fullname");
@@ -1596,7 +1484,7 @@ String *Swig_name_make(Node *n, String *prefix, const_String_or_char_ptr cname,
}
}
nname = result ? result : name;
- wrn = Swig_name_namewarn_get(n, prefix, nname, decl);
+ wrn = name_namewarn_get(n, prefix, nname, decl);
if (wrn) {
String *rename = Getattr(wrn, "rename");
if (rename) {
@@ -1641,14 +1529,14 @@ String *Swig_name_make(Node *n, String *prefix, const_String_or_char_ptr cname,
/* -----------------------------------------------------------------------------
* void Swig_name_inherit()
*
- * Inherit namewarn,rename, and feature objects
+ * Inherit namewarn, rename, and feature objects
*
* ----------------------------------------------------------------------------- */
void Swig_name_inherit(String *base, String *derived) {
/* Printf(stdout,"base = '%s', derived = '%s'\n", base, derived); */
- Swig_name_object_inherit(Swig_name_rename_hash(), base, derived);
- Swig_name_object_inherit(Swig_name_namewarn_hash(), base, derived);
+ Swig_name_object_inherit(name_rename_hash(), base, derived);
+ Swig_name_object_inherit(name_namewarn_hash(), base, derived);
Swig_name_object_inherit(Swig_cparse_features(), base, derived);
}
diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h
index becae9456..35a67640f 100644
--- a/Source/Swig/swig.h
+++ b/Source/Swig/swig.h
@@ -283,13 +283,11 @@ extern int ParmList_is_compactdefargs(ParmList *p);
extern void Swig_naming_init(void);
extern void Swig_name_namewarn_add(String *prefix, String *name, SwigType *decl, Hash *namewrn);
- extern Hash *Swig_name_namewarn_get(Node *n, String *prefix, String *name, SwigType *decl);
extern void Swig_name_rename_add(String *prefix, String *name, SwigType *decl, Hash *namewrn, ParmList *declaratorparms);
extern void Swig_name_inherit(String *base, String *derived);
extern List *Swig_make_inherit_list(String *clsname, List *names, String *Namespaceprefix);
extern void Swig_inherit_base_symbols(List *bases);
extern int Swig_need_protected(Node *n);
- extern int Swig_need_name_warning(Node *n);
extern int Swig_need_redefined_warn(Node *a, Node *b, int InClass);
extern String *Swig_name_make(Node *n, String *prefix, const_String_or_char_ptr cname, SwigType *decl, String *oldname);
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 9aafd8eb7..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,
@@ -47,7 +47,7 @@ def get_cxxflags(language, std, compiler):
"python":"-Werror " + cxx_common,
"r":"-Werror " + cxx_common,
"ruby":"-Werror " + cxx_common,
- "scilab": cxx_common,
+ "scilab":"-Werror " + cxx_common,
"tcl":"-Werror " + cxx_common,
}
if compiler == 'clang':
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 bcb3ba812..417450587 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
@@ -1448,6 +1448,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)
@@ -1457,6 +1459,7 @@ AC_SUBST(JAVALIBRARYPREFIX)
AC_SUBST(JAVASO)
AC_SUBST(JAVALDSHARED)
AC_SUBST(JAVACXXSHARED)
+AC_SUBST(JAVAFLAGS)
AC_SUBST(JAVACFLAGS)
#----------------------------------------------------------------
@@ -2002,8 +2005,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)
@@ -2370,7 +2375,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
@@ -2413,7 +2418,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)
@@ -2421,7 +2429,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
@@ -2444,7 +2452,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
@@ -2583,8 +2591,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