summaryrefslogtreecommitdiff
path: root/Examples
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2021-03-03 21:54:30 +0000
committerGitHub <noreply@github.com>2021-03-03 21:54:30 +0000
commit1a4dc8293151e25977ae89789a58d9431e5a377d (patch)
treef86bb711f1bce6f78521f5393dfbfefb2e9d6f22 /Examples
parentcf7811b17890af6da7174e4e5a65ca38fc55c0e2 (diff)
parentd38c8d512f988a2f332d0597c109231a1b1b805d (diff)
downloadswig-1a4dc8293151e25977ae89789a58d9431e5a377d.tar.gz
Merge branch 'master' into array_fix
Diffstat (limited to 'Examples')
-rw-r--r--Examples/Makefile.in750
-rw-r--r--Examples/contract/simple_c/example.c11
-rw-r--r--Examples/contract/simple_c/example.i19
-rw-r--r--Examples/contract/simple_c/runme1.py17
-rw-r--r--Examples/contract/simple_c/runme2.py20
-rw-r--r--Examples/contract/simple_cxx/example.i28
-rw-r--r--Examples/contract/simple_cxx/runme1.py33
-rw-r--r--Examples/contract/simple_cxx/runme2.py44
-rw-r--r--Examples/contract/simple_cxx/runme3.py57
-rw-r--r--Examples/go/callback/gocallback.go2
-rw-r--r--Examples/go/callback/runme.go3
-rw-r--r--Examples/go/class/runme.go3
-rw-r--r--Examples/go/constants/runme.go3
-rw-r--r--Examples/go/director/director.go4
-rw-r--r--Examples/go/director/runme.go3
-rw-r--r--Examples/go/enum/runme.go3
-rw-r--r--Examples/go/extend/runme.go3
-rw-r--r--Examples/go/funcptr/runme.go3
-rw-r--r--Examples/go/multimap/runme.go3
-rw-r--r--Examples/go/pointer/runme.go3
-rw-r--r--Examples/go/reference/runme.go3
-rw-r--r--Examples/go/simple/runme.go3
-rw-r--r--Examples/go/template/runme.go3
-rw-r--r--Examples/go/variables/runme.go3
-rw-r--r--Examples/guile/check.list8
-rw-r--r--Examples/guile/matrix/runme.scm5
-rw-r--r--Examples/guile/multivalue/example.i4
-rw-r--r--Examples/guile/simple/example.c27
-rw-r--r--Examples/guile/simple/example.i6
-rw-r--r--Examples/guile/simple/runme.scm28
-rw-r--r--Examples/guile/std_vector/example.h5
-rw-r--r--Examples/java/check.list1
-rw-r--r--Examples/java/doxygen/Makefile (renamed from Examples/php5/overloading/Makefile)13
-rw-r--r--Examples/java/doxygen/example.cxx48
-rw-r--r--Examples/java/doxygen/example.dsp162
-rw-r--r--Examples/java/doxygen/example.h107
-rw-r--r--Examples/java/doxygen/example.i17
-rw-r--r--Examples/java/doxygen/runme.java63
-rw-r--r--Examples/java/variables/runme.java2
-rw-r--r--Examples/javascript/check.list1
-rw-r--r--Examples/javascript/enum/runme.js2
-rw-r--r--Examples/javascript/exception/example.h18
-rw-r--r--Examples/javascript/exception/example.i6
-rw-r--r--Examples/javascript/exception/runme.js10
-rw-r--r--Examples/javascript/native/Makefile3
-rw-r--r--Examples/javascript/native/binding.gyp.in9
-rw-r--r--Examples/javascript/native/example.i47
-rw-r--r--Examples/javascript/native/example.js1
-rw-r--r--Examples/javascript/native/index.html31
-rw-r--r--Examples/javascript/native/runme.js3
-rw-r--r--Examples/javascript/variables/runme.js2
-rw-r--r--Examples/lua/arrays/runme.lua2
-rw-r--r--Examples/lua/class/runme.lua2
-rw-r--r--Examples/lua/constants/runme.lua2
-rw-r--r--Examples/lua/dual/dual.cpp2
-rw-r--r--Examples/lua/exception/example.h20
-rw-r--r--Examples/lua/exception/example.i6
-rw-r--r--Examples/lua/exception/runme.lua4
-rw-r--r--Examples/lua/funcptr3/runme.lua2
-rw-r--r--Examples/lua/functest/runme.lua2
-rw-r--r--Examples/lua/functor/runme.lua2
-rw-r--r--Examples/lua/import/runme.lua2
-rw-r--r--Examples/lua/nspace/runme.lua2
-rw-r--r--Examples/lua/owner/example.cxx2
-rw-r--r--Examples/lua/owner/runme.lua2
-rw-r--r--Examples/lua/pointer/runme.lua2
-rw-r--r--Examples/lua/simple/runme.lua2
-rw-r--r--Examples/lua/variables/runme.lua8
-rw-r--r--Examples/mzscheme/check.list1
-rw-r--r--Examples/mzscheme/class/Makefile (renamed from Examples/php5/disown/Makefile)8
-rw-r--r--Examples/mzscheme/class/example.cxx (renamed from Examples/php5/class/example.cxx)0
-rw-r--r--Examples/mzscheme/class/example.h (renamed from Examples/php5/class/example.h)0
-rw-r--r--Examples/mzscheme/class/example.i (renamed from Examples/php5/class/example.i)0
-rw-r--r--Examples/mzscheme/class/runme.scm60
-rw-r--r--Examples/mzscheme/multimap/Makefile1
-rw-r--r--Examples/mzscheme/multimap/example.c2
-rw-r--r--Examples/mzscheme/multimap/example.i6
-rw-r--r--Examples/mzscheme/multimap/runme.scm2
-rw-r--r--Examples/mzscheme/simple/Makefile1
-rw-r--r--Examples/mzscheme/simple/README1
-rw-r--r--Examples/mzscheme/simple/example.c30
-rw-r--r--Examples/mzscheme/simple/example.i13
-rw-r--r--Examples/mzscheme/simple/runme.scm39
-rw-r--r--Examples/mzscheme/std_vector/Makefile11
-rw-r--r--Examples/mzscheme/std_vector/example.h5
-rw-r--r--Examples/mzscheme/std_vector/runme.scm30
-rw-r--r--Examples/ocaml/argout_ref/Makefile13
-rw-r--r--Examples/ocaml/argout_ref/example.i9
-rw-r--r--Examples/ocaml/argout_ref/example_prog.ml26
-rw-r--r--Examples/ocaml/argout_ref/runme.ml17
-rw-r--r--Examples/ocaml/callback/Makefile35
-rw-r--r--Examples/ocaml/callback/example.c3
-rw-r--r--Examples/ocaml/callback/example.h (renamed from Examples/php5/callback/example.h)4
-rw-r--r--Examples/ocaml/callback/example.i (renamed from Examples/php5/callback/example.i)1
-rw-r--r--Examples/ocaml/callback/runme.ml30
-rw-r--r--Examples/ocaml/check.list13
-rw-r--r--Examples/ocaml/class/Makefile35
-rw-r--r--Examples/ocaml/class/example.c (renamed from Examples/contract/simple_cxx/example.cxx)14
-rw-r--r--Examples/ocaml/class/example.h (renamed from Examples/contract/simple_cxx/example.h)14
-rw-r--r--Examples/ocaml/class/example.i (renamed from Examples/php5/enum/example.i)3
-rw-r--r--Examples/ocaml/class/runme.ml57
-rw-r--r--Examples/ocaml/contract/Makefile15
-rw-r--r--Examples/ocaml/contract/runme.ml (renamed from Examples/ocaml/contract/example_prog.ml)7
-rw-r--r--Examples/ocaml/scoped_enum/Makefile15
-rw-r--r--Examples/ocaml/scoped_enum/example_prog.ml4
-rw-r--r--Examples/ocaml/scoped_enum/runme.ml5
-rw-r--r--Examples/ocaml/shapes/Makefile19
-rw-r--r--Examples/ocaml/shapes/runme.ml (renamed from Examples/ocaml/shapes/example_prog.ml)2
-rw-r--r--Examples/ocaml/simple/Makefile15
-rw-r--r--Examples/ocaml/simple/index.html24
-rw-r--r--Examples/ocaml/simple/runme.ml (renamed from Examples/ocaml/simple/example_prog.ml)2
-rw-r--r--Examples/ocaml/std_string/Makefile4
-rw-r--r--Examples/ocaml/std_vector/Makefile4
-rw-r--r--Examples/ocaml/std_vector/example.h5
-rw-r--r--Examples/ocaml/std_vector/runme.ml4
-rw-r--r--Examples/ocaml/stl/Makefile8
-rw-r--r--Examples/ocaml/stl/example.h2
-rw-r--r--Examples/ocaml/stl/example.i2
-rw-r--r--Examples/ocaml/string_from_ptr/Makefile34
-rw-r--r--Examples/ocaml/string_from_ptr/example.i (renamed from Examples/ocaml/string_from_ptr/foolib.i)2
-rw-r--r--Examples/ocaml/string_from_ptr/runme.ml (renamed from Examples/ocaml/string_from_ptr/example_prog.ml)4
-rw-r--r--Examples/ocaml/strings_test/Makefile10
-rw-r--r--Examples/ocaml/strings_test/example.h6
-rw-r--r--Examples/ocaml/strings_test/example.i1
-rw-r--r--Examples/ocaml/strings_test/runme.ml6
-rw-r--r--Examples/octave/check.list2
-rw-r--r--Examples/octave/example.mk12
-rw-r--r--Examples/octave/extend/runme.m2
-rw-r--r--Examples/octave/module_load/runme.m65
-rw-r--r--Examples/octave/variables/runme.m2
-rw-r--r--Examples/perl5/check.list1
-rw-r--r--Examples/perl5/java/Example.java29
-rw-r--r--Examples/perl5/java/Makefile24
-rw-r--r--Examples/perl5/java/example.i10
-rw-r--r--Examples/perl5/java/runme.pl29
-rw-r--r--Examples/perl5/variables/runme.pl2
-rw-r--r--Examples/php/constants/runme.php14
-rw-r--r--Examples/php/disown/runme.php4
-rw-r--r--Examples/php/enum/Makefile2
-rw-r--r--Examples/php/enum/runme.php20
-rw-r--r--Examples/php/pragmas/example.i3
-rw-r--r--Examples/php/pragmas/include.php2
-rw-r--r--Examples/php/pragmas/runme.php4
-rw-r--r--Examples/php/value/Makefile2
-rw-r--r--Examples/php/value/runme.php18
-rw-r--r--Examples/php/variables/runme.php4
-rw-r--r--Examples/php5/callback/Makefile19
-rw-r--r--Examples/php5/callback/example.cxx4
-rw-r--r--Examples/php5/callback/index.html19
-rw-r--r--Examples/php5/callback/runme.php47
-rw-r--r--Examples/php5/check.list19
-rw-r--r--Examples/php5/class/Makefile20
-rw-r--r--Examples/php5/class/runme.php60
-rw-r--r--Examples/php5/constants/Makefile20
-rw-r--r--Examples/php5/constants/example.i26
-rw-r--r--Examples/php5/constants/runme.php28
-rw-r--r--Examples/php5/cpointer/Makefile20
-rw-r--r--Examples/php5/cpointer/example.c16
-rw-r--r--Examples/php5/cpointer/example.i31
-rw-r--r--Examples/php5/cpointer/runme.php47
-rw-r--r--Examples/php5/disown/example.cxx51
-rw-r--r--Examples/php5/disown/example.h50
-rw-r--r--Examples/php5/disown/example.i12
-rw-r--r--Examples/php5/disown/runme.php49
-rw-r--r--Examples/php5/enum/Makefile20
-rw-r--r--Examples/php5/enum/example.cxx37
-rw-r--r--Examples/php5/enum/example.h13
-rw-r--r--Examples/php5/enum/runme.php32
-rw-r--r--Examples/php5/extend/Makefile19
-rw-r--r--Examples/php5/extend/example.cxx4
-rw-r--r--Examples/php5/extend/example.h56
-rw-r--r--Examples/php5/extend/example.i15
-rw-r--r--Examples/php5/extend/index.html19
-rw-r--r--Examples/php5/extend/runme.php76
-rw-r--r--Examples/php5/funcptr/Makefile20
-rw-r--r--Examples/php5/funcptr/example.c17
-rw-r--r--Examples/php5/funcptr/example.h7
-rw-r--r--Examples/php5/funcptr/example.i15
-rw-r--r--Examples/php5/funcptr/runme.php24
-rw-r--r--Examples/php5/overloading/example.cxx55
-rw-r--r--Examples/php5/overloading/example.h46
-rw-r--r--Examples/php5/overloading/example.i8
-rw-r--r--Examples/php5/overloading/runme.php58
-rw-r--r--Examples/php5/pointer/Makefile20
-rw-r--r--Examples/php5/pointer/example.c16
-rw-r--r--Examples/php5/pointer/example.i30
-rw-r--r--Examples/php5/pointer/runme.php35
-rw-r--r--Examples/php5/pragmas/Makefile20
-rw-r--r--Examples/php5/pragmas/example.i31
-rw-r--r--Examples/php5/pragmas/include.php7
-rw-r--r--Examples/php5/pragmas/runme.php5
-rw-r--r--Examples/php5/proxy/Makefile20
-rw-r--r--Examples/php5/proxy/example.cxx43
-rw-r--r--Examples/php5/proxy/example.h43
-rw-r--r--Examples/php5/proxy/example.i12
-rw-r--r--Examples/php5/proxy/runme.php68
-rw-r--r--Examples/php5/reference/Makefile20
-rw-r--r--Examples/php5/reference/example.cxx49
-rw-r--r--Examples/php5/reference/example.h22
-rw-r--r--Examples/php5/reference/example.i43
-rw-r--r--Examples/php5/reference/runme.php49
-rw-r--r--Examples/php5/simple/Makefile20
-rw-r--r--Examples/php5/simple/example.c23
-rw-r--r--Examples/php5/simple/example.i8
-rw-r--r--Examples/php5/simple/runme.php25
-rw-r--r--Examples/php5/sync/Makefile20
-rw-r--r--Examples/php5/sync/example.cxx13
-rw-r--r--Examples/php5/sync/example.h9
-rw-r--r--Examples/php5/sync/example.i7
-rw-r--r--Examples/php5/sync/runme.php15
-rw-r--r--Examples/php5/value/Makefile20
-rw-r--r--Examples/php5/value/example.c13
-rw-r--r--Examples/php5/value/example.h8
-rw-r--r--Examples/php5/value/example.i17
-rw-r--r--Examples/php5/value/runme.php43
-rw-r--r--Examples/php5/variables/Makefile20
-rw-r--r--Examples/php5/variables/example.c95
-rw-r--r--Examples/php5/variables/example.h34
-rw-r--r--Examples/php5/variables/example.i44
-rw-r--r--Examples/php5/variables/runme.php96
-rw-r--r--Examples/python/callback/runme.py22
-rw-r--r--Examples/python/check.list6
-rw-r--r--Examples/python/class/runme.py28
-rw-r--r--Examples/python/constants/runme.py28
-rw-r--r--Examples/python/contract/runme.py6
-rw-r--r--Examples/python/docstrings/runme.py2
-rw-r--r--Examples/python/doxygen/Makefile27
-rw-r--r--Examples/python/doxygen/example.cxx48
-rw-r--r--Examples/python/doxygen/example.dsp152
-rw-r--r--Examples/python/doxygen/example.h107
-rw-r--r--Examples/python/doxygen/example.i17
-rw-r--r--Examples/python/doxygen/runme.py28
-rw-r--r--Examples/python/enum/runme.py20
-rw-r--r--Examples/python/exception/example.h20
-rw-r--r--Examples/python/exception/example.i6
-rw-r--r--Examples/python/exception/runme.py28
-rw-r--r--Examples/python/exceptproxy/example.h11
-rw-r--r--Examples/python/exceptproxy/example.i37
-rw-r--r--Examples/python/exceptproxy/runme.py28
-rw-r--r--Examples/python/extend/runme.py26
-rw-r--r--Examples/python/funcptr/runme.py20
-rw-r--r--Examples/python/funcptr2/runme.py26
-rw-r--r--Examples/python/functor/runme.py4
-rw-r--r--Examples/python/import/runme.py78
-rw-r--r--Examples/python/import_packages/Makefile15
-rw-r--r--Examples/python/import_packages/from_init1/runme.py30
-rw-r--r--Examples/python/import_packages/from_init2/runme.py26
-rw-r--r--Examples/python/import_packages/from_init3/runme.py26
-rw-r--r--Examples/python/import_packages/module_is_init/Makefile15
-rw-r--r--Examples/python/import_packages/module_is_init/README18
-rw-r--r--Examples/python/import_packages/module_is_init/pkg1/Makefile20
-rw-r--r--Examples/python/import_packages/module_is_init/pkg1/foo.hpp10
-rw-r--r--Examples/python/import_packages/module_is_init/pkg1/foo.i5
-rw-r--r--Examples/python/import_packages/module_is_init/runme.py26
-rw-r--r--Examples/python/import_packages/namespace_pkg/nonpkg.py19
-rw-r--r--Examples/python/import_packages/namespace_pkg/normal.py20
-rw-r--r--Examples/python/import_packages/namespace_pkg/nstest.py30
-rw-r--r--Examples/python/import_packages/namespace_pkg/runme.py9
-rw-r--r--Examples/python/import_packages/namespace_pkg/split.py22
-rw-r--r--Examples/python/import_packages/namespace_pkg/zipsplit.py22
-rw-r--r--Examples/python/import_packages/relativeimport1/runme.py27
-rw-r--r--Examples/python/import_packages/relativeimport2/runme.py27
-rw-r--r--Examples/python/import_packages/relativeimport3/runme.py27
-rw-r--r--Examples/python/import_packages/same_modnames1/runme.py21
-rw-r--r--Examples/python/import_packages/same_modnames2/runme.py21
-rw-r--r--Examples/python/import_packages/split_modules/Makefile8
-rw-r--r--Examples/python/import_packages/split_modules/README3
-rw-r--r--Examples/python/import_packages/split_modules/vanilla/runme.py18
-rw-r--r--Examples/python/import_packages/split_modules/vanilla_split/Makefile4
-rw-r--r--Examples/python/import_packages/split_modules/vanilla_split/foo.i7
-rw-r--r--Examples/python/import_packages/split_modules/vanilla_split/runme.py18
-rw-r--r--Examples/python/import_template/runme.py78
-rw-r--r--Examples/python/index.html1
-rw-r--r--Examples/python/java/Example.java29
-rw-r--r--Examples/python/java/Makefile25
-rw-r--r--Examples/python/java/example.i13
-rw-r--r--Examples/python/java/runme.py16
-rw-r--r--Examples/python/multimap/example.i12
-rw-r--r--Examples/python/multimap/runme.py6
-rw-r--r--Examples/python/operator/example.i1
-rw-r--r--Examples/python/operator/runme.py14
-rw-r--r--Examples/python/performance/constructor/runme.py2
-rw-r--r--Examples/python/performance/func/runme.py2
-rw-r--r--Examples/python/performance/harness.py6
-rw-r--r--Examples/python/performance/hierarchy/runme.py2
-rw-r--r--Examples/python/performance/hierarchy_operator/runme.py2
-rw-r--r--Examples/python/performance/operator/runme.py2
-rw-r--r--Examples/python/pointer/runme.py18
-rw-r--r--Examples/python/reference/runme.py24
-rw-r--r--Examples/python/simple/runme.py6
-rw-r--r--Examples/python/smartptr/runme.py28
-rw-r--r--Examples/python/std_map/runme.py68
-rw-r--r--Examples/python/std_vector/example.h5
-rw-r--r--Examples/python/std_vector/runme.py12
-rw-r--r--Examples/python/template/runme.py8
-rw-r--r--Examples/python/variables/runme.py62
-rw-r--r--Examples/ruby/check.list1
-rw-r--r--Examples/ruby/exceptproxy/Makefile (renamed from Examples/ruby/exception_class/Makefile)0
-rw-r--r--Examples/ruby/exceptproxy/example.h (renamed from Examples/ruby/exception_class/example.h)8
-rw-r--r--Examples/ruby/exceptproxy/example.i (renamed from Examples/ruby/exception_class/example.i)3
-rw-r--r--Examples/ruby/exceptproxy/runme.rb (renamed from Examples/ruby/exception_class/runme.rb)0
-rw-r--r--Examples/ruby/free_function/runme.rb6
-rw-r--r--Examples/ruby/hashargs/example.i4
-rw-r--r--Examples/ruby/java/Example.java29
-rw-r--r--Examples/ruby/java/Makefile24
-rw-r--r--Examples/ruby/java/example.i9
-rw-r--r--Examples/ruby/java/runme.rb18
-rw-r--r--Examples/ruby/std_vector/example.h5
-rw-r--r--Examples/ruby/variables/runme.rb2
-rw-r--r--Examples/scilab/check.list1
-rw-r--r--[-rwxr-xr-x]Examples/scilab/matrix2/example.i0
-rw-r--r--Examples/scilab/std_list/runme.sci2
-rw-r--r--Examples/scilab/std_vector/example.h5
-rw-r--r--Examples/scilab/variables/runme.sci2
-rw-r--r--Examples/tcl/check.list1
-rw-r--r--Examples/tcl/java/Example.java29
-rw-r--r--Examples/tcl/java/Makefile24
-rw-r--r--Examples/tcl/java/example.i8
-rw-r--r--Examples/tcl/java/runme.tcl15
-rw-r--r--Examples/tcl/std_vector/example.h5
-rw-r--r--Examples/tcl/variables/runme.tcl2
-rw-r--r--Examples/test-suite/README2
-rw-r--r--Examples/test-suite/allprotected.i4
-rw-r--r--Examples/test-suite/autodoc.i53
-rw-r--r--Examples/test-suite/catches.i8
-rw-r--r--Examples/test-suite/ccomplextest.i81
-rw-r--r--Examples/test-suite/class_scope_namespace.i160
-rw-r--r--Examples/test-suite/common.mk118
-rw-r--r--Examples/test-suite/complextest.i53
-rw-r--r--Examples/test-suite/constant_directive.i10
-rw-r--r--Examples/test-suite/constructor_copy.i8
-rw-r--r--Examples/test-suite/cplusplus_throw.i10
-rw-r--r--Examples/test-suite/cpp11_alias_nested_template_scoping.i45
-rw-r--r--Examples/test-suite/cpp11_alignment.i3
-rw-r--r--Examples/test-suite/cpp11_alternate_function_syntax.i23
-rw-r--r--Examples/test-suite/cpp11_constexpr.i19
-rw-r--r--Examples/test-suite/cpp11_default_delete.i14
-rw-r--r--Examples/test-suite/cpp11_directors.i16
-rw-r--r--Examples/test-suite/cpp11_final_directors.i33
-rw-r--r--Examples/test-suite/cpp11_final_override.i40
-rw-r--r--Examples/test-suite/cpp11_hash_tables.i32
-rw-r--r--Examples/test-suite/cpp11_initializer_list.i22
-rw-r--r--Examples/test-suite/cpp11_lambda_functions.i44
-rw-r--r--Examples/test-suite/cpp11_noexcept.i11
-rw-r--r--Examples/test-suite/cpp11_raw_string_literals.i45
-rw-r--r--Examples/test-suite/cpp11_ref_qualifiers.i226
-rw-r--r--Examples/test-suite/cpp11_ref_qualifiers_rvalue_unignore.i15
-rw-r--r--Examples/test-suite/cpp11_ref_qualifiers_typemaps.i74
-rw-r--r--Examples/test-suite/cpp11_rvalue_reference2.i24
-rw-r--r--Examples/test-suite/cpp11_rvalue_reference3.i32
-rw-r--r--Examples/test-suite/cpp11_shared_ptr_const.i57
-rw-r--r--Examples/test-suite/cpp11_shared_ptr_nullptr_in_containers.i50
-rw-r--r--Examples/test-suite/cpp11_shared_ptr_overload.i89
-rw-r--r--Examples/test-suite/cpp11_shared_ptr_template_upcast.i88
-rw-r--r--Examples/test-suite/cpp11_shared_ptr_upcast.i188
-rw-r--r--Examples/test-suite/cpp11_static_assert.i24
-rw-r--r--Examples/test-suite/cpp11_std_array.i (renamed from Examples/test-suite/cpp11_li_std_array.i)2
-rw-r--r--Examples/test-suite/cpp11_std_unordered_map.i11
-rw-r--r--Examples/test-suite/cpp11_std_unordered_multimap.i7
-rw-r--r--Examples/test-suite/cpp11_std_unordered_multiset.i5
-rw-r--r--Examples/test-suite/cpp11_std_unordered_set.i7
-rw-r--r--Examples/test-suite/cpp11_template_explicit.i15
-rw-r--r--Examples/test-suite/cpp11_template_typedefs.i4
-rw-r--r--Examples/test-suite/cpp11_thread_local.i2
-rw-r--r--Examples/test-suite/cpp11_type_aliasing.i2
-rw-r--r--Examples/test-suite/cpp14_binary_integer_literals.i31
-rw-r--r--Examples/test-suite/cpp17_hex_floating_literals.i43
-rw-r--r--Examples/test-suite/cpp17_nested_namespaces.i199
-rw-r--r--Examples/test-suite/cpp17_nspace_nested_namespaces.i13
-rw-r--r--Examples/test-suite/cpp17_u8_char_literals.i26
-rw-r--r--Examples/test-suite/cpp_broken.i12
-rw-r--r--Examples/test-suite/cpp_namespace.i4
-rw-r--r--Examples/test-suite/cpp_parameters.i46
-rw-r--r--Examples/test-suite/cpp_static.i3
-rw-r--r--Examples/test-suite/csharp/Makefile.in13
-rw-r--r--Examples/test-suite/csharp/allprotected_runme.cs14
-rw-r--r--Examples/test-suite/csharp/complextest_runme.cs43
-rw-r--r--Examples/test-suite/csharp/cpp11_shared_ptr_template_upcast_runme.cs15
-rw-r--r--Examples/test-suite/csharp/cpp11_std_array_runme.cs (renamed from Examples/test-suite/csharp/cpp11_li_std_array_runme.cs)20
-rw-r--r--Examples/test-suite/csharp/cpp17_nested_namespaces_runme.cs25
-rw-r--r--Examples/test-suite/csharp/cpp17_nspace_nested_namespaces_runme.cs25
-rw-r--r--Examples/test-suite/csharp/csharp_director_typemaps_runme.cs53
-rw-r--r--Examples/test-suite/csharp/csharp_lib_arrays_bool_runme.cs90
-rw-r--r--Examples/test-suite/csharp/director_basic_runme.cs54
-rw-r--r--Examples/test-suite/csharp/director_classes_runme.cs13
-rw-r--r--Examples/test-suite/csharp/director_smartptr_runme.cs29
-rw-r--r--Examples/test-suite/csharp/director_void_runme.cs6
-rw-r--r--Examples/test-suite/csharp/li_boost_shared_ptr_director_runme.cs111
-rw-r--r--Examples/test-suite/csharp/li_std_auto_ptr_runme.cs7
-rw-r--r--Examples/test-suite/csharp/li_std_list_runme.cs402
-rw-r--r--Examples/test-suite/csharp/li_std_map_runme.cs16
-rw-r--r--Examples/test-suite/csharp/li_std_set_runme.cs105
-rw-r--r--Examples/test-suite/csharp/li_std_vector_runme.cs62
-rw-r--r--Examples/test-suite/csharp/li_std_wstring_runme.cs186
-rw-r--r--Examples/test-suite/csharp/nested_in_template_runme.cs10
-rw-r--r--Examples/test-suite/csharp/nested_inheritance_interface_runme.cs36
-rw-r--r--Examples/test-suite/csharp/preproc_constants_c_runme.cs6
-rw-r--r--Examples/test-suite/csharp/preproc_constants_runme.cs5
-rw-r--r--Examples/test-suite/csharp/proxycode_runme.cs33
-rw-r--r--Examples/test-suite/csharp_director_typemaps.i37
-rw-r--r--Examples/test-suite/csharp_exceptions.i34
-rw-r--r--Examples/test-suite/csharp_lib_arrays_bool.i78
-rw-r--r--Examples/test-suite/d/Makefile.in6
-rw-r--r--Examples/test-suite/d/director_classes_runme.1.d13
-rw-r--r--Examples/test-suite/d/director_classes_runme.2.d13
-rw-r--r--Examples/test-suite/d/li_boost_shared_ptr_director_runme.2.d114
-rw-r--r--Examples/test-suite/d/preproc_constants_c_runme.1.d5
-rw-r--r--Examples/test-suite/d/preproc_constants_c_runme.2.d5
-rw-r--r--Examples/test-suite/d/preproc_constants_runme.1.d5
-rw-r--r--Examples/test-suite/d/preproc_constants_runme.2.d5
-rw-r--r--Examples/test-suite/d/proxycode_runme.2.d41
-rw-r--r--Examples/test-suite/default_arg_expressions.i34
-rw-r--r--Examples/test-suite/default_args.i44
-rw-r--r--Examples/test-suite/default_args_c.i39
-rw-r--r--Examples/test-suite/derived_byvalue.i4
-rw-r--r--Examples/test-suite/destructor_methodmodifiers.i61
-rw-r--r--Examples/test-suite/director_basic.i52
-rw-r--r--Examples/test-suite/director_classes.i8
-rw-r--r--Examples/test-suite/director_comparison_operators.i23
-rw-r--r--Examples/test-suite/director_conversion_operators.i35
-rw-r--r--Examples/test-suite/director_exception.i67
-rw-r--r--Examples/test-suite/director_exception_catches.i25
-rw-r--r--Examples/test-suite/director_exception_nothrow.i28
-rw-r--r--Examples/test-suite/director_extend.i2
-rw-r--r--Examples/test-suite/director_overload.i4
-rw-r--r--Examples/test-suite/director_ownership.i72
-rw-r--r--Examples/test-suite/director_property.i4
-rw-r--r--Examples/test-suite/director_smartptr.i8
-rw-r--r--Examples/test-suite/director_thread.i87
-rw-r--r--Examples/test-suite/director_void.i4
-rw-r--r--Examples/test-suite/doxygen_alias.i22
-rw-r--r--Examples/test-suite/doxygen_basic_notranslate.i110
-rw-r--r--Examples/test-suite/doxygen_basic_translate.h5
-rw-r--r--Examples/test-suite/doxygen_basic_translate.i130
-rw-r--r--Examples/test-suite/doxygen_basic_translate_style2.i107
-rw-r--r--Examples/test-suite/doxygen_basic_translate_style3.i102
-rw-r--r--Examples/test-suite/doxygen_code_blocks.i62
-rw-r--r--Examples/test-suite/doxygen_ignore.i41
-rw-r--r--Examples/test-suite/doxygen_misc_constructs.h102
-rw-r--r--Examples/test-suite/doxygen_misc_constructs.i127
-rw-r--r--Examples/test-suite/doxygen_nested_class.i24
-rw-r--r--Examples/test-suite/doxygen_parsing.i141
-rw-r--r--Examples/test-suite/doxygen_parsing_enums.i40
-rw-r--r--Examples/test-suite/doxygen_parsing_enums_proper.i7
-rw-r--r--Examples/test-suite/doxygen_parsing_enums_simple.i6
-rw-r--r--Examples/test-suite/doxygen_parsing_enums_typesafe.i8
-rw-r--r--Examples/test-suite/doxygen_parsing_enums_typeunsafe.i6
-rw-r--r--Examples/test-suite/doxygen_translate.i266
-rw-r--r--Examples/test-suite/doxygen_translate_all_tags.i416
-rw-r--r--Examples/test-suite/doxygen_translate_links.i67
-rw-r--r--Examples/test-suite/enum_macro.i42
-rw-r--r--Examples/test-suite/errors/Makefile.in29
-rw-r--r--Examples/test-suite/errors/cpp_bad_global_memberptr.i6
-rw-r--r--Examples/test-suite/errors/cpp_bad_global_memberptr.stderr2
-rw-r--r--Examples/test-suite/errors/cpp_class_definition.i26
-rw-r--r--Examples/test-suite/errors/cpp_class_definition.stderr1
-rw-r--r--Examples/test-suite/errors/cpp_extra_brackets.i2
-rw-r--r--Examples/test-suite/errors/cpp_extra_brackets2.i2
-rw-r--r--Examples/test-suite/errors/cpp_final_destructor.stderr1
-rw-r--r--Examples/test-suite/errors/cpp_invalid_exponents1.i4
-rw-r--r--Examples/test-suite/errors/cpp_invalid_exponents1.stderr2
-rw-r--r--Examples/test-suite/errors/cpp_invalid_exponents2.i4
-rw-r--r--Examples/test-suite/errors/cpp_invalid_exponents2.stderr2
-rw-r--r--Examples/test-suite/errors/cpp_invalid_qualifiers.i43
-rw-r--r--Examples/test-suite/errors/cpp_invalid_qualifiers.stderr20
-rw-r--r--Examples/test-suite/errors/cpp_invalid_template.i9
-rw-r--r--Examples/test-suite/errors/cpp_invalid_template.stderr3
-rw-r--r--Examples/test-suite/errors/cpp_namespace_template_bad.i40
-rw-r--r--Examples/test-suite/errors/cpp_namespace_template_bad.stderr9
-rw-r--r--Examples/test-suite/errors/cpp_nested_namespace_alias.i34
-rw-r--r--Examples/test-suite/errors/cpp_nested_namespace_alias.stderr3
-rw-r--r--Examples/test-suite/errors/cpp_nested_template.stderr2
-rw-r--r--Examples/test-suite/errors/cpp_raw_string_termination.i4
-rw-r--r--Examples/test-suite/errors/cpp_raw_string_termination.stderr2
-rw-r--r--Examples/test-suite/errors/cpp_recursive_typedef.i2
-rw-r--r--Examples/test-suite/errors/cpp_refqualifier.i28
-rw-r--r--Examples/test-suite/errors/cpp_refqualifier.stderr6
-rw-r--r--Examples/test-suite/errors/cpp_shared_ptr.i2
-rw-r--r--Examples/test-suite/errors/cpp_template_duplicate_names.i51
-rw-r--r--Examples/test-suite/errors/cpp_template_duplicate_names.stderr14
-rw-r--r--Examples/test-suite/errors/cpp_template_friend.i2
-rw-r--r--Examples/test-suite/errors/cpp_template_scope.i57
-rw-r--r--Examples/test-suite/errors/cpp_template_scope.stderr11
-rw-r--r--Examples/test-suite/errors/cpp_using_type_aliasing.i13
-rw-r--r--Examples/test-suite/errors/cpp_using_type_aliasing.stderr0
-rw-r--r--Examples/test-suite/errors/doxygen_unknown_command.i6
-rw-r--r--Examples/test-suite/errors/doxygen_unknown_command.stderr1
-rw-r--r--Examples/test-suite/errors/pp_expressions_bad.i43
-rw-r--r--Examples/test-suite/errors/pp_expressions_bad.stderr19
-rw-r--r--Examples/test-suite/errors/pp_invalid_exponents.i7
-rw-r--r--Examples/test-suite/errors/pp_invalid_exponents.stderr6
-rw-r--r--Examples/test-suite/errors/pp_macro_missing_expression.i2
-rw-r--r--Examples/test-suite/errors/pp_missing_file.i2
-rw-r--r--Examples/test-suite/errors/pp_unknowndirective3.i14
-rw-r--r--Examples/test-suite/errors/pp_unknowndirective3.stderr4
-rw-r--r--Examples/test-suite/exception_order.i29
-rw-r--r--Examples/test-suite/exception_partial_info.i10
-rw-r--r--Examples/test-suite/extend.i4
-rw-r--r--Examples/test-suite/extend_template_method.i92
-rw-r--r--Examples/test-suite/extern_throws.i10
-rw-r--r--Examples/test-suite/features.i4
-rw-r--r--Examples/test-suite/friends.i7
-rw-r--r--Examples/test-suite/friends_template.i5
-rw-r--r--Examples/test-suite/funcptr_cpp.i3
-rw-r--r--Examples/test-suite/functors.i33
-rw-r--r--Examples/test-suite/global_immutable_vars.i33
-rw-r--r--Examples/test-suite/global_immutable_vars_cpp.i33
-rw-r--r--Examples/test-suite/go/Makefile.in164
-rw-r--r--Examples/test-suite/go/abstract_access_runme.go2
-rw-r--r--Examples/test-suite/go/abstract_typedef2_runme.go2
-rw-r--r--Examples/test-suite/go/abstract_typedef_runme.go2
-rw-r--r--Examples/test-suite/go/abstract_virtual_runme.go2
-rw-r--r--Examples/test-suite/go/argout_runme.go2
-rw-r--r--Examples/test-suite/go/array_member_runme.go2
-rw-r--r--Examples/test-suite/go/arrays_global_runme.go2
-rw-r--r--Examples/test-suite/go/char_binary_runme.go2
-rw-r--r--Examples/test-suite/go/class_ignore_runme.go2
-rw-r--r--Examples/test-suite/go/class_scope_weird_runme.go2
-rw-r--r--Examples/test-suite/go/compactdefaultargs_runme.go2
-rw-r--r--Examples/test-suite/go/constover_runme.go3
-rw-r--r--Examples/test-suite/go/constructor_copy_runme.go2
-rw-r--r--Examples/test-suite/go/contract_runme.go2
-rw-r--r--Examples/test-suite/go/cpp11_strongly_typed_enumerations_runme.go2
-rw-r--r--Examples/test-suite/go/cpp_enum_runme.go2
-rw-r--r--Examples/test-suite/go/cpp_namespace_runme.go2
-rw-r--r--Examples/test-suite/go/cpp_static_runme.go2
-rw-r--r--Examples/test-suite/go/default_args_runme.go2
-rw-r--r--Examples/test-suite/go/default_constructor_runme.go2
-rw-r--r--Examples/test-suite/go/director_alternating_runme.go2
-rw-r--r--Examples/test-suite/go/director_basic_runme.go2
-rw-r--r--Examples/test-suite/go/director_classic_runme.go2
-rw-r--r--Examples/test-suite/go/director_default_runme.go2
-rw-r--r--Examples/test-suite/go/director_detect_runme.go2
-rw-r--r--Examples/test-suite/go/director_enum_runme.go2
-rw-r--r--Examples/test-suite/go/director_exception_runme.go2
-rw-r--r--Examples/test-suite/go/director_extend_runme.go2
-rw-r--r--Examples/test-suite/go/director_finalizer_runme.go2
-rw-r--r--Examples/test-suite/go/director_frob_runme.go2
-rw-r--r--Examples/test-suite/go/director_nested_runme.go2
-rw-r--r--Examples/test-suite/go/director_profile_runme.go2
-rw-r--r--Examples/test-suite/go/director_protected_runme.go2
-rw-r--r--Examples/test-suite/go/director_string_runme.go2
-rw-r--r--Examples/test-suite/go/director_unroll_runme.go2
-rw-r--r--Examples/test-suite/go/disown_runme.go2
-rw-r--r--Examples/test-suite/go/dynamic_cast_runme.go2
-rw-r--r--Examples/test-suite/go/empty_c_runme.go2
-rw-r--r--Examples/test-suite/go/empty_runme.go2
-rw-r--r--Examples/test-suite/go/enum_template_runme.go2
-rw-r--r--Examples/test-suite/go/enums_runme.go2
-rw-r--r--Examples/test-suite/go/exception_order_runme.go2
-rw-r--r--Examples/test-suite/go/extend_placement_runme.go2
-rw-r--r--Examples/test-suite/go/extend_template_ns_runme.go2
-rw-r--r--Examples/test-suite/go/extend_template_runme.go2
-rw-r--r--Examples/test-suite/go/extend_variable_runme.go2
-rw-r--r--Examples/test-suite/go/extern_c_runme.go2
-rw-r--r--Examples/test-suite/go/friends_runme.go2
-rw-r--r--Examples/test-suite/go/fvirtual_runme.go2
-rw-r--r--Examples/test-suite/go/global_ns_arg_runme.go2
-rw-r--r--Examples/test-suite/go/go_director_inout_runme.go2
-rw-r--r--Examples/test-suite/go/go_inout_runme.go2
-rw-r--r--Examples/test-suite/go/go_subdir_import_runme.go6
-rw-r--r--Examples/test-suite/go/grouping_runme.go2
-rw-r--r--Examples/test-suite/go/import_nomodule_runme.go2
-rw-r--r--Examples/test-suite/go/imports_runme.go4
-rw-r--r--Examples/test-suite/go/inctest_runme.go2
-rw-r--r--Examples/test-suite/go/inherit_member_runme.go2
-rw-r--r--Examples/test-suite/go/inherit_missing_runme.go2
-rw-r--r--Examples/test-suite/go/input_runme.go2
-rw-r--r--Examples/test-suite/go/keyword_rename_c_runme.go2
-rw-r--r--Examples/test-suite/go/keyword_rename_runme.go2
-rw-r--r--Examples/test-suite/go/li_attribute_runme.go2
-rw-r--r--Examples/test-suite/go/li_carrays_cpp_runme.go2
-rw-r--r--Examples/test-suite/go/li_carrays_runme.go2
-rw-r--r--Examples/test-suite/go/li_cdata_cpp_runme.go2
-rw-r--r--Examples/test-suite/go/li_cdata_runme.go2
-rw-r--r--Examples/test-suite/go/li_cmalloc_runme.go2
-rw-r--r--Examples/test-suite/go/li_cpointer_cpp_runme.go2
-rw-r--r--Examples/test-suite/go/li_cpointer_runme.go2
-rw-r--r--Examples/test-suite/go/li_std_map_runme.go2
-rw-r--r--Examples/test-suite/go/li_std_vector_ptr_runme.go2
-rw-r--r--Examples/test-suite/go/member_pointer_runme.go2
-rw-r--r--Examples/test-suite/go/memberin_extend_c_runme.go2
-rw-r--r--Examples/test-suite/go/minherit_runme.go2
-rw-r--r--Examples/test-suite/go/mod_runme.go4
-rw-r--r--Examples/test-suite/go/multi_import_runme.go4
-rw-r--r--Examples/test-suite/go/namespace_class_runme.go2
-rw-r--r--Examples/test-suite/go/namespace_typemap_runme.go2
-rw-r--r--Examples/test-suite/go/namespace_virtual_method_runme.go2
-rw-r--r--Examples/test-suite/go/naturalvar_runme.go2
-rw-r--r--Examples/test-suite/go/nested_workaround_runme.go2
-rw-r--r--Examples/test-suite/go/overload_complicated_runme.go2
-rw-r--r--Examples/test-suite/go/overload_copy_runme.go2
-rw-r--r--Examples/test-suite/go/overload_extend2_runme.go2
-rw-r--r--Examples/test-suite/go/overload_extend_c_runme.go2
-rw-r--r--Examples/test-suite/go/overload_extend_runme.go2
-rw-r--r--Examples/test-suite/go/overload_polymorphic_runme.go2
-rw-r--r--Examples/test-suite/go/overload_rename_runme.go2
-rw-r--r--Examples/test-suite/go/overload_simple_runme.go2
-rw-r--r--Examples/test-suite/go/overload_subtype_runme.go2
-rw-r--r--Examples/test-suite/go/overload_template_fast_runme.go2
-rw-r--r--Examples/test-suite/go/overload_template_runme.go2
-rw-r--r--Examples/test-suite/go/preproc_runme.go2
-rw-r--r--Examples/test-suite/go/primitive_ref_runme.go2
-rw-r--r--Examples/test-suite/go/profiletest_runme.go2
-rw-r--r--Examples/test-suite/go/refcount_runme.go2
-rw-r--r--Examples/test-suite/go/reference_global_vars_runme.go2
-rw-r--r--Examples/test-suite/go/rename_scope_runme.go2
-rw-r--r--Examples/test-suite/go/rename_simple_runme.go2
-rw-r--r--Examples/test-suite/go/rename_strip_encoder_runme.go2
-rw-r--r--Examples/test-suite/go/ret_by_value_runme.go2
-rw-r--r--Examples/test-suite/go/return_const_value_runme.go2
-rw-r--r--Examples/test-suite/go/smart_pointer_extend_runme.go2
-rw-r--r--Examples/test-suite/go/smart_pointer_member_runme.go2
-rw-r--r--Examples/test-suite/go/smart_pointer_multi_runme.go2
-rw-r--r--Examples/test-suite/go/smart_pointer_multi_typedef_runme.go2
-rw-r--r--Examples/test-suite/go/smart_pointer_overload_runme.go2
-rw-r--r--Examples/test-suite/go/smart_pointer_rename_runme.go2
-rw-r--r--Examples/test-suite/go/smart_pointer_simple_runme.go2
-rw-r--r--Examples/test-suite/go/smart_pointer_templatevariables_runme.go2
-rw-r--r--Examples/test-suite/go/smart_pointer_typedef_runme.go2
-rw-r--r--Examples/test-suite/go/sneaky1_runme.go2
-rw-r--r--Examples/test-suite/go/special_variable_macros_runme.go2
-rw-r--r--Examples/test-suite/go/static_const_member_2_runme.go2
-rw-r--r--Examples/test-suite/go/struct_initialization_runme.go2
-rw-r--r--Examples/test-suite/go/struct_rename_runme.go2
-rw-r--r--Examples/test-suite/go/struct_value_runme.go2
-rw-r--r--Examples/test-suite/go/template_default_arg_runme.go2
-rw-r--r--Examples/test-suite/go/template_extend1_runme.go2
-rw-r--r--Examples/test-suite/go/template_extend2_runme.go2
-rw-r--r--Examples/test-suite/go/template_inherit_runme.go2
-rw-r--r--Examples/test-suite/go/template_ns4_runme.go2
-rw-r--r--Examples/test-suite/go/template_ns_runme.go2
-rw-r--r--Examples/test-suite/go/template_opaque_runme.go2
-rw-r--r--Examples/test-suite/go/template_ref_type_runme.go2
-rw-r--r--Examples/test-suite/go/template_rename_runme.go2
-rw-r--r--Examples/test-suite/go/template_static_runme.go2
-rw-r--r--Examples/test-suite/go/template_tbase_template_runme.go2
-rw-r--r--Examples/test-suite/go/template_type_namespace_runme.go2
-rw-r--r--Examples/test-suite/go/template_typedef_cplx3_runme.go2
-rw-r--r--Examples/test-suite/go/template_typedef_cplx4_runme.go2
-rw-r--r--Examples/test-suite/go/threads_exception_runme.go2
-rw-r--r--Examples/test-suite/go/typedef_class_runme.go2
-rw-r--r--Examples/test-suite/go/typedef_funcptr_runme.go29
-rw-r--r--Examples/test-suite/go/typedef_inherit_runme.go2
-rw-r--r--Examples/test-suite/go/typedef_scope_runme.go2
-rw-r--r--Examples/test-suite/go/typemap_namespace_runme.go2
-rw-r--r--Examples/test-suite/go/typemap_ns_using_runme.go2
-rw-r--r--Examples/test-suite/go/typemap_out_optimal_runme.go2
-rw-r--r--Examples/test-suite/go/typename_runme.go2
-rw-r--r--Examples/test-suite/go/unions_runme.go2
-rw-r--r--Examples/test-suite/go/using1_runme.go2
-rw-r--r--Examples/test-suite/go/using2_runme.go2
-rw-r--r--Examples/test-suite/go/using_composition_runme.go2
-rw-r--r--Examples/test-suite/go/using_extend_runme.go2
-rw-r--r--Examples/test-suite/go/using_inherit_runme.go2
-rw-r--r--Examples/test-suite/go/using_private_runme.go2
-rw-r--r--Examples/test-suite/go/using_protected_runme.go2
-rw-r--r--Examples/test-suite/go/varargs_overload_runme.go38
-rw-r--r--Examples/test-suite/go/varargs_runme.go2
-rw-r--r--Examples/test-suite/go/virtual_derivation_runme.go2
-rw-r--r--Examples/test-suite/go/virtual_poly_runme.go2
-rw-r--r--Examples/test-suite/go/voidtest_runme.go2
-rw-r--r--Examples/test-suite/go/wrapmacro_runme.go2
-rw-r--r--Examples/test-suite/go_subdir_import.list2
-rw-r--r--Examples/test-suite/guile/argout_runme.scm16
-rw-r--r--Examples/test-suite/guile/overload_complicated_runme.scm6
-rw-r--r--Examples/test-suite/guile/overload_null_runme.scm53
-rw-r--r--Examples/test-suite/ignore_parameter.i4
-rw-r--r--Examples/test-suite/ignore_template_constructor.i8
-rw-r--r--Examples/test-suite/import_fragments.i18
-rw-r--r--Examples/test-suite/import_fragments_a.i48
-rw-r--r--Examples/test-suite/import_fragments_b.i9
-rw-r--r--Examples/test-suite/imports_a.h8
-rw-r--r--Examples/test-suite/imports_b.h2
-rw-r--r--Examples/test-suite/insert_directive.h2
-rw-r--r--Examples/test-suite/insert_directive.i4
-rw-r--r--Examples/test-suite/intermediary_classname.i15
-rw-r--r--Examples/test-suite/java/CommentParser.java257
-rw-r--r--Examples/test-suite/java/Makefile.in33
-rw-r--r--Examples/test-suite/java/class_scope_namespace_runme.java59
-rw-r--r--Examples/test-suite/java/cpp11_alias_nested_template_scoping_runme.java32
-rw-r--r--Examples/test-suite/java/cpp11_initializer_list_runme.java21
-rw-r--r--Examples/test-suite/java/cpp11_raw_string_literals_runme.java67
-rw-r--r--Examples/test-suite/java/cpp11_ref_qualifiers_runme.java56
-rw-r--r--Examples/test-suite/java/cpp11_ref_qualifiers_rvalue_unignore_runme.java20
-rw-r--r--Examples/test-suite/java/cpp11_ref_qualifiers_typemaps_runme.java39
-rw-r--r--Examples/test-suite/java/cpp11_shared_ptr_overload_runme.java60
-rw-r--r--Examples/test-suite/java/cpp11_shared_ptr_template_upcast_runme.java24
-rw-r--r--Examples/test-suite/java/cpp11_std_array_runme.java (renamed from Examples/test-suite/java/cpp11_li_std_array_runme.java)22
-rw-r--r--Examples/test-suite/java/cpp11_std_unordered_map_runme.java122
-rw-r--r--Examples/test-suite/java/cpp11_std_unordered_set_runme.java75
-rw-r--r--Examples/test-suite/java/cpp11_template_typedefs_runme.java19
-rw-r--r--Examples/test-suite/java/cpp17_nested_namespaces_runme.java32
-rw-r--r--Examples/test-suite/java/cpp17_nspace_nested_namespaces_runme.java30
-rw-r--r--Examples/test-suite/java/director_classes_runme.java13
-rw-r--r--Examples/test-suite/java/director_exception_catches_runme.java35
-rw-r--r--Examples/test-suite/java/director_ownership_runme.java42
-rw-r--r--Examples/test-suite/java/director_smartptr_runme.java36
-rw-r--r--Examples/test-suite/java/director_string_runme.java4
-rw-r--r--Examples/test-suite/java/director_thread_runme.java6
-rw-r--r--Examples/test-suite/java/doxygen_alias_runme.java28
-rw-r--r--Examples/test-suite/java/doxygen_basic_notranslate_runme.java94
-rw-r--r--Examples/test-suite/java/doxygen_basic_translate_runme.java100
-rw-r--r--Examples/test-suite/java/doxygen_basic_translate_style2_runme.java93
-rw-r--r--Examples/test-suite/java/doxygen_basic_translate_style3_runme.java93
-rw-r--r--Examples/test-suite/java/doxygen_code_blocks_runme.java75
-rw-r--r--Examples/test-suite/java/doxygen_ignore_runme.java40
-rw-r--r--Examples/test-suite/java/doxygen_misc_constructs_runme.java198
-rw-r--r--Examples/test-suite/java/doxygen_nested_class_runme.java40
-rw-r--r--Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java58
-rw-r--r--Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java50
-rw-r--r--Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java59
-rw-r--r--Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java58
-rw-r--r--Examples/test-suite/java/doxygen_parsing_runme.java139
-rw-r--r--Examples/test-suite/java/doxygen_translate_all_tags_runme.java154
-rw-r--r--Examples/test-suite/java/doxygen_translate_links_runme.java61
-rw-r--r--Examples/test-suite/java/doxygen_translate_runme.java271
-rw-r--r--Examples/test-suite/java/enum_macro_runme.java24
-rw-r--r--Examples/test-suite/java/extend_template_method_runme.java63
-rw-r--r--Examples/test-suite/java/java_director_assumeoverride_runme.java2
-rw-r--r--Examples/test-suite/java/java_director_exception_feature_nspace_runme.java13
-rw-r--r--Examples/test-suite/java/java_director_exception_feature_runme.java13
-rw-r--r--Examples/test-suite/java/java_director_typemaps_ptr_runme.java200
-rw-r--r--Examples/test-suite/java/java_director_typemaps_runme.java151
-rw-r--r--Examples/test-suite/java/java_enums_runme.java6
-rw-r--r--Examples/test-suite/java/java_throws_runme.java22
-rw-r--r--Examples/test-suite/java/li_boost_shared_ptr_director_runme.java129
-rw-r--r--Examples/test-suite/java/li_std_list_runme.java180
-rw-r--r--Examples/test-suite/java/li_std_map_runme.java122
-rw-r--r--Examples/test-suite/java/li_std_set_runme.java90
-rw-r--r--Examples/test-suite/java/li_std_vector_runme.java159
-rw-r--r--Examples/test-suite/java/long_long_runme.java6
-rw-r--r--Examples/test-suite/java/member_pointer_const_runme.java60
-rw-r--r--Examples/test-suite/java/member_pointer_runme.java2
-rw-r--r--Examples/test-suite/java/namespace_chase_runme.java26
-rw-r--r--Examples/test-suite/java/namespace_template_runme.java32
-rw-r--r--Examples/test-suite/java/native_directive_runme.java22
-rw-r--r--Examples/test-suite/java/nested_inheritance_interface_runme.java32
-rw-r--r--Examples/test-suite/java/proxycode_runme.java42
-rw-r--r--Examples/test-suite/java/rename1_runme.java4
-rw-r--r--Examples/test-suite/java/rename2_runme.java4
-rw-r--r--Examples/test-suite/java/rename3_runme.java4
-rw-r--r--Examples/test-suite/java/rename4_runme.java4
-rw-r--r--Examples/test-suite/java/template_class_reuse_name_runme.java57
-rw-r--r--Examples/test-suite/java/template_default_cache_runme.java18
-rw-r--r--Examples/test-suite/java/template_parameters_global_scope_runme.java75
-rw-r--r--Examples/test-suite/java/template_partial_specialization_runme.java4
-rw-r--r--Examples/test-suite/java/template_partial_specialization_typedef_runme.java4
-rw-r--r--Examples/test-suite/java/template_using_directive_and_declaration_forward_runme.java10
-rw-r--r--Examples/test-suite/java/template_using_directive_typedef_runme.java31
-rw-r--r--Examples/test-suite/java/typedef_classforward_same_name_runme.java26
-rw-r--r--Examples/test-suite/java/typedef_funcptr_runme.java34
-rw-r--r--Examples/test-suite/java/typemap_template_parms_runme.java23
-rw-r--r--Examples/test-suite/java_director.i1
-rw-r--r--Examples/test-suite/java_director_assumeoverride.i4
-rw-r--r--Examples/test-suite/java_director_exception_feature.i37
-rw-r--r--Examples/test-suite/java_director_exception_feature_nspace.i35
-rw-r--r--Examples/test-suite/java_director_typemaps.i368
-rw-r--r--Examples/test-suite/java_director_typemaps_ptr.i433
-rw-r--r--Examples/test-suite/java_enums.i15
-rw-r--r--Examples/test-suite/java_throws.i33
-rw-r--r--Examples/test-suite/javascript/Makefile.in13
-rw-r--r--Examples/test-suite/javascript/class_scope_weird_runme.js11
-rw-r--r--Examples/test-suite/javascript/complextest_runme.js15
-rw-r--r--Examples/test-suite/javascript/integers_runme.js18
-rw-r--r--Examples/test-suite/javascript/li_typemaps_runme.js50
-rw-r--r--Examples/test-suite/javascript/native_directive_runme.js9
-rw-r--r--Examples/test-suite/javascript/null_pointer_runme.js2
-rw-r--r--Examples/test-suite/javascript/overload_null_runme.js49
-rw-r--r--Examples/test-suite/javascript/rename1_runme.js4
-rw-r--r--Examples/test-suite/javascript/rename2_runme.js4
-rw-r--r--Examples/test-suite/javascript/rename3_runme.js4
-rw-r--r--Examples/test-suite/javascript/rename4_runme.js4
-rw-r--r--Examples/test-suite/javascript/string_simple_runme.js2
-rw-r--r--Examples/test-suite/keyword_rename.i2
-rw-r--r--Examples/test-suite/kwargs_feature.i26
-rw-r--r--Examples/test-suite/li_attribute.i3
-rw-r--r--Examples/test-suite/li_boost_shared_ptr_bits.i4
-rw-r--r--Examples/test-suite/li_boost_shared_ptr_director.i138
-rw-r--r--Examples/test-suite/li_implicit.i5
-rw-r--r--Examples/test-suite/li_std_auto_ptr.i30
-rw-r--r--Examples/test-suite/li_std_containers_overload.i33
-rw-r--r--Examples/test-suite/li_std_deque.i4
-rw-r--r--Examples/test-suite/li_std_except.i40
-rw-r--r--Examples/test-suite/li_std_except_as_class.i11
-rw-r--r--Examples/test-suite/li_std_list.i58
-rw-r--r--Examples/test-suite/li_std_map.i25
-rw-r--r--Examples/test-suite/li_std_set.i44
-rw-r--r--Examples/test-suite/li_std_string.i31
-rw-r--r--Examples/test-suite/li_std_string_extra.i8
-rw-r--r--Examples/test-suite/li_std_vector.i4
-rw-r--r--Examples/test-suite/li_std_vector_back_reference.i14
-rw-r--r--Examples/test-suite/li_std_vector_extra.i16
-rw-r--r--Examples/test-suite/li_std_vector_ptr.i17
-rw-r--r--Examples/test-suite/li_std_wstring.i74
-rw-r--r--Examples/test-suite/li_std_wstring_inherit.i39
-rw-r--r--Examples/test-suite/li_typemaps.i6
-rw-r--r--Examples/test-suite/lua/Makefile.in7
-rw-r--r--Examples/test-suite/lua/abstract_access_runme.lua2
-rw-r--r--Examples/test-suite/lua/li_std_string_runme.lua4
-rw-r--r--Examples/test-suite/lua/li_typemaps_runme.lua4
-rw-r--r--Examples/test-suite/lua/lua_lightuserdata_runme.lua7
-rw-r--r--Examples/test-suite/lua/newobject2_runme.lua4
-rw-r--r--Examples/test-suite/lua/overload_complicated_runme.lua6
-rw-r--r--Examples/test-suite/lua/overload_null_runme.lua41
-rw-r--r--Examples/test-suite/lua_lightuserdata.i17
-rw-r--r--Examples/test-suite/member_funcptr_galore.i131
-rw-r--r--Examples/test-suite/member_pointer.i16
-rw-r--r--Examples/test-suite/member_pointer_const.i149
-rw-r--r--Examples/test-suite/minherit2.i4
-rw-r--r--Examples/test-suite/multiple_inheritance_interfaces.i29
-rw-r--r--Examples/test-suite/multiple_inheritance_shared_ptr.i6
-rw-r--r--Examples/test-suite/multivalue.i10
-rw-r--r--Examples/test-suite/mzscheme/Makefile.in62
-rw-r--r--Examples/test-suite/mzscheme/name_runme.scm2
-rw-r--r--Examples/test-suite/mzscheme/unions_runme.scm6
-rw-r--r--Examples/test-suite/name_warnings.i4
-rw-r--r--Examples/test-suite/namespace_chase.i36
-rw-r--r--Examples/test-suite/namespace_template.i40
-rw-r--r--Examples/test-suite/native_directive.i102
-rw-r--r--Examples/test-suite/nested.i83
-rw-r--r--Examples/test-suite/nested_in_template.i34
-rw-r--r--Examples/test-suite/nested_inheritance_interface.i20
-rw-r--r--Examples/test-suite/nested_structs.i4
-rw-r--r--Examples/test-suite/nested_template_base.i4
-rw-r--r--Examples/test-suite/newobject3.i25
-rw-r--r--Examples/test-suite/not_c_keywords.i13
-rw-r--r--Examples/test-suite/null_pointer.i4
-rw-r--r--Examples/test-suite/ocaml/Makefile.in100
-rw-r--r--Examples/test-suite/ocaml/abstract_access_runme.ml5
-rw-r--r--Examples/test-suite/ocaml/abstract_typedef2_runme.ml4
-rw-r--r--Examples/test-suite/ocaml/abstract_typedef_runme.ml6
-rw-r--r--Examples/test-suite/ocaml/abstract_virtual_runme.ml5
-rw-r--r--Examples/test-suite/ocaml/aggregate_runme.ml15
-rw-r--r--Examples/test-suite/ocaml/allowexcept_runme.ml7
-rw-r--r--Examples/test-suite/ocaml/cast_operator_runme.ml5
-rw-r--r--Examples/test-suite/ocaml/catches_runme.ml39
-rw-r--r--Examples/test-suite/ocaml/char_binary_runme.ml24
-rw-r--r--Examples/test-suite/ocaml/char_constant_runme.ml16
-rw-r--r--Examples/test-suite/ocaml/chartest_runme.ml25
-rw-r--r--Examples/test-suite/ocaml/class_scope_weird_runme.ml6
-rw-r--r--Examples/test-suite/ocaml/constover_runme.ml16
-rw-r--r--Examples/test-suite/ocaml/constructor_rename_runme.ml5
-rw-r--r--Examples/test-suite/ocaml/conversion_runme.ml9
-rw-r--r--Examples/test-suite/ocaml/cpp_nodefault_runme.ml17
-rw-r--r--Examples/test-suite/ocaml/cpp_static_runme.ml17
-rw-r--r--Examples/test-suite/ocaml/default_arg_values_runme.ml17
-rw-r--r--Examples/test-suite/ocaml/default_args_runme.ml58
-rw-r--r--Examples/test-suite/ocaml/director_default_runme.ml25
-rw-r--r--Examples/test-suite/ocaml/director_exception_catches_runme.ml15
-rw-r--r--Examples/test-suite/ocaml/director_exception_nothrow_runme.ml12
-rw-r--r--Examples/test-suite/ocaml/director_exception_runme.ml46
-rw-r--r--Examples/test-suite/ocaml/director_frob_runme.ml5
-rw-r--r--Examples/test-suite/ocaml/director_ignore_runme.ml18
-rw-r--r--Examples/test-suite/ocaml/director_pass_by_value_runme.ml24
-rw-r--r--Examples/test-suite/ocaml/director_unroll_runme.ml15
-rw-r--r--Examples/test-suite/ocaml/dynamic_cast_runme.ml9
-rw-r--r--Examples/test-suite/ocaml/exception_classname_runme.ml5
-rw-r--r--Examples/test-suite/ocaml/exception_order_runme.ml17
-rw-r--r--Examples/test-suite/ocaml/extend_constructor_destructor_runme.ml12
-rw-r--r--Examples/test-suite/ocaml/extend_placement_runme.ml53
-rw-r--r--Examples/test-suite/ocaml/extend_runme.ml26
-rw-r--r--Examples/test-suite/ocaml/extend_special_variables_runme.ml14
-rw-r--r--Examples/test-suite/ocaml/extend_template_runme.ml8
-rw-r--r--Examples/test-suite/ocaml/extend_typedef_class_runme.ml12
-rw-r--r--Examples/test-suite/ocaml/extern_c_runme.ml4
-rw-r--r--Examples/test-suite/ocaml/funcptr_cpp_runme.ml13
-rw-r--r--Examples/test-suite/ocaml/fvirtual_runme.ml10
-rw-r--r--Examples/test-suite/ocaml/global_ns_arg_runme.ml5
-rw-r--r--Examples/test-suite/ocaml/global_vars_runme.ml15
-rw-r--r--Examples/test-suite/ocaml/ignore_parameter_runme.ml20
-rw-r--r--Examples/test-suite/ocaml/inctest_runme.ml7
-rw-r--r--Examples/test-suite/ocaml/inherit_missing_runme.ml10
-rw-r--r--Examples/test-suite/ocaml/inout_runme.ml8
-rw-r--r--Examples/test-suite/ocaml/li_cpointer_cpp_runme.ml10
-rw-r--r--Examples/test-suite/ocaml/li_std_except_runme.ml18
-rw-r--r--Examples/test-suite/ocaml/li_std_vector_runme.ml23
-rw-r--r--Examples/test-suite/ocaml/memberin_extend_runme.ml10
-rw-r--r--Examples/test-suite/ocaml/multivalue_runme.ml8
-rw-r--r--Examples/test-suite/ocaml/namespace_virtual_method_runme.ml4
-rw-r--r--Examples/test-suite/ocaml/newobject2_runme.ml16
-rw-r--r--Examples/test-suite/ocaml/overload_bool_runme.ml26
-rw-r--r--Examples/test-suite/ocaml/overload_extend_runme.ml11
-rw-r--r--Examples/test-suite/ocaml/overload_method_runme.ml11
-rw-r--r--Examples/test-suite/ocaml/overload_numeric_runme.ml14
-rw-r--r--Examples/test-suite/ocaml/overload_polymorphic_runme.ml9
-rw-r--r--Examples/test-suite/ocaml/overload_rename_runme.ml7
-rw-r--r--Examples/test-suite/ocaml/overload_subtype_runme.ml8
-rw-r--r--Examples/test-suite/ocaml/overload_template_runme.ml60
-rw-r--r--Examples/test-suite/ocaml/primitive_ref_runme.ml20
-rw-r--r--Examples/test-suite/ocaml/reference_global_vars_runme.ml57
-rw-r--r--Examples/test-suite/ocaml/rename_predicates_runme.ml40
-rw-r--r--Examples/test-suite/ocaml/sizet_runme.ml10
-rw-r--r--Examples/test-suite/ocaml/special_variable_macros_runme.ml14
-rw-r--r--Examples/test-suite/ocaml/special_variables_runme.ml36
-rw-r--r--Examples/test-suite/ocaml/static_const_member_runme.ml9
-rw-r--r--Examples/test-suite/ocaml/string_simple_runme.ml9
-rw-r--r--Examples/test-suite/ocaml/struct_value_runme.ml11
-rw-r--r--Examples/test-suite/ocaml/swig_exception_runme.ml13
-rw-r--r--Examples/test-suite/ocaml/template_default_arg_overloaded_extend_runme.ml17
-rw-r--r--Examples/test-suite/ocaml/template_default_arg_runme.ml52
-rw-r--r--Examples/test-suite/ocaml/template_extend1_runme.ml8
-rw-r--r--Examples/test-suite/ocaml/template_extend2_runme.ml8
-rw-r--r--Examples/test-suite/ocaml/template_inherit_runme.ml22
-rw-r--r--Examples/test-suite/ocaml/template_opaque_runme.ml5
-rw-r--r--Examples/test-suite/ocaml/template_ref_type_runme.ml6
-rw-r--r--Examples/test-suite/ocaml/template_rename_runme.ml12
-rw-r--r--Examples/test-suite/ocaml/template_tbase_template_runme.ml5
-rw-r--r--Examples/test-suite/ocaml/throw_exception_runme.ml43
-rw-r--r--Examples/test-suite/ocaml/typedef_class_runme.ml13
-rw-r--r--Examples/test-suite/ocaml/typedef_classforward_same_name_runme.ml11
-rw-r--r--Examples/test-suite/ocaml/typedef_inherit_runme.ml11
-rw-r--r--Examples/test-suite/ocaml/typedef_mptr_runme.ml21
-rw-r--r--Examples/test-suite/ocaml/typedef_reference_runme.ml11
-rw-r--r--Examples/test-suite/ocaml/typemap_arrays_runme.ml4
-rw-r--r--Examples/test-suite/ocaml/typemap_delete_runme.ml5
-rw-r--r--Examples/test-suite/ocaml/types_directive_runme.ml14
-rw-r--r--Examples/test-suite/ocaml/unions_runme.ml24
-rw-r--r--Examples/test-suite/ocaml/using1_runme.ml4
-rw-r--r--Examples/test-suite/ocaml/using_extend_runme.ml12
-rw-r--r--Examples/test-suite/ocaml/using_inherit_runme.ml24
-rw-r--r--Examples/test-suite/ocaml/using_pointers_runme.ml10
-rw-r--r--Examples/test-suite/ocaml/using_private_runme.ml10
-rw-r--r--Examples/test-suite/ocaml/using_protected_runme.ml2
-rw-r--r--Examples/test-suite/ocaml/valuewrapper_runme.ml8
-rw-r--r--Examples/test-suite/ocaml/varargs_overload_runme.ml29
-rw-r--r--Examples/test-suite/ocaml/wrapmacro_runme.ml10
-rw-r--r--Examples/test-suite/octave/Makefile.in48
-rw-r--r--Examples/test-suite/octave/abstract_access_runme.m2
-rw-r--r--Examples/test-suite/octave/abstract_typedef_runme.m2
-rw-r--r--Examples/test-suite/octave/callback_runme.m18
-rw-r--r--Examples/test-suite/octave/class_ignore_runme.m2
-rw-r--r--Examples/test-suite/octave/class_scope_weird_runme.m2
-rw-r--r--Examples/test-suite/octave/compactdefaultargs_runme.m8
-rw-r--r--Examples/test-suite/octave/complextest_runme.m14
-rw-r--r--Examples/test-suite/octave/constructor_copy_runme.m8
-rw-r--r--Examples/test-suite/octave/default_args_runme.m8
-rw-r--r--Examples/test-suite/octave/director_abstract_runme.m6
-rw-r--r--Examples/test-suite/octave/director_basic_runme.m8
-rw-r--r--Examples/test-suite/octave/director_enum_runme.m2
-rw-r--r--Examples/test-suite/octave/director_nested_runme.m4
-rw-r--r--Examples/test-suite/octave/director_unroll_runme.m2
-rw-r--r--Examples/test-suite/octave/enum_template_runme.m4
-rw-r--r--Examples/test-suite/octave/enums_runme.m8
-rw-r--r--Examples/test-suite/octave/extend_template_ns_runme.m4
-rw-r--r--Examples/test-suite/octave/extend_template_runme.m4
-rw-r--r--Examples/test-suite/octave/extend_variable_runme.m2
-rw-r--r--Examples/test-suite/octave/friends_runme.m18
-rw-r--r--Examples/test-suite/octave/grouping_runme.m4
-rw-r--r--Examples/test-suite/octave/iadd_runme.m2
-rw-r--r--Examples/test-suite/octave/inout_runme.m10
-rw-r--r--Examples/test-suite/octave/inplaceadd_runme.m8
-rw-r--r--Examples/test-suite/octave/input_runme.m8
-rw-r--r--Examples/test-suite/octave/li_attribute_runme.m32
-rw-r--r--Examples/test-suite/octave/li_carrays_cpp_runme.m2
-rw-r--r--Examples/test-suite/octave/li_carrays_runme.m2
-rw-r--r--Examples/test-suite/octave/li_cmalloc_runme.m2
-rw-r--r--Examples/test-suite/octave/li_cpointer_cpp_runme.m2
-rw-r--r--Examples/test-suite/octave/li_cpointer_runme.m2
-rw-r--r--Examples/test-suite/octave/li_cstring_runme.m14
-rw-r--r--Examples/test-suite/octave/li_cwstring_runme.m18
-rw-r--r--Examples/test-suite/octave/li_factory_runme.m4
-rw-r--r--Examples/test-suite/octave/li_std_carray_runme.m6
-rw-r--r--Examples/test-suite/octave/li_std_containers_overload_runme.m37
-rw-r--r--Examples/test-suite/octave/li_std_set_runme.m26
-rw-r--r--Examples/test-suite/octave/li_std_stream_runme.m2
-rw-r--r--Examples/test-suite/octave/li_std_string_extra_runme.m10
-rw-r--r--Examples/test-suite/octave/li_std_wstream_runme.m2
-rw-r--r--Examples/test-suite/octave/li_std_wstring_runme.m95
-rw-r--r--Examples/test-suite/octave/multi_import_runme.m10
-rw-r--r--Examples/test-suite/octave/namespace_typemap_runme.m50
-rw-r--r--Examples/test-suite/octave/naturalvar_runme.m2
-rw-r--r--Examples/test-suite/octave/null_pointer_runme.m2
-rw-r--r--Examples/test-suite/octave/octave_cell_deref_runme.m4
-rw-r--r--Examples/test-suite/octave/overload_complicated_runme.m16
-rw-r--r--Examples/test-suite/octave/overload_extend2_runme.m16
-rw-r--r--Examples/test-suite/octave/overload_extend_c_runme.m10
-rw-r--r--Examples/test-suite/octave/overload_extend_runme.m10
-rw-r--r--Examples/test-suite/octave/overload_null_runme.m52
-rw-r--r--Examples/test-suite/octave/preproc_runme.m8
-rw-r--r--Examples/test-suite/octave/primitive_ref_runme.m26
-rw-r--r--Examples/test-suite/octave/reference_global_vars_runme.m34
-rw-r--r--Examples/test-suite/octave/rename_scope_runme.m4
-rw-r--r--Examples/test-suite/octave/ret_by_value_runme.m4
-rw-r--r--Examples/test-suite/octave/return_const_value_runme.m4
-rw-r--r--Examples/test-suite/octave/smart_pointer_extend_runme.m12
-rw-r--r--Examples/test-suite/octave/smart_pointer_member_runme.m10
-rw-r--r--Examples/test-suite/octave/smart_pointer_multi_runme.m4
-rw-r--r--Examples/test-suite/octave/smart_pointer_multi_typedef_runme.m4
-rw-r--r--Examples/test-suite/octave/smart_pointer_overload_runme.m12
-rw-r--r--Examples/test-suite/octave/smart_pointer_rename_runme.m6
-rw-r--r--Examples/test-suite/octave/smart_pointer_simple_runme.m4
-rw-r--r--Examples/test-suite/octave/smart_pointer_templatevariables_runme.m8
-rw-r--r--Examples/test-suite/octave/smart_pointer_typedef_runme.m4
-rw-r--r--Examples/test-suite/octave/static_const_member_2_runme.m2
-rw-r--r--Examples/test-suite/octave/std_containers_runme.m2
-rw-r--r--Examples/test-suite/octave/struct_value_runme.m4
-rw-r--r--Examples/test-suite/octave/swigobject_runme.m6
-rw-r--r--Examples/test-suite/octave/template_extend1_runme.m4
-rw-r--r--Examples/test-suite/octave/template_extend2_runme.m4
-rw-r--r--Examples/test-suite/octave/template_inherit_runme.m30
-rw-r--r--Examples/test-suite/octave/template_ns4_runme.m2
-rw-r--r--Examples/test-suite/octave/template_ns_runme.m8
-rw-r--r--Examples/test-suite/octave/template_tbase_template_runme.m2
-rw-r--r--Examples/test-suite/octave/template_typedef_cplx2_runme.m18
-rw-r--r--Examples/test-suite/octave/template_typedef_cplx_runme.m12
-rw-r--r--Examples/test-suite/octave/template_typedef_runme.m8
-rw-r--r--Examples/test-suite/octave/typemap_namespace_runme.m4
-rw-r--r--Examples/test-suite/octave/typemap_ns_using_runme.m2
-rw-r--r--Examples/test-suite/octave/types_directive_runme.m4
-rw-r--r--Examples/test-suite/octave/using1_runme.m2
-rw-r--r--Examples/test-suite/octave/using2_runme.m2
-rw-r--r--Examples/test-suite/octave/virtual_poly_runme.m12
-rw-r--r--Examples/test-suite/octave/voidtest_runme.m6
-rw-r--r--Examples/test-suite/octave_cell_deref.i2
-rw-r--r--Examples/test-suite/overload_arrays.i7
-rw-r--r--Examples/test-suite/overload_complicated.i29
-rw-r--r--Examples/test-suite/overload_copy.i4
-rw-r--r--Examples/test-suite/overload_method.i5
-rw-r--r--Examples/test-suite/overload_null.i52
-rw-r--r--Examples/test-suite/overload_simple.i7
-rw-r--r--Examples/test-suite/perl5/README2
-rw-r--r--Examples/test-suite/perl5/director_classes_runme.pl4
-rw-r--r--Examples/test-suite/perl5/global_vars_runme.pl8
-rw-r--r--Examples/test-suite/perl5/li_typemaps_runme.pl5
-rw-r--r--Examples/test-suite/perl5/overload_null_runme.pl44
-rw-r--r--Examples/test-suite/perl5/run-perl-test.pl2
-rw-r--r--Examples/test-suite/perl5/scilab_multivalue_runme.pl88
-rw-r--r--Examples/test-suite/php/Makefile.in2
-rw-r--r--Examples/test-suite/php/abstract_inherit_ok_runme.php2
-rw-r--r--Examples/test-suite/php/abstract_inherit_runme.php2
-rw-r--r--Examples/test-suite/php/add_link_runme.php8
-rw-r--r--Examples/test-suite/php/argout_runme.php4
-rw-r--r--Examples/test-suite/php/arrayptr_runme.php2
-rw-r--r--Examples/test-suite/php/arrays_global_runme.php18
-rw-r--r--Examples/test-suite/php/arrays_global_twodim_runme.php8
-rw-r--r--Examples/test-suite/php/arrays_runme.php8
-rw-r--r--Examples/test-suite/php/arrays_scope_runme.php6
-rw-r--r--Examples/test-suite/php/casts_runme.php6
-rw-r--r--Examples/test-suite/php/class_ignore_runme.php4
-rw-r--r--Examples/test-suite/php/cpp_basic_runme.php6
-rw-r--r--Examples/test-suite/php/cpp_static_runme.php6
-rw-r--r--Examples/test-suite/php/director_abstract_runme.php4
-rw-r--r--Examples/test-suite/php/director_basic_runme.php6
-rw-r--r--Examples/test-suite/php/director_classic_runme.php4
-rw-r--r--Examples/test-suite/php/director_default_runme.php4
-rw-r--r--Examples/test-suite/php/director_detect_runme.php4
-rw-r--r--Examples/test-suite/php/director_enum_runme.php4
-rw-r--r--Examples/test-suite/php/director_exception_runme.php4
-rw-r--r--Examples/test-suite/php/director_extend_runme.php4
-rw-r--r--Examples/test-suite/php/director_finalizer_runme.php6
-rw-r--r--Examples/test-suite/php/director_frob_runme.php6
-rw-r--r--Examples/test-suite/php/director_nested_runme.php4
-rw-r--r--Examples/test-suite/php/director_profile_runme.php4
-rw-r--r--Examples/test-suite/php/director_protected_runme.php6
-rw-r--r--Examples/test-suite/php/director_stl_runme.php4
-rw-r--r--Examples/test-suite/php/director_string_runme.php6
-rw-r--r--Examples/test-suite/php/director_thread_runme.php6
-rw-r--r--Examples/test-suite/php/director_unroll_runme.php11
-rw-r--r--Examples/test-suite/php/evil_diamond_prop_runme.php2
-rw-r--r--Examples/test-suite/php/exception_order_runme.php6
-rw-r--r--Examples/test-suite/php/grouping_runme.php6
-rw-r--r--Examples/test-suite/php/ignore_parameter_runme.php4
-rw-r--r--Examples/test-suite/php/import_nomodule_runme.php4
-rw-r--r--Examples/test-suite/php/li_carrays_cpp_runme.php6
-rw-r--r--Examples/test-suite/php/li_carrays_runme.php6
-rw-r--r--Examples/test-suite/php/li_factory_runme.php4
-rw-r--r--Examples/test-suite/php/li_std_string_runme.php3
-rw-r--r--Examples/test-suite/php/newobject1_runme.php4
-rw-r--r--Examples/test-suite/php/newobject3_runme.php18
-rw-r--r--Examples/test-suite/php/overload_null_runme.php46
-rw-r--r--Examples/test-suite/php/overload_rename_runme.php2
-rw-r--r--Examples/test-suite/php/php_iterator_runme.php4
-rw-r--r--Examples/test-suite/php/php_pragma_runme.php11
-rw-r--r--Examples/test-suite/php/prefix_runme.php4
-rw-r--r--Examples/test-suite/php/preproc_constants_c_runme.php3
-rw-r--r--Examples/test-suite/php/preproc_constants_runme.php3
-rw-r--r--Examples/test-suite/php/sym_runme.php2
-rw-r--r--Examples/test-suite/php/template_arg_typename_runme.php4
-rw-r--r--Examples/test-suite/php/template_construct_runme.php2
-rw-r--r--Examples/test-suite/php/tests.php74
-rw-r--r--Examples/test-suite/php/threads_exception_runme.php8
-rw-r--r--Examples/test-suite/php/typedef_reference_runme.php2
-rw-r--r--Examples/test-suite/php5/Makefile.in80
-rw-r--r--Examples/test-suite/php5/abstract_inherit_ok_runme.php12
-rw-r--r--Examples/test-suite/php5/abstract_inherit_runme.php14
-rw-r--r--Examples/test-suite/php5/add_link_runme.php22
-rw-r--r--Examples/test-suite/php5/argout_runme.php38
-rw-r--r--Examples/test-suite/php5/arrayptr_runme.php14
-rw-r--r--Examples/test-suite/php5/arrays_global_runme.php19
-rw-r--r--Examples/test-suite/php5/arrays_global_twodim_runme.php22
-rw-r--r--Examples/test-suite/php5/arrays_runme.php18
-rw-r--r--Examples/test-suite/php5/arrays_scope_runme.php16
-rw-r--r--Examples/test-suite/php5/callback_runme.php9
-rw-r--r--Examples/test-suite/php5/casts_runme.php18
-rw-r--r--Examples/test-suite/php5/char_strings_runme.php43
-rw-r--r--Examples/test-suite/php5/class_ignore_runme.php16
-rw-r--r--Examples/test-suite/php5/conversion_namespace_runme.php13
-rw-r--r--Examples/test-suite/php5/conversion_ns_template_runme.php10
-rw-r--r--Examples/test-suite/php5/conversion_runme.php13
-rw-r--r--Examples/test-suite/php5/cpp11_strongly_typed_enumerations_runme.php169
-rw-r--r--Examples/test-suite/php5/cpp_basic_runme.php20
-rw-r--r--Examples/test-suite/php5/cpp_static_runme.php14
-rw-r--r--Examples/test-suite/php5/director_abstract_runme.php62
-rw-r--r--Examples/test-suite/php5/director_basic_runme.php58
-rw-r--r--Examples/test-suite/php5/director_classic_runme.php150
-rw-r--r--Examples/test-suite/php5/director_default_runme.php20
-rw-r--r--Examples/test-suite/php5/director_detect_runme.php55
-rw-r--r--Examples/test-suite/php5/director_enum_runme.php25
-rw-r--r--Examples/test-suite/php5/director_exception_runme.php127
-rw-r--r--Examples/test-suite/php5/director_extend_runme.php24
-rw-r--r--Examples/test-suite/php5/director_finalizer_runme.php61
-rw-r--r--Examples/test-suite/php5/director_frob_runme.php19
-rw-r--r--Examples/test-suite/php5/director_nested_runme.php74
-rw-r--r--Examples/test-suite/php5/director_pass_by_value_runme.php24
-rw-r--r--Examples/test-suite/php5/director_profile_runme.php53
-rw-r--r--Examples/test-suite/php5/director_protected_runme.php70
-rw-r--r--Examples/test-suite/php5/director_stl_runme.php60
-rw-r--r--Examples/test-suite/php5/director_string_runme.php34
-rw-r--r--Examples/test-suite/php5/director_thread_runme.php32
-rw-r--r--Examples/test-suite/php5/director_unroll_runme.php29
-rw-r--r--Examples/test-suite/php5/enum_scope_template_runme.php15
-rw-r--r--Examples/test-suite/php5/evil_diamond_ns_runme.php18
-rw-r--r--Examples/test-suite/php5/evil_diamond_prop_runme.php38
-rw-r--r--Examples/test-suite/php5/evil_diamond_runme.php16
-rw-r--r--Examples/test-suite/php5/exception_order_runme.php39
-rw-r--r--Examples/test-suite/php5/extend_template_ns_runme.php12
-rw-r--r--Examples/test-suite/php5/extend_template_runme.php12
-rw-r--r--Examples/test-suite/php5/grouping_runme.php22
-rw-r--r--Examples/test-suite/php5/ignore_parameter_runme.php38
-rw-r--r--Examples/test-suite/php5/import_nomodule_runme.php20
-rw-r--r--Examples/test-suite/php5/li_carrays_cpp_runme.php22
-rw-r--r--Examples/test-suite/php5/li_carrays_runme.php22
-rw-r--r--Examples/test-suite/php5/li_factory_runme.php22
-rw-r--r--Examples/test-suite/php5/li_std_string_runme.php31
-rw-r--r--Examples/test-suite/php5/li_std_vector_member_var_runme.php30
-rw-r--r--Examples/test-suite/php5/newobject1_runme.php19
-rw-r--r--Examples/test-suite/php5/overload_rename_runme.php19
-rw-r--r--Examples/test-suite/php5/overload_return_type_runme.php13
-rw-r--r--Examples/test-suite/php5/php_iterator_runme.php24
-rw-r--r--Examples/test-suite/php5/pointer_reference_runme.php18
-rw-r--r--Examples/test-suite/php5/prefix_runme.php18
-rw-r--r--Examples/test-suite/php5/preproc_constants_c_runme.php66
-rw-r--r--Examples/test-suite/php5/preproc_constants_runme.php74
-rw-r--r--Examples/test-suite/php5/primitive_ref_runme.php34
-rw-r--r--Examples/test-suite/php5/rename_scope_runme.php16
-rw-r--r--Examples/test-suite/php5/skel.php15
-rw-r--r--Examples/test-suite/php5/smart_pointer_rename_runme.php27
-rw-r--r--Examples/test-suite/php5/swig_exception_runme.php33
-rw-r--r--Examples/test-suite/php5/sym_runme.php22
-rw-r--r--Examples/test-suite/php5/template_arg_typename_runme.php18
-rw-r--r--Examples/test-suite/php5/template_construct_runme.php11
-rw-r--r--Examples/test-suite/php5/tests.php237
-rw-r--r--Examples/test-suite/php5/threads_exception_runme.php43
-rw-r--r--Examples/test-suite/php5/typedef_reference_runme.php13
-rw-r--r--Examples/test-suite/php5/typemap_ns_using_runme.php9
-rw-r--r--Examples/test-suite/php5/using1_runme.php9
-rw-r--r--Examples/test-suite/php5/using2_runme.php9
-rw-r--r--Examples/test-suite/php5/valuewrapper_base_runme.php13
-rw-r--r--Examples/test-suite/php5/virtual_vs_nonvirtual_base_runme.php11
-rw-r--r--Examples/test-suite/php5/wrapmacro_runme.php12
-rw-r--r--Examples/test-suite/php_pragma.i6
-rw-r--r--Examples/test-suite/preproc.i80
-rw-r--r--Examples/test-suite/preproc_constants.i9
-rw-r--r--Examples/test-suite/preproc_gcc_output.h13
-rw-r--r--Examples/test-suite/preproc_gcc_output.i12
-rw-r--r--Examples/test-suite/primitive_types.i36
-rw-r--r--Examples/test-suite/proxycode.i141
-rw-r--r--Examples/test-suite/pure_virtual.i4
-rw-r--r--Examples/test-suite/python/Makefile.in108
-rw-r--r--Examples/test-suite/python/argcargvtest_runme.py13
-rw-r--r--Examples/test-suite/python/array_member_runme.py4
-rw-r--r--Examples/test-suite/python/autodoc_runme.py472
-rw-r--r--Examples/test-suite/python/callback_runme.py4
-rw-r--r--Examples/test-suite/python/ccomplextest_runme.py22
-rw-r--r--Examples/test-suite/python/char_binary_runme.py37
-rw-r--r--Examples/test-suite/python/comment_verifier.py26
-rw-r--r--Examples/test-suite/python/complextest_runme.py24
-rw-r--r--Examples/test-suite/python/constover_runme.py19
-rw-r--r--Examples/test-suite/python/contract_runme.py90
-rw-r--r--Examples/test-suite/python/cpp11_alternate_function_syntax_runme.py19
-rw-r--r--Examples/test-suite/python/cpp11_decltype_runme.py8
-rw-r--r--Examples/test-suite/python/cpp11_final_directors_runme.py11
-rw-r--r--Examples/test-suite/python/cpp11_hash_tables_runme.py60
-rw-r--r--Examples/test-suite/python/cpp11_null_pointer_constant_runme.py8
-rw-r--r--Examples/test-suite/python/cpp11_raw_string_literals_runme.py37
-rw-r--r--Examples/test-suite/python/cpp11_ref_qualifiers_runme.py45
-rw-r--r--Examples/test-suite/python/cpp11_ref_qualifiers_rvalue_unignore_runme.py4
-rw-r--r--Examples/test-suite/python/cpp11_result_of_runme.py8
-rw-r--r--Examples/test-suite/python/cpp11_rvalue_reference_runme.py8
-rw-r--r--Examples/test-suite/python/cpp11_shared_ptr_overload_runme.py45
-rw-r--r--Examples/test-suite/python/cpp11_shared_ptr_template_upcast_runme.py5
-rw-r--r--Examples/test-suite/python/cpp11_shared_ptr_upcast_runme.py63
-rw-r--r--Examples/test-suite/python/cpp11_std_array_runme.py (renamed from Examples/test-suite/python/cpp11_li_std_array_runme.py)16
-rw-r--r--Examples/test-suite/python/cpp11_uniform_initialization_runme.py8
-rw-r--r--Examples/test-suite/python/cpp14_binary_integer_literals_runme.py16
-rw-r--r--Examples/test-suite/python/cpp17_hex_floating_literals_runme.py28
-rw-r--r--Examples/test-suite/python/cpp17_nested_namespaces_runme.py18
-rw-r--r--Examples/test-suite/python/cpp17_u8_char_literals_runme.py10
-rw-r--r--Examples/test-suite/python/cpp_enum_runme.py12
-rw-r--r--Examples/test-suite/python/cpp_parameters_runme.py296
-rw-r--r--Examples/test-suite/python/cpp_static_runme.py51
-rw-r--r--Examples/test-suite/python/default_args_c_runme.py20
-rw-r--r--Examples/test-suite/python/default_args_runme.py62
-rw-r--r--Examples/test-suite/python/default_constructor_runme.py32
-rw-r--r--Examples/test-suite/python/director_abstract_runme.py20
-rw-r--r--Examples/test-suite/python/director_alternating_runme.py2
-rw-r--r--Examples/test-suite/python/director_basic_runme.py8
-rw-r--r--Examples/test-suite/python/director_comparison_operators_runme.py11
-rw-r--r--Examples/test-suite/python/director_detect_runme.py2
-rw-r--r--Examples/test-suite/python/director_exception_runme.py60
-rw-r--r--Examples/test-suite/python/director_extend_runme.py4
-rw-r--r--Examples/test-suite/python/director_frob_runme.py2
-rw-r--r--Examples/test-suite/python/director_nested_runme.py4
-rw-r--r--Examples/test-suite/python/director_profile_runme.py2
-rw-r--r--Examples/test-suite/python/director_protected_runme.py30
-rw-r--r--Examples/test-suite/python/director_smartptr_runme.py21
-rw-r--r--Examples/test-suite/python/director_string_runme.py6
-rw-r--r--Examples/test-suite/python/director_thread_runme.py3
-rw-r--r--Examples/test-suite/python/director_unroll_runme.py3
-rw-r--r--Examples/test-suite/python/director_wstring_runme.py18
-rw-r--r--Examples/test-suite/python/doxygen_alias_runme.py10
-rw-r--r--Examples/test-suite/python/doxygen_basic_notranslate_runme.py66
-rw-r--r--Examples/test-suite/python/doxygen_basic_translate_runme.py94
-rw-r--r--Examples/test-suite/python/doxygen_basic_translate_style2_runme.py82
-rw-r--r--Examples/test-suite/python/doxygen_basic_translate_style3_runme.py82
-rw-r--r--Examples/test-suite/python/doxygen_code_blocks_runme.py58
-rw-r--r--Examples/test-suite/python/doxygen_ignore_runme.py17
-rw-r--r--Examples/test-suite/python/doxygen_misc_constructs_runme.py143
-rw-r--r--Examples/test-suite/python/doxygen_parsing_runme.py66
-rw-r--r--Examples/test-suite/python/doxygen_translate_all_tags_runme.py319
-rw-r--r--Examples/test-suite/python/doxygen_translate_links_runme.py38
-rw-r--r--Examples/test-suite/python/doxygen_translate_runme.py260
-rw-r--r--Examples/test-suite/python/dynamic_cast_runme.py2
-rw-r--r--Examples/test-suite/python/exception_order_runme.py21
-rw-r--r--Examples/test-suite/python/extend_template_method_runme.py45
-rw-r--r--Examples/test-suite/python/funcptr_cpp_runme.py3
-rw-r--r--Examples/test-suite/python/functors_runme.py12
-rw-r--r--Examples/test-suite/python/fvirtual_runme.py2
-rw-r--r--Examples/test-suite/python/global_functions_runme.py10
-rw-r--r--Examples/test-suite/python/global_namespace_runme.py41
-rw-r--r--Examples/test-suite/python/global_vars_runme.py4
-rw-r--r--Examples/test-suite/python/ignore_parameter_runme.py23
-rw-r--r--Examples/test-suite/python/implicittest_runme.py25
-rw-r--r--Examples/test-suite/python/import_stl_runme.py2
-rw-r--r--Examples/test-suite/python/inctest_runme.py18
-rw-r--r--Examples/test-suite/python/inherit_missing_runme.py6
-rw-r--r--Examples/test-suite/python/inplaceadd_runme.py3
-rw-r--r--Examples/test-suite/python/keyword_rename_runme.py2
-rw-r--r--Examples/test-suite/python/kwargs_feature_runme.py43
-rw-r--r--Examples/test-suite/python/li_attribute_runme.py11
-rw-r--r--Examples/test-suite/python/li_attribute_template_runme.py3
-rw-r--r--Examples/test-suite/python/li_boost_shared_ptr_bits_runme.py9
-rw-r--r--Examples/test-suite/python/li_boost_shared_ptr_director_runme.py80
-rw-r--r--Examples/test-suite/python/li_boost_shared_ptr_runme.py4
-rw-r--r--Examples/test-suite/python/li_cstring_runme.py14
-rw-r--r--Examples/test-suite/python/li_cwstring_runme.py18
-rw-r--r--Examples/test-suite/python/li_implicit_runme.py6
-rw-r--r--Examples/test-suite/python/li_std_containers_int_runme.py49
-rw-r--r--Examples/test-suite/python/li_std_containers_overload_runme.py29
-rw-r--r--Examples/test-suite/python/li_std_map_runme.py32
-rw-r--r--Examples/test-suite/python/li_std_pair_runme.py47
-rw-r--r--Examples/test-suite/python/li_std_set_runme.py24
-rw-r--r--Examples/test-suite/python/li_std_stream_runme.py3
-rw-r--r--Examples/test-suite/python/li_std_string_extra_runme.py83
-rw-r--r--Examples/test-suite/python/li_std_vector_back_reference_runme.py10
-rw-r--r--Examples/test-suite/python/li_std_vector_enum_runme.py2
-rw-r--r--Examples/test-suite/python/li_std_vector_extra_runme.py40
-rw-r--r--Examples/test-suite/python/li_std_vector_ptr_runme.py10
-rw-r--r--Examples/test-suite/python/li_std_wstream_runme.py5
-rw-r--r--Examples/test-suite/python/li_std_wstring_inherit_runme.py44
-rw-r--r--Examples/test-suite/python/li_std_wstring_runme.py162
-rw-r--r--Examples/test-suite/python/member_pointer_const_runme.py51
-rw-r--r--Examples/test-suite/python/member_pointer_runme.py3
-rw-r--r--Examples/test-suite/python/minherit_runme.py40
-rw-r--r--Examples/test-suite/python/namespace_class_runme.py20
-rw-r--r--Examples/test-suite/python/nested_in_template_runme.py5
-rw-r--r--Examples/test-suite/python/nested_runme.py20
-rw-r--r--Examples/test-suite/python/not_c_keywords_runme.py7
-rw-r--r--Examples/test-suite/python/operator_overload_runme.py7
-rw-r--r--Examples/test-suite/python/overload_complicated_runme.py36
-rw-r--r--Examples/test-suite/python/overload_null_runme.py44
-rw-r--r--Examples/test-suite/python/overload_simple_runme.py50
-rw-r--r--Examples/test-suite/python/overload_subtype_runme.py4
-rw-r--r--Examples/test-suite/python/overload_template_fast_runme.py87
-rw-r--r--Examples/test-suite/python/overload_template_runme.py78
-rw-r--r--Examples/test-suite/python/pointer_reference_runme.py8
-rw-r--r--Examples/test-suite/python/preproc_gcc_output_runme.py5
-rw-r--r--Examples/test-suite/python/preproc_runme.py3
-rw-r--r--Examples/test-suite/python/primitive_ref_runme.py2
-rw-r--r--Examples/test-suite/python/primitive_types_runme.py217
-rw-r--r--Examples/test-suite/python/python_abstractbase_runme.py35
-rw-r--r--Examples/test-suite/python/python_abstractbase_runme3.py25
-rw-r--r--Examples/test-suite/python/python_append_runme.py23
-rw-r--r--Examples/test-suite/python/python_builtin_runme.py17
-rw-r--r--Examples/test-suite/python/python_destructor_exception_runme.py10
-rw-r--r--Examples/test-suite/python/python_docstring_runme.py2
-rw-r--r--Examples/test-suite/python/python_nondynamic_runme.py96
-rw-r--r--Examples/test-suite/python/python_overload_simple_cast_runme.py94
-rw-r--r--Examples/test-suite/python/python_pickle_runme.py14
-rw-r--r--Examples/test-suite/python/python_pybuf_runme3.py41
-rw-r--r--Examples/test-suite/python/python_pybuffer_runme.py70
-rw-r--r--Examples/test-suite/python/python_pythoncode_runme.py4
-rw-r--r--Examples/test-suite/python/python_richcompare_runme.py52
-rw-r--r--Examples/test-suite/python/python_strict_unicode_runme.py32
-rw-r--r--Examples/test-suite/python/reference_global_vars_runme.py4
-rw-r--r--Examples/test-suite/python/return_const_value_runme.py6
-rw-r--r--Examples/test-suite/python/smart_pointer_member_runme.py12
-rw-r--r--Examples/test-suite/python/smart_pointer_not_runme.py24
-rw-r--r--Examples/test-suite/python/std_containers_runme.py49
-rw-r--r--Examples/test-suite/python/struct_value_runme.py4
-rw-r--r--Examples/test-suite/python/swigobject_runme.py24
-rw-r--r--Examples/test-suite/python/template_class_reuse_name_runme.py42
-rw-r--r--Examples/test-suite/python/template_classes_runme.py8
-rw-r--r--Examples/test-suite/python/template_default_arg_runme.py40
-rw-r--r--Examples/test-suite/python/template_default_cache_runme.py9
-rw-r--r--Examples/test-suite/python/template_typedef_cplx2_runme.py63
-rw-r--r--Examples/test-suite/python/template_typedef_cplx_runme.py60
-rw-r--r--Examples/test-suite/python/template_typedef_runme.py9
-rw-r--r--Examples/test-suite/python/template_typemaps_typedef2_runme.py16
-rw-r--r--Examples/test-suite/python/template_typemaps_typedef_runme.py16
-rw-r--r--Examples/test-suite/python/template_using_directive_typedef_runme.py15
-rw-r--r--Examples/test-suite/python/threads_exception_runme.py16
-rw-r--r--Examples/test-suite/python/typedef_classforward_same_name_runme.py11
-rw-r--r--Examples/test-suite/python/typedef_funcptr_runme.py20
-rw-r--r--Examples/test-suite/python/typedef_inherit_runme.py8
-rw-r--r--Examples/test-suite/python/typedef_scope_runme.py4
-rw-r--r--Examples/test-suite/python/typemap_arrays_runme.py2
-rw-r--r--Examples/test-suite/python/typemap_template_typedef_runme.py32
-rw-r--r--Examples/test-suite/python/typename_runme.py8
-rw-r--r--Examples/test-suite/python/unicode_strings_runme.py35
-rw-r--r--Examples/test-suite/python/unions_runme.py16
-rw-r--r--Examples/test-suite/python/using_composition_runme.py18
-rw-r--r--Examples/test-suite/python/using_extend_runme.py12
-rw-r--r--Examples/test-suite/python/using_inherit_runme.py24
-rw-r--r--Examples/test-suite/python/using_private_runme.py6
-rw-r--r--Examples/test-suite/python/using_protected_runme.py2
-rw-r--r--Examples/test-suite/python/varargs_overload_runme.py50
-rw-r--r--Examples/test-suite/python/varargs_runme.py18
-rw-r--r--Examples/test-suite/python/virtual_derivation_runme.py2
-rw-r--r--Examples/test-suite/python_append.i26
-rw-r--r--Examples/test-suite/python_builtin.i32
-rw-r--r--Examples/test-suite/python_nondynamic.i11
-rw-r--r--Examples/test-suite/python_pybuffer.i (renamed from Examples/test-suite/python_pybuf.i)8
-rw-r--r--Examples/test-suite/python_pythoncode.i30
-rw-r--r--Examples/test-suite/python_varargs_typemap.i5
-rw-r--r--Examples/test-suite/r/Makefile.in17
-rw-r--r--Examples/test-suite/r/abstract_access_runme.R74
-rw-r--r--Examples/test-suite/r/enum_thorough_runme.R452
-rw-r--r--Examples/test-suite/r/overload_null_runme.R49
-rw-r--r--Examples/test-suite/r/r_memory_leak_runme.R26
-rw-r--r--Examples/test-suite/r/r_use_isnull_runme.R11
-rw-r--r--Examples/test-suite/r_memory_leak.i40
-rw-r--r--Examples/test-suite/r_use_isnull.i34
-rw-r--r--Examples/test-suite/redefined_not.i2
-rw-r--r--Examples/test-suite/register_par.i6
-rw-r--r--Examples/test-suite/rename.h6
-rw-r--r--Examples/test-suite/rename1.i7
-rw-r--r--Examples/test-suite/rename2.i2
-rw-r--r--Examples/test-suite/rename3.i2
-rw-r--r--Examples/test-suite/rename4.i12
-rw-r--r--Examples/test-suite/restrict_cplusplus.i3
-rw-r--r--Examples/test-suite/ruby/Makefile.in28
-rw-r--r--Examples/test-suite/ruby/cpp11_hash_tables_runme.rb61
-rw-r--r--Examples/test-suite/ruby/cpp11_shared_ptr_const_runme.rb9
-rw-r--r--Examples/test-suite/ruby/cpp11_shared_ptr_nullptr_in_containers_runme.rb16
-rw-r--r--Examples/test-suite/ruby/cpp11_shared_ptr_upcast_runme.rb60
-rw-r--r--Examples/test-suite/ruby/cpp11_std_array_runme.rb (renamed from Examples/test-suite/ruby/cpp11_li_std_array_runme.rb)4
-rw-r--r--Examples/test-suite/ruby/director_smartptr_runme.rb24
-rw-r--r--Examples/test-suite/ruby/global_immutable_vars_cpp_runme.rb48
-rw-r--r--Examples/test-suite/ruby/global_immutable_vars_runme.rb52
-rw-r--r--Examples/test-suite/ruby/li_boost_shared_ptr_director_runme.rb103
-rw-r--r--Examples/test-suite/ruby/li_std_auto_ptr_runme.rb27
-rw-r--r--Examples/test-suite/ruby/li_std_containers_overload_runme.rb44
-rw-r--r--Examples/test-suite/ruby/li_std_list_runme.rb8
-rw-r--r--Examples/test-suite/ruby/li_std_wstring_inherit_runme.rb12
-rw-r--r--Examples/test-suite/ruby/li_std_wstring_runme.rb59
-rw-r--r--Examples/test-suite/ruby/newobject1_runme.rb2
-rw-r--r--Examples/test-suite/ruby/newobject2_runme.rb4
-rw-r--r--Examples/test-suite/ruby/overload_null_runme.rb52
-rw-r--r--Examples/test-suite/ruby/ruby_alias_global_function_runme.rb20
-rw-r--r--Examples/test-suite/ruby/ruby_alias_method_runme.rb24
-rw-r--r--Examples/test-suite/ruby/ruby_alias_module_function_runme.rb26
-rw-r--r--Examples/test-suite/ruby/ruby_global_immutable_vars_cpp_runme.rb48
-rw-r--r--Examples/test-suite/ruby/ruby_global_immutable_vars_runme.rb52
-rw-r--r--Examples/test-suite/ruby/ruby_rdata_runme.rb7
-rw-r--r--Examples/test-suite/ruby/std_containers_runme.rb2
-rw-r--r--Examples/test-suite/ruby/swig_assert.rb22
-rw-r--r--Examples/test-suite/ruby_alias_global_function.i11
-rw-r--r--Examples/test-suite/ruby_alias_method.i26
-rw-r--r--Examples/test-suite/ruby_alias_module_function.i11
-rw-r--r--Examples/test-suite/ruby_global_immutable_vars.i34
-rw-r--r--Examples/test-suite/ruby_global_immutable_vars_cpp.i32
-rw-r--r--Examples/test-suite/ruby_rdata.i20
-rw-r--r--Examples/test-suite/schemerunme/reference_global_vars.scm8
-rw-r--r--Examples/test-suite/scilab/Makefile.in2
-rw-r--r--Examples/test-suite/scilab/li_std_container_typemaps_runme.sci4
-rw-r--r--Examples/test-suite/scilab/li_std_deque_runme.sci2
-rw-r--r--Examples/test-suite/scilab/null_pointer_runme.sci2
-rw-r--r--Examples/test-suite/scilab/overload_null_runme.sci45
-rw-r--r--Examples/test-suite/scilab/scilab_li_matrix_runme.sci6
-rw-r--r--Examples/test-suite/scilab/throw_exception_runme.sci10
-rw-r--r--Examples/test-suite/scilab/varargs_overload_runme.sci22
-rw-r--r--Examples/test-suite/simutry.i6
-rw-r--r--Examples/test-suite/smart_pointer_namespace2.i13
-rw-r--r--Examples/test-suite/smart_pointer_overload.i4
-rw-r--r--Examples/test-suite/static_const_member_2.i4
-rw-r--r--Examples/test-suite/std_containers.i4
-rw-r--r--Examples/test-suite/stl_no_default_constructor.i19
-rw-r--r--Examples/test-suite/string_simple.i4
-rw-r--r--Examples/test-suite/tcl/null_pointer_runme.tcl2
-rw-r--r--Examples/test-suite/tcl/overload_null_runme.tcl52
-rw-r--r--Examples/test-suite/template_class_reuse_name.i132
-rw-r--r--Examples/test-suite/template_default_cache.i35
-rw-r--r--Examples/test-suite/template_default_class_parms.i4
-rw-r--r--Examples/test-suite/template_default_class_parms_typedef.i4
-rw-r--r--Examples/test-suite/template_empty_inherit.i34
-rw-r--r--Examples/test-suite/template_nested_typemaps.i33
-rw-r--r--Examples/test-suite/template_opaque.i3
-rw-r--r--Examples/test-suite/template_parameters_global_scope.i133
-rw-r--r--Examples/test-suite/template_partial_specialization.i20
-rw-r--r--Examples/test-suite/template_partial_specialization_typedef.i20
-rw-r--r--Examples/test-suite/template_typedef_class_template.i4
-rw-r--r--Examples/test-suite/template_typedef_cplx5.i2
-rw-r--r--Examples/test-suite/template_typemaps.i4
-rw-r--r--Examples/test-suite/template_typemaps_typedef.i4
-rw-r--r--Examples/test-suite/template_typemaps_typedef2.i4
-rw-r--r--Examples/test-suite/template_using_directive_typedef.i44
-rw-r--r--Examples/test-suite/template_virtual.i2
-rw-r--r--Examples/test-suite/threads_exception.i22
-rw-r--r--Examples/test-suite/throw_exception.i30
-rw-r--r--Examples/test-suite/typedef_classforward_same_name.i15
-rw-r--r--Examples/test-suite/typedef_funcptr.i10
-rw-r--r--Examples/test-suite/typemap_delete.i4
-rw-r--r--Examples/test-suite/typemap_template.i26
-rw-r--r--Examples/test-suite/typemap_template_parms.i41
-rw-r--r--Examples/test-suite/typemap_template_typedef.i66
-rw-r--r--Examples/test-suite/unicode_strings.i2
-rw-r--r--Examples/test-suite/using_pointers.i8
-rw-r--r--Examples/test-suite/valuewrapper_opaque.i4
-rw-r--r--Examples/test-suite/varargs_overload.i44
-rw-r--r--Examples/test-suite/virtual_derivation.i1
-rw-r--r--Examples/test-suite/virtual_poly.i4
1443 files changed, 26119 insertions, 10453 deletions
diff --git a/Examples/Makefile.in b/Examples/Makefile.in
index 4db8c4c63..3f6140b5e 100644
--- a/Examples/Makefile.in
+++ b/Examples/Makefile.in
@@ -58,6 +58,7 @@ INTERFACE =
INTERFACEDIR =
INTERFACEPATH = $(SRCDIR)$(INTERFACEDIR)$(INTERFACE)
SWIGOPT =
+PCHSUPPORT = @PCHSUPPORT@
# SWIG_LIB_DIR and SWIGEXE must be explicitly set by Makefiles using this Makefile
SWIG_LIB_DIR = ./Lib
@@ -282,7 +283,7 @@ perl5_static_cpp: $(SRCDIR_SRCS)
# -----------------------------------------------------------------
perl5_run:
- $(RUNTOOL) $(PERL) $(PERL5_SCRIPT) $(RUNPIPE)
+ $(RUNTOOL) $(PERL) -I. $(PERL5_SCRIPT) $(RUNPIPE)
# -----------------------------------------------------------------
# Version display
@@ -334,8 +335,8 @@ else
SWIGOPTPY3 = -py3
endif
-PEP8 = @PEP8@
-PEP8_FLAGS = --ignore=E402,E501,E30,W291,W391
+PYCODESTYLE = @PYCODESTYLE@
+PYCODESTYLE_FLAGS = --ignore=E252,E30,E402,E501,E731,W291,W391
# ----------------------------------------------------------------
# Build a C dynamically loadable module
@@ -380,17 +381,11 @@ python_static_cpp: $(SRCDIR_SRCS)
# Running a Python example
# -----------------------------------------------------------------
-ifeq (,$(PY3))
- PYSCRIPT = $(RUNME).py
-else
- PYSCRIPT = $(RUNME)3.py
-endif
-
-PY2TO3 = 2to3 `2to3 -l | grep -v -E "Available|import$$" | awk '{print "-f "$$0}'`
+PYSCRIPT = $(RUNME).py
python_run: $(PYSCRIPT)
-ifneq (,$(PEP8))
- $(COMPILETOOL) $(PEP8) $(PEP8_FLAGS) $(PYSCRIPT)
+ifneq (,$(PYCODESTYLE))
+ $(COMPILETOOL) $(PYCODESTYLE) $(PYCODESTYLE_FLAGS) $(PYSCRIPT)
endif
env PYTHONPATH=$$PWD $(RUNTOOL) $(PYTHON) $(PYSCRIPT) $(RUNPIPE)
@@ -399,10 +394,6 @@ $(RUNME).py: $(SRCDIR)$(RUNME).py
cp $< $@
endif
-$(RUNME)3.py: $(SRCDIR)$(RUNME).py
- cp $< $@
- $(PY2TO3) -w $@ >/dev/null 2>&1
-
# -----------------------------------------------------------------
# Version display
# -----------------------------------------------------------------
@@ -420,7 +411,6 @@ python_clean:
rm -f core @EXTRA_CLEAN@
rm -f *.@OBJEXT@ *@SO@ *$(PYTHON_SO)
rm -f $(TARGET).py
- if test -f $(SRCDIR)$(RUNME).py; then rm -f $(RUNME)3.py $(RUNME)3.py.bak; fi
case "x$(SRCDIR)" in x|x./);; *) rm -f $(RUNME).py;; esac
@@ -439,13 +429,36 @@ OCTAVE_SO = @OCTAVE_SO@
OCTAVE_SCRIPT = $(SRCDIR)$(RUNME).m
# ----------------------------------------------------------------
+# Pre-compile Octave headers, if supported
+# ----------------------------------------------------------------
+
+ifeq (yes,$(PCHSUPPORT))
+
+octave_precompile_headers:
+ echo "precompiling $(OCTHEADERS)"
+ cp -f $(OCTHEADERSSRC) $(OCTHEADERS)
+ if $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(INCLUDES) $(OCTAVE_CXX) $(OCTHEADERS); then \
+ : ; \
+ else \
+ rm -f $(OCTHEADERSGCH); \
+ exit 1; \
+ fi
+
+else
+
+octave_precompile_headers:
+ echo "precompiling Octave headers not supported"; exit 1
+
+endif
+
+# ----------------------------------------------------------------
# Build a C dynamically loadable module
# Note: Octave requires C++ compiler when compiling C wrappers
# ----------------------------------------------------------------
octave: $(SRCDIR_SRCS)
- $(SWIG) -octave $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
- $(CXX) -g -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(INCLUDES) $(OCTAVE_CXX)
+ $(SWIG) -octave $(SWIGOCTHDROPT) $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
+ $(CXX) -g -c $(IOCTHEADERS) $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(INCLUDES) $(OCTAVE_CXX)
$(CC) -g -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CSRCS) $(INCLUDES)
$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO)
@@ -454,8 +467,8 @@ octave: $(SRCDIR_SRCS)
# -----------------------------------------------------------------
octave_cpp: $(SRCDIR_SRCS)
- $(SWIG) -c++ -octave $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
- $(CXX) -g -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(OCTAVE_CXX)
+ $(SWIG) -c++ -octave $(SWIGOCTHDROPT) $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
+ $(CXX) -g -c $(IOCTHEADERS) $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(OCTAVE_CXX)
$(CXXSHARED) -g $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO)
# -----------------------------------------------------------------
@@ -463,7 +476,7 @@ octave_cpp: $(SRCDIR_SRCS)
# -----------------------------------------------------------------
octave_run:
- OCTAVE_HISTFILE=/dev/null $(RUNTOOL) $(OCTAVE) $(OCTAVE_SCRIPT) $(RUNPIPE)
+ env OCTAVE_PATH= OCTAVE_HISTFILE=/dev/null $(RUNTOOL) $(OCTAVE) $(OCTAVE_SCRIPT) $(RUNPIPE)
# -----------------------------------------------------------------
# Version display
@@ -481,6 +494,7 @@ octave_clean:
rm -f *_wrap* *~ .~* myoctave@EXEEXT@ *.pyc
rm -f core @EXTRA_CLEAN@
rm -f *.@OBJEXT@ *@SO@ *$(OCTAVE_SO)
+ rm -f $(OCTHEADERS) $(OCTHEADERSGCH)
##################################################################
##### GUILE ######
@@ -671,7 +685,7 @@ javascript_build: $(SRCDIR_SRCS)
javascript_build_cpp: $(SRCDIR_SRCS)
ifeq (node,$(JSENGINE))
sed -e 's|$$srcdir|./$(SRCDIR)|g' $(SRCDIR)binding.gyp.in > binding.gyp
- $(NODEGYP) --loglevel=silent configure build 1>>/dev/null
+ MAKEFLAGS= $(NODEGYP) --loglevel=silent configure build 1>>/dev/null
else
$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(JSINCLUDES)
$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
@@ -806,45 +820,6 @@ android_clean:
rm -rf obj
##################################################################
-##### MODULA3 ######
-##################################################################
-
-MODULA3_INCLUDE= @MODULA3INC@
-
-# ----------------------------------------------------------------
-# Build a modula3 dynamically loadable module (C)
-# ----------------------------------------------------------------
-
-modula3: $(SRCDIR_SRCS)
- $(SWIG) -modula3 $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
-
-modula3_cpp: $(SRCDIR_SRCS)
- $(SWIG) -modula3 -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
-
-# -----------------------------------------------------------------
-# Run modula3 example
-# -----------------------------------------------------------------
-
-modula3_run:
- $(RUNTOOL) false $(RUNPIPE)
-
-# -----------------------------------------------------------------
-# Version display
-# -----------------------------------------------------------------
-
-modula3_version:
- echo "Unknown modula3 version"
-
-# -----------------------------------------------------------------
-# Cleaning the modula3 examples
-# -----------------------------------------------------------------
-
-modula3_clean:
- rm -f *_wrap* *.i3 *.m3
- rm -f core @EXTRA_CLEAN@
- rm -f *.@OBJEXT@ *@SO@
-
-##################################################################
##### MZSCHEME ######
##################################################################
@@ -852,7 +827,7 @@ MZSCHEME = mzscheme
MZC = @MZC@
MZDYNOBJ = @MZDYNOBJ@
MZSCHEME_SO = @MZSCHEME_SO@
-MZSCHEME_SCRIPT = $(RUNME).scm
+MZSCHEME_SCRIPT = $(SRCDIR)$(RUNME).scm
# ----------------------------------------------------------------
# Build a C/C++ dynamically loadable module
@@ -860,12 +835,12 @@ MZSCHEME_SCRIPT = $(RUNME).scm
mzscheme: $(SRCDIR_SRCS)
$(SWIG) -mzscheme $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
- $(COMPILETOOL) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ISRCS) $(SRCDIR_SRCS)
+ $(COMPILETOOL) $(MZC) `echo " $(CPPFLAGS) $(INCLUDES) $(CFLAGS)" | sed 's/ -/ ++ccf -/g'` --cc $(ISRCS) $(SRCDIR_SRCS)
$(COMPILETOOL) $(MZC) --ld $(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS)
mzscheme_cpp: $(SRCDIR_SRCS)
$(SWIG) -mzscheme -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
- $(COMPILETOOL) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS)
+ env CFLAGS= $(COMPILETOOL) $(MZC) `echo " $(CPPFLAGS) $(INCLUDES) $(CXXFLAGS)" | sed 's/ -/ ++ccf -/g'` --cc $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS)
$(CXXSHARED) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $(LIBPREFIX)$(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) $(MZDYNOBJ) $(CPP_DLLIBS)
# -----------------------------------------------------------------
@@ -896,135 +871,88 @@ mzscheme_clean:
##### Ocaml #####
##################################################################
-OCC=@OCAMLC@
-OCAMLDLGEN=@OCAMLDLGEN@
-OCAMLFIND=@OCAMLFIND@
-OCAMLMKTOP=@OCAMLMKTOP@ $(SWIGWHERE)
+OCC=$(COMPILETOOL) @OCAMLC@
+OCC_WITH_PP=env TMPDIR=./localtmp $(OCC)
+# TMPDIR above is a workaround for some ocamlc versions, such as 4.05.0, which always create a temp file of the same name breaking parallel make (seemingly only when -pp is used)
+OCAMLDLGEN=$(COMPILETOOL) @OCAMLDLGEN@
+OCAMLFIND=$(COMPILETOOL) @OCAMLFIND@
+OCAMLMKTOP=$(COMPILETOOL) @OCAMLMKTOP@
NOLINK ?= false
OCAMLPP= -pp "camlp4o ./swigp4.cmo"
OCAMLP4WHERE=`$(COMPILETOOL) @CAMLP4@ -where`
-OCAMLCORE=\
- rm -rf swig.mli swig.ml swigp4.ml && \
- $(SWIG) -ocaml -co swig.mli 2>/dev/null && \
- $(SWIG) -ocaml -co swig.ml 2>/dev/null && \
- $(SWIG) -ocaml -co swigp4.ml 2>/dev/null && \
- $(OCC) -c swig.mli && \
- $(OCC) -c swig.ml && \
- $(OCC) -I $(OCAMLP4WHERE) -pp "camlp4o pa_extend.cmo q_MLast.cmo" \
- -c swigp4.ml
+
+ocaml_core:
+ mkdir -p ./localtmp
+ $(SWIG) -ocaml -co swig.mli 2>/dev/null
+ $(SWIG) -ocaml -co swig.ml 2>/dev/null
+ $(SWIG) -ocaml -co swigp4.ml 2>/dev/null
+ $(OCC) -c swig.mli
+ $(OCC) -c swig.ml
+ $(OCC_WITH_PP) -I $(OCAMLP4WHERE) -pp "camlp4o pa_extend.cmo q_MLast.cmo" -c swigp4.ml
ocaml_static: $(SRCDIR_SRCS)
- $(OCAMLCORE)
$(SWIG) -ocaml $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
$(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCDIR_SRCS)
$(OCC) -g -c $(INTERFACE:%.i=%.mli)
- $(OCC) -g -c $(INTERFACE:%.i=%.ml)
- test -z "$(PROGFILE)" || test -f "$(PROGFILE)" && \
- $(OCC) $(OCAMLPP) -c $(PROGFILE)
- $(NOLINK) || $(OCC) -g -ccopt -g -cclib -g -custom -o $(TARGET) \
- swig.cmo \
- $(INTERFACE:%.i=%.cmo) \
- $(PROGFILE:%.ml=%.cmo) \
- $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)"
+ $(OCC) -w -U -g -c $(INTERFACE:%.i=%.ml)
+ test -z "$(PROGFILE)" || $(OCC_WITH_PP) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE)
+ $(NOLINK) || $(OCC) -g -ccopt -g -cclib -g -custom -o $(RUNME) swig.cmo $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)"
ocaml_dynamic: $(SRCDIR_SRCS)
- $(OCAMLCORE)
$(SWIG) -ocaml $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
$(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCDIR_SRCS)
- $(CXXSHARED) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(CCSHARED) -o $(INTERFACE:%.i=%@SO@) \
- $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) $(LIBS)
- $(OCAMLDLGEN) $(INTERFACE:%.i=%.ml) $(INTERFACE:%.i=%@SO@) > \
- $(INTERFACE:%.i=%_dynamic.ml)
+ $(CXXSHARED) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(CCSHARED) -o $(INTERFACE:%.i=%@SO@) $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) $(LIBS)
+ $(OCAMLDLGEN) $(INTERFACE:%.i=%.ml) $(INTERFACE:%.i=%@SO@) > $(INTERFACE:%.i=%_dynamic.ml)
mv $(INTERFACE:%.i=%_dynamic.ml) $(INTERFACE:%.i=%.ml)
rm $(INTERFACE:%.i=%.mli)
$(OCAMLFIND) $(OCC) -g -c -package dl $(INTERFACE:%.i=%.ml)
- test -z "$(PROGFILE)" || test -f "$(PROGFILE)" && \
- $(OCC) $(OCAMLPP) -c $(PROGFILE)
- $(NOLINK) || $(OCAMLFIND) \
- $(OCC) -g -ccopt -g -cclib -g -custom -o $(TARGET) \
- swig.cmo \
- -package dl -linkpkg \
- $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo)
+ test -z "$(PROGFILE)" || $(OCC_WITH_PP) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE)
+ $(NOLINK) || $(OCAMLFIND) $(OCC) -g -ccopt -g -cclib -g -custom -o $(RUNME) swig.cmo -package dl -linkpkg $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo)
ocaml_static_toplevel: $(SRCDIR_SRCS)
- $(OCAMLCORE)
$(SWIG) -ocaml $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
$(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCDIR_SRCS)
$(OCC) -g -c $(INTERFACE:%.i=%.mli)
- $(OCC) -g -c $(INTERFACE:%.i=%.ml)
- test -z "$(PROGFILE)" || test -f "$(PROGFILE)" && \
- $(OCC) $(OCAMLPP) -c $(PROGFILE)
- $(NOLINK) || $(OCAMLMKTOP) \
- swig.cmo \
- -I $(OCAMLP4WHERE) camlp4o.cma swigp4.cmo \
- -g -ccopt -g -cclib -g -custom -o $(TARGET)_top \
- $(INTERFACE:%.i=%.cmo) \
- $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)"
+ $(OCC) -w -U -g -c $(INTERFACE:%.i=%.ml)
+ test -z "$(PROGFILE)" || $(OCC_WITH_PP) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE)
+ $(NOLINK) || $(OCAMLMKTOP) swig.cmo -I $(OCAMLP4WHERE) dynlink.cma camlp4o.cma swigp4.cmo -cclib "$(LIBS)" -g -ccopt -g -cclib -g -custom -o $(RUNME)_top $(INTERFACE:%.i=%.cmo) $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS)
ocaml_static_cpp: $(SRCDIR_SRCS)
- $(OCAMLCORE)
$(SWIG) -ocaml -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
- $(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
- $(ICXXSRCS:%.cxx=%.c) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS)
+ $(OCC) -cc '$(CXX) $(CPPFLAGS)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" $(ICXXSRCS:%.cxx=%.c) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS)
$(OCC) -g -c $(INTERFACE:%.i=%.mli)
- $(OCC) -g -c $(INTERFACE:%.i=%.ml)
- test -z "$(PROGFILE)" || test -f "$(PROGFILE)" && \
- $(OCC) $(OCAMLPP) -c $(PROGFILE)
- $(NOLINK) || $(OCC) -g -ccopt -g -cclib -g -custom -o $(TARGET) \
- swig.cmo \
- $(INTERFACE:%.i=%.cmo) \
- $(PROGFILE:%.ml=%.cmo) \
- $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \
- -cclib "$(LIBS)" -cc '$(CXX) -Wno-write-strings'
+ $(OCC) -w -U -g -c $(INTERFACE:%.i=%.ml)
+ test -z "$(PROGFILE)" || $(OCC_WITH_PP) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE)
+ $(NOLINK) || $(OCC) -g -ccopt -g -cclib -g -custom -o $(RUNME) swig.cmo $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)" -cc '$(CXX)'
ocaml_static_cpp_toplevel: $(SRCDIR_SRCS)
- $(OCAMLCORE)
$(SWIG) -ocaml -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
- $(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
- $(ICXXSRCS:%.cxx=%.c) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS)
+ $(OCC) -cc '$(CXX) $(CPPFLAGS)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" $(ICXXSRCS:%.cxx=%.c) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS)
$(OCC) -g -c $(INTERFACE:%.i=%.mli)
- $(OCC) -g -c $(INTERFACE:%.i=%.ml)
- test -z "$(PROGFILE)" || test -f "$(PROGFILE)" && \
- $(OCC) $(OCAMLPP) -c $(PROGFILE)
- $(NOLINK) || $(OCAMLMKTOP) \
- swig.cmo \
- -I $(OCAMLP4WHERE) dynlink.cma camlp4o.cma swigp4.cmo \
- -g -ccopt -g -cclib -g -custom -o $(TARGET)_top \
- $(INTERFACE:%.i=%.cmo) \
- $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \
- -cclib "$(LIBS)" -cc '$(CXX) -Wno-write-strings'
+ $(OCC) -w -U -g -c $(INTERFACE:%.i=%.ml)
+ test -z "$(PROGFILE)" || $(OCC_WITH_PP) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE)
+ $(NOLINK) || $(OCAMLMKTOP) -cc '$(CXX) $(CPPFLAGS)' swig.cmo -I $(OCAMLP4WHERE) dynlink.cma camlp4o.cma swigp4.cmo -cclib "$(LIBS)" -g -ccopt -g -cclib -g -custom -o $(RUNME)_top $(INTERFACE:%.i=%.cmo) $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS)
ocaml_dynamic_cpp: $(SRCDIR_SRCS)
- $(OCAMLCORE)
$(SWIG) -ocaml -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
- $(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
- $(ICXXSRCS:%.cxx=%.c) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) -ccopt -fPIC
- $(CXXSHARED) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $(INTERFACE:%.i=%@SO@) \
- $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \
- $(CPP_DLLIBS) $(LIBS)
- $(OCAMLDLGEN) $(INTERFACE:%.i=%.ml) $(INTERFACE:%.i=%@SO@) > \
- $(INTERFACE:%.i=%_dynamic.ml)
+ $(OCC) -cc '$(CXX) $(CPPFLAGS)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" $(ICXXSRCS:%.cxx=%.c) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) -ccopt -fPIC
+ $(CXXSHARED) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $(INTERFACE:%.i=%@SO@) $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) $(CPP_DLLIBS) $(LIBS)
+ $(OCAMLDLGEN) $(INTERFACE:%.i=%.ml) $(INTERFACE:%.i=%@SO@) > $(INTERFACE:%.i=%_dynamic.ml)
mv $(INTERFACE:%.i=%_dynamic.ml) $(INTERFACE:%.i=%.ml)
rm $(INTERFACE:%.i=%.mli)
$(OCAMLFIND) $(OCC) -g -c -package dl $(INTERFACE:%.i=%.ml)
- test -z "$(PROGFILE)" || test -f "$(PROGFILE)" && \
- $(OCC) $(OCAMLPP) -c $(PROGFILE)
- $(NOLINK) || $(OCAMLFIND) \
- swig.cmo \
- $(OCC) -cclib -export-dynamic -g -ccopt -g -cclib -g -custom \
- -o $(TARGET) \
- -package dl -linkpkg \
- $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) -cc '$(CXX) -Wno-write-strings'
+ test -z "$(PROGFILE)" || $(OCC_WITH_PP) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE)
+ $(NOLINK) || $(OCAMLFIND) swig.cmo $(OCC) -cclib -export-dynamic -g -ccopt -g -cclib -g -custom -o $(RUNME) -package dl -linkpkg $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) -cc '$(CXX)'
# -----------------------------------------------------------------
# Run ocaml example
# -----------------------------------------------------------------
ocaml_run:
- $(RUNTOOL) ./$(TARGET) $(RUNPIPE)
+ $(RUNTOOL) ./$(RUNME) $(RUNPIPE)
# -----------------------------------------------------------------
# Version display
@@ -1038,9 +966,10 @@ ocaml_version:
# -----------------------------------------------------------------
ocaml_clean:
- rm -f *_wrap* *~ .~* *.cmo *.cmi $(MLFILE) $(MLFILE)i swig.mli swig.cmi swig.ml swig.cmo swigp4.ml swigp4.cmo
+ rm -f *_wrap* *~ .~* *.cmo *.cmi *.mli $(TARGET).ml $(RUNME) $(RUNME)_top swig.ml swigp4.ml
rm -f core @EXTRA_CLEAN@
rm -f *.@OBJEXT@ *@SO@
+ rm -rf ./localtmp
##################################################################
##### RUBY ######
@@ -1116,56 +1045,6 @@ ruby_clean:
rm -f *.@OBJEXT@ *$(RUBY_SO)
##################################################################
-##### PHP5 ######
-##################################################################
-
-PHP5 = @PHP5@
-PHP5_INCLUDE = @PHP5INC@
-PHP5_SO = @PHP5_SO@
-PHP5_SCRIPT = $(SRCDIR)$(RUNME).php
-
-# -------------------------------------------------------------------
-# Build a PHP5 dynamically loadable module (C)
-# -------------------------------------------------------------------
-
-php5: $(SRCDIR_SRCS)
- $(SWIG) -php5 $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
- $(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES) $(PHP5_INCLUDE)
- $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(PHP5_SO)
-
-# --------------------------------------------------------------------
-# Build a PHP5 dynamically loadable module (C++)
-# --------------------------------------------------------------------
-
-php5_cpp: $(SRCDIR_SRCS)
- $(SWIG) -php5 -cppext cxx -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
- $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PHP5_INCLUDE)
- $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(PHP5_SO)
-
-# -----------------------------------------------------------------
-# Running a PHP5 example
-# -----------------------------------------------------------------
-
-php5_run:
- $(RUNTOOL) $(PHP5) -n -q -d extension_dir=. -d safe_mode=Off $(PHP5_SCRIPT) $(RUNPIPE)
-
-# -----------------------------------------------------------------
-# Version display
-# -----------------------------------------------------------------
-
-php5_version:
- $(PHP5) -v | head -n 1
-
-# -----------------------------------------------------------------
-# Cleaning the PHP5 examples
-# -----------------------------------------------------------------
-
-php5_clean:
- rm -f *_wrap* *~ .~* example.php php_example.h
- rm -f core @EXTRA_CLEAN@
- rm -f *.@OBJEXT@ *$(PHP5_SO)
-
-##################################################################
##### PHP7 ######
##################################################################
@@ -1216,194 +1095,6 @@ php_clean:
rm -f *.@OBJEXT@ *$(PHP_SO)
##################################################################
-##### Pike ######
-##################################################################
-
-# Make sure these locate your Pike installation
-PIKE = pike
-PIKE_CFLAGS = @PIKECCDLFLAGS@ -DHAVE_CONFIG_H
-PIKE_INCLUDE = @PIKEINCLUDE@
-PIKE_LIB = @PIKELIB@
-PIKE_DLNK = @PIKEDYNAMICLINKING@
-PIKE_LIBOPTS = @PIKELINK@ @LIBS@ $(SYSLIBS)
-PIKE_SCRIPT = $(RUNME).pike
-
-# ----------------------------------------------------------------
-# Build a C dynamically loadable module
-# ----------------------------------------------------------------
-
-pike: $(SRCDIR_SRCS)
- $(SWIG) -pike $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
- $(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(PIKE_CFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) $(PIKE_INCLUDE)
- $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(PIKE_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
-
-# -----------------------------------------------------------------
-# Build a C++ dynamically loadable module
-# -----------------------------------------------------------------
-
-pike_cpp: $(SRCDIR_SRCS)
- $(SWIG) -c++ -pike $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
- $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(PIKE_INCLUDE)
- $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(PIKE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
-
-# -----------------------------------------------------------------
-# Build statically linked Pike interpreter
-#
-# These should only be used in conjunction with the %include embed.i
-# library file
-# -----------------------------------------------------------------
-
-pike_static: $(SRCDIR_SRCS)
- $(SWIG) -pike -lembed.i $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
- $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(PIKE_CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) \
- $(PIKE_INCLUDE) $(LIBS) -L$(PIKE_LIB) $(PIKE_LIBOPTS) -o $(TARGET)
-
-pike_cpp_static: $(SRCDIR_SRCS)
- $(SWIG) -c++ -pike -lembed.i $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
- $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) \
- $(PIKE_INCLUDE) $(LIBS) -L$(PIKE_LIB) $(PIKE_LIBOPTS) -o $(TARGET)
-
-# -----------------------------------------------------------------
-# Run pike example
-# -----------------------------------------------------------------
-
-pike_run:
- $(RUNTOOL) $(PIKE) $(PIKE_SCRIPT) $(RUNPIPE)
-
-# -----------------------------------------------------------------
-# Version display
-# -----------------------------------------------------------------
-
-pike_version:
- $(PIKE) -v 2>&1 | head -n 1
-
-# -----------------------------------------------------------------
-# Cleaning the Pike examples
-# -----------------------------------------------------------------
-
-pike_clean:
- rm -f *_wrap* *~ .~* mypike@EXEEXT@
- rm -f core @EXTRA_CLEAN@
- rm -f *.@OBJEXT@ *@SO@
-
-
-##################################################################
-##### Chicken ######
-##################################################################
-
-CHICKEN = @CHICKEN@
-CHICKEN_CSC = @CHICKEN_CSC@
-CHICKEN_CSI = @CHICKEN_CSI@
-CHICKEN_LIBOPTS = @CHICKENLIB@ $(SYSLIBS)
-CHICKEN_SHAREDLIBOPTS = @CHICKENSHAREDLIB@ $(SYSLIBS)
-CHICKEN_CFLAGS = @CHICKENOPTS@
-CHICKENOPTS = -quiet
-CHICKEN_MAIN =
-CHICKEN_SCRIPT = $(RUNME).scm
-
-# SWIG produces $(ISRCS) (the C wrapper file)
-# and $(CHICKEN_GENERATED_SCHEME) (the Scheme wrapper file):
-CHICKEN_GENERATED_SCHEME = $(INTERFACE:.i=.scm)
-CHICKEN_COMPILED_SCHEME = $(INTERFACE:.i=_chicken.c)
-CHICKEN_COMPILED_OBJECT = $(CHICKEN_COMPILED_SCHEME:.c=.@OBJEXT@)
-
-# flags for the main chicken sources (only used when compiling statically)
-CHICKEN_COMPILED_MAIN = $(CHICKEN_MAIN:.scm=_chicken.c)
-CHICKEN_COMPILED_MAIN_OBJECT = $(CHICKEN_COMPILED_MAIN:.c=.@OBJEXT@)
-
-# -----------------------------------------------------------------
-# Build a CHICKEN dynamically loadable module
-# -----------------------------------------------------------------
-
-# This is the old way to build chicken, but it does not work correctly with exceptions
-chicken_direct: $(SRCDIR_SRCS)
- $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH)
- $(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \
- -dynamic -feature chicken-compile-shared \
- -output-file $(CHICKEN_COMPILED_SCHEME)
- $(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(CHICKEN_CFLAGS) \
- $(INCLUDES) $(CHICKEN_INCLUDE) $(ISRCS) $(SRCDIR_SRCS) $(CHICKEN_COMPILED_SCHEME)
- $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(CHICKEN_COMPILED_OBJECT) $(OBJS) $(IOBJS) \
- $(LIBS) $(CHICKEN_SHAREDLIBOPTS) -o $(LIBPREFIX)$(TARGET)$(SO)
-
-chicken_direct_cpp: $(SRCDIR_CXXSRCS) $(CHICKSRCS)
- $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH)
- $(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \
- -dynamic -feature chicken-compile-shared \
- -output-file $(CHICKEN_COMPILED_SCHEME)
- $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(CHICKEN_CFLAGS) \
- $(INCLUDES) $(CHICKEN_INCLUDE) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(CHICKEN_COMPILED_SCHEME)
- $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(CHICKEN_COMPILED_OBJECT) $(OBJS) $(IOBJS) \
- $(LIBS) $(CPP_DLLIBS) $(CHICKEN_SHAREDLIBOPTS) -o $(LIBPREFIX)$(TARGET)$(SO)
-
-# -----------------------------------------------------------------
-# Build statically linked CHICKEN interpreter
-# -----------------------------------------------------------------
-
-# The following two targets are also used by the test suite
-chicken_static: $(SRCDIR_SRCS) $(CHICKSRCS)
- $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH)
- $(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \
- -output-file $(CHICKEN_COMPILED_SCHEME)
- $(CHICKEN) $(CHICKEN_MAIN) $(CHICKENOPTS) \
- -output-file $(CHICKEN_MAIN:.scm=_chicken.c)
- $(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(CHICKEN_CFLAGS) \
- $(INCLUDES) $(CHICKEN_INCLUDE) $(ISRCS) $(SRCDIR_SRCS) \
- $(CHICKEN_COMPILED_SCHEME) $(CHICKEN_COMPILED_MAIN)
- $(CC) $(CFLAGS) $(LDFLAGS) $(CHICKEN_COMPILED_OBJECT) $(CHICKEN_COMPILED_MAIN_OBJECT) \
- $(OBJS) $(IOBJS) $(LIBS) $(CHICKEN_SHAREDLIBOPTS) -o $(TARGET)
-
-chicken_static_cpp: $(SRCDIR_CXXSRCS) $(CHICKSRCS)
- $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH)
- $(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \
- -output-file $(CHICKEN_COMPILED_SCHEME)
- $(CHICKEN) $(CHICKEN_MAIN) $(CHICKENOPTS) \
- -output-file $(CHICKEN_MAIN:.scm=_chicken.c)
- $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(CHICKEN_CFLAGS) \
- $(INCLUDES) $(CHICKEN_INCLUDE) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) \
- $(CHICKEN_COMPILED_SCHEME) $(CHICKEN_COMPILED_MAIN)
- $(CXX) $(CXXFLAGS) $(LDFLAGS) $(CHICKEN_COMPILED_OBJECT) $(CHICKEN_COMPILED_MAIN_OBJECT) \
- $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) $(CHICKEN_SHAREDLIBOPTS) -o $(TARGET)
-
-# ----------------------------------------------------------------
-# Build a shared library using csc
-# ----------------------------------------------------------------
-
-chicken:
- $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH)
- $(COMPILETOOL) $(CHICKEN_CSC) -s `echo $(INCLUDES) | sed 's/-I/-C -I/g'` $(CHICKEN_GENERATED_SCHEME) $(SRCDIR_SRCS) $(ISRCS) -o $(TARGET)$(SO)
-
-chicken_cpp:
- $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH)
- $(COMPILETOOL) $(CHICKEN_CSC) -s `echo $(INCLUDES) | sed 's/-I/-C -I/g'` $(CHICKEN_GENERATED_SCHEME) $(SRCDIR_SRCS) $(ICXXSRCS) $(SRCDIR_CXXSRCS) -o $(TARGET)$(SO)
-
-chicken_externalhdr:
- $(SWIG) -chicken -external-runtime $(TARGET)
-
-# -----------------------------------------------------------------
-# Run CHICKEN example
-# -----------------------------------------------------------------
-
-chicken_run:
- env LD_LIBRARY_PATH=$$PWD $(RUNTOOL) $(CHICKEN_CSI) $(CHICKEN_SCRIPT) $(RUNPIPE)
-
-# -----------------------------------------------------------------
-# Version display
-# -----------------------------------------------------------------
-
-chicken_version:
- $(CHICKEN) -version | grep -i version
-
-# -----------------------------------------------------------------
-# Cleaning the CHICKEN examples
-# -----------------------------------------------------------------
-
-chicken_clean:
- rm -f *_wrap* *~ .~* *_chicken*
- rm -f core @EXTRA_CLEAN@
- rm -f *.@OBJEXT@ *@SO@
-
-##################################################################
##### CSHARP ######
##################################################################
@@ -1417,7 +1108,7 @@ CSHARPCFLAGS = @CSHARPCFLAGS@
CSHARPFLAGS =
CSHARPOPTIONS =
CSHARPSO = @CSHARPSO@
-CSHARP_RUNME = $(CSHARPCILINTERPRETER) $(CSHARPCILINTERPRETER_FLAGS) ./$(RUNME).exe
+CSHARP_RUNME = ./$(RUNME).exe
# ----------------------------------------------------------------
# Build a CSharp dynamically loadable module (C)
@@ -1455,7 +1146,7 @@ csharp_compile: $(SRCDIR_SRCS)
# -----------------------------------------------------------------
csharp_run:
- env LD_LIBRARY_PATH=$$PWD $(RUNTOOL) $(CSHARP_RUNME) $(RUNPIPE)
+ env LD_LIBRARY_PATH=$$PWD $(RUNTOOL) $(CSHARPCILINTERPRETER) $(CSHARPCILINTERPRETER_FLAGS) $(CSHARP_RUNME) $(RUNPIPE)
# -----------------------------------------------------------------
# Version display
@@ -1598,42 +1289,6 @@ allegrocl_clean:
rm -f *.@OBJEXT@ *@SO@
##################################################################
-##### CLISP ######
-##################################################################
-
-CLISP = @CLISPBIN@
-CLISP_SCRIPT=$(RUNME).lisp
-
-clisp: $(SRCDIR_SRCS)
- $(SWIG) -clisp $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
-
-clisp_cpp: $(SRCDIR_SRCS)
- $(SWIG) -c++ -clisp $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
-
-# -----------------------------------------------------------------
-# Run CLISP example
-# -----------------------------------------------------------------
-
-clisp_run:
- $(RUNTOOL) $(CLISP) -batch -s $(CLISP_SCRIPT) $(RUNPIPE)
-
-# -----------------------------------------------------------------
-# Version display
-# -----------------------------------------------------------------
-
-clisp_version:
- $(CLISP) --version | head -n 1
-
-# -----------------------------------------------------------------
-# Cleaning the CLISP examples
-# -----------------------------------------------------------------
-
-clisp_clean:
- rm -f *_wrap* *~ .~*
- rm -f core @EXTRA_CLEAN@
- rm -f *.@OBJEXT@ *@SO@
-
-##################################################################
##### CFFI ######
##################################################################
@@ -1674,46 +1329,6 @@ cffi_clean:
rm -f *.@OBJEXT@ *@SO@
##################################################################
-##### UFFI ######
-##################################################################
-
-UFFI = @UFFIBIN@
-UFFI_SCRIPT=$(RUNME).lisp
-
-uffi: $(SRCDIR_SRCS)
- $(SWIG) -uffi $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
-# $(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCDIR_SRCS)
-# $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
-
-uffi_cpp: $(SRCDIR_SRCS)
- $(SWIG) -c++ -uffi $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
-# $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES)
-# $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
-
-# -----------------------------------------------------------------
-# Run UFFI example
-# -----------------------------------------------------------------
-
-uffi_run:
- $(RUNTOOL) $(UFFI) -batch -s $(UFFI_SCRIPT) $(RUNPIPE)
-
-# -----------------------------------------------------------------
-# Version display
-# -----------------------------------------------------------------
-
-uffi_version:
- $(UFFI) --version
-
-# -----------------------------------------------------------------
-# Cleaning the UFFI examples
-# -----------------------------------------------------------------
-
-uffi_clean:
- rm -f *_wrap* *~ .~*
- rm -f core @EXTRA_CLEAN@
- rm -f *.@OBJEXT@ *@SO@
-
-##################################################################
##### R ######
##################################################################
@@ -1737,7 +1352,7 @@ r: $(SRCDIR_SRCS)
ifneq ($(SRCDIR_SRCS),)
$(CC) -g -c $(CPPFLAGS) $(CFLAGS) $(R_CFLAGS) $(SRCDIR_SRCS) $(INCLUDES)
endif
- +( PKG_CPPFLAGS="$(CPPFLAGS) $(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) $(OBJS) > /dev/null )
+ +( PKG_CPPFLAGS="$(CPPFLAGS) $(INCLUDES)" PKG_CFLAGS="$(CFLAGS)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) $(OBJS) > /dev/null )
# ----------------------------------------------------------------
# Build a R dynamically loadable module (C++)
@@ -1747,7 +1362,7 @@ r_cpp: $(SRCDIR_CXXSRCS)
ifneq ($(SRCDIR_CXXSRCS),)
$(CXX) -g -c $(CPPFLAGS) $(CXXFLAGS) $(R_CFLAGS) $(SRCDIR_CXXSRCS) $(INCLUDES)
endif
- +( PKG_CPPFLAGS="$(CPPFLAGS) $(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) $(OBJS) > /dev/null )
+ +( PKG_CPPFLAGS="$(CPPFLAGS) $(INCLUDES)" PKG_CXXFLAGS="$(CXXFLAGS)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) $(OBJS) > /dev/null )
# -----------------------------------------------------------------
# Run R example
@@ -1835,79 +1450,41 @@ scilab_clean:
GO = @GO@
GOGCC = @GOGCC@
GCCGO = @GCCGO@
-GO1 = @GO1@
-GO12 = @GO12@
-GO13 = @GO13@
-GO15 = @GO15@
-GOC = @GOC@
GOOPT = @GOOPT@
GCCGOOPT = @GCCGOOPT@
GOVERSIONOPTION = @GOVERSIONOPTION@
GOSWIGARG = `if $(GOGCC) ; then echo -gccgo; fi`
-GOCOMPILEARG = `if $(GO15); then echo tool compile; elif $(GO1) ; then echo tool $(GOC:c=g) ; fi` `if $(GO13) || $(GO15); then echo -pack ; fi`
GOSRCS = $(INTERFACE:.i=.go)
GOCSRCS = $(INTERFACE:.i=_gc.c)
-GOLD = `if $(GO15); then echo link; else echo $(GOC:c=l); fi`
-GOTOOL = `if $(GO1) ; then echo go tool; fi`
-GOPACK = `if $(GO1) ; then echo go tool pack; else echo gopack; fi`
-
GOPACKAGE = $(notdir $(INTERFACE:.i=.a))
-GOPATHDIR = gopath/src/$(INTERFACE:.i=)
-
-GOOBJEXT = `if $(GO15); then echo o; else echo $(GOC:c=); fi`
-GOGCOBJS = $(GOSRCS:.go=.$(GOOBJEXT))
-GOGCCOBJS = $(GOSRCS:.go=.@OBJEXT@)
+GOPATHPARENTDIR = gopath/$(GOMOD)/src
+GOPATHDIR = $(GOPATHPARENTDIR)/$(INTERFACE:.i=)
# ----------------------------------------------------------------
# Build a Go module (C)
# ----------------------------------------------------------------
-go_nocgo: $(SRCDIR_SRCS)
- $(SWIG) -go $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
- if $(GO12) || $(GO13) || $(GO15) || $(GOGCC); then \
- $(CC) -g -c $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES); \
- else \
- $(CC) -g -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES); \
- $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO); \
- fi
- if $(GOGCC) ; then \
- $(COMPILETOOL) $(GCCGO) -g -c -I . $(GOSRCS); \
- else \
- $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(GOSRCS); \
- $(COMPILETOOL) $(GOTOOL) $(GOC) -I $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`} $(GOCSRCS); \
- rm -f $(GOPACKAGE); \
- if $(GO13) || $(GO15); then \
- cp $(GOGCOBJS) $(GOPACKAGE); \
- $(COMPILETOOL) $(GOPACK) r $(GOPACKAGE) $(GOCSRCS:.c=.$(GOOBJEXT)) $(OBJS) $(IOBJS); \
- elif $(GO12); then \
- $(COMPILETOOL) $(GOPACK) grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)) $(OBJS) $(IOBJS); \
- else \
- $(COMPILETOOL) $(GOPACK) grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)); \
- fi; \
- fi
- if test -f $(SRCDIR)$(RUNME).go; then \
- if $(GOGCC) ; then \
- $(COMPILETOOL) $(GCCGO) -g -c $(SRCDIR)$(RUNME).go; \
- $(COMPILETOOL) $(GCCGO) -o $(RUNME) $(RUNME).@OBJEXT@ $(GOGCCOBJS) $(OBJS) $(IOBJS); \
- elif $(GO12) || $(GO13) || $(GO15); then \
- $(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \
- $(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld "$(CC)" -extldflags "$(CFLAGS) $(LDFLAGS)" -o $(RUNME) $(RUNME).$(GOOBJEXT); \
- else \
- $(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \
- $(COMPILETOOL) $(GOTOOL) $(GOLD) -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $(RUNME) $(RUNME).$(GOOBJEXT); \
- fi; \
- fi
-
-go: $(SRCDIR_SRCS)
- $(SWIG) -go -cgo $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
+$(GOPATHPARENTDIR)/go.mod:
+ @mkdir gopath 2>/dev/null || true
+ @mkdir gopath/$(GOMOD) 2>/dev/null || true
+ @mkdir gopath/$(GOMOD)/src 2>/dev/null || true
+ @mkdir $(GOPATHDIR) 2>/dev/null || true
+ echo "module swigtests" > $(GOPATHDIR)/go.mod
+ echo "" >> $(GOPATHDIR)/go.mod
+ echo "go 1.12" >> $(GOPATHDIR)/go.mod
+ mv -f $(GOPATHDIR)/go.mod $(GOPATHPARENTDIR)/go.mod
+
+go: $(SRCDIR_SRCS) $(GOPATHPARENTDIR)/go.mod
+ $(SWIG) -go -import-prefix swigtests $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
@mkdir gopath 2>/dev/null || true
- @mkdir gopath/src 2>/dev/null || true
- @mkdir gopath/src/$(INTERFACE:.i=) 2>/dev/null || true
- rm -f $(GOPATHDIR)/*
+ @mkdir gopath/$(GOMOD) 2>/dev/null || true
+ @mkdir gopath/$(GOMOD)/src 2>/dev/null || true
+ @mkdir $(GOPATHDIR) 2>/dev/null || true
+ rm -rf $(GOPATHDIR)/*
cp $(ISRCS) $(GOPATHDIR)/
if test -f $(IWRAP:.i=.h); then \
cp $(IWRAP:.i=.h) $(GOPATHDIR)/; \
@@ -1916,7 +1493,14 @@ go: $(SRCDIR_SRCS)
cp $(SRCDIR_SRCS) $(GOPATHDIR)/; \
fi
cp $(GOSRCS) $(GOPATHDIR)/
- GOPATH=`pwd`/gopath; \
+ @if test -f $(SRCDIR)$(RUNME).go; then \
+ mkdir gopath/$(GOMOD)/src/runme 2>/dev/null || true; \
+ rm -f gopath/$(GOMOD)/src/runme/*; \
+ fi
+ if test -f $(SRCDIR)$(RUNME).go; then \
+ cp $(SRCDIR)$(RUNME).go gopath/$(GOMOD)/src/runme/; \
+ fi
+ GOPATH=`pwd`/gopath/$(GOMOD); \
export GOPATH; \
CGO_CPPFLAGS="$(CPPFLAGS) $(INCLUDES) -I `cd $(SRCDIR) && pwd` -I `pwd`"; \
export CGO_CPPFLAGS; \
@@ -1924,82 +1508,29 @@ go: $(SRCDIR_SRCS)
export CGO_CFLAGS; \
CGO_LDFLAGS="$(LDFLAGS) -lm"; \
export CGO_LDFLAGS; \
- (cd $(GOPATHDIR)/ && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o $(GOPACKAGE))
- cp $(GOPATHDIR)/$(GOPACKAGE) $(dir $(INTERFACE))/$(GOPACKAGE)
+ (cd $(GOPATHDIR)/ && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o $(GOPACKAGE)); \
if $(GOGCC); then \
- cp $(dir $(INTERFACE))/$(GOPACKAGE) $(dir $(INTERFACE))/$(GOPACKAGE:.a=.gox); \
- fi
+ cp $(GOPATHDIR)/$(GOPACKAGE) $(GOPATHDIR)/$(GOPACKAGE:.a=.gox); \
+ fi; \
if test -f $(SRCDIR)$(RUNME).go; then \
- if $(GOGCC) ; then \
- $(COMPILETOOL) $(GCCGO) -c -g $(SRCDIR)$(RUNME).go; \
- $(COMPILETOOL) $(GCCGO) -o $(RUNME) $(RUNME).@OBJEXT@ $(dir $(INTERFACE))/$(GOPACKAGE); \
- elif $(GO12) || $(GO13) || $(GO15); then \
- $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -o $(RUNME).$(GOOBJEXT) $(SRCDIR)$(RUNME).go; \
- $(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld "$(CC)" -extldflags "$(CFLAGS) $(LDFLAGS)" -o $(RUNME) $(RUNME).$(GOOBJEXT); \
- else \
- $(COMPILETOOL) $(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \
- $(COMPILETOOL) $(GOTOOL) $(GOLD) -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $(RUNME) $(RUNME).$(GOOBJEXT); \
- fi; \
+ mkdir gopath/$(GOMOD)/src/swigtests 2>/dev/null || true; \
+ mkdir gopath/$(GOMOD)/src/swigtests/$(INTERFACE:.i=) 2>/dev/null || true; \
+ cp $(GOPATHDIR)/* gopath/$(GOMOD)/src/swigtests/$(INTERFACE:.i=)/; \
+ (cd gopath/$(GOMOD)/src/runme && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o runme $(RUNME).go); \
+ cp gopath/$(GOMOD)/src/runme/runme $(RUNME); \
fi
# ----------------------------------------------------------------
# Build a Go module (C++)
# ----------------------------------------------------------------
-go_cpp_nocgo: $(SRCDIR_SRCS)
- $(SWIG) -go -c++ $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
- if $(GO12) || $(GO13) || $(GO15) || $(GOGCC); then \
- if test -n "$(SRCDIR_CXXSRCS)$(SRCDIR_SRCS)"; then \
- $(CXX) -g -c $(CPPFLAGS) $(CXXFLAGS) $(SRCDIR_CXXSRCS) $(SRCDIR_SRCS) $(INCLUDES); \
- fi; \
- $(foreach f,$(ICXXSRCS), \
- $(CXX) -g -c $(CPPFLAGS) $(CXXFLAGS) -o $(addsuffix .@OBJEXT@,$(basename $f)) $f $(INCLUDES); \
- ) \
- else \
- $(CXX) -g -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES); \
- $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO); \
- fi
- if ! $(GOGCC) ; then \
- $(foreach f,$(GOSRCS), \
- $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . -o $(addsuffix .$(GOOBJEXT),$(basename $f)) $f \
- ); \
- $(foreach f,$(GOCSRCS), \
- $(COMPILETOOL) $(GOTOOL) $(GOC) -I $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`} \
- -o $(addsuffix .$(GOOBJEXT),$(basename $f)) $f; \
- ) \
- rm -f $(GOPACKAGE); \
- if $(GO13) || $(GO15); then \
- cp $(GOGCOBJS) $(GOPACKAGE); \
- $(COMPILETOOL) $(GOPACK) r $(GOPACKAGE) $(GOCSRCS:.c=.$(GOOBJEXT)) $(OBJS) $(IOBJS); \
- elif $(GO12); then \
- $(COMPILETOOL) $(GOPACK) grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)) $(OBJS) $(IOBJS); \
- else \
- $(COMPILETOOL) $(GOPACK) grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)); \
- fi; \
- else \
- $(foreach f,$(GOSRCS), \
- $(COMPILETOOL) $(GCCGO) -g -c -I . -o $(addsuffix .@OBJEXT@,$(basename $f)) $f \
- ); \
- fi
- if test -f $(SRCDIR)$(RUNME).go; then \
- if $(GOGCC) ; then \
- $(COMPILETOOL) $(GCCGO) -g -c $(SRCDIR)$(RUNME).go; \
- $(COMPILETOOL) $(GCCGO) -o $(RUNME) $(RUNME).@OBJEXT@ $(GOGCCOBJS) $(OBJS) $(IOBJS) -lstdc++; \
- elif $(GO12) || $(GO13) || $(GO15); then \
- $(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \
- $(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld "$(CXX)" -extldflags "$(CXXFLAGS) $(LDFLAGS)" -o $(RUNME) $(RUNME).$(GOOBJEXT); \
- else \
- $(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \
- $(COMPILETOOL) $(GOTOOL) $(GOLD) -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $(RUNME) $(RUNME).$(GOOBJEXT); \
- fi; \
- fi
-
-go_cpp: $(SRCDIR_SRCS)
- $(SWIG) -go -c++ -cgo $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
+go_cpp: $(SRCDIR_SRCS) $(GOPATHPARENTDIR)/go.mod
+ $(SWIG) -go -c++ -import-prefix swigtests $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
@mkdir gopath 2>/dev/null || true
- @mkdir gopath/src 2>/dev/null || true
- @mkdir gopath/src/$(INTERFACE:.i=) 2>/dev/null || true
- rm -f $(GOPATHDIR)/*
+ @mkdir gopath/$(GOMOD) 2>/dev/null || true
+ @mkdir gopath/$(GOMOD)/src 2>/dev/null || true
+ @mkdir $(GOPATHDIR) 2>/dev/null || true
+ rm -rf $(GOPATHDIR)/*
cp $(ICXXSRCS) $(GOPATHDIR)/
if test -f $(IWRAP:.i=.h); then \
cp $(IWRAP:.i=.h) $(GOPATHDIR)/; \
@@ -2011,7 +1542,14 @@ go_cpp: $(SRCDIR_SRCS)
cp $(SRCDIR_SRCS) $(GOPATHDIR)/; \
fi
cp $(GOSRCS) $(GOPATHDIR)/
- GOPATH=`pwd`/gopath; \
+ @if test -f $(SRCDIR)$(RUNME).go; then \
+ mkdir gopath/$(GOMOD)/src/runme 2>/dev/null || true; \
+ rm -f gopath/$(GOMOD)/src/runme/*; \
+ fi
+ if test -f $(SRCDIR)$(RUNME).go; then \
+ cp $(SRCDIR)$(RUNME).go gopath/$(GOMOD)/src/runme/; \
+ fi
+ GOPATH=`pwd`/gopath/$(GOMOD); \
export GOPATH; \
CGO_CPPFLAGS="$(CPPFLAGS) $(INCLUDES) -I `cd $(SRCDIR) && pwd` -I `pwd`"; \
export CGO_CPPFLAGS; \
@@ -2021,22 +1559,16 @@ go_cpp: $(SRCDIR_SRCS)
export CGO_CXXFLAGS; \
CGO_LDFLAGS="$(LDFLAGS) -lm"; \
export CGO_LDFLAGS; \
- (cd $(GOPATHDIR) && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o $(GOPACKAGE))
- cp $(GOPATHDIR)/$(GOPACKAGE) $(dir $(INTERFACE))/$(GOPACKAGE)
+ (cd $(GOPATHDIR) && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o $(GOPACKAGE)); \
if $(GOGCC); then \
- cp $(dir $(INTERFACE))/$(GOPACKAGE) $(dir $(INTERFACE))/$(GOPACKAGE:.a=.gox); \
- fi
+ cp $(GOPATHDIR)/$(GOPACKAGE) $(GOPATHDIR)/$(GOPACKAGE:.a=.gox); \
+ fi; \
if test -f $(SRCDIR)$(RUNME).go; then \
- if $(GOGCC) ; then \
- $(COMPILETOOL) $(GCCGO) -g -c $(SRCDIR)$(RUNME).go; \
- $(COMPILETOOL) $(GCCGO) -o $(RUNME) $(RUNME).@OBJEXT@ $(dir $(INTERFACE))/$(GOPACKAGE) -lstdc++; \
- elif $(GO12) || $(GO13) || $(GO15); then \
- $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -o $(RUNME).$(GOOBJEXT) $(SRCDIR)$(RUNME).go; \
- $(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld "$(CXX)" -extldflags "$(CXXFLAGS) $(LDFLAGS)" -o $(RUNME) $(RUNME).$(GOOBJEXT); \
- else \
- $(COMPILETOOL) $(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \
- $(COMPILETOOL) $(GOTOOL) $(GOLD) -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $(RUNME) $(RUNME).$(GOOBJEXT); \
- fi; \
+ mkdir gopath/$(GOMOD)/src/swigtests 2>/dev/null || true; \
+ mkdir gopath/$(GOMOD)/src/swigtests/$(INTERFACE:.i=) 2>/dev/null || true; \
+ cp $(GOPATHDIR)/* gopath/$(GOMOD)/src/swigtests/$(INTERFACE:.i=)/; \
+ (cd gopath/$(GOMOD)/src/runme && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o runme $(RUNME).go); \
+ cp gopath/$(GOMOD)/src/runme/runme $(RUNME); \
fi
# -----------------------------------------------------------------
diff --git a/Examples/contract/simple_c/example.c b/Examples/contract/simple_c/example.c
deleted file mode 100644
index 85a3e1417..000000000
--- a/Examples/contract/simple_c/example.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <stdio.h>
-
-int Circle (int x, int y, int radius) {
- /* Draw Circle */
- printf("Drawing the circle...\n");
- /* Return -1 to test contract post assertion */
- if (radius == 2)
- return -1;
- else
- return 1;
-}
diff --git a/Examples/contract/simple_c/example.i b/Examples/contract/simple_c/example.i
deleted file mode 100644
index 49df09af6..000000000
--- a/Examples/contract/simple_c/example.i
+++ /dev/null
@@ -1,19 +0,0 @@
-/* File : example.i */
-
-/* Basic C example for swig contract */
-/* Tiger, University of Chicago, 2003 */
-
-%module example
-
-%contract Circle (int x, int y, int radius) {
-require:
- x >= 0;
- y >= 0;
- radius > x;
-ensure:
- Circle >= 0;
-}
-
-%inline %{
-extern int Circle (int x, int y, int radius);
-%}
diff --git a/Examples/contract/simple_c/runme1.py b/Examples/contract/simple_c/runme1.py
deleted file mode 100644
index abd8df62f..000000000
--- a/Examples/contract/simple_c/runme1.py
+++ /dev/null
@@ -1,17 +0,0 @@
-import example
-# Call the Circle() function correctly
-
-x = 1;
-y = 1;
-r = 3;
-
-c = example.Circle(x, y, r)
-
-# test post-assertion
-x = 1;
-y = 1;
-r = 2;
-
-c = example.Circle(x, y, r)
-
-print "The return value of Circle(%d, %d, %d) is %d" % (x,y,r,c)
diff --git a/Examples/contract/simple_c/runme2.py b/Examples/contract/simple_c/runme2.py
deleted file mode 100644
index 48d4a3f10..000000000
--- a/Examples/contract/simple_c/runme2.py
+++ /dev/null
@@ -1,20 +0,0 @@
-import example
-
-# Call the Circle() function correctly
-
-x = 1;
-y = 1;
-r = 3;
-
-c = example.Circle(x, y, r)
-
-print "The return value of Circle(%d, %d, %d) is %d" % (x,y,r,c)
-
-# test pre-assertion
-x = 1;
-y = -1;
-r = 3;
-
-c = example.Circle(x, y, r)
-
-print "The return value of Circle(%d, %d, %d) is %d" % (x,y,r,c)
diff --git a/Examples/contract/simple_cxx/example.i b/Examples/contract/simple_cxx/example.i
deleted file mode 100644
index 9b47409d0..000000000
--- a/Examples/contract/simple_cxx/example.i
+++ /dev/null
@@ -1,28 +0,0 @@
-%module example
-
-%contract Circle::Circle(double radius) {
-require:
- radius > 0;
-}
-
-%contract Circle::area(void) {
-ensure:
- area > 0;
-}
-
-%contract Shape::move(double dx, double dy) {
-require:
- dx > 0;
-}
-
-/* should be no effect, since there is no move() for class Circle */
-%contract Circle::move(double dx, double dy) {
-require:
- dy > 1;
-}
-
-# include must be after contracts
-%{
-#include "example.h"
-%}
-%include "example.h"
diff --git a/Examples/contract/simple_cxx/runme1.py b/Examples/contract/simple_cxx/runme1.py
deleted file mode 100644
index 9028d02d9..000000000
--- a/Examples/contract/simple_cxx/runme1.py
+++ /dev/null
@@ -1,33 +0,0 @@
-import example
-
-# Create the Circle object
-
-r = 2;
-print " Creating circle (radium: %d) :" % r
-c = example.Circle(r)
-
-# Set the location of the object
-
-c.x = 20
-c.y = 30
-print " Here is its current position:"
-print " Circle = (%f, %f)" % (c.x,c.y)
-
-# ----- Call some methods -----
-
-print "\n Here are some properties of the Circle:"
-print " area = ", c.area()
-print " perimeter = ", c.perimeter()
-dx = 1;
-dy = 1;
-print " Moving with (%d, %d)..." % (dx, dy)
-c.move(dx, dy)
-
-del c
-
-print "==================================="
-
-# test construction */
-r = -1;
-print " Creating circle (radium: %d) :" % r
-c = example.Circle(r)
diff --git a/Examples/contract/simple_cxx/runme2.py b/Examples/contract/simple_cxx/runme2.py
deleted file mode 100644
index 5f9c0df5b..000000000
--- a/Examples/contract/simple_cxx/runme2.py
+++ /dev/null
@@ -1,44 +0,0 @@
-import example
-
-# Create the Circle object
-
-r = 2;
-print " Creating circle (radium: %d) :" % r
-c = example.Circle(r)
-
-# Set the location of the object
-
-c.x = 20
-c.y = 30
-print " Here is its current position:"
-print " Circle = (%f, %f)" % (c.x,c.y)
-
-# ----- Call some methods -----
-
-print "\n Here are some properties of the Circle:"
-print " area = ", c.area()
-print " perimeter = ", c.perimeter()
-dx = 1;
-dy = 1;
-print " Moving with (%d, %d)..." % (dx, dy)
-c.move(dx, dy)
-
-del c
-
-print "==================================="
-
-# test area function */
-r = 1;
-print " Creating circle (radium: %d) :" % r
-c = example.Circle(r)
-# Set the location of the object
-
-c.x = 20
-c.y = 30
-print " Here is its current position:"
-print " Circle = (%f, %f)" % (c.x,c.y)
-
-# ----- Call some methods -----
-
-print "\n Here are some properties of the Circle:"
-print " area = ", c.area()
diff --git a/Examples/contract/simple_cxx/runme3.py b/Examples/contract/simple_cxx/runme3.py
deleted file mode 100644
index a663732b1..000000000
--- a/Examples/contract/simple_cxx/runme3.py
+++ /dev/null
@@ -1,57 +0,0 @@
-import example
-
-# Create the Circle object
-
-r = 2;
-print " Creating circle (radium: %d) :" % r
-c = example.Circle(r)
-
-# Set the location of the object
-
-c.x = 20
-c.y = 30
-print " Here is its current position:"
-print " Circle = (%f, %f)" % (c.x,c.y)
-
-# ----- Call some methods -----
-
-print "\n Here are some properties of the Circle:"
-print " area = ", c.area()
-print " perimeter = ", c.perimeter()
-dx = 1;
-dy = 1;
-print " Moving with (%d, %d)..." % (dx, dy)
-c.move(dx, dy)
-
-del c
-
-print "==================================="
-
-# test move function */
-r = 2;
-print " Creating circle (radium: %d) :" % r
-c = example.Circle(r)
-# Set the location of the object
-
-c.x = 20
-c.y = 30
-print " Here is its current position:"
-print " Circle = (%f, %f)" % (c.x,c.y)
-
-# ----- Call some methods -----
-
-print "\n Here are some properties of the Circle:"
-print " area = ", c.area()
-print " perimeter = ", c.perimeter()
-
-# no error for Circle's pre-assertion
-dx = 1;
-dy = -1;
-print " Moving with (%d, %d)..." % (dx, dy)
-c.move(dx, dy)
-
-# error with Shape's pre-assertion
-dx = -1;
-dy = 1;
-print " Moving with (%d, %d)..." % (dx, dy)
-c.move(dx, dy)
diff --git a/Examples/go/callback/gocallback.go b/Examples/go/callback/gocallback.go
index 20fd0627a..881f505e0 100644
--- a/Examples/go/callback/gocallback.go
+++ b/Examples/go/callback/gocallback.go
@@ -36,6 +36,6 @@ func DeleteGoCallback(p GoCallback) {
p.deleteCallback()
}
-func (p *goCallback) Run() {
+func (p *overwrittenMethodsOnCallback) Run() {
fmt.Println("GoCallback.Run")
}
diff --git a/Examples/go/callback/runme.go b/Examples/go/callback/runme.go
index 03ab0c5e2..7c9ffd681 100644
--- a/Examples/go/callback/runme.go
+++ b/Examples/go/callback/runme.go
@@ -1,8 +1,9 @@
package main
import (
- . "./example"
"fmt"
+
+ . "swigtests/example"
)
func main() {
diff --git a/Examples/go/class/runme.go b/Examples/go/class/runme.go
index 8d68afb61..a09a18247 100644
--- a/Examples/go/class/runme.go
+++ b/Examples/go/class/runme.go
@@ -3,8 +3,9 @@
package main
import (
- . "./example"
"fmt"
+
+ . "swigtests/example"
)
func main() {
diff --git a/Examples/go/constants/runme.go b/Examples/go/constants/runme.go
index 1427997a0..57ef21a8b 100644
--- a/Examples/go/constants/runme.go
+++ b/Examples/go/constants/runme.go
@@ -1,8 +1,9 @@
package main
import (
- "./example"
"fmt"
+
+ "swigtests/example"
)
func main() {
diff --git a/Examples/go/director/director.go b/Examples/go/director/director.go
index 4f99bfc6d..c70606af1 100644
--- a/Examples/go/director/director.go
+++ b/Examples/go/director/director.go
@@ -32,7 +32,7 @@ type overwrittenMethodsOnFooBarAbstract struct {
fb FooBarAbstract
// If additional constructor arguments have been given they are typically
- // stored here so that the overriden methods can use them.
+ // stored here so that the overridden methods can use them.
}
func (om *overwrittenMethodsOnFooBarAbstract) Foo() string {
@@ -59,7 +59,7 @@ func NewFooBarGo() FooBarGo {
// The memory of the FooBarAbstract director object instance can be
// automatically freed once the FooBarGo instance is garbage collected by
// uncommenting the following line. Please make sure to understand the
- // runtime.SetFinalizer specific gotchas before doing this. Furthemore
+ // runtime.SetFinalizer specific gotchas before doing this. Furthermore
// DeleteFooBarGo should be deleted if a finalizer is in use or the fooBarGo
// struct needs additional data to prevent double deletion.
// runtime.SetFinalizer(fbgs, FooBarGo.deleteFooBarAbstract)
diff --git a/Examples/go/director/runme.go b/Examples/go/director/runme.go
index 0d839bc88..e28eccba6 100644
--- a/Examples/go/director/runme.go
+++ b/Examples/go/director/runme.go
@@ -1,9 +1,10 @@
package main
import (
- "./example"
"fmt"
"os"
+
+ "swigtests/example"
)
func Compare(name string, got string, exp string) error {
diff --git a/Examples/go/enum/runme.go b/Examples/go/enum/runme.go
index 99d2651f4..c0642e0b5 100644
--- a/Examples/go/enum/runme.go
+++ b/Examples/go/enum/runme.go
@@ -1,8 +1,9 @@
package main
import (
- . "./example"
"fmt"
+
+ . "swigtests/example"
)
func main() {
diff --git a/Examples/go/extend/runme.go b/Examples/go/extend/runme.go
index a56968937..716af52c5 100644
--- a/Examples/go/extend/runme.go
+++ b/Examples/go/extend/runme.go
@@ -3,8 +3,9 @@
package main
import (
- . "./example"
"fmt"
+
+ . "swigtests/example"
)
func main() {
diff --git a/Examples/go/funcptr/runme.go b/Examples/go/funcptr/runme.go
index 44dae3c9e..87ec7d495 100644
--- a/Examples/go/funcptr/runme.go
+++ b/Examples/go/funcptr/runme.go
@@ -1,8 +1,9 @@
package main
import (
- . "./example"
"fmt"
+
+ . "swigtests/example"
)
func main() {
diff --git a/Examples/go/multimap/runme.go b/Examples/go/multimap/runme.go
index 390205a80..2f8b20568 100644
--- a/Examples/go/multimap/runme.go
+++ b/Examples/go/multimap/runme.go
@@ -1,8 +1,9 @@
package main
import (
- . "./example"
"fmt"
+
+ . "swigtests/example"
)
func main() {
diff --git a/Examples/go/pointer/runme.go b/Examples/go/pointer/runme.go
index 1414d341e..73c6b2b3c 100644
--- a/Examples/go/pointer/runme.go
+++ b/Examples/go/pointer/runme.go
@@ -1,8 +1,9 @@
package main
import (
- . "./example"
"fmt"
+
+ . "swigtests/example"
)
func main() {
diff --git a/Examples/go/reference/runme.go b/Examples/go/reference/runme.go
index 004a04c2e..7391d9c8b 100644
--- a/Examples/go/reference/runme.go
+++ b/Examples/go/reference/runme.go
@@ -3,8 +3,9 @@
package main
import (
- . "./example"
"fmt"
+
+ . "swigtests/example"
)
func main() {
diff --git a/Examples/go/simple/runme.go b/Examples/go/simple/runme.go
index 9eb0ff454..5bc055f2e 100644
--- a/Examples/go/simple/runme.go
+++ b/Examples/go/simple/runme.go
@@ -1,8 +1,9 @@
package main
import (
- "./example"
"fmt"
+
+ "swigtests/example"
)
func main() {
diff --git a/Examples/go/template/runme.go b/Examples/go/template/runme.go
index fca2f1b75..e000b1579 100644
--- a/Examples/go/template/runme.go
+++ b/Examples/go/template/runme.go
@@ -3,8 +3,9 @@
package main
import (
- . "./example"
"fmt"
+
+ . "swigtests/example"
)
func main() {
diff --git a/Examples/go/variables/runme.go b/Examples/go/variables/runme.go
index 3d9737f5c..85ca8c638 100644
--- a/Examples/go/variables/runme.go
+++ b/Examples/go/variables/runme.go
@@ -3,8 +3,9 @@
package main
import (
- "./example"
"fmt"
+
+ "swigtests/example"
)
func main() {
diff --git a/Examples/guile/check.list b/Examples/guile/check.list
index 726e6ab75..1f22adf78 100644
--- a/Examples/guile/check.list
+++ b/Examples/guile/check.list
@@ -1,9 +1,9 @@
# see top-level Makefile.in
-constants
class
-port
-simple
-std_vector
+constants
matrix
multimap
multivalue
+port
+simple
+std_vector
diff --git a/Examples/guile/matrix/runme.scm b/Examples/guile/matrix/runme.scm
index f11061e56..b898bb485 100644
--- a/Examples/guile/matrix/runme.scm
+++ b/Examples/guile/matrix/runme.scm
@@ -1,6 +1,3 @@
-#!./matrix \
--e do-test -s
-!#
;;; Authors: David Beazley <beazley@cs.uchicago.edu>, 1999
;;; Martin Froehlich <MartinFroehlich@ACM.org>, 2000
;;;
@@ -15,7 +12,7 @@
;;; Explanation: The three lines at the beginning of this script are
;;; telling the kernel to load the enhanced guile interpreter named
;;; "matrix"; to execute the function "do-test" (-e option) after loading
-;;; this script (-s option). There are a lot more options wich allow for
+;;; this script (-s option). There are a lot more options which allow for
;;; even finer tuning. SEE ALSO: Section "Guile Scripts" in the "Guile
;;; reference manual -- Part I: Preliminaries".
;;;
diff --git a/Examples/guile/multivalue/example.i b/Examples/guile/multivalue/example.i
index 135389487..0ef710132 100644
--- a/Examples/guile/multivalue/example.i
+++ b/Examples/guile/multivalue/example.i
@@ -15,14 +15,14 @@ back to this behavior, use: */
void divide_l(int a, int b, int *OUTPUT, int *OUTPUT);
-/* Multiple values as vectors. By issueing: */
+/* Multiple values as vectors. By issuing: */
%values_as_vector;
/* vectors instead of lists will be used. */
void divide_v(int a, int b, int *OUTPUT, int *OUTPUT);
/* Multiple values for multiple-value continuations.
- (This is the most elegant way.) By issueing: */
+ (This is the most elegant way.) By issuing: */
%multiple_values;
/* multiple values are passed to the multiple-value
continuation, as created by `call-with-values' or the
diff --git a/Examples/guile/simple/example.c b/Examples/guile/simple/example.c
index dcafc4dc4..1c2af789c 100644
--- a/Examples/guile/simple/example.c
+++ b/Examples/guile/simple/example.c
@@ -1,21 +1,18 @@
-/* Simple example from documentation */
/* File : example.c */
-#include <time.h>
+/* A global variable */
+double Foo = 3.0;
-double My_variable = 3.0;
-
-int fact(int n) {
- if (n <= 1) return 1;
- else return n*fact(n-1);
+/* Compute the greatest common divisor of positive integers */
+int gcd(int x, int y) {
+ int g;
+ g = y;
+ while (x > 0) {
+ g = x;
+ x = y % x;
+ y = g;
+ }
+ return g;
}
-int mod(int n, int m) {
- return (n % m);
-}
-char *get_time() {
- long ltime;
- time(&ltime);
- return ctime(&ltime);
-}
diff --git a/Examples/guile/simple/example.i b/Examples/guile/simple/example.i
index 1a9930a14..4fcea98b2 100644
--- a/Examples/guile/simple/example.i
+++ b/Examples/guile/simple/example.i
@@ -5,10 +5,8 @@
%}
%inline %{
-extern double My_variable;
-extern int fact(int);
-extern int mod(int n, int m);
-extern char *get_time();
+extern int gcd(int x, int y);
+extern double Foo;
%}
%include guile/guilemain.i
diff --git a/Examples/guile/simple/runme.scm b/Examples/guile/simple/runme.scm
index c3fd0b41f..ccd755701 100644
--- a/Examples/guile/simple/runme.scm
+++ b/Examples/guile/simple/runme.scm
@@ -3,24 +3,20 @@
(for-each display args)
(newline))
-(mdisplay-newline (get-time) "My variable = " (My-variable))
+; Call our gcd() function
-(do ((i 0 (1+ i)))
- ((= 14 i))
- (mdisplay-newline i " factorial is " (fact i)))
+(define x 42)
+(define y 105)
+(define g (gcd x y))
+(mdisplay-newline "The gcd of " x " and " y " is " g)
-(define (mods i imax j jmax)
- (if (< i imax)
- (if (< j jmax)
- (begin
- (My-variable (+ (My-variable) (mod i j)))
- (mods i imax (+ j 1) jmax))
- (mods (+ i 1) imax 1 jmax))))
+; Manipulate the Foo global variable
-(mods 1 150 1 150)
+; Output its current value
+(mdisplay-newline "Foo = " (Foo))
-(mdisplay-newline "My-variable = " (My-variable))
-
-(exit (and (= 1932053504 (fact 13))
- (= 745470.0 (My-variable))))
+; Change its value
+(Foo 3.1415926)
+; See if the change took effect
+(mdisplay-newline "Foo = " (Foo))
diff --git a/Examples/guile/std_vector/example.h b/Examples/guile/std_vector/example.h
index 4f0dac70d..52e260d6d 100644
--- a/Examples/guile/std_vector/example.h
+++ b/Examples/guile/std_vector/example.h
@@ -17,9 +17,8 @@ std::vector<double> half(const std::vector<double>& v) {
}
void halve_in_place(std::vector<double>& v) {
- // would you believe this is the same as the above?
- std::transform(v.begin(),v.end(),v.begin(),
- std::bind2nd(std::divides<double>(),2.0));
+ for (std::vector<double>::iterator it = v.begin(); it != v.end(); ++it)
+ *it /= 2.0;
}
diff --git a/Examples/java/check.list b/Examples/java/check.list
index 825d04a6d..c30550a1c 100644
--- a/Examples/java/check.list
+++ b/Examples/java/check.list
@@ -2,6 +2,7 @@
callback
class
constants
+doxygen
enum
extend
funcptr
diff --git a/Examples/php5/overloading/Makefile b/Examples/java/doxygen/Makefile
index 8346a1dae..9f471746e 100644
--- a/Examples/php5/overloading/Makefile
+++ b/Examples/java/doxygen/Makefile
@@ -4,17 +4,18 @@ SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
CXXSRCS = example.cxx
TARGET = example
INTERFACE = example.i
-LIBS =
-SWIGOPT =
+SWIGOPT = -doxygen
+JAVASRCS = *.java
check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run
build:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php5_cpp
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_clean
+ rm -rf javadocs
diff --git a/Examples/java/doxygen/example.cxx b/Examples/java/doxygen/example.cxx
new file mode 100644
index 000000000..ccdb87dfe
--- /dev/null
+++ b/Examples/java/doxygen/example.cxx
@@ -0,0 +1,48 @@
+/* File : example.cxx */
+
+#include "example.h"
+#define M_PI 3.14159265358979323846
+
+/* Move the shape to a new location */
+void Shape::move(double dx, double dy) {
+ x += dx;
+ y += dy;
+}
+
+int Shape::nshapes = 0;
+
+Circle::Circle(double r) : radius(r) {
+ NumCircles++;
+}
+
+double Circle::area() {
+ return M_PI*radius*radius;
+}
+
+double Circle::perimeter() {
+ return 2*M_PI*radius;
+}
+
+Square::Square(double w) : width(w) {
+ NumSquares++;
+}
+
+double Square::area() {
+ return width*width;
+}
+
+double Square::perimeter() {
+ return 4*width;
+}
+
+int NumSquares = 0;
+int NumCircles = 0;
+
+Square MakeSquare(double r) {
+ return Square(r);
+}
+
+Circle MakeCircle(double w) {
+ return Circle(w);
+}
+
diff --git a/Examples/java/doxygen/example.dsp b/Examples/java/doxygen/example.dsp
new file mode 100644
index 000000000..f52544b95
--- /dev/null
+++ b/Examples/java/doxygen/example.dsp
@@ -0,0 +1,162 @@
+# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=example - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "example.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(JAVA_INCLUDE)" /I "$(JAVA_INCLUDE)\win32" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PostBuild_Desc=Java compile post-build step
+PostBuild_Cmds=echo on "%JAVA_BIN%\javac" *.java
+# End Special Build Tool
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(JAVA_INCLUDE)" /I "$(JAVA_INCLUDE)\win32" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 /out:"example.dll"
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PostBuild_Desc=Java compile post-build step
+PostBuild_Cmds=echo on "%JAVA_BIN%\javac" *.java
+# End Special Build Tool
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.cxx
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\example.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo JAVA_INCLUDE: %JAVA_INCLUDE%
+ echo JAVA_BIN: %JAVA_BIN%
+ echo on
+ ..\..\..\swig.exe -c++ -java "$(InputPath)"
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo JAVA_INCLUDE: %JAVA_INCLUDE%
+ echo JAVA_BIN: %JAVA_BIN%
+ echo on
+ ..\..\..\swig.exe -c++ -java "$(InputPath)"
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/Examples/java/doxygen/example.h b/Examples/java/doxygen/example.h
new file mode 100644
index 000000000..203348ae4
--- /dev/null
+++ b/Examples/java/doxygen/example.h
@@ -0,0 +1,107 @@
+/*! \file example.h
+This file provides a simple set of Shape classes. */
+
+/*! Base class for all shapes.
+ \author Bob
+ */
+class Shape {
+public:
+ /*! Default constructor for creating a Shape */
+ Shape() {
+ nshapes++;
+ }
+ /*! Destructor for destroying a Shape */
+ virtual ~Shape() {
+ nshapes--;
+ }
+ double x; /*!< x co-ordinate */
+ double y; /*!< y co-ordinate */
+ void move(double dx, double dy); /*!< Move a shape to a new co-ordinate
+ \param dx x co-ordinate
+ \param dy y co-ordinate */
+ virtual double area() = 0; /*!< \return the area */
+ virtual double perimeter() = 0; /*!< \return the perimeter */
+ static int nshapes; /*!< Number of shapes currently in existence */
+};
+
+/*! A class for representing a circle.
+ \author Jack
+ */
+class Circle : public Shape {
+private:
+ double radius;
+public:
+ /*! Construct a circle
+ * \param r radius of the circle */
+ Circle(double r);
+ /*! Calculate the area of the circle
+ * \return calculated area */
+ virtual double area();
+ /*! Calculate the perimeter of the circle
+ * \return calculated perimeter of the circle */
+ virtual double perimeter();
+};
+
+/// A class for representing a square.
+class Square : public Shape {
+private:
+ double width;
+public:
+ /** Construct a square
+ * \param w width of the square */
+ Square(double w);
+ /** Calculate the area of the square
+ * \return calculated area */
+ virtual double area();
+ /** Calculate the perimeter of the square
+ * \return calculated perimeter of the square */
+ virtual double perimeter();
+};
+
+/// A class for representing a rectangle, templated on the type for the rectangle dimensions
+template<typename T>
+class Rectangle : public Shape {
+private:
+ T height;
+ T width;
+public:
+ /** Construct a rectangle
+ * \param h height of the rectangle
+ * \param w width of the rectangle */
+ Rectangle(T h, T w) : height(h), width(w) {}
+ /** Calculate the area of the rectangle
+ * \return calculated area */
+ virtual double area() { return width*height; }
+ /** Calculate the perimeter of the rectangle
+ * \return calculated perimeter of the rectangle */
+ virtual double perimeter() { return 2*height + 2*width; }
+};
+
+
+/*! Factory function for creating a square
+ * \param r width of the square
+ * \return a fully constructed square */
+Square MakeSquare(double r);
+
+/*! Factory function for creating a circle
+ * \param w radius of the circle
+ * \return a fully constructed circle */
+Circle MakeCircle(double w);
+
+/*! Factory function for creating a rectangle
+ * \param h height of the rectangle
+ * \param w width of the rectangle
+ * \return a fully constructed rectangle */
+template<typename T>
+Rectangle<T> MakeRectangle(T h, T w) {
+ return Rectangle<T>(h, w);
+}
+
+
+
+/*! Total number of circles ever created */
+extern int NumCircles;
+
+/// Total number of squares ever created
+extern int NumSquares;
+
diff --git a/Examples/java/doxygen/example.i b/Examples/java/doxygen/example.i
new file mode 100644
index 000000000..803563dd9
--- /dev/null
+++ b/Examples/java/doxygen/example.i
@@ -0,0 +1,17 @@
+%module example
+
+%{
+#include "example.h"
+%}
+
+%immutable NumSquares;
+%immutable NumCircles;
+
+%include "example.h"
+
+/*! - this instantiation uses type int */
+%template(RectangleInt) Rectangle<int>;
+
+/*! - this instantiation uses type int */
+%template(MakeRectangleInt) MakeRectangle<int>;
+
diff --git a/Examples/java/doxygen/runme.java b/Examples/java/doxygen/runme.java
new file mode 100644
index 000000000..6b7bb3d01
--- /dev/null
+++ b/Examples/java/doxygen/runme.java
@@ -0,0 +1,63 @@
+// This example shows simple usage of the wrapped Shape classes.
+// The main purpose of this example is to show the doxygen comments translation to JavaDoc comments.
+// Users should look at the generated .java files and if javadoc is installed and working on your system,
+// the generated Java docs can be viewed in a browser by opening the javadocs/index.html file.
+
+import java.io.*;
+
+public class runme {
+ static {
+ try {
+ System.loadLibrary("example");
+ } 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[]) throws InterruptedException, IOException
+ {
+ System.out.println("Creating some objects:");
+ Circle c = example.MakeCircle(10);
+ System.out.println(" Created circle " + c);
+ Square s = example.MakeSquare(10);
+ System.out.println(" Created square " + s);
+ RectangleInt r = example.MakeRectangleInt(10, 20);
+ System.out.println(" Created rectangle " + r);
+
+ System.out.println("\nHere are some properties of the shapes:");
+ Shape[] shapes = {c, s, r};
+ for (int i=0; i<shapes.length; i++) {
+ System.out.println(" " + shapes[i].toString());
+ System.out.println(" area = " + shapes[i].area());
+ System.out.println(" perimeter = " + shapes[i].perimeter());
+ }
+
+ String command = "javadoc -quiet -public -d javadocs example.java Shape.java Circle.java Square.java RectangleInt.java";
+ System.out.println("\nRunning: " + command);
+ Process p = Runtime.getRuntime().exec(command);
+ int exitCode = p.waitFor();
+ System.out.println("javadoc exited with code " + exitCode);
+
+ BufferedReader stdout = new BufferedReader(new InputStreamReader(p.getInputStream()));
+ BufferedReader stderr = new BufferedReader(new InputStreamReader(p.getErrorStream()));
+
+ String line = null;
+
+ System.out.println("stdout from javadoc:\n");
+ while ((line = stdout.readLine()) != null) {
+ System.out.println(line);
+ }
+
+ System.out.println("\nstderr from javadoc:\n");
+ while ((line = stderr.readLine()) != null) {
+ System.out.println(line);
+ }
+
+ if (exitCode != 0) {
+ System.out.println("No java docs were generated!\n");
+ } else {
+ System.out.println("javadoc ran successfully, open javadocs/index.html in your browser to view the generated java docs.");
+ }
+ }
+}
diff --git a/Examples/java/variables/runme.java b/Examples/java/variables/runme.java
index 361a30fa6..a53cc543c 100644
--- a/Examples/java/variables/runme.java
+++ b/Examples/java/variables/runme.java
@@ -76,7 +76,7 @@ public class runme {
System.out.println( " Trying to set 'status'" );
try {
Method m = example.class.getDeclaredMethod("setStatus", new Class[] {Integer.class});
- m.invoke(example.class, new Object[] {new Integer(0)} );
+ m.invoke(example.class, new Object[] {Integer.valueOf(0)} );
System.out.println( "Hey, what's going on?!?! This shouldn't work" );
}
catch (NoSuchMethodException e) {
diff --git a/Examples/javascript/check.list b/Examples/javascript/check.list
index d5f44b81b..7ae61277c 100644
--- a/Examples/javascript/check.list
+++ b/Examples/javascript/check.list
@@ -4,6 +4,7 @@ constant
enum
exception
functor
+native
nspace
operator
overload
diff --git a/Examples/javascript/enum/runme.js b/Examples/javascript/enum/runme.js
index 851d43c4b..f3264889c 100644
--- a/Examples/javascript/enum/runme.js
+++ b/Examples/javascript/enum/runme.js
@@ -30,5 +30,5 @@ f.enum_test(example.Foo.LUDICROUS);
// enum value BLUE of enum color is accessed as property of cconst
console.log("example.BLUE= " + example.BLUE);
-// enum value LUDICROUS of enum Foo::speed is accessed as as property of cconst
+// enum value LUDICROUS of enum Foo::speed is accessed as property of cconst
console.log("example.speed.LUDICROUS= " + example.Foo.LUDICROUS);
diff --git a/Examples/javascript/exception/example.h b/Examples/javascript/exception/example.h
index 7cf917d01..bc744cda7 100644
--- a/Examples/javascript/exception/example.h
+++ b/Examples/javascript/exception/example.h
@@ -16,30 +16,26 @@ public:
char msg[256];
};
-#if defined(_MSC_VER)
- #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
-
class Test {
public:
- int simple() throw(int) {
+ int simple() {
throw(37);
return 1;
}
- int message() throw(const char *) {
+ int message() {
throw("I died.");
return 1;
}
- int hosed() throw(Exc) {
+ int hosed() {
throw(Exc(42,"Hosed"));
return 1;
}
- int unknown() throw(A*) {
+ int unknown() {
static A a;
throw &a;
return 1;
}
- int multi(int x) throw(int, const char *, Exc) {
+ int multi(int x) {
if (x == 1) throw(37);
if (x == 2) throw("Bleah!");
if (x == 3) throw(Exc(42,"No-go-diggy-die"));
@@ -47,7 +43,3 @@ public:
}
};
-#if defined(_MSC_VER)
- #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
-
diff --git a/Examples/javascript/exception/example.i b/Examples/javascript/exception/example.i
index 08672c3a8..ca1084452 100644
--- a/Examples/javascript/exception/example.i
+++ b/Examples/javascript/exception/example.i
@@ -7,6 +7,12 @@
%include "std_string.i"
+%catches(int) Test::simple();
+%catches(const char *) Test::message();
+%catches(Exc) Test::hosed();
+%catches(A*) Test::unknown();
+%catches(int, const char *, Exc) Test::multi(int x);
+
/* Let's just grab the original header file here */
%include "example.h"
diff --git a/Examples/javascript/exception/runme.js b/Examples/javascript/exception/runme.js
index 43ce66d6d..1001a7111 100644
--- a/Examples/javascript/exception/runme.js
+++ b/Examples/javascript/exception/runme.js
@@ -10,7 +10,7 @@ try{
if(error == -1) {
console.log("t.unknown() didn't throw");
} else {
- console.log("successfully catched throw in Test::unknown().");
+ console.log("successfully caught throw in Test::unknown().");
}
}
@@ -22,7 +22,7 @@ catch(error){
if(error == -1) {
console.log("t.simple() did not throw");
} else {
- console.log("successfully catched throw in Test::simple().");
+ console.log("successfully caught throw in Test::simple().");
}
}
@@ -33,7 +33,7 @@ try{
if(error == -1) {
console.log("t.message() did not throw");
} else {
- console.log("successfully catched throw in Test::message().");
+ console.log("successfully caught throw in Test::message().");
}
}
@@ -45,7 +45,7 @@ catch(error){
if(error == -1) {
console.log("t.hosed() did not throw");
} else {
- console.log("successfully catched throw in Test::hosed().");
+ console.log("successfully caught throw in Test::hosed().");
}
}
@@ -58,7 +58,7 @@ for (var i=1; i<4; i++) {
if(error == -1) {
console.log("t.multi(" + i + ") did not throw");
} else {
- console.log("successfully catched throw in Test::multi().");
+ console.log("successfully caught throw in Test::multi().");
}
}
}
diff --git a/Examples/javascript/native/Makefile b/Examples/javascript/native/Makefile
new file mode 100644
index 000000000..0402f8d09
--- /dev/null
+++ b/Examples/javascript/native/Makefile
@@ -0,0 +1,3 @@
+SRCS =
+
+include $(SRCDIR)../example.mk
diff --git a/Examples/javascript/native/binding.gyp.in b/Examples/javascript/native/binding.gyp.in
new file mode 100644
index 000000000..59779aef4
--- /dev/null
+++ b/Examples/javascript/native/binding.gyp.in
@@ -0,0 +1,9 @@
+{
+ "targets": [
+ {
+ "target_name": "example",
+ "sources": [ "example_wrap.cxx" ],
+ "include_dirs": ["$srcdir"]
+ }
+ ]
+}
diff --git a/Examples/javascript/native/example.i b/Examples/javascript/native/example.i
new file mode 100644
index 000000000..a9ca094a7
--- /dev/null
+++ b/Examples/javascript/native/example.i
@@ -0,0 +1,47 @@
+/* File : example.i */
+%module example
+
+// placeholder() used to help SWIG generate "SWIG_From_int" call
+%{
+ int placeholder();
+%}
+int placeholder() { return 0; }
+
+// actual demo code
+%wrapper
+%{
+#ifdef SWIG_V8_VERSION /* Engine: Node || V8 */
+
+ static SwigV8ReturnValue JavaScript_do_work(const SwigV8Arguments &args) {
+ SWIGV8_HANDLESCOPE();
+ const int MY_MAGIC_NUMBER = 5;
+ SWIGV8_VALUE jsresult =
+ SWIG_From_int(static_cast< int >(MY_MAGIC_NUMBER));
+ if (args.Length() != 0)
+ SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments.");
+ SWIGV8_RETURN(jsresult);
+ fail:
+ SWIGV8_RETURN(SWIGV8_UNDEFINED());
+ }
+
+#else /* Engine: JavaScriptCore */
+
+ static JSValueRef JavaScript_do_work(JSContextRef context,
+ JSObjectRef function, JSObjectRef thisObject, size_t argc,
+ const JSValueRef argv[], JSValueRef* exception) {
+ const int MY_MAGIC_NUMBER = 5;
+ JSValueRef jsresult =
+ SWIG_From_int SWIG_JSC_FROM_CALL_ARGS(
+ static_cast< int >(MY_MAGIC_NUMBER));
+ if (argc != 0)
+ SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments.");
+ return jsresult;
+ fail:
+ return JSValueMakeUndefined(context);
+ }
+
+#endif
+%}
+
+
+%native(magicNumber) void JavaScript_do_work();
diff --git a/Examples/javascript/native/example.js b/Examples/javascript/native/example.js
new file mode 100644
index 000000000..2e7f83a06
--- /dev/null
+++ b/Examples/javascript/native/example.js
@@ -0,0 +1 @@
+module.exports = require("build/Release/example");
diff --git a/Examples/javascript/native/index.html b/Examples/javascript/native/index.html
new file mode 100644
index 000000000..7c7d6b071
--- /dev/null
+++ b/Examples/javascript/native/index.html
@@ -0,0 +1,31 @@
+<html>
+<head>
+<title>SWIG:Examples:javascript:native</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+
+<tt>SWIG/Examples/javascript/native/</tt>
+<hr>
+
+<H2>Manually wrapped callback function in JavaScript</H2>
+
+<p>
+This example demonstrates how to manually add callback feature support to a SWIG module.
+</p>
+
+<ul>
+<li><a href="example.i">example.i</a>. Interface file containing the API function and async behind-the-scenes functions.
+<li><a href="runme.java">runme.js</a>. Sample JavaScript program showing the API function being called with a callback function parameter.
+</ul>
+
+<h2>Notes</h2>
+
+The V8 code queues the callback request for processing using the UV interface. An async function callback is invoked when the system is ready to process the next request. When the async function finishes, a completion function callback is invoked to finalize the request. Here the callback function parameter is invoked.
+<br/><br/>
+UV request queueing is only necessary for operations that would take a really long or otherwise unpredictable amount of time (async operations). A callback parameter could also be invoked immediately within the API function.
+
+<hr>
+</body>
+</html>
diff --git a/Examples/javascript/native/runme.js b/Examples/javascript/native/runme.js
new file mode 100644
index 000000000..b5e14d037
--- /dev/null
+++ b/Examples/javascript/native/runme.js
@@ -0,0 +1,3 @@
+var example = require("example");
+
+console.log("My magic number is: ", example.magicNumber());
diff --git a/Examples/javascript/variables/runme.js b/Examples/javascript/variables/runme.js
index a2b5f791c..36ddc5fe9 100644
--- a/Examples/javascript/variables/runme.js
+++ b/Examples/javascript/variables/runme.js
@@ -44,7 +44,7 @@ example.print_vars();
console.log("\nNow I'm going to try and modify some read only variables");
-console.log("Tring to set 'path'");
+console.log("Trying to set 'path'");
try{
example.path = "Whoa!";
console.log("Hey, what's going on?!?! This shouldn't work");
diff --git a/Examples/lua/arrays/runme.lua b/Examples/lua/arrays/runme.lua
index d0aa99813..daba2267f 100644
--- a/Examples/lua/arrays/runme.lua
+++ b/Examples/lua/arrays/runme.lua
@@ -1,6 +1,6 @@
---- importing ----
if string.sub(_VERSION,1,7)=='Lua 5.0' then
- -- lua5.0 doesnt have a nice way to do this
+ -- lua5.0 doesn't have a nice way to do this
lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
assert(lib)()
else
diff --git a/Examples/lua/class/runme.lua b/Examples/lua/class/runme.lua
index 5d140defe..50ac35d6d 100644
--- a/Examples/lua/class/runme.lua
+++ b/Examples/lua/class/runme.lua
@@ -5,7 +5,7 @@
---- importing ----
if string.sub(_VERSION,1,7)=='Lua 5.0' then
- -- lua5.0 doesnt have a nice way to do this
+ -- lua5.0 doesn't have a nice way to do this
lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
assert(lib)()
else
diff --git a/Examples/lua/constants/runme.lua b/Examples/lua/constants/runme.lua
index 751e7d623..ad6bd45d2 100644
--- a/Examples/lua/constants/runme.lua
+++ b/Examples/lua/constants/runme.lua
@@ -2,7 +2,7 @@
---- importing ----
if string.sub(_VERSION,1,7)=='Lua 5.0' then
- -- lua5.0 doesnt have a nice way to do this
+ -- lua5.0 doesn't have a nice way to do this
lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
assert(lib)()
else
diff --git a/Examples/lua/dual/dual.cpp b/Examples/lua/dual/dual.cpp
index 2108a7275..d2b3c75c4 100644
--- a/Examples/lua/dual/dual.cpp
+++ b/Examples/lua/dual/dual.cpp
@@ -16,7 +16,7 @@ and check to see if types Foo and Bar are registered with it
(Bar should be & Foo should not)
Note: Though both the modules exist and are loaded, they are not linked together,
-as they are connected to seperate lua interpreters.
+as they are connected to separate lua interpreters.
When the third lua state loads both example.i and example2.i,
the two modules are now linked together, and all can now find
diff --git a/Examples/lua/exception/example.h b/Examples/lua/exception/example.h
index 251ef1132..bc744cda7 100644
--- a/Examples/lua/exception/example.h
+++ b/Examples/lua/exception/example.h
@@ -1,6 +1,6 @@
/* File : example.h */
-#include <string>
+#include <string.h>
#ifndef SWIG
struct A {
};
@@ -16,30 +16,26 @@ public:
char msg[256];
};
-#if defined(_MSC_VER)
- #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
-
class Test {
public:
- int simple() throw(int&) {
+ int simple() {
throw(37);
return 1;
}
- int message() throw(const char *) {
+ int message() {
throw("I died.");
return 1;
}
- int hosed() throw(Exc) {
+ int hosed() {
throw(Exc(42,"Hosed"));
return 1;
}
- int unknown() throw(A*) {
+ int unknown() {
static A a;
throw &a;
return 1;
}
- int multi(int x) throw(int, const char *, Exc) {
+ int multi(int x) {
if (x == 1) throw(37);
if (x == 2) throw("Bleah!");
if (x == 3) throw(Exc(42,"No-go-diggy-die"));
@@ -47,7 +43,3 @@ public:
}
};
-#if defined(_MSC_VER)
- #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
-
diff --git a/Examples/lua/exception/example.i b/Examples/lua/exception/example.i
index 6187f8eff..a6b43837d 100644
--- a/Examples/lua/exception/example.i
+++ b/Examples/lua/exception/example.i
@@ -12,6 +12,12 @@
// note: only works if Exc is copyable
%apply SWIGTYPE EXCEPTION_BY_VAL {Exc};
+%catches(int) Test::simple();
+%catches(const char *) Test::message();
+%catches(Exc) Test::hosed();
+%catches(A*) Test::unknown();
+%catches(int, const char *, Exc) Test::multi(int x);
+
/* Let's just grab the original header file here */
%include "example.h"
diff --git a/Examples/lua/exception/runme.lua b/Examples/lua/exception/runme.lua
index a798efca7..adb2516c4 100644
--- a/Examples/lua/exception/runme.lua
+++ b/Examples/lua/exception/runme.lua
@@ -2,7 +2,7 @@
---- importing ----
if string.sub(_VERSION,1,7)=='Lua 5.0' then
- -- lua5.0 doesnt have a nice way to do this
+ -- lua5.0 doesn't have a nice way to do this
lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
assert(lib)()
else
@@ -48,7 +48,7 @@ else
end
-- this is a rather strange way to perform the multiple catch of exceptions
-print "calling t:mutli()"
+print "calling t:multi()"
for i=1,3 do
ok,res=pcall(function() t:multi(i) end)
if ok then
diff --git a/Examples/lua/funcptr3/runme.lua b/Examples/lua/funcptr3/runme.lua
index b78c504ef..3cd58520f 100644
--- a/Examples/lua/funcptr3/runme.lua
+++ b/Examples/lua/funcptr3/runme.lua
@@ -1,6 +1,6 @@
---- importing ----
if string.sub(_VERSION,1,7)=='Lua 5.0' then
- -- lua5.0 doesnt have a nice way to do this
+ -- lua5.0 doesn't have a nice way to do this
lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
assert(lib)()
else
diff --git a/Examples/lua/functest/runme.lua b/Examples/lua/functest/runme.lua
index 65b3cc215..773ab5dd6 100644
--- a/Examples/lua/functest/runme.lua
+++ b/Examples/lua/functest/runme.lua
@@ -1,6 +1,6 @@
---- importing ----
if string.sub(_VERSION,1,7)=='Lua 5.0' then
- -- lua5.0 doesnt have a nice way to do this
+ -- lua5.0 doesn't have a nice way to do this
lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
assert(lib)()
else
diff --git a/Examples/lua/functor/runme.lua b/Examples/lua/functor/runme.lua
index adf124ac6..d6f4d08c7 100644
--- a/Examples/lua/functor/runme.lua
+++ b/Examples/lua/functor/runme.lua
@@ -1,7 +1,7 @@
-- Operator overloading example
---- importing ----
if string.sub(_VERSION,1,7)=='Lua 5.0' then
- -- lua5.0 doesnt have a nice way to do this
+ -- lua5.0 doesn't have a nice way to do this
lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
assert(lib)()
else
diff --git a/Examples/lua/import/runme.lua b/Examples/lua/import/runme.lua
index 9cd7ae06c..7057b7bbd 100644
--- a/Examples/lua/import/runme.lua
+++ b/Examples/lua/import/runme.lua
@@ -3,7 +3,7 @@
print("Testing the %import directive")
if string.sub(_VERSION,1,7)=='Lua 5.0' then
- -- lua5.0 doesnt have a nice way to do this
+ -- lua5.0 doesn't have a nice way to do this
function loadit(a)
lib=loadlib(a..'.dll','luaopen_'..a) or loadlib(a..'.so','luaopen_'..a)
assert(lib)()
diff --git a/Examples/lua/nspace/runme.lua b/Examples/lua/nspace/runme.lua
index 876814052..a894cf849 100644
--- a/Examples/lua/nspace/runme.lua
+++ b/Examples/lua/nspace/runme.lua
@@ -5,7 +5,7 @@
---- importing ----
if string.sub(_VERSION,1,7)=='Lua 5.0' then
- -- lua5.0 doesnt have a nice way to do this
+ -- lua5.0 doesn't have a nice way to do this
lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
assert(lib)()
else
diff --git a/Examples/lua/owner/example.cxx b/Examples/lua/owner/example.cxx
index c2c073d79..a4dcc68a1 100644
--- a/Examples/lua/owner/example.cxx
+++ b/Examples/lua/owner/example.cxx
@@ -3,7 +3,9 @@
#include "example.h"
#include <stdio.h>
+#ifndef M_PI
#define M_PI 3.14159265358979323846
+#endif
/* Move the shape to a new location */
void Shape::move(double dx, double dy) {
diff --git a/Examples/lua/owner/runme.lua b/Examples/lua/owner/runme.lua
index 847645448..4d953cba6 100644
--- a/Examples/lua/owner/runme.lua
+++ b/Examples/lua/owner/runme.lua
@@ -1,7 +1,7 @@
-- Operator overloading example
---- importing ----
if string.sub(_VERSION,1,7)=='Lua 5.0' then
- -- lua5.0 doesnt have a nice way to do this
+ -- lua5.0 doesn't have a nice way to do this
lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
assert(lib)()
else
diff --git a/Examples/lua/pointer/runme.lua b/Examples/lua/pointer/runme.lua
index 8deee67e6..2906cc663 100644
--- a/Examples/lua/pointer/runme.lua
+++ b/Examples/lua/pointer/runme.lua
@@ -1,6 +1,6 @@
---- importing ----
if string.sub(_VERSION,1,7)=='Lua 5.0' then
- -- lua5.0 doesnt have a nice way to do this
+ -- lua5.0 doesn't have a nice way to do this
lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
assert(lib)()
else
diff --git a/Examples/lua/simple/runme.lua b/Examples/lua/simple/runme.lua
index 1e5a139c8..5f2e95c2f 100644
--- a/Examples/lua/simple/runme.lua
+++ b/Examples/lua/simple/runme.lua
@@ -1,6 +1,6 @@
---- importing ----
if string.sub(_VERSION,1,7)=='Lua 5.0' then
- -- lua5.0 doesnt have a nice way to do this
+ -- lua5.0 doesn't have a nice way to do this
lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
assert(lib)()
else
diff --git a/Examples/lua/variables/runme.lua b/Examples/lua/variables/runme.lua
index 05b2d3fbf..826845e90 100644
--- a/Examples/lua/variables/runme.lua
+++ b/Examples/lua/variables/runme.lua
@@ -1,6 +1,6 @@
---- importing ----
if string.sub(_VERSION,1,7)=='Lua 5.0' then
- -- lua5.0 doesnt have a nice way to do this
+ -- lua5.0 doesn't have a nice way to do this
lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
assert(lib)()
else
@@ -54,9 +54,9 @@ example.print_vars()
print "\nNow I'm going to try and modify some read only variables";
-print " Tring to set 'path' to 'Whoa!'";
+print " Trying to set 'path' to 'Whoa!'";
if pcall(function() example.path = "Whoa!" end)==true then
- print " Thats funny, it didn't give an error!"
+ print " That's funny, it didn't give an error!"
else
print " It gave an error, as it should"
end
@@ -64,7 +64,7 @@ print(" Just checking the value: path =", example.path)
print " Trying to set 'status' to '0'";
if pcall(function() example.status = 0 end)==true then
- print " Thats funny, it didn't give an error!"
+ print " That's funny, it didn't give an error!"
else
print " It gave an error, as it should"
end
diff --git a/Examples/mzscheme/check.list b/Examples/mzscheme/check.list
index f9e4f11c7..d2554c41c 100644
--- a/Examples/mzscheme/check.list
+++ b/Examples/mzscheme/check.list
@@ -1,4 +1,5 @@
# see top-level Makefile.in
+class
multimap
simple
std_vector
diff --git a/Examples/php5/disown/Makefile b/Examples/mzscheme/class/Makefile
index 8346a1dae..0b36a60d7 100644
--- a/Examples/php5/disown/Makefile
+++ b/Examples/mzscheme/class/Makefile
@@ -4,17 +4,15 @@ SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
CXXSRCS = example.cxx
TARGET = example
INTERFACE = example.i
-LIBS =
SWIGOPT =
check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_run
build:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php5_cpp
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme_cpp
clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_clean
diff --git a/Examples/php5/class/example.cxx b/Examples/mzscheme/class/example.cxx
index 046304519..046304519 100644
--- a/Examples/php5/class/example.cxx
+++ b/Examples/mzscheme/class/example.cxx
diff --git a/Examples/php5/class/example.h b/Examples/mzscheme/class/example.h
index 0dff185b2..0dff185b2 100644
--- a/Examples/php5/class/example.h
+++ b/Examples/mzscheme/class/example.h
diff --git a/Examples/php5/class/example.i b/Examples/mzscheme/class/example.i
index fbdf7249f..fbdf7249f 100644
--- a/Examples/php5/class/example.i
+++ b/Examples/mzscheme/class/example.i
diff --git a/Examples/mzscheme/class/runme.scm b/Examples/mzscheme/class/runme.scm
new file mode 100644
index 000000000..dea0b75bc
--- /dev/null
+++ b/Examples/mzscheme/class/runme.scm
@@ -0,0 +1,60 @@
+; file: runme.scm
+
+; This file illustrates the proxy class C++ interface generated
+; by SWIG.
+
+(load-extension "example.so")
+
+; Convenience wrapper around the display function
+; (which only accepts one argument at the time)
+
+(define (mdisplay-newline . args)
+ (for-each display args)
+ (newline))
+
+; ----- Object creation -----
+
+(mdisplay-newline "Creating some objects:")
+(define c (new-Circle 10))
+(mdisplay-newline " Created circle " c)
+(define s (new-Square 10))
+(mdisplay-newline " Created square " s)
+
+; ----- Access a static member -----
+
+(mdisplay-newline "\nA total of " (Shape-nshapes) " shapes were created")
+
+; ----- Member data access -----
+
+; Set the location of the object
+
+(Shape-x-set c 20)
+(Shape-y-set c 30)
+
+(Shape-x-set s -10)
+(Shape-y-set s 5)
+
+(mdisplay-newline "\nHere is their current position:")
+(mdisplay-newline " Circle = (" (Shape-x-get c) "," (Shape-y-get c) ")")
+(mdisplay-newline " Square = (" (Shape-x-get s) "," (Shape-y-get s) ")")
+
+; ----- Call some methods -----
+
+(mdisplay-newline "\nHere are some properties of the shapes:")
+(define (shape-props o)
+ (mdisplay-newline " " o)
+ (mdisplay-newline " area = " (Shape-area o))
+ (mdisplay-newline " perimeter = " (Shape-perimeter o)))
+(for-each shape-props (list c s))
+
+(mdisplay-newline "\nGuess I'll clean up now")
+
+; Note: this invokes the virtual destructor
+(delete-Shape c)
+(delete-Shape s)
+
+(define s 3)
+(mdisplay-newline (Shape-nshapes) " shapes remain")
+(mdisplay-newline "Goodbye")
+
+(exit 0)
diff --git a/Examples/mzscheme/multimap/Makefile b/Examples/mzscheme/multimap/Makefile
index 713ee43a7..eccd59d82 100644
--- a/Examples/mzscheme/multimap/Makefile
+++ b/Examples/mzscheme/multimap/Makefile
@@ -13,5 +13,6 @@ build:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme
+
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_clean
diff --git a/Examples/mzscheme/multimap/example.c b/Examples/mzscheme/multimap/example.c
index b8360fa8a..e945042ab 100644
--- a/Examples/mzscheme/multimap/example.c
+++ b/Examples/mzscheme/multimap/example.c
@@ -27,7 +27,7 @@ int gcdmain(int argc, char *argv[]) {
return 0;
}
-int count(char *bytes, int len, char c) {
+int charcount(char *bytes, int len, char c) {
int i;
int count = 0;
for (i = 0; i < len; i++) {
diff --git a/Examples/mzscheme/multimap/example.i b/Examples/mzscheme/multimap/example.i
index 515948abc..db4be3d16 100644
--- a/Examples/mzscheme/multimap/example.i
+++ b/Examples/mzscheme/multimap/example.i
@@ -4,7 +4,7 @@
%{
extern int gcd(int x, int y);
extern int gcdmain(int argc, char *argv[]);
-extern int count(char *bytes, int len, char c);
+extern int charcount(char *bytes, int len, char c);
extern void capitalize (char *str, int len);
extern void circle (double cx, double cy);
extern int squareCubed (int n, int *OUTPUT);
@@ -50,7 +50,7 @@ extern int gcdmain(int argc, char *argv[]);
$2 = SCHEME_STRLEN_VAL($input);
}
-extern int count(char *bytes, int len, char c);
+extern int charcount(char *bytes, int len, char c);
/* This example shows how to wrap a function that mutates a string */
@@ -68,7 +68,7 @@ extern int count(char *bytes, int len, char c);
%typemap(argout) (char *str, int len) {
Scheme_Object *s;
- s = scheme_make_sized_string($1,$2,1);
+ s = scheme_make_sized_string($1,$2);
SWIG_APPEND_VALUE(s);
free($1);
}
diff --git a/Examples/mzscheme/multimap/runme.scm b/Examples/mzscheme/multimap/runme.scm
index f1e626f43..6d2c9cce3 100644
--- a/Examples/mzscheme/multimap/runme.scm
+++ b/Examples/mzscheme/multimap/runme.scm
@@ -20,7 +20,7 @@
(gcdmain #("gcdmain" "42" "105"))
-(display (count "Hello World" #\l))
+(display (charcount "Hello World" #\l))
(newline)
(display (capitalize "hello world"))
diff --git a/Examples/mzscheme/simple/Makefile b/Examples/mzscheme/simple/Makefile
index 713ee43a7..eccd59d82 100644
--- a/Examples/mzscheme/simple/Makefile
+++ b/Examples/mzscheme/simple/Makefile
@@ -13,5 +13,6 @@ build:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme
+
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_clean
diff --git a/Examples/mzscheme/simple/README b/Examples/mzscheme/simple/README
deleted file mode 100644
index 07e8da069..000000000
--- a/Examples/mzscheme/simple/README
+++ /dev/null
@@ -1 +0,0 @@
-Simple example from users manual.
diff --git a/Examples/mzscheme/simple/example.c b/Examples/mzscheme/simple/example.c
index f2b074781..1c2af789c 100644
--- a/Examples/mzscheme/simple/example.c
+++ b/Examples/mzscheme/simple/example.c
@@ -1,24 +1,18 @@
-/* Simple example from documentation */
/* File : example.c */
-#include <time.h>
+/* A global variable */
+double Foo = 3.0;
-double My_variable = 3.0;
-
-/* Compute factorial of n */
-int fact(int n) {
- if (n <= 1) return 1;
- else return n*fact(n-1);
-}
-
-/* Compute n mod m */
-int my_mod(int n, int m) {
- return (n % m);
+/* Compute the greatest common divisor of positive integers */
+int gcd(int x, int y) {
+ int g;
+ g = y;
+ while (x > 0) {
+ g = x;
+ x = y % x;
+ y = g;
+ }
+ return g;
}
-char *get_time() {
- long ltime;
- time(&ltime);
- return ctime(&ltime);
-}
diff --git a/Examples/mzscheme/simple/example.i b/Examples/mzscheme/simple/example.i
index 5b3e95580..24093b9bf 100644
--- a/Examples/mzscheme/simple/example.i
+++ b/Examples/mzscheme/simple/example.i
@@ -1,16 +1,7 @@
/* File : example.i */
%module example
-%{
-/* Put headers and other declarations here */
-%}
-
-%include typemaps.i
-
-%rename(mod) my_mod;
%inline %{
-extern double My_variable;
-extern int fact(int);
-extern int my_mod(int n, int m);
-extern char *get_time();
+extern int gcd(int x, int y);
+extern double Foo;
%}
diff --git a/Examples/mzscheme/simple/runme.scm b/Examples/mzscheme/simple/runme.scm
index a98e31fd5..88d32d6fc 100644
--- a/Examples/mzscheme/simple/runme.scm
+++ b/Examples/mzscheme/simple/runme.scm
@@ -2,23 +2,30 @@
(load-extension "example.so")
-(display (get-time))
+; Call our gcd() function
-(printf "My-variable = ~a~n" (my-variable))
+(define x 42)
+(define y 105)
+(define g (gcd x y))
+(display "The gcd of ")
+(display x)
+(display " and ")
+(display y)
+(display " is ")
+(display g)
+(newline)
-(let loop ((i 0))
- (when (< i 14) (begin (display i)
- (display " factorial is ")
- (display (fact i))
- (newline)
- (loop (+ i 1)))))
+; Manipulate the Foo global variable
-(let loop ((i 1))
- (when (< i 250)
- (begin
- (let loopi ((j 1))
- (when (< j 250) (begin (my-variable (+ (my-variable) (mod i j)))
- (loopi (+ j 1)))))
- (loop (+ i 1)))))
+; Output its current value
+(display "Foo = ")
+(display (Foo))
+(newline)
-(printf "My-variable = ~a~n" (my-variable))
+; Change its value
+(Foo 3.1415926)
+
+; See if the change took effect
+(display "Foo = ")
+(display (Foo))
+(newline)
diff --git a/Examples/mzscheme/std_vector/Makefile b/Examples/mzscheme/std_vector/Makefile
index 96f5e80cf..8057465b3 100644
--- a/Examples/mzscheme/std_vector/Makefile
+++ b/Examples/mzscheme/std_vector/Makefile
@@ -1,21 +1,18 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
-SRCS =
+CXXSRCS =
TARGET = example
INTERFACE = example.i
SWIGOPT =
-GPP = `which g++`
-MZC = test -n "/usr/bin/mzc" && /usr/bin/mzc
-
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_run
build:
- $(SWIGEXE) -mzscheme -c++ $(SWIGOPT) $(INTERFACE)
- $(MZC) --compiler $(GPP) ++ccf "-I." --cc example_wrap.cxx
- $(MZC) --linker $(GPP) --ld $(TARGET).so example_wrap.o
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
+ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme_cpp
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_clean
diff --git a/Examples/mzscheme/std_vector/example.h b/Examples/mzscheme/std_vector/example.h
index 4f0dac70d..52e260d6d 100644
--- a/Examples/mzscheme/std_vector/example.h
+++ b/Examples/mzscheme/std_vector/example.h
@@ -17,9 +17,8 @@ std::vector<double> half(const std::vector<double>& v) {
}
void halve_in_place(std::vector<double>& v) {
- // would you believe this is the same as the above?
- std::transform(v.begin(),v.end(),v.begin(),
- std::bind2nd(std::divides<double>(),2.0));
+ for (std::vector<double>::iterator it = v.begin(); it != v.end(); ++it)
+ *it /= 2.0;
}
diff --git a/Examples/mzscheme/std_vector/runme.scm b/Examples/mzscheme/std_vector/runme.scm
index 67351f128..7af9d168e 100644
--- a/Examples/mzscheme/std_vector/runme.scm
+++ b/Examples/mzscheme/std_vector/runme.scm
@@ -9,16 +9,17 @@
(if (< i size)
(begin
(proc v i)
- (with-vector-item v (+ i 1)))))
+ (with-vector-item v (+ i 1)))
+ (void)))
(with-vector-item v 0)))
-(define (with-intvector v proc)
- (with-vector v proc intvector-length))
-(define (with-doublevector v proc)
- (with-vector v proc doublevector-length))
+(define (with-IntVector v proc)
+ (with-vector v proc IntVector-length))
+(define (with-DoubleVector v proc)
+ (with-vector v proc DoubleVector-length))
-(define (print-doublevector v)
- (with-doublevector v (lambda (v i) (display (doublevector-ref v i))
+(define (print-DoubleVector v)
+ (with-DoubleVector v (lambda (v i) (display (DoubleVector-ref v i))
(display " ")))
(newline))
@@ -29,11 +30,11 @@
(newline)
; ... or a wrapped std::vector<int>
-(define v (new-intvector 4))
-(with-intvector v (lambda (v i) (intvector-set! v i (+ i 1))))
+(define v (new-IntVector 4))
+(with-IntVector v (lambda (v i) (IntVector-set! v i (+ i 1))))
(display (average v))
(newline)
-(delete-intvector v)
+(delete-IntVector v)
; half will return a Scheme vector.
; Call it with a Scheme vector...
@@ -42,13 +43,12 @@
(newline)
; ... or a wrapped std::vector<double>
-(define v (new-doublevector))
-(map (lambda (i) (doublevector-push! v i)) '(1 2 3 4))
+(define v (new-DoubleVector))
+(map (lambda (i) (DoubleVector-push! v i)) '(1 2 3 4))
(display (half v))
(newline)
; now halve a wrapped std::vector<double> in place
(halve-in-place v)
-(print-doublevector v)
-(delete-doublevector v)
-
+(print-DoubleVector v)
+(delete-DoubleVector v)
diff --git a/Examples/ocaml/argout_ref/Makefile b/Examples/ocaml/argout_ref/Makefile
index 8b7fc959e..09370940f 100644
--- a/Examples/ocaml/argout_ref/Makefile
+++ b/Examples/ocaml/argout_ref/Makefile
@@ -4,8 +4,7 @@ SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
SRCS = example.c
TARGET = example
INTERFACE = example.i
-MLFILE = example.ml
-PROGFILE = example_prog.ml
+PROGFILE = runme.ml
OBJS = example.o
check: build
@@ -16,16 +15,20 @@ build: static
static:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
+ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ ocaml_core
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
+ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
ocaml_static_cpp
dynamic:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
ocaml_dynamic_cpp
clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' MLFILE='$(MLFILE)' ocaml_clean
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_clean
diff --git a/Examples/ocaml/argout_ref/example.i b/Examples/ocaml/argout_ref/example.i
index 5ea6777fb..a3e6bf8a6 100644
--- a/Examples/ocaml/argout_ref/example.i
+++ b/Examples/ocaml/argout_ref/example.i
@@ -1,8 +1,13 @@
/* File : example.i */
%module example
+%typemap(argout) (const int &x, const int &y) {
+ swig_result = caml_list_append(swig_result, caml_val_int(*$1));
+ swig_result = caml_list_append(swig_result, caml_val_int(*$2));
+}
+
%{
-extern "C" void factor(int &x, int &y);
+extern "C" void factor(const int &x, const int &y);
%}
-extern "C" void factor(int &x, int &y);
+extern "C" void factor(const int &x, const int &y);
diff --git a/Examples/ocaml/argout_ref/example_prog.ml b/Examples/ocaml/argout_ref/example_prog.ml
deleted file mode 100644
index c6de34597..000000000
--- a/Examples/ocaml/argout_ref/example_prog.ml
+++ /dev/null
@@ -1,26 +0,0 @@
-(* example_prog.ml *)
-
-open Swig
-open Example
-
-exception BadReturn
-
-let _ = if Array.length Sys.argv < 3 then
- begin
- print_endline
- ("Usage: " ^ Sys.argv.(0) ^ " n1 n2\n" ^
- " Displays the least factors of the numbers that have the same\n" ^
- " relationship, 16 12 -> 4 3\n") ;
- exit 0
- end
-
-let x = int_of_string Sys.argv.(1)
-let y = int_of_string Sys.argv.(2)
-let (xf,yf) = match _factor '((x to int),(y to int)) with
- C_list [ C_int a ; C_int b ] -> a,b
- | _ -> raise BadReturn
-let _ = print_endline
- ("Factorization of " ^ (string_of_int x) ^
- " and " ^ (string_of_int y) ^
- " is " ^ (string_of_int xf) ^
- " and " ^ (string_of_int yf))
diff --git a/Examples/ocaml/argout_ref/runme.ml b/Examples/ocaml/argout_ref/runme.ml
new file mode 100644
index 000000000..cb9a94255
--- /dev/null
+++ b/Examples/ocaml/argout_ref/runme.ml
@@ -0,0 +1,17 @@
+(* runme.ml *)
+
+open Swig
+open Example
+
+exception BadReturn
+
+let x = if Array.length Sys.argv > 1 then int_of_string Sys.argv.(1) else 16
+let y = if Array.length Sys.argv > 2 then int_of_string Sys.argv.(2) else 12
+let (xf,yf) = match _factor '((x to int),(y to int)) with
+ C_list [ C_int a ; C_int b ] -> a,b
+ | _ -> raise BadReturn
+let _ = print_endline
+ ("Factorization of " ^ (string_of_int x) ^
+ " and " ^ (string_of_int y) ^
+ " is " ^ (string_of_int xf) ^
+ " and " ^ (string_of_int yf))
diff --git a/Examples/ocaml/callback/Makefile b/Examples/ocaml/callback/Makefile
new file mode 100644
index 000000000..b81b5ac1b
--- /dev/null
+++ b/Examples/ocaml/callback/Makefile
@@ -0,0 +1,35 @@
+TOP = ../..
+SWIGEXE = $(TOP)/../swig
+SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
+SWIGOPT =
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+PROGFILE = runme.ml
+OBJS = example.o
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run
+
+build: static
+
+static:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
+ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
+ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ ocaml_core
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
+ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
+ ocaml_static_cpp
+
+toplevel:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
+ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
+ ocaml_static_cpp_toplevel
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_clean
diff --git a/Examples/ocaml/callback/example.c b/Examples/ocaml/callback/example.c
new file mode 100644
index 000000000..4ead01f58
--- /dev/null
+++ b/Examples/ocaml/callback/example.c
@@ -0,0 +1,3 @@
+/* File : example.c */
+
+#include "example.h"
diff --git a/Examples/php5/callback/example.h b/Examples/ocaml/callback/example.h
index 2a0194999..12d888595 100644
--- a/Examples/php5/callback/example.h
+++ b/Examples/ocaml/callback/example.h
@@ -4,13 +4,12 @@
class Callback {
public:
- virtual ~Callback() { std::cout << "Callback::~Callback()" << std:: endl; }
+ virtual ~Callback() { std::cout << "Callback::~Callback()" << std::endl; }
virtual void run() { std::cout << "Callback::run()" << std::endl; }
};
class Caller {
-private:
Callback *_callback;
public:
Caller(): _callback(0) {}
@@ -19,4 +18,3 @@ public:
void setCallback(Callback *cb) { delCallback(); _callback = cb; }
void call() { if (_callback) _callback->run(); }
};
-
diff --git a/Examples/php5/callback/example.i b/Examples/ocaml/callback/example.i
index cf61ef9d2..584da73d9 100644
--- a/Examples/php5/callback/example.i
+++ b/Examples/ocaml/callback/example.i
@@ -4,7 +4,6 @@
#include "example.h"
%}
-/* turn on director wrapping Callback */
%feature("director") Callback;
%include "example.h"
diff --git a/Examples/ocaml/callback/runme.ml b/Examples/ocaml/callback/runme.ml
new file mode 100644
index 000000000..ddc974984
--- /dev/null
+++ b/Examples/ocaml/callback/runme.ml
@@ -0,0 +1,30 @@
+(* file: runme.ml
+
+This file illustrates cross-language polymorphism using directors. *)
+
+open Swig
+open Example
+
+let new_OCamlCallback ob meth args =
+ match meth with
+ | "run" -> print_endline "OCamlCallback.run()"; C_void
+ | _ -> (invoke ob) meth args
+
+let caller = new_Caller '()
+
+let _ = print_endline "Adding and calling a normal C++ callback"
+let _ = print_endline "----------------------------------------"
+
+let callback = new_Callback '()
+let _ = caller -> "setCallback" (callback)
+let _ = caller -> "call" ()
+let _ = caller -> "delCallback" ()
+
+let _ = print_endline "\nAdding and calling an OCaml callback"
+let _ = print_endline "------------------------------------"
+
+let callback = new_derived_object new_Callback (new_OCamlCallback) '()
+let _ = caller -> "setCallback" (callback)
+let _ = caller -> "call" ()
+let _ = caller -> "delCallback" ()
+let _ = print_endline "\nOCaml exit"
diff --git a/Examples/ocaml/check.list b/Examples/ocaml/check.list
index cbdf270f0..cab5a6545 100644
--- a/Examples/ocaml/check.list
+++ b/Examples/ocaml/check.list
@@ -1,10 +1,13 @@
# see top-level Makefile.in
-simple
-std_string
-std_vector
-stl
argout_ref
-shapes
+callback
+class
contract
scoped_enum
+shapes
+simple
+#std_string
+std_vector
+stl
string_from_ptr
+strings_test
diff --git a/Examples/ocaml/class/Makefile b/Examples/ocaml/class/Makefile
new file mode 100644
index 000000000..b81b5ac1b
--- /dev/null
+++ b/Examples/ocaml/class/Makefile
@@ -0,0 +1,35 @@
+TOP = ../..
+SWIGEXE = $(TOP)/../swig
+SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
+SWIGOPT =
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+PROGFILE = runme.ml
+OBJS = example.o
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run
+
+build: static
+
+static:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
+ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
+ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ ocaml_core
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
+ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
+ ocaml_static_cpp
+
+toplevel:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
+ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
+ ocaml_static_cpp_toplevel
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_clean
diff --git a/Examples/contract/simple_cxx/example.cxx b/Examples/ocaml/class/example.c
index e3dd2ca7a..3bac43244 100644
--- a/Examples/contract/simple_cxx/example.cxx
+++ b/Examples/ocaml/class/example.c
@@ -1,5 +1,6 @@
-#include "example.h"
+/* File : example.c */
+#include "example.h"
#define M_PI 3.14159265358979323846
/* Move the shape to a new location */
@@ -10,21 +11,18 @@ void Shape::move(double dx, double dy) {
int Shape::nshapes = 0;
-double Circle::area(void) {
- /* return -1 is to test post-assertion */
- if (radius == 1)
- return -1;
+double Circle::area() {
return M_PI*radius*radius;
}
-double Circle::perimeter(void) {
+double Circle::perimeter() {
return 2*M_PI*radius;
}
-double Square::area(void) {
+double Square::area() {
return width*width;
}
-double Square::perimeter(void) {
+double Square::perimeter() {
return 4*width;
}
diff --git a/Examples/contract/simple_cxx/example.h b/Examples/ocaml/class/example.h
index de708bb7b..0dff185b2 100644
--- a/Examples/contract/simple_cxx/example.h
+++ b/Examples/ocaml/class/example.h
@@ -8,10 +8,10 @@ public:
virtual ~Shape() {
nshapes--;
}
- double x, y;
+ double x, y;
void move(double dx, double dy);
- virtual double area(void) = 0;
- virtual double perimeter(void) = 0;
+ virtual double area() = 0;
+ virtual double perimeter() = 0;
static int nshapes;
};
@@ -20,8 +20,8 @@ private:
double radius;
public:
Circle(double r) : radius(r) { }
- virtual double area(void);
- virtual double perimeter(void);
+ virtual double area();
+ virtual double perimeter();
};
class Square : public Shape {
@@ -29,6 +29,6 @@ private:
double width;
public:
Square(double w) : width(w) { }
- virtual double area(void);
- virtual double perimeter(void);
+ virtual double area();
+ virtual double perimeter();
};
diff --git a/Examples/php5/enum/example.i b/Examples/ocaml/class/example.i
index abf254731..fbdf7249f 100644
--- a/Examples/php5/enum/example.i
+++ b/Examples/ocaml/class/example.i
@@ -5,8 +5,5 @@
#include "example.h"
%}
-
/* Let's just grab the original header file here */
-
%include "example.h"
-
diff --git a/Examples/ocaml/class/runme.ml b/Examples/ocaml/class/runme.ml
new file mode 100644
index 000000000..5e7b1f26c
--- /dev/null
+++ b/Examples/ocaml/class/runme.ml
@@ -0,0 +1,57 @@
+(* file: runme.ml
+
+ This file illustrates the proxy class C++ interface generated
+ by SWIG. *)
+
+open Swig
+open Example
+
+let repr o =
+ Printf.sprintf "<%s at %#x>" (o -> ":classof" () as string) (o -> "&" () as int)
+
+(* ----- Object creation ----- *)
+
+let _ = print_endline "Creating some objects:"
+let c = new_Circle '(10)
+let _ = Printf.printf " Created circle %s\n" (repr c)
+let s = new_Square '(10)
+let _ = Printf.printf " Created square %s\n" (repr s)
+
+(* ----- Access a static member ----- *)
+
+let _ = Printf.printf "\nA total of %d shapes were created\n" (_Shape_nshapes '() as int)
+
+(* ----- Member data access ----- *)
+
+(* Set the location of the object *)
+
+let _ = c -> "[x]" (20)
+let _ = c -> "[y]" (30)
+
+(* Temp var to work around a swigp4 bug (it doesn't properly handle "-" in some cases). *)
+let arg = (-10. to float)
+let _ = s -> "[x]" (arg)
+let _ = s -> "[y]" (5)
+
+let _ = print_endline "\nHere is their current position:"
+let _ = Printf.printf " Circle = (%f, %f)\n" (c -> "[x]" () as float) (c -> "[y]" () as float)
+let _ = Printf.printf " Square = (%f, %f)\n" (s -> "[x]" () as float) (s -> "[y]" () as float)
+
+(* ----- Call some methods ----- *)
+
+let _ = print_endline "\nHere are some properties of the shapes:"
+
+let _ = List.iter (fun o ->
+ Printf.printf " %s\n" (repr o);
+ Printf.printf " area = %f\n" (o -> area () as float);
+ Printf.printf " perimeter = %f\n" (o -> perimeter () as float)
+ ) [c; s]
+
+let _ = print_endline "\nGuess I'll clean up now"
+
+(* Note: this invokes the virtual destructor *)
+let _ = c -> "~" ()
+let _ = s -> "~" ()
+
+let _ = Printf.printf "%d shapes remain\n" (_Shape_nshapes '() as int)
+let _ = print_endline "Goodbye"
diff --git a/Examples/ocaml/contract/Makefile b/Examples/ocaml/contract/Makefile
index c77e6dcc4..8148de142 100644
--- a/Examples/ocaml/contract/Makefile
+++ b/Examples/ocaml/contract/Makefile
@@ -4,8 +4,7 @@ SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
SRCS =
TARGET = example
INTERFACE = example.i
-MLFILE = example.ml
-PROGFILE = example_prog.ml
+PROGFILE = runme.ml
OBJS =
check: build
@@ -16,23 +15,27 @@ build: static
dynamic:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
ocaml_dynamic
static:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
+ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ ocaml_core
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
+ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
ocaml_static
toplevel:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
ocaml_static_toplevel
clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' MLFILE='$(MLFILE)' ocaml_clean
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_clean
diff --git a/Examples/ocaml/contract/example_prog.ml b/Examples/ocaml/contract/runme.ml
index 748109c2b..a77eed701 100644
--- a/Examples/ocaml/contract/example_prog.ml
+++ b/Examples/ocaml/contract/runme.ml
@@ -4,4 +4,9 @@ open Example
let _ = print_endline "This won't throw."
let _ = Printf.printf "Cos 1.0 is %f\n" (_cos '(1.0) as float)
let _ = print_endline "This will throw."
-let _ = Printf.printf "Cos 5.0 is %f\n" (_cos '(5.0) as float)
+let _ =
+ try
+ Printf.printf "Cos 5.0 is %f\n" (_cos '(5.0) as float)
+ with Failure s ->
+ print_endline s ;
+ print_endline "Exception thrown."
diff --git a/Examples/ocaml/scoped_enum/Makefile b/Examples/ocaml/scoped_enum/Makefile
index 9655c98e6..cfed474ef 100644
--- a/Examples/ocaml/scoped_enum/Makefile
+++ b/Examples/ocaml/scoped_enum/Makefile
@@ -4,8 +4,7 @@ SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
SRCS =
TARGET = example
INTERFACE = example.i
-MLFILE = example.ml
-PROGFILE = example_prog.ml
+PROGFILE = runme.ml
OBJS =
check: build
@@ -16,23 +15,27 @@ build: static
dynamic:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
ocaml_dynamic_cpp
static:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
+ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ ocaml_core
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
+ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
ocaml_static_cpp
toplevel:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
ocaml_static_cpp_toplevel
clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' MLFILE='$(MLFILE)' ocaml_clean
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_clean
diff --git a/Examples/ocaml/scoped_enum/example_prog.ml b/Examples/ocaml/scoped_enum/example_prog.ml
deleted file mode 100644
index e19bb3454..000000000
--- a/Examples/ocaml/scoped_enum/example_prog.ml
+++ /dev/null
@@ -1,4 +0,0 @@
-open Swig
-open Example
-
-let _ = _f (match Sys.argv.(1) with "Tag1" -> ``Tag1 | _ -> ``Tag2)
diff --git a/Examples/ocaml/scoped_enum/runme.ml b/Examples/ocaml/scoped_enum/runme.ml
new file mode 100644
index 000000000..f70b6e1f8
--- /dev/null
+++ b/Examples/ocaml/scoped_enum/runme.ml
@@ -0,0 +1,5 @@
+open Swig
+open Example
+
+let arg = if Array.length Sys.argv > 1 then Sys.argv.(1) else "Tag1"
+let _ = _f (match arg with "Tag1" -> ``Tag1 | _ -> ``Tag2)
diff --git a/Examples/ocaml/shapes/Makefile b/Examples/ocaml/shapes/Makefile
index b291d07e8..eab86d298 100644
--- a/Examples/ocaml/shapes/Makefile
+++ b/Examples/ocaml/shapes/Makefile
@@ -5,35 +5,38 @@ SWIGOPT =
SRCS = example.c
TARGET = example
INTERFACE = example.i
-MLFILE = example.ml
-PROGFILE = example_prog.ml
+PROGFILE = runme.ml
OBJS = example.o
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run
-build: static static_top
+build: static toplevel
static:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
+ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ ocaml_core
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
+ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
+ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
ocaml_static_cpp
-static_top:
+toplevel: static
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
+ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
ocaml_static_cpp_toplevel
dynamic:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)'
- MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
+ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
ocaml_dynamic_cpp
clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' MLFILE='$(MLFILE)' ocaml_clean
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_clean
diff --git a/Examples/ocaml/shapes/example_prog.ml b/Examples/ocaml/shapes/runme.ml
index b9e35158a..a7a2f9374 100644
--- a/Examples/ocaml/shapes/example_prog.ml
+++ b/Examples/ocaml/shapes/runme.ml
@@ -1,4 +1,4 @@
-(* example_prog.ml *)
+(* runme.ml *)
open Swig ;;
open Example ;;
diff --git a/Examples/ocaml/simple/Makefile b/Examples/ocaml/simple/Makefile
index 88fef7435..27fdb20f5 100644
--- a/Examples/ocaml/simple/Makefile
+++ b/Examples/ocaml/simple/Makefile
@@ -4,8 +4,7 @@ SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
SRCS = example.c
TARGET = example
INTERFACE = example.i
-MLFILE = example.ml
-PROGFILE = example_prog.ml
+PROGFILE = runme.ml
OBJS = example.o
check: build
@@ -16,23 +15,27 @@ build: static
dynamic:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
ocaml_dynamic
static:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
+ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ ocaml_core
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
+ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
ocaml_static
toplevel:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
ocaml_static_toplevel
clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' MLFILE='$(MLFILE)' ocaml_clean
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_clean
diff --git a/Examples/ocaml/simple/index.html b/Examples/ocaml/simple/index.html
index dace471a3..9ae997be5 100644
--- a/Examples/ocaml/simple/index.html
+++ b/Examples/ocaml/simple/index.html
@@ -1,18 +1,18 @@
<html>
<head>
-<title>SWIG:Examples:python:simple</title>
+<title>SWIG:Examples:ocaml:simple</title>
</head>
<body bgcolor="#ffffff">
-<tt>SWIG/Examples/python/simple/</tt>
+<tt>SWIG/Examples/ocaml/simple/</tt>
<hr>
-<H2>Simple Python Example</H2>
+<H2>Simple Ocaml Example</H2>
<p>
-This example illustrates how you can hook Python to a very simple C program containing
+This example illustrates how you can hook Ocaml to a very simple C program containing
a function and a global variable.
<h2>The C Code</h2>
@@ -57,7 +57,7 @@ extern double Foo;
<h2>Compilation</h2>
<ol>
-<li><tt>swig -python <a href="example.i">example.i</a></tt>
+<li><tt>swig -ocaml <a href="example.i">example.i</a></tt>
<p>
<li>Compile <tt><a href="example_wrap.c">example_wrap.c</a></tt> and <tt><a href="example.c">example.c</a></tt>
to create the extension <tt>examplemodule.so</tt>.
@@ -65,29 +65,29 @@ to create the extension <tt>examplemodule.so</tt>.
<h2>Using the extension</h2>
-Click <a href="example.py">here</a> to see a script that calls our C functions from Python.
+Click <a href="example.ml">here</a> to see a script that calls our C functions from Ocaml.
<h2>Key points</h2>
<ul>
-<li>Use the <tt>import</tt> statement to load your extension module from Python. For example:
+<li>Use the <tt>open</tt> statement to load your extension module from Ocaml. For example:
<blockquote>
<pre>
-import example
+open Example
</pre>
</blockquote>
-<li>C functions work just like Python functions. For example:
+<li>C functions work just like Ocaml functions. For example:
<blockquote>
<pre>
-g = example.gcd(42,105)
+let g = _gcd '(x,y) as int
</pre>
</blockquote>
-<li>C global variables are accessed through a special variable called 'cvar'. For example:
+<li>C global variable Foo is wrapped as _Foo in ocaml. For example:
<blockquote>
<pre>
-a = example.cvar.Foo
+let _ = Printf.printf "Foo = %f\n" (_Foo '() as float)
</pre>
</blockquote>
</ul>
diff --git a/Examples/ocaml/simple/example_prog.ml b/Examples/ocaml/simple/runme.ml
index cc3b973d8..4f7a407ef 100644
--- a/Examples/ocaml/simple/example_prog.ml
+++ b/Examples/ocaml/simple/runme.ml
@@ -1,4 +1,4 @@
-(* example_prog.ml *)
+(* runme.ml *)
open Swig
open Example
diff --git a/Examples/ocaml/std_string/Makefile b/Examples/ocaml/std_string/Makefile
index 099b1fcee..655465692 100644
--- a/Examples/ocaml/std_string/Makefile
+++ b/Examples/ocaml/std_string/Makefile
@@ -15,6 +15,10 @@ static:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ ocaml_core
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
+ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
+ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
ocaml_static_cpp
dynamic:
diff --git a/Examples/ocaml/std_vector/Makefile b/Examples/ocaml/std_vector/Makefile
index 099b1fcee..655465692 100644
--- a/Examples/ocaml/std_vector/Makefile
+++ b/Examples/ocaml/std_vector/Makefile
@@ -15,6 +15,10 @@ static:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ ocaml_core
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
+ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
+ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
ocaml_static_cpp
dynamic:
diff --git a/Examples/ocaml/std_vector/example.h b/Examples/ocaml/std_vector/example.h
index b75359243..d968f6953 100644
--- a/Examples/ocaml/std_vector/example.h
+++ b/Examples/ocaml/std_vector/example.h
@@ -17,9 +17,8 @@ std::vector<double> half(const std::vector<double>& v) {
}
void halve_in_place(std::vector<double>& v) {
- // would you believe this is the same as the above?
- std::transform(v.begin(),v.end(),v.begin(),
- std::bind2nd(std::divides<double>(),2.0));
+ for (std::vector<double>::iterator it = v.begin(); it != v.end(); ++it)
+ *it /= 2.0;
}
diff --git a/Examples/ocaml/std_vector/runme.ml b/Examples/ocaml/std_vector/runme.ml
index feb70dd5e..0f5519b6f 100644
--- a/Examples/ocaml/std_vector/runme.ml
+++ b/Examples/ocaml/std_vector/runme.ml
@@ -14,7 +14,7 @@ let print_DoubleVector v =
(fun v i ->
print_float ((v '[i to int]) as float) ;
print_string " ") ;
- print_endline
+ print_endline ""
end
(* Call average with a Ocaml array... *)
@@ -27,7 +27,7 @@ let rec fill_dv v x =
fill_dv v (x *. x)
end
let _ = fill_dv v 0.999
-let _ = print_DoubleVector v ; print_endline ""
+let _ = print_DoubleVector v
let u = new_IntVector '()
let _ = for i = 1 to 4 do
u -> push_back ((i to int))
diff --git a/Examples/ocaml/stl/Makefile b/Examples/ocaml/stl/Makefile
index 912dd9f8d..363311d95 100644
--- a/Examples/ocaml/stl/Makefile
+++ b/Examples/ocaml/stl/Makefile
@@ -15,19 +15,17 @@ static:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- ocaml_static_cpp
-
-director:
+ ocaml_core
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- ocaml_static_cpp_director
+ ocaml_static_cpp
dynamic:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- ocaml_static_cpp
+ ocaml_dynamic_cpp
toplevel:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
diff --git a/Examples/ocaml/stl/example.h b/Examples/ocaml/stl/example.h
index df5762bfc..da1d50e22 100644
--- a/Examples/ocaml/stl/example.h
+++ b/Examples/ocaml/stl/example.h
@@ -8,7 +8,7 @@
using std::string;
-double vec_write(std::vector<string> v) {
+void vec_write(std::vector<string> v) {
int n = 0;
for( std::vector<string>::iterator i = v.begin();
i != v.end();
diff --git a/Examples/ocaml/stl/example.i b/Examples/ocaml/stl/example.i
index 19a80a605..214ac47a5 100644
--- a/Examples/ocaml/stl/example.i
+++ b/Examples/ocaml/stl/example.i
@@ -7,6 +7,4 @@
#define ENABLE_STRING_VECTOR
%include stl.i
-%feature("director");
-
%include example.h
diff --git a/Examples/ocaml/string_from_ptr/Makefile b/Examples/ocaml/string_from_ptr/Makefile
index f9b027802..5ab5c44a9 100644
--- a/Examples/ocaml/string_from_ptr/Makefile
+++ b/Examples/ocaml/string_from_ptr/Makefile
@@ -1,39 +1,41 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
-SWIGOPT = -c++
SRCS =
TARGET = example
-INTERFACE = foolib.i
-MLFILE = foolib.ml
-PROGFILE = example_prog.ml
+INTERFACE = example.i
+PROGFILE = runme.ml
OBJS =
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run
-build: static static_top
+build: static toplevel
static:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
- ocaml_static_cpp
+ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ ocaml_core
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
+ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
+ ocaml_static
-static_top:
+toplevel: static
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
- ocaml_static_cpp_toplevel
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
+ ocaml_static_toplevel
dynamic:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)'
- MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
- ocaml_dynamic_cpp
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)'
+ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
+ ocaml_dynamic
clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' MLFILE='$(MLFILE)' ocaml_clean
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_clean
diff --git a/Examples/ocaml/string_from_ptr/foolib.i b/Examples/ocaml/string_from_ptr/example.i
index 86e0880eb..d66487940 100644
--- a/Examples/ocaml/string_from_ptr/foolib.i
+++ b/Examples/ocaml/string_from_ptr/example.i
@@ -1,4 +1,4 @@
-%module foolib
+%module example
%{
static int foo( char **buf ) {
*buf = "string from c";
diff --git a/Examples/ocaml/string_from_ptr/example_prog.ml b/Examples/ocaml/string_from_ptr/runme.ml
index 8069dc228..039762017 100644
--- a/Examples/ocaml/string_from_ptr/example_prog.ml
+++ b/Examples/ocaml/string_from_ptr/runme.ml
@@ -1,7 +1,5 @@
-(* foo_program.ml -- the program using foolib *)
-
open Swig (* Give access to the swig library *)
-open Foolib (* This is the name of your swig output *)
+open Example (* This is the name of your swig output *)
let results = _foo '() (* Function names are prefixed with _ in order to make
them lex as identifiers in ocaml. Consider that
diff --git a/Examples/ocaml/strings_test/Makefile b/Examples/ocaml/strings_test/Makefile
index 24e2e6cca..38cf234da 100644
--- a/Examples/ocaml/strings_test/Makefile
+++ b/Examples/ocaml/strings_test/Makefile
@@ -9,21 +9,25 @@ PROGFILE = runme.ml
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run
-build: static top
+build: static toplevel
static:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ ocaml_core
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
+ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
+ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
ocaml_static_cpp
dynamic:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- ocaml_static_cpp
+ ocaml_dynamic_cpp
-top:
+toplevel: static
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
diff --git a/Examples/ocaml/strings_test/example.h b/Examples/ocaml/strings_test/example.h
index 959404b5d..9dbc881a8 100644
--- a/Examples/ocaml/strings_test/example.h
+++ b/Examples/ocaml/strings_test/example.h
@@ -19,7 +19,7 @@ void takes_char_ptr( char *p ) {
cout << "takes_char_ptr( \"" << p << "\" );" << endl;
}
-char *gives_char_ptr() {
+const char *gives_const_char_ptr() {
return "foo";
}
@@ -28,8 +28,8 @@ void takes_and_gives_std_string( std::string &inout ) {
inout.insert( inout.end(), ']' );
}
-void takes_and_gives_char_ptr( char *&inout ) {
- char *pout = strchr( inout, '.' );
+void takes_and_gives_const_char_ptr( const char *&inout ) {
+ const char *pout = strchr( inout, '.' );
if( pout ) inout = pout + 1;
else inout = "foo";
}
diff --git a/Examples/ocaml/strings_test/example.i b/Examples/ocaml/strings_test/example.i
index be9eabfbc..d360715c1 100644
--- a/Examples/ocaml/strings_test/example.i
+++ b/Examples/ocaml/strings_test/example.i
@@ -11,4 +11,5 @@ using std::string;
#include "example.h"
%}
+%include "std_string.i"
%include example.h
diff --git a/Examples/ocaml/strings_test/runme.ml b/Examples/ocaml/strings_test/runme.ml
index 0eb56379c..727bc025e 100644
--- a/Examples/ocaml/strings_test/runme.ml
+++ b/Examples/ocaml/strings_test/runme.ml
@@ -8,10 +8,10 @@ let _ = print_endline
("_gives_std_string <<" ^ (get_string (_gives_std_string C_void)) ^ " >>")
let _ = _takes_char_ptr (C_string "bar")
let _ = print_endline
- ("_gives_char_ptr << " ^ (get_string (_gives_char_ptr C_void)) ^ " >>")
+ ("_gives_const_char_ptr << " ^ (get_string (_gives_const_char_ptr C_void)) ^ " >>")
let _ = print_endline
("_takes_and_gives_std_string << " ^
(get_string (_takes_and_gives_std_string (C_string "foo"))) ^ " >>")
let _ = print_endline
- ("_takes_and_gives_char_ptr << " ^
- (get_string (_takes_and_gives_char_ptr (C_string "bar.bar"))) ^ " >>")
+ ("_takes_and_gives_const_char_ptr << " ^
+ (get_string (_takes_and_gives_const_char_ptr (C_string "bar.bar"))) ^ " >>")
diff --git a/Examples/octave/check.list b/Examples/octave/check.list
index e9c719231..54a591042 100644
--- a/Examples/octave/check.list
+++ b/Examples/octave/check.list
@@ -8,8 +8,8 @@ extend
funcptr
funcptr2
functor
-operator
module_load
+operator
pointer
reference
simple
diff --git a/Examples/octave/example.mk b/Examples/octave/example.mk
index 1ab96f038..88608a12b 100644
--- a/Examples/octave/example.mk
+++ b/Examples/octave/example.mk
@@ -8,25 +8,25 @@ TARGET = swigexample
INTERFACE = example.i
check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
+ $(MAKE) -f $(TOP)/Makefile PCHSUPPORT=no SRCDIR='$(SRCDIR)' octave_run
build:
ifneq (,$(SRCS))
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
+ $(MAKE) -f $(TOP)/Makefile PCHSUPPORT=no SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
else
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
+ $(MAKE) -f $(TOP)/Makefile PCHSUPPORT=no SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
endif
ifneq (,$(TARGET2)$(SWIGOPT2))
ifneq (,$(SRCS))
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
+ $(MAKE) -f $(TOP)/Makefile PCHSUPPORT=no SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='$(SWIGOPT2)' TARGET='$(TARGET2)' INTERFACE='$(INTERFACE)' octave
else
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
+ $(MAKE) -f $(TOP)/Makefile PCHSUPPORT=no SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='$(SWIGOPT2)' TARGET='$(TARGET2)' INTERFACE='$(INTERFACE)' octave_cpp
endif
@@ -34,4 +34,4 @@ endif
clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
+ $(MAKE) -f $(TOP)/Makefile PCHSUPPORT=no SRCDIR='$(SRCDIR)' octave_clean
diff --git a/Examples/octave/extend/runme.m b/Examples/octave/extend/runme.m
index bc73184a8..c88a7c151 100644
--- a/Examples/octave/extend/runme.m
+++ b/Examples/octave/extend/runme.m
@@ -14,7 +14,7 @@ CEO=@(name) subclass(swigexample.Manager(name),'getPosition',@(self) "CEO");
# Create an instance of our employee extension class, CEO. The calls to
# getName() and getPosition() are standard, the call to getTitle() uses
-# the director wrappers to call CEO.getPosition. e = CEO("Alice")
+# the director wrappers to call CEO.getPosition.
e = CEO("Alice");
printf("%s is a %s\n",e.getName(),e.getPosition());
diff --git a/Examples/octave/module_load/runme.m b/Examples/octave/module_load/runme.m
index 0e327efcd..beab1213b 100644
--- a/Examples/octave/module_load/runme.m
+++ b/Examples/octave/module_load/runme.m
@@ -5,63 +5,73 @@ endif
# load module
clear all;
+assert(exist("swigexample") == 3);
swigexample;
+assert(isglobal("swigexample"));
assert(cvar.ivar == ifunc);
-assert(exist("swigexample","var"));
clear all
+assert(exist("swigexample") == 3);
swigexample;
+assert(isglobal("swigexample"));
assert(cvar.ivar == ifunc);
-assert(exist("swigexample","var"));
clear all
# load module in a function globally before base context
clear all;
-function testme
+function testme_1
+ assert(exist("swigexample") == 3);
swigexample;
+ assert(isglobal("swigexample"));
assert(cvar.ivar == ifunc);
- assert(exist("swigexample","var"));
endfunction
-testme
-testme
+testme_1
+testme_1
+assert(exist("swigexample") == 3);
swigexample;
+assert(isglobal("swigexample"));
assert(cvar.ivar == ifunc);
-assert(exist("swigexample","var"));
clear all
-function testme
+function testme_2
+ assert(exist("swigexample") == 3);
swigexample;
+ assert(isglobal("swigexample"));
assert(cvar.ivar == ifunc);
- assert(exist("swigexample","var"));
endfunction
-testme
-testme
+testme_2
+testme_2
+assert(exist("swigexample") == 3);
swigexample;
+assert(isglobal("swigexample"));
assert(cvar.ivar == ifunc);
-assert(exist("swigexample","var"));
clear all
# load module in a function globally after base context
clear all;
+assert(exist("swigexample") == 3);
swigexample;
+assert(isglobal("swigexample"));
assert(cvar.ivar == ifunc);
-assert(exist("swigexample","var"));
-function testme
+function testme_3
+ assert(exist("swigexample") == 3);
swigexample;
+ assert(isglobal("swigexample"));
assert(cvar.ivar == ifunc);
- assert(exist("swigexample","var"));
endfunction
-testme
-testme
+testme_3
+testme_3
clear all
+assert(exist("swigexample") == 3);
swigexample;
+assert(isglobal("swigexample"));
assert(cvar.ivar == ifunc);
-assert(exist("swigexample","var"));
-function testme
+function testme_4
+ assert(exist("swigexample") == 3);
swigexample;
+ assert(isglobal("swigexample"));
assert(cvar.ivar == ifunc);
- assert(exist("swigexample","var"));
endfunction
-testme
-testme
+testme_4
+testme_4
clear all
# octave 3.0.5 randomly crashes on the remaining tests
@@ -71,13 +81,16 @@ endif
# load module with no cvar
clear all;
+who;
+assert(exist("swigexample2") == 3);
swigexample2;
+assert(isglobal("swigexample2"));
assert(swigexample2.ivar == ifunc);
-assert(exist("swigexample2","var"));
-assert(!isglobal("cvar"))
+assert(!exist("cvar", "var"));
clear all
+assert(exist("swigexample2") == 3);
swigexample2;
+assert(isglobal("swigexample2"));
assert(swigexample2.ivar == ifunc);
-assert(exist("swigexample2","var"));
-assert(!isglobal("cvar"))
+assert(!exist("cvar", "var"));
clear all
diff --git a/Examples/octave/variables/runme.m b/Examples/octave/variables/runme.m
index 71ac72f29..df4cad77c 100644
--- a/Examples/octave/variables/runme.m
+++ b/Examples/octave/variables/runme.m
@@ -51,7 +51,7 @@ swigexample.print_vars();
printf("\nNow I'm going to try and modify some read only variables\n");
-printf(" Tring to set 'path'\n");
+printf(" Trying to set 'path'\n");
try
swigexample.cvar.path = "Whoa!";
printf("Hey, what's going on?!?! This shouldn't work\n");
diff --git a/Examples/perl5/check.list b/Examples/perl5/check.list
index dda849311..78d45fc0b 100644
--- a/Examples/perl5/check.list
+++ b/Examples/perl5/check.list
@@ -6,7 +6,6 @@ constants2
extend
funcptr
import
-java
multimap
multiple_inheritance
pointer
diff --git a/Examples/perl5/java/Example.java b/Examples/perl5/java/Example.java
deleted file mode 100644
index 91ddb1ac5..000000000
--- a/Examples/perl5/java/Example.java
+++ /dev/null
@@ -1,29 +0,0 @@
-public class Example {
- public int mPublicInt;
-
- public Example() {
- mPublicInt = 0;
- }
-
- public Example(int IntVal) {
- mPublicInt = IntVal;
- }
-
-
- public int Add(int a, int b) {
- return (a+b);
- }
-
- public float Add(float a, float b) {
- return (a+b);
- }
-
- public String Add(String a, String b) {
- return (a+b);
- }
-
- public Example Add(Example a, Example b) {
- return new Example(a.mPublicInt + b.mPublicInt);
- }
-}
-
diff --git a/Examples/perl5/java/Makefile b/Examples/perl5/java/Makefile
deleted file mode 100644
index 7c133235f..000000000
--- a/Examples/perl5/java/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-TOP = ../..
-SWIGEXE = $(TOP)/../swig
-SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
-CXXSRCS =
-TARGET = example
-INTERFACE = example.i
-LIBS = -lm
-
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run
-
-build: Example.class Example.h
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
- SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- CXXSHARED="gcj -fpic -shared Example.class" PERL5_CCFLAGS='' PERL5_EXP='' LIBS="-lstdc++" perl5_cpp
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean
- rm -f *.class Example.h
-
-Example.class Example.h: $(SRCDIR)Example.java
- gcj -d . -fPIC -C -c -g $(SRCDIR)Example.java
- gcjh Example.class
diff --git a/Examples/perl5/java/example.i b/Examples/perl5/java/example.i
deleted file mode 100644
index a82abb267..000000000
--- a/Examples/perl5/java/example.i
+++ /dev/null
@@ -1,10 +0,0 @@
-%module example
-
-%include <cni.i>
-
-%{
-#include "Example.h"
-%}
-
-
-%include Example.h
diff --git a/Examples/perl5/java/runme.pl b/Examples/perl5/java/runme.pl
deleted file mode 100644
index 56ad6e408..000000000
--- a/Examples/perl5/java/runme.pl
+++ /dev/null
@@ -1,29 +0,0 @@
-use example;
-
-example::JvCreateJavaVM(undef);
-example::JvAttachCurrentThread(undef, undef);
-
-$e1 = new example::Example(1);
-print $e1->{mPublicInt},"\n";
-
-$e2 = new example::Example(2);
-print $e2->{mPublicInt},"\n";
-
-$i = $e1->Add(1,2);
-print $i,"\n";
-
-$d = $e2->Add(1.0,2.0);
-print $d,"\n";
-
-$d = $e2->Add("1","2");
-print $d,"\n";
-
-$e3 = $e1->Add($e1,$e2);
-print $e3->{mPublicInt},"\n";
-
-
-$s = $e2->Add("a","b");
-print $s,"\n";
-
-
-example::JvDetachCurrentThread()
diff --git a/Examples/perl5/variables/runme.pl b/Examples/perl5/variables/runme.pl
index 76e3dc8bc..2c3484db7 100644
--- a/Examples/perl5/variables/runme.pl
+++ b/Examples/perl5/variables/runme.pl
@@ -65,7 +65,7 @@ if (!$@) {
}
print " get error for 'status'\n";
-print " Tring to set 'path'\n";
+print " Trying to set 'path'\n";
eval { $example::path = "Whoa!";};
if (!$@) {
die("path");
diff --git a/Examples/php/constants/runme.php b/Examples/php/constants/runme.php
index cea06485f..91c597a40 100644
--- a/Examples/php/constants/runme.php
+++ b/Examples/php/constants/runme.php
@@ -12,16 +12,12 @@ print "EXPR = " . EXPR . " (should be 48.5484)\n";
print "iconst = " . iconst . " (should be 37)\n";
print "fconst = " . fconst . " (should be 3.14)\n";
-if (EXTERN!="EXTERN") {
- print "EXTERN = " . EXTERN . " (Arg! This shouldn't print anything)\n";
-} else {
- print "EXTERN defaults to 'EXTERN', it probably isn't defined (good)\n";
+$c = get_defined_constants();
+if (array_key_exists("EXTERN", $c)) {
+ print "EXTERN = " . $c["EXTERN"] . " (Arg! This shouldn't print anything)\n";
}
-
-if (FOO!="FOO") {
- print "FOO = " . FOO . "(Arg! This shouldn't print anything)\n";
-} else {
- print "FOO defaults to 'FOO', it probably isn't defined (good)\n";
+if (array_key_exists("FOO", $c)) {
+ print "FOO = " . $c["FOO"] . " (Arg! This shouldn't print anything)\n";
}
diff --git a/Examples/php/disown/runme.php b/Examples/php/disown/runme.php
index d90b03a9d..a70d7b061 100644
--- a/Examples/php/disown/runme.php
+++ b/Examples/php/disown/runme.php
@@ -26,7 +26,7 @@ $container->addShape($s);
print "\nA total of " . Shape::nshapes() . " shapes were created\n";
# ----- Delete by the old references -----
-# This should not truely delete the shapes because they are now owned
+# This should not truly delete the shapes because they are now owned
# by the ShapeContainer.
print "Delete the old references.";
@@ -38,7 +38,7 @@ $s = NULL;
print "\nA total of " . Shape::nshapes() . " shapes remain\n";
# ----- Delete by the container -----
-# This should truely delete the shapes
+# This should truly delete the shapes
print "Delete the container.";
$container = NULL;
diff --git a/Examples/php/enum/Makefile b/Examples/php/enum/Makefile
index 4483f781e..063a0645f 100644
--- a/Examples/php/enum/Makefile
+++ b/Examples/php/enum/Makefile
@@ -5,7 +5,7 @@ CXXSRCS = example.cxx
TARGET = example
INTERFACE = example.i
LIBS =
-SWIGOPT = -noproxy
+SWIGOPT =
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run
diff --git a/Examples/php/enum/runme.php b/Examples/php/enum/runme.php
index 55b0bc4c3..813476645 100644
--- a/Examples/php/enum/runme.php
+++ b/Examples/php/enum/runme.php
@@ -11,22 +11,22 @@ print " BLUE =" . BLUE;
print " GREEN =" . GREEN;
print "\n*** Foo::speed ***";
-print " Foo_IMPULSE =" . Foo_IMPULSE;
-print " Foo_WARP =" . Foo_WARP;
-print " Foo_LUDICROUS =" . Foo_LUDICROUS;
+print " Foo::IMPULSE =" . Foo::IMPULSE;
+print " Foo::WARP =" . Foo::WARP;
+print " Foo::LUDICROUS =" . Foo::LUDICROUS;
print "\nTesting use of enums with functions\n";
-enum_test(RED, Foo_IMPULSE);
-enum_test(BLUE, Foo_WARP);
-enum_test(GREEN, Foo_LUDICROUS);
+enum_test(RED, Foo::IMPULSE);
+enum_test(BLUE, Foo::WARP);
+enum_test(GREEN, Foo::LUDICROUS);
enum_test(1234,5678);
print "\nTesting use of enum with class method\n";
-$f = new_Foo();
+$f = new Foo();
-Foo_enum_test($f,Foo_IMPULSE);
-Foo_enum_test($f,Foo_WARP);
-Foo_enum_test($f,Foo_LUDICROUS);
+$f->enum_test(Foo::IMPULSE);
+$f->enum_test(Foo::WARP);
+$f->enum_test(Foo::LUDICROUS);
?>
diff --git a/Examples/php/pragmas/example.i b/Examples/php/pragmas/example.i
index c7e8bf303..ea9590b6f 100644
--- a/Examples/php/pragmas/example.i
+++ b/Examples/php/pragmas/example.i
@@ -25,7 +25,8 @@
%pragma(php) code="
# This code is inserted into example.php
-echo \"this was php code\\n\";
+echo \"This was php code\\n\";
"
+%pragma(php) version="1.5"
%pragma(php) phpinfo="php_info_print_table_start();"
diff --git a/Examples/php/pragmas/include.php b/Examples/php/pragmas/include.php
index e19880a06..11d985d66 100644
--- a/Examples/php/pragmas/include.php
+++ b/Examples/php/pragmas/include.php
@@ -1,7 +1,7 @@
<?php
# This code is inserted into example.php
-echo "this is include.php\n";
+echo "This is include.php\n";
?>
diff --git a/Examples/php/pragmas/runme.php b/Examples/php/pragmas/runme.php
index 538548b6f..7b2c179cb 100644
--- a/Examples/php/pragmas/runme.php
+++ b/Examples/php/pragmas/runme.php
@@ -1,5 +1,9 @@
<?php
+# For finding include.php
+set_include_path(realpath(dirname(__FILE__)) . PATH_SEPARATOR . get_include_path());
+
require "example.php";
+echo "Version - " . ((new ReflectionExtension('example'))->getVersion()) . "\n";
?>
diff --git a/Examples/php/value/Makefile b/Examples/php/value/Makefile
index 28fc3a127..47e5ed9f9 100644
--- a/Examples/php/value/Makefile
+++ b/Examples/php/value/Makefile
@@ -5,7 +5,7 @@ SRCS = example.c
TARGET = example
INTERFACE = example.i
LIBS =
-SWIGOPT = -noproxy
+SWIGOPT =
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run
diff --git a/Examples/php/value/runme.php b/Examples/php/value/runme.php
index 49115376c..569c87cf5 100644
--- a/Examples/php/value/runme.php
+++ b/Examples/php/value/runme.php
@@ -3,15 +3,15 @@
require "example.php";
- $v = new_vector();
- vector_x_set($v,1.0);
- vector_y_set($v,2.0);
- vector_z_set($v,3.0);
+ $v = new Vector();
+ $v->x = 1.0;
+ $v->y = 2.0;
+ $v->z = 3.0;
- $w = new_vector();
- vector_x_set($w,10.0);
- vector_y_set($w,11.0);
- vector_z_set($w,12.0);
+ $w = new Vector();
+ $w->x = 10.0;
+ $w->y = 11.0;
+ $w->z = 12.0;
echo "I just created the following vector\n";
vector_print($v);
@@ -25,7 +25,7 @@
echo "\nNow I'm going to add the vectors together\n";
- $r = new_vector();
+ $r = new Vector();
vector_add($v, $w, $r);
vector_print($r);
diff --git a/Examples/php/variables/runme.php b/Examples/php/variables/runme.php
index bbfeb610b..14f27f389 100644
--- a/Examples/php/variables/runme.php
+++ b/Examples/php/variables/runme.php
@@ -26,10 +26,10 @@
echo "pt = ".pt_get(), point_print(pt_get()) , "\n";
/* Try to set the values of some global variables */
-$a = "42.14";
+ $a = "42.14";
ivar_set($a);
-echo "a = $a\n";
+ echo "a = $a\n";
svar_set(-31000);
lvar_set(65537);
uivar_set(123456);
diff --git a/Examples/php5/callback/Makefile b/Examples/php5/callback/Makefile
deleted file mode 100644
index 3a34106c3..000000000
--- a/Examples/php5/callback/Makefile
+++ /dev/null
@@ -1,19 +0,0 @@
-TOP = ../..
-SWIGEXE = $(TOP)/../swig
-SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
-CXXSRCS = example.cxx
-TARGET = example
-INTERFACE = example.i
-LIBS = -lm
-SWIGOPT =
-
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' \
- SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php5_cpp
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean
diff --git a/Examples/php5/callback/example.cxx b/Examples/php5/callback/example.cxx
deleted file mode 100644
index 450d75608..000000000
--- a/Examples/php5/callback/example.cxx
+++ /dev/null
@@ -1,4 +0,0 @@
-/* File : example.cxx */
-
-#include "example.h"
-
diff --git a/Examples/php5/callback/index.html b/Examples/php5/callback/index.html
deleted file mode 100644
index 2a6cbdff9..000000000
--- a/Examples/php5/callback/index.html
+++ /dev/null
@@ -1,19 +0,0 @@
-<html>
-<head>
-<title>SWIG:Examples:php5:callback</title>
-</head>
-
-<body bgcolor="#ffffff">
-
-
-<tt>SWIG/Examples/php5/callback/</tt>
-<hr>
-
-<H2>Implementing C++ callbacks in PHP5</H2>
-
-<p>
-This example illustrates how to use directors to implement C++ callbacks in PHP5.
-
-<hr>
-</body>
-</html>
diff --git a/Examples/php5/callback/runme.php b/Examples/php5/callback/runme.php
deleted file mode 100644
index 2be71994f..000000000
--- a/Examples/php5/callback/runme.php
+++ /dev/null
@@ -1,47 +0,0 @@
-<?php
-
-# This file illustrates the cross language polymorphism using directors.
-
-require("example.php");
-
-# Class, which overwrites Callback::run().
-
-class PhpCallback extends Callback {
- function run() {
- print "PhpCallback.run()\n";
- }
-};
-
-# Create an Caller instance
-
-$caller = new Caller();
-
-# Add a simple C++ callback (caller owns the callback, so
-# we disown it first by clearing the .thisown flag).
-
-print "Adding and calling a normal C++ callback\n";
-print "----------------------------------------\n";
-
-$callback = new Callback();
-$callback->thisown = 0;
-$caller->setCallback($callback);
-$caller->call();
-$caller->delCallback();
-
-print "\n";
-print "Adding and calling a PHP callback\n";
-print "------------------------------------\n";
-
-# Add a PHP callback.
-
-$callback = new PhpCallback();
-$callback->thisown = 0;
-$caller->setCallback($callback);
-$caller->call();
-$caller->delCallback();
-
-# All done.
-
-print "php exit\n";
-
-?>
diff --git a/Examples/php5/check.list b/Examples/php5/check.list
deleted file mode 100644
index fef3feba6..000000000
--- a/Examples/php5/check.list
+++ /dev/null
@@ -1,19 +0,0 @@
-# see top-level Makefile.in
-# (see also top-level configure.ac kludge)
-callback
-class
-constants
-cpointer
-disown
-enum
-extend
-funcptr
-overloading
-pointer
-pragmas
-proxy
-reference
-simple
-sync
-value
-variables
diff --git a/Examples/php5/class/Makefile b/Examples/php5/class/Makefile
deleted file mode 100644
index 8346a1dae..000000000
--- a/Examples/php5/class/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-TOP = ../..
-SWIGEXE = $(TOP)/../swig
-SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
-CXXSRCS = example.cxx
-TARGET = example
-INTERFACE = example.i
-LIBS =
-SWIGOPT =
-
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
- SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php5_cpp
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean
diff --git a/Examples/php5/class/runme.php b/Examples/php5/class/runme.php
deleted file mode 100644
index 99c253b46..000000000
--- a/Examples/php5/class/runme.php
+++ /dev/null
@@ -1,60 +0,0 @@
-<?php
-
-# This example illustrates how member variables are wrapped.
-
-require("example.php");
-
-# ----- Object creation -----
-
-print "Creating some objects:\n";
-$c = new Circle(10);
-print " Created circle\n";
-$s = new Square(10);
-print " Created square\n";
-
-# ----- Access a static member -----
-
-print "\nA total of " . Shape::nshapes() . " shapes were created\n";
-
-# ----- Member data access -----
-
-# Set the location of the object.
-# Note: methods in the base class Shape are used since
-# x and y are defined there.
-
-$c->x = 20;
-$c->y = 30;
-$s->x = -10;
-$s->y = 5;
-
-print "\nHere is their current position:\n";
-print " Circle = ({$c->x},{$c->y})\n";
-print " Square = ({$s->x},{$s->y})\n";
-
-# ----- Call some methods -----
-
-# Notice how the Shape_area() and Shape_perimeter() functions really
-# invoke the appropriate virtual method on each object.
-print "\nHere are some properties of the shapes:\n";
-foreach (array($c,$s) as $o) {
- print " ". get_class($o) . "\n";
- print " area = {$o->area()}\n";
- print " perimeter = {$o->perimeter()}\n";
-}
-
-# ----- Delete everything -----
-
-print "\nGuess I'll clean up now\n";
-
-# Note: this invokes the virtual destructor
-$c = NULL;
-$s = NULL;
-
-# and don't forget the $o from the for loop above. It still refers to
-# the square.
-$o = NULL;
-
-print Shape::nshapes() . " shapes remain\n";
-print "Goodbye\n";
-
-?>
diff --git a/Examples/php5/constants/Makefile b/Examples/php5/constants/Makefile
deleted file mode 100644
index f9557fa89..000000000
--- a/Examples/php5/constants/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-TOP = ../..
-SWIGEXE = $(TOP)/../swig
-SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
-SRCS =
-TARGET = example
-INTERFACE = example.i
-LIBS =
-SWIGOPT =
-
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
- SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php5
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean
diff --git a/Examples/php5/constants/example.i b/Examples/php5/constants/example.i
deleted file mode 100644
index 0098a893a..000000000
--- a/Examples/php5/constants/example.i
+++ /dev/null
@@ -1,26 +0,0 @@
-/* File : example.i */
-%module example
-
-/* A few preprocessor macros */
-
-#define ICONST 42
-#define FCONST 2.1828
-#define CCONST 'x'
-#define CCONST2 '\n'
-#define SCONST "Hello World"
-#define SCONST2 "\"Hello World\""
-
-/* This should work just fine */
-#define EXPR ICONST + 3*(FCONST)
-
-/* This shouldn't do anything */
-#define EXTERN extern
-
-/* Neither should this (BAR isn't defined) */
-#define FOO (ICONST + BAR)
-
-/* The following statements also produce constants */
-%constant int iconst = 37;
-%constant double fconst = 3.14;
-
-
diff --git a/Examples/php5/constants/runme.php b/Examples/php5/constants/runme.php
deleted file mode 100644
index cea06485f..000000000
--- a/Examples/php5/constants/runme.php
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-
-require "example.php";
-
-print "ICONST = " . ICONST . " (should be 42)\n";
-print "FCONST = " . FCONST . " (should be 2.1828)\n";
-print "CCONST = " . CCONST . " (should be 'x')\n";
-print "CCONST2 = " . CCONST2 . " (this should be on a new line)\n";
-print "SCONST = " . SCONST . " (should be 'Hello World')\n";
-print "SCONST2 = " . SCONST2 . " (should be '\"Hello World\"')\n";
-print "EXPR = " . EXPR . " (should be 48.5484)\n";
-print "iconst = " . iconst . " (should be 37)\n";
-print "fconst = " . fconst . " (should be 3.14)\n";
-
-if (EXTERN!="EXTERN") {
- print "EXTERN = " . EXTERN . " (Arg! This shouldn't print anything)\n";
-} else {
- print "EXTERN defaults to 'EXTERN', it probably isn't defined (good)\n";
-}
-
-if (FOO!="FOO") {
- print "FOO = " . FOO . "(Arg! This shouldn't print anything)\n";
-} else {
- print "FOO defaults to 'FOO', it probably isn't defined (good)\n";
-}
-
-
-?>
diff --git a/Examples/php5/cpointer/Makefile b/Examples/php5/cpointer/Makefile
deleted file mode 100644
index 92085788a..000000000
--- a/Examples/php5/cpointer/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-TOP = ../..
-SWIGEXE = $(TOP)/../swig
-SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
-SRCS = example.c
-TARGET = example
-INTERFACE = example.i
-LIBS =
-SWIGOPT =
-
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
- SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php5
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean
diff --git a/Examples/php5/cpointer/example.c b/Examples/php5/cpointer/example.c
deleted file mode 100644
index 04dd08df0..000000000
--- a/Examples/php5/cpointer/example.c
+++ /dev/null
@@ -1,16 +0,0 @@
-/* File : example.c */
-
-void add(int *x, int *y, int *result) {
- *result = *x + *y;
-}
-
-void sub(int *x, int *y, int *result) {
- *result = *x - *y;
-}
-
-int divide(int n, int d, int *r) {
- int q;
- q = n/d;
- *r = n - q*d;
- return q;
-}
diff --git a/Examples/php5/cpointer/example.i b/Examples/php5/cpointer/example.i
deleted file mode 100644
index c61d92858..000000000
--- a/Examples/php5/cpointer/example.i
+++ /dev/null
@@ -1,31 +0,0 @@
-/* File : example.i */
-%module example
-
-%{
-extern void add(int *, int *, int *);
-extern void sub(int *, int *, int *);
-%}
-
-/* This example illustrates a couple of different techniques
- for manipulating C pointers */
-
-/* First we'll use the pointer library */
-extern void add(int *x, int *y, int *result);
-
-%include cpointer.i
-%pointer_functions(int, intp);
-
-/* Next we'll use some typemaps */
-
-%include typemaps.i
-extern void sub(int *INPUT, int *INPUT, int *OUTPUT);
-
-/* Next we'll use typemaps and the %apply directive */
-
-//%apply int *OUTPUT { int *r };
-//extern int divide(int n, int d, int *r);
-
-
-
-
-
diff --git a/Examples/php5/cpointer/runme.php b/Examples/php5/cpointer/runme.php
deleted file mode 100644
index 22e8a681a..000000000
--- a/Examples/php5/cpointer/runme.php
+++ /dev/null
@@ -1,47 +0,0 @@
-<?php
-
- require "example.php";
-
- # First create some objects using the pointer library.
-
- print "Testing the pointer library\n";
-
- $a = example::new_intp();
- $b = example::new_intp();
- $c = example::new_intp();
- example::intp_assign($a,37);
- example::intp_assign($b,42);
-
- print " a = $a\n";
- print " b = $b\n";
- print " c = $c\n";
-
- # Call the add() function wuth some pointers
- example::add($a,$b,$c);
-
- # Now get the result
- $r = example::intp_value($c);
-
- print " 37 + 42 = $r\n";
-
- # Clean up the pointers
- example::delete_intp($a);
- example::delete_intp($b);
- example::delete_intp($c);
-
- # Now try the typemap library
- # This should be much easier. Now how it is no longer
- # necessary to manufacture pointers.
-
- print "Trying the typemap library\n";
- $r = example::sub(37,42);
- print " 37 - 42 = $r\n";
-
- # Now try the version with multiple return values
- # print "Testing multiple return values\n";
- # $a = example::divide(42,37);
- # $q = $a[0]
- # $r = $a[1]
- # print " 42/37 = $q remainder $r\n";
-
-?>
diff --git a/Examples/php5/disown/example.cxx b/Examples/php5/disown/example.cxx
deleted file mode 100644
index 6393735e9..000000000
--- a/Examples/php5/disown/example.cxx
+++ /dev/null
@@ -1,51 +0,0 @@
-/* File : example.c */
-
-#include "example.h"
-#include <math.h>
-#ifndef M_PI
-# define M_PI 3.14159265358979323846
-#endif
-
-int Shape::get_nshapes() {
- return nshapes;
-}
-
-/* Move the shape to a new location */
-void Shape::move(double dx, double dy) {
- x += dx;
- y += dy;
-}
-
-int Shape::nshapes = 0;
-
-void Circle::set_radius( double r ) {
- radius = r;
-}
-
-double Circle::area(void) {
- return M_PI*radius*radius;
-}
-
-double Circle::perimeter(void) {
- return 2*M_PI*radius;
-}
-
-double Square::area(void) {
- return width*width;
-}
-
-double Square::perimeter(void) {
- return 4*width;
-}
-
-ShapeContainer::~ShapeContainer() {
- iterator i=shapes.begin();
- for( iterator i = shapes.begin(); i != shapes.end(); ++i ) {
- delete *i;
- }
-}
-
-void
-ShapeContainer::addShape( Shape *s ) {
- shapes.push_back( s );
-}
diff --git a/Examples/php5/disown/example.h b/Examples/php5/disown/example.h
deleted file mode 100644
index e9f96743f..000000000
--- a/Examples/php5/disown/example.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* File : example.h */
-
-#include <vector>
-
-class Shape {
-public:
- Shape() {
- nshapes++;
- }
- virtual ~Shape() {
- nshapes--;
- }
- double x, y;
- void move(double dx, double dy);
- virtual double area(void) = 0;
- virtual double perimeter(void) = 0;
- static int nshapes;
- static int get_nshapes();
-};
-
-class Circle : public Shape {
-private:
- double radius;
-public:
- Circle(double r) : radius(r) { }
- ~Circle() { }
- void set_radius( double r );
- virtual double area(void);
- virtual double perimeter(void);
-};
-
-class Square : public Shape {
-private:
- double width;
-public:
- Square(double w) : width(w) { }
- ~Square() { }
- virtual double area(void);
- virtual double perimeter(void);
-};
-
-class ShapeContainer {
-private:
- typedef std::vector<Shape*>::iterator iterator;
- std::vector<Shape*> shapes;
-public:
- ShapeContainer() : shapes() {}
- ~ShapeContainer();
- void addShape( Shape *s );
-};
diff --git a/Examples/php5/disown/example.i b/Examples/php5/disown/example.i
deleted file mode 100644
index 599f162c5..000000000
--- a/Examples/php5/disown/example.i
+++ /dev/null
@@ -1,12 +0,0 @@
-/* File : example.i */
-%module example
-
-%{
-#include "example.h"
-%}
-
-%apply SWIGTYPE *DISOWN {(Shape *s)};
-
-/* Let's just grab the original header file here */
-%include "example.h"
-
diff --git a/Examples/php5/disown/runme.php b/Examples/php5/disown/runme.php
deleted file mode 100644
index d90b03a9d..000000000
--- a/Examples/php5/disown/runme.php
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-
-# This file illustrates the low-level C++ interface
-# created by SWIG. In this case, all of our C++ classes
-# get converted into function calls.
-
-require("example.php");
-
-# ----- Object creation -----
-
-print "Creating some objects:\n";
-$c = new Circle(10);
-print " Created circle \$c\n";
-$s = new Square(10);
-print " Created square \$s\n";
-
-# ----- Create the ShapeContainer ----
-
-$container = new ShapeContainer();
-
-$container->addShape($c);
-$container->addShape($s);
-
-# ----- Access a static member -----
-
-print "\nA total of " . Shape::nshapes() . " shapes were created\n";
-
-# ----- Delete by the old references -----
-# This should not truely delete the shapes because they are now owned
-# by the ShapeContainer.
-
-print "Delete the old references.";
-
-# Note: this invokes the virtual destructor
-$c = NULL;
-$s = NULL;
-
-print "\nA total of " . Shape::nshapes() . " shapes remain\n";
-
-# ----- Delete by the container -----
-# This should truely delete the shapes
-
-print "Delete the container.";
-$container = NULL;
-print "\nA total of " . Shape::nshapes() . " shapes remain\n";
-
-print "Goodbye\n";
-
-?>
diff --git a/Examples/php5/enum/Makefile b/Examples/php5/enum/Makefile
deleted file mode 100644
index dc59a6c9b..000000000
--- a/Examples/php5/enum/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-TOP = ../..
-SWIGEXE = $(TOP)/../swig
-SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
-CXXSRCS = example.cxx
-TARGET = example
-INTERFACE = example.i
-LIBS =
-SWIGOPT = -noproxy
-
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
- SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php5_cpp
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean
diff --git a/Examples/php5/enum/example.cxx b/Examples/php5/enum/example.cxx
deleted file mode 100644
index df7bb6328..000000000
--- a/Examples/php5/enum/example.cxx
+++ /dev/null
@@ -1,37 +0,0 @@
-/* File : example.cxx */
-
-#include "example.h"
-#include <stdio.h>
-
-void Foo::enum_test(speed s) {
- if (s == IMPULSE) {
- printf("IMPULSE speed\n");
- } else if (s == WARP) {
- printf("WARP speed\n");
- } else if (s == LUDICROUS) {
- printf("LUDICROUS speed\n");
- } else {
- printf("Unknown speed\n");
- }
-}
-
-void enum_test(color c, Foo::speed s) {
- if (c == RED) {
- printf("color = RED, ");
- } else if (c == BLUE) {
- printf("color = BLUE, ");
- } else if (c == GREEN) {
- printf("color = GREEN, ");
- } else {
- printf("color = Unknown color!, ");
- }
- if (s == Foo::IMPULSE) {
- printf("speed = IMPULSE speed\n");
- } else if (s == Foo::WARP) {
- printf("speed = WARP speed\n");
- } else if (s == Foo::LUDICROUS) {
- printf("speed = LUDICROUS speed\n");
- } else {
- printf("speed = Unknown speed!\n");
- }
-}
diff --git a/Examples/php5/enum/example.h b/Examples/php5/enum/example.h
deleted file mode 100644
index 525d62afc..000000000
--- a/Examples/php5/enum/example.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/* File : example.h */
-
-enum color { RED, BLUE, GREEN };
-
-class Foo {
- public:
- Foo() { }
- enum speed { IMPULSE, WARP, LUDICROUS };
- void enum_test(speed s);
-};
-
-void enum_test(color c, Foo::speed s);
-
diff --git a/Examples/php5/enum/runme.php b/Examples/php5/enum/runme.php
deleted file mode 100644
index 55b0bc4c3..000000000
--- a/Examples/php5/enum/runme.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-
-require "example.php";
-
-# ----- Object creation -----
-
-# Print out the value of some enums
-print "*** color ***";
-print " RED =" . RED;
-print " BLUE =" . BLUE;
-print " GREEN =" . GREEN;
-
-print "\n*** Foo::speed ***";
-print " Foo_IMPULSE =" . Foo_IMPULSE;
-print " Foo_WARP =" . Foo_WARP;
-print " Foo_LUDICROUS =" . Foo_LUDICROUS;
-
-print "\nTesting use of enums with functions\n";
-
-enum_test(RED, Foo_IMPULSE);
-enum_test(BLUE, Foo_WARP);
-enum_test(GREEN, Foo_LUDICROUS);
-enum_test(1234,5678);
-
-print "\nTesting use of enum with class method\n";
-$f = new_Foo();
-
-Foo_enum_test($f,Foo_IMPULSE);
-Foo_enum_test($f,Foo_WARP);
-Foo_enum_test($f,Foo_LUDICROUS);
-
-?>
diff --git a/Examples/php5/extend/Makefile b/Examples/php5/extend/Makefile
deleted file mode 100644
index 3a34106c3..000000000
--- a/Examples/php5/extend/Makefile
+++ /dev/null
@@ -1,19 +0,0 @@
-TOP = ../..
-SWIGEXE = $(TOP)/../swig
-SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
-CXXSRCS = example.cxx
-TARGET = example
-INTERFACE = example.i
-LIBS = -lm
-SWIGOPT =
-
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' \
- SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php5_cpp
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean
diff --git a/Examples/php5/extend/example.cxx b/Examples/php5/extend/example.cxx
deleted file mode 100644
index 450d75608..000000000
--- a/Examples/php5/extend/example.cxx
+++ /dev/null
@@ -1,4 +0,0 @@
-/* File : example.cxx */
-
-#include "example.h"
-
diff --git a/Examples/php5/extend/example.h b/Examples/php5/extend/example.h
deleted file mode 100644
index ca1aed28f..000000000
--- a/Examples/php5/extend/example.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* File : example.h */
-
-#include <cstdio>
-#include <iostream>
-#include <vector>
-#include <string>
-#include <cmath>
-
-class Employee {
-private:
- std::string name;
-public:
- Employee(const char* n): name(n) {}
- virtual std::string getTitle() { return getPosition() + " " + getName(); }
- virtual std::string getName() { return name; }
- virtual std::string getPosition() const { return "Employee"; }
- virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); }
-};
-
-
-class Manager: public Employee {
-public:
- Manager(const char* n): Employee(n) {}
- virtual std::string getPosition() const { return "Manager"; }
-};
-
-
-class EmployeeList {
- std::vector<Employee*> list;
-public:
- EmployeeList() {
- list.push_back(new Employee("Bob"));
- list.push_back(new Employee("Jane"));
- list.push_back(new Manager("Ted"));
- }
- void addEmployee(Employee *p) {
- list.push_back(p);
- std::cout << "New employee added. Current employees are:" << std::endl;
- std::vector<Employee*>::iterator i;
- for (i=list.begin(); i!=list.end(); i++) {
- std::cout << " " << (*i)->getTitle() << std::endl;
- }
- }
- const Employee *get_item(int i) {
- return list[i];
- }
- ~EmployeeList() {
- std::vector<Employee*>::iterator i;
- std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl;
- for (i=list.begin(); i!=list.end(); i++) {
- delete *i;
- }
- std::cout << "~EmployeeList empty." << std::endl;
- }
-};
-
diff --git a/Examples/php5/extend/example.i b/Examples/php5/extend/example.i
deleted file mode 100644
index c8ec32e09..000000000
--- a/Examples/php5/extend/example.i
+++ /dev/null
@@ -1,15 +0,0 @@
-/* File : example.i */
-%module(directors="1") example
-%{
-#include "example.h"
-%}
-
-%include "std_vector.i"
-%include "std_string.i"
-
-/* turn on director wrapping for Manager */
-%feature("director") Employee;
-%feature("director") Manager;
-
-%include "example.h"
-
diff --git a/Examples/php5/extend/index.html b/Examples/php5/extend/index.html
deleted file mode 100644
index 32c6a4913..000000000
--- a/Examples/php5/extend/index.html
+++ /dev/null
@@ -1,19 +0,0 @@
-<html>
-<head>
-<title>SWIG:Examples:php:extend</title>
-</head>
-
-<body bgcolor="#ffffff">
-
-
-<tt>SWIG/Examples/php/extend/</tt>
-<hr>
-
-<H2>Extending a simple C++ class in PHP</H2>
-
-<p>
-This example illustrates the extending of a C++ class with cross language polymorphism.
-
-<hr>
-</body>
-</html>
diff --git a/Examples/php5/extend/runme.php b/Examples/php5/extend/runme.php
deleted file mode 100644
index 158683142..000000000
--- a/Examples/php5/extend/runme.php
+++ /dev/null
@@ -1,76 +0,0 @@
-<?php
-
-# This file illustrates the cross language polymorphism using directors.
-
-require("example.php");
-
-# CEO class, which overrides Employee::getPosition().
-
-class CEO extends Manager {
- function getPosition() {
- return "CEO";
- }
-}
-
-# Create an instance of our employee extension class, CEO. The calls to
-# getName() and getPosition() are standard, the call to getTitle() uses
-# the director wrappers to call CEO.getPosition.
-
-$e = new CEO("Alice");
-print $e->getName() . " is a " . $e->getPosition() . "\n";
-printf("Just call her \"%s\"\n", $e->getTitle());
-print "----------------------\n";
-
-# Create a new EmployeeList instance. This class does not have a C++
-# director wrapper, but can be used freely with other classes that do.
-
-$list = new EmployeeList();
-
-# EmployeeList owns its items, so we must surrender ownership of objects
-# we add. This involves first clearing the ->disown member to tell the
-# C++ director to start reference counting.
-
-$e->thisown = 0;
-$list->addEmployee($e);
-print "----------------------\n";
-
-# Now we access the first four items in list (three are C++ objects that
-# EmployeeList's constructor adds, the last is our CEO). The virtual
-# methods of all these instances are treated the same. For items 0, 1, and
-# 2, both all methods resolve in C++. For item 3, our CEO, getTitle calls
-# getPosition which resolves in PHP. The call to getPosition is
-# slightly different, however, from the e.getPosition() call above, since
-# now the object reference has been "laundered" by passing through
-# EmployeeList as an Employee*. Previously, PHP resolved the call
-# immediately in CEO, but now PHP thinks the object is an instance of
-# class Employee (actually EmployeePtr). So the call passes through the
-# Employee proxy class and on to the C wrappers and C++ director,
-# eventually ending up back at the CEO implementation of getPosition().
-# The call to getTitle() for item 3 runs the C++ Employee::getTitle()
-# method, which in turn calls getPosition(). This virtual method call
-# passes down through the C++ director class to the PHP implementation
-# in CEO. All this routing takes place transparently.
-
-print "(position, title) for items 0-3:\n";
-
-printf(" %s, \"%s\"\n", $list->get_item(0)->getPosition(), $list->get_item(0)->getTitle());
-printf(" %s, \"%s\"\n", $list->get_item(1)->getPosition(), $list->get_item(1)->getTitle());
-printf(" %s, \"%s\"\n", $list->get_item(2)->getPosition(), $list->get_item(2)->getTitle());
-printf(" %s, \"%s\"\n", $list->get_item(3)->getPosition(), $list->get_item(3)->getTitle());
-print "----------------------\n";
-
-# Time to delete the EmployeeList, which will delete all the Employee*
-# items it contains. The last item is our CEO, which gets destroyed as its
-# reference count goes to zero. The PHP destructor runs, and is still
-# able to call the getName() method since the underlying C++ object still
-# exists. After this destructor runs the remaining C++ destructors run as
-# usual to destroy the object.
-
-unset($list);
-print "----------------------\n";
-
-# All done.
-
-print "php exit\n";
-
-?>
diff --git a/Examples/php5/funcptr/Makefile b/Examples/php5/funcptr/Makefile
deleted file mode 100644
index 92085788a..000000000
--- a/Examples/php5/funcptr/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-TOP = ../..
-SWIGEXE = $(TOP)/../swig
-SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
-SRCS = example.c
-TARGET = example
-INTERFACE = example.i
-LIBS =
-SWIGOPT =
-
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
- SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php5
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean
diff --git a/Examples/php5/funcptr/example.c b/Examples/php5/funcptr/example.c
deleted file mode 100644
index 99583b72e..000000000
--- a/Examples/php5/funcptr/example.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/* File : example.c */
-
-int do_op(int a, int b, int (*op)(int,int)) {
- return (*op)(a,b);
-}
-
-int add(int a, int b) {
- return a+b;
-}
-
-int sub(int a, int b) {
- return a-b;
-}
-
-int mul(int a, int b) {
- return a*b;
-}
diff --git a/Examples/php5/funcptr/example.h b/Examples/php5/funcptr/example.h
deleted file mode 100644
index 58989db79..000000000
--- a/Examples/php5/funcptr/example.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* file: example.h */
-
-extern int do_op(int,int, int (*op)(int,int));
-extern int add(int,int);
-extern int sub(int,int);
-extern int mul(int,int);
-
diff --git a/Examples/php5/funcptr/example.i b/Examples/php5/funcptr/example.i
deleted file mode 100644
index 39390da27..000000000
--- a/Examples/php5/funcptr/example.i
+++ /dev/null
@@ -1,15 +0,0 @@
-/* File : example.i */
-%module example
-%{
-#include "example.h"
-%}
-
-/* Wrap a function taking a pointer to a function */
-extern int do_op(int a, int b, int (*op)(int, int));
-
-/* Now install a bunch of "ops" as constants */
-%constant int (*ADD)(int,int) = add;
-%constant int (*SUB)(int,int) = sub;
-%constant int (*MUL)(int,int) = mul;
-
-
diff --git a/Examples/php5/funcptr/runme.php b/Examples/php5/funcptr/runme.php
deleted file mode 100644
index 712d4147c..000000000
--- a/Examples/php5/funcptr/runme.php
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-
-require "example.php";
-
-$a = 37;
-$b = 42;
-
-# Now call our C function with a bunch of callbacks
-
-print "Trying some C callback functions\n";
-print " a = $a\n";
-print " b = $b\n";
-print " ADD(a,b) = ". do_op($a,$b,ADD)."\n";
-print " SUB(a,b) = ". do_op($a,$b,SUB)."\n";
-print " MUL(a,b) = ". do_op($a,$b,MUL)."\n";
-
-print "Here is what the C callback function objects look like in php\n";
-print "Using swig style string pointers as we need them registered as constants\n";
-print " ADD = " . ADD . "\n";
-print " SUB = " . SUB . "\n";
-print " MUL = " . MUL . "\n";
-
-?>
-
diff --git a/Examples/php5/overloading/example.cxx b/Examples/php5/overloading/example.cxx
deleted file mode 100644
index 2f684f05c..000000000
--- a/Examples/php5/overloading/example.cxx
+++ /dev/null
@@ -1,55 +0,0 @@
-/* File : example.c */
-
-#include "example.h"
-#include <math.h>
-#ifndef M_PI
-# define M_PI 3.14159265358979323846
-#endif
-
-int Shape::get_nshapes() {
- return nshapes;
-}
-
-/* Move the shape to a new location */
-void Shape::move(double dx, double dy) {
- x += dx;
- y += dy;
-}
-
-int Shape::nshapes = 0;
-
-double Circle::area(void) {
- return M_PI*radius*radius;
-}
-
-double Circle::perimeter(void) {
- return 2*M_PI*radius;
-}
-
-double Square::area(void) {
- return width*width;
-}
-
-double Square::perimeter(void) {
- return 4*width;
-}
-
-const char *overloaded(int i) {
- return "Overloaded with int";
-}
-
-const char *overloaded(double d) {
- return "Overloaded with double";
-}
-
-const char *overloaded(const char * str) {
- return "Overloaded with char *";
-}
-
-const char *overloaded( const Circle& ) {
- return "Overloaded with Circle";
-}
-
-const char *overloaded( const Shape& ) {
- return "Overloaded with Shape";
-}
diff --git a/Examples/php5/overloading/example.h b/Examples/php5/overloading/example.h
deleted file mode 100644
index 01d71dd70..000000000
--- a/Examples/php5/overloading/example.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* File : example.h */
-
-#include <stdio.h>
-
-class Shape {
-public:
- Shape() {
- nshapes++;
- }
- virtual ~Shape() {
- nshapes--;
- }
- double x, y;
- void move(double dx, double dy);
- virtual double area(void) = 0;
- virtual double perimeter(void) = 0;
- static int nshapes;
- static int get_nshapes();
-};
-
-class Circle : public Shape {
-private:
- double radius;
-public:
- Circle(double r) : radius(r) { }
- ~Circle() { }
- virtual double area(void);
- virtual double perimeter(void);
-};
-
-class Square : public Shape {
-private:
- double width;
-public:
- Square(double w) : width(w) { }
- ~Square() { }
- virtual double area(void);
- virtual double perimeter(void);
-};
-
-const char *overloaded( int i );
-const char *overloaded( double d );
-const char *overloaded( const char * str );
-const char *overloaded( const Circle& );
-const char *overloaded( const Shape& );
-
diff --git a/Examples/php5/overloading/example.i b/Examples/php5/overloading/example.i
deleted file mode 100644
index 950d2549d..000000000
--- a/Examples/php5/overloading/example.i
+++ /dev/null
@@ -1,8 +0,0 @@
-/* File : example.i */
-%module example
-
-%{
-#include "example.h"
-%}
-
-%include "example.h"
diff --git a/Examples/php5/overloading/runme.php b/Examples/php5/overloading/runme.php
deleted file mode 100644
index 56d515138..000000000
--- a/Examples/php5/overloading/runme.php
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-
-# This file illustrates the low-level C++ interface
-# created by SWIG. In this case, all of our C++ classes
-# get converted into function calls.
-
-include("example.php");
-
-# ----- Object creation -----
-
-print "Creating some objects:\n";
-$c = new Circle(10);
-print " Created circle \$c\n";
-$s = new Square(10);
-print " Created square \$s\n";
-
-# ----- Access a static member -----
-
-print "\nA total of " . Shape::nshapes() . " shapes were created\n";
-
-# ----- Member data access -----
-
-# Set the location of the object.
-# Note: methods in the base class Shape are used since
-# x and y are defined there.
-
-$c->x = 20;
-$c->y = 30;
-$s->x = -10;
-$s->y = 5;
-
-print "\nHere is their current position:\n";
-print " Circle = (" . $c->x . "," . $c->y . ")\n";
-print " Square = (" . $s->x . "," . $s->y . ")\n";
-
-# ----- Call some methods -----
-
-print "\nCall some overloaded methods:\n";
-foreach (array(1, 2.1, "quick brown fox", $c, $s) as $o) {
- print " overloaded = " . overloaded($o) . "\n";
-}
-
-# Need to unset($o) or else we hang on to a reference to the Square object.
-unset($o);
-
-# ----- Delete everything -----
-
-print "\nGuess I'll clean up now\n";
-
-# Note: this invokes the virtual destructor
-unset($c);
-$s = 42;
-
-print Shape::nshapes() . " shapes remain\n";
-
-print "Goodbye\n";
-
-?>
diff --git a/Examples/php5/pointer/Makefile b/Examples/php5/pointer/Makefile
deleted file mode 100644
index 92085788a..000000000
--- a/Examples/php5/pointer/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-TOP = ../..
-SWIGEXE = $(TOP)/../swig
-SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
-SRCS = example.c
-TARGET = example
-INTERFACE = example.i
-LIBS =
-SWIGOPT =
-
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
- SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php5
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean
diff --git a/Examples/php5/pointer/example.c b/Examples/php5/pointer/example.c
deleted file mode 100644
index 3326dec3e..000000000
--- a/Examples/php5/pointer/example.c
+++ /dev/null
@@ -1,16 +0,0 @@
-/* File : example.c */
-
-void add(double *x, double *y, double *result) {
- *result = *x + *y;
-}
-
-void sub(int *x, int *y, int *result) {
- *result = *x - *y;
-}
-
-int divide(int n, int d, int *r) {
- int q;
- q = n/d;
- *r = n - q*d;
- return q;
-}
diff --git a/Examples/php5/pointer/example.i b/Examples/php5/pointer/example.i
deleted file mode 100644
index 1f0059406..000000000
--- a/Examples/php5/pointer/example.i
+++ /dev/null
@@ -1,30 +0,0 @@
-/* File : example.i */
-%module example
-
-%{
-extern void add(double *, double *, double *);
-extern void sub(int *, int *, int *);
-extern int divide(int, int, int *);
-%}
-
-/* This example illustrates a couple of different techniques
- for manipulating C pointers */
-
-%include phppointers.i
-/* First we'll use the pointer library */
-extern void add(double *REF, double *REF, double *REF);
-
-/* Next we'll use some typemaps */
-
-%include typemaps.i
-extern void sub(int *INPUT, int *INPUT, int *OUTPUT);
-
-/* Next we'll use typemaps and the %apply directive */
-
-//%apply int *OUTPUT { int *r };
-//extern int divide(int n, int d, int *r);
-
-
-
-
-
diff --git a/Examples/php5/pointer/runme.php b/Examples/php5/pointer/runme.php
deleted file mode 100644
index e79b23810..000000000
--- a/Examples/php5/pointer/runme.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-
- require "example.php";
-
- # First create some objects using the pointer library.
-
- print "Testing the pointer library\n";
-
- $a = 37.145;
- $b = 42.555;
- $c = ""; // $c must be defined and not null.
-
- print " a = $a\n";
- print " b = $b\n";
- print " c = $c\n";
-
- # Call the add() function wuth some pointers
- add($a,$b,$c);
-
- print " $a + $b = $c\n";
-
- # Now try the typemap library
- # This should be much easier. Now how it is no longer
- # necessary to manufacture pointers.
-
- print "Trying the typemap library\n";
- $r = sub(37,42);
- print " 37 - 42 = $r\n";
-
- # Now try the version with multiple return values
- # print "Testing multiple return values\n";
- # ($q,$r) = divide(42,37);
- # print " 42/37 = $q remainder $r\n";
-
-?>
diff --git a/Examples/php5/pragmas/Makefile b/Examples/php5/pragmas/Makefile
deleted file mode 100644
index f9557fa89..000000000
--- a/Examples/php5/pragmas/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-TOP = ../..
-SWIGEXE = $(TOP)/../swig
-SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
-SRCS =
-TARGET = example
-INTERFACE = example.i
-LIBS =
-SWIGOPT =
-
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
- SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php5
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean
diff --git a/Examples/php5/pragmas/example.i b/Examples/php5/pragmas/example.i
deleted file mode 100644
index c7e8bf303..000000000
--- a/Examples/php5/pragmas/example.i
+++ /dev/null
@@ -1,31 +0,0 @@
-/* File : example.i */
-%module example
-
-%init{
- zend_printf("This was %%init\n");
-}
-
-%minit{
- zend_printf("This was %%minit\n");
-}
-
-%mshutdown{
- zend_printf("This was %%shutdown\n");
-}
-
-%rinit{
- zend_printf("This was %%rinit\n");
-}
-
-%rshutdown{
- zend_printf("This was %%rshutdown\n");
-}
-
-%pragma(php) include="include.php";
-
-%pragma(php) code="
-# This code is inserted into example.php
-echo \"this was php code\\n\";
-"
-
-%pragma(php) phpinfo="php_info_print_table_start();"
diff --git a/Examples/php5/pragmas/include.php b/Examples/php5/pragmas/include.php
deleted file mode 100644
index e19880a06..000000000
--- a/Examples/php5/pragmas/include.php
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php
-
-# This code is inserted into example.php
-echo "this is include.php\n";
-
-
-?>
diff --git a/Examples/php5/pragmas/runme.php b/Examples/php5/pragmas/runme.php
deleted file mode 100644
index 538548b6f..000000000
--- a/Examples/php5/pragmas/runme.php
+++ /dev/null
@@ -1,5 +0,0 @@
-<?php
-
-require "example.php";
-
-?>
diff --git a/Examples/php5/proxy/Makefile b/Examples/php5/proxy/Makefile
deleted file mode 100644
index 8346a1dae..000000000
--- a/Examples/php5/proxy/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-TOP = ../..
-SWIGEXE = $(TOP)/../swig
-SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
-CXXSRCS = example.cxx
-TARGET = example
-INTERFACE = example.i
-LIBS =
-SWIGOPT =
-
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
- SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php5_cpp
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean
diff --git a/Examples/php5/proxy/example.cxx b/Examples/php5/proxy/example.cxx
deleted file mode 100644
index 94e4a7888..000000000
--- a/Examples/php5/proxy/example.cxx
+++ /dev/null
@@ -1,43 +0,0 @@
-/* File : example.c */
-
-#include "example.h"
-#include <math.h>
-#ifndef M_PI
-# define M_PI 3.14159265358979323846
-#endif
-
-int Shape::get_nshapes() {
- return nshapes;
-}
-
-/* Move the shape to a new location */
-void Shape::move(double dx, double dy) {
- x += dx;
- y += dy;
-}
-
-int Shape::nshapes = 0;
-
-void Circle::set_radius( double r ) {
- radius = r;
-}
-
-double Circle::area(void) {
- return M_PI*radius*radius;
-}
-
-double Circle::perimeter(void) {
- return 2*M_PI*radius;
-}
-
-double Square::area(void) {
- return width*width;
-}
-
-double Square::perimeter(void) {
- return 4*width;
-}
-
-Circle *CircleFactory( double r ) {
- return new Circle(r);
-}
diff --git a/Examples/php5/proxy/example.h b/Examples/php5/proxy/example.h
deleted file mode 100644
index 0683f07f3..000000000
--- a/Examples/php5/proxy/example.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* File : example.h */
-
-#include <stdio.h>
-
-class Shape {
-public:
- Shape() {
- nshapes++;
- }
- virtual ~Shape() {
- nshapes--;
- }
- double x, y;
- void move(double dx, double dy);
- virtual double area(void) = 0;
- virtual double perimeter(void) = 0;
- static int nshapes;
- static int get_nshapes();
-};
-
-class Circle : public Shape {
-private:
- double radius;
-public:
- Circle(double r) : radius(r) { }
- ~Circle() { }
- void set_radius( double r );
- virtual double area(void);
- virtual double perimeter(void);
-};
-
-class Square : public Shape {
-private:
- double width;
-public:
- Square(double w) : width(w) { }
- ~Square() { }
- virtual double area(void);
- virtual double perimeter(void);
-};
-
-Circle *CircleFactory( double r );
-
diff --git a/Examples/php5/proxy/example.i b/Examples/php5/proxy/example.i
deleted file mode 100644
index ce73746d0..000000000
--- a/Examples/php5/proxy/example.i
+++ /dev/null
@@ -1,12 +0,0 @@
-/* File : example.i */
-%module example
-
-%{
-#include "example.h"
-%}
-
-/* Let's just grab the original header file here */
-
-%newobject CircleFactory;
-%include "example.h"
-
diff --git a/Examples/php5/proxy/runme.php b/Examples/php5/proxy/runme.php
deleted file mode 100644
index e70ab229f..000000000
--- a/Examples/php5/proxy/runme.php
+++ /dev/null
@@ -1,68 +0,0 @@
-<?php
-
-# This file illustrates the low-level C++ interface
-# created by SWIG. In this case, all of our C++ classes
-# get converted into function calls.
-
-include("example.php");
-
-# ----- Object creation -----
-
-print "Creating some objects:\n";
-$c = example::CircleFactory(10);
-print " Created circle \$c with area ". $c->area() ."\n";
-$s = new Square(10);
-print " Created square \$s\n";
-
-# ----- Access a static member -----
-
-print "\nA total of " . Shape::nshapes() . " shapes were created\n";
-
-# ----- Member data access -----
-
-# Set the location of the object.
-# Note: methods in the base class Shape are used since
-# x and y are defined there.
-
-$c->x = 20;
-$c->y = 30;
-$s->x = -10;
-$s->y = 5;
-
-print "\nHere is their current position:\n";
-print " Circle = (" . $c->x . "," . $c->y . ")\n";
-print " Square = (" . $s->x . "," . $s->y . ")\n";
-
-# ----- Call some methods -----
-
-print "\nHere are some properties of the shapes:\n";
-foreach (array($c,$s) as $o) {
- print " ".get_class($o)." \$o\n";
- print " x = " . $o->x . "\n";
- print " y = " . $o->y . "\n";
- print " area = " . $o->area() . "\n";
- print " perimeter = " . $o->perimeter() . "\n";
- }
-
-# Need to unset($o) or else we hang on to a reference to the Square object.
-unset($o);
-
-# ----- Delete everything -----
-
-print "\nGuess I'll clean up now\n";
-
-# Note: this invokes the virtual destructor
-unset($c);
-$s = 42;
-
-print Shape::nshapes() . " shapes remain\n";
-
-print "Manually setting nshapes\n";
-
-Shape::nshapes(42);
-
-print Shape::get_nshapes() ." == 42\n";
-
-print "Goodbye\n";
-
-?>
diff --git a/Examples/php5/reference/Makefile b/Examples/php5/reference/Makefile
deleted file mode 100644
index 8346a1dae..000000000
--- a/Examples/php5/reference/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-TOP = ../..
-SWIGEXE = $(TOP)/../swig
-SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
-CXXSRCS = example.cxx
-TARGET = example
-INTERFACE = example.i
-LIBS =
-SWIGOPT =
-
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
- SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php5_cpp
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean
diff --git a/Examples/php5/reference/example.cxx b/Examples/php5/reference/example.cxx
deleted file mode 100644
index 7ead7fbf6..000000000
--- a/Examples/php5/reference/example.cxx
+++ /dev/null
@@ -1,49 +0,0 @@
-/* File : example.cxx */
-
-/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
-#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
-# define _CRT_SECURE_NO_DEPRECATE
-#endif
-
-#include "example.h"
-#include <stdio.h>
-#include <stdlib.h>
-
-Vector operator+(const Vector &a, const Vector &b) {
- Vector r;
- r.x = a.x + b.x;
- r.y = a.y + b.y;
- r.z = a.z + b.z;
- return r;
-}
-
-char *Vector::as_string() {
- static char temp[512];
- sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z);
- return temp;
-}
-
-VectorArray::VectorArray(int size) {
- items = new Vector[size];
- maxsize = size;
- printf("VectorArray new: self=%p\n", (void *)this);
-}
-
-VectorArray::~VectorArray() {
- printf("VectorArray delete: self=%p\n", (void *)this);
- delete [] items;
-}
-
-Vector &VectorArray::operator[](int index) {
- printf("VectorArray: read[%d] self=%p\n", index, (void *)this);
- if ((index < 0) || (index >= maxsize)) {
- printf("Panic! Array index out of bounds.\n");
- exit(1);
- }
- return items[index];
-}
-
-int VectorArray::size() {
- printf("VectorArray: size %d self=%p\n", maxsize, (void *)this);
- return maxsize;
-}
diff --git a/Examples/php5/reference/example.h b/Examples/php5/reference/example.h
deleted file mode 100644
index 353b88835..000000000
--- a/Examples/php5/reference/example.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/* File : example.h */
-
-class Vector {
-private:
- double x,y,z;
-public:
- Vector() : x(0), y(0), z(0) { }
- Vector(double x, double y, double z) : x(x), y(y), z(z) { }
- friend Vector operator+(const Vector &a, const Vector &b);
- char *as_string();
-};
-
-class VectorArray {
-private:
- Vector *items;
- int maxsize;
-public:
- VectorArray(int maxsize);
- ~VectorArray();
- Vector &operator[](int);
- int size();
-};
diff --git a/Examples/php5/reference/example.i b/Examples/php5/reference/example.i
deleted file mode 100644
index df1459921..000000000
--- a/Examples/php5/reference/example.i
+++ /dev/null
@@ -1,43 +0,0 @@
-/* File : example.i */
-
-/* This file has a few "typical" uses of C++ references. */
-
-%module example
-
-%{
-#include "example.h"
-%}
-
-class Vector {
-public:
- Vector(double x, double y, double z);
- ~Vector();
- char *as_string();
-};
-
-/* This helper function calls an overloaded operator */
-%inline %{
-Vector addv(Vector &a, Vector &b) {
- return a+b;
-}
-%}
-
-/* Wrapper around an array of vectors class */
-
-class VectorArray {
-public:
- VectorArray(int maxsize);
- ~VectorArray();
- int size();
-
- /* This wrapper provides an alternative to the [] operator */
- %extend {
- Vector &get(int index) {
- printf("VectorArray extended get: %p %d\n", (void *)$self, index);
- return (*$self)[index];
- }
- void set(int index, Vector &a) {
- (*$self)[index] = a;
- }
- }
-};
diff --git a/Examples/php5/reference/runme.php b/Examples/php5/reference/runme.php
deleted file mode 100644
index 5d264ee43..000000000
--- a/Examples/php5/reference/runme.php
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-
-# This file illustrates the manipulation of C++ references in PHP.
-
-require "example.php";
-
-# ----- Object creation -----
-
-print "Creating some objects:\n";
-$a = new Vector(3, 4, 5);
-$b = new Vector(10, 11, 12);
-
-print " Created a: {$a->as_string()}\n";
-print " Created b: {$b->as_string()}\n";
-
-# ----- Call an overloaded operator -----
-
-# This calls the wrapper we placed around
-#
-# operator+(const Vector &a, const Vector &)
-#
-# It returns a new allocated object.
-
-print "Adding a+b\n";
-$c = example::addv($a, $b);
-print " a+b ={$c->as_string()}\n";
-
-# ----- Create a vector array -----
-
-print "Creating an array of vectors\n";
-$va = new VectorArray(10);
-
-print " va: size={$va->size()}\n";
-
-# ----- Set some values in the array -----
-
-# These operators copy the value of $a and $b to the vector array
-$va->set(0, $a);
-$va->set(1, $b);
-$va->set(2, addv($a, $b));
-
-# Get some values from the array
-
-print "Getting some array values\n";
-for ($i = 0; $i < 5; $i++) {
- print " va[$i] = {$va->get($i)->as_string()}\n";
-}
-
-?>
diff --git a/Examples/php5/simple/Makefile b/Examples/php5/simple/Makefile
deleted file mode 100644
index 92085788a..000000000
--- a/Examples/php5/simple/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-TOP = ../..
-SWIGEXE = $(TOP)/../swig
-SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
-SRCS = example.c
-TARGET = example
-INTERFACE = example.i
-LIBS =
-SWIGOPT =
-
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
- SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php5
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean
diff --git a/Examples/php5/simple/example.c b/Examples/php5/simple/example.c
deleted file mode 100644
index 2fe275632..000000000
--- a/Examples/php5/simple/example.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/* File : example.c */
-#include <stdio.h>
-
-/* A global variable */
-double Foo = 3.0;
-
-void print_Foo() {
- printf("In C, Foo = %f\n",Foo);
-}
-
-/* Compute the greatest common divisor of positive integers */
-int gcd(int x, int y) {
- int g;
- g = y;
- while (x > 0) {
- g = x;
- x = y % x;
- y = g;
- }
- return g;
-}
-
-
diff --git a/Examples/php5/simple/example.i b/Examples/php5/simple/example.i
deleted file mode 100644
index 9d4e22aa9..000000000
--- a/Examples/php5/simple/example.i
+++ /dev/null
@@ -1,8 +0,0 @@
-/* File : example.i */
-%module example
-
-%inline %{
-extern int gcd(int x, int y);
-extern double Foo;
-void print_Foo();
-%}
diff --git a/Examples/php5/simple/runme.php b/Examples/php5/simple/runme.php
deleted file mode 100644
index 0e96fe800..000000000
--- a/Examples/php5/simple/runme.php
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php
-
-require "example.php";
-
-# Call our gcd() function
-
-$x = "42 aaa";
-$y = 105;
-$g = gcd($x,$y);
-print "The gcd of $x and $y is $g\n";
-
-# Manipulate the Foo global variable
-
-# Output its current value
-print "Foo = " . Foo_get() . "\n";
-
-# Change its value
-Foo_set(3.1415926);
-
-# See if the change took effect ( this isn't a good example for php, see
-# manual for why. )
-print "Foo = " . Foo_get() . "\n";
-print_Foo();
-
-?>
diff --git a/Examples/php5/sync/Makefile b/Examples/php5/sync/Makefile
deleted file mode 100644
index 8346a1dae..000000000
--- a/Examples/php5/sync/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-TOP = ../..
-SWIGEXE = $(TOP)/../swig
-SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
-CXXSRCS = example.cxx
-TARGET = example
-INTERFACE = example.i
-LIBS =
-SWIGOPT =
-
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
- SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php5_cpp
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean
diff --git a/Examples/php5/sync/example.cxx b/Examples/php5/sync/example.cxx
deleted file mode 100644
index 0942279b2..000000000
--- a/Examples/php5/sync/example.cxx
+++ /dev/null
@@ -1,13 +0,0 @@
-#include "example.h"
-#include <stdio.h>
-
-int x = 42;
-char *s = (char *)"Test";
-
-void Sync::printer(void) {
-
- printf("The value of global s is %s\n", s);
- printf("The value of global x is %d\n", x);
- printf("The value of class s is %s\n", s);
- printf("The value of class x is %d\n", x);
-}
diff --git a/Examples/php5/sync/example.h b/Examples/php5/sync/example.h
deleted file mode 100644
index d67ec21dc..000000000
--- a/Examples/php5/sync/example.h
+++ /dev/null
@@ -1,9 +0,0 @@
-extern char *s;
-extern int x;
-
-class Sync {
- public:
- int x;
- char *s;
- void printer(void);
-};
diff --git a/Examples/php5/sync/example.i b/Examples/php5/sync/example.i
deleted file mode 100644
index 17ff87cf3..000000000
--- a/Examples/php5/sync/example.i
+++ /dev/null
@@ -1,7 +0,0 @@
-%module example
-
-%{
-#include "example.h"
-%}
-
-%include "example.h"
diff --git a/Examples/php5/sync/runme.php b/Examples/php5/sync/runme.php
deleted file mode 100644
index a7c43474f..000000000
--- a/Examples/php5/sync/runme.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<?
-
-// Load module and PHP classes.
-include("example.php");
-
-echo "Got new object\n";
-echo "Got string $s and value $x \n";
-
-$s = new Sync();
-echo "Got new object\n";
-
-$s->printer();
-
-?>
-
diff --git a/Examples/php5/value/Makefile b/Examples/php5/value/Makefile
deleted file mode 100644
index b0b5e20ac..000000000
--- a/Examples/php5/value/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-TOP = ../..
-SWIGEXE = $(TOP)/../swig
-SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
-SRCS = example.c
-TARGET = example
-INTERFACE = example.i
-LIBS =
-SWIGOPT = -noproxy
-
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
- SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php5
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean
diff --git a/Examples/php5/value/example.c b/Examples/php5/value/example.c
deleted file mode 100644
index 3c402a214..000000000
--- a/Examples/php5/value/example.c
+++ /dev/null
@@ -1,13 +0,0 @@
-/* File : example.c */
-
-#include "example.h"
-
-double dot_product(Vector a, Vector b) {
- return (a.x*b.x + a.y*b.y + a.z*b.z);
-}
-
-void vector_add(Vector a, Vector b, Vector* result) {
- result->x = a.x + b.x;
- result->y = a.y + b.y;
- result->z = a.z + b.z;
-}
diff --git a/Examples/php5/value/example.h b/Examples/php5/value/example.h
deleted file mode 100644
index f55752a5f..000000000
--- a/Examples/php5/value/example.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/* File : example.h */
-
-typedef struct {
- double x, y, z;
-} Vector;
-
-double dot_product(Vector a, Vector b);
-void vector_add(Vector a, Vector b, Vector* result);
diff --git a/Examples/php5/value/example.i b/Examples/php5/value/example.i
deleted file mode 100644
index 20a453468..000000000
--- a/Examples/php5/value/example.i
+++ /dev/null
@@ -1,17 +0,0 @@
-// Tests SWIG's handling of pass-by-value for complex datatypes
-%module example
-
-%{
-#include "example.h"
-%}
-
-%include "example.h"
-
-/* Some helper functions for our interface */
-%inline %{
-
-void vector_print(Vector *v) {
- printf("Vector %p = (%g, %g, %g)\n", (void *)v, v->x, v->y, v->z);
-}
-%}
-
diff --git a/Examples/php5/value/runme.php b/Examples/php5/value/runme.php
deleted file mode 100644
index 49115376c..000000000
--- a/Examples/php5/value/runme.php
+++ /dev/null
@@ -1,43 +0,0 @@
-<?php
-
- require "example.php";
-
-
- $v = new_vector();
- vector_x_set($v,1.0);
- vector_y_set($v,2.0);
- vector_z_set($v,3.0);
-
- $w = new_vector();
- vector_x_set($w,10.0);
- vector_y_set($w,11.0);
- vector_z_set($w,12.0);
-
- echo "I just created the following vector\n";
- vector_print($v);
- vector_print($w);
-
- echo "\nNow I'm going to compute the dot product\n";
-
- $d = dot_product($v, $w);
-
- echo "dot product = $d (should be 68)\n";
-
- echo "\nNow I'm going to add the vectors together\n";
-
- $r = new_vector();
- vector_add($v, $w, $r);
-
- vector_print($r);
-
- echo "The value should be (11,13,15)\n";
-
- echo "\nNow I'm going to clean up the return result\n";
-
-# free($r);
-
- echo "Good\n";
-
-?>
-
-
diff --git a/Examples/php5/variables/Makefile b/Examples/php5/variables/Makefile
deleted file mode 100644
index 92085788a..000000000
--- a/Examples/php5/variables/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-TOP = ../..
-SWIGEXE = $(TOP)/../swig
-SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
-SRCS = example.c
-TARGET = example
-INTERFACE = example.i
-LIBS =
-SWIGOPT =
-
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
- SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php5
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean
diff --git a/Examples/php5/variables/example.c b/Examples/php5/variables/example.c
deleted file mode 100644
index d4c6d026d..000000000
--- a/Examples/php5/variables/example.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/* File : example.c */
-
-/* I'm a file containing some C global variables */
-
-/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
-#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
-# define _CRT_SECURE_NO_DEPRECATE
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "example.h"
-
-int ivar = 0;
-short svar = 0;
-long lvar = 0;
-unsigned int uivar = 0;
-unsigned short usvar = 0;
-unsigned long ulvar = 0;
-signed char scvar = 0;
-unsigned char ucvar = 0;
-char cvar = 0;
-float fvar = 0;
-double dvar = 0;
-char *strvar = 0;
-const char cstrvar[] = "Goodbye";
-int *iptrvar = 0;
-char name[5] = "Dave";
-char path[256] = "/home/beazley";
-
-
-/* Global variables involving a structure */
-Point *ptptr = 0;
-Point pt = { 10, 20 };
-
-/* A variable that we will make read-only in the interface */
-int status = 1;
-
-/* A debugging function to print out their values */
-
-void print_vars() {
- printf("ivar = %d\n", ivar);
- printf("svar = %d\n", svar);
- printf("lvar = %ld\n", lvar);
- printf("uivar = %u\n", uivar);
- printf("usvar = %u\n", usvar);
- printf("ulvar = %lu\n", ulvar);
- printf("scvar = %d\n", scvar);
- printf("ucvar = %u\n", ucvar);
- printf("fvar = %g\n", fvar);
- printf("dvar = %g\n", dvar);
- printf("cvar = %c\n", cvar);
- printf("strvar = %s\n", strvar ? strvar : "(null)");
- printf("cstrvar = %s\n", cstrvar);
- printf("iptrvar = %p\n", (void *)iptrvar);
- printf("name = %c%c%c%c%c\n", name[0],name[1],name[2],name[3],name[4]);
- printf("ptptr = %p %s\n", (void *)ptptr, Point_print( ptptr ) );
- printf("pt = (%d, %d)\n", pt.x, pt.y);
- printf("status = %d\n", status);
-}
-
-/* A function to create an integer (to test iptrvar) */
-
-int *new_int(int value) {
- int *ip = (int *) malloc(sizeof(int));
- *ip = value;
- return ip;
-}
-
-int value_int(int *value) {
- return *value;
-}
-
-/* A function to create a point */
-
-Point *new_Point(int x, int y) {
- Point *p = (Point *) malloc(sizeof(Point));
- p->x = x;
- p->y = y;
- return p;
-}
-
-char * Point_print(Point *p) {
- static char buffer[256];
- if (p) {
- sprintf(buffer,"(%d,%d)", p->x,p->y);
- } else {
- sprintf(buffer,"null");
- }
- return buffer;
-}
-
-void pt_print() {
- printf("(%d, %d)\n", pt.x, pt.y);
-}
diff --git a/Examples/php5/variables/example.h b/Examples/php5/variables/example.h
deleted file mode 100644
index 3b3659ce5..000000000
--- a/Examples/php5/variables/example.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* File: example.h */
-
-typedef struct {
- int x,y;
-} Point;
-
-/* Some global variable declarations */
-extern int ivar;
-extern short svar;
-extern long lvar;
-extern unsigned int uivar;
-extern unsigned short usvar;
-extern unsigned long ulvar;
-extern signed char scvar;
-extern unsigned char ucvar;
-extern char cvar;
-extern float fvar;
-extern double dvar;
-extern char *strvar;
-extern const char cstrvar[];
-extern int *iptrvar;
-extern char name[5];
-
-extern Point *ptptr;
-extern Point pt;
-
-extern int status;
-extern char path[256];
-
-extern void print_vars();
-extern int *new_int(int value);
-extern Point *new_Point(int x, int y);
-extern char *Point_print(Point *p);
-extern void pt_print();
diff --git a/Examples/php5/variables/example.i b/Examples/php5/variables/example.i
deleted file mode 100644
index 3edbb72d7..000000000
--- a/Examples/php5/variables/example.i
+++ /dev/null
@@ -1,44 +0,0 @@
-/* File : example.i */
-%module example
-%{
-#include "example.h"
-%}
-
-/* Some global variable declarations */
-extern int ivar;
-extern short svar;
-extern long lvar;
-extern unsigned int uivar;
-extern unsigned short usvar;
-extern unsigned long ulvar;
-extern signed char scvar;
-extern unsigned char ucvar;
-extern char cvar;
-extern float fvar;
-extern double dvar;
-extern char *strvar;
-extern const char cstrvar[];
-extern int *iptrvar;
-extern char name[5];
-
-extern Point *ptptr;
-extern Point pt;
-
-/* Some read-only variables */
-
-%immutable;
-extern int status;
-extern char path[256];
-%mutable;
-
-/* Some helper functions to make it easier to test */
-extern void print_vars();
-extern int *new_int(int value);
-
-extern Point *new_Point(int x, int y);
-extern char *Point_print(Point *p);
-extern void pt_print();
-
-
-
-
diff --git a/Examples/php5/variables/runme.php b/Examples/php5/variables/runme.php
deleted file mode 100644
index bbfeb610b..000000000
--- a/Examples/php5/variables/runme.php
+++ /dev/null
@@ -1,96 +0,0 @@
-<?php
-
- require "example.php";
- echo "\nVariables (values printed from C)\n";
-
- print_vars();
-
- echo "Variables (values printed from PHP)\n";
-
- echo "ivar = ".ivar_get()."\n";
- echo "svar = ".svar_get()."\n";
- echo "lvar = ".lvar_get()."\n";
- echo "uivar = ".uivar_get()."\n";
- echo "usvar = ".usvar_get()."\n";
- echo "ulvar = ".ulvar_get()."\n";
- echo "scvar = ".scvar_get()."\n";
- echo "ucvar = ".ucvar_get()."\n";
- echo "cvar = ".cvar_get()."\n";
- echo "fvar = ".fvar_get()."\n";
- echo "dvar = ".dvar_get()."\n";
- echo "strvar = ".strvar_get()."\n";
- echo "cstrvar = ".cstrvar_get()."\n";
- echo "iptrvar = ".iptrvar_get()."\n";
- echo "name = \"".name_get()."\"\n";
- echo "ptptr = ".ptptr_get() , point_print(ptptr_get()) , "\n";
- echo "pt = ".pt_get(), point_print(pt_get()) , "\n";
-
- /* Try to set the values of some global variables */
-$a = "42.14";
-
- ivar_set($a);
-echo "a = $a\n";
- svar_set(-31000);
- lvar_set(65537);
- uivar_set(123456);
- usvar_set(61000);
- ulvar_set(654321);
- scvar_set(-13);
- ucvar_set(251);
- cvar_set("S");
- fvar_set(3.14159);
- dvar_set(2.1828);
- strvar_set("Hello World");
- iptrvar_set(new_int(37));
- ptptr_set(new_point(37,42));
- name_set("B");
-
- echo "Variables (values printed from PHP)\n";
-
- echo "ivar = ".ivar_get()."\n";
- echo "svar = ".svar_get()."\n";
- echo "lvar = ".lvar_get()."\n";
- echo "uivar = ".uivar_get()."\n";
- echo "usvar = ".usvar_get()."\n";
- echo "ulvar = ".ulvar_get()."\n";
- echo "scvar = ".scvar_get()."\n";
- echo "ucvar = ".ucvar_get()."\n";
- echo "cvar = ".cvar_get()."\n";
- echo "fvar = ".fvar_get()."\n";
- echo "dvar = ".dvar_get()."\n";
- echo "strvar = ".strvar_get()."\n";
- echo "cstrvar = ".cstrvar_get()."\n";
- echo "iptrvar = ".iptrvar_get()."\n";
- echo "name = ".name_get()."\n";
- echo "ptptr = ".ptptr_get() , point_print(ptptr_get()) , "\n";
- echo "pt = ".pt_get(), point_print(pt_get()) , "\n";
-
- echo "\nVariables (values printed from C)\n";
-
- print_vars();
-
- echo "\nI'm going to try and update a structure variable.\n";
-
- pt_set(ptptr_get());
-
- echo "The new value is \n";
-
- pt_print();
-
- echo "You should see the value", point_print(ptptr_get()), "\n";
-
- echo "\nNow I'm going to try and modify some read only variables\n";
-
- echo "Trying to set 'path'\n";
-
- //path_set("Whoa!");
- echo "Path = ".path_get()."\n";
-
- echo "Trying to set 'status'\n";
-
- /* And this */
- //status_set(0);
- echo "Status = ".status_get()."\n";
-
-?>
-
diff --git a/Examples/python/callback/runme.py b/Examples/python/callback/runme.py
index 345a3eb6e..41deb8386 100644
--- a/Examples/python/callback/runme.py
+++ b/Examples/python/callback/runme.py
@@ -11,7 +11,7 @@ class PyCallback(example.Callback):
example.Callback.__init__(self)
def run(self):
- print "PyCallback.run()"
+ print("PyCallback.run()")
# Create an Caller instance
@@ -20,8 +20,8 @@ caller = example.Caller()
# Add a simple C++ callback (caller owns the callback, so
# we disown it first by clearing the .thisown flag).
-print "Adding and calling a normal C++ callback"
-print "----------------------------------------"
+print("Adding and calling a normal C++ callback")
+print("----------------------------------------")
callback = example.Callback()
callback.thisown = 0
@@ -29,9 +29,9 @@ caller.setCallback(callback)
caller.call()
caller.delCallback()
-print
-print "Adding and calling a Python callback"
-print "------------------------------------"
+print("")
+print("Adding and calling a Python callback")
+print("------------------------------------")
# Add a Python callback (caller owns the callback, so we
# disown it first by calling __disown__).
@@ -40,9 +40,9 @@ caller.setCallback(PyCallback().__disown__())
caller.call()
caller.delCallback()
-print
-print "Adding and calling another Python callback"
-print "------------------------------------------"
+print("")
+print("Adding and calling another Python callback")
+print("------------------------------------------")
# Let's do the same but use the weak reference this time.
@@ -53,5 +53,5 @@ caller.delCallback()
# All done.
-print
-print "python exit"
+print("")
+print("python exit")
diff --git a/Examples/python/check.list b/Examples/python/check.list
index a43a5fca0..025278f89 100644
--- a/Examples/python/check.list
+++ b/Examples/python/check.list
@@ -4,6 +4,7 @@ class
constants
contract
docstrings
+doxygen
enum
exception
exceptproxy
@@ -12,9 +13,8 @@ funcptr
funcptr2
functor
import
-import_template
import_packages
-java
+import_template
#libffi
multimap
operator
@@ -22,8 +22,8 @@ pointer
reference
simple
smartptr
-std_vector
std_map
+std_vector
template
varargs
variables
diff --git a/Examples/python/class/runme.py b/Examples/python/class/runme.py
index 34d21505c..adade7468 100644
--- a/Examples/python/class/runme.py
+++ b/Examples/python/class/runme.py
@@ -7,15 +7,15 @@ import example
# ----- Object creation -----
-print "Creating some objects:"
+print("Creating some objects:")
c = example.Circle(10)
-print " Created circle", c
+print(" Created circle %s" % c)
s = example.Square(10)
-print " Created square", s
+print(" Created square %s" % s)
# ----- Access a static member -----
-print "\nA total of", example.cvar.Shape_nshapes, "shapes were created"
+print("\nA total of %d shapes were created" % example.cvar.Shape_nshapes)
# ----- Member data access -----
@@ -27,25 +27,25 @@ c.y = 30
s.x = -10
s.y = 5
-print "\nHere is their current position:"
-print " Circle = (%f, %f)" % (c.x, c.y)
-print " Square = (%f, %f)" % (s.x, s.y)
+print("\nHere is their current position:")
+print(" Circle = (%f, %f)" % (c.x, c.y))
+print(" Square = (%f, %f)" % (s.x, s.y))
# ----- Call some methods -----
-print "\nHere are some properties of the shapes:"
+print("\nHere are some properties of the shapes:")
for o in [c, s]:
- print " ", o
- print " area = ", o.area()
- print " perimeter = ", o.perimeter()
+ print(" %s" % o)
+ print(" area = %s" % o.area())
+ print(" perimeter = %s" % o.perimeter())
# prevent o from holding a reference to the last object looked at
o = None
-print "\nGuess I'll clean up now"
+print("\nGuess I'll clean up now")
# Note: this invokes the virtual destructor
del c
del s
-print example.cvar.Shape_nshapes, "shapes remain"
-print "Goodbye"
+print("%d shapes remain" % example.cvar.Shape_nshapes)
+print("Goodbye")
diff --git a/Examples/python/constants/runme.py b/Examples/python/constants/runme.py
index 415d1adc4..808bf1fe6 100644
--- a/Examples/python/constants/runme.py
+++ b/Examples/python/constants/runme.py
@@ -2,22 +2,24 @@
import example
-print "ICONST =", example.ICONST, "(should be 42)"
-print "FCONST =", example.FCONST, "(should be 2.1828)"
-print "CCONST =", example.CCONST, "(should be 'x')"
-print "CCONST2 =", example.CCONST2, "(this should be on a new line)"
-print "SCONST =", example.SCONST, "(should be 'Hello World')"
-print "SCONST2 =", example.SCONST2, "(should be '\"Hello World\"')"
-print "EXPR =", example.EXPR, "(should be 48.5484)"
-print "iconst =", example.iconst, "(should be 37)"
-print "fconst =", example.fconst, "(should be 3.14)"
+print("ICONST = %s (should be 42)" % example.ICONST)
+print("FCONST = %s (should be 2.1828)" % example.FCONST)
+print("CCONST = %s (should be 'x')" % example.CCONST)
+print("CCONST2 = %s (this should be on a new line)" % example.CCONST2)
+print("SCONST = %s (should be 'Hello World')" % example.SCONST)
+print("SCONST2 = %s (should be '\"Hello World\"')" % example.SCONST2)
+print("EXPR = %s (should be 48.5484)" % example.EXPR)
+print("iconst = %s (should be 37)" % example.iconst)
+print("fconst = %s (should be 3.14)" % example.fconst)
try:
- print "EXTERN = ", example.EXTERN, "(Arg! This shouldn't print anything)"
+ x = example.EXTERN
+ print("%s (Arg! This shouldn't print anything)" % x)
except AttributeError:
- print "EXTERN isn't defined (good)"
+ print("EXTERN isn't defined (good)")
try:
- print "FOO = ", example.FOO, "(Arg! This shouldn't print anything)"
+ x = example.FOO
+ print("%s (Arg! This shouldn't print anything)" % x)
except AttributeError:
- print "FOO isn't defined (good)"
+ print("FOO isn't defined (good)")
diff --git a/Examples/python/contract/runme.py b/Examples/python/contract/runme.py
index ce01e5a1d..ec0aceb45 100644
--- a/Examples/python/contract/runme.py
+++ b/Examples/python/contract/runme.py
@@ -7,15 +7,15 @@ import example
x = 42
y = 105
g = example.gcd(x, y)
-print "The gcd of %d and %d is %d" % (x, y, g)
+print("The gcd of %d and %d is %d" % (x, y, g))
# Manipulate the Foo global variable
# Output its current value
-print "Foo = ", example.cvar.Foo
+print("Foo = %s" % example.cvar.Foo)
# Change its value
example.cvar.Foo = 3.1415926
# See if the change took effect
-print "Foo = ", example.cvar.Foo
+print("Foo = %s" % example.cvar.Foo)
diff --git a/Examples/python/docstrings/runme.py b/Examples/python/docstrings/runme.py
index c25d291b6..76386d214 100644
--- a/Examples/python/docstrings/runme.py
+++ b/Examples/python/docstrings/runme.py
@@ -2,4 +2,4 @@
import example
-print "example.Foo.bar.__doc__ =", repr(example.Foo.bar.__doc__), "(Should be 'No comment')"
+print("example.Foo.bar.__doc__ = %s (Should be 'No comment')" % repr(example.Foo.bar.__doc__))
diff --git a/Examples/python/doxygen/Makefile b/Examples/python/doxygen/Makefile
new file mode 100644
index 000000000..1a0e3d7c5
--- /dev/null
+++ b/Examples/python/doxygen/Makefile
@@ -0,0 +1,27 @@
+TOP = ../..
+SWIGEXE = $(TOP)/../swig
+SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS = -lm
+SWIGOPT = -doxygen
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
+ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
+ SWIGOPT='$(SWIGOPT)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp
+
+static:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
+ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
+ SWIGOPT='$(SWIGOPT)' \
+ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
+ rm -f example.html
diff --git a/Examples/python/doxygen/example.cxx b/Examples/python/doxygen/example.cxx
new file mode 100644
index 000000000..ccdb87dfe
--- /dev/null
+++ b/Examples/python/doxygen/example.cxx
@@ -0,0 +1,48 @@
+/* File : example.cxx */
+
+#include "example.h"
+#define M_PI 3.14159265358979323846
+
+/* Move the shape to a new location */
+void Shape::move(double dx, double dy) {
+ x += dx;
+ y += dy;
+}
+
+int Shape::nshapes = 0;
+
+Circle::Circle(double r) : radius(r) {
+ NumCircles++;
+}
+
+double Circle::area() {
+ return M_PI*radius*radius;
+}
+
+double Circle::perimeter() {
+ return 2*M_PI*radius;
+}
+
+Square::Square(double w) : width(w) {
+ NumSquares++;
+}
+
+double Square::area() {
+ return width*width;
+}
+
+double Square::perimeter() {
+ return 4*width;
+}
+
+int NumSquares = 0;
+int NumCircles = 0;
+
+Square MakeSquare(double r) {
+ return Square(r);
+}
+
+Circle MakeCircle(double w) {
+ return Circle(w);
+}
+
diff --git a/Examples/python/doxygen/example.dsp b/Examples/python/doxygen/example.dsp
new file mode 100644
index 000000000..95ad8f173
--- /dev/null
+++ b/Examples/python/doxygen/example.dsp
@@ -0,0 +1,152 @@
+# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=example - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "example.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /debug /machine:I386 /out:"_example.pyd" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /machine:I386 /out:"_example.pyd"
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Debug"
+# Name "example - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\example.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\example_wrap.cxx
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\example.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\example.i
+
+!IF "$(CFG)" == "example - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -python "$(InputPath)"
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "example - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\example.i
+InputName=example
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -python "$(InputPath)"
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/Examples/python/doxygen/example.h b/Examples/python/doxygen/example.h
new file mode 100644
index 000000000..203348ae4
--- /dev/null
+++ b/Examples/python/doxygen/example.h
@@ -0,0 +1,107 @@
+/*! \file example.h
+This file provides a simple set of Shape classes. */
+
+/*! Base class for all shapes.
+ \author Bob
+ */
+class Shape {
+public:
+ /*! Default constructor for creating a Shape */
+ Shape() {
+ nshapes++;
+ }
+ /*! Destructor for destroying a Shape */
+ virtual ~Shape() {
+ nshapes--;
+ }
+ double x; /*!< x co-ordinate */
+ double y; /*!< y co-ordinate */
+ void move(double dx, double dy); /*!< Move a shape to a new co-ordinate
+ \param dx x co-ordinate
+ \param dy y co-ordinate */
+ virtual double area() = 0; /*!< \return the area */
+ virtual double perimeter() = 0; /*!< \return the perimeter */
+ static int nshapes; /*!< Number of shapes currently in existence */
+};
+
+/*! A class for representing a circle.
+ \author Jack
+ */
+class Circle : public Shape {
+private:
+ double radius;
+public:
+ /*! Construct a circle
+ * \param r radius of the circle */
+ Circle(double r);
+ /*! Calculate the area of the circle
+ * \return calculated area */
+ virtual double area();
+ /*! Calculate the perimeter of the circle
+ * \return calculated perimeter of the circle */
+ virtual double perimeter();
+};
+
+/// A class for representing a square.
+class Square : public Shape {
+private:
+ double width;
+public:
+ /** Construct a square
+ * \param w width of the square */
+ Square(double w);
+ /** Calculate the area of the square
+ * \return calculated area */
+ virtual double area();
+ /** Calculate the perimeter of the square
+ * \return calculated perimeter of the square */
+ virtual double perimeter();
+};
+
+/// A class for representing a rectangle, templated on the type for the rectangle dimensions
+template<typename T>
+class Rectangle : public Shape {
+private:
+ T height;
+ T width;
+public:
+ /** Construct a rectangle
+ * \param h height of the rectangle
+ * \param w width of the rectangle */
+ Rectangle(T h, T w) : height(h), width(w) {}
+ /** Calculate the area of the rectangle
+ * \return calculated area */
+ virtual double area() { return width*height; }
+ /** Calculate the perimeter of the rectangle
+ * \return calculated perimeter of the rectangle */
+ virtual double perimeter() { return 2*height + 2*width; }
+};
+
+
+/*! Factory function for creating a square
+ * \param r width of the square
+ * \return a fully constructed square */
+Square MakeSquare(double r);
+
+/*! Factory function for creating a circle
+ * \param w radius of the circle
+ * \return a fully constructed circle */
+Circle MakeCircle(double w);
+
+/*! Factory function for creating a rectangle
+ * \param h height of the rectangle
+ * \param w width of the rectangle
+ * \return a fully constructed rectangle */
+template<typename T>
+Rectangle<T> MakeRectangle(T h, T w) {
+ return Rectangle<T>(h, w);
+}
+
+
+
+/*! Total number of circles ever created */
+extern int NumCircles;
+
+/// Total number of squares ever created
+extern int NumSquares;
+
diff --git a/Examples/python/doxygen/example.i b/Examples/python/doxygen/example.i
new file mode 100644
index 000000000..803563dd9
--- /dev/null
+++ b/Examples/python/doxygen/example.i
@@ -0,0 +1,17 @@
+%module example
+
+%{
+#include "example.h"
+%}
+
+%immutable NumSquares;
+%immutable NumCircles;
+
+%include "example.h"
+
+/*! - this instantiation uses type int */
+%template(RectangleInt) Rectangle<int>;
+
+/*! - this instantiation uses type int */
+%template(MakeRectangleInt) MakeRectangle<int>;
+
diff --git a/Examples/python/doxygen/runme.py b/Examples/python/doxygen/runme.py
new file mode 100644
index 000000000..657535cc2
--- /dev/null
+++ b/Examples/python/doxygen/runme.py
@@ -0,0 +1,28 @@
+# This example shows simple usage of the wrapped Shape classes.
+# The main purpose of this example is to show the doxygen comments translation to PyDoc comments.
+# Users should look at the generated example.py file.
+# The generated PyDoc can be viewed in a browser by opening the example.html file.
+
+import example
+
+print("Creating some objects:")
+c = example.MakeCircle(10)
+print(" Created circle %s" % c)
+s = example.MakeSquare(10)
+print(" Created square %s" % s)
+r = example.MakeRectangleInt(10, 20)
+print(" Created rectangle %s" % r)
+
+print("\nHere are some properties of the shapes:")
+for o in [c, s, r]:
+ print(" %s" % o)
+ print(" area = %s" % o.area())
+ print(" perimeter = %s" % o.perimeter())
+
+print("\nRunning pydoc, this is the equivalent to executing: pydoc -w ./example.py")
+
+import pydoc
+
+pydoc.writedoc("example")
+
+print("Open example.html in your browser to view the generated python docs")
diff --git a/Examples/python/enum/runme.py b/Examples/python/enum/runme.py
index def01b147..4920c1dcf 100644
--- a/Examples/python/enum/runme.py
+++ b/Examples/python/enum/runme.py
@@ -5,24 +5,24 @@ import example
# ----- Object creation -----
# Print out the value of some enums
-print "*** color ***"
-print " RED =", example.RED
-print " BLUE =", example.BLUE
-print " GREEN =", example.GREEN
+print("*** color ***")
+print(" RED = %s" % example.RED)
+print(" BLUE = %s" % example.BLUE)
+print(" GREEN = %s" % example.GREEN)
-print "\n*** Foo::speed ***"
-print " Foo_IMPULSE =", example.Foo.IMPULSE
-print " Foo_WARP =", example.Foo.WARP
-print " Foo_LUDICROUS =", example.Foo.LUDICROUS
+print("\n*** Foo::speed ***")
+print(" Foo_IMPULSE = %s" % example.Foo.IMPULSE)
+print(" Foo_WARP = %s" % example.Foo.WARP)
+print(" Foo_LUDICROUS = %s" % example.Foo.LUDICROUS)
-print "\nTesting use of enums with functions\n"
+print("\nTesting use of enums with functions\n")
example.enum_test(example.RED, example.Foo.IMPULSE)
example.enum_test(example.BLUE, example.Foo.WARP)
example.enum_test(example.GREEN, example.Foo.LUDICROUS)
example.enum_test(1234, 5678)
-print "\nTesting use of enum with class method"
+print("\nTesting use of enum with class method")
f = example.Foo()
f.enum_test(example.Foo.IMPULSE)
diff --git a/Examples/python/exception/example.h b/Examples/python/exception/example.h
index 8f9a977b0..bc744cda7 100644
--- a/Examples/python/exception/example.h
+++ b/Examples/python/exception/example.h
@@ -1,6 +1,6 @@
/* File : example.h */
-#include <string>
+#include <string.h>
#ifndef SWIG
struct A {
};
@@ -16,30 +16,26 @@ public:
char msg[256];
};
-#if defined(_MSC_VER)
- #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
-
class Test {
public:
- int simple() throw(int) {
+ int simple() {
throw(37);
return 1;
}
- int message() throw(const char *) {
+ int message() {
throw("I died.");
return 1;
}
- int hosed() throw(Exc) {
+ int hosed() {
throw(Exc(42,"Hosed"));
return 1;
}
- int unknown() throw(A*) {
+ int unknown() {
static A a;
throw &a;
return 1;
}
- int multi(int x) throw(int, const char *, Exc) {
+ int multi(int x) {
if (x == 1) throw(37);
if (x == 2) throw("Bleah!");
if (x == 3) throw(Exc(42,"No-go-diggy-die"));
@@ -47,7 +43,3 @@ public:
}
};
-#if defined(_MSC_VER)
- #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
-
diff --git a/Examples/python/exception/example.i b/Examples/python/exception/example.i
index 817c5221c..3a3a6548f 100644
--- a/Examples/python/exception/example.i
+++ b/Examples/python/exception/example.i
@@ -7,6 +7,12 @@
%include "std_string.i"
+%catches(int) Test::simple();
+%catches(const char *) Test::message();
+%catches(Exc) Test::hosed();
+%catches(A*) Test::unknown();
+%catches(int, const char *, Exc) Test::multi(int x);
+
/* Let's just grab the original header file here */
%include "example.h"
diff --git a/Examples/python/exception/runme.py b/Examples/python/exception/runme.py
index 7fae49030..7b5c10d19 100644
--- a/Examples/python/exception/runme.py
+++ b/Examples/python/exception/runme.py
@@ -7,36 +7,36 @@ import example
t = example.Test()
try:
t.unknown()
-except RuntimeError, e:
- print "incomplete type", e.args[0]
+except RuntimeError as e:
+ print("incomplete type %s" % e.args[0])
try:
t.simple()
-except RuntimeError, e:
- print e.args[0]
+except RuntimeError as e:
+ print(e.args[0])
try:
t.message()
-except RuntimeError, e:
- print e.args[0]
+except RuntimeError as e:
+ print(e.args[0])
if not example.is_python_builtin():
try:
t.hosed()
- except example.Exc, e:
- print e.code, e.msg
+ except example.Exc as e:
+ print("%s %s" % (e.code, e.msg))
else:
try:
t.hosed()
- except BaseException, e:
+ except BaseException as e:
# Throwing builtin classes as exceptions not supported (-builtin
# option)
- print e
+ print(e)
for i in range(1, 4):
try:
t.multi(i)
- except RuntimeError, e:
- print e.args[0]
- except example.Exc, e:
- print e.code, e.msg
+ except RuntimeError as e:
+ print(e.args[0])
+ except example.Exc as e:
+ print("%s %s" % (e.code, e.msg))
diff --git a/Examples/python/exceptproxy/example.h b/Examples/python/exceptproxy/example.h
index ec7107a5e..3ee6d765d 100644
--- a/Examples/python/exceptproxy/example.h
+++ b/Examples/python/exceptproxy/example.h
@@ -8,10 +8,6 @@ class FullError {
FullError(int m) : maxsize(m) { }
};
-#if defined(_MSC_VER)
- #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
-
template<typename T> class Queue {
int maxsize;
T *items;
@@ -27,7 +23,7 @@ template<typename T> class Queue {
~Queue() {
delete [] items;
}
- void enqueue(T x) throw(FullError) {
+ void enqueue(T x) {
if (nitems == maxsize) {
throw FullError(maxsize);
}
@@ -47,8 +43,3 @@ template<typename T> class Queue {
}
};
-
-#if defined(_MSC_VER)
- #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
-
diff --git a/Examples/python/exceptproxy/example.i b/Examples/python/exceptproxy/example.i
index 0a46afbb6..4ad960845 100644
--- a/Examples/python/exceptproxy/example.i
+++ b/Examples/python/exceptproxy/example.i
@@ -20,29 +20,12 @@
the header file, the enqueue method throws FullError and
the dequeue method throws EmptyError. Since we don't
want to define an exception handler for everything, we
- simply write a handler each method individually.
+ simply write a handler for each method individually.
Note: the *::enqueue syntax means that we simply define
the handler for any class with this method defined.
*/
-/*
- First we need to 'disable' the default swig throw mechanism for the
- FullError class. We do this by rethrowing the exception.
-
- Note that this is necessary since the class appears in a throw
- declaration:
-
-
- void enqueue(T x) throw(FullError);
-
- hence, swig recognizes it as an exception class and it will generate
- the necessary code to catch it and rethrow it to the python side.
-
-*/
-%typemap(throws) FullError "(void)$1; throw;";
-
-
%exception *::enqueue {
try {
$action
@@ -76,15 +59,15 @@
*/
/*
- Now, the EmpytError doesn't appear in a throw declaration, and hence
- we need to 'mark' it as an exception class. In python, classes that
- are used as exception are 'special', and need to be wrapped as
- 'classic' ones.
-
- This is a python issue, and if you don't mark the class, you will
- see 'interesting' behaviours at the python side.
-
-
+ Python classes that are used as exceptions need to be subclasses of the
+ "Exception" class, and so SWIG needs to know which wrapped classes may be
+ used in this way. You can explicitly tell SWIG this by using
+ %exceptionclass. SWIG will implicitly set this feature for classes which
+ appear in a throw declaration, but it's not a problem to explicitly
+ mark such classes as well.
+
+ This is a Python requirement - if you fail to mark such classes with
+ %exceptionclass you may see 'interesting' behaviour on the Python side.
*/
%exceptionclass EmptyError;
%exceptionclass FullError;
diff --git a/Examples/python/exceptproxy/runme.py b/Examples/python/exceptproxy/runme.py
index 970d6201d..d25fb6de6 100644
--- a/Examples/python/exceptproxy/runme.py
+++ b/Examples/python/exceptproxy/runme.py
@@ -2,44 +2,44 @@
import example
if example.is_python_builtin():
- print "Skipping example: -builtin option does not support %exceptionclass"
+ print("Skipping example: -builtin option does not support %exceptionclass")
exit(0)
q = example.intQueue(10)
-print "Inserting items into intQueue"
+print("Inserting items into intQueue")
-print type(example.FullError)
+print(type(example.FullError))
try:
for i in range(0, 100):
q.enqueue(i)
-except example.FullError, e:
- print "Maxsize is", e.maxsize
+except example.FullError as e:
+ print("Maxsize is %s" % e.maxsize)
-print "Removing items"
+print("Removing items")
try:
- while 1:
+ while True:
q.dequeue()
-except example.EmptyError, e:
+except example.EmptyError as e:
pass
q = example.doubleQueue(1000)
-print "Inserting items into doubleQueue"
+print("Inserting items into doubleQueue")
try:
for i in range(0, 10000):
q.enqueue(i * 1.5)
-except example.FullError, e:
- print "Maxsize is", e.maxsize
+except example.FullError as e:
+ print("Maxsize is %s" % e.maxsize)
-print "Removing items"
+print("Removing items")
try:
- while 1:
+ while True:
q.dequeue()
-except example.EmptyError, e:
+except example.EmptyError as e:
pass
diff --git a/Examples/python/extend/runme.py b/Examples/python/extend/runme.py
index 2bb38fadc..d7e626ec2 100644
--- a/Examples/python/extend/runme.py
+++ b/Examples/python/extend/runme.py
@@ -18,12 +18,12 @@ class CEO(example.Manager):
# Create an instance of our employee extension class, CEO. The calls to
# getName() and getPosition() are standard, the call to getTitle() uses
-# the director wrappers to call CEO.getPosition. e = CEO("Alice")
+# the director wrappers to call CEO.getPosition.
e = CEO("Alice")
-print e.getName(), "is a", e.getPosition()
-print "Just call her \"%s\"" % e.getTitle()
-print "----------------------"
+print("%s is a %s" % (e.getName(), e.getPosition()))
+print("Just call her \"%s\"" % e.getTitle())
+print("----------------------")
# Create a new EmployeeList instance. This class does not have a C++
@@ -40,7 +40,7 @@ list = example.EmployeeList()
e = e.__disown__()
list.addEmployee(e)
-print "----------------------"
+print("----------------------")
# Now we access the first four items in list (three are C++ objects that
# EmployeeList's constructor adds, the last is our CEO). The virtual
@@ -59,13 +59,13 @@ print "----------------------"
# passes down through the C++ director class to the Python implementation
# in CEO. All this routing takes place transparently.
-print "(position, title) for items 0-3:"
+print("(position, title) for items 0-3:")
-print " %s, \"%s\"" % (list.get_item(0).getPosition(), list.get_item(0).getTitle())
-print " %s, \"%s\"" % (list.get_item(1).getPosition(), list.get_item(1).getTitle())
-print " %s, \"%s\"" % (list.get_item(2).getPosition(), list.get_item(2).getTitle())
-print " %s, \"%s\"" % (list.get_item(3).getPosition(), list.get_item(3).getTitle())
-print "----------------------"
+print(" %s, \"%s\"" % (list.get_item(0).getPosition(), list.get_item(0).getTitle()))
+print(" %s, \"%s\"" % (list.get_item(1).getPosition(), list.get_item(1).getTitle()))
+print(" %s, \"%s\"" % (list.get_item(2).getPosition(), list.get_item(2).getTitle()))
+print(" %s, \"%s\"" % (list.get_item(3).getPosition(), list.get_item(3).getTitle()))
+print("----------------------")
# Time to delete the EmployeeList, which will delete all the Employee*
# items it contains. The last item is our CEO, which gets destroyed as its
@@ -75,8 +75,8 @@ print "----------------------"
# usual to destroy the object.
del list
-print "----------------------"
+print("----------------------")
# All done.
-print "python exit"
+print("python exit")
diff --git a/Examples/python/funcptr/runme.py b/Examples/python/funcptr/runme.py
index bf0c6e1ac..4248f928d 100644
--- a/Examples/python/funcptr/runme.py
+++ b/Examples/python/funcptr/runme.py
@@ -7,14 +7,14 @@ b = 42
# Now call our C function with a bunch of callbacks
-print "Trying some C callback functions"
-print " a =", a
-print " b =", b
-print " ADD(a,b) =", example.do_op(a, b, example.ADD)
-print " SUB(a,b) =", example.do_op(a, b, example.SUB)
-print " MUL(a,b) =", example.do_op(a, b, example.MUL)
+print("Trying some C callback functions")
+print(" a = %s" % a)
+print(" b = %s" % b)
+print(" ADD(a,b) = %s" % example.do_op(a, b, example.ADD))
+print(" SUB(a,b) = %s" % example.do_op(a, b, example.SUB))
+print(" MUL(a,b) = %s" % example.do_op(a, b, example.MUL))
-print "Here is what the C callback function objects look like in Python"
-print " ADD =", example.ADD
-print " SUB =", example.SUB
-print " MUL =", example.MUL
+print("Here is what the C callback function objects look like in Python")
+print(" ADD = %s" % example.ADD)
+print(" SUB = %s" % example.SUB)
+print(" MUL = %s" % example.MUL)
diff --git a/Examples/python/funcptr2/runme.py b/Examples/python/funcptr2/runme.py
index a4405d9d9..afa2e2db6 100644
--- a/Examples/python/funcptr2/runme.py
+++ b/Examples/python/funcptr2/runme.py
@@ -7,18 +7,18 @@ b = 42
# Now call our C function with a bunch of callbacks
-print "Trying some C callback functions"
-print " a =", a
-print " b =", b
-print " ADD(a,b) =", example.do_op(a, b, example.ADD)
-print " SUB(a,b) =", example.do_op(a, b, example.SUB)
-print " MUL(a,b) =", example.do_op(a, b, example.MUL)
+print("Trying some C callback functions")
+print(" a = %s" % a)
+print(" b = %s" % b)
+print(" ADD(a,b) = %s" % example.do_op(a, b, example.ADD))
+print(" SUB(a,b) = %s" % example.do_op(a, b, example.SUB))
+print(" MUL(a,b) = %s" % example.do_op(a, b, example.MUL))
-print "Here is what the C callback function objects look like in Python"
-print " ADD =", example.ADD
-print " SUB =", example.SUB
-print " MUL =", example.MUL
+print("Here is what the C callback function objects look like in Python")
+print(" ADD = %s" % example.ADD)
+print(" SUB = %s" % example.SUB)
+print(" MUL = %s" % example.MUL)
-print "Call the functions directly..."
-print " add(a,b) =", example.add(a, b)
-print " sub(a,b) =", example.sub(a, b)
+print("Call the functions directly...")
+print(" add(a,b) = %s" % example.add(a, b))
+print(" sub(a,b) = %s" % example.sub(a, b))
diff --git a/Examples/python/functor/runme.py b/Examples/python/functor/runme.py
index 7f6f2b649..69289a78b 100644
--- a/Examples/python/functor/runme.py
+++ b/Examples/python/functor/runme.py
@@ -12,5 +12,5 @@ for i in range(0, 100):
a(i) # Note: function call
b(math.sqrt(i)) # Note: function call
-print a.result()
-print b.result()
+print(a.result())
+print(b.result())
diff --git a/Examples/python/import/runme.py b/Examples/python/import/runme.py
index 0e83acad0..afa21a2b3 100644
--- a/Examples/python/import/runme.py
+++ b/Examples/python/import/runme.py
@@ -1,15 +1,22 @@
# file: runme.py
# Test various properties of classes defined in separate modules
+import sys
+
+print("Testing the %import directive")
-print "Testing the %import directive"
import base
import foo
import bar
import spam
+def write_flush(s):
+ # Python 2/3 compatible write and flush
+ sys.stdout.write(s)
+ sys.stdout.flush()
+
# Create some objects
-print "Creating some objects"
+print("Creating some objects")
a = base.Base()
b = foo.Foo()
@@ -17,91 +24,74 @@ c = bar.Bar()
d = spam.Spam()
# Try calling some methods
-print "Testing some methods"
-print "",
-print "Should see 'Base::A' ---> ",
+print("Testing some methods")
+
+write_flush(" Should see 'Base::A' ---> ")
a.A()
-print "Should see 'Base::B' ---> ",
+write_flush(" Should see 'Base::B' ---> ")
a.B()
-print "Should see 'Foo::A' ---> ",
+write_flush(" Should see 'Foo::A' ---> ")
b.A()
-print "Should see 'Foo::B' ---> ",
+write_flush(" Should see 'Foo::B' ---> ")
b.B()
-print "Should see 'Bar::A' ---> ",
+write_flush(" Should see 'Bar::A' ---> ")
c.A()
-print "Should see 'Bar::B' ---> ",
+write_flush(" Should see 'Bar::B' ---> ")
c.B()
-print "Should see 'Spam::A' ---> ",
+write_flush(" Should see 'Spam::A' ---> ")
d.A()
-print "Should see 'Spam::B' ---> ",
+write_flush(" Should see 'Spam::B' ---> ")
d.B()
# Try some casts
-print "\nTesting some casts\n"
-print "",
+print("\nTesting some casts\n")
x = a.toBase()
-print "Should see 'Base::A' ---> ",
+write_flush(" Should see 'Base::A' ---> ")
x.A()
-print "Should see 'Base::B' ---> ",
+write_flush(" Should see 'Base::B' ---> ")
x.B()
x = b.toBase()
-print "Should see 'Foo::A' ---> ",
+write_flush(" Should see 'Foo::A' ---> ")
x.A()
-print "Should see 'Base::B' ---> ",
+write_flush(" Should see 'Base::B' ---> ")
x.B()
x = c.toBase()
-print "Should see 'Bar::A' ---> ",
+write_flush(" Should see 'Bar::A' ---> ")
x.A()
-print "Should see 'Base::B' ---> ",
+write_flush(" Should see 'Base::B' ---> ")
x.B()
x = d.toBase()
-print "Should see 'Spam::A' ---> ",
+write_flush(" Should see 'Spam::A' ---> ")
x.A()
-print "Should see 'Base::B' ---> ",
+write_flush(" Should see 'Base::B' ---> ")
x.B()
x = d.toBar()
-print "Should see 'Bar::B' ---> ",
+write_flush(" Should see 'Bar::B' ---> ")
x.B()
-print "\nTesting some dynamic casts\n"
+print("\nTesting some dynamic casts\n")
x = d.toBase()
-print " Spam -> Base -> Foo : ",
y = foo.Foo_fromBase(x)
-if y:
- print "bad swig"
-else:
- print "good swig"
+print(" Spam -> Base -> Foo : {} swig".format("bad" if y else "good"))
-print " Spam -> Base -> Bar : ",
y = bar.Bar_fromBase(x)
-if y:
- print "good swig"
-else:
- print "bad swig"
+print(" Spam -> Base -> Bar : {} swig".format("good" if y else "bad"))
-print " Spam -> Base -> Spam : ",
y = spam.Spam_fromBase(x)
-if y:
- print "good swig"
-else:
- print "bad swig"
+print(" Spam -> Base -> Spam : {} swig".format("good" if y else "bad"))
-print " Foo -> Spam : ",
y = spam.Spam_fromBase(b)
-if y:
- print "bad swig"
-else:
- print "good swig"
+print(" Foo -> Spam : {} swig".format("bad" if y else "good"))
diff --git a/Examples/python/import_packages/Makefile b/Examples/python/import_packages/Makefile
index f428d6f5c..c7f9a830b 100644
--- a/Examples/python/import_packages/Makefile
+++ b/Examples/python/import_packages/Makefile
@@ -8,11 +8,12 @@ import_packages_subdirs = \
from_init1 \
from_init2 \
from_init3 \
+ module_is_init \
relativeimport1 \
relativeimport2 \
relativeimport3 \
split_modules \
- namespace_pkg
+ namespace_pkg \
check: build
@@ -21,19 +22,19 @@ check: build
mkdir -p `dirname $$file`; \
cp "${SRCDIR}$$file" "$$file" || exit 1; \
done; \
- fi; \
+ fi
for s in $(import_packages_subdirs); do \
- (cd $$s && $(MAKE) check); \
+ (cd $$s && $(MAKE) check) || exit 1; \
done
build:
for s in $(import_packages_subdirs); do \
- (cd $$s && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build); \
+ (cd $$s && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build) || exit 1; \
done
static:
for s in $(import_packages_subdirs); do \
- (cd $$s && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static); \
+ (cd $$s && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static) || exit 1; \
done
clean:
@@ -42,7 +43,7 @@ clean:
for file in `cd $(SRCDIR) && find . -type f -name "*.py"`; do \
rm -f "$$file" || exit 1; \
done; \
- fi; \
+ fi
for s in $(import_packages_subdirs); do \
- (cd $$s && $(MAKE) clean); \
+ (cd $$s && $(MAKE) clean) || exit 1; \
done
diff --git a/Examples/python/import_packages/from_init1/runme.py b/Examples/python/import_packages/from_init1/runme.py
index dda397487..c76716f16 100644
--- a/Examples/python/import_packages/from_init1/runme.py
+++ b/Examples/python/import_packages/from_init1/runme.py
@@ -1,13 +1,35 @@
-import sys
import os.path
+import subprocess
+import sys
+
+def run_except_on_windows(commandline, env=None):
+ if os.name != "nt" and sys.platform != "cygwin":
+ # Strange failures on windows/cygin/mingw
+ subprocess.check_call(commandline, env=env, shell=True)
+ print((" Finished running: " + commandline))
# Test import of modules content from within __init__.py
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
-print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
+print("Testing " + testname + " - %module(package=...) + python 'import' in __init__.py")
+
+if sys.version_info < (2, 5):
+ print(" Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'")
+ sys.exit(0)
if sys.version_info < (3, 0):
import py2.pkg2
- print " Finished importing py2.pkg2"
+ print(" Finished importing py2.pkg2")
+ commandline = sys.executable + " -m py2.pkg2.bar"
+ run_except_on_windows(commandline)
+ commandline = sys.executable + " -m py2.pkg2.foo"
+ run_except_on_windows(commandline)
else:
import py3.pkg2
- print " Finished importing py3.pkg2"
+ print(" Finished importing py3.pkg2")
+ # commandline = sys.executable + " -m py3.pkg2.bar"
+ # run_except_on_windows(commandline)
+ # commandline = sys.executable + " -m py3.pkg2.foo"
+ # run_except_on_windows(commandline)
+
+# TODO: Commented out code above results in (from python-3.6 onwards):
+# RuntimeWarning: 'py3.pkg2.bar' found in sys.modules after import of package 'py3.pkg2', but prior to execution of 'py3.pkg2.bar'; this may result in unpredictable behaviour
diff --git a/Examples/python/import_packages/from_init2/runme.py b/Examples/python/import_packages/from_init2/runme.py
index dda397487..c9c46a4da 100644
--- a/Examples/python/import_packages/from_init2/runme.py
+++ b/Examples/python/import_packages/from_init2/runme.py
@@ -1,13 +1,31 @@
-import sys
import os.path
+import subprocess
+import sys
+
+def run_except_on_windows(commandline, env=None):
+ if os.name != "nt" and sys.platform != "cygwin":
+ # Strange failures on windows/cygin/mingw
+ subprocess.check_call(commandline, env=env, shell=True)
+ print((" Finished running: " + commandline))
# Test import of modules content from within __init__.py
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
-print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
+print("Testing " + testname + " - %module(package=...) + python 'import' in __init__.py")
+
+if sys.version_info < (2, 5):
+ print(" Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'")
+ sys.exit(0)
if sys.version_info < (3, 0):
import py2.pkg2
- print " Finished importing py2.pkg2"
+ print(" Finished importing py2.pkg2")
+ commandline = sys.executable + " -m py2.pkg2.bar"
+ run_except_on_windows(commandline)
else:
import py3.pkg2
- print " Finished importing py3.pkg2"
+ print(" Finished importing py3.pkg2")
+ # commandline = sys.executable + " -m py3.pkg2.bar"
+ # run_except_on_windows(commandline)
+
+# TODO: Commented out code above results in (from python-3.6 onwards):
+# RuntimeWarning: 'py3.pkg2.bar' found in sys.modules after import of package 'py3.pkg2', but prior to execution of 'py3.pkg2.bar'; this may result in unpredictable behaviour
diff --git a/Examples/python/import_packages/from_init3/runme.py b/Examples/python/import_packages/from_init3/runme.py
index dda397487..c9c46a4da 100644
--- a/Examples/python/import_packages/from_init3/runme.py
+++ b/Examples/python/import_packages/from_init3/runme.py
@@ -1,13 +1,31 @@
-import sys
import os.path
+import subprocess
+import sys
+
+def run_except_on_windows(commandline, env=None):
+ if os.name != "nt" and sys.platform != "cygwin":
+ # Strange failures on windows/cygin/mingw
+ subprocess.check_call(commandline, env=env, shell=True)
+ print((" Finished running: " + commandline))
# Test import of modules content from within __init__.py
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
-print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
+print("Testing " + testname + " - %module(package=...) + python 'import' in __init__.py")
+
+if sys.version_info < (2, 5):
+ print(" Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'")
+ sys.exit(0)
if sys.version_info < (3, 0):
import py2.pkg2
- print " Finished importing py2.pkg2"
+ print(" Finished importing py2.pkg2")
+ commandline = sys.executable + " -m py2.pkg2.bar"
+ run_except_on_windows(commandline)
else:
import py3.pkg2
- print " Finished importing py3.pkg2"
+ print(" Finished importing py3.pkg2")
+ # commandline = sys.executable + " -m py3.pkg2.bar"
+ # run_except_on_windows(commandline)
+
+# TODO: Commented out code above results in (from python-3.6 onwards):
+# RuntimeWarning: 'py3.pkg2.bar' found in sys.modules after import of package 'py3.pkg2', but prior to execution of 'py3.pkg2.bar'; this may result in unpredictable behaviour
diff --git a/Examples/python/import_packages/module_is_init/Makefile b/Examples/python/import_packages/module_is_init/Makefile
new file mode 100644
index 000000000..43763aa4b
--- /dev/null
+++ b/Examples/python/import_packages/module_is_init/Makefile
@@ -0,0 +1,15 @@
+TOP = ../../..
+LIBS =
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
+
+build:
+ cd pkg1 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build
+
+static:
+ cd pkg1 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
+ cd pkg1 && $(MAKE) clean
diff --git a/Examples/python/import_packages/module_is_init/README b/Examples/python/import_packages/module_is_init/README
new file mode 100644
index 000000000..ee7391cda
--- /dev/null
+++ b/Examples/python/import_packages/module_is_init/README
@@ -0,0 +1,18 @@
+This example tests renaming the generated SWIG pure Python module to __init__.py
+to turn the module into a Python package.
+
+Use 'python runme.py' to run the test.
+
+Overview:
+---------
+
+SWIG generates a pure Python module foo.py from the input interface file foo.i.
+The foo.py file is generated within the pkg1 directory and is then renamed __init__.py.
+This results in everything in the SWIG generated module being available in the Python
+pkg1 package.
+
+This approach of turning the SWIG generated module into a package worked in versions
+of SWIG up to swig-3.0.8, but stopped working from swig-3.0.9 until it was
+re-instated in swig-4.0.0. However, Python 2.7 or 3.3 and later are needed to
+work out of the box. Python 3.2 does not work as this version of Python does
+not set __package__ in __init__.py.
diff --git a/Examples/python/import_packages/module_is_init/pkg1/Makefile b/Examples/python/import_packages/module_is_init/pkg1/Makefile
new file mode 100644
index 000000000..d9d83ed0a
--- /dev/null
+++ b/Examples/python/import_packages/module_is_init/pkg1/Makefile
@@ -0,0 +1,20 @@
+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
+ mv foo.py __init__.py
+
+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
+ rm -f __init__.py
diff --git a/Examples/python/import_packages/module_is_init/pkg1/foo.hpp b/Examples/python/import_packages/module_is_init/pkg1/foo.hpp
new file mode 100644
index 000000000..01c462266
--- /dev/null
+++ b/Examples/python/import_packages/module_is_init/pkg1/foo.hpp
@@ -0,0 +1,10 @@
+
+int foofunction(int i) {
+ return i *= 10;
+}
+
+struct FooClass {
+ int foomethod(int i) {
+ return i += 5;
+ }
+};
diff --git a/Examples/python/import_packages/module_is_init/pkg1/foo.i b/Examples/python/import_packages/module_is_init/pkg1/foo.i
new file mode 100644
index 000000000..f8d71380c
--- /dev/null
+++ b/Examples/python/import_packages/module_is_init/pkg1/foo.i
@@ -0,0 +1,5 @@
+%module foo
+%{
+#include "./foo.hpp"
+%}
+%include "./foo.hpp"
diff --git a/Examples/python/import_packages/module_is_init/runme.py b/Examples/python/import_packages/module_is_init/runme.py
new file mode 100644
index 000000000..c4806cdf8
--- /dev/null
+++ b/Examples/python/import_packages/module_is_init/runme.py
@@ -0,0 +1,26 @@
+import os.path
+import sys
+
+# Test import of a SWIG generated module renamed as the package's __init__.py
+testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
+print("Testing " + testname + " - module renamed as __init__.py")
+
+if sys.version_info >= (3, 0, 0) and sys.version_info < (3, 3, 0):
+ print(" Not importing as Python version is >= 3.0 and < 3.3")
+ # Package detection does not work in these versions.
+ # Can be fixed by using this in the interface file:
+ # %module(moduleimport="from . import $module") foo # without -builtin
+ # %module(moduleimport="from .$module import *") foo # with -builtin
+ sys.exit(0)
+
+import pkg1
+print(" Finished importing pkg1")
+
+if pkg1.foofunction(123) != 1230:
+ raise RuntimeError("foofunction failed")
+
+fc = pkg1.FooClass()
+if fc.foomethod(1) != 6:
+ raise RuntimeError("foomethod failed")
+
+print(" Finished testing pkg1")
diff --git a/Examples/python/import_packages/namespace_pkg/nonpkg.py b/Examples/python/import_packages/namespace_pkg/nonpkg.py
index acf0aedbd..52be74db4 100644
--- a/Examples/python/import_packages/namespace_pkg/nonpkg.py
+++ b/Examples/python/import_packages/namespace_pkg/nonpkg.py
@@ -1,5 +1,22 @@
+import os
+import subprocess
+import sys
+
+def run_except_on_windows(commandline, env=None):
+ if os.name != "nt" and sys.platform != "cygwin":
+ # Strange failures on windows/cygin/mingw
+ subprocess.check_call(commandline, env=env, shell=True)
+ print(" Finished running: " + commandline)
+
+print(" Starting subtest " + os.path.basename(__file__))
+
# import robin as a module in the global namespace
import robin
+print(" Finished importing robin")
+
+if not(robin.run() == "AWAY!"):
+ raise RuntimeError("test failed")
-assert(robin.run() == "AWAY!")
+commandline = sys.executable + " -m robin"
+run_except_on_windows(commandline)
diff --git a/Examples/python/import_packages/namespace_pkg/normal.py b/Examples/python/import_packages/namespace_pkg/normal.py
index fc26c0216..0eb8f517c 100644
--- a/Examples/python/import_packages/namespace_pkg/normal.py
+++ b/Examples/python/import_packages/namespace_pkg/normal.py
@@ -1,7 +1,23 @@
+import os
+import subprocess
import sys
+
+def run_except_on_windows(commandline, env=None):
+ if os.name != "nt" and sys.platform != "cygwin":
+ # Strange failures on windows/cygin/mingw
+ subprocess.check_call(commandline, env=env, shell=True)
+ print(" Finished running: " + commandline)
+
+print(" Starting subtest " + os.path.basename(__file__))
+
# Package brave found under one path
-sys.path.insert(0, 'path1')
+sys.path.insert(0, "path1")
from brave import robin
+print(" Finished from brave import robin")
+
+if not(robin.run() == "AWAY!"):
+ raise RuntimeError("test failed")
-assert(robin.run() == "AWAY!")
+commandline = sys.executable + " -m brave.robin"
+run_except_on_windows(commandline, env = {"PYTHONPATH": "path1"})
diff --git a/Examples/python/import_packages/namespace_pkg/nstest.py b/Examples/python/import_packages/namespace_pkg/nstest.py
index 9b075ad8c..4d618a6ad 100644
--- a/Examples/python/import_packages/namespace_pkg/nstest.py
+++ b/Examples/python/import_packages/namespace_pkg/nstest.py
@@ -1,11 +1,17 @@
import sys
import os
import shutil
+import subprocess
import zipfile
+def run_except_on_windows(commandline, env=None):
+ if os.name != "nt" and sys.platform != "cygwin":
+ # Strange failures on windows/cygin/mingw
+ subprocess.check_call(commandline, env=env, shell=True)
+ print(" Finished running: " + commandline)
def copyMods():
- dirs = ['path1', 'path2', 'path3']
+ dirs = ["path1", "path2", "path3"]
# Clean out any old package paths
for d in dirs:
@@ -14,20 +20,20 @@ def copyMods():
for d in dirs:
os.mkdir(d)
- os.mkdir(os.path.join(d, 'brave'))
+ 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("path1", "brave"))
+ subprocess.check_call("cp _robin.* " + os.path.join("path1", "brave"), shell=True)
- shutil.copy('robin.py', os.path.join('path2', 'brave'))
- os.system('cp _robin.* ' + os.path.join('path3', 'brave'))
+ shutil.copy("robin.py", os.path.join("path2", "brave"))
+ subprocess.check_call("cp _robin.* " + os.path.join("path3", "brave"), shell=True)
mkzip()
def mkzip():
zf = zipfile.ZipFile("path4.zip", "w")
- zf.writestr("brave/", b'')
- zf.write('robin.py', 'brave/robin.py')
+ zf.writestr("brave/", b"")
+ zf.write("robin.py", "brave/robin.py")
zf.close()
@@ -35,10 +41,10 @@ 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")
+ run_except_on_windows(sys.executable + " nonpkg.py")
+ run_except_on_windows(sys.executable + " normal.py")
+ run_except_on_windows(sys.executable + " split.py")
+ run_except_on_windows(sys.executable + " zipsplit.py")
if __name__ == "__main__":
diff --git a/Examples/python/import_packages/namespace_pkg/runme.py b/Examples/python/import_packages/namespace_pkg/runme.py
index 9c22d36fb..54a8e4ee6 100644
--- a/Examples/python/import_packages/namespace_pkg/runme.py
+++ b/Examples/python/import_packages/namespace_pkg/runme.py
@@ -1,17 +1,18 @@
# These examples rely on namespace packages. Don't
# run them for old python interpreters.
-import sys
import os.path
+import subprocess
+import sys
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
-print "Testing " + testname + " - namespace packages"
+print("Testing " + testname + " - namespace packages")
if sys.version_info < (3, 3, 0):
- print " Not importing nstest as Python version is < 3.3"
+ print(" Not importing nstest as Python version is < 3.3")
sys.exit(0)
import nstest
-print " Finished importing 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
index 1b66c2d49..9d786dc07 100644
--- a/Examples/python/import_packages/namespace_pkg/split.py
+++ b/Examples/python/import_packages/namespace_pkg/split.py
@@ -1,9 +1,25 @@
+import os
+import subprocess
import sys
+
+def run_except_on_windows(commandline, env=None):
+ if os.name != "nt" and sys.platform != "cygwin":
+ # Strange failures on windows/cygin/mingw
+ subprocess.check_call(commandline, env=env, shell=True)
+ print(" Finished running: " + commandline)
+
+print(" Starting subtest " + os.path.basename(__file__))
+
# 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')
+sys.path.insert(0, "path2")
+sys.path.insert(0, "path3")
from brave import robin
+print(" Finished from brave import robin")
+
+if not(robin.run() == "AWAY!"):
+ raise RuntimeError("test failed")
-assert(robin.run() == "AWAY!")
+commandline = sys.executable + " -m brave.robin"
+run_except_on_windows(commandline , env = {"PYTHONPATH": "path2:path3"})
diff --git a/Examples/python/import_packages/namespace_pkg/zipsplit.py b/Examples/python/import_packages/namespace_pkg/zipsplit.py
index 9e35559e3..30434f9c0 100644
--- a/Examples/python/import_packages/namespace_pkg/zipsplit.py
+++ b/Examples/python/import_packages/namespace_pkg/zipsplit.py
@@ -1,9 +1,25 @@
+import os
+import subprocess
import sys
+
+def run_except_on_windows(commandline, env=None):
+ if os.name != "nt" and sys.platform != "cygwin":
+ # Strange failures on windows/cygin/mingw
+ subprocess.check_call(commandline, env=env, shell=True)
+ print(" Finished running: " + commandline)
+
+print(" Starting subtest " + os.path.basename(__file__))
+
# 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')
+sys.path.insert(0, "path4.zip")
+sys.path.insert(0, "path3")
from brave import robin
+print(" Finished from brave import robin")
+
+if not(robin.run() == "AWAY!"):
+ raise RuntimeError("test failed")
-assert(robin.run() == "AWAY!")
+commandline = sys.executable + " -m brave.robin"
+run_except_on_windows(commandline, env = {"PYTHONPATH": "path3:path4.zip"})
diff --git a/Examples/python/import_packages/relativeimport1/runme.py b/Examples/python/import_packages/relativeimport1/runme.py
index 997476b1d..3073cb5a7 100644
--- a/Examples/python/import_packages/relativeimport1/runme.py
+++ b/Examples/python/import_packages/relativeimport1/runme.py
@@ -1,13 +1,32 @@
-import sys
import os.path
+import subprocess
+import sys
+
+def run_except_on_windows(commandline, env=None):
+ if os.name != "nt" and sys.platform != "cygwin":
+ # Strange failures on windows/cygin/mingw
+ subprocess.check_call(commandline, env=env, shell=True)
+ print((" Finished running: " + commandline))
# Test import of modules content from within __init__.py
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
-print "Testing " + testname + " - %module(package=...) with -relativeimport"
+print("Testing " + testname + " - %module(package=...) with -relativeimport")
+
+if sys.version_info < (2, 5):
+ print(" Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'")
+ sys.exit(0)
if sys.version_info < (3, 0):
import py2.pkg2.bar
- print " Finished importing py2.pkg2.bar"
+ print(" Finished importing py2.pkg2.bar")
+ commandline = sys.executable + " -m py2.pkg2.bar"
+ run_except_on_windows(commandline)
+ commandline = sys.executable + " -m py2.pkg2.pkg3.foo"
+ run_except_on_windows(commandline)
else:
import py3.pkg2.bar
- print " Finished importing py3.pkg2.bar"
+ print(" Finished importing py3.pkg2.bar")
+ commandline = sys.executable + " -m py3.pkg2.bar"
+ run_except_on_windows(commandline)
+ commandline = sys.executable + " -m py3.pkg2.pkg3.foo"
+ run_except_on_windows(commandline)
diff --git a/Examples/python/import_packages/relativeimport2/runme.py b/Examples/python/import_packages/relativeimport2/runme.py
index 9789afc18..9ab8d9471 100644
--- a/Examples/python/import_packages/relativeimport2/runme.py
+++ b/Examples/python/import_packages/relativeimport2/runme.py
@@ -1,13 +1,32 @@
-import sys
import os.path
+import subprocess
+import sys
+
+def run_except_on_windows(commandline, env=None):
+ if os.name != "nt" and sys.platform != "cygwin":
+ # Strange failures on windows/cygin/mingw
+ subprocess.check_call(commandline, env=env, shell=True)
+ print((" Finished running: " + commandline))
# Test import of modules content from within __init__.py
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
-print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
+print("Testing " + testname + " - %module(package=...) + python 'import' in __init__.py")
+
+if sys.version_info < (2, 5):
+ print(" Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'")
+ sys.exit(0)
if sys.version_info < (3, 0):
import py2.pkg2.bar
- print " Finished importing py2.pkg2.bar"
+ print(" Finished importing py2.pkg2.bar")
+ commandline = sys.executable + " -m py2.pkg2.bar"
+ run_except_on_windows(commandline)
+ commandline = sys.executable + " -m py2.pkg2.pkg3.pkg4.foo"
+ run_except_on_windows(commandline)
else:
import py3.pkg2.bar
- print " Finished importing py3.pkg2.bar"
+ print(" Finished importing py3.pkg2.bar")
+ commandline = sys.executable + " -m py3.pkg2.bar"
+ run_except_on_windows(commandline)
+ commandline = sys.executable + " -m py3.pkg2.pkg3.pkg4.foo"
+ run_except_on_windows(commandline)
diff --git a/Examples/python/import_packages/relativeimport3/runme.py b/Examples/python/import_packages/relativeimport3/runme.py
index 997476b1d..3073cb5a7 100644
--- a/Examples/python/import_packages/relativeimport3/runme.py
+++ b/Examples/python/import_packages/relativeimport3/runme.py
@@ -1,13 +1,32 @@
-import sys
import os.path
+import subprocess
+import sys
+
+def run_except_on_windows(commandline, env=None):
+ if os.name != "nt" and sys.platform != "cygwin":
+ # Strange failures on windows/cygin/mingw
+ subprocess.check_call(commandline, env=env, shell=True)
+ print((" Finished running: " + commandline))
# Test import of modules content from within __init__.py
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
-print "Testing " + testname + " - %module(package=...) with -relativeimport"
+print("Testing " + testname + " - %module(package=...) with -relativeimport")
+
+if sys.version_info < (2, 5):
+ print(" Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'")
+ sys.exit(0)
if sys.version_info < (3, 0):
import py2.pkg2.bar
- print " Finished importing py2.pkg2.bar"
+ print(" Finished importing py2.pkg2.bar")
+ commandline = sys.executable + " -m py2.pkg2.bar"
+ run_except_on_windows(commandline)
+ commandline = sys.executable + " -m py2.pkg2.pkg3.foo"
+ run_except_on_windows(commandline)
else:
import py3.pkg2.bar
- print " Finished importing py3.pkg2.bar"
+ print(" Finished importing py3.pkg2.bar")
+ commandline = sys.executable + " -m py3.pkg2.bar"
+ run_except_on_windows(commandline)
+ commandline = sys.executable + " -m py3.pkg2.pkg3.foo"
+ run_except_on_windows(commandline)
diff --git a/Examples/python/import_packages/same_modnames1/runme.py b/Examples/python/import_packages/same_modnames1/runme.py
index 3c3c00c1a..05846ed9d 100644
--- a/Examples/python/import_packages/same_modnames1/runme.py
+++ b/Examples/python/import_packages/same_modnames1/runme.py
@@ -1,19 +1,26 @@
import os.path
+import subprocess
+import sys
+
+def run_except_on_windows(commandline, env=None):
+ if os.name != "nt" and sys.platform != "cygwin":
+ # Strange failures on windows/cygin/mingw
+ subprocess.check_call(commandline, env=env, shell=True)
+ print((" Finished running: " + commandline))
# Test import of same modules from different packages
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
-print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
+print("Testing " + testname + " - %module(package=...) + python 'import' in __init__.py")
import pkg2.foo
-print " Finished importing pkg2.foo"
+print(" Finished importing pkg2.foo")
var2 = pkg2.foo.Pkg2_Foo()
classname = str(type(var2))
-# Check for an old-style class if swig was run in -classic mode
-if classname == "<type 'instance'>":
- classname = str(var2.__class__)
-
if classname.find("pkg2.foo.Pkg2_Foo") == -1:
raise RuntimeError("failed type checking: " + classname)
-print " Successfully created object pkg2.foo.Pkg2_Foo"
+print(" Successfully created object pkg2.foo.Pkg2_Foo")
+
+commandline = sys.executable + " -m pkg2.foo"
+run_except_on_windows(commandline)
diff --git a/Examples/python/import_packages/same_modnames2/runme.py b/Examples/python/import_packages/same_modnames2/runme.py
index 38daad0a3..190dadc77 100644
--- a/Examples/python/import_packages/same_modnames2/runme.py
+++ b/Examples/python/import_packages/same_modnames2/runme.py
@@ -1,18 +1,25 @@
import os.path
+import subprocess
+import sys
+
+def run_except_on_windows(commandline, env=None):
+ if os.name != "nt" and sys.platform != "cygwin":
+ # Strange failures on windows/cygin/mingw
+ subprocess.check_call(commandline, env=env, shell=True)
+ print((" Finished running: " + commandline))
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
-print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
+print("Testing " + testname + " - %module(package=...) + python 'import' in __init__.py")
import pkg1.pkg2.foo
-print " Finished importing pkg1.pkg2.foo"
+print(" Finished importing pkg1.pkg2.foo")
var2 = pkg1.pkg2.foo.Pkg2_Foo()
classname = str(type(var2))
-# Check for an old-style class if swig was run in -classic mode
-if classname == "<type 'instance'>":
- classname = str(var2.__class__)
-
if classname.find("pkg1.pkg2.foo.Pkg2_Foo") == -1:
raise RuntimeError("failed type checking: " + classname)
-print " Successfully created object pkg1.pkg2.foo.Pkg2_Foo"
+print(" Successfully created object pkg1.pkg2.foo.Pkg2_Foo")
+
+commandline = sys.executable + " -m pkg1.pkg2.foo"
+run_except_on_windows(commandline)
diff --git a/Examples/python/import_packages/split_modules/Makefile b/Examples/python/import_packages/split_modules/Makefile
index 65d635bb7..9eaaabd32 100644
--- a/Examples/python/import_packages/split_modules/Makefile
+++ b/Examples/python/import_packages/split_modules/Makefile
@@ -6,21 +6,21 @@ subdirs = vanilla vanilla_split
check: build
for s in $(subdirs); do \
- (cd $$s && $(MAKE) check); \
+ (cd $$s && $(MAKE) check) || exit 1; \
done
build:
for s in $(subdirs); do \
- (cd $$s && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build); \
+ (cd $$s && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build) || exit 1; \
done
static:
for s in $(subdirs); do \
- (cd $$s && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static); \
+ (cd $$s && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static) || exit 1; \
done
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
for s in $(subdirs); do \
- (cd $$s && $(MAKE) clean); \
+ (cd $$s && $(MAKE) clean) || exit 1; \
done
diff --git a/Examples/python/import_packages/split_modules/README b/Examples/python/import_packages/split_modules/README
index 0cb543e8a..d2ca15e7a 100644
--- a/Examples/python/import_packages/split_modules/README
+++ b/Examples/python/import_packages/split_modules/README
@@ -2,6 +2,9 @@
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.
+From SWIG 4.0.0 onwards, split modules are not supported by default.
+The %module directive needs to be customised with the moduleimport attribute
+in order to import the a global C/C++ module.
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/runme.py b/Examples/python/import_packages/split_modules/vanilla/runme.py
index a188364f1..0f7b8806b 100644
--- a/Examples/python/import_packages/split_modules/vanilla/runme.py
+++ b/Examples/python/import_packages/split_modules/vanilla/runme.py
@@ -1,10 +1,22 @@
import os.path
+import subprocess
+import sys
+
+def run_except_on_windows(commandline, env=None):
+ if os.name != "nt" and sys.platform != "cygwin":
+ # Strange failures on windows/cygin/mingw
+ subprocess.check_call(commandline, env=env, shell=True)
+ print((" Finished running: " + commandline))
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
-print "Testing " + testname + " - split modules"
+print("Testing " + testname + " - split modules")
import pkg1.foo
-print " Finished importing pkg1.foo"
+print(" Finished importing pkg1.foo")
+
+if not(pkg1.foo.count() == 3):
+ raise RuntimeError("test failed")
-assert(pkg1.foo.count() == 3)
+commandline = sys.executable + " -m pkg1.foo"
+run_except_on_windows(commandline)
diff --git a/Examples/python/import_packages/split_modules/vanilla_split/Makefile b/Examples/python/import_packages/split_modules/vanilla_split/Makefile
index c322b5aec..5d1c3521c 100644
--- a/Examples/python/import_packages/split_modules/vanilla_split/Makefile
+++ b/Examples/python/import_packages/split_modules/vanilla_split/Makefile
@@ -19,4 +19,6 @@ static:
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean
- cd pkg1 && $(MAKE) -f $(TOP)/../Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean
+ if test -d pkg1; then \
+ cd pkg1 && $(MAKE) -f $(TOP)/../Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean; \
+ fi
diff --git a/Examples/python/import_packages/split_modules/vanilla_split/foo.i b/Examples/python/import_packages/split_modules/vanilla_split/foo.i
index 60ce16ec3..81ad43a5b 100644
--- a/Examples/python/import_packages/split_modules/vanilla_split/foo.i
+++ b/Examples/python/import_packages/split_modules/vanilla_split/foo.i
@@ -1,4 +1,9 @@
-%module(package="pkg1") foo
+#if defined(SWIGPYTHON_BUILTIN) /* defined when using -builtin */
+%module(package="pkg1", moduleimport="from $module import *") foo
+#else
+%module(package="pkg1", moduleimport="import $module") foo
+#endif
+
%{
static unsigned count(void)
{
diff --git a/Examples/python/import_packages/split_modules/vanilla_split/runme.py b/Examples/python/import_packages/split_modules/vanilla_split/runme.py
index a188364f1..0f7b8806b 100644
--- a/Examples/python/import_packages/split_modules/vanilla_split/runme.py
+++ b/Examples/python/import_packages/split_modules/vanilla_split/runme.py
@@ -1,10 +1,22 @@
import os.path
+import subprocess
+import sys
+
+def run_except_on_windows(commandline, env=None):
+ if os.name != "nt" and sys.platform != "cygwin":
+ # Strange failures on windows/cygin/mingw
+ subprocess.check_call(commandline, env=env, shell=True)
+ print((" Finished running: " + commandline))
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
-print "Testing " + testname + " - split modules"
+print("Testing " + testname + " - split modules")
import pkg1.foo
-print " Finished importing pkg1.foo"
+print(" Finished importing pkg1.foo")
+
+if not(pkg1.foo.count() == 3):
+ raise RuntimeError("test failed")
-assert(pkg1.foo.count() == 3)
+commandline = sys.executable + " -m pkg1.foo"
+run_except_on_windows(commandline)
diff --git a/Examples/python/import_template/runme.py b/Examples/python/import_template/runme.py
index 35f8924c1..b14f8d35e 100644
--- a/Examples/python/import_template/runme.py
+++ b/Examples/python/import_template/runme.py
@@ -1,15 +1,22 @@
# file: runme.py
# Test various properties of classes defined in separate modules
+import sys
+
+print("Testing the %import directive with templates")
-print "Testing the %import directive with templates"
import base
import foo
import bar
import spam
+def write_flush(s):
+ # Python 2/3 compatible write and flush
+ sys.stdout.write(s)
+ sys.stdout.flush()
+
# Create some objects
-print "Creating some objects"
+print("Creating some objects")
a = base.intBase()
b = foo.intFoo()
@@ -17,91 +24,74 @@ c = bar.intBar()
d = spam.intSpam()
# Try calling some methods
-print "Testing some methods"
-print "",
-print "Should see 'Base::A' ---> ",
+print("Testing some methods")
+
+write_flush(" Should see 'Base::A' ---> ")
a.A()
-print "Should see 'Base::B' ---> ",
+write_flush(" Should see 'Base::B' ---> ")
a.B()
-print "Should see 'Foo::A' ---> ",
+write_flush(" Should see 'Foo::A' ---> ")
b.A()
-print "Should see 'Foo::B' ---> ",
+write_flush(" Should see 'Foo::B' ---> ")
b.B()
-print "Should see 'Bar::A' ---> ",
+write_flush(" Should see 'Bar::A' ---> ")
c.A()
-print "Should see 'Bar::B' ---> ",
+write_flush(" Should see 'Bar::B' ---> ")
c.B()
-print "Should see 'Spam::A' ---> ",
+write_flush(" Should see 'Spam::A' ---> ")
d.A()
-print "Should see 'Spam::B' ---> ",
+write_flush(" Should see 'Spam::B' ---> ")
d.B()
# Try some casts
-print "\nTesting some casts\n"
-print "",
+print("\nTesting some casts\n")
x = a.toBase()
-print "Should see 'Base::A' ---> ",
+write_flush(" Should see 'Base::A' ---> ")
x.A()
-print "Should see 'Base::B' ---> ",
+write_flush(" Should see 'Base::B' ---> ")
x.B()
x = b.toBase()
-print "Should see 'Foo::A' ---> ",
+write_flush(" Should see 'Foo::A' ---> ")
x.A()
-print "Should see 'Base::B' ---> ",
+write_flush(" Should see 'Base::B' ---> ")
x.B()
x = c.toBase()
-print "Should see 'Bar::A' ---> ",
+write_flush(" Should see 'Bar::A' ---> ")
x.A()
-print "Should see 'Base::B' ---> ",
+write_flush(" Should see 'Base::B' ---> ")
x.B()
x = d.toBase()
-print "Should see 'Spam::A' ---> ",
+write_flush(" Should see 'Spam::A' ---> ")
x.A()
-print "Should see 'Base::B' ---> ",
+write_flush(" Should see 'Base::B' ---> ")
x.B()
x = d.toBar()
-print "Should see 'Bar::B' ---> ",
+write_flush(" Should see 'Bar::B' ---> ")
x.B()
-print "\nTesting some dynamic casts\n"
+print("\nTesting some dynamic casts\n")
x = d.toBase()
-print " Spam -> Base -> Foo : ",
y = foo.intFoo_fromBase(x)
-if y:
- print "bad swig"
-else:
- print "good swig"
+print(" Spam -> Base -> Foo : {} swig".format("bad" if y else "good"))
-print " Spam -> Base -> Bar : ",
y = bar.intBar_fromBase(x)
-if y:
- print "good swig"
-else:
- print "bad swig"
+print(" Spam -> Base -> Bar : {} swig".format("good" if y else "bad"))
-print " Spam -> Base -> Spam : ",
y = spam.intSpam_fromBase(x)
-if y:
- print "good swig"
-else:
- print "bad swig"
+print(" Spam -> Base -> Spam : {} swig".format("good" if y else "bad"))
-print " Foo -> Spam : ",
y = spam.intSpam_fromBase(b)
-if y:
- print "bad swig"
-else:
- print "good swig"
+print(" Foo -> Spam : {} swig".format("bad" if y else "good"))
diff --git a/Examples/python/index.html b/Examples/python/index.html
index 3bbdd66e8..750c0f04a 100644
--- a/Examples/python/index.html
+++ b/Examples/python/index.html
@@ -89,7 +89,6 @@ to look at the <a href="http://www.python.org/sigs/distutils-sig/">distutils</a>
<h2>Compatibility</h2>
For Python 3, set the environment variable <tt>PY3=1</tt>.
-This will ensure the 2to3 program is run prior to running any example.
<p>
Your mileage may vary. If you experience a problem, please let us know by
diff --git a/Examples/python/java/Example.java b/Examples/python/java/Example.java
deleted file mode 100644
index 91ddb1ac5..000000000
--- a/Examples/python/java/Example.java
+++ /dev/null
@@ -1,29 +0,0 @@
-public class Example {
- public int mPublicInt;
-
- public Example() {
- mPublicInt = 0;
- }
-
- public Example(int IntVal) {
- mPublicInt = IntVal;
- }
-
-
- public int Add(int a, int b) {
- return (a+b);
- }
-
- public float Add(float a, float b) {
- return (a+b);
- }
-
- public String Add(String a, String b) {
- return (a+b);
- }
-
- public Example Add(Example a, Example b) {
- return new Example(a.mPublicInt + b.mPublicInt);
- }
-}
-
diff --git a/Examples/python/java/Makefile b/Examples/python/java/Makefile
deleted file mode 100644
index 7c75e6b91..000000000
--- a/Examples/python/java/Makefile
+++ /dev/null
@@ -1,25 +0,0 @@
-TOP = ../..
-SWIGEXE = $(TOP)/../swig
-SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
-CXXSRCS =
-TARGET = example
-INTERFACE = example.i
-LIBS = -lm
-
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
-
-build: Example.class Example.h
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
- SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- CXXSHARED="gcj -fpic -shared Example.class" DEFS='' LIBS="-lstdc++" python_cpp
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
- rm -f $(TARGET).py
- rm -f *.class Example.h
-
-Example.class Example.h: $(SRCDIR)Example.java
- gcj -d . -fPIC -C -c -g $(SRCDIR)Example.java
- gcjh Example.class
diff --git a/Examples/python/java/example.i b/Examples/python/java/example.i
deleted file mode 100644
index 80e08870f..000000000
--- a/Examples/python/java/example.i
+++ /dev/null
@@ -1,13 +0,0 @@
-%module example
-%include <cni.i>
-
-%{
-#include "Example.h"
-%}
-
-
-%include Example.h
-
-%extend Example {
- ~Example() {}
-}
diff --git a/Examples/python/java/runme.py b/Examples/python/java/runme.py
deleted file mode 100644
index 641ba27dd..000000000
--- a/Examples/python/java/runme.py
+++ /dev/null
@@ -1,16 +0,0 @@
-from example import *
-
-JvCreateJavaVM(None)
-JvAttachCurrentThread(None, None)
-
-e1 = Example(1)
-e2 = Example(2)
-
-print e1.Add(1, 2)
-print e1.Add(1.0, 2.0)
-e3 = e1.Add(e1, e2)
-print e3.mPublicInt
-
-print e1.Add("1", "2")
-
-JvDetachCurrentThread()
diff --git a/Examples/python/multimap/example.i b/Examples/python/multimap/example.i
index 66c0f74c6..3ff5d52c0 100644
--- a/Examples/python/multimap/example.i
+++ b/Examples/python/multimap/example.i
@@ -39,7 +39,11 @@ extern int gcd(int x, int y);
%#if PY_VERSION_HEX >= 0x03000000
{
PyObject *utf8str = PyUnicode_AsUTF8String(s);
- const char *cstr = PyBytes_AsString(utf8str);
+ const char *cstr;
+ if (!utf8str) {
+ SWIG_fail;
+ }
+ cstr = PyBytes_AsString(utf8str);
$2[i] = strdup(cstr);
Py_DECREF(utf8str);
}
@@ -72,6 +76,9 @@ extern int gcdmain(int argc, char *argv[]);
SWIG_fail;
}
utf8str = PyUnicode_AsUTF8String($input);
+ if (!utf8str) {
+ SWIG_fail;
+ }
PyBytes_AsStringAndSize(utf8str, &cstr, &len);
$1 = strncpy((char *)malloc(len+1), cstr, (size_t)len);
$2 = (int)len;
@@ -105,6 +112,9 @@ extern int count(char *bytes, int len, char c);
char *cstr;
Py_ssize_t len;
PyObject *utf8str = PyUnicode_AsUTF8String($input);
+ if (!utf8str) {
+ SWIG_fail;
+ }
PyBytes_AsStringAndSize(utf8str, &cstr, &len);
$1 = strncpy((char *)malloc(len+1), cstr, (size_t)len);
$2 = (int)len;
diff --git a/Examples/python/multimap/runme.py b/Examples/python/multimap/runme.py
index ad693b73a..e24f54ee1 100644
--- a/Examples/python/multimap/runme.py
+++ b/Examples/python/multimap/runme.py
@@ -7,14 +7,14 @@ import example
x = 42
y = 105
g = example.gcd(x, y)
-print "The gcd of %d and %d is %d" % (x, y, g)
+print("The gcd of %d and %d is %d" % (x, y, g))
# Call the gcdmain() function
example.gcdmain(["gcdmain", "42", "105"])
# Call the count function
-print example.count("Hello World", "l")
+print(example.count("Hello World", "l"))
# Call the capitalize function
-print example.capitalize("hello world")
+print(example.capitalize("hello world"))
diff --git a/Examples/python/operator/example.i b/Examples/python/operator/example.i
index e37e76b3e..1e4b7ce34 100644
--- a/Examples/python/operator/example.i
+++ b/Examples/python/operator/example.i
@@ -17,6 +17,7 @@
%include "example.h"
/* An output method that turns a complex into a short string */
+%feature("python:slot", "tp_str", functype="reprfunc") Complex::__str__; // For -builtin option to use __str__ in the tp_str slot
%extend Complex {
char *__str__() {
static char temp[512];
diff --git a/Examples/python/operator/runme.py b/Examples/python/operator/runme.py
index ac48f2676..ee479f0b5 100644
--- a/Examples/python/operator/runme.py
+++ b/Examples/python/operator/runme.py
@@ -4,17 +4,17 @@ import example
a = example.Complex(2, 3)
b = example.Complex(-5, 10)
-print "a =", a
-print "b =", b
+print("a = %s" % a)
+print("b = %s" % b)
c = a + b
-print "c =", c
-print "a*b =", a * b
-print "a-c =", a - c
+print("c = %s" % c)
+print("a*b = %s" % (a * b))
+print("a-c = %s" % (a - c))
e = example.ComplexCopy(a - c)
-print "e =", e
+print("e = %s" % e)
# Big expression
f = ((a + b) * (c + b * e)) + (-a)
-print "f =", f
+print("f = %s" % f)
diff --git a/Examples/python/performance/constructor/runme.py b/Examples/python/performance/constructor/runme.py
index 1771fba7b..b00cd456c 100644
--- a/Examples/python/performance/constructor/runme.py
+++ b/Examples/python/performance/constructor/runme.py
@@ -1,5 +1,5 @@
import sys
-sys.path.append('..')
+sys.path.append("..")
import harness
diff --git a/Examples/python/performance/func/runme.py b/Examples/python/performance/func/runme.py
index 760a8ab6d..3b142791c 100644
--- a/Examples/python/performance/func/runme.py
+++ b/Examples/python/performance/func/runme.py
@@ -1,5 +1,5 @@
import sys
-sys.path.append('..')
+sys.path.append("..")
import harness
diff --git a/Examples/python/performance/harness.py b/Examples/python/performance/harness.py
index c3d38b4fb..3468faaad 100644
--- a/Examples/python/performance/harness.py
+++ b/Examples/python/performance/harness.py
@@ -17,16 +17,16 @@ def run(proc):
except IndexError:
proc = Popen(
- [sys.executable, 'runme.py', 'Simple_baseline'], stdout=PIPE)
+ [sys.executable, "runme.py", "Simple_baseline"], stdout=PIPE)
(stdout, stderr) = proc.communicate()
print stdout
proc = Popen(
- [sys.executable, 'runme.py', 'Simple_optimized'], stdout=PIPE)
+ [sys.executable, "runme.py", "Simple_optimized"], stdout=PIPE)
(stdout, stderr) = proc.communicate()
print stdout
proc = Popen(
- [sys.executable, 'runme.py', 'Simple_builtin'], stdout=PIPE)
+ [sys.executable, "runme.py", "Simple_builtin"], stdout=PIPE)
(stdout, stderr) = proc.communicate()
print stdout
diff --git a/Examples/python/performance/hierarchy/runme.py b/Examples/python/performance/hierarchy/runme.py
index 8255cdc86..389958284 100644
--- a/Examples/python/performance/hierarchy/runme.py
+++ b/Examples/python/performance/hierarchy/runme.py
@@ -1,5 +1,5 @@
import sys
-sys.path.append('..')
+sys.path.append("..")
import harness
diff --git a/Examples/python/performance/hierarchy_operator/runme.py b/Examples/python/performance/hierarchy_operator/runme.py
index eabfae864..48241d48b 100644
--- a/Examples/python/performance/hierarchy_operator/runme.py
+++ b/Examples/python/performance/hierarchy_operator/runme.py
@@ -1,5 +1,5 @@
import sys
-sys.path.append('..')
+sys.path.append("..")
import harness
diff --git a/Examples/python/performance/operator/runme.py b/Examples/python/performance/operator/runme.py
index d75ae404c..798dd8bf9 100644
--- a/Examples/python/performance/operator/runme.py
+++ b/Examples/python/performance/operator/runme.py
@@ -1,5 +1,5 @@
import sys
-sys.path.append('..')
+sys.path.append("..")
import harness
diff --git a/Examples/python/pointer/runme.py b/Examples/python/pointer/runme.py
index 5b5f16bc2..46371b89a 100644
--- a/Examples/python/pointer/runme.py
+++ b/Examples/python/pointer/runme.py
@@ -3,23 +3,23 @@
import example
# First create some objects using the pointer library.
-print "Testing the pointer library"
+print("Testing the pointer library")
a = example.new_intp()
b = example.new_intp()
c = example.new_intp()
example.intp_assign(a, 37)
example.intp_assign(b, 42)
-print " a =", a
-print " b =", b
-print " c =", c
+print(" a = %s" % a)
+print(" b = %s" % b)
+print(" c = %s" % c)
# Call the add() function with some pointers
example.add(a, b, c)
# Now get the result
r = example.intp_value(c)
-print " 37 + 42 =", r
+print(" 37 + 42 = %s" % r)
# Clean up the pointers
example.delete_intp(a)
@@ -30,12 +30,12 @@ example.delete_intp(c)
# This should be much easier. Now how it is no longer
# necessary to manufacture pointers.
-print "Trying the typemap library"
+print("Trying the typemap library")
r = example.sub(37, 42)
-print " 37 - 42 =", r
+print(" 37 - 42 = %s" % r)
# Now try the version with multiple return values
-print "Testing multiple return values"
+print("Testing multiple return values")
q, r = example.divide(42, 37)
-print " 42/37 = %d remainder %d" % (q, r)
+print(" 42/37 = %d remainder %d" % (q, r))
diff --git a/Examples/python/reference/runme.py b/Examples/python/reference/runme.py
index 0ff217b02..8a96e03a7 100644
--- a/Examples/python/reference/runme.py
+++ b/Examples/python/reference/runme.py
@@ -6,12 +6,12 @@ import example
# ----- Object creation -----
-print "Creating some objects:"
+print("Creating some objects:")
a = example.Vector(3, 4, 5)
b = example.Vector(10, 11, 12)
-print " Created", a.cprint()
-print " Created", b.cprint()
+print(" Created %s" % a.cprint())
+print(" Created %s" % b.cprint())
# ----- Call an overloaded operator -----
@@ -21,9 +21,9 @@ print " Created", b.cprint()
#
# It returns a new allocated object.
-print "Adding a+b"
+print("Adding a+b")
c = example.addv(a, b)
-print " a+b =", c.cprint()
+print(" a+b = %s" % c.cprint())
# Note: Unless we free the result, a memory leak will occur
del c
@@ -31,9 +31,9 @@ del c
# ----- Create a vector array -----
# Note: Using the high-level interface here
-print "Creating an array of vectors"
+print("Creating an array of vectors")
va = example.VectorArray(10)
-print " va = ", va
+print(" va = %s" % va)
# ----- Set some values in the array -----
@@ -45,17 +45,17 @@ va.set(2, example.addv(a, b))
# Get some values from the array
-print "Getting some array values"
+print("Getting some array values")
for i in range(0, 5):
- print " va(%d) = %s" % (i, va.get(i).cprint())
+ print(" va(%d) = %s" % (i, va.get(i).cprint()))
# Watch under resource meter to check on this
-print "Making sure we don't leak memory."
-for i in xrange(0, 1000000):
+print("Making sure we don't leak memory.")
+for i in range(0, 1000000):
c = va.get(i % 10)
# ----- Clean up -----
-print "Cleaning up"
+print("Cleaning up")
del va
del a
diff --git a/Examples/python/simple/runme.py b/Examples/python/simple/runme.py
index ce01e5a1d..ec0aceb45 100644
--- a/Examples/python/simple/runme.py
+++ b/Examples/python/simple/runme.py
@@ -7,15 +7,15 @@ import example
x = 42
y = 105
g = example.gcd(x, y)
-print "The gcd of %d and %d is %d" % (x, y, g)
+print("The gcd of %d and %d is %d" % (x, y, g))
# Manipulate the Foo global variable
# Output its current value
-print "Foo = ", example.cvar.Foo
+print("Foo = %s" % example.cvar.Foo)
# Change its value
example.cvar.Foo = 3.1415926
# See if the change took effect
-print "Foo = ", example.cvar.Foo
+print("Foo = %s" % example.cvar.Foo)
diff --git a/Examples/python/smartptr/runme.py b/Examples/python/smartptr/runme.py
index 5f8b73476..f01636ad6 100644
--- a/Examples/python/smartptr/runme.py
+++ b/Examples/python/smartptr/runme.py
@@ -7,17 +7,17 @@ import example
# ----- Object creation -----
-print "Creating some objects:"
+print("Creating some objects:")
cc = example.Circle(10)
c = example.ShapePtr(cc)
-print " Created circle", c
+print(" Created circle %s" % c)
ss = example.Square(10)
s = example.ShapePtr(ss)
-print " Created square", s
+print(" Created square %s" % s)
# ----- Access a static member -----
-print "\nA total of", example.cvar.Shape_nshapes, "shapes were created"
+print("\nA total of %s shapes were created" % example.cvar.Shape_nshapes)
# ----- Member data access -----
@@ -29,19 +29,19 @@ c.y = 30
s.x = -10
s.y = 5
-print "\nHere is their current position:"
-print " Circle = (%f, %f)" % (c.x, c.y)
-print " Square = (%f, %f)" % (s.x, s.y)
+print("\nHere is their current position:")
+print(" Circle = (%f, %f)" % (c.x, c.y))
+print(" Square = (%f, %f)" % (s.x, s.y))
# ----- Call some methods -----
-print "\nHere are some properties of the shapes:"
+print("\nHere are some properties of the shapes:")
for o in [c, s]:
- print " ", o
- print " area = ", o.area()
- print " perimeter = ", o.perimeter()
+ print(" %s" % o)
+ print(" area = %s" % o.area())
+ print(" perimeter = %s" % o.perimeter())
-print "\nGuess I'll clean up now"
+print("\nGuess I'll clean up now")
# Note: this invokes the virtual destructor
del c
@@ -50,5 +50,5 @@ del cc
del ss
s = 3
-print example.cvar.Shape_nshapes, "shapes remain"
-print "Goodbye"
+print("%d shapes remain" % example.cvar.Shape_nshapes)
+print("Goodbye")
diff --git a/Examples/python/std_map/runme.py b/Examples/python/std_map/runme.py
index 26031f3f4..e86f613fa 100644
--- a/Examples/python/std_map/runme.py
+++ b/Examples/python/std_map/runme.py
@@ -11,45 +11,45 @@ dmap = {}
dmap["hello"] = 1.0
dmap["hi"] = 2.0
-print dmap.items()
-print dmap.keys()
-print dmap.values()
+print(list(dmap.items()))
+print(list(dmap.keys()))
+print(list(dmap.values()))
-print dmap
+print(dmap)
hmap = example.halfd(dmap)
dmap = hmap
-print dmap
-for i in dmap.iterkeys():
- print "key", i
+print(dmap)
+for i in dmap.keys():
+ print("key %s" % i)
-for i in dmap.itervalues():
- print "val", i
+for i in dmap.values():
+ print("val %s" % i)
-for k, v in dmap.iteritems():
- print "item", k, v
+for k, v in dmap.items():
+ print("item %s %s" % (k, v))
dmap = example.DoubleMap()
dmap["hello"] = 1.0
dmap["hi"] = 2.0
-for i in dmap.iterkeys():
- print "key", i
+for i in dmap.keys():
+ print("key %s" % i)
-for i in dmap.itervalues():
- print "val", i
+for i in dmap.values():
+ print("val %s" % i)
-for k, v in dmap.iteritems():
- print "item", k, v
+for k, v in dmap.items():
+ print("item %s %s" % (k, v))
-print dmap.items()
-print dmap.keys()
-print dmap.values()
+print(list(dmap.items()))
+print(list(dmap.keys()))
+print(list(dmap.values()))
hmap = example.halfd(dmap)
-print hmap.keys()
-print hmap.values()
+print(list(hmap.keys()))
+print(list(hmap.values()))
dmap = {}
@@ -57,23 +57,23 @@ dmap["hello"] = 2
dmap["hi"] = 4
hmap = example.halfi(dmap)
-print hmap
-print hmap.keys()
-print hmap.values()
+print(hmap)
+print(list(hmap.keys()))
+print(list(hmap.values()))
dmap = hmap
-for i in dmap.iterkeys():
- print "key", i
+for i in dmap.keys():
+ print("key %s" % i)
-for i in dmap.itervalues():
- print "val", i
+for i in dmap.values():
+ print("val %s" % i)
-for i in dmap.iteritems():
- print "item", i
+for i in dmap.items():
+ print("item %s" % str(i))
-for k, v in dmap.iteritems():
- print "item", k, v
+for k, v in dmap.items():
+ print("item %s %s" % (k, v))
-print dmap
+print(dmap)
diff --git a/Examples/python/std_vector/example.h b/Examples/python/std_vector/example.h
index 4f0dac70d..52e260d6d 100644
--- a/Examples/python/std_vector/example.h
+++ b/Examples/python/std_vector/example.h
@@ -17,9 +17,8 @@ std::vector<double> half(const std::vector<double>& v) {
}
void halve_in_place(std::vector<double>& v) {
- // would you believe this is the same as the above?
- std::transform(v.begin(),v.end(),v.begin(),
- std::bind2nd(std::divides<double>(),2.0));
+ for (std::vector<double>::iterator it = v.begin(); it != v.end(); ++it)
+ *it /= 2.0;
}
diff --git a/Examples/python/std_vector/runme.py b/Examples/python/std_vector/runme.py
index d7d3c2ea4..3f1106d59 100644
--- a/Examples/python/std_vector/runme.py
+++ b/Examples/python/std_vector/runme.py
@@ -4,32 +4,30 @@ import example
# Call average with a Python list...
-print example.average([1, 2, 3, 4])
+print(example.average([1, 2, 3, 4]))
# ... or a wrapped std::vector<int>
v = example.IntVector(4)
for i in range(len(v)):
v[i] = i + 1
-print example.average(v)
+print(example.average(v))
# half will return a Python list.
# Call it with a Python tuple...
-print example.half((1.0, 1.5, 2.0, 2.5, 3.0))
+print(example.half((1.0, 1.5, 2.0, 2.5, 3.0)))
# ... or a wrapped std::vector<double>
v = example.DoubleVector()
for i in [1, 2, 3, 4]:
v.append(i)
-print example.half(v)
+print(example.half(v))
# now halve a wrapped std::vector<double> in place
example.halve_in_place(v)
-for i in range(len(v)):
- print v[i], "; ",
-print
+print([i for i in v])
diff --git a/Examples/python/template/runme.py b/Examples/python/template/runme.py
index e408e15f9..85b1ba937 100644
--- a/Examples/python/template/runme.py
+++ b/Examples/python/template/runme.py
@@ -3,8 +3,8 @@
import example
# Call some templated functions
-print example.maxint(3, 7)
-print example.maxdouble(3.14, 2.18)
+print(example.maxint(3, 7))
+print(example.maxdouble(3.14, 2.18))
# Create some class
@@ -21,12 +21,12 @@ sum = 0
for i in range(0, 100):
sum = sum + iv.getitem(i)
-print sum
+print(sum)
sum = 0.0
for i in range(0, 1000):
sum = sum + dv.getitem(i)
-print sum
+print(sum)
del iv
del dv
diff --git a/Examples/python/variables/runme.py b/Examples/python/variables/runme.py
index 3388a0eba..d59e0aa3e 100644
--- a/Examples/python/variables/runme.py
+++ b/Examples/python/variables/runme.py
@@ -22,51 +22,51 @@ example.cvar.name = "Bill"
# Now print out the values of the variables
-print "Variables (values printed from Python)"
+print("Variables (values printed from Python)")
-print "ivar =", example.cvar.ivar
-print "svar =", example.cvar.svar
-print "lvar =", example.cvar.lvar
-print "uivar =", example.cvar.uivar
-print "usvar =", example.cvar.usvar
-print "ulvar =", example.cvar.ulvar
-print "scvar =", example.cvar.scvar
-print "ucvar =", example.cvar.ucvar
-print "fvar =", example.cvar.fvar
-print "dvar =", example.cvar.dvar
-print "cvar =", example.cvar.cvar
-print "strvar =", example.cvar.strvar
-print "cstrvar =", example.cvar.cstrvar
-print "iptrvar =", example.cvar.iptrvar
-print "name =", example.cvar.name
-print "ptptr =", example.cvar.ptptr, example.Point_print(example.cvar.ptptr)
-print "pt =", example.cvar.pt, example.Point_print(example.cvar.pt)
+print("ivar = %s" % example.cvar.ivar)
+print("svar = %s" % example.cvar.svar)
+print("lvar = %s" % example.cvar.lvar)
+print("uivar = %s" % example.cvar.uivar)
+print("usvar = %s" % example.cvar.usvar)
+print("ulvar = %s" % example.cvar.ulvar)
+print("scvar = %s" % example.cvar.scvar)
+print("ucvar = %s" % example.cvar.ucvar)
+print("fvar = %s" % example.cvar.fvar)
+print("dvar = %s" % example.cvar.dvar)
+print("cvar = %s" % example.cvar.cvar)
+print("strvar = %s" % example.cvar.strvar)
+print("cstrvar = %s" % example.cvar.cstrvar)
+print("iptrvar = %s" % example.cvar.iptrvar)
+print("name = %s" % example.cvar.name)
+print("ptptr = %s %s" % (example.cvar.ptptr, example.Point_print(example.cvar.ptptr)))
+print("pt = %s %s" % (example.cvar.pt, example.Point_print(example.cvar.pt)))
-print "\nVariables (values printed from C)"
+print("\nVariables (values printed from C)")
example.print_vars()
-print "\nNow I'm going to try and modify some read only variables"
+print("\nNow I'm going to try and modify some read only variables")
-print " Tring to set 'path'"
+print(" Trying to set 'path'")
try:
example.cvar.path = "Whoa!"
- print "Hey, what's going on?!?! This shouldn't work"
-except:
- print "Good."
+ print("Hey, what's going on?!?! This shouldn't work")
+except Exception:
+ print("Good.")
-print " Trying to set 'status'"
+print(" Trying to set 'status'")
try:
example.cvar.status = 0
- print "Hey, what's going on?!?! This shouldn't work"
-except:
- print "Good."
+ print("Hey, what's going on?!?! This shouldn't work")
+except Exception:
+ print("Good.")
-print "\nI'm going to try and update a structure variable.\n"
+print("\nI'm going to try and update a structure variable.\n")
example.cvar.pt = example.cvar.ptptr
-print "The new value is"
+print("The new value is")
example.pt_print()
-print "You should see the value", example.Point_print(example.cvar.ptptr)
+print("You should see the value %s" % example.Point_print(example.cvar.ptptr))
diff --git a/Examples/ruby/check.list b/Examples/ruby/check.list
index 2e581fb82..bdc2736ad 100644
--- a/Examples/ruby/check.list
+++ b/Examples/ruby/check.list
@@ -9,7 +9,6 @@ functor
hashargs
import
import_template
-java
mark_function
multimap
operator
diff --git a/Examples/ruby/exception_class/Makefile b/Examples/ruby/exceptproxy/Makefile
index 2d4518e11..2d4518e11 100644
--- a/Examples/ruby/exception_class/Makefile
+++ b/Examples/ruby/exceptproxy/Makefile
diff --git a/Examples/ruby/exception_class/example.h b/Examples/ruby/exceptproxy/example.h
index 9facde4bd..3ee6d765d 100644
--- a/Examples/ruby/exception_class/example.h
+++ b/Examples/ruby/exceptproxy/example.h
@@ -23,7 +23,7 @@ template<typename T> class Queue {
~Queue() {
delete [] items;
}
- void enqueue(T x) throw(FullError) {
+ void enqueue(T x) {
if (nitems == maxsize) {
throw FullError(maxsize);
}
@@ -43,9 +43,3 @@ template<typename T> class Queue {
}
};
-
-
-
-
-
-
diff --git a/Examples/ruby/exception_class/example.i b/Examples/ruby/exceptproxy/example.i
index 5094b7a60..ad0c23acb 100644
--- a/Examples/ruby/exception_class/example.i
+++ b/Examples/ruby/exceptproxy/example.i
@@ -14,9 +14,10 @@
%}
-/* The EmpytError doesn't appear in a throw declaration, and hence
+/* The EmptyError doesn't appear in a throw declaration, and hence
we need to tell SWIG that the dequeue method throws it. This can
now be done via the %catchs feature. */
+%catches(FullError) *::enqueue;
%catches(EmptyError) *::dequeue();
diff --git a/Examples/ruby/exception_class/runme.rb b/Examples/ruby/exceptproxy/runme.rb
index c198c1406..c198c1406 100644
--- a/Examples/ruby/exception_class/runme.rb
+++ b/Examples/ruby/exceptproxy/runme.rb
diff --git a/Examples/ruby/free_function/runme.rb b/Examples/ruby/free_function/runme.rb
index a517ed454..cf405d4cc 100644
--- a/Examples/ruby/free_function/runme.rb
+++ b/Examples/ruby/free_function/runme.rb
@@ -39,7 +39,11 @@ GC.start
# C++ object
ok = false
begin
- puts tiger2.get_name
+ # Let's stress the GC a bit, a single pass might not be enough.
+ 10.times {
+ GC.start
+ puts tiger2.get_name
+ }
rescue ObjectPreviouslyDeleted => error
ok = true
end
diff --git a/Examples/ruby/hashargs/example.i b/Examples/ruby/hashargs/example.i
index 10e209e5f..4c3f3070b 100644
--- a/Examples/ruby/hashargs/example.i
+++ b/Examples/ruby/hashargs/example.i
@@ -2,13 +2,13 @@
%typemap(in) (int nattributes, const char **names, const int *values) (VALUE keys_ary, int i, VALUE key, VALUE val) {
Check_Type($input, T_HASH);
- $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
+ $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, Qnil));
$2 = NULL;
$3 = NULL;
if ($1 > 0) {
$2 = (char **) malloc($1*sizeof(char *));
$3 = (int *) malloc($1*sizeof(int));
- keys_ary = rb_funcall($input, rb_intern("keys"), 0, NULL);
+ keys_ary = rb_funcall($input, rb_intern("keys"), 0, Qnil);
for (i = 0; i < $1; i++) {
key = rb_ary_entry(keys_ary, i);
val = rb_hash_aref($input, key);
diff --git a/Examples/ruby/java/Example.java b/Examples/ruby/java/Example.java
deleted file mode 100644
index 91ddb1ac5..000000000
--- a/Examples/ruby/java/Example.java
+++ /dev/null
@@ -1,29 +0,0 @@
-public class Example {
- public int mPublicInt;
-
- public Example() {
- mPublicInt = 0;
- }
-
- public Example(int IntVal) {
- mPublicInt = IntVal;
- }
-
-
- public int Add(int a, int b) {
- return (a+b);
- }
-
- public float Add(float a, float b) {
- return (a+b);
- }
-
- public String Add(String a, String b) {
- return (a+b);
- }
-
- public Example Add(Example a, Example b) {
- return new Example(a.mPublicInt + b.mPublicInt);
- }
-}
-
diff --git a/Examples/ruby/java/Makefile b/Examples/ruby/java/Makefile
deleted file mode 100644
index bec5e1844..000000000
--- a/Examples/ruby/java/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-TOP = ../..
-SWIGEXE = $(TOP)/../swig
-SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
-CXXSRCS =
-TARGET = example
-INTERFACE = example.i
-LIBS = -lm
-
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run
-
-build: Example.class Example.h
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
- SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- CXXSHARED="gcj -fpic -shared Example.class" LIBS="-lstdc++" DEFS='' ruby_cpp
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean
- rm -f *.class Example.h
-
-Example.class Example.h: $(SRCDIR)Example.java
- gcj -d . -fPIC -C -c -g $(SRCDIR)Example.java
- gcjh Example.class
diff --git a/Examples/ruby/java/example.i b/Examples/ruby/java/example.i
deleted file mode 100644
index 13d5b5e70..000000000
--- a/Examples/ruby/java/example.i
+++ /dev/null
@@ -1,9 +0,0 @@
-%module example
-%include <cni.i>
-
-%{
-#include "Example.h"
-%}
-
-
-%include Example.h
diff --git a/Examples/ruby/java/runme.rb b/Examples/ruby/java/runme.rb
deleted file mode 100644
index fc018b70c..000000000
--- a/Examples/ruby/java/runme.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require 'example'
-
-Example.JvCreateJavaVM(nil)
-Example.JvAttachCurrentThread(nil, nil)
-
-e1 = Example::Example.new(1)
-e2 = Example::Example.new(2)
-
-print e1.Add(1,2),"\n"
-print e1.Add(1.0,2.0),"\n"
-e3 = e1.Add(e1,e2)
-print e3.mPublicInt,"\n"
-
-
-print e1.Add("1","2"),"\n"
-
-Example.JvDetachCurrentThread()
-
diff --git a/Examples/ruby/std_vector/example.h b/Examples/ruby/std_vector/example.h
index 4f0dac70d..52e260d6d 100644
--- a/Examples/ruby/std_vector/example.h
+++ b/Examples/ruby/std_vector/example.h
@@ -17,9 +17,8 @@ std::vector<double> half(const std::vector<double>& v) {
}
void halve_in_place(std::vector<double>& v) {
- // would you believe this is the same as the above?
- std::transform(v.begin(),v.end(),v.begin(),
- std::bind2nd(std::divides<double>(),2.0));
+ for (std::vector<double>::iterator it = v.begin(); it != v.end(); ++it)
+ *it /= 2.0;
}
diff --git a/Examples/ruby/variables/runme.rb b/Examples/ruby/variables/runme.rb
index 38531c833..b748384ce 100644
--- a/Examples/ruby/variables/runme.rb
+++ b/Examples/ruby/variables/runme.rb
@@ -48,7 +48,7 @@ Example.print_vars()
puts "\nNow I'm going to try and modify some read only variables";
-puts " Tring to set 'path'";
+puts " Trying to set 'path'";
begin
Example.path = "Whoa!"
puts "Hey, what's going on?!?! This shouldn't work"
diff --git a/Examples/scilab/check.list b/Examples/scilab/check.list
index 0bcf457c2..d57cfab64 100644
--- a/Examples/scilab/check.list
+++ b/Examples/scilab/check.list
@@ -13,4 +13,3 @@ std_vector
struct
template
variables
-
diff --git a/Examples/scilab/matrix2/example.i b/Examples/scilab/matrix2/example.i
index e37cd116c..e37cd116c 100755..100644
--- a/Examples/scilab/matrix2/example.i
+++ b/Examples/scilab/matrix2/example.i
diff --git a/Examples/scilab/std_list/runme.sci b/Examples/scilab/std_list/runme.sci
index e4c04b029..6075d7ac7 100644
--- a/Examples/scilab/std_list/runme.sci
+++ b/Examples/scilab/std_list/runme.sci
@@ -7,7 +7,7 @@ if ierr <> 0 then
end
example_Init();
-// This example shows how to use C++ fonctions with STL lists arguments
+// This example shows how to use C++ functions with STL lists arguments
// Here, STL lists are converted from/to Scilab matrices (SWIG_SCILAB_EXTRA_NATIVE_CONTAINERS is not defined)
// integer lists
diff --git a/Examples/scilab/std_vector/example.h b/Examples/scilab/std_vector/example.h
index 4f0dac70d..52e260d6d 100644
--- a/Examples/scilab/std_vector/example.h
+++ b/Examples/scilab/std_vector/example.h
@@ -17,9 +17,8 @@ std::vector<double> half(const std::vector<double>& v) {
}
void halve_in_place(std::vector<double>& v) {
- // would you believe this is the same as the above?
- std::transform(v.begin(),v.end(),v.begin(),
- std::bind2nd(std::divides<double>(),2.0));
+ for (std::vector<double>::iterator it = v.begin(); it != v.end(); ++it)
+ *it /= 2.0;
}
diff --git a/Examples/scilab/variables/runme.sci b/Examples/scilab/variables/runme.sci
index 98d76cfa0..1ef077467 100644
--- a/Examples/scilab/variables/runme.sci
+++ b/Examples/scilab/variables/runme.sci
@@ -49,7 +49,7 @@ print_vars()
// Immutable variables
printf("\nNow I''m going to try and modify some read only variables\n");
-printf(" Tring to set ''path''\n");
+printf(" Trying to set ''path''\n");
try
path_set("Whoa!");
printf("Hey, what''s going on?!?! This shouldn''t work\n");
diff --git a/Examples/tcl/check.list b/Examples/tcl/check.list
index 8e7a8a9d7..31d26261b 100644
--- a/Examples/tcl/check.list
+++ b/Examples/tcl/check.list
@@ -5,7 +5,6 @@ contract
enum
funcptr
import
-java
multimap
operator
pointer
diff --git a/Examples/tcl/java/Example.java b/Examples/tcl/java/Example.java
deleted file mode 100644
index 91ddb1ac5..000000000
--- a/Examples/tcl/java/Example.java
+++ /dev/null
@@ -1,29 +0,0 @@
-public class Example {
- public int mPublicInt;
-
- public Example() {
- mPublicInt = 0;
- }
-
- public Example(int IntVal) {
- mPublicInt = IntVal;
- }
-
-
- public int Add(int a, int b) {
- return (a+b);
- }
-
- public float Add(float a, float b) {
- return (a+b);
- }
-
- public String Add(String a, String b) {
- return (a+b);
- }
-
- public Example Add(Example a, Example b) {
- return new Example(a.mPublicInt + b.mPublicInt);
- }
-}
-
diff --git a/Examples/tcl/java/Makefile b/Examples/tcl/java/Makefile
deleted file mode 100644
index e4dfc536b..000000000
--- a/Examples/tcl/java/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-TOP = ../..
-SWIGEXE = $(TOP)/../swig
-SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
-CXXSRCS =
-TARGET = example
-INTERFACE = example.i
-LIBS = -lm
-
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run
-
-build: Example.class Example.h
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
- SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- TCLCXXSHARED="gcj -fpic -shared Example.class " LIBS="-lstdc++" DEFS='' tcl_cpp
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_clean
- rm -f *.class Example.h
-
-Example.class Example.h: $(SRCDIR)Example.java
- gcj -d . -fPIC -C -c -g $(SRCDIR)Example.java
- gcjh Example.class
diff --git a/Examples/tcl/java/example.i b/Examples/tcl/java/example.i
deleted file mode 100644
index b69d83f8d..000000000
--- a/Examples/tcl/java/example.i
+++ /dev/null
@@ -1,8 +0,0 @@
-%module example
-%include <cni.i>
-
-%{
-#include "Example.h"
-%}
-
-%include Example.h
diff --git a/Examples/tcl/java/runme.tcl b/Examples/tcl/java/runme.tcl
deleted file mode 100644
index 6caf0079f..000000000
--- a/Examples/tcl/java/runme.tcl
+++ /dev/null
@@ -1,15 +0,0 @@
-catch { load ./example[info sharedlibextension] example}
-
-JvCreateJavaVM NULL
-JvAttachCurrentThread NULL NULL
-Example e1 1
-Example e2 2
-
-puts "[e1 cget -mPublicInt]"
-puts "[e2 cget -mPublicInt]"
-
-puts "[e2 Add 1 2]"
-puts "[e2 Add 1.0 2.0]"
-puts "[e2 Add '1' '2']"
-
-JvDetachCurrentThread
diff --git a/Examples/tcl/std_vector/example.h b/Examples/tcl/std_vector/example.h
index 4f0dac70d..52e260d6d 100644
--- a/Examples/tcl/std_vector/example.h
+++ b/Examples/tcl/std_vector/example.h
@@ -17,9 +17,8 @@ std::vector<double> half(const std::vector<double>& v) {
}
void halve_in_place(std::vector<double>& v) {
- // would you believe this is the same as the above?
- std::transform(v.begin(),v.end(),v.begin(),
- std::bind2nd(std::divides<double>(),2.0));
+ for (std::vector<double>::iterator it = v.begin(); it != v.end(); ++it)
+ *it /= 2.0;
}
diff --git a/Examples/tcl/variables/runme.tcl b/Examples/tcl/variables/runme.tcl
index b9e2fd418..71aec38b8 100644
--- a/Examples/tcl/variables/runme.tcl
+++ b/Examples/tcl/variables/runme.tcl
@@ -48,7 +48,7 @@ print_vars
puts "\nNow I'm going to try and modify some read only variables";
-puts " Tring to set 'path'";
+puts " Trying to set 'path'";
if { [catch {
set path "Whoa!"
puts "Hey, what's going on?!?! This shouldn't work"
diff --git a/Examples/test-suite/README b/Examples/test-suite/README
index aac7636c6..3b7cea477 100644
--- a/Examples/test-suite/README
+++ b/Examples/test-suite/README
@@ -47,6 +47,6 @@ testdir/README file.
Further Documentation
---------------------
-There is documentation about the test-suite and how to use use it in
+There is documentation about the test-suite and how to use it in
the SWIG documentation - Doc/Manual/Extending.html#Extending_test_suite.
diff --git a/Examples/test-suite/allprotected.i b/Examples/test-suite/allprotected.i
index 086cfb245..e9b4eb341 100644
--- a/Examples/test-suite/allprotected.i
+++ b/Examples/test-suite/allprotected.i
@@ -79,5 +79,9 @@ protected:
};
int ProtectedBase::staticMemberVariable = 10;
+class ProtectedDerived : public ProtectedBase {
+public:
+ ProtectedDerived(const char *s) : ProtectedBase(s) {}
+};
%}
diff --git a/Examples/test-suite/autodoc.i b/Examples/test-suite/autodoc.i
index a2d9f5b4e..efc720155 100644
--- a/Examples/test-suite/autodoc.i
+++ b/Examples/test-suite/autodoc.i
@@ -1,5 +1,7 @@
%module(docstring="hello.") autodoc
+%warnfilter(SWIGWARN_PARSE_KEYWORD) inout;
+
%feature("autodoc");
// special typemap and its docs
@@ -74,6 +76,10 @@
%feature("autodoc","1") D::D(int a, int b, Hola h); // names + types
%feature("autodoc","2") E::E(int a, int b, Hola h); // extended
%feature("autodoc","3") F::F(int a, int b, Hola h); // extended + types
+%feature("autodoc","0") C::~C(); // names
+%feature("autodoc","1") D::~D(); // names + types
+%feature("autodoc","2") E::~E(); // extended
+%feature("autodoc","3") F::~F(); // extended + types
%inline {
@@ -133,6 +139,14 @@ typedef int Integer;
void banana(S *a, const struct tagS *b, int c, Integer d) {}
%}
+// Check docs for a template type
+%inline %{
+template<typename X> struct T {
+ T inout(T t) { return t; }
+};
+%}
+%template(TInteger) T<int>;
+
%inline %{
#ifdef SWIGPYTHON_BUILTIN
bool is_python_builtin() { return true; }
@@ -140,4 +154,41 @@ bool is_python_builtin() { return true; }
bool is_python_builtin() { return false; }
#endif
%}
-
+
+// Autodoc language keywords
+%feature(autodoc,1) process;
+%feature(autodoc,1) process2;
+%feature("compactdefaultargs") process;
+%feature("compactdefaultargs") process2;
+%inline %{
+int process(int from, int in, int var) { return from; }
+int process2(int from = 0, int _in = 1, int var = 2) { return from; }
+%}
+
+%feature(autodoc,1) process3;
+%feature(autodoc,1) process4;
+%feature("kwargs") process3;
+%feature("kwargs") process4;
+%inline %{
+int process3(int from, int _in, int var) { return from; }
+int process4(int from = 0, int _in = 1, int var = 2) { return from; }
+%}
+
+// Autodoc for methods with default arguments not directly representable in
+// target language.
+%feature(autodoc,0) process_complex_defval;
+%feature("compactdefaultargs") process_complex_defval;
+%inline %{
+const int PROCESS_DEFAULT_VALUE = 17;
+typedef long int some_type;
+int process_complex_defval(int val = PROCESS_DEFAULT_VALUE, int factor = some_type(-1)) { return val*factor; }
+%}
+
+// Test for empty docstring, which should be ignored.
+%feature("docstring") ""
+
+%inline %{
+struct a_structure{
+ char my_array[1];
+};
+%}
diff --git a/Examples/test-suite/catches.i b/Examples/test-suite/catches.i
index 8f09ae24c..89cf43f8d 100644
--- a/Examples/test-suite/catches.i
+++ b/Examples/test-suite/catches.i
@@ -1,9 +1,9 @@
%module catches
+// throw is invalid in C++17 and later, only SWIG to use it
+#define TESTCASE_THROW3(T1, T2, T3) throw(T1, T2, T3)
%{
-#if defined(_MSC_VER)
- #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
+#define TESTCASE_THROW3(T1, T2, T3)
%}
%include <exception.i> // for throws(...) typemap
@@ -23,7 +23,7 @@ void test_catches(int i) {
throw ThreeException();
}
}
-void test_exception_specification(int i) throw(int, const char *, const ThreeException&) {
+void test_exception_specification(int i) TESTCASE_THROW3(int, const char *, const ThreeException&) {
test_catches(i);
}
void test_catches_all(int i) {
diff --git a/Examples/test-suite/ccomplextest.i b/Examples/test-suite/ccomplextest.i
new file mode 100644
index 000000000..c631dc02e
--- /dev/null
+++ b/Examples/test-suite/ccomplextest.i
@@ -0,0 +1,81 @@
+%module ccomplextest
+
+%include <complex.i>
+
+%{
+#include <complex.h>
+
+#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199001L
+#define HAS_C99_COMPLEX_FOR_TESTING 1
+#else
+/* c99 complex not supported - super hack tests to just test plain floating point numbers */
+/* some pre c99 compilers (gcc-4.x) don't define _Complex but do define complex */
+#define _Complex
+#if !defined(complex)
+# define complex
+#endif
+#define conj
+#define conjf
+#define creal
+#define cimag
+#if defined(I)
+# undef I
+# define I 1
+#endif
+#define HAS_C99_COMPLEX_FOR_TESTING 0
+#endif
+%}
+
+%inline
+{
+ int has_c99_complex(void) {
+ return HAS_C99_COMPLEX_FOR_TESTING;
+ }
+
+ complex double Conj(complex double a)
+ {
+ return conj(a);
+ }
+
+
+ complex float Conjf(complex float a)
+ {
+ return conjf(a);
+ }
+
+
+ double complex Conj1(double complex a)
+ {
+ return conj(a);
+ }
+
+
+ float complex Conjf1(float complex a)
+ {
+ return conjf(a);
+ }
+
+
+ _Complex double Conj2(_Complex double a)
+ {
+ return conj(a);
+ }
+
+
+ _Complex float Conjf2(_Complex float a)
+ {
+ return conjf(a);
+ }
+
+
+ double _Complex Conj3(double _Complex a)
+ {
+ return conj(a);
+ }
+
+
+ float _Complex Conjf3(float _Complex a)
+ {
+ return conjf(a);
+ }
+}
diff --git a/Examples/test-suite/class_scope_namespace.i b/Examples/test-suite/class_scope_namespace.i
new file mode 100644
index 000000000..47d918157
--- /dev/null
+++ b/Examples/test-suite/class_scope_namespace.i
@@ -0,0 +1,160 @@
+// Test a mix of forward class declarations, class definitions, using declarations and using directives.
+
+%module class_scope_namespace
+
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) H::HH;
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Space8::I_::II;
+
+%inline %{
+struct A;
+namespace Space1 {
+ namespace SubSpace1 {
+ struct A {
+ void aa(Space1::SubSpace1::A, SubSpace1::A, A) {}
+ };
+ void aaa(Space1::SubSpace1::A, SubSpace1::A, A) {}
+ }
+}
+
+namespace Space2 {
+ struct B;
+}
+using Space2::B;
+#ifdef __clang__
+namespace Space2 {
+ struct B {
+ void bb(Space2::B, B) {}
+ };
+}
+#else
+struct B {
+ void bb(Space2::B, B) {}
+};
+#endif
+void bbb(Space2::B, B) {}
+
+namespace Space3 {
+ namespace SubSpace3 {
+ struct C;
+ struct D;
+ }
+}
+struct C;
+struct D;
+namespace Space3 {
+ struct C;
+ struct SubSpace3::C {
+ void cc(Space3::SubSpace3::C, SubSpace3::C) {}
+ };
+ using SubSpace3::D;
+ struct SubSpace3::D {
+ void dd(Space3::SubSpace3::D, SubSpace3::D, D) {}
+ };
+ void ccc(Space3::SubSpace3::C, SubSpace3::C) {}
+ void ddd(Space3::SubSpace3::D, SubSpace3::D, D) {}
+}
+
+namespace Space4 {
+ namespace SubSpace4 {
+ struct E;
+ }
+}
+using namespace Space4;
+using SubSpace4::E;
+// Was added to incorrect namespace in swig-3.0.12
+struct SubSpace4::E {
+ void ee(Space4::SubSpace4::E, SubSpace4::E, E) {}
+};
+void eee(Space4::SubSpace4::E, SubSpace4::E, E) {}
+
+namespace Space5 {
+ namespace SubSpace5 {
+ namespace SubSubSpace5 {
+ struct F;
+ }
+ }
+}
+namespace Space5 {
+ using namespace SubSpace5;
+ using SubSubSpace5::F;
+ // Was added to incorrect namespace in swig-3.0.12
+ struct SubSubSpace5::F {
+ void ff(Space5::SubSpace5::SubSubSpace5::F, SubSpace5::SubSubSpace5::F, SubSubSpace5::F, F) {}
+ };
+ void fff(Space5::SubSpace5::SubSubSpace5::F, SubSpace5::SubSubSpace5::F, SubSubSpace5::F, F) {}
+}
+
+namespace Space6 {
+ struct G;
+ namespace SubSpace6 {
+ struct G;
+ }
+}
+namespace Space6 {
+ struct SubSpace6::G {
+ void gg(Space6::SubSpace6::G, SubSpace6::G) {}
+ };
+ void ggg(Space6::SubSpace6::G, SubSpace6::G) {}
+}
+
+struct HH;
+struct H {
+ struct HH {
+ void hh(H::HH) {}
+ };
+};
+void hhh(H::HH) {}
+
+namespace Space8 {
+ struct II;
+ struct I_ {
+ struct II {
+ void ii(Space8::I_::II, I_::II) {}
+ };
+ };
+ void iii(Space8::I_::II, I_::II) {}
+}
+
+struct J;
+namespace Space9 {
+ namespace SubSpace9 {
+ struct J {
+ void jj(Space9::SubSpace9::J, SubSpace9::J, J) {}
+ };
+ void jjj(Space9::SubSpace9::J, SubSpace9::J, J) {}
+ }
+}
+
+namespace Space10 {
+ struct K;
+}
+namespace Space10 {
+ namespace SubSpace10 {
+ struct K {
+ void kk(Space10::SubSpace10::K, SubSpace10::K, K) {}
+ };
+ void kkk(Space10::SubSpace10::K, SubSpace10::K, K) {}
+ }
+}
+
+namespace OtherSpace {
+ struct L;
+ struct M;
+}
+using OtherSpace::L;
+namespace Space11 {
+ using OtherSpace::M;
+ namespace SubSpace11 {
+ struct L {
+ void ll(Space11::SubSpace11::L, SubSpace11::L, L) {}
+ };
+ void lll(Space11::SubSpace11::L, SubSpace11::L, L) {}
+ struct M {
+ void mm(Space11::SubSpace11::M, SubSpace11::M, M) {}
+ };
+ void mmm(Space11::SubSpace11::M, SubSpace11::M, M) {}
+ }
+}
+
+%}
+
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index e3881afd6..be3453df7 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -83,13 +83,11 @@ Makefile: $(srcdir)/Makefile.in ../../../config.status
# Broken C++ test cases. (Can be run individually using: make testcase.cpptest)
CPP_TEST_BROKEN += \
constants \
- cpp_broken \
director_nested_class \
exception_partial_info \
extend_variable \
li_boost_shared_ptr_template \
nested_private \
- overload_complicated \
rename_camel \
template_default_pointer \
template_private_assignment \
@@ -99,7 +97,7 @@ CPP_TEST_BROKEN += \
# Broken C test cases. (Can be run individually using: make testcase.ctest)
C_TEST_BROKEN += \
- tag_no_clash_with_variable
+ tag_no_clash_with_variable \
# C++ test cases. (Can be run individually using: make testcase.cpptest)
CPP_TEST_CASES += \
@@ -136,6 +134,7 @@ CPP_TEST_CASES += \
char_binary \
char_strings \
chartest \
+ class_scope_namespace \
class_forward \
class_ignore \
class_scope_weird \
@@ -160,15 +159,23 @@ CPP_TEST_CASES += \
cpp_enum \
cpp_namespace \
cpp_nodefault \
+ cpp_parameters \
cpp_static \
cpp_typedef \
+ cpp14_binary_integer_literals \
+ cpp17_hex_floating_literals \
+ cpp17_nested_namespaces \
+ cpp17_nspace_nested_namespaces \
+ cpp17_u8_char_literals \
curiously_recurring_template_pattern \
default_args \
+ default_arg_expressions \
default_arg_values \
default_constructor \
defvalue_constructor \
derived_byvalue \
derived_nested \
+ destructor_methodmodifiers \
destructor_reprotected \
director_abstract \
director_alternating \
@@ -177,10 +184,14 @@ CPP_TEST_CASES += \
director_classes \
director_classic \
director_constructor \
+ director_comparison_operators \
+ director_conversion_operators \
director_default \
director_detect \
director_enum \
director_exception \
+ director_exception_catches \
+ director_exception_nothrow \
director_extend \
director_finalizer \
director_frob \
@@ -192,6 +203,7 @@ CPP_TEST_CASES += \
director_nspace_director_name_collision \
director_overload \
director_overload2 \
+ director_ownership \
director_pass_by_value \
director_primitives \
director_property \
@@ -227,6 +239,7 @@ CPP_TEST_CASES += \
extend_placement \
extend_special_variables \
extend_template \
+ extend_template_method \
extend_template_ns \
extend_typedef_class \
extern_c \
@@ -238,13 +251,16 @@ CPP_TEST_CASES += \
friends \
friends_template \
funcptr_cpp \
+ functors \
fvirtual \
+ global_immutable_vars_cpp \
global_namespace \
global_ns_arg \
global_scope_types \
global_vars \
grouping \
ignore_parameter \
+ import_fragments \
import_nomodule \
inherit \
inherit_member \
@@ -261,9 +277,10 @@ CPP_TEST_CASES += \
li_attribute \
li_attribute_template \
li_boost_shared_ptr \
+ li_boost_shared_ptr_attribute \
li_boost_shared_ptr_bits \
+ li_boost_shared_ptr_director \
li_boost_shared_ptr_template \
- li_boost_shared_ptr_attribute \
li_carrays_cpp \
li_cdata_cpp \
li_cpointer_cpp \
@@ -277,6 +294,7 @@ CPP_TEST_CASES += \
memberin_extend \
member_funcptr_galore \
member_pointer \
+ member_pointer_const \
member_template \
minherit \
minherit2 \
@@ -288,6 +306,7 @@ CPP_TEST_CASES += \
multiple_inheritance_shared_ptr \
name_cxx \
name_warnings \
+ namespace_chase \
namespace_class \
namespace_enum \
namespace_extend \
@@ -301,6 +320,7 @@ CPP_TEST_CASES += \
namespace_virtual_method \
nspace \
nspace_extend \
+ native_directive \
naturalvar \
naturalvar_more \
naturalvar_onoff \
@@ -308,10 +328,13 @@ CPP_TEST_CASES += \
nested_directors \
nested_comment \
nested_ignore \
+ nested_inheritance_interface \
+ nested_in_template \
nested_scope \
nested_template_base \
nested_workaround \
newobject1 \
+ newobject3 \
null_pointer \
operator_overload \
operator_overload_break \
@@ -320,10 +343,12 @@ CPP_TEST_CASES += \
ordering \
overload_arrays \
overload_bool \
+ overload_complicated \
overload_copy \
overload_extend \
overload_method \
overload_numeric \
+ overload_null \
overload_polymorphic \
overload_rename \
overload_return_type \
@@ -335,13 +360,13 @@ CPP_TEST_CASES += \
preproc_constants \
primitive_ref \
private_assign \
+ proxycode \
protected_rename \
pure_virtual \
redefined \
redefined_not \
refcount \
reference_global_vars \
- register_par \
rename1 \
rename2 \
rename3 \
@@ -387,6 +412,7 @@ CPP_TEST_CASES += \
static_array_member \
static_const_member \
static_const_member_2 \
+ stl_no_default_constructor \
string_constants \
struct_initialization_cpp \
struct_value \
@@ -399,6 +425,7 @@ CPP_TEST_CASES += \
template_basic \
template_base_template \
template_classes \
+ template_class_reuse_name \
template_const_ref \
template_construct \
template_templated_constructors \
@@ -408,11 +435,13 @@ CPP_TEST_CASES += \
template_default_arg_overloaded \
template_default_arg_overloaded_extend \
template_default_arg_virtual_destructor \
+ template_default_cache \
template_default_class_parms \
template_default_class_parms_typedef \
template_default_inherit \
template_default_qualify \
template_default_vw \
+ template_empty_inherit \
template_enum \
template_enum_ns_inherit \
template_enum_typedef \
@@ -429,6 +458,7 @@ CPP_TEST_CASES += \
template_methods \
template_namespace_forward_declaration \
template_using_directive_and_declaration_forward \
+ template_using_directive_typedef \
template_nested \
template_nested_typemaps \
template_ns \
@@ -439,6 +469,7 @@ CPP_TEST_CASES += \
template_ns_enum2 \
template_ns_inherit \
template_ns_scope \
+ template_parameters_global_scope \
template_partial_arg \
template_partial_specialization \
template_partial_specialization_typedef \
@@ -476,6 +507,7 @@ CPP_TEST_CASES += \
throw_exception \
typedef_array_member \
typedef_class \
+ typedef_classforward_same_name \
typedef_funcptr \
typedef_inherit \
typedef_mptr \
@@ -496,6 +528,8 @@ CPP_TEST_CASES += \
typemap_numinputs \
typemap_template \
typemap_template_parm_typedef \
+ typemap_template_parms \
+ typemap_template_typedef \
typemap_out_optimal \
typemap_qualifier_strip \
typemap_variables \
@@ -524,14 +558,16 @@ CPP_TEST_CASES += \
varargs_overload \
variable_replacement \
virtual_destructor \
+ virtual_derivation \
virtual_poly \
virtual_vs_nonvirtual_base \
voidtest \
wallkw \
- wrapmacro
+ wrapmacro \
# C++11 test cases.
-CPP11_TEST_CASES = \
+CPP11_TEST_CASES += \
+ cpp11_alias_nested_template_scoping \
cpp11_alignment \
cpp11_alternate_function_syntax \
cpp11_constexpr \
@@ -539,23 +575,28 @@ CPP11_TEST_CASES = \
cpp11_default_delete \
cpp11_delegating_constructors \
cpp11_director_enums \
+ cpp11_directors \
cpp11_explicit_conversion_operators \
+ cpp11_final_directors \
cpp11_final_override \
cpp11_function_objects \
cpp11_inheriting_constructors \
cpp11_initializer_list \
cpp11_initializer_list_extend \
cpp11_lambda_functions \
- cpp11_li_std_array \
cpp11_noexcept \
cpp11_null_pointer_constant \
cpp11_raw_string_literals \
+ cpp11_ref_qualifiers \
+ cpp11_ref_qualifiers_rvalue_unignore \
+ cpp11_ref_qualifiers_typemaps \
cpp11_result_of \
cpp11_rvalue_reference \
cpp11_rvalue_reference2 \
cpp11_rvalue_reference3 \
cpp11_sizeof_object \
cpp11_static_assert \
+ cpp11_std_array \
cpp11_strongly_typed_enumerations \
cpp11_thread_local \
cpp11_template_double_brackets \
@@ -569,10 +610,40 @@ CPP11_TEST_CASES = \
# Broken C++11 test cases.
CPP11_TEST_BROKEN = \
-# cpp11_hash_tables \ # not fully implemented yet
# cpp11_variadic_templates \ # Broken for some languages (such as Java)
# cpp11_reference_wrapper \ # No typemaps
+# Doxygen support test cases: can only be used with languages supporting
+# Doxygen comment translation (currently Python and Java) and only if not
+# disabled by configure via SKIP_DOXYGEN_TEST_CASES.
+ifneq ($(SKIP_DOXYGEN_TEST_CASES),1)
+python_HAS_DOXYGEN := 1
+java_HAS_DOXYGEN := 1
+
+$(eval HAS_DOXYGEN := $($(LANGUAGE)_HAS_DOXYGEN))
+endif
+
+ifdef HAS_DOXYGEN
+DOXYGEN_TEST_CASES += \
+ doxygen_alias \
+ doxygen_basic_notranslate \
+ doxygen_basic_translate \
+ doxygen_basic_translate_style2 \
+ doxygen_basic_translate_style3 \
+ doxygen_code_blocks \
+ doxygen_ignore \
+ doxygen_misc_constructs \
+ doxygen_nested_class \
+ doxygen_parsing \
+ doxygen_parsing_enums \
+ doxygen_translate \
+ doxygen_translate_all_tags \
+ doxygen_translate_links \
+
+$(DOXYGEN_TEST_CASES:=.cpptest): SWIGOPT += -doxygen
+
+CPP_TEST_CASES += $(DOXYGEN_TEST_CASES)
+endif
#
# Put all the heavy STD/STL cases here, where they can be skipped if needed
@@ -581,6 +652,7 @@ CPP_STD_TEST_CASES += \
director_string \
ignore_template_constructor \
li_std_combinations \
+ li_std_containers_overload \
li_std_deque \
li_std_except \
li_std_except_as_class \
@@ -589,15 +661,15 @@ CPP_STD_TEST_CASES += \
li_std_pair_using \
li_std_string \
li_std_vector \
+ li_std_vector_back_reference \
li_std_vector_enum \
li_std_vector_member_var\
li_std_vector_ptr \
+ li_std_wstring \
smart_pointer_inherit \
template_typedef_fnc \
template_type_namespace \
- template_opaque
-# li_std_list
-
+ template_opaque \
ifndef SKIP_CPP_STD_CASES
CPP_TEST_CASES += ${CPP_STD_TEST_CASES}
@@ -616,6 +688,7 @@ C_TEST_CASES += \
char_constant \
const_const \
constant_expr \
+ default_args_c \
empty_c \
enums \
enum_forward \
@@ -625,6 +698,7 @@ C_TEST_CASES += \
funcptr \
function_typedef \
global_functions \
+ global_immutable_vars \
immutable_values \
inctest \
infinity \
@@ -644,13 +718,16 @@ C_TEST_CASES += \
nested_extend_c \
nested_structs \
newobject2 \
+ not_c_keywords \
overload_extend_c \
overload_extend2 \
preproc \
preproc_constants_c \
preproc_defined \
+ preproc_gcc_output \
preproc_include \
preproc_line_file \
+ register_par \
ret_by_value \
simple_array \
sizeof_pointer \
@@ -658,21 +735,22 @@ C_TEST_CASES += \
string_simple \
struct_rename \
struct_initialization \
+ typedef_classforward_same_name \
typedef_struct \
typemap_subst \
union_parameter \
- unions
+ unions \
# Multi-module C++ test cases . (Can be run individually using make testcase.multicpptest)
MULTI_CPP_TEST_CASES += \
clientdata_prop \
- imports \
import_stl \
- packageoption \
+ imports \
mod \
+ multi_import \
+ packageoption \
template_typedef_import \
- multi_import
# Custom tests - tests with additional commandline options
wallkw.cpptest: SWIGOPT += -Wallkw
@@ -721,6 +799,10 @@ check-cpp: $(CPP_TEST_CASES:=.cpptest)
check-cpp11: $(CPP11_TEST_CASES:=.cpptest)
+ifdef HAS_DOXYGEN
+check-doxygen: $(DOXYGEN_TEST_CASES:=.cpptest)
+endif
+
check-failing-test = \
$(MAKE) -s $1.$2 >/dev/null 2>/dev/null && echo "Failing test $1 passed."
@@ -761,7 +843,7 @@ swig_and_compile_external = \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
TARGET='$*_wrap_hdr.h' \
- $(LANGUAGE)$(VARIANT)_externalhdr; \
+ $(LANGUAGE)$(VARIANT)_externalhdr && \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS) $*_external.cxx' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
INCLUDES='$(INCLUDES)' SWIGOPT='$(SWIGOPT)' NOLINK=true \
@@ -775,7 +857,7 @@ setup = \
echo "$(ACTION)ing $(LANGUAGE) testcase $* (with run test)" ; \
else \
echo "$(ACTION)ing $(LANGUAGE) testcase $*" ; \
- fi;
+ fi
diff --git a/Examples/test-suite/complextest.i b/Examples/test-suite/complextest.i
index 64c751a82..6c7b1f44a 100644
--- a/Examples/test-suite/complextest.i
+++ b/Examples/test-suite/complextest.i
@@ -2,7 +2,6 @@
%include <complex.i>
-#ifdef __cplusplus
%{
#include <algorithm>
#include <functional>
@@ -10,52 +9,54 @@
%}
%include <std_vector.i>
-#if 1
%template(VectorStdCplx) std::vector<std::complex<double> >;
-#endif
-%inline
+%inline
{
- std::complex<double> Conj(const std::complex<double>& a)
+ std::complex<double> Conj(std::complex<double> a)
{
return std::conj(a);
- }
+ }
- std::complex<float> Conjf(const std::complex<float>& a)
+ std::complex<float> Conjf(std::complex<float> a)
{
return std::conj(a);
- }
+ }
-#if 1
- std::vector<std::complex<double> > Copy_h(const std::vector<std::complex<double> >& a)
+ std::vector<std::complex<double> > CopyHalf(std::vector<std::complex<double> > a)
{
std::vector<std::complex<double> > b(a.size()/2);
std::copy(a.begin(), a.begin()+a.size()/2, b.begin());
return b;
- }
-#endif
-}
-
-
-#else
+ }
+ using namespace std;
-%{
-%}
+ struct ComplexPair
+ {
+ std::complex<double> z1;
+ complex<double> z2;
+ };
-%inline
-{
- complex Conj(complex a)
+ const complex<double>& Conj2(const complex<double>& a)
{
- return conj(a);
+ static complex<double> ret;
+ ret = std::conj(a);
+ return ret;
}
+ const complex<float>& Conjf2(const complex<float>& a)
+ {
+ static complex<float> ret;
+ ret = std::conj(a);
+ return ret;
+ }
- complex float Conjf(float complex a)
+ const vector<complex<double> >& CopyHalfRef(const vector<complex<double> >& a)
{
- return conj(a);
+ static vector<complex<double> > b;
+ b = CopyHalf(a);
+ return b;
}
}
-
-#endif
diff --git a/Examples/test-suite/constant_directive.i b/Examples/test-suite/constant_directive.i
index 89f13cecc..3e4775df1 100644
--- a/Examples/test-suite/constant_directive.i
+++ b/Examples/test-suite/constant_directive.i
@@ -2,6 +2,10 @@
// %constant and struct
+#ifdef SWIGOCAML
+%warnfilter(SWIGWARN_PARSE_KEYWORD) val;
+#endif
+
%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
@@ -10,6 +14,11 @@ struct Type1 {
Type1(int val = 0) : val(val) {}
int val;
};
+enum EnumType
+{
+ EnumValue
+};
+EnumType enumValue = EnumValue;
/* Typedefs for const Type and its pointer */
typedef const Type1 Type1Const;
typedef const Type1* Type1Cptr;
@@ -42,3 +51,4 @@ Type1 getType1Instance() { return Type1(111); }
%constant Type1Cfptr TYPE1CFPTR1DEF_CONSTANT1 = getType1Instance;
/* Regular constant */
%constant int TYPE_INT = 0;
+%constant enum EnumType newValue = enumValue;
diff --git a/Examples/test-suite/constructor_copy.i b/Examples/test-suite/constructor_copy.i
index 7dcd05e8b..222c12f32 100644
--- a/Examples/test-suite/constructor_copy.i
+++ b/Examples/test-suite/constructor_copy.i
@@ -73,12 +73,18 @@ public:
%include "std_vector.i"
-#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGR) || defined(SWIGOCTAVE) || defined(SWIGRUBY) || defined(SWIGJAVASCRIPT) || defined(SWIGSCILAB)
+#if defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGR) || defined(SWIGOCTAVE) || defined(SWIGRUBY) || defined(SWIGJAVASCRIPT) || defined(SWIGSCILAB)
#define SWIG_GOOD_VECTOR
%ignore std::vector<Space::Flow>::vector(size_type);
%ignore std::vector<Space::Flow>::resize(size_type);
#endif
+#if defined(SWIGJAVA)
+#define SWIG_GOOD_VECTOR
+%ignore std::vector<Space::Flow>::vector(jint);
+%ignore std::vector<Space::Flow>::resize(jint);
+#endif
+
#if defined(SWIGTCL) || defined(SWIGPERL)
#define SWIG_GOOD_VECTOR
/* here, for languages with bad declaration */
diff --git a/Examples/test-suite/cplusplus_throw.i b/Examples/test-suite/cplusplus_throw.i
index 3b11c48ca..72ae62938 100644
--- a/Examples/test-suite/cplusplus_throw.i
+++ b/Examples/test-suite/cplusplus_throw.i
@@ -5,10 +5,10 @@
%module cplusplus_throw
+// throw is invalid in C++17 and later, only SWIG to use it
+#define TESTCASE_THROW1(T1) throw(T1)
%{
-#if defined(_MSC_VER)
- #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
+#define TESTCASE_THROW1(T1)
%}
%nodefaultctor;
@@ -20,8 +20,8 @@ class Foo { };
class Bar {
public:
void baz() const { };
- void foo() throw (Foo) { };
- void bazfoo() const throw (int) { };
+ void foo() TESTCASE_THROW1(Foo) { };
+ void bazfoo() const TESTCASE_THROW1(int) { };
};
%}
diff --git a/Examples/test-suite/cpp11_alias_nested_template_scoping.i b/Examples/test-suite/cpp11_alias_nested_template_scoping.i
new file mode 100644
index 000000000..72814aa88
--- /dev/null
+++ b/Examples/test-suite/cpp11_alias_nested_template_scoping.i
@@ -0,0 +1,45 @@
+%module cpp11_alias_nested_template_scoping
+
+// Test to check a template parameter type is expanded when the template parameter
+// is used twice in a type name. Expansion was
+// Y< short >::YYY< T >::value_type >
+// instead of
+// Y< short >::YYY< short >::value_type >
+
+#if !defined(SWIGCSHARP) && !defined(SWIGJAVA)
+%feature("flatnested") ZZZ;
+#endif
+
+%inline %{
+template<typename T> struct Y {
+ typedef T value_type;
+ typedef Y YY;
+ template<typename T2> using YYY = Y<T2>;
+ template<typename T2> struct ZZZ {
+ typedef T2 another_type;
+ };
+ value_type create1() const { return T(); }
+ typename Y::value_type create2() const { return T(); }
+ typename Y<T>::value_type create3() const { return T(); }
+ typename YY::value_type create4() const { return T(); }
+ typename Y<T>::YY::value_type create5() const { return T(); }
+ Y<T>::YYY<T>::value_type create6() const { return T(); }
+ typename Y<T>::template ZZZ<T>::another_type create7() const { return T(); }
+
+ // With global scope prefix
+ typename ::Y<T>::value_type create13() const { return T(); }
+
+ typename ::Y<T>::YY::value_type create15() const { return T(); }
+ ::Y<T>::YYY<T>::value_type create16() const { return T(); }
+ typename ::Y<T>::template ZZZ<T>::another_type create17() const { return T(); }
+};
+%}
+
+%extend Y {
+%template() YYY<short>;
+%template() ZZZ<short>;
+};
+// Use above workaround instead of below (which currently gives syntax error)
+// %template() Y<short>::YYY<short>;
+
+%template(Yshort) Y<short>;
diff --git a/Examples/test-suite/cpp11_alignment.i b/Examples/test-suite/cpp11_alignment.i
index fb25c4ebb..135f63641 100644
--- a/Examples/test-suite/cpp11_alignment.i
+++ b/Examples/test-suite/cpp11_alignment.i
@@ -4,7 +4,8 @@
struct A {
int member;
};
-const int align1 = alignof(A::member);
+const int align1 = alignof(int);
+const int align2 = alignof(int *);
%}
%{
diff --git a/Examples/test-suite/cpp11_alternate_function_syntax.i b/Examples/test-suite/cpp11_alternate_function_syntax.i
index 227a1c8c8..b3ecabc8c 100644
--- a/Examples/test-suite/cpp11_alternate_function_syntax.i
+++ b/Examples/test-suite/cpp11_alternate_function_syntax.i
@@ -6,13 +6,26 @@
struct SomeStruct {
int addNormal(int x, int y);
auto addAlternate(int x, int y) -> int;
+ auto addAlternateConst(int x, int y) const -> int;
+ auto addAlternateNoExcept(int x, int y) noexcept -> int;
+ auto addAlternateConstNoExcept(int x, int y) const noexcept -> int;
+ auto addAlternateMemberPtrParm(int x, int (SomeStruct::*mp)(int, int)) -> int;
+ auto addAlternateMemberPtrConstParm(int x, int (SomeStruct::*mp)(int, int) const) const -> int;
+
+ virtual auto addFinal(int x, int y) const noexcept -> int final { return x + y; }
+ virtual ~SomeStruct() = default;
};
-auto SomeStruct::addAlternate(int x, int y) -> int {
- return x + y;
+int SomeStruct::addNormal(int x, int y) { return x + y; }
+auto SomeStruct::addAlternate(int x, int y) -> int { return x + y; }
+auto SomeStruct::addAlternateConst(int x, int y) const -> int { return x + y; }
+auto SomeStruct::addAlternateNoExcept(int x, int y) noexcept -> int { return x + y; }
+auto SomeStruct::addAlternateConstNoExcept(int x, int y) const noexcept -> int { return x + y; }
+auto SomeStruct::addAlternateMemberPtrParm(int x, int (SomeStruct::*mp)(int, int)) -> int {
+ return 100*x + (this->*mp)(x, x);
}
-
-int SomeStruct::addNormal(int x, int y) {
- return x + y;
+auto SomeStruct::addAlternateMemberPtrConstParm(int x, int (SomeStruct::*mp)(int, int) const) const -> int {
+ return 1000*x + (this->*mp)(x, x);
}
+
%}
diff --git a/Examples/test-suite/cpp11_constexpr.i b/Examples/test-suite/cpp11_constexpr.i
index d91107cc6..420db4f83 100644
--- a/Examples/test-suite/cpp11_constexpr.i
+++ b/Examples/test-suite/cpp11_constexpr.i
@@ -3,11 +3,26 @@
*/
%module cpp11_constexpr
+
+%{
+#if defined(__clang__)
+#pragma clang diagnostic push
+// Suppress: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior
+// For MMM() and NNN()
+#pragma clang diagnostic ignored "-Wconstexpr-not-const"
+#endif
+%}
+
%inline %{
+#ifdef SWIG
+#define SWIGTESTCONST const
+#else
+#define SWIGTESTCONST
+#endif
constexpr int AAA = 10;
constexpr const int BBB = 20;
constexpr int CCC() { return 30; }
-constexpr const int DDD() { return 40; }
+constexpr SWIGTESTCONST int DDD() { return 40; }
constexpr int XXX() { return 10; }
constexpr int YYY = XXX() + 100;
@@ -17,7 +32,7 @@ struct ConstExpressions {
static constexpr int KKK = 200;
static const int LLL = 300;
constexpr int MMM() { return 400; }
- constexpr const int NNN() { return 500; }
+ constexpr SWIGTESTCONST int NNN() { return 500; }
// Regression tests for support added in SWIG 3.0.4:
static constexpr const int JJJ1 = 101;
constexpr static int KKK1 = 201;
diff --git a/Examples/test-suite/cpp11_default_delete.i b/Examples/test-suite/cpp11_default_delete.i
index 79c02cddc..0c20fb7ee 100644
--- a/Examples/test-suite/cpp11_default_delete.i
+++ b/Examples/test-suite/cpp11_default_delete.i
@@ -17,20 +17,26 @@ public:
};
struct A1 {
- void func(int i) {}
+ void funk(int i) {}
A1() = default;
~A1() = default;
- void func(double i) = delete; /* Don't cast double to int. Compiler returns an error */
+ void funk(double i) = delete; /* Don't cast double to int. Compiler returns an error */
private:
A1(const A1&);
};
A1::A1(const A1&) = default;
struct A2 {
- void func(int i) {}
+ void funk(int i) {}
+
+// Workaround clang 10.0.1 -std=c++17 linker error (oddly for Java and not Python):
+// Undefined symbols for architecture x86_64:"___cxa_deleted_virtual", referenced from: vtable for A2
+#if !(defined(__clang__) && __cplusplus >= 201703L)
virtual void fff(int) = delete;
+#endif
+
virtual ~A2() = default;
- template<class T> void func(T) = delete;
+ template<class T> void funk(T) = delete;
};
struct trivial {
diff --git a/Examples/test-suite/cpp11_directors.i b/Examples/test-suite/cpp11_directors.i
new file mode 100644
index 000000000..3d1fbea25
--- /dev/null
+++ b/Examples/test-suite/cpp11_directors.i
@@ -0,0 +1,16 @@
+%module(directors="1") cpp11_directors
+%feature("director");
+
+%inline %{
+
+class Foo {
+ public:
+ virtual ~Foo() noexcept {}
+ virtual int ping() noexcept = 0;
+ virtual int pong() noexcept = 0;
+ virtual int pang() const& noexcept = 0;
+ virtual int peng() & noexcept = 0;
+ virtual int pung() & = 0;
+};
+
+%}
diff --git a/Examples/test-suite/cpp11_final_directors.i b/Examples/test-suite/cpp11_final_directors.i
new file mode 100644
index 000000000..b58111adb
--- /dev/null
+++ b/Examples/test-suite/cpp11_final_directors.i
@@ -0,0 +1,33 @@
+%module(directors="1") cpp11_final_directors
+
+%director Derived;
+
+// Check SWIG will not wrap these classes as directors where the destructors are final
+%director BaseFinalDestructor;
+%director BaseFinalDestructor2;
+
+%warnfilter(SWIGWARN_LANG_DIRECTOR_FINAL) BaseFinalDestructor::~BaseFinalDestructor;
+%warnfilter(SWIGWARN_LANG_DIRECTOR_FINAL) BaseFinalDestructor2::~BaseFinalDestructor2;
+
+%inline %{
+struct Base {
+ virtual void basemeth() final {}
+ virtual ~Base() {}
+};
+
+struct Derived : Base {
+ virtual int derivedmeth() final { return 1; }
+ virtual int meth() { return 2; }
+ virtual ~Derived() {}
+};
+
+struct BaseFinalDestructor {
+ virtual void basefinalmeth() final {}
+ virtual ~BaseFinalDestructor() final {}
+};
+
+struct BaseFinalDestructor2 {
+ virtual void basefinalmeth() {}
+ virtual ~BaseFinalDestructor2() final {}
+};
+%}
diff --git a/Examples/test-suite/cpp11_final_override.i b/Examples/test-suite/cpp11_final_override.i
index f691f8770..c31ae73b6 100644
--- a/Examples/test-suite/cpp11_final_override.i
+++ b/Examples/test-suite/cpp11_final_override.i
@@ -6,6 +6,12 @@
%warnfilter(SWIGWARN_PARSE_KEYWORD) final; // 'final' is a java keyword, renaming to '_final'
%warnfilter(SWIGWARN_PARSE_KEYWORD) override; // 'override' is a C# keyword, renaming to '_override'
+// throw is invalid in C++17 and later, only SWIG to use it
+#define TESTCASE_THROW1(T1) throw(T1)
+%{
+#define TESTCASE_THROW1(T1)
+%}
+
%inline %{
struct Base {
@@ -16,6 +22,8 @@ struct Base {
virtual void finaloverride2() {}
virtual void finaloverride3() {}
virtual void finaloverride4() const {}
+ virtual void finaloverride5() {}
+ virtual void finaloverride6() const {}
virtual ~Base() {}
};
@@ -31,6 +39,8 @@ struct Derived /*final*/ : Base {
virtual void finaloverride2() override final {}
virtual void finaloverride3() noexcept override final {}
virtual void finaloverride4() const noexcept override final {}
+ virtual void finaloverride5() TESTCASE_THROW1(int) override final {}
+ virtual void finaloverride6() const TESTCASE_THROW1(int) override final {}
virtual ~Derived() override final {}
};
void Derived::override2() const noexcept {}
@@ -78,6 +88,7 @@ struct Destructors4 : Base {
struct FinalOverrideMethods {
virtual void final() {}
virtual void override(int) {}
+ virtual ~FinalOverrideMethods() = default;
};
struct FinalOverrideVariables {
int final;
@@ -126,3 +137,32 @@ void DerivedNoVirtualStruct::cd() {}
void DerivedNoVirtualStruct::ef() {}
DerivedNoVirtualStruct::~DerivedNoVirtualStruct() {}
%}
+
+%inline %{
+namespace Outer {
+ namespace final {
+ template <typename T> struct smart_ptr {
+ typedef T type;
+ };
+ }
+ namespace override {
+ template <typename T> struct dumb_ptr {
+ typedef T type;
+ };
+ }
+}
+%}
+
+%template(SmartPtrBaseStruct) Outer::final::smart_ptr<DerivedStruct>;
+
+%inline %{
+class ObjectDB
+{
+public:
+ static void smart1(typename Outer::final::smart_ptr<DerivedStruct>::type *objectT) {}
+ static void smart2(Outer::final::smart_ptr<DerivedStruct>::type *objectT) {}
+ static void dumb1(typename Outer::override::dumb_ptr<DerivedStruct>::type *objectT) {}
+ static void dumb2(Outer::override::dumb_ptr<DerivedStruct>::type *objectT) {}
+ static Outer::final::smart_ptr<DerivedStruct>::type get() { return DerivedStruct(); }
+};
+%}
diff --git a/Examples/test-suite/cpp11_hash_tables.i b/Examples/test-suite/cpp11_hash_tables.i
index 4f68cbac5..0c671aa5d 100644
--- a/Examples/test-suite/cpp11_hash_tables.i
+++ b/Examples/test-suite/cpp11_hash_tables.i
@@ -4,19 +4,27 @@
%inline %{
#include <set>
-//#include <map>
+#include <map>
#include <unordered_set>
-//#include <unordered_map>
+#include <unordered_map>
%}
%include "std_set.i"
-//%include "std_map.i"
+%include "std_multiset.i"
+%include "std_map.i"
+%include "std_multimap.i"
%include "std_unordered_set.i"
-//%include "std_unordered_map.i"
+%include "std_unordered_multiset.i"
+%include "std_unordered_map.i"
+%include "std_unordered_multimap.i"
%template (SetInt) std::set<int>;
-//%template (MapIntInt) std::map<int, int>;
+%template (MultiSetInt) std::multiset<int>;
+%template (MapIntInt) std::map<int, int>;
+%template (MultiMapIntInt) std::multimap<int, int>;
%template (UnorderedSetInt) std::unordered_set<int>;
-//%template (UnorderedMapIntInt) std::unordered_map<int, int>;
+%template (UnorderedMultiSetInt) std::unordered_multiset<int>;
+%template (UnorderedMapIntInt) std::unordered_map<int, int>;
+%template (UnorderedMultiMapIntInt) std::unordered_multimap<int, int>;
%inline %{
using namespace std;
@@ -25,19 +33,19 @@ class MyClass {
public:
set<int> getSet() { return _set; }
void addSet(int elt) { _set.insert(_set.begin(), elt); }
-// map<int, int> getMap() { return _map; }
-// void addMap(int elt1, int elt2) { _map.insert(make_pair(elt1, elt2)); }
+ map<int, int> getMap() { return _map; }
+ void addMap(int elt1, int elt2) { _map.insert(make_pair(elt1, elt2)); }
unordered_set<int> getUnorderedSet() { return _unordered_set; }
void addUnorderedSet(int elt) { _unordered_set.insert(_unordered_set.begin(), elt); }
-// unordered_map<int, int> getUnorderedMap() { return _unordered_map; }
-// void addUnorderedMap(int elt1, int elt2) { _unordered_map.insert(make_pair(elt1, elt2)); }
+ unordered_map<int, int> getUnorderedMap() { return _unordered_map; }
+ void addUnorderedMap(int elt1, int elt2) { _unordered_map.insert(make_pair(elt1, elt2)); }
private:
set<int> _set;
-// map<int, int> _map;
+ map<int, int> _map;
unordered_set<int> _unordered_set;
-// unordered_map<int, int> _unordered_map;
+ unordered_map<int, int> _unordered_map;
};
%}
diff --git a/Examples/test-suite/cpp11_initializer_list.i b/Examples/test-suite/cpp11_initializer_list.i
index 58d2ecc50..b309576c1 100644
--- a/Examples/test-suite/cpp11_initializer_list.i
+++ b/Examples/test-suite/cpp11_initializer_list.i
@@ -6,12 +6,21 @@
%ignore A::A(std::initializer_list<int>);
%ignore B::method;
-%typemap(in) std::initializer_list<const char *> {
+%typemap(in) std::initializer_list<const char *> %{
$1 = {"Ab", "Fab"};
-}
+%}
+
+%begin %{
+#if __GNUC__ >= 9
+/* warning: ‘new’ of initializer_list does not extend the lifetime of the underlying array [-Winit-list-lifetime] */
+/* incorrect warning for C::C(std::initializer_list<const char *>) */
+#pragma GCC diagnostic ignored "-Winit-list-lifetime"
+#endif
+%}
%inline %{
#include <initializer_list>
+#include <string>
class A {
public:
@@ -26,9 +35,16 @@ public:
void method(std::initializer_list<int> init) {}
};
class C {
+ std::string joined;
public:
- C(std::initializer_list<const char *>) {}
+ C(std::initializer_list<const char *> init) {
+ for (auto& val : init)
+ joined += val;
+ }
C() {}
+ const char * get_joined_string() {
+ return joined.c_str();
+ }
};
%}
diff --git a/Examples/test-suite/cpp11_lambda_functions.i b/Examples/test-suite/cpp11_lambda_functions.i
index 161e08c65..3d7d76d60 100644
--- a/Examples/test-suite/cpp11_lambda_functions.i
+++ b/Examples/test-suite/cpp11_lambda_functions.i
@@ -26,6 +26,14 @@
%warnfilter(SWIGWARN_CPP11_LAMBDA) Space1::lambda19;
%warnfilter(SWIGWARN_CPP11_LAMBDA) Space1::Space2::lambda20;
+// throw is invalid in C++17 and later, only SWIG to use it
+#define TESTCASE_THROW0() throw()
+#define TESTCASE_THROW1(T1) throw(T1)
+%{
+#define TESTCASE_THROW0()
+#define TESTCASE_THROW1(T1)
+%}
+
%inline %{
/* Defined lambda function with return value. */
auto lambda1 = [](int x, int y) -> int { return x+y; };
@@ -35,14 +43,17 @@ auto lambda1 = [](int x, int y) -> int { return x+y; };
single statement "return expr;". */
auto lambda2 = [](int x, int y) { return x+y; };
-auto lambda3 = [&](int x, int y) { return x+y; };
-auto lambda4 = [=](int x, int y) { return x+y; };
int thing = 0;
#ifdef SWIG
-// Not strictly correct as captured variables should have non-automatic storage duration, ie shouldn't capture globals. gcc-4.7 warns about this, but we check that SWIG can parse this anyway.
+// This is not strictly legal: non-local lambda expression cannot have a capture-default
+// gcc-4.7 warns about this and gcc-9 gives an error, but we check that SWIG can parse this anyway.
+auto lambda3 = [&](int x, int y) { return x+y; };
+auto lambda4 = [=](int x, int y) { return x+y; };
auto lambda5 = [=,&thing]() { return thing; };
#else
-auto lambda5 = [=]() { return thing; };
+auto lambda3 = [](int x, int y) { return x+y; };
+auto lambda4 = [](int x, int y) { return x+y; };
+auto lambda5 = []() { return thing; };
#endif
void fn() {
@@ -51,22 +62,27 @@ void fn() {
}
auto lambda6 = [] (int a, int b) mutable { return a + b; };
auto lambda7 = [] (int x, int y) -> int { return x+y; };
-auto lambda8 = [] (int x, int y) throw() -> int { return x+y; };
-auto lambda9 = [] (int x, int y) mutable throw() -> int { return x+y; };
-auto lambda10 = [] (int x, int y) throw(int) { return x+y; };
-auto lambda11 = [] (int x, int y) mutable throw(int) { return x+y; };
+auto lambda8 = [] (int x, int y) TESTCASE_THROW0() -> int { return x+y; };
+auto lambda9 = [] (int x, int y) mutable TESTCASE_THROW0() -> int { return x+y; };
+auto lambda10 = [] (int x, int y) TESTCASE_THROW1(int) { return x+y; };
+auto lambda11 = [] (int x, int y) mutable TESTCASE_THROW1(int) { return x+y; };
auto lambda12 = [] (int a, int b) { return a + b; }(1, 2);
auto lambda13 = [] (int a, int b) mutable { return a + b; }(1, 2);
-auto lambda14 = [] () throw () {};
-auto lambda15 = [] () mutable throw () {};
+auto lambda14 = [] () TESTCASE_THROW0() {};
+auto lambda15 = [] () mutable TESTCASE_THROW0() {};
auto lambda16 = [] { return thing; };
auto lambda17 = [] { return thing; }();
-constexpr auto lambda18 = [] (int x, int y) mutable throw(int) { return x+y; };
+#if defined(SWIG) || (defined(__cplusplus) && __cplusplus >= 201703L)
+#define CONSTEXPR constexpr
+#else
+#define CONSTEXPR
+#endif
+CONSTEXPR auto lambda18 = [] (int x, int y) mutable TESTCASE_THROW1(int) { return x+y; };
namespace Space1 {
- constexpr auto lambda19 = [] (int x, int y) mutable throw(int) { return x+y; };
+ CONSTEXPR auto lambda19 = [] (int x, int y) mutable TESTCASE_THROW1(int) { return x+y; };
namespace Space2 {
- constexpr auto lambda20 = [] (int x, int y) mutable throw(int) { return x+y; };
+ CONSTEXPR auto lambda20 = [] (int x, int y) mutable TESTCASE_THROW1(int) { return x+y; };
}
}
@@ -102,6 +118,6 @@ int runLambdaInline() {
// TODO
int(*lambda101notauto)(int, int) = [] (int a, int b) { return a + b; };
int lambda102 = [] (int a, int b) mutable { return a + b; }(1, 2);
-void lambda_init(int = ([=]{ return 0; })());
+void lambda_init(int = ([]{ return 0; })());
%}
diff --git a/Examples/test-suite/cpp11_noexcept.i b/Examples/test-suite/cpp11_noexcept.i
index ef96fd8a7..8aa0baa5a 100644
--- a/Examples/test-suite/cpp11_noexcept.i
+++ b/Examples/test-suite/cpp11_noexcept.i
@@ -3,9 +3,13 @@
%ignore NoExceptClass(NoExceptClass&&);
%rename(Assignment) NoExceptClass::operator=;
+%{
+extern "C" void global_noexcept(int, bool) noexcept {}
+%}
%inline %{
extern "C" void global_noexcept(int, bool) noexcept;
+extern "C" void global_noexcept2(int, bool) noexcept {}
struct NoExceptClass {
static const bool VeryTrue = true;
@@ -14,7 +18,7 @@ struct NoExceptClass {
NoExceptClass(const NoExceptClass&) noexcept {}
NoExceptClass(NoExceptClass&&) noexcept {}
NoExceptClass& operator=(const NoExceptClass&) noexcept { return *this; }
- ~NoExceptClass() noexcept {}
+ virtual ~NoExceptClass() noexcept {}
void noex0() noexcept {}
void noex1() noexcept(sizeof(int) == 4) {}
@@ -27,8 +31,13 @@ struct NoExceptClass {
void noo1() const noexcept {}
static void noo2() noexcept {}
virtual void noo3() const noexcept {}
+
+// Workaround clang 10.0.1 -std=c++17 linker error (oddly for Java and not Python):
+// Undefined symbols for architecture x86_64: "___cxa_deleted_virtual", referenced from: vtable for NoExceptClass
+#if !(defined(__clang__) && __cplusplus >= 201703L)
virtual void noo4() const noexcept = delete;
virtual void noo5() const throw() = delete;
+#endif
};
struct NoExceptAbstract {
diff --git a/Examples/test-suite/cpp11_raw_string_literals.i b/Examples/test-suite/cpp11_raw_string_literals.i
index 6fd13a0d0..b50b768b9 100644
--- a/Examples/test-suite/cpp11_raw_string_literals.i
+++ b/Examples/test-suite/cpp11_raw_string_literals.i
@@ -17,7 +17,9 @@
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) hh;
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) ii;
+#if defined(SWIGTCL) || defined(SWIGCSHARP) || defined(SWIGOCTAVE) || defined(SWIGRUBY) || defined(SWIGPYTHON) || defined(SWIGJAVA)
%include <std_wstring.i>
+#endif
%inline %{
#include <iostream>
@@ -45,6 +47,9 @@ wstring aa = L"Wide string";
const char *bb = u8"UTF-8 string";
const char16_t *cc = u"UTF-16 string";
const char32_t *dd = U"UTF-32 string";
+// New char literals
+char16_t char16_t_char = u'a';
+char32_t char32_t_char = U'b';
%}
/* Raw string literals */
@@ -57,3 +62,43 @@ const char16_t *hh = uR"XXX(I'm a "raw UTF-16" \ string.)XXX";
const char32_t *ii = UR"XXX(I'm a "raw UTF-32" \ string.)XXX";
%}
+// Constants
+#if defined(SWIGJAVA)
+%javaconst(1);
+#elif SWIGCSHARP
+%csconst(1);
+#elif SWIGD
+%dmanifestconst;
+#endif
+
+%inline %{
+#define jj ")I'm an \"ascii\" \\ string constant."
+#define kk R"XXX()I'm an "ascii" \ string constant.)XXX";
+%}
+
+%constant mm = R"XXX()I'm an "ascii" \ string constant with multiple
+
+lines.)XXX";
+
+// docstring feature
+%feature("docstring") RawStringDoc::WW "Single line documentation comment"
+%feature("docstring") RawStringDoc::XX %{
+Multi-line
+documentation
+comment
+%}
+%feature("docstring") RawStringDoc::YY R"RRR(Single line "raw string" documentation comment)RRR"
+%feature("docstring") RawStringDoc::ZZ R"FOO(Documentation comment
+
+as a "raw string"
+on multiple lines including a \ backslash)FOO"
+
+%inline %{
+struct RawStringDoc {
+ void WW() {}
+ void XX() {}
+ void YY() {}
+ void ZZ() {}
+};
+%}
+
diff --git a/Examples/test-suite/cpp11_ref_qualifiers.i b/Examples/test-suite/cpp11_ref_qualifiers.i
new file mode 100644
index 000000000..e37136770
--- /dev/null
+++ b/Examples/test-suite/cpp11_ref_qualifiers.i
@@ -0,0 +1,226 @@
+%module cpp11_ref_qualifiers
+
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) ccextra2;
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) ccextra3;
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) cc2;
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) cc3;
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) cc5;
+
+%include <std_string.i>
+
+%ignore Host::h() const &;
+
+// Basic testing
+%inline %{
+using std::string;
+class Host {
+ string s;
+public:
+ string h1() & { return string(); }
+ string h2() const & { return string(); }
+ string h3() && { return std::move(string()); }
+ string h4() const && { return std::move(string()); }
+ string h5() const { return string(); }
+ string h6() volatile const & { return string(); }
+ string h7() const volatile & { return string(); }
+ string h8() volatile const && { return std::move(string()); }
+ string h9() const volatile && { return std::move(string()); }
+
+ string h() & { return string(); }
+ string h() const & { return string(); }
+ string h() && { return std::move(string()); }
+ string h() const && { return std::move(string()); }
+};
+%}
+
+// %feature testing
+%feature("except") F1() & %{ result = "F1"; %}
+%feature("except") F2 %{ result = "F2"; %}
+%feature("except") F3 %{ result = "F3"; %}
+%feature("except") F3() %{ _should_not_be_used_ %}
+
+%feature("except") C1(int i) const & %{ result = "C1"; %}
+%feature("except") C2 %{ result = "C2"; %}
+%feature("except") C3 %{ result = "C3"; %}
+%feature("except") C3(int i) %{ _should_not_be_used_ %}
+
+%inline %{
+struct Features {
+ string F1() & { return string(); }
+ string F2() & { return string(); }
+ string F3() & { return string(); }
+
+ string C1(int i) const & { return string(); }
+ string C2(int i) const & { return string(); }
+ string C3(int i) const & { return string(); }
+};
+%}
+
+// %rename testing
+%rename(RR1) R1;
+%rename(RR2) R2() &;
+%rename(RR3) R3;
+%rename(RR3Bad) R3();
+
+%rename(SS1) S1;
+%rename(SS2) S2(int i) const &;
+%rename(SS3) S3;
+%rename(SS3Bad) S3(int i);
+%rename(SS3BadConst) S3(int i) const;
+%rename(SS3BadLValue) S3(int i) &;
+
+%inline %{
+struct Renames {
+ string R1() & { return string(); }
+ string R2() & { return string(); }
+ string R3() & { return string(); }
+
+ string S1(int i) const & { return string(); }
+ string S2(int i) const & { return string(); }
+ string S3(int i) const & { return string(); }
+};
+%}
+
+// Conversion operators
+%rename(StringConvertCopy) operator string() &;
+%rename(StringConvertMove) operator string() &&;
+%feature("ignore", "0") operator string() &&; // unignore as it is ignored by default
+
+%inline %{
+struct ConversionOperators {
+ virtual operator string() & { return string(); }
+ virtual operator string() && { return std::move(string()); }
+ virtual ~ConversionOperators() {}
+};
+struct ConversionOperators2 {
+ virtual operator string() && { return std::move(string()); }
+ virtual ~ConversionOperators2() {}
+};
+%}
+
+%inline %{
+struct Funcs {
+ short FF(bool) { return 0; }
+ short CC(bool) const & { return 0; }
+};
+
+class MemberFuncPtrs
+{
+public:
+ // member ref-qualified function pointers, unnamed parameters
+ int aaa1(short (Funcs::*)(bool) &) const;
+ int aaa2(short (Funcs::* const *&)(bool) &) const;
+ int aaa3(short (Funcs::* *&)(bool) &) const;
+ int aaa4(short (Funcs::* *const&)(bool) &) const;
+ int aaa5(short (Funcs::* &)(bool) &) const;
+ int aaa6(short (Funcs::* const)(bool) &) const;
+ int aaa7(short (Funcs::* const&)(bool) &) const;
+
+ int aaa8(short (Funcs::* const&)(bool) &&) const;
+
+ // member cv-qualified and ref-qualified function pointers, unnamed parameters
+ int bbb1(short (Funcs::*)(bool) const &) const;
+ int bbb2(short (Funcs::* const *&)(bool) const &) const;
+ int bbb3(short (Funcs::* *&)(bool) const &) const;
+ int bbb4(short (Funcs::* *const&)(bool) const &) const;
+ int bbb5(short (Funcs::* &)(bool) const &) const;
+ int bbb6(short (Funcs::* const)(bool) const &) const;
+ int bbb7(short (Funcs::* const&)(bool) const &) const;
+
+ int bbb8(short (Funcs::*)(bool) const &&) const;
+
+ // member ref-qualified function pointers, named parameters
+ int qqq1(short (Funcs::* qq1)(bool) &) const;
+ int qqq2(short (Funcs::* const *& qq2)(bool) &) const;
+ int qqq3(short (Funcs::* *& qq3)(bool) &) const;
+ int qqq4(short (Funcs::* *const& qq4)(bool) &) const;
+ int qqq5(short (Funcs::* & qq5)(bool) &) const;
+ int qqq6(short (Funcs::* const qq6)(bool) &) const;
+ int qqq7(short (Funcs::* const& qq7)(bool) &) const;
+
+ int qqq8(short (Funcs::* const& qq8)(bool) &&) const;
+
+ // member cv-qualified and ref-qualified function pointers, named parameters
+ int rrr1(short (Funcs::* rr1)(bool) const &) const;
+ int rrr2(short (Funcs::* const *& rr2)(bool) const &) const;
+ int rrr3(short (Funcs::* *& rr3)(bool) const &) const;
+ int rrr4(short (Funcs::* *const& rr4)(bool) const &) const;
+ int rrr5(short (Funcs::* & rr5)(bool) const &) const;
+ int rrr6(short (Funcs::* const rr6)(bool) const &) const;
+ int rrr7(short (Funcs::* const& rr7)(bool) const &) const;
+
+ int rrr8(short (Funcs::* rr1)(bool) const &&) const;
+};
+
+// member ref-qualified function pointers, unnamed parameters
+int MemberFuncPtrs::aaa1(short (Funcs::*)(bool) &) const { return 0; }
+int MemberFuncPtrs::aaa2(short (Funcs::* const *&)(bool) &) const { return 0; }
+int MemberFuncPtrs::aaa3(short (Funcs::* *&)(bool) &) const { return 0; }
+int MemberFuncPtrs::aaa4(short (Funcs::* *const&)(bool) &) const { return 0; }
+int MemberFuncPtrs::aaa5(short (Funcs::* &)(bool) &) const { return 0; }
+int MemberFuncPtrs::aaa6(short (Funcs::* const)(bool) &) const { return 0; }
+int MemberFuncPtrs::aaa7(short (Funcs::* const&)(bool) &) const { return 0; }
+
+int MemberFuncPtrs::aaa8(short (Funcs::* const&)(bool) &&) const { return 0; }
+
+// member cv-qualified and ref-qualified function pointers, unnamed parameters
+int MemberFuncPtrs::bbb1(short (Funcs::*)(bool) const &) const { return 0; }
+int MemberFuncPtrs::bbb2(short (Funcs::* const *&)(bool) const &) const { return 0; }
+int MemberFuncPtrs::bbb3(short (Funcs::* *&)(bool) const &) const { return 0; }
+int MemberFuncPtrs::bbb4(short (Funcs::* *const&)(bool) const &) const { return 0; }
+int MemberFuncPtrs::bbb5(short (Funcs::* &)(bool) const &) const { return 0; }
+int MemberFuncPtrs::bbb6(short (Funcs::* const)(bool) const &) const { return 0; }
+int MemberFuncPtrs::bbb7(short (Funcs::* const&)(bool) const &) const { return 0; }
+
+int MemberFuncPtrs::bbb8(short (Funcs::*)(bool) const &&) const { return 0; }
+
+// member ref-qualified function pointers, named parameters
+int MemberFuncPtrs::qqq1(short (Funcs::* qq1)(bool) &) const { return 0; }
+int MemberFuncPtrs::qqq2(short (Funcs::* const *& qq2)(bool) &) const { return 0; }
+int MemberFuncPtrs::qqq3(short (Funcs::* *& qq3)(bool) &) const { return 0; }
+int MemberFuncPtrs::qqq4(short (Funcs::* *const& qq4)(bool) &) const { return 0; }
+int MemberFuncPtrs::qqq5(short (Funcs::* & qq5)(bool) &) const { return 0; }
+int MemberFuncPtrs::qqq6(short (Funcs::* const qq6)(bool) &) const { return 0; }
+int MemberFuncPtrs::qqq7(short (Funcs::* const& qq7)(bool) &) const { return 0; }
+
+int MemberFuncPtrs::qqq8(short (Funcs::* const& qq8)(bool) &&) const { return 0; }
+
+// member cv-qualified and ref-qualified function pointers, named parameters
+int MemberFuncPtrs::rrr1(short (Funcs::* rr1)(bool) const &) const { return 0; }
+int MemberFuncPtrs::rrr2(short (Funcs::* const *& rr2)(bool) const &) const { return 0; }
+int MemberFuncPtrs::rrr3(short (Funcs::* *& rr3)(bool) const &) const { return 0; }
+int MemberFuncPtrs::rrr4(short (Funcs::* *const& rr4)(bool) const &) const { return 0; }
+int MemberFuncPtrs::rrr5(short (Funcs::* & rr5)(bool) const &) const { return 0; }
+int MemberFuncPtrs::rrr6(short (Funcs::* const rr6)(bool) const &) const { return 0; }
+int MemberFuncPtrs::rrr7(short (Funcs::* const& rr7)(bool) const &) const { return 0; }
+
+int MemberFuncPtrs::rrr8(short (Funcs::* rr1)(bool) const &&) const { return 0; }
+
+// member cv-qualified and ref-qualified pointer variables
+short (Funcs::* cc1)(bool) const & = &Funcs::CC;
+
+short (Funcs::* const * ccextra2)(bool) const & = &cc1;
+short (Funcs::* * ccextra3)(bool) const & = &cc1;
+short (Funcs::* *const ccextra4)(bool) const & = &cc1;
+
+short (Funcs::* const *& cc2)(bool) const & = ccextra2;
+short (Funcs::* *& cc3)(bool) const & = ccextra3;
+short (Funcs::* *const& cc4)(bool) const & = ccextra4;
+short (Funcs::* & cc5)(bool) const & = cc1;
+short (Funcs::* const cc6)(bool) const & = &Funcs::CC;
+short (Funcs::* const& cc7)(bool) const & = cc1;
+%}
+
+%inline %{
+
+struct Funktions {
+ int addByValue(const int &a, int b) const & { return a+b; }
+ int * addByPointer(const int &a, int b) const & { static int val; val = a+b; return &val; }
+ int & addByReference(const int &a, int b) const & { static int val; val = a+b; return val; }
+};
+
+int call1(int (Funktions::*d)(const int &, int) const &, int a, int b) { Funktions f; return (f.*d)(a, b); }
+//int call2(int * (Funktions::*d)(const int &, int) const &, int a, int b) { Funktions f; return *(f.*d)(a, b); }
+//int call3(int & (Funktions::*d)(const int &, int) const &, int a, int b) { Funktions f; return (f.*d)(a, b); }
+%}
+%constant int (Funktions::*ADD_BY_VALUE)(const int &, int) const & = &Funktions::addByValue;
diff --git a/Examples/test-suite/cpp11_ref_qualifiers_rvalue_unignore.i b/Examples/test-suite/cpp11_ref_qualifiers_rvalue_unignore.i
new file mode 100644
index 000000000..2f5fadfc6
--- /dev/null
+++ b/Examples/test-suite/cpp11_ref_qualifiers_rvalue_unignore.i
@@ -0,0 +1,15 @@
+%module cpp11_ref_qualifiers_rvalue_unignore
+
+// This is a minimal test that does not include any C++ headers to make sure the required
+// <memory> header is generated from a fragment for the generated std::move call
+
+// m1 and m2 are ignored by default, unignore them
+%feature("ignore", "0") RefQualifier::m1() &&;
+%feature("ignore", "0") RefQualifier::m2() const &&;
+
+%inline %{
+struct RefQualifier {
+ void m1() && {}
+ void m2() const && {}
+};
+%}
diff --git a/Examples/test-suite/cpp11_ref_qualifiers_typemaps.i b/Examples/test-suite/cpp11_ref_qualifiers_typemaps.i
new file mode 100644
index 000000000..0e1c3fe53
--- /dev/null
+++ b/Examples/test-suite/cpp11_ref_qualifiers_typemaps.i
@@ -0,0 +1,74 @@
+%module cpp11_ref_qualifiers_typemaps
+
+%typemap(in) SWIGTYPE (CLASS::*) %{
+ _this_will_fail_to_compile_if_used_
+%}
+
+// typemaps to completely ignore the input parm and override it
+%typemap(in) short (Funcs::*ff)(bool) const %{ $1 = &Funcs::FFF2; %}
+%typemap(in) short (Funcs::*cc)(bool) & %{ $1 = &Funcs::CCC5; %}
+%typemap(in) short (Funcs::*gg)(bool) const & %{ $1 = &Funcs::GGG8; %}
+%typemap(in) short (Funcs::*hh)(bool) && %{ $1 = &Funcs::HHH11; %}
+
+%typemap(in) short (Funcs::*)(bool) const %{ $1 = &Funcs::FFF3; %}
+%typemap(in) short (Funcs::*)(bool) & %{ $1 = &Funcs::CCC6; %}
+%typemap(in) short (Funcs::*)(bool) const & %{ $1 = &Funcs::GGG9; %}
+%typemap(in) short (Funcs::*)(bool) && %{ $1 = &Funcs::HHH12; %}
+
+%inline %{
+struct Funcs {
+ short FFF1(bool) const { return 1; }
+ short FFF2(bool) const { return 2; }
+ short FFF3(bool) const { return 3; }
+ short CCC4(bool) & { return 4; }
+ short CCC5(bool) & { return 5; }
+ short CCC6(bool) & { return 6; }
+ short GGG7(bool) const & { return 7; }
+ short GGG8(bool) const & { return 8; }
+ short GGG9(bool) const & { return 9; }
+ short HHH10(bool) && { return 10; }
+ short HHH11(bool) && { return 11; }
+ short HHH12(bool) && { return 12; }
+};
+struct TypemapsNamedParms
+{
+ short fff(short (Funcs::*ff)(bool) const) {
+ Funcs funcs;
+ return (funcs.*ff)(true);
+ }
+ short ccc(short (Funcs::*cc)(bool) &) {
+ Funcs funcs;
+ return (funcs.*cc)(true);
+ }
+ short ggg(short (Funcs::*gg)(bool) const &) {
+ Funcs funcs;
+ return (funcs.*gg)(true);
+ }
+ short hhh(short (Funcs::*hh)(bool) &&) {
+ return (Funcs().*hh)(true);
+ }
+};
+struct TypemapsUnnamedParms
+{
+ short fff(short (Funcs::*f)(bool) const) {
+ Funcs funcs;
+ return (funcs.*f)(true);
+ }
+ short ccc(short (Funcs::*c)(bool) &) {
+ Funcs funcs;
+ return (funcs.*c)(true);
+ }
+ short ggg(short (Funcs::*g)(bool) const &) {
+ Funcs funcs;
+ return (funcs.*g)(true);
+ }
+ short hhh(short (Funcs::*h)(bool) &&) {
+ return (Funcs().*h)(true);
+ }
+};
+%}
+
+%constant short (Funcs::*FF1_MFP)(bool) const = &Funcs::FFF1;
+%constant short (Funcs::*CC4_MFP)(bool) & = &Funcs::CCC4;
+%constant short (Funcs::*GG7_MFP)(bool) const & = &Funcs::GGG7;
+%constant short (Funcs::*HH10_MFP)(bool) && = &Funcs::HHH10;
diff --git a/Examples/test-suite/cpp11_rvalue_reference2.i b/Examples/test-suite/cpp11_rvalue_reference2.i
index 6718a3941..a2a0020f5 100644
--- a/Examples/test-suite/cpp11_rvalue_reference2.i
+++ b/Examples/test-suite/cpp11_rvalue_reference2.i
@@ -23,7 +23,7 @@ struct Thingy {
int val;
int &lvalref;
int &&rvalref;
- Thingy(int v) : val(v), lvalref(val), rvalref(22) {}
+ Thingy(int v, int &&rvalv) : val(v), lvalref(val), rvalref(std::move(rvalv)) {}
void refIn(long &i) {}
void rvalueIn(long &&i) {}
short && rvalueInOut(short &&i) { return std::move(i); }
@@ -31,8 +31,8 @@ struct Thingy {
// test both primitive and user defined rvalue reference default arguments and compactdefaultargs
void compactDefaultArgs(const bool &&b = (const bool &&)PublicGlobalTrue, const UserDef &&u = (const UserDef &&)PublicUserDef) {}
void privateDefaultArgs(const bool &&b = (const bool &&)PrivateTrue) {}
- operator int &&() { return std::move(0); }
- Thingy(const Thingy& rhs) : val(rhs.val), lvalref(rhs.lvalref), rvalref(copy_int(rhs.rvalref)) {}
+ operator int &&() { return std::move(val); }
+ Thingy(const Thingy& rhs) : val(rhs.val), lvalref(rhs.lvalref), rvalref(std::move(rhs.rvalref)) {}
Thingy& operator=(const Thingy& rhs) {
val = rhs.val;
lvalref = rhs.lvalref;
@@ -41,23 +41,25 @@ struct Thingy {
}
private:
static const bool PrivateTrue;
- int copy_int(int& i) { return i; }
Thingy();
};
const bool Thingy::PrivateTrue = true;
short && globalRvalueInOut(short &&i) { return std::move(i); }
-Thingy &&globalrrval = Thingy(55);
+int glob = 123;
-short && func(short &&i) { return std::move(i); }
-Thingy getit() { return Thingy(22); }
+Thingy &&globalrrval = Thingy(55, std::move(glob));
+
+short && funk(short &&i) { return std::move(i); }
+Thingy getit() { return Thingy(22, std::move(glob)); }
void rvalrefFunction1(int &&v = (int &&)5) {}
-void rvalrefFunctionBYVAL(short (Thingy::*memFunc)(short)) {}
-void rvalrefFunctionLVALUE(short &(Thingy::*memFunc)(short &)) {}
-void rvalrefFunction2(short && (Thingy::*memFunc)(short &&)) {}
-void rvalrefFunction3(short && (*memFunc)(short &&)) {}
+void rvalrefFunctionBYVAL(short (Thingy::*fptr)(short)) {}
+void rvalrefFunctionPTR(short * (*fptr)(short *)) {}
+void rvalrefFunctionLVALUE(short & (Thingy::*fptr)(short &)) {}
+void rvalrefFunction2(short && (Thingy::*fptr)(short &&)) {}
+void rvalrefFunction3(short && (*fptr)(short &&)) {}
template <typename T> struct RemoveReference {
typedef T type;
diff --git a/Examples/test-suite/cpp11_rvalue_reference3.i b/Examples/test-suite/cpp11_rvalue_reference3.i
index c65309945..8ebf45366 100644
--- a/Examples/test-suite/cpp11_rvalue_reference3.i
+++ b/Examples/test-suite/cpp11_rvalue_reference3.i
@@ -26,12 +26,18 @@ void takeit5(Thing const*const&& t) {}
struct Containing {
Thing && member_rvalue_ref;
- Thing *&& member_rvalue_ref_ptr1 = 0;
- Thing const*&& member_rvalue_ref_ptr2 = 0;
- Thing *const&& member_rvalue_ref_ptr3 = 0;
- Thing const*const &&member_rvalue_ref_ptr4 = 0;
+ Thing *&& member_rvalue_ref_ptr1;
+ Thing const*&& member_rvalue_ref_ptr2;
+ Thing *const&& member_rvalue_ref_ptr3;
+ Thing const*const &&member_rvalue_ref_ptr4;
- Containing() : member_rvalue_ref(Thing()) {}
+ Containing(Thing&&r, Thing*&& r1, Thing const*&& r2, Thing *const&& r3, Thing const*const && r4) :
+ member_rvalue_ref(std::move(r)),
+ member_rvalue_ref_ptr1(std::move(r1)),
+ member_rvalue_ref_ptr2(std::move(r2)),
+ member_rvalue_ref_ptr3(std::move(r3)),
+ member_rvalue_ref_ptr4(std::move(r4))
+ {}
};
%}
@@ -57,11 +63,17 @@ void int_takeit5(int const*const&& t) {}
struct IntContaining {
int && member_rvalue_ref;
- int *&& member_rvalue_ref_ptr1 = 0;
- int const*&& member_rvalue_ref_ptr2 = 0;
- int *const&& member_rvalue_ref_ptr3 = 0;
- int const*const &&member_rvalue_ref_ptr4 = 0;
+ int *&& member_rvalue_ref_ptr1;
+ int const*&& member_rvalue_ref_ptr2;
+ int *const&& member_rvalue_ref_ptr3;
+ int const*const &&member_rvalue_ref_ptr4;
- IntContaining() : member_rvalue_ref(55) {}
+ IntContaining(int&& r, int*&& r1, int const*&& r2, int *const&& r3, int const*const && r4) :
+ member_rvalue_ref(std::move(r)),
+ member_rvalue_ref_ptr1(std::move(r1)),
+ member_rvalue_ref_ptr2(std::move(r2)),
+ member_rvalue_ref_ptr3(std::move(r3)),
+ member_rvalue_ref_ptr4(std::move(r4))
+ {}
};
%}
diff --git a/Examples/test-suite/cpp11_shared_ptr_const.i b/Examples/test-suite/cpp11_shared_ptr_const.i
new file mode 100644
index 000000000..5e38123b4
--- /dev/null
+++ b/Examples/test-suite/cpp11_shared_ptr_const.i
@@ -0,0 +1,57 @@
+%module cpp11_shared_ptr_const
+
+%{
+
+#include <memory>
+#include <vector>
+
+class Foo
+{
+ int m;
+public:
+ Foo(int i) : m(i) {}
+ int get_m() { return m;}
+};
+
+std::shared_ptr<Foo> foo(Foo v) {
+ return std::shared_ptr<Foo>(new Foo(v));
+}
+
+std::shared_ptr<const Foo> const_foo(Foo v) {
+ return std::shared_ptr<const Foo>(new Foo(v));
+}
+
+std::vector<std::shared_ptr<Foo> > foo_vec(Foo v) {
+ std::vector<std::shared_ptr<Foo> > result;
+ result.push_back( std::shared_ptr<Foo>(new Foo(v)) );
+ return result;
+}
+
+std::vector<std::shared_ptr<const Foo> > const_foo_vec(Foo v) {
+ std::vector<std::shared_ptr<const Foo> > result;
+ result.push_back( std::shared_ptr<Foo>(new Foo(v)) );
+ return result;
+}
+
+%}
+
+%include <std_shared_ptr.i>
+%include <std_vector.i>
+
+%shared_ptr(Foo);
+
+%template (FooVector) std::vector<std::shared_ptr<Foo> >;
+%template (FooConstVector) std::vector<std::shared_ptr<Foo const> >;
+
+class Foo
+{
+ int m;
+public:
+ Foo(int i);
+ int get_m();
+};
+std::shared_ptr<Foo> foo(Foo v);
+std::shared_ptr<const Foo> const_foo(Foo v);
+std::vector<std::shared_ptr<Foo> > foo_vec(Foo v) const;
+std::vector<std::shared_ptr<const Foo> > const_foo_vec(Foo v) const;
+
diff --git a/Examples/test-suite/cpp11_shared_ptr_nullptr_in_containers.i b/Examples/test-suite/cpp11_shared_ptr_nullptr_in_containers.i
new file mode 100644
index 000000000..2167dfb73
--- /dev/null
+++ b/Examples/test-suite/cpp11_shared_ptr_nullptr_in_containers.i
@@ -0,0 +1,50 @@
+%module cpp11_shared_ptr_nullptr_in_containers
+
+%{
+#include <memory>
+#include <vector>
+
+class C;
+%}
+
+%include <std_shared_ptr.i>
+%include <std_vector.i>
+
+%shared_ptr(C)
+
+%inline %{
+
+class C {
+ int m;
+public:
+ C() : m(-1) {}
+ C(int i) : m(i) {}
+ int get_m() { return m; }
+};
+
+%}
+
+%template() std::vector<std::shared_ptr<C> >;
+
+%inline %{
+
+ std::vector<std::shared_ptr<C> > ret_vec_c_shared_ptr() {
+ std::vector<std::shared_ptr<C> > ret(3);
+ ret[0] = std::shared_ptr<C>(new C(0));
+ ret[2] = std::shared_ptr<C>(new C(2));
+ return ret;
+ }
+
+ std::vector<std::shared_ptr<C> > ret_arg_vec(const std::vector<std::shared_ptr<C> >& v) {
+ return v;
+ }
+
+ bool is_last_null(const std::vector<std::shared_ptr<C> >& v) {
+ if( v.back() ) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+%}
diff --git a/Examples/test-suite/cpp11_shared_ptr_overload.i b/Examples/test-suite/cpp11_shared_ptr_overload.i
new file mode 100644
index 000000000..ab84fda9a
--- /dev/null
+++ b/Examples/test-suite/cpp11_shared_ptr_overload.i
@@ -0,0 +1,89 @@
+%module cpp11_shared_ptr_overload
+
+// Tests to ensure valid overloading in C++ between shared_ptr and other types result in code that compiles
+// and all but the 1st overloaded method are automatically ignored/shadowed.
+// Tests the 'equivalent' attribute in the 'typecheck' typemap.
+
+%include <std_string.i>
+%include <std_shared_ptr.i>
+
+%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED,SWIGWARN_LANG_OVERLOAD_SHADOW) UseA(std::shared_ptr<MyType> mytype);
+%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED,SWIGWARN_LANG_OVERLOAD_SHADOW) UseB(int, std::shared_ptr<MyType> mytype);
+%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED,SWIGWARN_LANG_OVERLOAD_SHADOW) UseC(int, std::shared_ptr<MyType> mytype, std::shared_ptr<MyType>);
+
+%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED,SWIGWARN_LANG_OVERLOAD_SHADOW) UseX(MyType &mytype);
+%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED,SWIGWARN_LANG_OVERLOAD_SHADOW) UseY(int, MyType &mytype);
+%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED,SWIGWARN_LANG_OVERLOAD_SHADOW) UseZ(int, MyType &mytype, std::shared_ptr<MyType>);
+
+%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED,SWIGWARN_LANG_OVERLOAD_SHADOW) Combo1;
+%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED,SWIGWARN_LANG_OVERLOAD_SHADOW) Combo2;
+%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED,SWIGWARN_LANG_OVERLOAD_SHADOW) Combo3;
+%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED,SWIGWARN_LANG_OVERLOAD_SHADOW) Combo4;
+%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED,SWIGWARN_LANG_OVERLOAD_SHADOW) Combo5;
+%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED,SWIGWARN_LANG_OVERLOAD_SHADOW) Combo6;
+%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED,SWIGWARN_LANG_OVERLOAD_SHADOW) Combo7;
+
+%shared_ptr(MyType);
+
+%inline %{
+#include <memory>
+#include <string>
+struct MyType {
+ std::string val;
+ MyType(std::string val = std::string()) : val(val) {}
+};
+
+// ref
+std::string UseA(MyType &mytype) { return mytype.val + " ref"; }
+std::string UseA(std::shared_ptr<MyType> mytype) { return mytype->val + " sharedptr"; }
+
+std::string UseB(int, MyType &mytype) { return mytype.val + " ref"; }
+std::string UseB(int, std::shared_ptr<MyType> mytype) { return mytype->val + " sharedptr"; }
+
+std::string UseC(int, MyType &mytype, std::shared_ptr<MyType>) { return mytype.val + " ref"; }
+std::string UseC(int, std::shared_ptr<MyType> mytype, std::shared_ptr<MyType>) { return mytype->val + " sharedptr"; }
+
+// sharedptr
+std::string UseX(std::shared_ptr<MyType> mytype) { return mytype->val + " sharedptr"; }
+std::string UseX(MyType &mytype) { return mytype.val + " ref"; }
+
+std::string UseY(int, std::shared_ptr<MyType> mytype) { return mytype->val + " sharedptr"; }
+std::string UseY(int, MyType &mytype) { return mytype.val + " ref"; }
+
+std::string UseZ(int, std::shared_ptr<MyType> mytype, std::shared_ptr<MyType>) { return mytype->val + " sharedptr"; }
+std::string UseZ(int, MyType &mytype, std::shared_ptr<MyType>) { return mytype.val + " ref"; }
+
+// Combo1-4
+std::string Combo1(MyType mytype) { return mytype.val + "Combo1"; }
+std::string Combo1(MyType *mytype) { return ""; }
+std::string Combo1(std::shared_ptr<MyType> mytype) { return ""; }
+std::string Combo1(std::shared_ptr<MyType>* mytype) { return ""; }
+
+std::string Combo2(MyType *mytype) { return mytype->val + "Combo2"; }
+std::string Combo2(std::shared_ptr<MyType> mytype) { return ""; }
+std::string Combo2(std::shared_ptr<MyType>* mytype) { return ""; }
+std::string Combo2(MyType mytype) { return ""; }
+
+std::string Combo3(std::shared_ptr<MyType> mytype) { return mytype->val + "Combo3"; }
+std::string Combo3(std::shared_ptr<MyType>* mytype) { return ""; }
+std::string Combo3(MyType mytype) { return ""; }
+std::string Combo3(MyType *mytype) { return ""; }
+
+std::string Combo4(std::shared_ptr<MyType>* mytype) { return (*mytype)->val + "Combo4"; }
+std::string Combo4(MyType mytype) { return ""; }
+std::string Combo4(MyType *mytype) { return ""; }
+std::string Combo4(std::shared_ptr<MyType> mytype) { return ""; }
+
+// Combo5-7
+std::string Combo5(MyType &mytype) { return mytype.val + "Combo5"; }
+std::string Combo5(MyType *mytype) { return ""; }
+std::string Combo5(std::shared_ptr<MyType> mytype) { return ""; }
+
+std::string Combo6(MyType *mytype) { return mytype->val + "Combo6"; }
+std::string Combo6(std::shared_ptr<MyType> mytype) { return ""; }
+std::string Combo6(MyType &mytype) { return ""; }
+
+std::string Combo7(std::shared_ptr<MyType> mytype) { return mytype->val + "Combo7"; }
+std::string Combo7(MyType &mytype) { return ""; }
+std::string Combo7(MyType *mytype) { return ""; }
+%}
diff --git a/Examples/test-suite/cpp11_shared_ptr_template_upcast.i b/Examples/test-suite/cpp11_shared_ptr_template_upcast.i
new file mode 100644
index 000000000..38968bb60
--- /dev/null
+++ b/Examples/test-suite/cpp11_shared_ptr_template_upcast.i
@@ -0,0 +1,88 @@
+%module cpp11_shared_ptr_template_upcast
+
+%{
+#include <memory>
+#include <string>
+%}
+
+%include <std_shared_ptr.i>
+%include <std_string.i>
+
+%{
+class Base {
+public:
+ Base() : value(0) {}
+ Base(int v) : value(v) {}
+ virtual ~Base() {}
+
+ virtual int GetResult() = 0;
+
+ int value;
+};
+
+class Derived : public Base {
+public:
+ Derived() : Base() {}
+ Derived(int v) : Base(v) {}
+ virtual ~Derived() {}
+
+ int GetResult() { return value*2; }
+};
+
+template <class T> class Printable : virtual public T {
+public:
+ Printable(int param) : T(param) {}
+ ~Printable() {}
+
+ std::string GetFormatted() { return std::string("The formatted result is: ").append(std::to_string(this->GetResult())); }
+};
+
+std::shared_ptr<Printable<Derived> > MakePrintableDerived(int param) {
+ return std::make_shared<Printable<Derived> >(param);
+}
+
+%}
+
+%shared_ptr(Base);
+%shared_ptr(Derived);
+%shared_ptr(Printable<Derived>)
+
+class Base {
+public:
+ Base();
+ Base(int v);
+ virtual ~Base();
+
+ virtual int GetResult() = 0;
+
+ int value;
+};
+
+class Derived : public Base {
+public:
+ Derived();
+ Derived(int v);
+ virtual ~Derived();
+
+ int GetResult();
+};
+
+/*
+ Virtual inheritance is contrived for this case, but exposes whether SWIGSmartPtrUpcast generated a correctly typed shared pointer of the upcasted class type -
+ if the pointer type is incorrect, this will result in a segmentation fault (on Windows, this could manifest as undefined behavior) when trying to access members
+ inherited from T through a shared_ptr<Printable<T> >.
+*/
+template <class T> class Printable : virtual public T {
+public:
+ Printable(int param);
+ ~Printable();
+
+ std::string GetFormatted();
+};
+
+std::shared_ptr<Printable<Derived> > MakePrintableDerived(int param);
+
+
+%template(PrintableDerived) Printable<Derived>;
+
+
diff --git a/Examples/test-suite/cpp11_shared_ptr_upcast.i b/Examples/test-suite/cpp11_shared_ptr_upcast.i
new file mode 100644
index 000000000..9d85f43d4
--- /dev/null
+++ b/Examples/test-suite/cpp11_shared_ptr_upcast.i
@@ -0,0 +1,188 @@
+%module cpp11_shared_ptr_upcast
+
+%{
+#include <set>
+#include <map>
+#include <memory>
+#include <unordered_set>
+#include <unordered_map>
+#include <vector>
+%}
+
+%include <std_vector.i>
+%include <std_map.i>
+%include <std_shared_ptr.i>
+
+%{
+
+class Base {
+ int m;
+public:
+ Base() : m(-1) {}
+ Base(int i) : m(i) {}
+ int get_m() { return m; }
+};
+
+class Derived : public Base {
+ int n;
+public:
+ Derived() : n(-2) {}
+ Derived(int i) : n(i) {}
+ int get_n() { return n; }
+};
+
+typedef std::shared_ptr<Base> BasePtr;
+typedef std::shared_ptr<Derived> DerivedPtr;
+
+// non-overloaded
+int derived_num1(DerivedPtr v) {
+ return v == nullptr ? 999 : (*v).get_n();
+}
+
+int derived_num2(std::vector<DerivedPtr> v) {
+ return v[0] == nullptr ? 999 : (*v[0]).get_n();
+}
+
+int derived_num3(std::map<int, DerivedPtr> v) {
+ return v[0] == nullptr ? 999 : (*v[0]).get_n();
+}
+
+int base_num1(BasePtr v) {
+ return v == nullptr ? 999 : (*v).get_m();
+}
+
+int base_num2(std::vector<BasePtr > v) {
+ return v[0] == nullptr ? 999 : (*v[0]).get_m();
+}
+
+int base_num3(std::map<int, BasePtr > v) {
+ return v[0] == nullptr ? 999 : (*v[0]).get_m();
+}
+
+// overloaded
+int derived_num(DerivedPtr v) {
+ return derived_num1(v);
+}
+
+int derived_num(std::vector<DerivedPtr> v) {
+ return derived_num2(v);
+}
+
+int derived_num(std::map<int, DerivedPtr> v) {
+ return derived_num3(v);
+}
+
+int base_num(BasePtr v) {
+ return base_num1(v);
+}
+
+int base_num(std::vector<BasePtr > v) {
+ return base_num2(v);
+}
+
+int base_num(std::map<int, BasePtr > v) {
+ return base_num3(v);
+}
+%}
+
+
+%shared_ptr(Base);
+%shared_ptr(Derived);
+
+%template(BaseList) std::vector<std::shared_ptr<Base> >;
+%template(DerivedList) std::vector<std::shared_ptr<Derived> >;
+
+%template(BaseMap) std::map<int, std::shared_ptr<Base> >;
+%template(DerivedMap) std::map<int, std::shared_ptr<Derived> >;
+
+class Base {
+ int m;
+public:
+ Base();
+ int get_m();
+};
+
+class Derived : public Base {
+ int n;
+public:
+ Derived();
+ Derived(int i);
+ int get_n();
+};
+
+typedef std::shared_ptr<Base> BasePtr;
+typedef std::shared_ptr<Derived> DerivedPtr;
+
+// non-overloaded
+int derived_num1(DerivedPtr);
+int derived_num2(std::vector<std::shared_ptr<Derived> > v);
+int derived_num3(std::map<int, DerivedPtr> v);
+int base_num1(BasePtr);
+int base_num2(std::vector<std::shared_ptr<Base> > v);
+int base_num3(std::map<int, BasePtr > v);
+
+// overloaded
+int derived_num(DerivedPtr);
+int derived_num(std::vector<std::shared_ptr<Derived> > v);
+int derived_num(std::map<int, DerivedPtr> v);
+int base_num(BasePtr);
+int base_num(std::vector<std::shared_ptr<Base> > v);
+int base_num(std::map<int, BasePtr > v);
+
+// ptr to shared_ptr
+%shared_ptr(Base2);
+%shared_ptr(Derived2)
+
+%inline %{
+class Base2 {
+ int m;
+public:
+ Base2() : m(-1) {}
+ Base2(int i) : m(i) {}
+ int get_m() { return m; }
+};
+
+
+class Derived2 : public Base2 {
+ int n;
+public:
+ Derived2() : n(0) {}
+ Derived2(int i) : n(i) {}
+ int get_n_2() { return n; }
+};
+%}
+
+%template(Base2List) std::vector<std::shared_ptr<Base2> * >;
+%template(Base2Map) std::map<int, std::shared_ptr<Base2> * >;
+
+%template(Derived2List) std::vector<std::shared_ptr<Derived2> * >;
+%template(Derived2Map) std::map<int, std::shared_ptr<Derived2> * >;
+
+%inline %{
+typedef std::shared_ptr<Derived2> * Derived2Ptr;
+typedef std::shared_ptr<Base2> * Base2Ptr;
+
+int base2_num1(Base2Ptr v) {
+ return v == nullptr ? 999 : *v == nullptr ? 888 : (*v)->get_m();
+}
+
+int base2_num2(std::vector<Base2Ptr> v) {
+ return v[0] == nullptr ? 999 : *v[0] == nullptr ? 888 : (*v[0])->get_m();
+}
+
+int base2_num3(std::map<int, Base2Ptr> v) {
+ return v[0] == nullptr ? 999 : *v[0] == nullptr ? 888 : (*v[0])->get_m();
+}
+
+int derived2_num1(Derived2Ptr v) {
+ return v == nullptr ? 999 : *v == nullptr ? 888 : (*v)->get_n_2();
+}
+
+int derived2_num2(std::vector<Derived2Ptr> v) {
+ return v[0] == nullptr ? 999 : *v[0] == nullptr ? 888 : (*v[0])->get_n_2();
+}
+
+int derived2_num3(std::map<int, Derived2Ptr> v) {
+ return v[0] == nullptr ? 999 : *v[0] == nullptr ? 888 : (*v[0])->get_n_2();
+}
+%}
diff --git a/Examples/test-suite/cpp11_static_assert.i b/Examples/test-suite/cpp11_static_assert.i
index 8d616f96c..7ca452d85 100644
--- a/Examples/test-suite/cpp11_static_assert.i
+++ b/Examples/test-suite/cpp11_static_assert.i
@@ -1,12 +1,32 @@
-/* This test case checks whether SWIG correctly parses and ignores the
- keywords "static_assert()" inside the class or struct.
+/* This test case checks whether SWIG correctly parses and ignores
+ "static_assert()" in various places.
*/
%module cpp11_static_assert
%inline %{
+static_assert(sizeof(int) >= 2, "What? int size is invalid!");
+
+namespace dummy {
+// C++17 allows the message to be omitted, so check that works too.
+// But only show the C++17 version to SWIG, as the compiler may
+// lack C++17 support.
+#ifdef SWIG
+static_assert(sizeof(int) >= sizeof(short));
+#else
+static_assert(sizeof(int) >= sizeof(short), "blah");
+#endif
+}
+
template <typename T>
struct Check1 {
static_assert(sizeof(int) <= sizeof(T), "not big enough");
+ Check1() {
+#ifdef SWIG
+ static_assert(true);
+#else
+ static_assert(true, "true");
+#endif
+ }
};
template <typename T>
diff --git a/Examples/test-suite/cpp11_li_std_array.i b/Examples/test-suite/cpp11_std_array.i
index dedd6483a..3d4771551 100644
--- a/Examples/test-suite/cpp11_li_std_array.i
+++ b/Examples/test-suite/cpp11_std_array.i
@@ -1,4 +1,4 @@
-%module cpp11_li_std_array
+%module cpp11_std_array
#if defined(SWIGPYTHON) || defined(SWIGRUBY) || defined(SWIGJAVA) || defined(SWIGCSHARP)
diff --git a/Examples/test-suite/cpp11_std_unordered_map.i b/Examples/test-suite/cpp11_std_unordered_map.i
new file mode 100644
index 000000000..4bdec9c7c
--- /dev/null
+++ b/Examples/test-suite/cpp11_std_unordered_map.i
@@ -0,0 +1,11 @@
+%module cpp11_std_unordered_map
+
+%include <std_string.i>
+%include <std_unordered_map.i>
+
+%template(UnorderedMapIntInt) std::unordered_map<int, int>;
+%template(UnorderedMapStringInt) std::unordered_map<std::string, int>;
+
+%inline %{
+std::unordered_map<std::string, int, std::hash< std::string >,std::equal_to< std::string >,std::allocator< std::pair< std::string const,int > > > inout(std::unordered_map<std::string, int> m) { return m; }
+%}
diff --git a/Examples/test-suite/cpp11_std_unordered_multimap.i b/Examples/test-suite/cpp11_std_unordered_multimap.i
new file mode 100644
index 000000000..8556b26b5
--- /dev/null
+++ b/Examples/test-suite/cpp11_std_unordered_multimap.i
@@ -0,0 +1,7 @@
+%module cpp11_std_unordered_multimap
+
+%include <std_pair.i>
+%include <std_unordered_multimap.i>
+
+%template(PairIntInt) std::pair<int,int>;
+%template(UnorderedMultiMapIntInt) std::unordered_multimap<int, int>;
diff --git a/Examples/test-suite/cpp11_std_unordered_multiset.i b/Examples/test-suite/cpp11_std_unordered_multiset.i
new file mode 100644
index 000000000..c9907425e
--- /dev/null
+++ b/Examples/test-suite/cpp11_std_unordered_multiset.i
@@ -0,0 +1,5 @@
+%module cpp11_std_unordered_multiset
+
+%include <std_unordered_multiset.i>
+
+%template(UnorderedMultiSetInt) std::unordered_multiset<int>;
diff --git a/Examples/test-suite/cpp11_std_unordered_set.i b/Examples/test-suite/cpp11_std_unordered_set.i
new file mode 100644
index 000000000..c2b8174bb
--- /dev/null
+++ b/Examples/test-suite/cpp11_std_unordered_set.i
@@ -0,0 +1,7 @@
+%module cpp11_std_unordered_set
+
+%include <std_string.i>
+%include <std_unordered_set.i>
+
+%template(UnorderedSetInt) std::unordered_set<int>;
+%template(UnorderedSetString) std::unordered_set<std::string>;
diff --git a/Examples/test-suite/cpp11_template_explicit.i b/Examples/test-suite/cpp11_template_explicit.i
index f8fca4fae..71752f822 100644
--- a/Examples/test-suite/cpp11_template_explicit.i
+++ b/Examples/test-suite/cpp11_template_explicit.i
@@ -8,7 +8,8 @@
%inline %{
-template<typename T> struct Temper {
+template<typename T> class Temper {
+public:
T val;
};
@@ -18,14 +19,20 @@ public:
int memberFunction() { return 100; }
};
+class B {
+public:
+ short member;
+ short memberFunction() { return 100; }
+};
+
template class Temper<A>;
-extern template class Temper<A>;
+extern template class Temper<B>;
template class Temper<A*>;
-extern template class Temper<A*>;
+extern template class Temper<B*>;
template class Temper<int>;
-extern template class Temper<int>;
+extern template class Temper<short>;
%}
%template(TemperInt) Temper<int>;
diff --git a/Examples/test-suite/cpp11_template_typedefs.i b/Examples/test-suite/cpp11_template_typedefs.i
index 02cb8ac30..5f1f2e6f9 100644
--- a/Examples/test-suite/cpp11_template_typedefs.i
+++ b/Examples/test-suite/cpp11_template_typedefs.i
@@ -15,7 +15,7 @@ public:
using type2_t = T2;
T1 a;
T2 b;
- constexpr int get_n() { return N; }
+ constexpr int get_n() const { return N; }
};
// Specialization for T1=const char*, T2=bool
@@ -26,7 +26,7 @@ public:
using type2_t = bool;
type1_t a;
type2_t b;
- constexpr int get_n() { return 3 * N; }
+ constexpr int get_n() const { return 3 * N; }
};
// alias templates
diff --git a/Examples/test-suite/cpp11_thread_local.i b/Examples/test-suite/cpp11_thread_local.i
index 6a1019824..21f21859b 100644
--- a/Examples/test-suite/cpp11_thread_local.i
+++ b/Examples/test-suite/cpp11_thread_local.i
@@ -20,8 +20,10 @@ extern "C++" thread_local int ecpptval;
thread_local int ThreadLocals::stval = 11;
thread_local int ThreadLocals::tsval = 22;
+#if !defined(_MSC_VER)
thread_local const int ThreadLocals::stcval88;
thread_local const int ThreadLocals::tscval99;
+#endif
%}
%{
diff --git a/Examples/test-suite/cpp11_type_aliasing.i b/Examples/test-suite/cpp11_type_aliasing.i
index 2f6ea3aa7..abc1642c4 100644
--- a/Examples/test-suite/cpp11_type_aliasing.i
+++ b/Examples/test-suite/cpp11_type_aliasing.i
@@ -108,5 +108,5 @@ PairSubclass::data_t plus1(PairSubclass::const_ref_data_t x) { return x + 1; }
using callback_t = int(*)(int);
callback_t get_callback() { return mult2; }
-int call(callback_t func, int param) { return func(param); }
+int call(callback_t funk, int param) { return funk(param); }
%}
diff --git a/Examples/test-suite/cpp14_binary_integer_literals.i b/Examples/test-suite/cpp14_binary_integer_literals.i
new file mode 100644
index 000000000..9c696b5a5
--- /dev/null
+++ b/Examples/test-suite/cpp14_binary_integer_literals.i
@@ -0,0 +1,31 @@
+%module cpp14_binary_integer_literals
+
+// Tests are designed so that code compiles with C++98 compilers
+
+%{
+#if __cplusplus >= 201402L
+#define CPP14 1
+#endif
+%}
+
+int b1 = 0b1;
+int b2 = 0b10;
+long b3 = 0b11l;
+unsigned long b4 = 0b100ul;
+unsigned long b5 = 0B101UL;
+
+%{
+#if defined(CPP14)
+int b1 = 0b1;
+int b2 = 0b10;
+long b3 = 0b11l;
+unsigned long b4 = 0b100ul;
+unsigned long b5 = 0B101UL;
+#else
+int b1 = 1;
+int b2 = 2;
+long b3 = 3;
+unsigned long b4 = 4;
+unsigned long b5 = 5;
+#endif
+%}
diff --git a/Examples/test-suite/cpp17_hex_floating_literals.i b/Examples/test-suite/cpp17_hex_floating_literals.i
new file mode 100644
index 000000000..dfc1dc0cf
--- /dev/null
+++ b/Examples/test-suite/cpp17_hex_floating_literals.i
@@ -0,0 +1,43 @@
+%module cpp17_hex_floating_literals
+
+// Tests are designed so that code compiles with C++98 compilers
+
+%{
+#if __cplusplus >= 201703L
+#define CPP17 1
+#endif
+%}
+
+double f1 = 0x.0p1;
+double f2 = 0x0.p1;
+double f3 = 0x0.0p-1;
+double f4 = 0xf.p-1;
+double f5 = 0xA.0p1;
+double f6 = 0x0.10P+10;
+double f7 = 0xb2F.p2;
+float f8 = 0x1234AP1F;
+float f9 = 0x45A1.D1A2p+10f;
+
+%{
+#if defined(CPP17)
+double f1 = 0x.0p1;
+double f2 = 0x0.p1;
+double f3 = 0x0.0p-1;
+double f4 = 0xf.p-1;
+double f5 = 0xA.0p1;
+double f6 = 0x0.10P+10;
+double f7 = 0xb2F.p2;
+float f8 = 0x1234AP1F;
+float f9 = 0x45A1.D1A2p+10f;
+#else
+double f1 = 0.;
+double f2 = 0.;
+double f3 = 0.;
+double f4 = 7.5;
+double f5 = 20.;
+double f6 = 64.;
+double f7 = 11452.;
+float f8 = 149140.f;
+float f9 = 18253638.f;
+#endif
+%}
diff --git a/Examples/test-suite/cpp17_nested_namespaces.i b/Examples/test-suite/cpp17_nested_namespaces.i
new file mode 100644
index 000000000..b9ec9bd5a
--- /dev/null
+++ b/Examples/test-suite/cpp17_nested_namespaces.i
@@ -0,0 +1,199 @@
+%module cpp17_nested_namespaces
+// Tests c++17 style nested namespaces
+// Tests are designed so that code compiles with C++98 compilers
+
+#define CPP17 1
+%{
+#if __cplusplus >= 201703L
+#define CPP17 1
+#endif
+%}
+
+%inline %{
+// Tests with namespaces already defined using C++98 style (non-nested) namespaces
+namespace A1 {
+ struct A1Struct {
+ void A1Method() {}
+ };
+ namespace B1 {
+ struct B1Struct {
+ void B1Method() {}
+ };
+ }
+}
+#if defined(CPP17)
+namespace A1::B1 {
+#else
+namespace A1 {
+ namespace B1 {
+#endif
+ A1Struct createA1Struct() { return ::A1::A1Struct(); }
+ B1Struct createB1Struct() { return ::A1::B1::B1Struct(); }
+#if !defined(CPP17)
+ }
+}
+#else
+}
+#endif
+
+namespace A1 {
+ namespace B1 {
+ namespace C1 {
+ struct C1Struct {
+ void C1Method() {}
+ };
+ }
+ }
+}
+
+#if defined(CPP17)
+namespace A1::B1::C1 {
+#else
+namespace A1 {
+ namespace B1 {
+ namespace C1 {
+#endif
+ C1Struct createC1Struct() { return ::A1::B1::C1::C1Struct(); }
+#if !defined(CPP17)
+ }
+ }
+}
+#else
+}
+#endif
+%}
+
+%inline %{
+// Tests with namespaces already defined using C++17 style (nested) namespaces
+#if defined(CPP17)
+namespace A2::B2 {
+#else
+namespace A2 {
+ namespace B2 {
+#endif
+ struct B2Struct {
+ void B2Method() {}
+ };
+#if !defined(CPP17)
+ }
+}
+#else
+}
+#endif
+
+#if defined(CPP17)
+namespace A2::B2 {
+#else
+namespace A2 {
+ namespace B2 {
+#endif
+ B2Struct createB2Struct() { return ::A2::B2::B2Struct(); }
+#if !defined(CPP17)
+ }
+}
+#else
+}
+#endif
+
+#if defined(CPP17)
+namespace A2::B2::C2 {
+#else
+namespace A2 {
+ namespace B2 {
+ namespace C2 {
+#endif
+ struct C2Struct {
+ void C2Method() {}
+ };
+#if !defined(CPP17)
+ }
+ }
+}
+#else
+}
+#endif
+
+#if defined(CPP17)
+namespace A2::B2::C2 {
+#else
+namespace A2 {
+ namespace B2 {
+ namespace C2 {
+#endif
+ C2Struct createC2Struct() { return ::A2::B2::C2::C2Struct(); }
+#if !defined(CPP17)
+ }
+ }
+}
+#else
+}
+#endif
+%}
+
+
+%inline %{
+// Tests with namespaces already defined using C++17 style (nested) namespaces to 3 levels
+#if defined(CPP17)
+namespace A3::B3::C3 {
+#else
+namespace A3 {
+ namespace B3 {
+ namespace C3 {
+#endif
+ struct C3Struct {
+ void C3Method() {}
+ };
+#if !defined(CPP17)
+ }
+ }
+}
+#else
+}
+#endif
+
+#if defined(CPP17)
+namespace A3::B3::C3 {
+#else
+namespace A3 {
+ namespace B3 {
+ namespace C3 {
+#endif
+ C3Struct createC3Struct() { return ::A3::B3::C3::C3Struct(); }
+#if !defined(CPP17)
+ }
+ }
+}
+#else
+}
+#endif
+
+#if defined(CPP17)
+namespace A3::B3 {
+#else
+namespace A3 {
+ namespace B3 {
+#endif
+ struct B3Struct {
+ void B3Method() {}
+ };
+#if !defined(CPP17)
+ }
+}
+#else
+}
+#endif
+
+#if defined(CPP17)
+namespace A3::B3 {
+#else
+namespace A3 {
+ namespace B3 {
+#endif
+ B3Struct createB3Struct() { return ::A3::B3::B3Struct(); }
+#if !defined(CPP17)
+ }
+}
+#else
+}
+#endif
+%}
diff --git a/Examples/test-suite/cpp17_nspace_nested_namespaces.i b/Examples/test-suite/cpp17_nspace_nested_namespaces.i
new file mode 100644
index 000000000..a88878de9
--- /dev/null
+++ b/Examples/test-suite/cpp17_nspace_nested_namespaces.i
@@ -0,0 +1,13 @@
+%module cpp17_nspace_nested_namespaces
+
+#if defined(SWIGJAVA)
+SWIG_JAVABODY_PROXY(public, public, SWIGTYPE)
+#endif
+
+// nspace feature only supported by these languages
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD) || defined(SWIGLUA) || defined(SWIGJAVASCRIPT)
+%nspace;
+#endif
+
+
+%include "cpp17_nested_namespaces.i"
diff --git a/Examples/test-suite/cpp17_u8_char_literals.i b/Examples/test-suite/cpp17_u8_char_literals.i
new file mode 100644
index 000000000..1aae1b231
--- /dev/null
+++ b/Examples/test-suite/cpp17_u8_char_literals.i
@@ -0,0 +1,26 @@
+%module cpp17_u8_char_literals
+
+// Tests are designed so that code compiles with C++98 compilers
+
+%{
+#if __cplusplus >= 201703L
+#define CPP17 1
+#endif
+%}
+
+// UTF-8 character literals will (apparently) have type char8_t in C++20.
+char a = u8'a';
+char u = u8'u';
+char u8 = u8'8';
+
+%{
+#if defined(CPP17)
+char a = u8'a';
+char u = u8'u';
+char u8 = u8'8';
+#else
+char a = 'a';
+char u = 'u';
+char u8 = '8';
+#endif
+%}
diff --git a/Examples/test-suite/cpp_broken.i b/Examples/test-suite/cpp_broken.i
deleted file mode 100644
index 84d6122e5..000000000
--- a/Examples/test-suite/cpp_broken.i
+++ /dev/null
@@ -1,12 +0,0 @@
-%module cpp_broken
-
-
-// bug #940318
-%inline %{
-typedef enum {
-eZero = 0
-#define ONE 1
-} EFoo;
-%}
-
-
diff --git a/Examples/test-suite/cpp_namespace.i b/Examples/test-suite/cpp_namespace.i
index d7bf95e9f..a415917db 100644
--- a/Examples/test-suite/cpp_namespace.i
+++ b/Examples/test-suite/cpp_namespace.i
@@ -2,6 +2,10 @@
%module cpp_namespace
+#ifdef SWIGOCAML
+%warnfilter(SWIGWARN_PARSE_KEYWORD) method;
+#endif
+
%inline %{
typedef int Bad;
diff --git a/Examples/test-suite/cpp_parameters.i b/Examples/test-suite/cpp_parameters.i
new file mode 100644
index 000000000..e8a4c94fd
--- /dev/null
+++ b/Examples/test-suite/cpp_parameters.i
@@ -0,0 +1,46 @@
+%module cpp_parameters
+
+%{
+// For Perl
+#ifdef Zero
+#undef Zero
+#endif
+%}
+%inline %{
+
+// Zero arguments
+struct Zero {
+ Zero() {}
+ int zero() { return 0; }
+ static int stat_zero() { return 0; }
+};
+// One mandatory argument
+struct One {
+ One(int a) {}
+ int one(int a) { return a; }
+ static int stat_one(int a) { return a; }
+};
+// Two mandatory arguments
+struct Two {
+ Two(int a, int b) {}
+ int two(int a, int b) { return a + b; }
+ static int stat_two(int a, int b) { return a + b; }
+};
+// Single optional argument
+struct Single {
+ Single(int a=0) {}
+ int single(int a=0) { return a; }
+ static int stat_single(int a=0) { return a; }
+};
+
+int global_zero() { return 0; }
+int global_one(int a) { return a; }
+int global_two(int a, int b) { return a + b; }
+int global_single(int a=0) { return a; }
+
+#ifdef SWIGPYTHON_BUILTIN
+bool is_python_builtin() { return true; }
+#else
+bool is_python_builtin() { return false; }
+#endif
+%}
diff --git a/Examples/test-suite/cpp_static.i b/Examples/test-suite/cpp_static.i
index 1f8ca1282..9ffe55837 100644
--- a/Examples/test-suite/cpp_static.i
+++ b/Examples/test-suite/cpp_static.i
@@ -10,6 +10,7 @@ Tests Sourceforge bug #444748.
class StaticMemberTest {
public:
static int static_int;
+ static int grab_int() { return static_int; }
};
class StaticFunctionTest {
@@ -28,10 +29,12 @@ int StaticMemberTest::static_int = 99;
%inline %{
struct StaticBase {
static int statty;
+ static int grab_statty_base() { return statty; }
virtual ~StaticBase() {}
};
struct StaticDerived : StaticBase {
static int statty;
+ static int grab_statty_derived() { return statty; }
};
%}
diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in
index 0c799c7d9..b0ad0c7cf 100644
--- a/Examples/test-suite/csharp/Makefile.in
+++ b/Examples/test-suite/csharp/Makefile.in
@@ -13,11 +13,14 @@ top_srcdir = ../@top_srcdir@
top_builddir = ../@top_builddir@
CPP_TEST_CASES = \
+ complextest \
csharp_attributes \
csharp_swig2_compatibility \
+ csharp_director_typemaps \
csharp_exceptions \
csharp_features \
csharp_lib_arrays \
+ csharp_lib_arrays_bool \
csharp_namespace_system_collision \
csharp_prepost \
csharp_typemaps \
@@ -25,9 +28,15 @@ CPP_TEST_CASES = \
enum_thorough_typesafe \
exception_partial_info \
intermediary_classname \
- li_boost_intrusive_ptr
+ li_boost_intrusive_ptr \
+ li_std_list \
CPP11_TEST_CASES = \
+ cpp11_shared_ptr_const \
+ cpp11_shared_ptr_nullptr_in_containers \
+ cpp11_shared_ptr_overload \
+ cpp11_shared_ptr_template_upcast \
+ cpp11_shared_ptr_upcast \
cpp11_strongly_typed_enumerations_simple \
include $(srcdir)/../common.mk
@@ -40,7 +49,9 @@ CSHARPFLAGSSPECIAL =
# Custom tests - tests with additional commandline options
intermediary_classname.cpptest: SWIGOPT += -dllimport intermediary_classname
+complextest.cpptest: CSHARPFLAGSSPECIAL = -r:System.Numerics.dll
csharp_lib_arrays.cpptest: CSHARPFLAGSSPECIAL = -unsafe
+csharp_lib_arrays_bool.cpptest: CSHARPFLAGSSPECIAL = -unsafe
csharp_swig2_compatibility.cpptest: SWIGOPT += -DSWIG2_CSHARP
# Rules for the different types of tests
diff --git a/Examples/test-suite/csharp/allprotected_runme.cs b/Examples/test-suite/csharp/allprotected_runme.cs
index 99a791d58..6b04feb25 100644
--- a/Examples/test-suite/csharp/allprotected_runme.cs
+++ b/Examples/test-suite/csharp/allprotected_runme.cs
@@ -13,6 +13,20 @@ public class runme
{
MyProtectedBase mpb = new MyProtectedBase("MyProtectedBase");
mpb.accessProtected();
+ try {
+ // C++ destructor is protected
+ mpb.Dispose();
+ throw new Exception("failed to catch MethodAccessException");
+ } catch (MethodAccessException) {
+ // Exception message: C++ destructor does not have public access
+ }
+ ProtectedDerived pd = new ProtectedDerived("ProtectedDerived");
+ // Destroying via the ProtectedDerived's destructor should work
+ pd.Dispose();
+
+ ProtectedBase pb = new ProtectedDerived("ProtectedDerived");
+ // ProtectedDerived's destructor should be called via the Dispose(disposing) virtual call
+ pb.Dispose();
}
}
diff --git a/Examples/test-suite/csharp/complextest_runme.cs b/Examples/test-suite/csharp/complextest_runme.cs
new file mode 100644
index 000000000..e7af9c106
--- /dev/null
+++ b/Examples/test-suite/csharp/complextest_runme.cs
@@ -0,0 +1,43 @@
+// This is the complex runtime testcase. It checks that the C++ std::complex type works.
+// It requires .NET 4.0 as the previous versions didn't have System.Numerics.Complex type.
+
+using System;
+using System.Numerics;
+
+using complextestNamespace;
+
+public class complextest_runme {
+
+ public static void Main() {
+ var a = new Complex(-1, 2);
+ if ( complextest.Conj(a) != Complex.Conjugate(a) )
+ throw new Exception("std::complex<double> test failed");
+
+ if ( complextest.Conjf(a) != Complex.Conjugate(a) )
+ throw new Exception("std::complex<float> test failed");
+
+ if ( complextest.Conj2(a) != Complex.Conjugate(a) )
+ throw new Exception("std::complex<double> test failed");
+
+ if ( complextest.Conjf2(a) != Complex.Conjugate(a) )
+ throw new Exception("std::complex<float> test failed");
+
+ var vec = new VectorStdCplx();
+ vec.Add(new Complex(1, 2));
+ vec.Add(new Complex(2, 3));
+ vec.Add(new Complex(4, 3));
+ vec.Add(new Complex(1, 0));
+
+ if ( complextest.CopyHalf(vec).Count != 2 )
+ throw new Exception("CopyHalf test failed");
+
+ if ( complextest.CopyHalfRef(vec).Count != 2 )
+ throw new Exception("CopyHalfRef test failed");
+
+ var p = new ComplexPair();
+ p.z1 = new Complex(0, 1);
+ p.z2 = new Complex(0, -1);
+ if ( Complex.Conjugate(p.z2) != p.z1 )
+ throw new Exception("vector<complex> test failed");
+ }
+}
diff --git a/Examples/test-suite/csharp/cpp11_shared_ptr_template_upcast_runme.cs b/Examples/test-suite/csharp/cpp11_shared_ptr_template_upcast_runme.cs
new file mode 100644
index 000000000..e76d2bada
--- /dev/null
+++ b/Examples/test-suite/csharp/cpp11_shared_ptr_template_upcast_runme.cs
@@ -0,0 +1,15 @@
+// This is the cpp11_shared_ptr_template_upcast runtime testcase. It checks that SWIG generates the appropriate upcasted shared_ptr type for a template instantiation deriving from a base class.
+// For this case, the expected behavior is: given a cptr with underlying type shared_ptr<Printable<Derived> >, PrintableDerived_SWIGSmartPtrUpcast returns a cptr with
+// underlying type std::shared_ptr< Derived >, where Printable<Derived> inherits from Derived.
+using System;
+using cpp11_shared_ptr_template_upcastNamespace;
+
+public class cpp11_shared_ptr_template_upcast_runme
+{
+ static void Main()
+ {
+ PrintableDerived pd = cpp11_shared_ptr_template_upcast.MakePrintableDerived(20);
+ pd.GetResult();
+ pd.GetFormatted();
+ }
+}
diff --git a/Examples/test-suite/csharp/cpp11_li_std_array_runme.cs b/Examples/test-suite/csharp/cpp11_std_array_runme.cs
index d0c956ad3..ee7c5ee24 100644
--- a/Examples/test-suite/csharp/cpp11_li_std_array_runme.cs
+++ b/Examples/test-suite/csharp/cpp11_std_array_runme.cs
@@ -1,8 +1,8 @@
// This test tests all the methods in the C# collection wrapper
using System;
-using cpp11_li_std_arrayNamespace;
+using cpp11_std_arrayNamespace;
-public class cpp11_li_std_array_runme
+public class cpp11_std_array_runme
{
private static ArrayInt6 ToArray6(int[] a)
{
@@ -37,24 +37,24 @@ public class cpp11_li_std_array_runme
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 });
+ compareContainers(cpp11_std_array.arrayOutVal(), new int[] { -2, -1, 0, 0, 1, 2 });
+ compareContainers(cpp11_std_array.arrayOutConstRef(), new int[] { -2, -1, 0, 0, 1, 2 });
+ compareContainers(cpp11_std_array.arrayOutRef(), new int[] { -2, -1, 0, 0, 1, 2 });
+ compareContainers(cpp11_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 }));
+ ai = cpp11_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 }));
+ ai = cpp11_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);
+ cpp11_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);
+ cpp11_std_array.arrayInPtr(ai);
compareContainers(ai, new int[] { 90, 80, 70, 60, 50, 40 });
// fill
diff --git a/Examples/test-suite/csharp/cpp17_nested_namespaces_runme.cs b/Examples/test-suite/csharp/cpp17_nested_namespaces_runme.cs
new file mode 100644
index 000000000..8707b4e20
--- /dev/null
+++ b/Examples/test-suite/csharp/cpp17_nested_namespaces_runme.cs
@@ -0,0 +1,25 @@
+using System;
+using cpp17_nested_namespacesNamespace;
+
+public class cpp17_nested_namespaces_runme
+{
+ static void Main()
+ {
+ new A1Struct().A1Method();
+ new B1Struct().B1Method();
+ new C1Struct().C1Method();
+ cpp17_nested_namespaces.createA1Struct().A1Method();
+ cpp17_nested_namespaces.createB1Struct().B1Method();
+ cpp17_nested_namespaces.createC1Struct().C1Method();
+
+ new B2Struct().B2Method();
+ new C2Struct().C2Method();
+ cpp17_nested_namespaces.createB2Struct().B2Method();
+ cpp17_nested_namespaces.createC2Struct().C2Method();
+
+ new B3Struct().B3Method();
+ new C3Struct().C3Method();
+ cpp17_nested_namespaces.createB3Struct().B3Method();
+ cpp17_nested_namespaces.createC3Struct().C3Method();
+ }
+}
diff --git a/Examples/test-suite/csharp/cpp17_nspace_nested_namespaces_runme.cs b/Examples/test-suite/csharp/cpp17_nspace_nested_namespaces_runme.cs
new file mode 100644
index 000000000..61a8287f4
--- /dev/null
+++ b/Examples/test-suite/csharp/cpp17_nspace_nested_namespaces_runme.cs
@@ -0,0 +1,25 @@
+using System;
+using cpp17_nspace_nested_namespacesNamespace;
+
+public class cpp17_nspace_nested_namespaces_runme
+{
+ static void Main()
+ {
+ new cpp17_nspace_nested_namespacesNamespace.A1.A1Struct().A1Method();
+ new cpp17_nspace_nested_namespacesNamespace.A1.B1.B1Struct().B1Method();
+ new cpp17_nspace_nested_namespacesNamespace.A1.B1.C1.C1Struct().C1Method();
+ cpp17_nspace_nested_namespaces.createA1Struct().A1Method();
+ cpp17_nspace_nested_namespaces.createB1Struct().B1Method();
+ cpp17_nspace_nested_namespaces.createC1Struct().C1Method();
+
+ new cpp17_nspace_nested_namespacesNamespace.A2.B2.B2Struct().B2Method();
+ new cpp17_nspace_nested_namespacesNamespace.A2.B2.C2.C2Struct().C2Method();
+ cpp17_nspace_nested_namespaces.createB2Struct().B2Method();
+ cpp17_nspace_nested_namespaces.createC2Struct().C2Method();
+
+ new cpp17_nspace_nested_namespacesNamespace.A3.B3.B3Struct().B3Method();
+ new cpp17_nspace_nested_namespacesNamespace.A3.B3.C3.C3Struct().C3Method();
+ cpp17_nspace_nested_namespaces.createB3Struct().B3Method();
+ cpp17_nspace_nested_namespaces.createC3Struct().C3Method();
+ }
+}
diff --git a/Examples/test-suite/csharp/csharp_director_typemaps_runme.cs b/Examples/test-suite/csharp/csharp_director_typemaps_runme.cs
new file mode 100644
index 000000000..6143332db
--- /dev/null
+++ b/Examples/test-suite/csharp/csharp_director_typemaps_runme.cs
@@ -0,0 +1,53 @@
+
+using System;
+using System.Reflection;
+using csharp_director_typemapsNamespace;
+
+public class csharp_director_typemaps_runme {
+
+ class CSharpDirectorTypemaps_InStreamDerived : InStream
+ {
+ private int constant;
+ public CSharpDirectorTypemaps_InStreamDerived(int constant) { this.constant = constant; }
+ public override int Read(global::System.IntPtr buf, int len, out int readLen) {
+ readLen = (buf == global::System.IntPtr.Zero) ? -len - constant : len + constant;
+ return readLen;
+ }
+ public override int Write(global::System.IntPtr buf, int len, out int writeLen) {
+ writeLen = (buf == global::System.IntPtr.Zero) ? -len - constant : len + constant;
+ return writeLen;
+ }
+ }
+ public static void Main() {
+ int outLen = -1;
+ int k = 100;
+ int j = 23;
+ InStream instream = new CSharpDirectorTypemaps_InStreamDerived(k);
+
+ {
+ int ret = csharp_director_typemaps.callRead(instream, InStream.getCPtr(instream).Handle, j, out outLen);
+ Assert(outLen, j + k);
+ Assert(ret, j + k);
+ }
+ {
+ int ret = csharp_director_typemaps.callRead(instream, global::System.IntPtr.Zero, j, out outLen);
+ Assert(outLen, -j - k);
+ Assert(ret, -j - k);
+ }
+
+ {
+ int ret = csharp_director_typemaps.callWrite(instream, InStream.getCPtr(instream).Handle, j, out outLen);
+ Assert(outLen, j + k);
+ Assert(ret, j + k);
+ }
+ {
+ int ret = csharp_director_typemaps.callWrite(instream, global::System.IntPtr.Zero, j, out outLen);
+ Assert(outLen, -j - k);
+ Assert(ret, -j - k);
+ }
+ }
+ private static void Assert(int i1, int i2) {
+ if (i1 != i2)
+ throw new Exception("assertion failure. " + i1 + " != " + i2);
+ }
+}
diff --git a/Examples/test-suite/csharp/csharp_lib_arrays_bool_runme.cs b/Examples/test-suite/csharp/csharp_lib_arrays_bool_runme.cs
new file mode 100644
index 000000000..3b19b576f
--- /dev/null
+++ b/Examples/test-suite/csharp/csharp_lib_arrays_bool_runme.cs
@@ -0,0 +1,90 @@
+using System;
+using csharp_lib_arrays_boolNamespace;
+
+public class runme
+{
+ static void Main()
+ {
+ {
+ bool[] source = { true, false, false, true, false, true, true, false };
+ bool[] target = new bool[ source.Length ];
+
+ csharp_lib_arrays_bool.myArrayCopyUsingFixedArraysBool( source, target, target.Length );
+ CompareArrays(source, target, "bool[] INPUT/OUTPUT Fixed");
+ }
+
+ {
+ bool[] source = { true, false, false, true, false, true, true, false };
+ bool[] target = { false, true, true, false, true, false, false, true };
+
+ csharp_lib_arrays_bool.myArraySwapUsingFixedArraysBool( source, target, target.Length );
+
+ for (int i=0; i<target.Length; ++i)
+ target[i] = !target[i];
+
+ CompareArrays(source, target, "bool[] INOUT");
+ }
+
+ if( runtimeIsMono() )
+ {
+// Console.Error.WriteLine("Tests are running on mono, failing bool[] tests skipped");
+// See Mono bug report https://github.com/mono/mono/issues/15592
+ return;
+ }
+
+ {
+ bool[] source = { true, false, false, true, false, true, true, false };
+ bool[] target = new bool[ source.Length ];
+
+ if( !csharp_lib_arrays_bool.checkBoolArrayCorrect( source, source.Length ) )
+ {
+ throw new Exception("bool[] INPUT incorrect");
+ }
+
+ csharp_lib_arrays_bool.myArrayCopyBool( source, target, target.Length );
+ CompareArrays(source, target, "bool[] INPUT/OUTPUT");
+ }
+
+ {
+ bool[] source = { true, false, false, true, false, true, true, false };
+ bool[] target = { false, true, true, false, true, false, false, true };
+
+ csharp_lib_arrays_bool.myArraySwapBool( source, target, target.Length );
+
+ for (int i=0; i<target.Length; ++i)
+ target[i] = !target[i];
+
+ CompareArrays(source, target, "bool[] INOUT");
+ }
+ }
+
+ static void CompareArrays<T>( T[] a, T[] b, string testName )
+ {
+ if (a.Length != b.Length)
+ throw new Exception("size mismatch");
+
+ for(int i=0; i<a.Length; ++i) {
+ if (a[i].Equals(b[i]) == false) {
+ Console.Error.WriteLine("C# Array mismatch: " + testName);
+ Console.Error.WriteLine("a:");
+ PrintArray(a);
+ Console.Error.WriteLine("b:");
+ PrintArray(b);
+ throw new Exception("element mismatch");
+ }
+ }
+ }
+
+ static void PrintArray<T>( T[] a )
+ {
+ foreach ( T i in a )
+ Console.Error.Write( "{0} ", i );
+ Console.Error.WriteLine();
+ }
+
+ static bool runtimeIsMono()
+ {
+ return Type.GetType ("Mono.Runtime") != null;
+ }
+}
+
diff --git a/Examples/test-suite/csharp/director_basic_runme.cs b/Examples/test-suite/csharp/director_basic_runme.cs
index b9916108c..de299b145 100644
--- a/Examples/test-suite/csharp/director_basic_runme.cs
+++ b/Examples/test-suite/csharp/director_basic_runme.cs
@@ -48,6 +48,36 @@ public class runme
if (myNewBar == null)
throw new Exception("non-null pointer marshalling problem");
myNewBar.x = 10;
+
+ // Low level implementation check
+// my.testSwigDerivedClassHasMethod();
+
+ // These should not call the C# implementations as they are not overridden
+ int v;
+ v = MyClass.call_nonVirtual(my);
+ if (v != 100) throw new Exception("call_nonVirtual broken() " + v);
+
+ v = MyClass.call_nonOverride(my);
+ if (v != 101) throw new Exception("call_nonOverride broken() " + v);
+
+ // A mix of overridden and non-overridden
+ MyClassEnd myend = new MyClassEnd();
+ MyClass mc = myend;
+
+ v = mc.nonVirtual();
+ if (v != 202) throw new Exception("mc.nonVirtual() broken " + v);
+
+ v = MyClass.call_nonVirtual(mc);
+ if (v != 202) throw new Exception("call_nonVirtual(mc) broken " + v);
+
+ v = MyClass.call_nonVirtual(myend);
+ if (v != 202) throw new Exception("call_nonVirtual(myend) broken" + v);
+
+ v = MyClass.call_nonOverride(mc);
+ if (v != 101) throw new Exception("call_nonOverride(mc) broken" + v);
+
+ v = MyClass.call_nonOverride(myend);
+ if (v != 101) throw new Exception("call_nonOverride(myend) broken" + v);
}
}
}
@@ -69,6 +99,30 @@ class MyOverriddenClass : MyClass {
throw new Exception("null not received as expected");
return b;
}
+
+ public new bool nonVirtual() {
+ throw new Exception("non-virtual overrides virtual method");
+ }
+
+ public new virtual bool nonOverride() {
+ throw new Exception("non-override overrides virtual method");
+ }
+}
+
+class MyClassMiddle : MyClass {
+ public override int nonVirtual() {
+ return 202;
+ }
+}
+
+class MyClassEnd : MyClassMiddle {
+ public new bool nonVirtual() {
+ throw new Exception("non-virtual overrides virtual method");
+ }
+
+ public new virtual bool nonOverride() {
+ throw new Exception("non-override overrides virtual method");
+ }
}
}
diff --git a/Examples/test-suite/csharp/director_classes_runme.cs b/Examples/test-suite/csharp/director_classes_runme.cs
index 112561464..700492fb1 100644
--- a/Examples/test-suite/csharp/director_classes_runme.cs
+++ b/Examples/test-suite/csharp/director_classes_runme.cs
@@ -16,6 +16,7 @@ Expected output if PrintDebug enabled:
Base - Val(444.555)
Base - Ref(444.555)
Base - Ptr(444.555)
+Base - ConstPtrRef(444.555)
Base - FullyOverloaded(int 10)
Base - FullyOverloaded(bool 1)
Base - SemiOverloaded(int -678)
@@ -26,6 +27,7 @@ Base - DefaultParms(10, 1.1)
Derived - Val(444.555)
Derived - Ref(444.555)
Derived - Ptr(444.555)
+Derived - ConstPtrRef(444.555)
Derived - FullyOverloaded(int 10)
Derived - FullyOverloaded(bool 1)
Derived - SemiOverloaded(int -678)
@@ -36,6 +38,7 @@ Derived - DefaultParms(10, 1.1)
CSharpDerived - Val(444.555)
CSharpDerived - Ref(444.555)
CSharpDerived - Ptr(444.555)
+CSharpDerived - ConstPtrRef(444.555)
CSharpDerived - FullyOverloaded(int 10)
CSharpDerived - FullyOverloaded(bool True)
CSharpDerived - SemiOverloaded(-678)
@@ -59,7 +62,7 @@ public class runme
void run()
{
- if (director_classes.PrintDebug) Console.WriteLine("------------ Start ------------ ");
+ if (director_classes.PrintDebug) Console.WriteLine("------------ Start ------------");
Caller myCaller = new Caller();
@@ -85,7 +88,7 @@ public class runme
makeCalls(myCaller, myBase);
}
- if (director_classes.PrintDebug) Console.WriteLine("------------ Finish ------------ ");
+ if (director_classes.PrintDebug) Console.WriteLine("------------ Finish ------------");
}
void makeCalls(Caller myCaller, Base myBase)
@@ -99,6 +102,7 @@ public class runme
if (myCaller.ValCall(dh).val != dh.val) throw new Exception("failed");
if (myCaller.RefCall(dh).val != dh.val) throw new Exception("failed");
if (myCaller.PtrCall(dh).val != dh.val) throw new Exception("failed");
+ if (myCaller.ConstPtrRefCall(dh).val != dh.val) throw new Exception("failed");
// Fully overloaded method test (all methods in base class are overloaded)
if (NAMESPACE + myCaller.FullyOverloadedCall(10) != myBase.GetType() + "::FullyOverloaded(int)") throw new Exception("failed");
@@ -142,6 +146,11 @@ public class CSharpDerived : Base
if (director_classes.PrintDebug) Console.WriteLine("CSharpDerived - Ptr({0})", x.val);
return x;
}
+ public override DoubleHolder ConstPtrRef(DoubleHolder x)
+ {
+ if (director_classes.PrintDebug) Console.WriteLine("CSharpDerived - ConstPtrRef({0})", x.val);
+ return x;
+ }
public override String FullyOverloaded(int x)
{
if (director_classes.PrintDebug) Console.WriteLine("CSharpDerived - FullyOverloaded(int {0})", x);
diff --git a/Examples/test-suite/csharp/director_smartptr_runme.cs b/Examples/test-suite/csharp/director_smartptr_runme.cs
index 559dff7a0..33037a1da 100644
--- a/Examples/test-suite/csharp/director_smartptr_runme.cs
+++ b/Examples/test-suite/csharp/director_smartptr_runme.cs
@@ -26,6 +26,29 @@ public class runme
}
}
+ private class director_smartptr_MyBarFooDerived : FooDerived
+ {
+ public override string ping()
+ {
+ return "director_smartptr_MyBarFooDerived.ping()";
+ }
+
+ public override string pong()
+ {
+ return "director_smartptr_MyBarFooDerived.pong();" + ping();
+ }
+
+ public override string upcall(FooBar fooBarPtr)
+ {
+ return "overrideDerived;" + fooBarPtr.FooBarDo();
+ }
+
+ public override Foo makeFoo()
+ {
+ return new Foo();
+ }
+ }
+
private static void check(string got, string expected)
{
if (got != expected)
@@ -49,5 +72,11 @@ public class runme
Foo myFoo2 = new Foo().makeFoo();
check(myFoo2.pong(), "Foo::pong();Foo::ping()");
check(Foo.callPong(myFoo2), "Foo::pong();Foo::ping()");
+
+ FooDerived myBarFooDerived = new director_smartptr_MyBarFooDerived();
+ check(myBarFooDerived.ping(), "director_smartptr_MyBarFooDerived.ping()");
+ check(FooDerived.callPong(myBarFooDerived), "director_smartptr_MyBarFooDerived.pong();director_smartptr_MyBarFooDerived.ping()");
+ check(FooDerived.callUpcall(myBarFooDerived, fooBar), "overrideDerived;Bar::Foo2::Foo2Bar()");
+
}
}
diff --git a/Examples/test-suite/csharp/director_void_runme.cs b/Examples/test-suite/csharp/director_void_runme.cs
index 24b470f11..ef440a76a 100644
--- a/Examples/test-suite/csharp/director_void_runme.cs
+++ b/Examples/test-suite/csharp/director_void_runme.cs
@@ -67,6 +67,12 @@ public class runme
if (x != 1334)
throw new Exception("Bad4 should be 1334, got " + x);
}
+ {
+ MemberVoid mv = new MemberVoid();
+ global::System.IntPtr zero = global::System.IntPtr.Zero;
+ mv.memberVariable = zero;
+ zero = mv.memberVariable;
+ }
}
}
diff --git a/Examples/test-suite/csharp/li_boost_shared_ptr_director_runme.cs b/Examples/test-suite/csharp/li_boost_shared_ptr_director_runme.cs
new file mode 100644
index 000000000..0a03b7f10
--- /dev/null
+++ b/Examples/test-suite/csharp/li_boost_shared_ptr_director_runme.cs
@@ -0,0 +1,111 @@
+using System;
+using li_boost_shared_ptr_directorNamespace;
+
+public class li_boost_shared_ptr_director_runme {
+
+ private static void check(int got, int expected) {
+ if (got != expected)
+ throw new Exception("Failed, got: " + got + " expected: " + expected);
+ }
+
+ public static void Main() {
+ Derived a = new Derived(false);
+ Derived b = new Derived(true);
+
+ check(li_boost_shared_ptr_director.call_ret_c_shared_ptr(a), 1);
+ check(li_boost_shared_ptr_director.call_ret_c_shared_ptr(b), -1);
+ check(li_boost_shared_ptr_director.call_ret_c_by_value(a), 1);
+
+ check(li_boost_shared_ptr_director.call_ret_c_shared_ptr(a), 1);
+ check(li_boost_shared_ptr_director.call_ret_c_shared_ptr(b), -1);
+ check(li_boost_shared_ptr_director.call_ret_c_by_value(a), 1);
+
+ check(li_boost_shared_ptr_director.call_take_c_by_value(a), 5);
+ check(li_boost_shared_ptr_director.call_take_c_by_ref(a), 6);
+ check(li_boost_shared_ptr_director.call_take_c_by_pointer(a), 7);
+ check(li_boost_shared_ptr_director.call_take_c_by_pointer_ref(a), 8);
+ check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_value(a), 9);
+ check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_ref(a), 10);
+ check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_pointer(a), 11);
+ check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_pointer_ref(a), 12);
+
+ check(li_boost_shared_ptr_director.call_take_c_by_pointer_with_null(a), -2);
+ check(li_boost_shared_ptr_director.call_take_c_by_pointer_ref_with_null(a), -3);
+ check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_value_with_null(a), -4);
+ check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_ref_with_null(a), -5);
+ check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_pointer_with_null(a), -6);
+ check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_pointer_ref_with_null(a), -7);
+ }
+
+}
+
+class Derived : Base {
+
+ private bool return_none;
+
+ public Derived(bool flag) : base() {
+ this.return_none = flag;
+ }
+
+ public override C ret_c_shared_ptr() {
+ if (this.return_none)
+ return null;
+ else
+ return new C();
+ }
+
+ public override C ret_c_by_value() {
+ return new C();
+ }
+
+ public override int take_c_by_value(C c) {
+ return c.get_m();
+ }
+
+ public override int take_c_by_ref(C c) {
+ return c.get_m();
+ }
+
+ public override int take_c_by_pointer(C c) {
+ if (c != null)
+ return c.get_m();
+ else
+ return -2;
+ }
+
+ public override int take_c_by_pointer_ref(C c) {
+ if (c != null)
+ return c.get_m();
+ else
+ return -3;
+ }
+
+ public override int take_c_shared_ptr_by_value(C c) {
+ if (c != null)
+ return c.get_m();
+ else
+ return -4;
+ }
+
+ public override int take_c_shared_ptr_by_ref(C c) {
+ if (c != null)
+ return c.get_m();
+ else
+ return -5;
+ }
+
+ public override int take_c_shared_ptr_by_pointer(C c) {
+ if (c != null)
+ return c.get_m();
+ else
+ return -6;
+ }
+
+ public override int take_c_shared_ptr_by_pointer_ref(C c) {
+ if (c != null)
+ return c.get_m();
+ else
+ return -7;
+ }
+
+}
diff --git a/Examples/test-suite/csharp/li_std_auto_ptr_runme.cs b/Examples/test-suite/csharp/li_std_auto_ptr_runme.cs
index 1f66042a6..863b86701 100644
--- a/Examples/test-suite/csharp/li_std_auto_ptr_runme.cs
+++ b/Examples/test-suite/csharp/li_std_auto_ptr_runme.cs
@@ -19,6 +19,13 @@ public class li_std_auto_ptr_runme {
if (Klass.getTotal_count() != 2)
throw new Exception("number of objects should be 2");
+ using (Klass k3 = li_std_auto_ptr.makeKlassAutoPtr("second")) {
+ if (Klass.getTotal_count() != 3)
+ throw new Exception("number of objects should be 3");
+ }
+ if (Klass.getTotal_count() != 2)
+ throw new Exception("number of objects should be 2");
+
k1 = null;
{
int countdown = 500;
diff --git a/Examples/test-suite/csharp/li_std_list_runme.cs b/Examples/test-suite/csharp/li_std_list_runme.cs
new file mode 100644
index 000000000..1a5b1562d
--- /dev/null
+++ b/Examples/test-suite/csharp/li_std_list_runme.cs
@@ -0,0 +1,402 @@
+using System;
+using li_std_listNamespace;
+
+public class li_std_list_runme {
+ private static readonly int collectionSize = 20;
+
+ public static void Main() {
+ // Setup a list of int
+ IntList list = new IntList();
+ IntList.IntListNode node;
+
+ for (int i = 0; i < 20; i++) {
+ int nb = i * 10;
+ list.Add(nb);
+ }
+
+ // Count property test
+ if (list.Count != collectionSize)
+ throw new Exception("Count test failed");
+
+ // IsReadOnly property test
+ if (list.IsReadOnly)
+ throw new Exception("IsReadOnly test failed");
+
+ // Contains method test
+ if (!list.Contains(0))
+ throw new Exception("Contains method test 1 failed");
+ if (!list.Contains(2 * 10))
+ throw new Exception("Contains method test 2 failed");
+ if (!list.Contains(19 * 10))
+ throw new Exception("Contains method test 3 failed");
+ if (list.Contains(20 * 10))
+ throw new Exception("Contains method test 4 failed");
+
+ // Nodes comparison method overload
+ {
+ IntList.IntListNode temp = new IntList.IntListNode(3);
+ if (list.First == temp)
+ throw new Exception("== overload method test (1) failed");
+ temp = new IntList.IntListNode(0);
+ if (list.First == temp)
+ throw new Exception("== overload method test (2) failed");
+ IntList.IntListNode temp2 = new IntList.IntListNode(0);
+ if (temp == temp2)
+ throw new Exception("== overload method test (3) failed");
+ if (!(list.First == list.First))
+ throw new Exception("== overload method test (4) failed");
+ if (list.First != list.First)
+ throw new Exception("!= overload method test (1) failed");
+ if (!(temp != temp2))
+ throw new Exception("!= overload method test (2) failed");
+ if (list.First.Equals(temp))
+ throw new Exception("Equals method test failed");
+ if (list.First.GetHashCode() == temp.GetHashCode())
+ throw new Exception("GetHashCode method test (1) failed");
+ if (list.First.GetHashCode() == list.First.GetHashCode())
+ throw new Exception("GetHashCode method test (2) failed");
+
+ }
+
+ // Getter test
+ {
+ if (list.First == null)
+ throw new Exception("First getter test (1) failed");
+ if (list.Last == null)
+ throw new Exception("Last getter test (1) failed");
+ if (list.Last.Next != null)
+ throw new Exception("Next getter test (1) failed");
+ if (list.First.Next == null)
+ throw new Exception("Next getter test (2) failed");
+ if (list.First.Previous != null)
+ throw new Exception("Previous getter test (1) failed");
+ if (list.Last.Previous == null)
+ throw new Exception("Previous getter test (2) failed");
+ }
+
+ // AddFirst method test
+ node = list.AddFirst(34);
+ if (list.First.Value != 34 || node.Value != 34 || node != list.First)
+ throw new Exception("AddFirst method test failed");
+ try {
+ list.AddFirst(null);
+ } catch (ArgumentNullException) {
+ try {
+ list.AddFirst(list.First);
+ } catch (InvalidOperationException) {
+ }
+ }
+
+ // RemoveFirst method test
+ int tmp = list.First.Value;
+ list.RemoveFirst();
+ if (list.First.Value == tmp || list.First.Value != 0 * 10)
+ throw new Exception("RemoveFirst method test failed");
+
+ // AddLast method test
+ node = list.AddLast(8);
+ if (list.Last.Value != 8 || node.Value != 8 || node != list.Last)
+ throw new Exception("AddLast method test failed");
+ try {
+ list.AddLast(null);
+ } catch (ArgumentNullException) {
+ try {
+ list.AddLast(list.First);
+ } catch (InvalidOperationException) {
+ }
+ }
+
+ // RemoveLast method test
+ int tmp2 = list.Last.Value;
+ list.RemoveLast();
+ if (list.Last.Value == tmp2 || list.Last.Value != (list.Count - 1) * 10)
+ throw new Exception("RemoveLast method test failed");
+
+ // AddBefore method test
+ node = list.AddBefore(list.Last, 17);
+ if (list.Last.Previous.Value != 17 || node.Value != 17 || node != list.Last.Previous)
+ throw new Exception("AddBefore method test (1) failed");
+ try {
+ node = null;
+ list.AddBefore(list.Last, node);
+ throw new Exception("AddBefore method test (2) failed");
+ } catch (ArgumentNullException) {
+ try {
+ node = new IntList.IntListNode(1);
+ list.AddBefore(null, node);
+ throw new Exception("AddBefore method test (3) failed");
+ } catch (ArgumentNullException) {
+ try {
+ list.AddBefore(list.Last, list.First);
+ } catch (InvalidOperationException) {
+ }
+ }
+ }
+
+ // AddAfter method test
+ node = list.AddAfter(list.First, 47);
+ if (list.First.Next.Value != 47 || node.Value != 47 || node != list.First.Next)
+ throw new Exception("AddAfter method test (1) failed");
+ try {
+ node = null;
+ list.AddAfter(list.First.Next, node);
+ throw new Exception("AddAfter method test (2) failed");
+ } catch (ArgumentNullException) {
+ try {
+ list.AddAfter(list.First, list.Last);
+ } catch (InvalidOperationException) {
+ }
+ }
+
+ // Find method test
+ node = list.Find(0);
+ if (node == null || node.Value != 0)
+ throw new Exception("Find method test (1) failed");
+ node = list.Find(47);
+ if (node == null || node.Value != 47)
+ throw new Exception("Find method test (2) failed");
+ node = list.Find(190);
+ if (node == null || node.Value != 190)
+ throw new Exception("Find method test (3) failed");
+ node = list.Find(-3);
+ if (node != null)
+ throw new Exception("Find method test (4) failed");
+
+ // Remove method test
+ if (!list.Remove(17) || list.Contains(17) || list.Last.Previous.Value == 17)
+ throw new Exception("Remove method test (1) failed");
+ if (!list.Remove(47) || list.Contains(47) || list.First.Next.Value == 47)
+ throw new Exception("Remove method test (2) failed");
+ if (!list.Remove(0) || list.Contains(0) || list.First.Value == 0)
+ throw new Exception("Remove method test (3) failed");
+ if (!list.Remove(190) || list.Contains(190) || list.Last.Value == 190)
+ throw new Exception("Remove method test (4) failed");
+ try {
+ node = null;
+ list.Remove(node);
+ throw new Exception("Remove method test (5) failed");
+ } catch (ArgumentNullException) {
+ try {
+ node = new IntList.IntListNode(4);
+ list.Remove(node);
+ throw new Exception("Remove method test (5) failed");
+ } catch (InvalidOperationException) {
+ }
+ }
+
+ // ICollection constructor test
+ {
+ int[] intArray = new int[] { 0, 11, 22, 33, 44, 55, 33 };
+ IntList il = new IntList(intArray);
+ if (intArray.Length != il.Count)
+ throw new Exception("ICollection constructor length check failed: " + intArray.Length + "-" + il.Count);
+ node = il.First;
+ for (int i = 0; i < intArray.Length; i++) {
+ if (intArray[i] != node.Value)
+ throw new Exception("ICollection constructor failed, index:" + i);
+ node = node.Next;
+ }
+ try {
+ new IntList((System.Collections.ICollection)null);
+ throw new Exception("ICollection constructor null test failed");
+ } catch (ArgumentNullException) {
+ }
+ }
+
+ // Enumerator test
+ {
+ node = list.First;
+ System.Collections.IEnumerator myEnumerator = list.GetEnumerator();
+ while (myEnumerator.MoveNext()) {
+ if ((int)myEnumerator.Current != node.Value)
+ throw new Exception("Enumerator (1) test failed");
+ node = node.Next;
+ }
+ }
+ {
+ node = list.First;
+ System.Collections.Generic.IEnumerator<int> myEnumerator = list.GetEnumerator();
+ while (myEnumerator.MoveNext()) {
+ if (myEnumerator.Current != node.Value)
+ throw new Exception("Enumerator (2) test failed");
+ node = node.Next;
+ }
+ }
+ {
+ node = list.First;
+ IntList.IntListEnumerator myEnumerator = list.GetEnumerator();
+ while (myEnumerator.MoveNext()) {
+ if (myEnumerator.Current != node.Value)
+ throw new Exception("Enumerator (3) test failed");
+ node = node.Next;
+ }
+ }
+ {
+ node = list.First;
+ foreach (var elem in list) {
+ if (elem != node.Value)
+ throw new Exception("Enumerator (4) test failed");
+ node = node.Next;
+ }
+ }
+
+ // CopyTo method test
+ {
+ int[] outputarray = new int[collectionSize - 2];
+ list.CopyTo(outputarray, 0);
+ int index = 0;
+ IntList.IntListNode temp = list.First;
+ foreach (int val in outputarray) {
+ if (temp.Value != val) {
+ throw new Exception("CopyTo method test (1) failed, index:" + index);
+ }
+ index++;
+ temp = temp.Next;
+ }
+ }
+ {
+ DoubleList inputlist = new DoubleList();
+ int arrayLen = 10;
+ for (int i = 0; i < arrayLen; i++) {
+ double num = i * 10.1;
+ inputlist.Add(num);
+ }
+ double[] outputarray = new double[arrayLen];
+ inputlist.CopyTo(outputarray, 0);
+ DoubleList.DoubleListNode temp = inputlist.First;
+ for (int i = 0; i < arrayLen; i++) {
+ if (outputarray[i] != temp.Value)
+ throw new Exception("CopyTo method test (2) failed, index:" + i);
+ temp = temp.Next;
+ }
+ }
+ {
+ StructList inputlist = new StructList();
+ int arrayLen = 10;
+ for (int i = 0; i < arrayLen; i++)
+ inputlist.Add(new Struct(i / 10.0));
+ Struct[] outputarray = new Struct[arrayLen];
+ inputlist.CopyTo(outputarray, 0);
+ StructList.StructListNode temp = inputlist.First;
+ for (int i = 0; i < arrayLen; i++) {
+ if (outputarray[i].num != temp.Value.num)
+ throw new Exception("CopyTo method test (3) failed, index:" + i);
+ temp = temp.Next;
+ }
+ foreach (Struct s in inputlist) {
+ s.num += 20.0;
+ }
+ temp = inputlist.First;
+ for (int i = 0; i < arrayLen; i++) {
+ if (outputarray[i].num != temp.Value.num)
+ throw new Exception("CopyTo method test (4) failed, index:" + i);
+ temp = temp.Next;
+ }
+ }
+ try {
+ list.CopyTo(null, 0);
+ throw new Exception("CopyTo method test (5) failed");
+ } catch (ArgumentNullException) {
+ }
+
+ // Clear() test
+ list.Clear();
+ if (list.Count != 0)
+ throw new Exception("Clear method failed");
+
+ // Finally test the methods being wrapped
+ {
+ IntList il = new IntList();
+ for (int i = 0; i < 4; i++) {
+ il.Add(i);
+ }
+
+ double x = li_std_list.average(il);
+ x += li_std_list.average(new IntList(new int[] { 1, 2, 3, 4 }));
+
+ DoubleList dlist = new DoubleList();
+ for (int i = 0; i < 10; i++) {
+ dlist.Add(i / 2.0);
+ }
+ li_std_list.halve_in_place(dlist);
+ }
+
+ // Dispose()
+ {
+ using (StructList ls = new StructList(new Struct[] { new Struct(0.0), new Struct(11.1) }))
+ using (DoubleList ld = new DoubleList(new double[] { 0.0, 11.1 })) { }
+ }
+
+ // More wrapped methods
+ {
+ FloatList l0 = li_std_list.listreal(new FloatList());
+ float flo = 123.456f;
+ l0.Add(flo);
+ flo = l0.First.Value;
+
+ IntList l1 = li_std_list.listint(new IntList());
+ IntPtrList l2 = li_std_list.listintptr(new IntPtrList());
+ IntConstPtrList l3 = li_std_list.listintconstptr(new IntConstPtrList());
+
+ l1.Add(123);
+ l2.Clear();
+ l3.Clear();
+
+ StructList l4 = li_std_list.liststruct(new StructList());
+ StructPtrList l5 = li_std_list.liststructptr(new StructPtrList());
+ StructConstPtrList l6 = li_std_list.liststructconstptr(new StructConstPtrList());
+
+ l4.Add(new Struct(123));
+ l5.Add(new Struct(123));
+ l6.Add(new Struct(123));
+ }
+
+ // Test lists of pointers
+ {
+ StructPtrList inputlist = new StructPtrList();
+ int arrayLen = 10;
+ for (int i = 0; i < arrayLen; i++) {
+ inputlist.Add(new Struct(i / 10.0));
+ }
+ Struct[] outputarray = new Struct[arrayLen];
+ inputlist.CopyTo(outputarray, 0);
+ StructPtrList.StructPtrListNode temp = inputlist.First;
+ for (int i = 0; i < arrayLen; i++) {
+ if (outputarray[i].num != temp.Value.num)
+ throw new Exception("StructPtrList test (1) failed, i:" + i);
+ temp = temp.Next;
+ }
+ foreach (Struct s in inputlist) {
+ s.num += 20.0;
+ }
+ for (int i = 0; i < arrayLen; i++) {
+ if (outputarray[i].num != 20.0 + i / 10.0)
+ throw new Exception("StructPtrList test (2) failed (a deep copy was incorrectly made), i:" + i);
+ }
+ }
+
+ // Test lists of const pointers
+ {
+ StructConstPtrList inputlist = new StructConstPtrList();
+ int arrayLen = 10;
+ for (int i = 0; i < arrayLen; i++) {
+ inputlist.Add(new Struct(i / 10.0));
+ }
+ Struct[] outputarray = new Struct[arrayLen];
+ inputlist.CopyTo(outputarray, 0);
+ StructConstPtrList.StructConstPtrListNode temp = inputlist.First;
+ for (int i = 0; i < arrayLen; i++) {
+ if (outputarray[i].num != temp.Value.num)
+ throw new Exception("StructConstPtrList test (1) failed, i:" + i);
+ temp = temp.Next;
+ }
+ foreach (Struct s in inputlist) {
+ s.num += 20.0;
+ }
+ for (int i = 0; i < arrayLen; i++) {
+ if (outputarray[i].num != 20.0 + i / 10.0)
+ throw new Exception("StructConstPtrList test (2) failed (a deep copy was incorrectly made), i:" + i);
+ }
+ }
+ }
+}
diff --git a/Examples/test-suite/csharp/li_std_map_runme.cs b/Examples/test-suite/csharp/li_std_map_runme.cs
index 0fe1ab5cd..51510c9fc 100644
--- a/Examples/test-suite/csharp/li_std_map_runme.cs
+++ b/Examples/test-suite/csharp/li_std_map_runme.cs
@@ -18,7 +18,7 @@ public class li_std_map_runme {
public static void Main()
{
- // Set up an int int map
+ // Set up an string to int map
StringIntMap simap = new StringIntMap();
for (int i = 0; i < collectionSize; i++)
{
@@ -240,6 +240,20 @@ public class li_std_map_runme {
throw new Exception("Key test (2) on complex key map failed");
}
+ // Custom compare function
+ {
+ StringLengthNumberMap slmap = new StringLengthNumberMap();
+ li_std_map.populate(slmap);
+
+ string keys = string.Join(" ", new List<string>(slmap.Keys));
+ if (keys != "a aa zzz xxxx aaaaa")
+ throw new Exception("Keys are wrong or in wrong order: " + keys);
+
+ string values = string.Join(" ", new List<int>(slmap.Values));
+ if (values != "1 2 3 4 5")
+ throw new Exception("Values are wrong or in wrong order: " + values);
+ }
+
// All done
}
}
diff --git a/Examples/test-suite/csharp/li_std_set_runme.cs b/Examples/test-suite/csharp/li_std_set_runme.cs
new file mode 100644
index 000000000..e9cd2c271
--- /dev/null
+++ b/Examples/test-suite/csharp/li_std_set_runme.cs
@@ -0,0 +1,105 @@
+using System;
+using System.Collections.Generic;
+using li_std_setNamespace;
+
+public class runme
+{
+ static void checkThat(bool mustBeTrue, string message)
+ {
+ if (!mustBeTrue)
+ throw new Exception("Test that the set " + message + " failed");
+ }
+
+ static void Main()
+ {
+ StringSet ss = new StringSet();
+
+ // Check the interface methods first.
+ ISet<string> s = ss;
+
+ checkThat(s.Count == 0, "is initially empty");
+ checkThat(!s.Contains("key"), "doesn't contain inexistent element");
+ checkThat(!s.Remove("key"), "returns false when removing inexistent element");
+
+ checkThat(s.Add("key"), "returns true when adding a new element");
+ checkThat(!s.Add("key"), "returns false when adding an existing element");
+ checkThat(s.Contains("key"), "contains the just added element");
+ checkThat(s.Remove("key"), "returns true when removing an existing element");
+ checkThat(s.Count == 0, "is empty again");
+
+ checkThat(s.Add("key1"), "Add(key1) returns true");
+ checkThat(s.Add("key2"), "Add(key2) returns true");
+ checkThat(s.Add("key3"), "Add(key3) returns true");
+
+ // Also check a different interface, providing a different Add() (sic!).
+ ICollection<string> coll = ss;
+ coll.Add("key");
+ checkThat(ss.Count == 4, "contains 4 elements");
+
+ // Now use object-specific methods, mimicking HashSet<>.
+ string val;
+ checkThat(ss.TryGetValue("key1", out val), "could retrieve existing item");
+ checkThat(val.Equals("key1"), "value was returned correctly by TryGetValue()");
+ checkThat(!ss.TryGetValue("no-such-key", out val), "couldn't retrieve inexistent item");
+ checkThat(val == null, "value was reset after failed TryGetValue()");
+
+ IList<string> list = new List<string>();
+ foreach (string str in ss) {
+ list.Add(str);
+ }
+ checkThat(list.Count == 4, "copy contains 4 elements");
+
+ ss.Clear();
+ checkThat(ss.Count == 0, "is empty after Clear()");
+
+ // Check set-theoretic methods.
+ checkThat(new StringSet().SetEquals(new StringSet()), "SetEquals() works for empty sets");
+ checkThat(new StringSet{"foo"}.SetEquals(new StringSet{"foo"}), "SetEquals() works for non-empty sets");
+ checkThat(!new StringSet{"foo"}.SetEquals(new[] {"bar"}), "SetEquals() doesn't always return true");
+
+ ss = new StringSet{"foo", "bar", "baz"};
+ ss.ExceptWith(new[] {"baz", "quux"});
+ checkThat(ss.SetEquals(new[] {"foo", "bar"}), "ExceptWith works");
+
+ ss = new StringSet{"foo", "bar", "baz"};
+ ss.IntersectWith(new[] {"baz", "quux"});
+ checkThat(ss.SetEquals(new[] {"baz"}), "IntersectWith works");
+
+ checkThat(ss.IsProperSubsetOf(new[] {"bar", "baz"}), "IsProperSubsetOf works");
+ checkThat(!ss.IsProperSubsetOf(new[] {"baz"}), "!IsProperSubsetOf works");
+ checkThat(ss.IsSubsetOf(new[] {"bar", "baz"}), "IsSubsetOf works");
+ checkThat(!ss.IsSubsetOf(new[] {"bar"}), "!IsSubsetOf works");
+
+ ss = new StringSet{"foo", "bar", "baz"};
+ checkThat(ss.IsProperSupersetOf(new[] {"bar"}), "IsProperSupersetOf works");
+ checkThat(!ss.IsProperSupersetOf(new[] {"quux"}), "IsProperSupersetOf works");
+ checkThat(ss.IsSupersetOf(new[] {"foo", "bar", "baz"}), "IsProperSupersetOf works");
+ checkThat(!ss.IsSupersetOf(new[] {"foo", "bar", "baz", "quux"}), "IsProperSupersetOf works");
+
+ checkThat(ss.Overlaps(new[] {"foo"}), "Overlaps works");
+ checkThat(!ss.Overlaps(new[] {"moo"}), "!Overlaps works");
+
+ ss.SymmetricExceptWith(new[] {"baz", "quux"});
+ checkThat(ss.SetEquals(new[] {"foo", "bar", "quux"}), "SymmetricExceptWith works");
+
+ ss = new StringSet{"foo", "bar", "baz"};
+ ss.UnionWith(new[] {"baz", "quux"});
+ checkThat(ss.SetEquals(new[] {"foo", "bar", "baz", "quux"}), "UnionWith works");
+
+ // Check a set of another type.
+ FooSet fooSet = new FooSet();
+ ISet<Foo> fooISet = fooSet;
+ checkThat(fooISet.Count == 0, "is initially empty");
+ checkThat(fooISet.Add(new Foo(17)), "added successfully");
+ checkThat(fooISet.Count == 1, "is not empty any more");
+
+ // And a set of primitive type.
+ IntSet intSet = new IntSet();
+ checkThat(intSet.Count == 0, "is initially empty");
+ checkThat(intSet.Add(17), "17 added successfully");
+ checkThat(!intSet.Add(17), "17 not added again");
+ checkThat(intSet.Count == 1, "not empty any more");
+ checkThat(intSet.Add(289), "289 added successfully");
+ checkThat(intSet.Count == 2, "even less empty now");
+ }
+}
diff --git a/Examples/test-suite/csharp/li_std_vector_runme.cs b/Examples/test-suite/csharp/li_std_vector_runme.cs
index fa8700d89..0c6211ca5 100644
--- a/Examples/test-suite/csharp/li_std_vector_runme.cs
+++ b/Examples/test-suite/csharp/li_std_vector_runme.cs
@@ -121,7 +121,7 @@ public class li_std_vector_runme {
throw new Exception("Contains test 4 failed");
{
- // ICollection constructor
+ // IEnumerable constructor
double[] doubleArray = new double[] { 0.0, 11.1, 22.2, 33.3, 44.4, 55.5, 33.3 };
DoubleVector dv = new DoubleVector(doubleArray);
if (doubleArray.Length != dv.Count)
@@ -177,6 +177,17 @@ public class li_std_vector_runme {
if (doubleArray[i] != dvCopy[i])
throw new Exception("Copy constructor failed, index:" + i);
}
+ if (dvCopy.Count != doubleArray.Length)
+ throw new Exception("Copy constructor lengths mismatch");
+
+ // ToArray test
+ double[] dvArray = dv.ToArray();
+ for (int i=0; i<doubleArray.Length; i++) {
+ if (doubleArray[i] != dvArray[i])
+ throw new Exception("ToArray failed, index:" + i);
+ }
+ if (dvArray.Length != doubleArray.Length)
+ throw new Exception("ToArray lengths mismatch");
}
{
// Repeat() test
@@ -619,6 +630,55 @@ public class li_std_vector_runme {
}
}
+ // Test construction
+ {
+ string[] one_two_three = new string[] { "one", "two", "three" };
+
+ // Test construction from array
+ {
+ string[] collection = one_two_three;
+ check123(new StringVector(collection));
+ }
+
+ // Test construction from IEnumerable
+ {
+ global::System.Collections.IEnumerable collection = one_two_three;
+ check123(new StringVector(collection));
+ }
+
+ // Test construction from IEnumerable<>
+ {
+ global::System.Collections.Generic.IEnumerable<string> collection = one_two_three;
+ check123(new StringVector(collection));
+ }
+
+ // Test construction from IList<>
+ {
+ global::System.Collections.Generic.IList<string> collection = one_two_three;
+ check123(new StringVector(collection));
+ }
+
+ // Test construction from ICollection
+ {
+ global::System.Collections.ICollection collection = one_two_three;
+ check123(new StringVector(collection));
+ }
+
+ // Test construction from ICollection<>
+ {
+ global::System.Collections.Generic.ICollection<string> collection = new global::System.Collections.Generic.List<string>(one_two_three);
+ check123(new StringVector(collection));
+ }
+ }
+
+ }
+
+ private static void check123(StringVector stringv) {
+ string concatenated = "";
+ foreach (string s in stringv)
+ concatenated = concatenated + s;
+ if (concatenated != "onetwothree")
+ throw new Exception("concatenated string failed: " + concatenated);
}
}
diff --git a/Examples/test-suite/csharp/li_std_wstring_runme.cs b/Examples/test-suite/csharp/li_std_wstring_runme.cs
index fe663a3e0..d2927287f 100644
--- a/Examples/test-suite/csharp/li_std_wstring_runme.cs
+++ b/Examples/test-suite/csharp/li_std_wstring_runme.cs
@@ -3,74 +3,130 @@ using li_std_wstringNamespace;
public class runme
{
- static void Main()
+ static private void check_equal(char a, char b)
{
- char y='h';
-
- if (li_std_wstring.test_wcvalue(y) != y)
- throw new Exception("bad string mapping:" + li_std_wstring.test_wcvalue(y));
-
- if (li_std_wstring.test_wcvalue_w() != 'W')
- throw new Exception("bad string mapping:" + li_std_wstring.test_wcvalue_w());
-
- string x="hello";
-
- if (li_std_wstring.test_ccvalue(x) != x)
- throw new Exception("bad string mapping");
-
- if (li_std_wstring.test_cvalue(x) != x)
- throw new Exception("bad string mapping");
-
-
- if (li_std_wstring.test_value(x) != x)
- throw new Exception("bad string mapping: " + x + li_std_wstring.test_value(x));
-
- if (li_std_wstring.test_const_reference(x) != x)
- throw new Exception("bad string mapping");
-
-
- string s = "he";
- s = s + "llo";
-
- if (s != x)
- throw new Exception("bad string mapping: " + s + x);
-
- if (li_std_wstring.test_value(s) != x)
- throw new Exception("bad string mapping");
-
- if (li_std_wstring.test_const_reference(s) != x)
- throw new Exception("bad string mapping");
-
- string a = s;
-
- if (li_std_wstring.test_value(a) != x)
- throw new Exception("bad string mapping");
-
- if (li_std_wstring.test_const_reference(a) != x)
- throw new Exception("bad string mapping");
-
- string b = " world";
-
- if (a + b != "hello world")
- throw new Exception("bad string mapping");
-
- if (a + " world" != "hello world")
- throw new Exception("bad string mapping");
-
- if ("hello" + b != "hello world")
- throw new Exception("bad string mapping");
-
- s = "hello world";
-
- B myB = new B("hi");
+ if (a != b)
+ throw new Exception("char failed '" + a + "' != '" + b + "'");
+ }
- myB.name = "hello";
- if (myB.name != "hello")
- throw new Exception("bad string mapping");
+ static private void check_equal(string a, string b)
+ {
+ if (a != b)
+ throw new Exception("string failed '" + a + "' != '" + b + "'");
+ }
- myB.a = "hello";
- if (myB.a != "hello")
- throw new Exception("bad string mapping");
+ static void Main()
+ {
+ char h = 'h';
+ check_equal(li_std_wstring.test_wcvalue(h), h);
+
+ string x = "abc";
+ check_equal(li_std_wstring.test_ccvalue(x), x);
+ check_equal(li_std_wstring.test_cvalue(x), x);
+
+ check_equal(li_std_wstring.test_wchar_overload(x), x);
+ check_equal(li_std_wstring.test_wchar_overload(), null);
+
+ li_std_wstring.test_pointer(null);
+ li_std_wstring.test_const_pointer(null);
+
+ try {
+ li_std_wstring.test_value(null);
+ throw new Exception("NULL check failed");
+ } catch (ArgumentNullException) {
+ }
+
+ try {
+ li_std_wstring.test_reference(null);
+ throw new Exception("NULL check failed");
+ } catch (ArgumentNullException e) {
+ if (!e.Message.Contains("type is null"))
+ throw new Exception("Missing text " + e);
+ }
+ try {
+ li_std_wstring.test_const_reference(null);
+ throw new Exception("NULL check failed");
+ } catch (ArgumentNullException e) {
+ if (!e.Message.Contains("null wstring"))
+ throw new Exception("Missing text " + e);
+ }
+
+ x = "hello";
+ check_equal(li_std_wstring.test_const_reference(x), x);
+
+ /* Postpone, tricky, std::wstring portability problem.
+ * std::wstring is 2 bytes on Windows, 4 bytes on Linux, LPWSTR is 2 bytes.
+ * .NET marshalling should work on Windows but not Linux.
+ string s = "abc";
+ if (!li_std_wstring.test_equal_abc(s))
+ throw new Exception("Not equal " + s);
+ */
+
+ try {
+ li_std_wstring.test_throw();
+ } catch (Exception e) {
+ check_equal(e.Message, "throwing test_throw");
+ }
+
+ x = "abc\0def";
+ // Unlike other languages, embedded NULL in std::string not supported
+ // check_equal(li_std_wstring.test_value(x), x);
+ check_equal(li_std_wstring.test_value(x), "abc");
+ check_equal(li_std_wstring.test_ccvalue(x), "abc");
+ check_equal(li_std_wstring.test_wchar_overload(x), "abc");
+
+ // Member variables
+ var s = new wchar_test_struct();
+ s.wchar_t_member = h;
+ check_equal(s.wchar_t_member, h);
+ s.wchar_t_ptr_member = x;
+ check_equal(s.wchar_t_ptr_member, "abc");
+
+ {
+ // Unicode strings
+ string[] test_strings = {
+ "JP: 日本語", "DE: Kröpeliner Straße" , "RU: Война и мир", "EN: War and Peace"
+ };
+
+ foreach (string expected in test_strings)
+ {
+ string received = li_std_wstring.test_value(expected);
+ check_equal(received, expected);
+ }
+
+ foreach (string expected in test_strings)
+ {
+ string received = li_std_wstring.test_const_reference(expected);
+ check_equal(received, expected);
+ }
+
+ foreach (string expected in test_strings)
+ {
+ string received = li_std_wstring.test_ccvalue(expected);
+ check_equal(received, expected);
+ }
+
+ foreach (string expected in test_strings)
+ {
+ s.wchar_t_ptr_member = expected;
+ string received = s.wchar_t_ptr_member;
+ check_equal(received, expected);
+ }
+
+ /* Not working for Japanese and Russian characters on Windows, okay on Linux
+ * Is fixed by adding CharSet=CharSet.Unicode to the DllImport, so change to:
+ * [global::System.Runtime.InteropServices.DllImport("li_std_wstring", CharSet=global::System.Runtime.InteropServices.CharSet.Unicode, EntryPoint="CSharp_li_std_wstringNamespace_test_wcvalue")]
+ * Needs a SWIG code change to support this
+ foreach (string test_string in test_strings)
+ {
+ foreach (char expected in test_string)
+ {
+ char received = li_std_wstring.test_wcvalue(expected);
+ check_equal(received, expected);
+ }
+ }
+ */
+ }
}
}
diff --git a/Examples/test-suite/csharp/nested_in_template_runme.cs b/Examples/test-suite/csharp/nested_in_template_runme.cs
new file mode 100644
index 000000000..e57e03999
--- /dev/null
+++ b/Examples/test-suite/csharp/nested_in_template_runme.cs
@@ -0,0 +1,10 @@
+using System;
+using nested_in_templateNamespace;
+
+public class runme {
+ static void Main() {
+ var cd = new OuterTemplate1.ConcreteDerived(88);
+ if (cd.m_value != 88)
+ throw new Exception("ConcreteDerived not created correctly");
+ }
+}
diff --git a/Examples/test-suite/csharp/nested_inheritance_interface_runme.cs b/Examples/test-suite/csharp/nested_inheritance_interface_runme.cs
new file mode 100644
index 000000000..810b7db6d
--- /dev/null
+++ b/Examples/test-suite/csharp/nested_inheritance_interface_runme.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using nested_inheritance_interfaceNamespace;
+
+public class nested_inheritance_interface_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 takeIA(IASwigInterface ia) {
+ }
+
+ public static void Main() {
+ Type[] BNInterfaces = typeof(B.N).GetInterfaces();
+ string expectedInterfacesString = "IASwigInterface IDisposable";
+ string actualInterfacesString = SortArrayToString(BNInterfaces);
+ if (expectedInterfacesString != actualInterfacesString)
+ throw new Exception("Expected interfaces for " + typeof(B.N).Name + ": \n" + expectedInterfacesString + "\n" + "Actual interfaces: \n" + actualInterfacesString);
+
+ if (!typeof(IASwigInterface).IsInterface)
+ throw new Exception(typeof(IASwigInterface).Name + " should be an interface but is not");
+
+ // overloaded methods check
+ B.N d = new B.N();
+ takeIA(d);
+ }
+}
diff --git a/Examples/test-suite/csharp/preproc_constants_c_runme.cs b/Examples/test-suite/csharp/preproc_constants_c_runme.cs
index 76c684d85..5966d5266 100644
--- a/Examples/test-suite/csharp/preproc_constants_c_runme.cs
+++ b/Examples/test-suite/csharp/preproc_constants_c_runme.cs
@@ -36,7 +36,7 @@ public class runme {
assert( typeof(string) == preproc_constants_c.CONST_STRING2.GetType() );
assert( typeof(int) == preproc_constants_c.INT_AND_BOOL.GetType() );
-// assert( typeof(int) == preproc_constants_c.INT_AND_CHAR.GetType() );
+ assert( typeof(int) == preproc_constants_c.INT_AND_CHAR.GetType() );
assert( typeof(int) == preproc_constants_c.INT_AND_INT.GetType() );
assert( typeof(uint) == preproc_constants_c.INT_AND_UINT.GetType() );
assert( typeof(int) == preproc_constants_c.INT_AND_LONG.GetType() );
@@ -61,7 +61,9 @@ public class runme {
assert( typeof(int) == preproc_constants_c.EXPR_LAND.GetType() );
assert( typeof(int) == preproc_constants_c.EXPR_LOR.GetType() );
assert( typeof(double) == preproc_constants_c.EXPR_CONDITIONAL.GetType() );
-
+ assert( typeof(double) == preproc_constants_c.EXPR_MIXED1.GetType() );
+ assert( typeof(int) == preproc_constants_c.EXPR_WCHAR_MAX.GetType() );
+ assert( typeof(int) == preproc_constants_c.EXPR_WCHAR_MIN.GetType() );
}
static void assert(bool assertion) {
if (!assertion)
diff --git a/Examples/test-suite/csharp/preproc_constants_runme.cs b/Examples/test-suite/csharp/preproc_constants_runme.cs
index 9fae5914a..6af8f20a4 100644
--- a/Examples/test-suite/csharp/preproc_constants_runme.cs
+++ b/Examples/test-suite/csharp/preproc_constants_runme.cs
@@ -35,7 +35,7 @@ public class runme {
assert( typeof(string) == preproc_constants.CONST_STRING2.GetType() );
assert( typeof(int) == preproc_constants.INT_AND_BOOL.GetType() );
-// assert( typeof(int) == preproc_constants.INT_AND_CHAR.GetType() );
+ assert( typeof(int) == preproc_constants.INT_AND_CHAR.GetType() );
assert( typeof(int) == preproc_constants.INT_AND_INT.GetType() );
assert( typeof(uint) == preproc_constants.INT_AND_UINT.GetType() );
assert( typeof(int) == preproc_constants.INT_AND_LONG.GetType() );
@@ -60,6 +60,9 @@ public class runme {
assert( typeof(bool) == preproc_constants.EXPR_LAND.GetType() );
assert( typeof(bool) == preproc_constants.EXPR_LOR.GetType() );
assert( typeof(double) == preproc_constants.EXPR_CONDITIONAL.GetType() );
+ assert( typeof(double) == preproc_constants.EXPR_MIXED1.GetType() );
+ assert( typeof(int) == preproc_constants.EXPR_WCHAR_MAX.GetType() );
+ assert( typeof(int) == preproc_constants.EXPR_WCHAR_MIN.GetType() );
}
static void assert(bool assertion) {
diff --git a/Examples/test-suite/csharp/proxycode_runme.cs b/Examples/test-suite/csharp/proxycode_runme.cs
new file mode 100644
index 000000000..24e76c0c6
--- /dev/null
+++ b/Examples/test-suite/csharp/proxycode_runme.cs
@@ -0,0 +1,33 @@
+using System;
+using proxycodeNamespace;
+
+public class proxycode_runme {
+
+ public static void Main() {
+ if (new Proxy1().proxycode1(100) != 101)
+ throw new Exception("Fail");
+ if (new Proxy2().proxycode2a(100) != 102)
+ throw new Exception("Fail");
+ if (new Proxy2().proxycode2b(100) != 102)
+ throw new Exception("Fail");
+ if (new Proxy3().proxycode3(100) != 103)
+ throw new Exception("Fail");
+
+ if (new Proxy4().proxycode4(100) != 104)
+ throw new Exception("Fail");
+ if (new Proxy4.Proxy4Nested().proxycode4nested(100) != 144)
+ throw new Exception("Fail");
+
+ if (new Proxy5a().proxycode5((short)100) != (short)100)
+ throw new Exception("Fail");
+ if (new Proxy5b().proxycode5(100) != 100)
+ throw new Exception("Fail");
+ if (new Proxy5b().proxycode5(100, 100) != 255)
+ throw new Exception("Fail");
+
+ uint t1 = 10;
+ uint t2 = 100;
+ Proxy6 p = new Proxy6().proxyUseT(t1, t2);
+ p.useT(t1, t2);
+ }
+}
diff --git a/Examples/test-suite/csharp_director_typemaps.i b/Examples/test-suite/csharp_director_typemaps.i
new file mode 100644
index 000000000..614bdbf23
--- /dev/null
+++ b/Examples/test-suite/csharp_director_typemaps.i
@@ -0,0 +1,37 @@
+%module (directors="1") csharp_director_typemaps
+
+// This tests that the csout typemap is handled correctly in the director code.
+// The 'out' needs stripping in some parts of the generated director code.
+
+%feature("director") InStream;
+
+%apply void *VOID_INT_PTR { void * }
+
+%typemap(ctype) int* readLen, int* writeLen "/*ctype*/ int*"
+%typemap(imtype) int* readLen, int* writeLen "/*imtype*/ out int"
+%typemap(cstype) int* readLen "/*cstype*/ out int"
+// Note for below: 'out' used in typemap comment
+%typemap(cstype) int* writeLen "/*out cstype out*/ out int"
+%typemap(csin) int* readLen, int* writeLen "/*csin*/ out $csinput"
+%typemap(in) int* readLen, int* writeLen %{/*in*/ $1 = ($1_ltype)$input; %}
+%typemap(out) int* readLen, int* writeLen %{/*out*/ $result = (void *)$1; %}
+%typemap(csdirectorin) int* readLen, int* writeLen "/*csdirectorin*/ out $iminput"
+%typemap(csdirectorout) int* readLen, int* writeLen "/*csdirectorout*/ $cscall"
+%typemap(directorin) int* readLen, int* writeLen "/*directorin*/ $input = $1;"
+%typemap(directorout) int* readLen, int* writeLen %{/*directorout*/ $result = ($1_ltype)$input; %}
+
+%inline %{
+class InStream
+{
+public:
+ virtual int Read(void* buf, int len, int* readLen) = 0;
+ virtual int Write(void* buf, int len, int* writeLen) = 0;
+ virtual ~InStream() {}
+};
+int callRead(InStream* stream, void* buf, int len, int* readLen) {
+ return stream->Read(buf, len, readLen);
+}
+int callWrite(InStream* stream, void* buf, int len, int* writeLen) {
+ return stream->Write(buf, len, writeLen);
+}
+%}
diff --git a/Examples/test-suite/csharp_exceptions.i b/Examples/test-suite/csharp_exceptions.i
index e5b4d495b..71581480e 100644
--- a/Examples/test-suite/csharp_exceptions.i
+++ b/Examples/test-suite/csharp_exceptions.i
@@ -1,5 +1,11 @@
%module csharp_exceptions
+// throw is invalid in C++17 and later, only SWIG to use it
+#define TESTCASE_THROW1(T1) throw(T1)
+%{
+#define TESTCASE_THROW1(T1)
+%}
+
%include <exception.i>
%inline %{
@@ -36,21 +42,16 @@
}
%inline %{
-
-#if defined(_MSC_VER)
- #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
-
// %exception tests
void ThrowByValue() { throw Ex("ThrowByValue"); }
void ThrowByReference() { throw Ex("ThrowByReference"); }
// %csnothrowexception
void NoThrowException() { throw Ex("NoThrowException"); }
// exception specifications
-void ExceptionSpecificationValue() throw(Ex) { throw Ex("ExceptionSpecificationValue"); }
-void ExceptionSpecificationReference() throw(Ex&) { throw Ex("ExceptionSpecificationReference"); }
-void ExceptionSpecificationString() throw(const char *) { throw "ExceptionSpecificationString"; }
-void ExceptionSpecificationInteger() throw(int) { throw 20; }
+void ExceptionSpecificationValue() TESTCASE_THROW1(Ex) { throw Ex("ExceptionSpecificationValue"); }
+void ExceptionSpecificationReference() TESTCASE_THROW1(Ex&) { throw Ex("ExceptionSpecificationReference"); }
+void ExceptionSpecificationString() TESTCASE_THROW1(const char *) { throw "ExceptionSpecificationString"; }
+void ExceptionSpecificationInteger() TESTCASE_THROW1(int) { throw 20; }
%}
// test exceptions in the default typemaps
@@ -64,15 +65,15 @@ void NullValue(Ex e) {}
// enums
%inline %{
enum TestEnum {TestEnumItem};
-void ExceptionSpecificationEnumValue() throw(TestEnum) { throw TestEnumItem; }
-void ExceptionSpecificationEnumReference() throw(TestEnum&) { throw TestEnumItem; }
+void ExceptionSpecificationEnumValue() TESTCASE_THROW1(TestEnum) { throw TestEnumItem; }
+void ExceptionSpecificationEnumReference() TESTCASE_THROW1(TestEnum&) { throw TestEnumItem; }
%}
// std::string
%include <std_string.i>
%inline %{
-void ExceptionSpecificationStdStringValue() throw(std::string) { throw std::string("ExceptionSpecificationStdStringValue"); }
-void ExceptionSpecificationStdStringReference() throw(const std::string&) { throw std::string("ExceptionSpecificationStdStringReference"); }
+void ExceptionSpecificationStdStringValue() TESTCASE_THROW1(std::string) { throw std::string("ExceptionSpecificationStdStringValue"); }
+void ExceptionSpecificationStdStringReference() TESTCASE_THROW1(const std::string&) { throw std::string("ExceptionSpecificationStdStringReference"); }
void NullStdStringValue(std::string s) {}
void NullStdStringReference(std::string &s) {}
%}
@@ -104,12 +105,8 @@ void MemoryLeakCheck() {
%inline %{
struct constructor {
constructor(std::string s) {}
- constructor() throw(int) { throw 10; }
+ constructor() TESTCASE_THROW1(int) { throw 10; }
};
-
-#if defined(_MSC_VER)
- #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
%}
// test exception pending in the csout typemaps
@@ -239,3 +236,4 @@ struct ThrowsClass {
%inline %{
void InnerExceptionTest() { throw Ex("My InnerException message"); }
%}
+
diff --git a/Examples/test-suite/csharp_lib_arrays_bool.i b/Examples/test-suite/csharp_lib_arrays_bool.i
new file mode 100644
index 000000000..58cee9d80
--- /dev/null
+++ b/Examples/test-suite/csharp_lib_arrays_bool.i
@@ -0,0 +1,78 @@
+%module csharp_lib_arrays_bool
+
+%include "arrays_csharp.i"
+
+%apply bool INPUT[] { bool* sourceArray }
+%apply bool OUTPUT[] { bool* targetArray }
+
+%apply bool INOUT[] { bool* array1 }
+%apply bool INOUT[] { bool* array2 }
+
+%inline %{
+#include <iostream>
+
+/* copy the contents of the first array to the second */
+void myArrayCopyBool( bool* sourceArray, bool* targetArray, int nitems ) {
+ int i;
+ for ( i = 0; i < nitems; i++ ) {
+ targetArray[ i ] = sourceArray[ i ];
+ }
+}
+
+/* swap the contents of the two arrays */
+void myArraySwapBool( bool* array1, bool* array2, int nitems ) {
+ int i;
+ bool temp;
+ for ( i = 0; i < nitems; i++ ) {
+ temp = array1[ i ];
+ array1[ i ] = array2[ i ];
+ array2[ i ] = temp;
+ }
+}
+
+bool checkBoolArrayCorrect( bool* sourceArray, int sourceArraySize ) {
+ if( sourceArraySize != 8 ) {
+ std::cout << "checkBoolArrayCorrect: Expected array with 8 elements" << std::endl;
+ return false;
+ }
+ return sourceArray[0] == true &&
+ sourceArray[1] == false &&
+ sourceArray[2] == false &&
+ sourceArray[3] == true &&
+ sourceArray[4] == false &&
+ sourceArray[5] == true &&
+ sourceArray[6] == true &&
+ sourceArray[7] == false;
+}
+%}
+
+%clear bool* sourceArray;
+%clear bool* targetArray;
+
+%clear bool* array1;
+%clear bool* array2;
+
+// Below replicates the above array handling but this time using the pinned (fixed) array typemaps
+%csmethodmodifiers myArrayCopyUsingFixedArraysBool "public unsafe";
+%csmethodmodifiers myArraySwapUsingFixedArraysBool "public unsafe";
+
+%apply bool FIXED[] { bool* sourceArray }
+%apply bool FIXED[] { bool* targetArray }
+
+%inline %{
+void myArrayCopyUsingFixedArraysBool( bool *sourceArray, bool* targetArray, int nitems ) {
+ myArrayCopyBool(sourceArray, targetArray, nitems);
+}
+%}
+
+%apply bool FIXED[] { bool* array1 }
+%apply bool FIXED[] { bool* array2 }
+
+%inline %{
+void myArraySwapUsingFixedArraysBool( bool* array1, bool* array2, int nitems ) {
+ myArraySwapBool(array1, array2, nitems);
+}
+%}
+
+
+
diff --git a/Examples/test-suite/d/Makefile.in b/Examples/test-suite/d/Makefile.in
index 3333df110..a20cfb4e3 100644
--- a/Examples/test-suite/d/Makefile.in
+++ b/Examples/test-suite/d/Makefile.in
@@ -24,6 +24,12 @@ CPP_TEST_CASES = \
d_nativepointers \
exception_partial_info
+CPP11_TEST_CASES = \
+ cpp11_shared_ptr_const \
+ cpp11_shared_ptr_nullptr_in_containers \
+ cpp11_shared_ptr_overload \
+ cpp11_shared_ptr_upcast \
+
include $(srcdir)/../common.mk
# Overridden variables here
diff --git a/Examples/test-suite/d/director_classes_runme.1.d b/Examples/test-suite/d/director_classes_runme.1.d
index 9c34db82a..e753f5f6d 100644
--- a/Examples/test-suite/d/director_classes_runme.1.d
+++ b/Examples/test-suite/d/director_classes_runme.1.d
@@ -18,6 +18,7 @@
* Base - Val(444.555)
* Base - Ref(444.555)
* Base - Ptr(444.555)
+ * Base - ConstPtrRef(444.555)
* Base - FullyOverloaded(int 10)
* Base - FullyOverloaded(bool 1)
* Base - SemiOverloaded(int -678)
@@ -28,6 +29,7 @@
* Derived - Val(444.555)
* Derived - Ref(444.555)
* Derived - Ptr(444.555)
+ * Derived - ConstPtrRef(444.555)
* Derived - FullyOverloaded(int 10)
* Derived - FullyOverloaded(bool 1)
* Derived - SemiOverloaded(int -678)
@@ -38,6 +40,7 @@
* DDerived - Val(444.555)
* DDerived - Ref(444.555)
* DDerived - Ptr(444.555)
+ * DDerived - ConstPtrRef(444.555)
* DDerived - FullyOverloaded(int 10)
* DDerived - FullyOverloaded(bool True)
* DDerived - SemiOverloaded(-678)
@@ -57,7 +60,7 @@ import director_classes.Derived;
import director_classes.DoubleHolder;
void main() {
- if (PrintDebug) Stdout.formatln("------------ Start ------------ ");
+ if (PrintDebug) Stdout.formatln("------------ Start ------------");
auto myCaller = new Caller();
@@ -83,7 +86,7 @@ void main() {
makeCalls(myCaller, myBase);
}
- if (PrintDebug) Stdout.formatln("------------ Finish ------------ ");
+ if (PrintDebug) Stdout.formatln("------------ Finish ------------");
}
void makeCalls(Caller myCaller, Base myBase) {
@@ -96,6 +99,7 @@ void makeCalls(Caller myCaller, Base myBase) {
if (myCaller.ValCall(dh).val != dh.val) throw new Exception("[1] failed");
if (myCaller.RefCall(dh).val != dh.val) throw new Exception("[2] failed");
if (myCaller.PtrCall(dh).val != dh.val) throw new Exception("[3] failed");
+ if (myCaller.ConstPtrRefCall(dh).val != dh.val) throw new Exception("[3] failed");
// Fully overloaded method test (all methods in base class are overloaded)
if (myCaller.FullyOverloadedCall(10) != myBaseType ~ "::FullyOverloaded(int)") throw new Exception("[4] failed");
@@ -136,6 +140,11 @@ public class DDerived : Base {
return x;
}
+ public override DoubleHolder ConstPtrRef(DoubleHolder x) {
+ if (PrintDebug) Stdout.formatln("DDerived - ConstPtrRef({0:d3})", x.val);
+ return x;
+ }
+
public override char[] FullyOverloaded(int x) {
if (PrintDebug) Stdout.formatln("DDerived - FullyOverloaded(int {0})", x);
return "DDerived::FullyOverloaded(int)";
diff --git a/Examples/test-suite/d/director_classes_runme.2.d b/Examples/test-suite/d/director_classes_runme.2.d
index 98e27b3cd..b16fa5461 100644
--- a/Examples/test-suite/d/director_classes_runme.2.d
+++ b/Examples/test-suite/d/director_classes_runme.2.d
@@ -18,6 +18,7 @@
* Base - Val(444.555)
* Base - Ref(444.555)
* Base - Ptr(444.555)
+ * Base - ConstPtrRef(444.555)
* Base - FullyOverloaded(int 10)
* Base - FullyOverloaded(bool 1)
* Base - SemiOverloaded(int -678)
@@ -28,6 +29,7 @@
* Derived - Val(444.555)
* Derived - Ref(444.555)
* Derived - Ptr(444.555)
+ * Derived - ConstPtrRef(444.555)
* Derived - FullyOverloaded(int 10)
* Derived - FullyOverloaded(bool 1)
* Derived - SemiOverloaded(int -678)
@@ -38,6 +40,7 @@
* DDerived - Val(444.555)
* DDerived - Ref(444.555)
* DDerived - Ptr(444.555)
+ * DDerived - ConstPtrRef(444.555)
* DDerived - FullyOverloaded(int 10)
* DDerived - FullyOverloaded(bool true)
* DDerived - SemiOverloaded(-678)
@@ -58,7 +61,7 @@ import director_classes.Derived;
import director_classes.DoubleHolder;
void main() {
- if (PrintDebug) writeln("------------ Start ------------ ");
+ if (PrintDebug) writeln("------------ Start ------------");
auto myCaller = new Caller();
@@ -84,7 +87,7 @@ void main() {
makeCalls(myCaller, myBase);
}
- if (PrintDebug) writeln("------------ Finish ------------ ");
+ if (PrintDebug) writeln("------------ Finish ------------");
}
void makeCalls(Caller myCaller, Base myBase) {
@@ -97,6 +100,7 @@ void makeCalls(Caller myCaller, Base myBase) {
enforce(myCaller.ValCall(dh).val == dh.val, "[1] failed");
enforce(myCaller.RefCall(dh).val == dh.val, "[2] failed");
enforce(myCaller.PtrCall(dh).val == dh.val, "[3] failed");
+ enforce(myCaller.ConstPtrRefCall(dh).val == dh.val, "[3] failed");
// Fully overloaded method test (all methods in base class are overloaded)
enforce(myCaller.FullyOverloadedCall(10) == myBaseType ~ "::FullyOverloaded(int)", "[4] failed");
@@ -137,6 +141,11 @@ public class DDerived : Base {
return x;
}
+ public override DoubleHolder ConstPtrRef(DoubleHolder x) {
+ if (PrintDebug) writefln("DDerived - ConstPtrRef(%s)", x.val);
+ return x;
+ }
+
public override string FullyOverloaded(int x) {
if (PrintDebug) writefln("DDerived - FullyOverloaded(int %s)", x);
return "DDerived::FullyOverloaded(int)";
diff --git a/Examples/test-suite/d/li_boost_shared_ptr_director_runme.2.d b/Examples/test-suite/d/li_boost_shared_ptr_director_runme.2.d
new file mode 100644
index 000000000..fbcb03fa6
--- /dev/null
+++ b/Examples/test-suite/d/li_boost_shared_ptr_director_runme.2.d
@@ -0,0 +1,114 @@
+module li_boost_shared_ptr_director_runme;
+
+import std.conv;
+import std.exception;
+import std.stdio;
+import std.string;
+import li_boost_shared_ptr_director.li_boost_shared_ptr_director;
+import li_boost_shared_ptr_director.Base;
+import li_boost_shared_ptr_director.C;
+
+void check(int got, int expected) {
+ enforce(got == expected, "Failed. got: " ~ to!string(got) ~ " Expected: " ~ to!string(expected));
+}
+
+void main() {
+ Derived a = new Derived(false);
+ Derived b = new Derived(true);
+
+ check(call_ret_c_shared_ptr(a), 1);
+ check(call_ret_c_shared_ptr(b), -1);
+ check(call_ret_c_by_value(a), 1);
+
+ check(call_ret_c_shared_ptr(a), 1);
+ check(call_ret_c_shared_ptr(b), -1);
+ check(call_ret_c_by_value(a), 1);
+
+ check(call_take_c_by_value(a), 5);
+ check(call_take_c_by_ref(a), 6);
+ check(call_take_c_by_pointer(a), 7);
+ check(call_take_c_by_pointer_ref(a), 8);
+ check(call_take_c_shared_ptr_by_value(a), 9);
+ check(call_take_c_shared_ptr_by_ref(a), 10);
+ check(call_take_c_shared_ptr_by_pointer(a), 11);
+ check(call_take_c_shared_ptr_by_pointer_ref(a), 12);
+
+ check(call_take_c_by_pointer_with_null(a), -2);
+ check(call_take_c_by_pointer_ref_with_null(a), -3);
+ check(call_take_c_shared_ptr_by_value_with_null(a), -4);
+ check(call_take_c_shared_ptr_by_ref_with_null(a), -5);
+ check(call_take_c_shared_ptr_by_pointer_with_null(a), -6);
+ check(call_take_c_shared_ptr_by_pointer_ref_with_null(a), -7);
+}
+
+public class Derived : Base {
+
+ private bool return_none;
+
+ public this(bool flag) {
+ super();
+ this.return_none = flag;
+ }
+
+ public override C ret_c_shared_ptr() {
+ if (this.return_none)
+ return null;
+ else
+ return new C();
+ }
+
+ public override C ret_c_by_value() {
+ return new C();
+ }
+
+ public override int take_c_by_value(C c) {
+ return c.get_m();
+ }
+
+ public override int take_c_by_ref(C c) {
+ return c.get_m();
+ }
+
+ public override int take_c_by_pointer(C c) {
+ if (c !is null)
+ return c.get_m();
+ else
+ return -2;
+ }
+
+ public override int take_c_by_pointer_ref(C c) {
+ if (c !is null)
+ return c.get_m();
+ else
+ return -3;
+ }
+
+ public override int take_c_shared_ptr_by_value(C c) {
+ if (c !is null)
+ return c.get_m();
+ else
+ return -4;
+ }
+
+ public override int take_c_shared_ptr_by_ref(C c) {
+ if (c !is null)
+ return c.get_m();
+ else
+ return -5;
+ }
+
+ public override int take_c_shared_ptr_by_pointer(C c) {
+ if (c !is null)
+ return c.get_m();
+ else
+ return -6;
+ }
+
+ public override int take_c_shared_ptr_by_pointer_ref(C c) {
+ if (c !is null)
+ return c.get_m();
+ else
+ return -7;
+ }
+
+}
diff --git a/Examples/test-suite/d/preproc_constants_c_runme.1.d b/Examples/test-suite/d/preproc_constants_c_runme.1.d
index d846c71ac..a6c2f3d10 100644
--- a/Examples/test-suite/d/preproc_constants_c_runme.1.d
+++ b/Examples/test-suite/d/preproc_constants_c_runme.1.d
@@ -36,7 +36,7 @@ void main() {
static assert(is(char[] == typeof(CONST_STRING2())));
static assert(is(int == typeof(INT_AND_BOOL())));
-// static assert(is(int == typeof(INT_AND_CHAR())));
+ static assert(is(int == typeof(INT_AND_CHAR())));
static assert(is(int == typeof(INT_AND_INT())));
static assert(is(uint == typeof(INT_AND_UINT())));
static assert(is(c_long == typeof(INT_AND_LONG())));
@@ -61,4 +61,7 @@ void main() {
static assert(is(int == typeof(EXPR_LAND())));
static assert(is(int == typeof(EXPR_LOR())));
static assert(is(double == typeof(EXPR_CONDITIONAL())));
+ static assert(is(double == typeof(EXPR_MIXED1())));
+ static assert(is(int == typeof(EXPR_WCHAR_MAX())));
+ static assert(is(int == typeof(EXPR_WCHAR_MIN())));
}
diff --git a/Examples/test-suite/d/preproc_constants_c_runme.2.d b/Examples/test-suite/d/preproc_constants_c_runme.2.d
index 9bdbb9372..786cb48cc 100644
--- a/Examples/test-suite/d/preproc_constants_c_runme.2.d
+++ b/Examples/test-suite/d/preproc_constants_c_runme.2.d
@@ -36,7 +36,7 @@ void main() {
static assert(is(string == typeof(CONST_STRING2())));
static assert(is(int == typeof(INT_AND_BOOL())));
-// static assert(is(int == typeof(INT_AND_CHAR())));
+ static assert(is(int == typeof(INT_AND_CHAR())));
static assert(is(int == typeof(INT_AND_INT())));
static assert(is(uint == typeof(INT_AND_UINT())));
static assert(is(c_long == typeof(INT_AND_LONG())));
@@ -61,4 +61,7 @@ void main() {
static assert(is(int == typeof(EXPR_LAND())));
static assert(is(int == typeof(EXPR_LOR())));
static assert(is(double == typeof(EXPR_CONDITIONAL())));
+ static assert(is(double == typeof(EXPR_MIXED1())));
+ static assert(is(int == typeof(EXPR_WCHAR_MAX())));
+ static assert(is(int == typeof(EXPR_WCHAR_MIN())));
}
diff --git a/Examples/test-suite/d/preproc_constants_runme.1.d b/Examples/test-suite/d/preproc_constants_runme.1.d
index 009405fc7..85fa918e4 100644
--- a/Examples/test-suite/d/preproc_constants_runme.1.d
+++ b/Examples/test-suite/d/preproc_constants_runme.1.d
@@ -35,7 +35,7 @@ void main() {
static assert(is(char[] == typeof(CONST_STRING2())));
static assert(is(int == typeof(INT_AND_BOOL())));
-// static assert(is(int == typeof(INT_AND_CHAR())));
+ static assert(is(int == typeof(INT_AND_CHAR())));
static assert(is(int == typeof(INT_AND_INT())));
static assert(is(uint == typeof(INT_AND_UINT())));
static assert(is(c_long == typeof(INT_AND_LONG())));
@@ -60,4 +60,7 @@ void main() {
static assert(is(bool == typeof(EXPR_LAND())));
static assert(is(bool == typeof(EXPR_LOR())));
static assert(is(double == typeof(EXPR_CONDITIONAL())));
+ static assert(is(double == typeof(EXPR_MIXED1())));
+ static assert(is(int == typeof(EXPR_WCHAR_MAX())));
+ static assert(is(int == typeof(EXPR_WCHAR_MIN())));
}
diff --git a/Examples/test-suite/d/preproc_constants_runme.2.d b/Examples/test-suite/d/preproc_constants_runme.2.d
index 2d92ef052..c81e53160 100644
--- a/Examples/test-suite/d/preproc_constants_runme.2.d
+++ b/Examples/test-suite/d/preproc_constants_runme.2.d
@@ -35,7 +35,7 @@ void main() {
static assert(is(string == typeof(CONST_STRING2())));
static assert(is(int == typeof(INT_AND_BOOL())));
-// static assert(is(int == typeof(INT_AND_CHAR())));
+ static assert(is(int == typeof(INT_AND_CHAR())));
static assert(is(int == typeof(INT_AND_INT())));
static assert(is(uint == typeof(INT_AND_UINT())));
static assert(is(c_long == typeof(INT_AND_LONG())));
@@ -60,4 +60,7 @@ void main() {
static assert(is(bool == typeof(EXPR_LAND())));
static assert(is(bool == typeof(EXPR_LOR())));
static assert(is(double == typeof(EXPR_CONDITIONAL())));
+ static assert(is(double == typeof(EXPR_MIXED1())));
+ static assert(is(int == typeof(EXPR_WCHAR_MAX())));
+ static assert(is(int == typeof(EXPR_WCHAR_MIN())));
}
diff --git a/Examples/test-suite/d/proxycode_runme.2.d b/Examples/test-suite/d/proxycode_runme.2.d
new file mode 100644
index 000000000..133217f2e
--- /dev/null
+++ b/Examples/test-suite/d/proxycode_runme.2.d
@@ -0,0 +1,41 @@
+module proxycode_runme;
+
+import std.exception;
+import proxycode.Proxy1;
+import proxycode.Proxy2;
+import proxycode.Proxy3;
+import proxycode.Proxy4;
+import proxycode.Proxy5a;
+import proxycode.Proxy5b;
+import proxycode.Proxy6;
+
+void main() {
+ if (new Proxy1().proxycode1(100) != 101)
+ throw new Exception("Fail");
+
+ if (new Proxy1().proxycode1(100) != 101)
+ throw new Exception("Fail");
+ if (new Proxy2().proxycode2a(100) != 102)
+ throw new Exception("Fail");
+ if (new Proxy2().proxycode2b(100) != 102)
+ throw new Exception("Fail");
+ if (new Proxy3().proxycode3(100) != 103)
+ throw new Exception("Fail");
+
+ if (new Proxy4().proxycode4(100) != 104)
+ throw new Exception("Fail");
+// if (new Proxy4.Proxy4Nested().proxycode4nested(100) != 144)
+// throw new Exception("Fail");
+
+ if (new Proxy5a().proxycode5(100) != 100)
+ throw new Exception("Fail");
+ if (new Proxy5b().proxycode5(100) != 100)
+ throw new Exception("Fail");
+ if (new Proxy5b().proxycode5(100, 100) != 255)
+ throw new Exception("Fail");
+
+ uint t1 = 10;
+ uint t2 = 100;
+ Proxy6 p = new Proxy6().proxyUseT(t1, t2);
+ p.useT(t1, t2);
+}
diff --git a/Examples/test-suite/default_arg_expressions.i b/Examples/test-suite/default_arg_expressions.i
new file mode 100644
index 000000000..d83dc05bc
--- /dev/null
+++ b/Examples/test-suite/default_arg_expressions.i
@@ -0,0 +1,34 @@
+%module default_arg_expressions
+
+#ifdef SWIGOCAML
+%warnfilter(SWIGWARN_PARSE_KEYWORD) val;
+#endif
+
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) ptr;
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) UsdGeomTokensPtr;
+%immutable UsdGeomTokens;
+
+%inline %{
+struct Numbers {
+ int val;
+ int *ptr;
+ Numbers() : val(), ptr(&val) {}
+};
+struct TfToken {
+ Numbers val;
+ Numbers *ptr;
+ TfToken() : val(), ptr(&val) {}
+};
+struct Tokens {
+ const TfToken face;
+ const TfToken *pface;
+ Tokens() : face(), pface(&face) {}
+};
+static Tokens UsdGeomTokens;
+static Tokens *UsdGeomTokensPtr = &UsdGeomTokens;
+void CreateMaterialBindSubset1(const Tokens &elementType = UsdGeomTokens) {}
+void CreateMaterialBindSubset2(int num = UsdGeomTokensPtr->pface->val.val) {}
+void CreateMaterialBindSubset3(int num = UsdGeomTokensPtr->pface->ptr->val) {}
+void CreateMaterialBindSubset4(int num = UsdGeomTokensPtr->face.val.val) {}
+//void CreateMaterialBindSubset5(int num = UsdGeomTokens.face.val.val) {}
+%}
diff --git a/Examples/test-suite/default_args.i b/Examples/test-suite/default_args.i
index 02d860765..6b680f561 100644
--- a/Examples/test-suite/default_args.i
+++ b/Examples/test-suite/default_args.i
@@ -2,26 +2,51 @@
%module default_args
+#ifdef SWIGOCAML
+%warnfilter(SWIGWARN_PARSE_KEYWORD) val;
+#endif
+
%{
#if defined(_MSC_VER)
- #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+ #pragma warning(disable: 4146) // unary minus operator applied to unsigned type, result still unsigned
#endif
%}
+// throw is invalid in C++17 and later, only SWIG to use it
+#define TESTCASE_THROW1(T1) throw(T1)
+#define TESTCASE_THROW2(T1, T2) throw(T1, T2)
+%{
+#define TESTCASE_THROW1(T1)
+#define TESTCASE_THROW2(T1, T2)
+%}
+
%include <std_string.i>
%inline %{
#include <string>
// All kinds of numbers: hex, octal (which pose special problems to Python), negative...
- void trickyvalue1(int first, int pos = -1) {}
- void trickyvalue2(int first, unsigned rgb = 0xabcdef) {}
- void trickyvalue3(int first, int mode = 0644) {}
+
+ class TrickyInPython {
+ public:
+ int value_m1(int first, int pos = -1) { return pos; }
+ unsigned value_0xabcdef(int first, unsigned rgb = 0xabcdef) { return rgb; }
+ int value_0644(int first, int mode = 0644) { return mode; }
+ int value_perm(int first, int mode = 0640 | 0004) { return mode; }
+ int value_m01(int first, int val = -01) { return val; }
+ bool booltest2(bool x = 0 | 1) { return x; }
+ int max_32bit_int1(int a = 0x7FFFFFFF) { return a; }
+ int max_32bit_int2(int a = 2147483647) { return a; }
+ int min_32bit_int1(int a = -0x80000000) { return a; }
+ long long too_big_32bit_int1(long long a = 0x80000000) { return a; }
+ long long too_big_32bit_int2(long long a = 2147483648LL) { return a; }
+ long long too_small_32bit_int1(long long a = -0x80000001) { return a; }
+ long long too_small_32bit_int2(long long a = -2147483649LL) { return a; }
+ };
void doublevalue1(int first, double num = 0.0e-1) {}
void doublevalue2(int first, double num = -0.0E2) {}
- // Long long arguments are not handled at Python level currently but still work.
void seek(long long offset = 0LL) {}
void seek2(unsigned long long offset = 0ULL) {}
void seek3(long offset = 0L) {}
@@ -152,6 +177,9 @@
int double_if_handle_is_null(int n, MyHandle h = 0) { return h ? n : 2*n; }
int double_if_dbl_ptr_is_null(int n, double* null_by_default)
{ return null_by_default ? n : 2*n; }
+
+ void defaulted1(unsigned offset = -1U) {} // minus unsigned!
+ void defaulted2(int offset = -1U) {} // minus unsigned!
};
int Foo::bar = 1;
int Foo::spam = 2;
@@ -182,18 +210,18 @@
// Default parameters with exception specifications
%inline %{
-void exceptionspec(int a = -1) throw (int, const char*) {
+void exceptionspec(int a = -1) TESTCASE_THROW2(int, const char*) {
if (a == -1)
throw "ciao";
else
throw a;
}
struct Except {
- Except(bool throwException, int a = -1) throw (int) {
+ Except(bool throwException, int a = -1) TESTCASE_THROW1(int) {
if (throwException)
throw a;
}
- void exspec(int a = 0) throw (int, const char*) {
+ void exspec(int a = 0) TESTCASE_THROW2(int, const char*) {
::exceptionspec(a);
}
};
diff --git a/Examples/test-suite/default_args_c.i b/Examples/test-suite/default_args_c.i
index e0c0af056..f507aa797 100644
--- a/Examples/test-suite/default_args_c.i
+++ b/Examples/test-suite/default_args_c.i
@@ -1,5 +1,13 @@
%module default_args_c
+%{
+#if defined(__clang__)
+#pragma clang diagnostic push
+// Suppress: use of logical '||' with constant operand
+#pragma clang diagnostic ignored "-Wconstant-logical-operand"
+#endif
+%}
+
/* Default arguments for C code */
int foo1(int x = 42 || 3);
int foo43(int x = 42 | 3);
@@ -12,3 +20,34 @@ int foo43(int x) {
return x;
}
%}
+
+%inline %{
+struct FooStruct {
+ int num;
+};
+%}
+%extend FooStruct {
+ void no_arg() {}
+ void one_req(int *required) {}
+ void one_opt(int *optional = NULL) {}
+ void two_arg(int *required, int *optional = NULL) {}
+}
+
+%inline %{
+struct StaticStruct {
+ int snum;
+};
+%}
+%extend StaticStruct {
+ static void no_arg() {}
+ static void one_req(int *required) {}
+ static void one_opt(int *optional = NULL) {}
+ static void two_arg(int *required, int *optional = NULL) {}
+}
+
+%{
+void global_opts1(int *optional) {}
+void global_opts2(int *required, int *optional) {}
+%}
+void global_opts1(int *optional = NULL) {}
+void global_opts2(int *required, int *optional = NULL) {}
diff --git a/Examples/test-suite/derived_byvalue.i b/Examples/test-suite/derived_byvalue.i
index a251a8fc6..21de809a5 100644
--- a/Examples/test-suite/derived_byvalue.i
+++ b/Examples/test-suite/derived_byvalue.i
@@ -1,5 +1,9 @@
%module derived_byvalue
+#ifdef SWIGOCAML
+%warnfilter(SWIGWARN_PARSE_KEYWORD) method;
+#endif
+
%inline %{
struct Foo {
diff --git a/Examples/test-suite/destructor_methodmodifiers.i b/Examples/test-suite/destructor_methodmodifiers.i
new file mode 100644
index 000000000..93db7f2cc
--- /dev/null
+++ b/Examples/test-suite/destructor_methodmodifiers.i
@@ -0,0 +1,61 @@
+%module destructor_methodmodifiers
+
+// This test changes the proxy classes so that they cannot be inherited from in the target language
+// Previously the %csmethodmodifiers, %dmethodmodifiers, %javamethodmodifiers on destructors were ignored
+// Now they can control the dispose/Dispose/delete method modifiers
+
+#if defined(SWIGCSHARP)
+
+// remove all use of protected and virtual keywords
+%typemap(csclassmodifiers) NotForDeriving1, NotForDeriving2 "public sealed class"
+%csmethodmodifiers NotForDeriving1::~NotForDeriving1 "public /*not virtual nor override*/";
+%csmethodmodifiers NotForDeriving2::~NotForDeriving2 "public /*not virtual nor override*/";
+
+// remove protected keyword to remove compiler warning
+%typemap(csbody) NotForDeriving1, NotForDeriving2 %{
+ private global::System.Runtime.InteropServices.HandleRef swigCPtr;
+ private /*protected*/ bool swigCMemOwn;
+
+ internal $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) {
+ swigCMemOwn = cMemoryOwn;
+ swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
+ }
+
+ internal 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;
+ }
+%}
+
+#elif defined(SWIGD)
+
+%typemap(dclassmodifiers) NotForDeriving1, NotForDeriving2 "final class"
+%dmethodmodifiers NotForDeriving1::~NotForDeriving1 "public final";
+%dmethodmodifiers NotForDeriving2::~NotForDeriving2 "public final";
+
+#elif defined(SWIGJAVA)
+
+%typemap(javaclassmodifiers) NotForDeriving1, NotForDeriving2 "public final class"
+%javamethodmodifiers NotForDeriving1::~NotForDeriving1 "public synchronized final";
+%javamethodmodifiers NotForDeriving2::~NotForDeriving2 "public synchronized final";
+
+#endif
+
+%inline %{
+//#include <iostream>
+struct NotForDeriving1 {
+ void notvirtual() {}
+ ~NotForDeriving1() {
+// std::cout << "~NotForDeriving1 called" << std::endl;
+ }
+};
+struct NotForDeriving2 {
+ void notvirtual() {}
+#if defined(SWIG)
+%extend {
+ ~NotForDeriving2() {
+// std::cout << "~NotForDeriving2 called" << std::endl;
+ }
+}
+#endif
+};
+%}
diff --git a/Examples/test-suite/director_basic.i b/Examples/test-suite/director_basic.i
index 4c258b097..23d910324 100644
--- a/Examples/test-suite/director_basic.i
+++ b/Examples/test-suite/director_basic.i
@@ -1,6 +1,11 @@
%module(directors="1") director_basic
+#ifdef SWIGOCAML
+%warnfilter(SWIGWARN_PARSE_KEYWORD) method;
+#endif
+
%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) MyClass::pmethod;
+%warnfilter(SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) ConstPtrClass::getConstPtr;
%{
#include <string>
@@ -65,6 +70,14 @@
%}
+ %typemap(cscode) MyClass %{
+ public void testSwigDerivedClassHasMethod() {
+ if (SwigDerivedClassHasMethod("nonVirtual", swigMethodTypes3))
+ throw new global::System.Exception("non-overriding non-virtual method would be when connecting director");
+ if (SwigDerivedClassHasMethod("nonOverride", swigMethodTypes4))
+ throw new global::System.Exception("non-overriding virtual method would be when connecting director");
+ }
+ %}
%feature("director") MyClass;
@@ -121,6 +134,29 @@ public:
static Bar * call_pmethod(MyClass *myclass, Bar *b) {
return myclass->pmethod(b);
}
+
+ virtual int nonVirtual()
+ {
+ return 100;
+ }
+
+ virtual int nonOverride()
+ {
+ return 101;
+ }
+
+ static int call_nonVirtual(MyClass *myclass)
+ {
+ return myclass->nonVirtual();
+ }
+
+ static int call_nonOverride(MyClass *myclass)
+ {
+ return myclass->nonOverride();
+ }
+
+ // Collisions with generated method names
+ virtual void Connect() { }
};
template<class T>
@@ -139,7 +175,19 @@ public:
}
};
-
-%}
+ %}
%template(MyClassT_i) MyClassT<int>;
+
+ %feature("director") ConstPtrClass;
+
+ %inline %{
+
+class ConstPtrClass {
+public:
+ virtual ~ConstPtrClass() {}
+ virtual int *const getConstPtr() = 0;
+};
+
+ %}
+
diff --git a/Examples/test-suite/director_classes.i b/Examples/test-suite/director_classes.i
index 98c29e88c..52342bfc8 100644
--- a/Examples/test-suite/director_classes.i
+++ b/Examples/test-suite/director_classes.i
@@ -3,6 +3,11 @@
%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) Base::Ref;
%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) Base::Ptr;
+%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) Base::ConstPtrRef;
+
+#ifdef SWIGOCAML
+%warnfilter(SWIGWARN_PARSE_KEYWORD) val;
+#endif
%module(directors="1") director_classes
@@ -43,6 +48,7 @@ public:
virtual DoubleHolder Val(DoubleHolder x) { if (PrintDebug) std::cout << "Base - Val(" << x.val << ")" << std::endl; return x; }
virtual DoubleHolder& Ref(DoubleHolder& x) { if (PrintDebug) std::cout << "Base - Ref(" << x.val << ")" << std::endl; return x; }
virtual DoubleHolder* Ptr(DoubleHolder* x) { if (PrintDebug) std::cout << "Base - Ptr(" << x->val << ")" << std::endl; return x; }
+ virtual DoubleHolder *const& ConstPtrRef(DoubleHolder *const& cprx) { if (PrintDebug) std::cout << "Base - ConstPtrRef(" << cprx->val << ")" << std::endl; return cprx; }
virtual std::string FullyOverloaded(int x) { if (PrintDebug) std::cout << "Base - FullyOverloaded(int " << x << ")" << std::endl; return "Base::FullyOverloaded(int)"; }
virtual std::string FullyOverloaded(bool x) { if (PrintDebug) std::cout << "Base - FullyOverloaded(bool " << x << ")" << std::endl; return "Base::FullyOverloaded(bool)"; }
@@ -68,6 +74,7 @@ public:
virtual DoubleHolder Val(DoubleHolder x) { if (PrintDebug) std::cout << "Derived - Val(" << x.val << ")" << std::endl; return x; }
virtual DoubleHolder& Ref(DoubleHolder& x) { if (PrintDebug) std::cout << "Derived - Ref(" << x.val << ")" << std::endl; return x; }
virtual DoubleHolder* Ptr(DoubleHolder* x) { if (PrintDebug) std::cout << "Derived - Ptr(" << x->val << ")" << std::endl; return x; }
+ virtual DoubleHolder *const& ConstPtrRef(DoubleHolder *const& cprx) { if (PrintDebug) std::cout << "Derived - ConstPtrRef(" << cprx->val << ")" << std::endl; return cprx; }
virtual std::string FullyOverloaded(int x) { if (PrintDebug) std::cout << "Derived - FullyOverloaded(int " << x << ")" << std::endl; return "Derived::FullyOverloaded(int)"; }
virtual std::string FullyOverloaded(bool x) { if (PrintDebug) std::cout << "Derived - FullyOverloaded(bool " << x << ")" << std::endl; return "Derived::FullyOverloaded(bool)"; }
@@ -99,6 +106,7 @@ public:
DoubleHolder ValCall(DoubleHolder x) { return m_base->Val(x); }
DoubleHolder& RefCall(DoubleHolder& x) { return m_base->Ref(x); }
DoubleHolder* PtrCall(DoubleHolder* x) { return m_base->Ptr(x); }
+ DoubleHolder *const& ConstPtrRefCall(DoubleHolder *const& cprx) { return m_base->ConstPtrRef(cprx); }
std::string FullyOverloadedCall(int x) { return m_base->FullyOverloaded(x); }
std::string FullyOverloadedCall(bool x) { return m_base->FullyOverloaded(x); }
std::string SemiOverloadedCall(int x) { return m_base->SemiOverloaded(x); }
diff --git a/Examples/test-suite/director_comparison_operators.i b/Examples/test-suite/director_comparison_operators.i
new file mode 100644
index 000000000..f2251ed6d
--- /dev/null
+++ b/Examples/test-suite/director_comparison_operators.i
@@ -0,0 +1,23 @@
+%module(directors="1") director_comparison_operators
+
+%include "std_string.i"
+%feature("director");
+
+#if !defined(SWIGLUA) && !defined(SWIGR)
+%rename(EqualEqual) operator ==;
+%rename(NotEqual) operator !=;
+%rename(LessThanEqual) operator <=;
+%rename(GreaterThanEqual) operator >=;
+#endif
+
+%inline %{
+class Foo {
+public:
+ virtual ~Foo() { }
+ virtual bool operator==(const Foo&) const = 0;
+ virtual bool operator>=(const Foo&) const = 0;
+ virtual bool operator<=(const Foo&) const = 0;
+ virtual bool operator!=(const Foo&) const = 0;
+ virtual std::string test(const char *foo="a=1,b=2") { return foo; }
+};
+%}
diff --git a/Examples/test-suite/director_conversion_operators.i b/Examples/test-suite/director_conversion_operators.i
new file mode 100644
index 000000000..afcd49d3f
--- /dev/null
+++ b/Examples/test-suite/director_conversion_operators.i
@@ -0,0 +1,35 @@
+%module(directors="1") director_conversion_operators
+
+%feature("director");
+
+%warnfilter(SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) Bar;
+
+%rename(toFoo) Bar::operator Foo();
+%rename(toFooPtr) Bar::operator Foo *();
+%rename(toFooRef) Bar::operator Foo &();
+%rename(toFooPtrRef) Bar::operator Foo *&();
+
+%rename(toOtherFoo) Bar::operator OtherFoo();
+%rename(toOtherFooPtr) Bar::operator OtherFoo *();
+%rename(toOtherFooRef) Bar::operator OtherFoo &();
+%rename(toOtherFooPtrRef) Bar::operator OtherFoo *&();
+
+%inline %{
+ struct Foo {
+ };
+ struct OtherFoo {
+ };
+ struct Bar {
+ Foo myFoo;
+ Foo *myFooPtr;
+ virtual ~Bar() { }
+ virtual operator Foo () { return Foo(); }
+ virtual operator Foo *() { return &myFoo; }
+ virtual operator Foo &() { return myFoo; }
+ virtual operator Foo *&() { return myFooPtr; }
+ virtual operator OtherFoo () = 0;
+ virtual operator OtherFoo *() = 0;
+ virtual operator OtherFoo &() = 0;
+ virtual operator OtherFoo *&() = 0;
+ };
+%}
diff --git a/Examples/test-suite/director_exception.i b/Examples/test-suite/director_exception.i
index abe23b381..71366bef0 100644
--- a/Examples/test-suite/director_exception.i
+++ b/Examples/test-suite/director_exception.i
@@ -3,27 +3,17 @@
%warnfilter(SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) return_const_char_star;
%{
-
-#if defined(_MSC_VER)
- #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
-
#include <string>
-
// define dummy director exception classes to prevent spurious errors
// in target languages that do not support directors.
#ifndef SWIG_DIRECTORS
namespace Swig {
-class DirectorException {};
-class DirectorMethodException: public Swig::DirectorException {};
+ class DirectorException {};
+ class DirectorMethodException: public Swig::DirectorException {};
}
- #ifndef SWIG_fail
- #define SWIG_fail
- #endif
#endif /* !SWIG_DIRECTORS */
-
%}
%include "std_string.i"
@@ -31,14 +21,14 @@ class DirectorMethodException: public Swig::DirectorException {};
#ifdef SWIGPHP
%feature("director:except") {
- if ($error == FAILURE) {
- throw Swig::DirectorMethodException();
- }
+ if ($error == FAILURE) {
+ Swig::DirectorMethodException::raise("$symname");
+ }
}
%exception {
- try { $action }
- catch (Swig::DirectorException &) { SWIG_fail; }
+ try { $action }
+ catch (Swig::DirectorException &) { SWIG_fail; }
}
#endif
@@ -46,14 +36,14 @@ class DirectorMethodException: public Swig::DirectorException {};
#ifdef SWIGPYTHON
%feature("director:except") {
- if ($error != NULL) {
- throw Swig::DirectorMethodException();
- }
+ if ($error != NULL) {
+ Swig::DirectorMethodException::raise("$symname");
+ }
}
%exception {
- try { $action }
- catch (Swig::DirectorException &) { SWIG_fail; }
+ try { $action }
+ catch (Swig::DirectorException &) { SWIG_fail; }
}
#endif
@@ -71,12 +61,12 @@ class DirectorMethodException: public Swig::DirectorException {};
// Change back to old 2.0 default behavior
%feature("director:except") {
- jthrowable $error = jenv->ExceptionOccurred();
- if ($error) {
- // Dont clear exception, still be active when return to java execution
- // Essentially ignore exception occurred -- old behavior.
- return $null;
- }
+ jthrowable $error = jenv->ExceptionOccurred();
+ if ($error) {
+ // Dont clear exception, still be active when return to java execution
+ // Essentially ignore exception occurred -- old behavior.
+ return $null;
+ }
}
#endif
@@ -84,7 +74,7 @@ class DirectorMethodException: public Swig::DirectorException {};
#ifdef SWIGRUBY
%feature("director:except") {
- throw Swig::DirectorMethodException($error);
+ Swig::DirectorMethodException::raise($error);
}
%exception {
@@ -125,6 +115,18 @@ Foo *launder(Foo *f) {
%feature("director") Bar;
%feature("director") ReturnAllTypes;
+%{
+// throw is deprecated in C++11 and invalid in C++17 and later
+#if defined(__cplusplus) && __cplusplus >= 201103L
+#define throw(TYPE1, TYPE2, TYPE3)
+#else
+#define throw(TYPE1, TYPE2, TYPE3) throw(TYPE1, TYPE2, TYPE3)
+#if defined(_MSC_VER)
+ #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+#endif
+%}
+
%inline %{
struct Exception1
{
@@ -137,16 +139,15 @@ Foo *launder(Foo *f) {
class Base
{
public:
- virtual ~Base() throw () {}
+ virtual ~Base() {}
};
class Bar : public Base
{
public:
- virtual std::string ping() throw (Exception1, Exception2&) { return "Bar::ping()"; }
- virtual std::string pong() throw (Unknown1, int, Unknown2&) { return "Bar::pong();" + ping(); }
- virtual std::string pang() throw () { return "Bar::pang()"; }
+ virtual std::string ping() throw(Exception1, Exception2&, double) { return "Bar::ping()"; }
+ virtual std::string pong() throw(Unknown1, int, Unknown2&) { return "Bar::pong();" + ping(); }
};
// Class to allow regression testing SWIG/PHP not checking if an exception
diff --git a/Examples/test-suite/director_exception_catches.i b/Examples/test-suite/director_exception_catches.i
new file mode 100644
index 000000000..ad183665f
--- /dev/null
+++ b/Examples/test-suite/director_exception_catches.i
@@ -0,0 +1,25 @@
+%module(directors="1") director_exception_catches
+
+%include <std_string.i>
+%feature("director") BaseClass;
+
+%{
+// define dummy director exception classes to prevent spurious errors
+// in target languages that do not support directors.
+
+#ifndef SWIG_DIRECTORS
+namespace Swig {
+ class DirectorException {};
+}
+#endif /* !SWIG_DIRECTORS */
+%}
+
+%catches(Swig::DirectorException) BaseClass::call_description;
+
+%inline %{
+struct BaseClass {
+ virtual std::string description() const = 0;
+ static std::string call_description(BaseClass& bc) { return bc.description(); }
+ virtual ~BaseClass() {}
+};
+%}
diff --git a/Examples/test-suite/director_exception_nothrow.i b/Examples/test-suite/director_exception_nothrow.i
new file mode 100644
index 000000000..8a072617f
--- /dev/null
+++ b/Examples/test-suite/director_exception_nothrow.i
@@ -0,0 +1,28 @@
+%module(directors="1") director_exception_nothrow
+
+%include "std_string.i"
+
+%feature("director") Bar;
+
+%{
+#if defined(_MSC_VER)
+ #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+%}
+
+%inline %{
+#include <string>
+
+class Base
+{
+public:
+ virtual ~Base() throw() {}
+};
+
+
+class Bar : public Base
+{
+public:
+ virtual std::string pang() throw() { return "Bar::pang()"; }
+};
+%}
diff --git a/Examples/test-suite/director_extend.i b/Examples/test-suite/director_extend.i
index cec930a42..60a9d4cf0 100644
--- a/Examples/test-suite/director_extend.i
+++ b/Examples/test-suite/director_extend.i
@@ -25,7 +25,7 @@ namespace Swig {
size_t ExceptionMethod()
{
// Check positioning of director code in wrapper file
-// Below is what we really want to test, but director exceptions vary too much across across all languages
+// Below is what we really want to test, but director exceptions vary too much across all languages
// throw Swig::DirectorException("DirectorException was not in scope!!");
// Instead check definition of Director class as that is defined in the same place as DirectorException (director.swg)
size_t size = sizeof(Swig::Director);
diff --git a/Examples/test-suite/director_overload.i b/Examples/test-suite/director_overload.i
index 55bdf2caa..604ffe5ca 100644
--- a/Examples/test-suite/director_overload.i
+++ b/Examples/test-suite/director_overload.i
@@ -1,5 +1,9 @@
%module(directors="1") director_overload
+#ifdef SWIGOCAML
+%warnfilter(SWIGWARN_PARSE_KEYWORD) method;
+#endif
+
%feature("director");
#ifdef SWIGPYTHON
diff --git a/Examples/test-suite/director_ownership.i b/Examples/test-suite/director_ownership.i
new file mode 100644
index 000000000..48e909758
--- /dev/null
+++ b/Examples/test-suite/director_ownership.i
@@ -0,0 +1,72 @@
+%module(directors="1") director_ownership
+
+// Github issue #1184
+
+%include "std_string.i"
+
+%feature("director") example::ContentBase;
+%feature("director") example::ContentDerived;
+
+%newobject example::make_content;
+
+%inline %{
+#include <string>
+
+namespace example
+{
+
+class ContentBase
+{
+public:
+ ContentBase() {}
+ virtual ~ContentBase() {}
+ virtual std::string get_name() const = 0;
+};
+
+
+class ContentDerived: public ContentBase
+{
+public:
+ ContentDerived():ContentBase() { m_name = "ContentDerived"; }
+ virtual ~ContentDerived() {}
+ virtual std::string get_name() const { return m_name; }
+
+private:
+ std::string m_name;
+};
+
+
+class Container
+{
+public:
+ Container() { m_content = 0; }
+ ~Container()
+ {
+ clear_content();
+ }
+ // the container takes the ownership of the content
+ void set_content(ContentBase* content)
+ {
+ clear_content();
+ m_content = content;
+ }
+ ContentBase* get_content() { return m_content; }
+
+private:
+ void clear_content()
+ {
+ if(m_content)
+ {
+ delete m_content;
+ m_content = 0;
+ }
+ }
+
+private:
+ ContentBase* m_content;
+};
+
+static ContentBase* make_content() { return new ContentDerived(); }
+
+} // namespace example
+%}
diff --git a/Examples/test-suite/director_property.i b/Examples/test-suite/director_property.i
index da37ca4ae..d64e0c439 100644
--- a/Examples/test-suite/director_property.i
+++ b/Examples/test-suite/director_property.i
@@ -2,6 +2,10 @@
%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) MyClass::pmethod;
+#ifdef SWIGOCAML
+%warnfilter(SWIGWARN_PARSE_KEYWORD) method;
+#endif
+
%{
#include <string>
diff --git a/Examples/test-suite/director_smartptr.i b/Examples/test-suite/director_smartptr.i
index 9d0be80f0..d016af17e 100644
--- a/Examples/test-suite/director_smartptr.i
+++ b/Examples/test-suite/director_smartptr.i
@@ -44,7 +44,6 @@ public:
%include <boost_shared_ptr.i>
%shared_ptr(Foo)
-
%feature("director") Foo;
class FooBar {
@@ -72,5 +71,12 @@ public:
static Foo* get_self(Foo *self_);
};
+%shared_ptr(FooDerived)
+%feature("director") FooDerived;
+
+%inline %{
+struct FooDerived : Foo {
+};
+%}
#endif
diff --git a/Examples/test-suite/director_thread.i b/Examples/test-suite/director_thread.i
index 2732eb907..c4564737f 100644
--- a/Examples/test-suite/director_thread.i
+++ b/Examples/test-suite/director_thread.i
@@ -7,29 +7,51 @@
%module(directors="1") director_thread
#endif
+#ifdef SWIGOCAML
+%warnfilter(SWIGWARN_PARSE_KEYWORD) val;
+#endif
+
+%begin %{
+#define SWIG_JAVA_USE_THREAD_NAME
+//#define DEBUG_DIRECTOR_THREAD_NAME
+%}
+
%{
#ifdef _WIN32
#include <windows.h>
#include <process.h>
+#include <stdio.h>
#else
#include <pthread.h>
+#include <errno.h>
+#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#endif
-#include <iostream>
+#include <assert.h>
+#include "swig_examples_lock.h"
class Foo;
extern "C" {
#ifdef _WIN32
- unsigned int __stdcall working(void* t);
- unsigned int thread_id(0);
+ static unsigned int __stdcall working(void* t);
+ static HANDLE thread_handle = 0;
#else
void* working(void* t);
- pthread_t thread;
+ static pthread_t thread;
#endif
+
static int thread_terminate = 0;
-
+ static SwigExamples::CriticalSection critical_section;
+ int get_thread_terminate() {
+ SwigExamples::Lock lock(critical_section);
+ return thread_terminate;
+ }
+ void set_thread_terminate(int value) {
+ SwigExamples::Lock lock(critical_section);
+ thread_terminate = value;
+ }
}
%}
@@ -55,9 +77,10 @@ extern "C" {
}
void stop() {
- thread_terminate = 1;
+ set_thread_terminate(1);
%#ifdef _WIN32
- /*TODO(bhy) what to do for win32? */
+ WaitForSingleObject(thread_handle, INFINITE);
+ CloseHandle(thread_handle);
%#else
pthread_join(thread, NULL);
%#endif
@@ -65,13 +88,49 @@ extern "C" {
void run() {
%#ifdef _WIN32
- _beginthreadex(NULL,0,working,this,0,&thread_id);
+ unsigned int thread_id = 0;
+ thread_handle = (HANDLE)_beginthreadex(NULL,0,working,this,0,&thread_id);
+ if (thread_handle == 0) {
+ fprintf(stderr, "_beginthreadex failed in run()\n");
+ assert(0);
+ }
%#else
- pthread_create(&thread,NULL,working,this);
+ int create = pthread_create(&thread,NULL,working,this);
+ if (create != 0) {
+ errno = create;
+ perror("pthread_create in run()");
+ assert(0);
+ }
%#endif
MilliSecondSleep(500);
}
-
+
+ void setThreadName() {
+%#ifdef _WIN32
+%#else
+
+%#ifdef __APPLE__
+ int setname = pthread_setname_np("MyThreadName");
+%#else
+ int setname = pthread_setname_np(pthread_self(), "MyThreadName");
+%#endif
+
+ if (setname != 0) {
+ errno = setname;
+ perror("calling pthread_setname_np in setThreadName()");
+ assert(0);
+ }
+%#endif
+ }
+
+ static bool namedThread() {
+%#ifdef _WIN32
+ return false;
+%#else
+ return true;
+%#endif
+ }
+
virtual void do_foo() {
val += 1;
}
@@ -87,15 +146,11 @@ extern "C" {
#endif
{
Foo* f = static_cast<Foo*>(t);
- while ( ! thread_terminate ) {
+ f->setThreadName();
+ while (!get_thread_terminate()) {
MilliSecondSleep(50);
f->do_foo();
}
-#ifdef _WIN32
- /* TODO(bhy) what's the corresponding of pthread_exit in win32? */
-#else
- pthread_exit(0);
-#endif
return 0;
}
}
diff --git a/Examples/test-suite/director_void.i b/Examples/test-suite/director_void.i
index 40f53b6e2..d9d99aaac 100644
--- a/Examples/test-suite/director_void.i
+++ b/Examples/test-suite/director_void.i
@@ -43,5 +43,9 @@ struct Caller {
return *(int *)p;
}
};
+
+struct MemberVoid {
+ void *memberVariable;
+};
%}
diff --git a/Examples/test-suite/doxygen_alias.i b/Examples/test-suite/doxygen_alias.i
new file mode 100644
index 000000000..79cb7964b
--- /dev/null
+++ b/Examples/test-suite/doxygen_alias.i
@@ -0,0 +1,22 @@
+%module doxygen_alias
+
+#ifdef SWIGJAVA
+%feature("doxygen:alias:nullptr") "null"
+#elif defined(SWIGPYTHON)
+%feature("doxygen:alias:nullptr") "None"
+#else
+%feature("doxygen:alias:nullptr") "NULL"
+#endif
+
+%inline %{
+
+class Something {};
+
+/**
+ A function returning something.
+
+ @returns A new object which may be @nullptr.
+ */
+Something* make_something() { return 0; }
+
+%}
diff --git a/Examples/test-suite/doxygen_basic_notranslate.i b/Examples/test-suite/doxygen_basic_notranslate.i
new file mode 100644
index 000000000..e62be5437
--- /dev/null
+++ b/Examples/test-suite/doxygen_basic_notranslate.i
@@ -0,0 +1,110 @@
+%module doxygen_basic_notranslate
+
+%include "doxygen_basic_translate.h"
+%feature("doxygen:notranslate") function;
+%feature("doxygen:notranslate") function1;
+%feature("doxygen:notranslate") function2;
+%feature("doxygen:notranslate") function3;
+%feature("doxygen:notranslate") function4;
+%feature("doxygen:notranslate") function5;
+%feature("doxygen:notranslate") function6;
+%feature("doxygen:notranslate") function7;
+
+%inline %{
+
+/**
+ * \brief
+ * Brief description.
+ *
+ * The comment text
+ * \author Some author
+ * \return Some number
+ * \sa function2
+ */
+int function()
+{
+ return 0;
+}
+
+/** Single line comment */
+void function1()
+{
+}
+
+/**
+ * A test of a very very very very very very very very very very very very very very very very
+ * very very very very very long comment string.
+ */
+void function2()
+{
+}
+
+/**
+ * A test for overloaded functions
+ * This is function \b one
+ */
+void function3(int a)
+{
+}
+
+/**
+ * A test for overloaded functions
+ * This is function \b two
+ */
+void function3(int a, int b)
+{
+}
+
+/**
+ * A test of some mixed tag usage
+ * \if CONDITION
+ * This \a code fragment shows us something \.
+ * \par Minuses:
+ * \arg it's senseless
+ * \arg it's stupid
+ * \arg it's null
+ *
+ * \warning This may not work as expected
+ *
+ * \code
+ * int main() { while(true); }
+ * \endcode
+ * \endif
+ */
+void function4()
+{
+}
+
+
+void function5(int a)
+{
+}
+/**< This is a post comment. */
+
+/**
+ * Test for default args
+ * @param a Some parameter, default is 42
+ */
+void function6(int a=42)
+{
+}
+
+class Shape
+{
+public:
+ typedef Shape* superType;
+};
+
+/**
+ * Test for a parameter with difficult type
+ * (mostly for python)
+ * @param a Very strange param
+ */
+void function7(Shape::superType *a[10])
+{
+}
+
+/**
+ * Comment at the end of file should be ignored.
+ */
+%}
diff --git a/Examples/test-suite/doxygen_basic_translate.h b/Examples/test-suite/doxygen_basic_translate.h
new file mode 100644
index 000000000..7b2b3f58a
--- /dev/null
+++ b/Examples/test-suite/doxygen_basic_translate.h
@@ -0,0 +1,5 @@
+
+/**
+ * This file contains only doxygen comment without a declaration -
+ * it should be ignored by SWIG and must not trigger syntax error.
+ */
diff --git a/Examples/test-suite/doxygen_basic_translate.i b/Examples/test-suite/doxygen_basic_translate.i
new file mode 100644
index 000000000..4e543fef9
--- /dev/null
+++ b/Examples/test-suite/doxygen_basic_translate.i
@@ -0,0 +1,130 @@
+%module doxygen_basic_translate
+
+%include "doxygen_basic_translate.h"
+
+%inline %{
+
+/**
+ * \brief
+ * Brief description.
+ *
+ * The comment text.
+ *
+ * \author Some author
+ *
+ * \return Some number
+ *
+ * \sa function2
+ */
+int function()
+{
+ return 0;
+}
+
+/**
+ * A test of a very very very very very very very very very very very very very very very very
+ * very very very very very long comment string.
+ */
+void function2()
+{
+}
+
+/**
+ * A test for overloaded functions
+ * This is function \b one
+ */
+void function3(int a)
+{
+}
+
+/**
+ * A test for overloaded functions
+ * This is function \b two
+ */
+void function3(int a, int b)
+{
+}
+
+/**
+ * A test of some mixed tag usage
+ * \if CONDITION
+ * This \a code fragment shows us something \.
+ * \par Minuses:
+ * \arg it's senseless
+ * \arg it's stupid
+ * \arg it's null
+ *
+ * \warning This may not work as expected
+ * \code
+ * int main() { while(true); }
+ *
+ * // Test blank line in code block
+ * \endcode
+ * \endif
+ */
+void function4()
+{
+}
+
+
+void function5(int a)
+{
+}
+/**< This is a post comment. */
+
+/**
+ * Test for default args
+ * @param a Some parameter, default is 42
+ */
+void function6(int a=42)
+{
+}
+
+class Shape
+{
+public:
+ typedef Shape* superType;
+};
+
+/**
+ * Test for a parameter with difficult type
+ * (mostly for python)
+ * @param a Very strange param
+ */
+void function7(Shape::superType *a[10])
+{
+}
+
+/**
+ Multiple parameters test.
+
+ @param y Vertical coordinate.
+ @param x Horizontal coordinate.
+ @return Arc tangent of @c y/x.
+ */
+double Atan2(double y, double x)
+{
+ return 0;
+}
+
+/* Regression test for crash with empty comment: */
+/**/
+
+/**
+ * @brief Test variadic function
+ * @param ... extra args
+ */
+void function8(...) {
+}
+
+/**
+ * @brief Test unnamed argument
+ * @param baz Description of baz
+ */
+void function9(int) {
+}
+
+/**
+ * Comment at the end of file should be ignored.
+ */
+%}
diff --git a/Examples/test-suite/doxygen_basic_translate_style2.i b/Examples/test-suite/doxygen_basic_translate_style2.i
new file mode 100644
index 000000000..32e3cfcbe
--- /dev/null
+++ b/Examples/test-suite/doxygen_basic_translate_style2.i
@@ -0,0 +1,107 @@
+%module doxygen_basic_translate_style2
+
+%include "doxygen_basic_translate.h"
+
+// This test demonstrates a doxygen comment style that starts on the
+// first line and so uses extra spacing in subsequent lines.
+
+%inline %{
+
+/** \brief
+ * Brief description.
+ *
+ * The comment text.
+ *
+ * \author Some author
+ *
+ * \return Some number
+ *
+ * \sa function2
+ */
+int function()
+{
+ return 0;
+}
+
+/** A test of a very very very very very very very very very very very very very very very very
+ * very very very very very long comment string.
+ */
+void function2()
+{
+}
+
+/** A test for overloaded functions
+ * This is function \b one
+ */
+void function3(int a)
+{
+}
+
+/** A test for overloaded functions
+ * This is function \b two
+ */
+void function3(int a, int b)
+{
+}
+
+/** A test of some mixed tag usage
+ * \if CONDITION
+ * This \a code fragment shows us something \.
+ * \par Minuses:
+ * \arg it's senseless
+ * \arg it's stupid
+ * \arg it's null
+ *
+ * \warning This may not work as expected
+ * \code
+ * int main() { while(true); }
+ *
+ * // Test blank line in code block
+ * \endcode
+ * \endif
+ */
+void function4()
+{
+}
+
+
+void function5(int a)
+{
+}
+/**< This is a post comment. */
+
+/** Test for default args
+ * @param a Some parameter, default is 42
+ */
+void function6(int a=42)
+{
+}
+
+class Shape
+{
+public:
+ typedef Shape* superType;
+};
+
+/** Test for a parameter with difficult type
+ * (mostly for python)
+ * @param a Very strange param
+ */
+void function7(Shape::superType *a[10])
+{
+}
+
+/** Multiple parameters test.
+ *
+ * @param y Vertical coordinate.
+ * @param x Horizontal coordinate.
+ * @return Arc tangent of @c y/x.
+ */
+double Atan2(double y, double x)
+{
+ return 0;
+}
+
+/** Comment at the end of file should be ignored.
+ */
+%}
diff --git a/Examples/test-suite/doxygen_basic_translate_style3.i b/Examples/test-suite/doxygen_basic_translate_style3.i
new file mode 100644
index 000000000..e364b164f
--- /dev/null
+++ b/Examples/test-suite/doxygen_basic_translate_style3.i
@@ -0,0 +1,102 @@
+%module doxygen_basic_translate_style3
+
+%include "doxygen_basic_translate.h"
+
+%inline %{
+
+/// \brief
+/// Brief description.
+///
+/// The comment text.
+///
+/// \author Some author
+///
+/// \return Some number
+///
+/// \sa function2
+int function()
+{
+ return 0;
+}
+
+/// A test of a very very very very very very very very very very very very very very very very
+/// very very very very very long comment string.
+void function2()
+{
+}
+
+/// A test for overloaded functions
+/// This is function \b one
+void function3(int a)
+{
+}
+
+/// A test for overloaded functions
+/// This is function \b two
+void function3(int a, int b)
+{
+}
+
+/// A test of some mixed tag usage
+/// \if CONDITION
+/// This \a code fragment shows us something \.
+/// \par Minuses:
+/// \arg it's senseless
+/// \arg it's stupid
+/// \arg it's null
+///
+/// \warning This may not work as expected
+/// \code
+/// int main() { while(true); }
+///
+/// int testBlankLine() {}
+/// \endcode
+/// \endif
+void function4()
+{
+ // Note: a comment in the above code block will not get processed
+ // correctly with this doxygen comment style, because
+ // DoxygenParser::tokenizeDoxygenComment strips out the leading
+ // comment characters. Whereas it works in the other doxygen
+ // comment styles (as shown in the other variations of
+ // doxygen_basic_translate), this test is modified to remove the
+ // comment within the code block.
+}
+
+
+void function5(int a)
+{
+}
+///< This is a post comment.
+
+/// Test for default args
+/// @param a Some parameter, default is 42
+void function6(int a=42)
+{
+}
+
+class Shape
+{
+public:
+ typedef Shape* superType;
+};
+
+/// Test for a parameter with difficult type
+/// (mostly for python)
+/// @param a Very strange param
+void function7(Shape::superType *a[10])
+{
+}
+
+/// Multiple parameters test.
+///
+/// @param y Vertical coordinate.
+/// @param x Horizontal coordinate.
+/// @return Arc tangent of @c y/x.
+double Atan2(double y, double x)
+{
+ return 0;
+}
+
+/// Comment at the end of file should be ignored.
+%}
diff --git a/Examples/test-suite/doxygen_code_blocks.i b/Examples/test-suite/doxygen_code_blocks.i
new file mode 100644
index 000000000..900e8f9bb
--- /dev/null
+++ b/Examples/test-suite/doxygen_code_blocks.i
@@ -0,0 +1,62 @@
+%module doxygen_code_blocks
+
+// This test is only used with Python
+
+%inline %{
+
+/**
+ * \brief Test for code blocks
+ *
+ * \code
+ * simple code block
+ * \endcode
+ *
+ * More advanced usage with C++ characters:
+ * \code
+ * std::vector<int> first; // empty vector of ints
+ * std::vector<int> second (4,100); // four ints with value 100
+ * std::vector<int> third (second.begin(),second.end()); // iterating through second
+ * std::vector<int> fourth (third); // a copy of third
+ * // the iterator constructor can also be used to construct from arrays:
+ * int myints[] = {16,2,77,29};
+ * std::vector<int> fifth (myints, myints + sizeof(myints) / sizeof(int) );
+ *
+ * std::cout << "The contents of fifth are:";
+ * for (std::vector<int>::iterator it = fifth.begin(); it != fifth.end(); ++it)
+ * std::cout << ' ' << *it;
+ * std::cout << '\n';
+ * \endcode
+ *
+ * A code block for C:
+ * \code{.c}
+ * printf("hello world");
+ * \endcode
+ *
+ * A code block for Java:
+ * \code{.java}
+ * public class HelloWorld {
+ * public static void main(String[] args) {
+ * // Prints "Hello, World" to the terminal window.
+ * System.out.println("Hello, World");
+ * }
+ * }
+ * \endcode
+ *
+ * A code block for python:
+ * \code{.py}
+ * print('hello world')
+ * \endcode
+ *
+ * A python doctest example:
+ * \code{.py}
+ * >>> 1 + 1
+ * 2
+ * \endcode
+ */
+int function()
+{
+ return 0;
+}
+
+
+%}
diff --git a/Examples/test-suite/doxygen_ignore.i b/Examples/test-suite/doxygen_ignore.i
new file mode 100644
index 000000000..8e5449f43
--- /dev/null
+++ b/Examples/test-suite/doxygen_ignore.i
@@ -0,0 +1,41 @@
+%module doxygen_ignore
+
+%feature("doxygen:ignore:transferfull");
+%feature("doxygen:ignore:compileroptions", range="line");
+%feature("doxygen:ignore:forcpponly", range="end");
+
+#ifdef SWIGJAVA
+%feature("doxygen:ignore:beginJavaOnly", range="end:endJavaOnly", contents="parse");
+%feature("doxygen:ignore:beginPythonOnly", range="end:endPythonOnly");
+#elif defined(SWIGPYTHON)
+%feature("doxygen:ignore:beginJavaOnly", range="end:endJavaOnly");
+%feature("doxygen:ignore:beginPythonOnly", range="end:endPythonOnly", contents="parse");
+#else
+%feature("doxygen:ignore:beginJavaOnly", range="end:endJavaOnly");
+%feature("doxygen:ignore:beginPythonOnly", range="end:endPythonOnly");
+#endif
+
+%inline %{
+
+/**
+ A contrived example of ignoring too many commands in one comment.
+
+ @forcpponly
+ This is C++-specific.
+ @endforcpponly
+
+ @beginJavaOnly
+ This is specific to @e Java.
+ @endJavaOnly
+
+ @beginPythonOnly
+ This is specific to @b Python.
+ @endPythonOnly
+
+ @transferfull Command ignored, but anything here is still included.
+
+ @compileroptions This function must be compiled with /EHa when using MSVC.
+ */
+int * func() { return 0; }
+
+%}
diff --git a/Examples/test-suite/doxygen_misc_constructs.h b/Examples/test-suite/doxygen_misc_constructs.h
new file mode 100644
index 000000000..9e81aaf28
--- /dev/null
+++ b/Examples/test-suite/doxygen_misc_constructs.h
@@ -0,0 +1,102 @@
+/*
+ * This file contains comments which demonstrate details about Doxygen processing,
+ * so they can be emulated in SWIG doxy comment translation
+ */
+
+
+
+/**This comment without space after '*' is valid in Doxygen.
+ *
+ */
+void isNoSpaceValidA()
+{}
+
+/**.This comment without space after '*' is valid in Doxygen.
+ *
+ */
+void isNoSpaceValidB()
+{}
+
+
+/***This is not Doxygen comment.
+ *
+ */
+void isNoSpaceValidC()
+{}
+
+
+/**
+ * Backslash following\c word is a valid doxygen command. Output contains
+ * 'followingword' with 'word' in code font.
+ */
+void backslashA()
+{}
+
+// Output of escaped symbols below in doxygen generated HTML:
+// Rendered: Escaped symbols: $ @ \ & < > # % " \. :: @text ::text
+// HTML source: Escaped symbols: $ @ \ &amp; &lt; &gt; # % " \. :: @text ::text
+
+
+/**
+ * Doxy command without trailing \cspace space is ignored - nothing appears
+ * on output. Standalone \ and '\' get to output.
+ * Standalone @ and '@' get to output.
+ * Commands "in quoted \b strings are treated as plain text".
+ * Commands not recognized by Doxygen \blah @blah are ignored.
+ * Backslashes in DOS paths d:\xyz\qwe\myfile and words
+ * following them do not appear on output, we must quote them with
+ * double quotes: "d:\xyz\qwe\myfile", "@something". Single quotes do not help:
+ * 'd:\xyz\qwe\myfile'. Escaping works: d:\\xyz\\qwe\\myfile. Unix
+ * paths of course have no such problems: /xyz/qwe/myfile
+ * Commands for escaped symbols:
+ * \$ \@ \\ \& \~ \< \> \# \% \" \. \:: \@text \::text
+ */
+void backslashB()
+{}
+
+/**
+ * Backslash e at end of \e line froze SWIG \e
+ * with old comment parser.
+ *
+ * @see MyClass::fun(char,
+ * float)
+ */
+void backslashC()
+{}
+
+/**
+ * The next line contains expression:
+ * <pre>
+ * ['retVal < 10', 'g_counter == 23 && g_mode & 3']
+ *</pre>
+ *
+ * Both words should be emphasized \b isystem.connect.
+ * But not the last period. For \b example, comma should not be emphasized.
+ * Similar \b for: double colon.
+ *
+ * Spaces at the start of line should be taken into account:
+ * @param id used as prefix in log
+ * statements. The default value is empty string, which is OK if
+ * there is only one app. instance. Example:
+ * <pre>
+ * ctrl.setBP("func1");
+ * </pre>
+ * If we set the id to \c main_, we get:
+ * <pre>
+ * main_ctrl.setBP("func1");
+ * </pre>
+ *
+ * @param fileName name of the log file
+ */
+void cycle(int id, char *fileName)
+{}
+
+/// This doc comment ends with a quote: "and that's ok"
+void doc_ends_with_quote() {}
+
+/**
+ This comment contains embedded triple-quoted string:
+
+ """How quaint"""
+ */
+void doc_with_triple_quotes() {}
diff --git a/Examples/test-suite/doxygen_misc_constructs.i b/Examples/test-suite/doxygen_misc_constructs.i
new file mode 100644
index 000000000..9cf95de39
--- /dev/null
+++ b/Examples/test-suite/doxygen_misc_constructs.i
@@ -0,0 +1,127 @@
+// This file contains tests for situations, which do not normally
+// appear in the code, but must nevertheless be handled correctly.
+
+%module doxygen_misc_constructs
+
+%warnfilter(SWIGWARN_DOXYGEN_UNKNOWN_COMMAND) backslashB;
+
+%inline %{
+
+ // Tag '@endink' must be recognized even if it is not
+ // followed by whitespace.
+
+ /** Tag endlink must be recognized also when followed by nonspace character.
+ *
+ * @link Connection::getId() @endlink<br> */
+
+ char g_counter;
+
+
+ /**
+ Tag endlink must be recognized also when it is the last token
+ in the comment.
+
+ @link Connection::getId() @endlink<br>
+ @link debugIdeTraceProfilerCoverageSample.py Python example. @endlink
+ */
+ int g_zipCode;
+
+
+ // Parameter 'isReportSize' must appear in comment of the overload, which
+ // has it. Empty line before link must be preserved.
+ /**
+ * Returns address of file line.
+ *
+ * @param fileName name of the file, where the source line is located
+ * @param line line number
+ * @param isGetSize if set, for every object location both address and size are returned
+ *
+ * @link Connection::getId() @endlink<br>
+ */
+ void getAddress(int &fileName,
+ int line,
+ bool isGetSize = false) {}
+
+ // The first comment must be ignored.
+ /**
+ * \defgroup icFacade isystem.connect Facade
+ *
+ * This page shows the core classes, which can be used to control
+ * all aspects of winIDEA, for example: debugging, analyzers, IO module, ...
+ */
+
+ /**
+ * This class contains information for connection to winIDEA. Its methods
+ * return reference to self, so we can use it like this:
+ * <pre>
+ * CConnectionConfig config = new CConnectionConfig();
+ * config.discoveryPort(5534).dllPath("C:\\myWinIDEA\\connect.dll").id("main");
+ * </pre>
+ *
+ * All parameters are optional. Set only what is required, default values are
+ * used for unspecified parameters.
+ * <p>
+ *
+ * @link advancedWinIDEALaunching.py Python example.@endlink<br>
+ */
+ class CConnectionConfig
+ {
+ };
+
+ // Text after '\c' must be kept unchanged in Python.
+ /**
+ * Determines how long the \c isystem.connect should wait for running
+ * instances to respond. Only one of \c lfWaitXXX flags from IConnect::ELaunchFlags
+ * may be specified.
+ */
+ int waitTime(long waitTime) {return 33;}
+
+
+ // Line with tag \ingroup must not appear in translated comment:
+ /** \ingroup icFacade
+ *
+ * This function returns connection id.
+ */
+ int getConnection() {return 3;}
+
+ // the following must produce no comment in wrapper
+ /*******************************************************************/
+ char getFirstLetter() {return 'a';}
+
+
+ /**
+ * Class description.
+ */
+ class ClassWithNestedEnum {
+ public:
+ /**
+ * Enum description.
+ */
+ typedef enum {ONE, ///< desc of one
+ TWO, ///< desc of two
+ THREE ///< desc of three
+ } ENested;
+
+ };
+
+ /// @return This is a bad place for this tag, but it should be ignored.
+ struct StructWithReturnComment {};
+
+ /**
+ An example of a list in a documentation comment.
+
+ - The first item of the list.
+ - The second list item, on
+ several indented lines,
+ showing that the indentation
+ is preserved.
+ - And the final list item after it.
+
+ And this is not a list item any more.
+ */
+ void showList() { }
+
+ #include "doxygen_misc_constructs.h"
+
+%}
+ %include "doxygen_misc_constructs.h"
diff --git a/Examples/test-suite/doxygen_nested_class.i b/Examples/test-suite/doxygen_nested_class.i
new file mode 100644
index 000000000..55575e34f
--- /dev/null
+++ b/Examples/test-suite/doxygen_nested_class.i
@@ -0,0 +1,24 @@
+%module doxygen_nested_class
+
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) DoxOuter::DoxInner;
+
+%inline %{
+
+struct DoxOuter {
+ /** DoxOuter constructor */
+ DoxOuter() {}
+ /** DoxInner class description */
+ struct DoxInner {
+ /** DoxInner constructor */
+ DoxInner() {}
+ /** doxInt variable */
+ int doxInt;
+ /** doxShort const variable */
+ static const short doxShort = 1;
+ /** doxMethod description */
+ void doxMethod() {}
+ /** doxStaticMethod description */
+ static void doxStaticMethod() {}
+ };
+};
+%}
diff --git a/Examples/test-suite/doxygen_parsing.i b/Examples/test-suite/doxygen_parsing.i
new file mode 100644
index 000000000..3a559053d
--- /dev/null
+++ b/Examples/test-suite/doxygen_parsing.i
@@ -0,0 +1,141 @@
+%module doxygen_parsing
+
+%inline %{
+
+/**
+ * The class comment
+ */
+class SomeClass
+{
+};
+
+/**
+ * The function comment
+ */
+void someFunction()
+{
+}
+
+/**
+ * The enum comment
+ */
+enum SomeEnum
+{
+ SOME_ENUM_ITEM
+};
+
+/**
+ * The struct comment
+ */
+struct SomeStruct
+{
+ int width; ///< \**immutable** image width in pixels
+};
+
+/**
+ * The var comment
+ */
+int someVar=42;
+
+/**
+ * The constant comment
+ */
+#define CONSTANT_VALUE 4242
+
+/// SomeAnotherClass description
+class SomeAnotherClass
+{
+public:
+ /// First overloaded constructor.
+ SomeAnotherClass(int) { }
+
+ /// Second overloaded constructor.
+ SomeAnotherClass(const char*) { }
+
+
+ /**
+ * The class attribute comment
+ */
+ int classAttr;
+
+ int classAttr2; ///< The class attribute post-comment
+
+ int classAttr3; ///< The class attribute post-comment
+ //!< with details
+
+ /**
+ * The class method comment.
+ *
+ * \link SomeAnotherClass#classMethodExtended(int, int) a link text \endlink
+ */
+ void classMethod()
+ {
+ }
+
+ /**
+ * The class method with parameter
+ */
+ void classMethodExtended(
+ int a, ///< Parameter a
+ int b ///< Parameter b
+ )
+ {
+ }
+
+ /**
+ * The class method with parameter
+ *
+ * @param a Parameter a
+ * @param b Parameter b
+ */
+ void classMethodExtended2(int a, int b)
+ {
+ }
+};
+
+struct SomeAnotherStruct
+{
+ /**
+ * The struct attribute comment
+ */
+ int structAttr;
+
+ int structAttr2; ///< The struct attribute post-comment
+
+ int structAttr3; ///< The struct attribute post-comment
+ //!< with details
+
+ /**
+ * The struct method comment
+ */
+ void structMethod()
+ {
+ }
+
+ /**
+ * The struct method with parameter
+ */
+ void structMethodExtended(
+ int a, ///< Parameter a
+ int b ///< Parameter b
+ )
+ {
+ }
+
+ /**
+ * The struct method with parameter
+ *
+ * @param a Parameter a
+ * @param b Parameter b
+ */
+ void structMethodExtended2(int a, int b)
+ {
+ }
+};
+
+#ifdef SWIGPYTHON_BUILTIN
+bool is_python_builtin() { return true; }
+#else
+bool is_python_builtin() { return false; }
+#endif
+%}
diff --git a/Examples/test-suite/doxygen_parsing_enums.i b/Examples/test-suite/doxygen_parsing_enums.i
new file mode 100644
index 000000000..b7a39871f
--- /dev/null
+++ b/Examples/test-suite/doxygen_parsing_enums.i
@@ -0,0 +1,40 @@
+%module doxygen_parsing_enums
+
+%inline %{
+
+
+ /**
+ * Testing comments before enum items
+ */
+ enum SomeAnotherEnum
+ {
+ /**
+ * The comment for the first item
+ */
+ SOME_ITEM_1,
+ /**
+ * The comment for the second item
+ */
+ SOME_ITEM_2,
+ /**
+ * The comment for the third item
+ */
+ SOME_ITEM_3
+ };
+
+ /**
+ * Testing comments after enum items
+ */
+ enum SomeAnotherEnum2
+ {
+ SOME_ITEM_10, ///< Post comment for the first item
+ SOME_ITEM_20, ///< Post comment for the second item
+ SOME_ITEM_30 ///< Post comment for the third item
+ };
+
+ enum SomeEnumWithTrailingComma
+ {
+ SOME_ITEM_100, ///< Post comment after comma.
+ SOME_ITEM_200, ///< Post comment after last comma.
+ };
+%}
diff --git a/Examples/test-suite/doxygen_parsing_enums_proper.i b/Examples/test-suite/doxygen_parsing_enums_proper.i
new file mode 100644
index 000000000..1a69a84f1
--- /dev/null
+++ b/Examples/test-suite/doxygen_parsing_enums_proper.i
@@ -0,0 +1,7 @@
+%module "doxygen_parsing_enums_proper"
+
+// Test enum commenting using the proper enums in the target language
+%include "enums.swg"
+
+%include "doxygen_parsing_enums.i"
+
diff --git a/Examples/test-suite/doxygen_parsing_enums_simple.i b/Examples/test-suite/doxygen_parsing_enums_simple.i
new file mode 100644
index 000000000..823a27584
--- /dev/null
+++ b/Examples/test-suite/doxygen_parsing_enums_simple.i
@@ -0,0 +1,6 @@
+%module "doxygen_parsing_enums_simple"
+
+// Test enum commenting using simple constants (SWIG-1.3.21 and earlier default enum wrapping for C# and Java)
+%include "enumsimple.swg"
+
+%include "doxygen_parsing_enums.i" \ No newline at end of file
diff --git a/Examples/test-suite/doxygen_parsing_enums_typesafe.i b/Examples/test-suite/doxygen_parsing_enums_typesafe.i
new file mode 100644
index 000000000..25e355ee2
--- /dev/null
+++ b/Examples/test-suite/doxygen_parsing_enums_typesafe.i
@@ -0,0 +1,8 @@
+%module "doxygen_parsing_enums_typesafe"
+
+// Test enum commenting using the typesafe enum pattern in the target language
+%include "enumtypesafe.swg"
+
+#define SWIG_TEST_NOCSCONST // For C# typesafe enums
+
+%include "doxygen_parsing_enums.i" \ No newline at end of file
diff --git a/Examples/test-suite/doxygen_parsing_enums_typeunsafe.i b/Examples/test-suite/doxygen_parsing_enums_typeunsafe.i
new file mode 100644
index 000000000..e001035df
--- /dev/null
+++ b/Examples/test-suite/doxygen_parsing_enums_typeunsafe.i
@@ -0,0 +1,6 @@
+%module "doxygen_parsing_enums_typeunsafe"
+
+// Test enum commenting using a type unsafe enum pattern (constant integers in a class for the enum type)
+%include "enumtypeunsafe.swg"
+
+%include "doxygen_parsing_enums.i" \ No newline at end of file
diff --git a/Examples/test-suite/doxygen_translate.i b/Examples/test-suite/doxygen_translate.i
new file mode 100644
index 000000000..bb0af1c14
--- /dev/null
+++ b/Examples/test-suite/doxygen_translate.i
@@ -0,0 +1,266 @@
+%module doxygen_translate
+
+#if defined(SWIGJAVA)
+%javamethodmodifiers function "@Deprecated\npublic"
+#endif
+
+%inline %{
+
+/**
+ * \a Hello
+ *
+ * \arg some list item
+ *
+ * \authors lots of them
+ *
+ * \author Zubr
+ *
+ * \b boldword
+ *
+ * \c codeword
+ *
+ * \cite citationword
+ *
+ * \code some test code \endcode
+ *
+ * \cond SOMECONDITION
+ * Some conditional comment
+ * \endcond
+ *
+ * \copyright some copyright
+ *
+ * \deprecated Now use another function
+ *
+ * \e italicword
+ *
+ * \example someFile.txt
+ * Some details on using the example
+ *
+ * \exception SuperError
+ *
+ * \if ANOTHERCONDITION
+ * First part of comment
+ * \if SECONDCONDITION
+ * Nested condition text
+ * \elseif THIRDCONDITION
+ * The third condition text
+ * \else
+ * The last text block
+ * \endif
+ * \else
+ * Second part of comment
+ * \if CONDITION
+ * Second part extended
+ * \endif
+ * \endif
+ *
+ * \ifnot SOMECONDITION
+ * This is printed if not
+ * \endif
+ *
+ * \image html testImage.bmp "Hello, world!" width=10cm
+ *
+ * <ul>
+ *
+ * \li Some unordered list
+ * \li With lots of items
+ * \li lots of lots of items
+ *
+ * </ul>
+ *
+ * \link someMember Some description follows \endlink
+ *
+ * \n \n \n
+ *
+ * \note Here
+ * is the note!
+ *
+ * \overload
+ *
+ * \p someword
+ *
+ * \package superPackage
+ *
+ * \par The paragraph title
+ * The paragraph text.
+ * Maybe even multiline
+ *
+ * \param a the first param
+ *
+ * \remark Some remark text
+ *
+ * \remarks Another remarks section
+ *
+ * \result Whatever
+ *
+ * \return it
+ *
+ * \returns may return
+ *
+ * \sa someOtherMethod
+ *
+ * \see function
+ *
+ * \since version 0.0.0.1
+ *
+ * \throw superException
+ *
+ * \throws RuntimeError
+ *
+ * \todo Some very important task
+ *
+ * \tparam b B is mentioned again...
+ *
+ * \verbatim
+ * very long
+ * text with tags <sometag>
+ * \endverbatim
+ *
+ * \version 0.0.0.2
+ *
+ * \warning This is senseless!
+ *
+ * Here goes test of symbols:
+ * \$ \@ \\ \& \~ \< \> \# \% \" \. \::
+ *
+ * And here goes simple text
+ */
+int function(int a, float b)
+{
+ return 0;
+}
+
+/**
+ * Test for html tags. See Doxygen doc for list of tags recognized by Doxygen.
+ *
+ * <a href="http://acme.com/index.html">This is link</a>
+ * <b>bold</b>
+ * <BLOCKQUOTE cite="http://www.worldwildlife.org/who/index.html">
+ * Quotation block.
+ * </BLOCKQUOTE>
+ * <br>
+ * <center>center</center>
+ * <code>this is code</code>
+ *
+ * <DL>
+ * <DT>Starts an item title.</DT>
+ * <DD>Starts an item description.</dd>
+ * </dl>
+ *
+ * <DFN>Starts a piece of text displayed in a typewriter font.
+ * </DFN>
+ * <DIV>Starts a section with a specific style (HTML only)
+ * </DIV>
+ * <EM>Starts a piece of text displayed in an italic font.</EM>
+ *
+ * <FORM>'Form' does not generate any output.
+ * </FORM>
+ * <HR>
+ * <H1>Heading 1
+ * </H1>
+ * <H2>Heading 2
+ * </H2>
+ * <H3>Heading 3
+ * </H3>
+ * <I>Starts a piece of text displayed in an italic font.</I>
+ * <INPUT>Input tag.
+ * <IMG src="slika.png">
+ * <META>Meta tag.
+ * <MULTICOL>Multicol is ignored by doxygen.
+ * </MULTICOL>
+ *
+ * <OL>
+ * <LI>List item 1.</LI>
+ * <LI>List item 2.</LI>
+ * </OL>
+ *
+ * <P>Starts a new paragraph.
+ * </P>
+ * <PRE>Starts a preformatted fragment.
+ * </PRE>
+ * <SMALL>Starts a section of text displayed in a smaller font.
+ * </SMALL>
+ * <SPAN>Starts an inline text fragment with a specific style.</SPAN>
+ * <STRONG>Starts a section of bold text.</STRONG>
+ * <SUB>Starts a piece of text displayed in subscript.</SUB>
+ * <SUP>Starts a piece of text displayed in superscript.</SUP>
+ *
+ * <table border = '1'>
+ * <caption>Animals</caption>
+ * <tr><th> Column 1 </th><th> Column 2 </th></tr>
+ * <tr><td> cow </td><td> dog </td></tr>
+ * <tr><td> cat </td><td> mouse </td></tr>
+ * <tr><td> horse </td><td> parrot </td></tr>
+ * </table>
+ *
+ * <TT>Starts a piece of text displayed in a typewriter font.
+ * </TT>
+ * <KBD>Starts a piece of text displayed in a typewriter font.
+ * </KBD>
+ *
+ * <UL>
+ * <LI>List item 1.</LI>
+ * <LI>List item 2.</LI>
+ * <LI>List item 3.</LI>
+ * </UL>
+ *
+ * <VAR>Starts a piece of text displayed in an italic font.</VAR>
+ *
+ * \htmlonly
+ * <u>underlined \b bold text - doxy commands are ignored inside 'htmlonly' section </u>
+ * \endhtmlonly
+ */
+void htmlFunction(int a, float b)
+{
+}
+
+/**
+ * The meaning of flags:
+ *
+ * @param byFlags bits marking required items:
+ * <table>
+ * <tr><th> Size in bits</th><th> Items Required </th></tr>
+ * <tr><td> 1 - 8 </td><td> 1 </td></tr>
+ * <tr><td> 9 - 16 </td><td> 2 </td></tr>
+ * <tr><td> 17 - 32 </td><td> 4 </td></tr>
+ * </table>
+ * Almost all combinations of above flags are supported by
+ * \c htmlTable... functions.
+ */
+void htmlTableFunction(int byFlags)
+{
+}
+
+
+/**
+ * All entities are treated as commands &copy; &trade; &reg;
+ * should work also&lt;in text
+ * &gt;
+ * &amp;
+ * &apos;
+ * &quot;
+ * &lsquo;
+ * &rsquo;
+ * &ldquo;
+ * &rdquo;
+ * &ndash;
+ * &mdash;
+ * &nbsp;
+ * &times;
+ * &minus;
+ * &sdot;
+ * &sim;
+ * &le;
+ * &ge;
+ * &larr;
+ * &rarr;
+ * Not an &text; html entity - ignored by Doxygen.
+ * Not an &text html entity - ampersand is replaced with entity.
+ */
+void htmlEntitiesFunction(int a, float b)
+{
+}
+
+
+
+%}
diff --git a/Examples/test-suite/doxygen_translate_all_tags.i b/Examples/test-suite/doxygen_translate_all_tags.i
new file mode 100644
index 000000000..b54203d0a
--- /dev/null
+++ b/Examples/test-suite/doxygen_translate_all_tags.i
@@ -0,0 +1,416 @@
+%module doxygen_translate_all_tags
+
+#if defined(SWIGJAVA)
+%javamethodmodifiers func02 "@Deprecated\npublic"
+#endif
+
+%inline %{
+
+/**
+ * \a Hello
+ *
+ * \addindex SomeLatexIndex
+ *
+ * \addtogroup someGroup "Some title"
+ *
+ * \anchor theAnchor
+ *
+ * \arg some list item
+ *
+ * \attention This is attention!
+ * You were warned!
+ *
+ * \authors lots of them
+ * \author Zubr
+ *
+ * \b boldword
+ *
+ * \brief Some brief description,
+ * extended to many lines.
+ *
+ * \bug Not everything works right now...
+ * \c codeword
+ *
+ * \callgraph
+ * \callergraph
+ * \category someCategory headerFile.h headerName
+ *
+ * \cite citationword
+ * \class someClass headerFile.h headerName
+ * \code some test code \endcode
+ *
+ * Code immediately following text. Pydoc translation must add an
+ * empty line before:
+ * \code more test code \endcode
+ */
+void func01(int a)
+{
+}
+
+
+/**
+ * \cond SOMECONDITION
+ * Some conditional comment
+ * \endcond
+ *
+ * \copybrief someClass::someMethod
+ *
+ * \copydetails someClass::someMethod2
+ *
+ * \copydoc someClass::someMethod3
+ *
+ * \copyright some copyright
+ *
+ * \date 1970 - 2012
+ *
+ * \def someDefine
+ *
+ * \defgroup someGroup Some titles
+ *
+ * \deprecated Now use another function
+ *
+ * \details This is very large
+ * and detailed description of some thing
+ */
+void func02(int a)
+{
+}
+
+
+/**
+ * Comment for \b func03().
+ *
+ * \dir /somePath/someFolder
+ *
+ * \dontinclude someFile.h
+ *
+ * \dot
+ * digraph example {
+ * node [shape=record, fontname=Helvetica, fontsize=10];
+ * b [ label="class B" URL="\ref B"];
+ * c [ label="class C" URL="\ref C"];
+ * b -> c [ arrowhead="open", style="dashed" ];
+ * }
+ * \enddot
+ *
+ * \dotfile dotFile.dot "The caption"
+ *
+ * \e italicword
+ *
+ * \em emphazedWord
+ *
+ * \enum someEnum
+ *
+ * \example someFile.txt
+ * Some details on using the example
+ */
+void func03(int a)
+{
+}
+
+
+/**
+ *
+ * \exception SuperError
+ *
+ * \extends someOtherFunction
+ *
+ * \f$ \sqrt{(x_2-x_1)^2+(y_2-y_1)^2} \f$
+ *
+ * \f[
+ * \sqrt{(x_2-x_1)^2+(y_2-y_1)^2}
+ * \f]
+ *
+ * \f{
+ * \sqrt{(x_2-x_1)^2+(y_2-y_1)^2}
+ * \f}
+ *
+ * Math immediately following text. Pydoc translation must add an
+ * empty line before:
+ * \f[
+ * \sqrt{(x_2-x_1)^2+(y_2-y_1)^2}
+ * \f]
+ *
+ * \file file.h
+ *
+ * \fn someFn
+ *
+ * \headerfile someHeader.h "Header name"
+ *
+ * \hideinitializer
+ *
+ * \htmlinclude htmlFile.htm
+ *
+ * \htmlonly
+ * This will only appear in hmtl
+ * \endhtmlonly
+ */
+void func04(int a)
+{
+}
+
+
+/**
+ * \if ANOTHERCONDITION
+ * First part of comment
+ * \if SECONDCONDITION
+ * Nested condition text
+ * \elseif THIRDCONDITION
+ * The third condition text
+ * \else
+ * The last text block
+ * \endif
+ * \else
+ * Second part of comment
+ * \if CONDITION
+ * Second part extended
+ * \endif
+ * \endif
+ *
+ * \ifnot SOMECONDITION
+ * This is printed if not
+ * \endif
+ *
+ * \image html testImage.bmp "Hello, world!" asd=10qwe
+ *
+ * \implements someFunction
+ *
+ * \include header.h
+ *
+ * \includelineno header2.h
+ *
+ * \ingroup someGroup anotherGroup
+ *
+ * \internal
+ *
+ * \invariant Some text
+ * describing invariant.
+ */
+void func05(int a)
+{
+}
+
+
+/**
+ * Comment for \b func06().
+ *
+ * \interface someInterface someHeader.h "Header name"
+ *
+ * \latexonly
+ * This will only appear in LATeX
+ * \endlatexonly
+ *
+ * <ul>
+ *
+ * \li Some unordered list
+ * \li With lots of items
+ * \li lots of lots of items
+ *
+ * </ul>
+ *
+ * \line example
+ *
+ * \link someMember Some description follows\endlink with text after
+ *
+ * \mainpage Some title
+ *
+ * \manonly
+ * This will only appear in man
+ * \endmanonly
+ *
+ * \memberof someThing
+ *
+ * \msc
+ * Sender,Receiver;
+ * Sender->Receiver [label="Command()", URL="\ref Receiver::Command()"];
+ * Sender<-Receiver [label="Ack()", URL="\ref Ack()", ID="1"];
+ * \endmsc
+ *
+ * \mscfile mscFile.msc "The caption"
+ *
+ * \n \n \n
+ */
+void func06(int a)
+{
+}
+
+
+/**
+ * Comment for \b func07().
+ *
+ * \name someHeader.h
+ *
+ * \namespace someNamespace
+ *
+ * \nosubgrouping
+ *
+ * \note Here
+ * is the note!
+ *
+ * \overload
+ *
+ * \p someword
+ *
+ * \package superPackage
+ *
+ * \page somePage The title
+ *
+ * \par The paragraph title
+ * The paragraph text.
+ * Maybe even multiline
+ *
+ * \paragraph someParagraph Paragraph title
+ *
+ * \param a the first param
+ * \param[in] b parameter with intent(in)
+ * \param[out] c parameter with intent(out)
+ * \param[in,out] d parameter with intent(in,out)
+ *
+ * \post Some description
+ *
+ * \pre Some description
+ *
+ * \private
+ *
+ * \privatesection
+ *
+ * \property someVar
+ */
+void func07(int a, int b, int c, int d)
+{
+}
+
+
+/**
+ * \protected
+ *
+ * \protectedsection
+ *
+ * \anchor someAnchor
+ * Text after anchor.
+ * \protocol someProtocol header.h "Header name"
+ *
+ * \public
+ *
+ * \publicsection
+ *
+ * \ref someAnchor "Anchor description"
+ *
+ * \ref someAnchor not quoted text is not part of ref tag
+ *
+ * \ref someAnchor
+ *
+ * \related toSomething
+ *
+ * \relates toSomethingElse
+ *
+ * \relatedalso someName
+ *
+ * \relatesalso someName
+ *
+ * \remark Some remark text
+ *
+ * \remarks Another remarks section
+ *
+ * \result Whatever
+ *
+ * \return it
+ *
+ * \returns may return
+ *
+ * \retval someValue Some description
+ */
+void func08(int a)
+{
+}
+
+
+/**
+ * \rtfonly
+ * This will only appear in RTF
+ * \endrtfonly
+ *
+ * \sa someOtherMethod
+ *
+ * \section someSection Some title
+ *
+ * \see function
+ *
+ * \short Same as
+ * brief description
+ *
+ * \showinitializer
+ *
+ * \since version 0.0.0.1
+ *
+ * \skip somePattern
+ *
+ * \skipline someLine
+ *
+ * \snippet example.h Some snippet
+ *
+ * \struct someStruct
+ *
+ * \subpage someSubpage "Some description"
+ *
+ * \subsection someSubsection Some title
+ *
+ * \subsubsection someSubsection Some title
+ *
+ * \tableofcontents
+ *
+ * \test Some
+ * description of the
+ * test case
+ *
+ * \throw superException
+ *
+ * \throws RuntimeError
+ */
+void func09(int a)
+{
+}
+
+
+/**
+ * \todo Some very important task
+ *
+ * \tparam b B is mentioned again...
+ *
+ * \typedef someTypedef
+ *
+ * \union someUnion
+ *
+ * \until somePattern
+ *
+ * \var someVar
+ *
+ * \verbatim
+ * very long
+ * text with tags <sometag>
+ * \endverbatim
+ *
+ * \verbinclude someFile.h
+ *
+ * \version 0.0.0.2
+ *
+ * \warning This is senseless!
+ *
+ * \weakgroup someGroup Some title
+ *
+ * \xmlonly
+ * This will only appear in XML
+ * \endxmlonly
+ *
+ * \xrefitem todo "Todo" "Todo List"
+ *
+ * Here goes test of symbols:
+ * \$ \@ \\ \& \~ \< \> \# \% \" \. \::
+ *
+ * And here goes simple text
+ */
+void func10(int a, float b)
+{
+}
+
+%}
diff --git a/Examples/test-suite/doxygen_translate_links.i b/Examples/test-suite/doxygen_translate_links.i
new file mode 100644
index 000000000..769a4f4e7
--- /dev/null
+++ b/Examples/test-suite/doxygen_translate_links.i
@@ -0,0 +1,67 @@
+
+
+%module doxygen_translate_links
+%include "std_string.i"
+
+%inline %{
+
+class Shape
+{
+public:
+ typedef Shape* superType;
+};
+
+/**
+ * Testing typenames converting in \@ link
+ *
+ * \link superFunc(int,std::string)
+ * Test for std_string member
+ * \endlink
+ *
+ * \link superFunc(int,long,void*)
+ * Test for simple types
+ * \endlink
+ *
+ * \link superFunc(Shape::superType*)
+ * Test for custom types
+ * \endlink
+ *
+ * \link superFunc(int**[13])
+ * Test for complex types
+ * \endlink
+ *
+ * same works for 'See also:' links:
+ *
+ * \sa superFunc(int,std::string)
+ * \sa superFunc(int,long,void*)
+ * \sa superFunc(Shape::superType*)
+ * \sa superFunc(int**[13])
+ *
+ * some failing params:
+ *
+ * \sa superFunc()
+ * \sa superFunc()
+ * \sa superFunc()
+ *
+ */
+void function()
+{
+}
+
+void superFunc(int, std::string)
+{
+}
+
+void superFunc(int, long, void *)
+{
+}
+
+void superFunc(Shape::superType *)
+{
+}
+
+void superFunc(int **arr[13])
+{
+}
+
+%}
diff --git a/Examples/test-suite/enum_macro.i b/Examples/test-suite/enum_macro.i
index c058cdf72..a5e8a2461 100644
--- a/Examples/test-suite/enum_macro.i
+++ b/Examples/test-suite/enum_macro.i
@@ -97,3 +97,45 @@ enum Greeks13
#define GREEK13 -13
};
+/* Multiple macros */
+
+%inline %{
+enum Greeks14
+{
+#define GREEK14a -14
+#define GREEK14b -140
+ theta14,
+};
+
+enum Greeks15
+{
+ alpha15 = 150,
+ beta15 = 151,
+#define GREEK15a -150
+#define GREEK15b -151
+ theta15 = 152,
+ delta15 = 153
+};
+
+enum Greeks16
+{
+ alpha16 = 160,
+ beta16 = 161,
+#define GREEK16a -160
+#define GREEK16b -161
+#define GREEK16c -162
+ theta16 = 162,
+ delta16 = 163
+};
+
+enum Greeks17
+{
+ alpha17 = 170,
+ beta17 = 171,
+ theta17 = 172,
+ delta17 = 173
+#define GREEK17a -170
+#define GREEK17b -171
+#define GREEK17c -172
+};
+%}
diff --git a/Examples/test-suite/errors/Makefile.in b/Examples/test-suite/errors/Makefile.in
index cf7889a1d..7137a6862 100644
--- a/Examples/test-suite/errors/Makefile.in
+++ b/Examples/test-suite/errors/Makefile.in
@@ -24,15 +24,32 @@ SWIG_LIB_SET = @SWIG_LIB_SET@
SWIGINVOKE = $(SWIG_LIB_SET) $(SWIGTOOL) $(SWIGEXE)
# All .i files with prefix 'cpp_' will be treated as C++ input and remaining .i files as C input
-ALL_ERROR_TEST_CASES := $(patsubst %.i,%, $(notdir $(wildcard $(srcdir)/*.i)))
-CPP_ERROR_TEST_CASES := $(filter cpp_%, $(ALL_ERROR_TEST_CASES))
-C_ERROR_TEST_CASES := $(filter-out $(CPP_ERROR_TEST_CASES), $(ALL_ERROR_TEST_CASES))
+ALL_ERROR_TEST_CASES := $(sort $(patsubst %.i,%, $(notdir $(wildcard $(srcdir)/*.i))))
+CPP_ERROR_TEST_CASES := $(sort $(filter cpp_%, $(ALL_ERROR_TEST_CASES)))
+C_ERROR_TEST_CASES := $(sort $(filter-out $(CPP_ERROR_TEST_CASES), $(ALL_ERROR_TEST_CASES)))
+DOXYGEN_ERROR_TEST_CASES := $(sort $(filter doxygen_%, $(C_ERROR_TEST_CASES)))
+C_ERROR_TEST_CASES := $(sort $(filter-out $(DOXYGEN_ERROR_TEST_CASES), $(C_ERROR_TEST_CASES)))
+
+# Always use C++ for Doxygen tests, there doesn't seem to be any need to
+# distinguish between C and C++ Doxygen tests.
+DOXYGEN_ERROR_TEST_CASES := $(DOXYGEN_ERROR_TEST_CASES:=.cpptest)
ERROR_TEST_CASES := $(CPP_ERROR_TEST_CASES:=.cpptest) \
- $(C_ERROR_TEST_CASES:=.ctest)
+ $(C_ERROR_TEST_CASES:=.ctest) \
+ $(DOXYGEN_ERROR_TEST_CASES)
include $(srcdir)/../common.mk
+# This is tricky: we need to let common.mk define SWIGOPT before appending to
+# it, if we do it before including it, its defining of SWIGOPT would override
+# whatever we do here.
+$(DOXYGEN_ERROR_TEST_CASES): SWIGOPT += -doxygen
+
+# Unique module names are obtained from the .i file name (required for parallel make).
+# Note: -module overrides %module in the .i file.
+MODULE_OPTION=-module $*
+nomodule.ctest: MODULE_OPTION =
+
# Portable dos2unix / todos for stripping CR
TODOS = tr -d '\r'
#TODOS = sed -e 's/\r$$//' # On Mac OS X behaves as if written 's/r$$//'
@@ -43,12 +60,12 @@ STRIP_SRCDIR = sed -e 's|\\|/|g' -e 's|^$(SRCDIR)||'
# Rules for the different types of tests
%.cpptest:
echo "$(ACTION)ing errors testcase $*"
- -$(SWIGINVOKE) -c++ -python -Wall -Fstandard $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT)
+ -$(SWIGINVOKE) -c++ -python -Wall -Fstandard $(MODULE_OPTION) $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT)
$(COMPILETOOL) diff -c $(SRCDIR)$*.stderr $*.$(ERROR_EXT)
%.ctest:
echo "$(ACTION)ing errors testcase $*"
- -$(SWIGINVOKE) -python -Wall -Fstandard $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT)
+ -$(SWIGINVOKE) -python -Wall -Fstandard $(MODULE_OPTION) $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT)
$(COMPILETOOL) diff -c $(SRCDIR)$*.stderr $*.$(ERROR_EXT)
%.clean:
diff --git a/Examples/test-suite/errors/cpp_bad_global_memberptr.i b/Examples/test-suite/errors/cpp_bad_global_memberptr.i
new file mode 100644
index 000000000..f0d95cfed
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_bad_global_memberptr.i
@@ -0,0 +1,6 @@
+%module xxx
+
+struct Funcs {};
+
+short (Funcs::* *)(bool) = 0;
+short (Funcs::* const*)(bool) = 0;
diff --git a/Examples/test-suite/errors/cpp_bad_global_memberptr.stderr b/Examples/test-suite/errors/cpp_bad_global_memberptr.stderr
new file mode 100644
index 000000000..ac3f9cbe0
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_bad_global_memberptr.stderr
@@ -0,0 +1,2 @@
+cpp_bad_global_memberptr.i:5: Error: Missing symbol name for global declaration
+cpp_bad_global_memberptr.i:6: Error: Missing symbol name for global declaration
diff --git a/Examples/test-suite/errors/cpp_class_definition.i b/Examples/test-suite/errors/cpp_class_definition.i
new file mode 100644
index 000000000..8381e75cc
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_class_definition.i
@@ -0,0 +1,26 @@
+%module xxx
+
+// This should error but doesn't
+#if 0
+namespace OtherSpace {
+ struct L;
+}
+namespace Space11 {
+ namespace SubSpace11 {
+ using OtherSpace::L;
+ struct L {
+ void ll();
+ };
+ }
+}
+#endif
+
+namespace Space1 {
+ struct A;
+}
+namespace Space2 {
+ struct Space1::A {
+ void x();
+ };
+}
+
diff --git a/Examples/test-suite/errors/cpp_class_definition.stderr b/Examples/test-suite/errors/cpp_class_definition.stderr
new file mode 100644
index 000000000..2c4102842
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_class_definition.stderr
@@ -0,0 +1 @@
+cpp_class_definition.i:22: Error: 'Space1::A' resolves to 'Space1::A' and was incorrectly instantiated in scope 'Space2' instead of within scope 'Space1'.
diff --git a/Examples/test-suite/errors/cpp_extra_brackets.i b/Examples/test-suite/errors/cpp_extra_brackets.i
index 32cf7f72d..81fdb29c4 100644
--- a/Examples/test-suite/errors/cpp_extra_brackets.i
+++ b/Examples/test-suite/errors/cpp_extra_brackets.i
@@ -1,4 +1,4 @@
-%module cpp_extra_brackets
+%module xxx
// Extra brackets was segfaulting in SWIG-3.0.0
struct ABC {
diff --git a/Examples/test-suite/errors/cpp_extra_brackets2.i b/Examples/test-suite/errors/cpp_extra_brackets2.i
index 17a5d5918..194dea435 100644
--- a/Examples/test-suite/errors/cpp_extra_brackets2.i
+++ b/Examples/test-suite/errors/cpp_extra_brackets2.i
@@ -1,4 +1,4 @@
-%module cpp_extra_brackets
+%module xxx
// Extra brackets was segfaulting in SWIG-3.0.0
struct ABC {
diff --git a/Examples/test-suite/errors/cpp_final_destructor.stderr b/Examples/test-suite/errors/cpp_final_destructor.stderr
new file mode 100644
index 000000000..d8c509d0c
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_final_destructor.stderr
@@ -0,0 +1 @@
+cpp_final_destructor.i:7: Warning 525: Destructor BaseFinal::~BaseFinal() is final, BaseFinal cannot be a director class.
diff --git a/Examples/test-suite/errors/cpp_invalid_exponents1.i b/Examples/test-suite/errors/cpp_invalid_exponents1.i
new file mode 100644
index 000000000..1ff2c3603
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_invalid_exponents1.i
@@ -0,0 +1,4 @@
+%module xxx
+
+void bad(double nn = 5e);
+
diff --git a/Examples/test-suite/errors/cpp_invalid_exponents1.stderr b/Examples/test-suite/errors/cpp_invalid_exponents1.stderr
new file mode 100644
index 000000000..6096114be
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_invalid_exponents1.stderr
@@ -0,0 +1,2 @@
+cpp_invalid_exponents1.i:3: Error: Exponent does not have any digits
+cpp_invalid_exponents1.i:3: Error: Syntax error in input(1).
diff --git a/Examples/test-suite/errors/cpp_invalid_exponents2.i b/Examples/test-suite/errors/cpp_invalid_exponents2.i
new file mode 100644
index 000000000..2e074872a
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_invalid_exponents2.i
@@ -0,0 +1,4 @@
+%module xxx
+
+void bad(double nn = 6.6e);
+
diff --git a/Examples/test-suite/errors/cpp_invalid_exponents2.stderr b/Examples/test-suite/errors/cpp_invalid_exponents2.stderr
new file mode 100644
index 000000000..e7d1bf07d
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_invalid_exponents2.stderr
@@ -0,0 +1,2 @@
+cpp_invalid_exponents2.i:3: Error: Exponent does not have any digits
+cpp_invalid_exponents2.i:3: Error: Syntax error in input(1).
diff --git a/Examples/test-suite/errors/cpp_invalid_qualifiers.i b/Examples/test-suite/errors/cpp_invalid_qualifiers.i
new file mode 100644
index 000000000..d0723dff6
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_invalid_qualifiers.i
@@ -0,0 +1,43 @@
+%module xxx
+
+// Constructors, destructors and static methods cannot have qualifiers
+struct A {
+ ~A() const;
+};
+struct B {
+ virtual ~B() const;
+};
+struct C {
+ ~C() &;
+};
+struct D {
+ virtual ~D() &;
+};
+struct E {
+ ~E() &&;
+};
+struct F {
+ virtual ~F() &&;
+};
+
+struct J {
+ J() const;
+ J(int) const;
+};
+struct K {
+ K() &;
+ K(int) &;
+};
+struct L {
+ L() &&;
+ L(int) &&;
+};
+
+struct M {
+ static void m1() const;
+ static void m2() &;
+ thread_local static void m3() &&;
+ static auto m4() const -> int;
+ static auto m5() & -> int;
+ static auto m6() && -> int;
+};
diff --git a/Examples/test-suite/errors/cpp_invalid_qualifiers.stderr b/Examples/test-suite/errors/cpp_invalid_qualifiers.stderr
new file mode 100644
index 000000000..7b3e442eb
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_invalid_qualifiers.stderr
@@ -0,0 +1,20 @@
+cpp_invalid_qualifiers.i:5: Error: Destructor ~A() const cannot have a qualifier.
+cpp_invalid_qualifiers.i:8: Error: Destructor ~B() const cannot have a qualifier.
+cpp_invalid_qualifiers.i:11: Error: Destructor ~C() & cannot have a qualifier.
+cpp_invalid_qualifiers.i:14: Error: Destructor ~D() & cannot have a qualifier.
+cpp_invalid_qualifiers.i:17: Error: Destructor ~E() && cannot have a qualifier.
+cpp_invalid_qualifiers.i:20: Error: Destructor ~F() && cannot have a qualifier.
+cpp_invalid_qualifiers.i:24: Error: Constructor cannot have a qualifier.
+cpp_invalid_qualifiers.i:25: Error: Constructor cannot have a qualifier.
+cpp_invalid_qualifiers.i:28: Error: Constructor cannot have a qualifier.
+cpp_invalid_qualifiers.i:29: Error: Constructor cannot have a qualifier.
+cpp_invalid_qualifiers.i:32: Error: Constructor cannot have a qualifier.
+cpp_invalid_qualifiers.i:33: Error: Constructor cannot have a qualifier.
+cpp_invalid_qualifiers.i:37: Error: Static function m1() const cannot have a qualifier.
+cpp_invalid_qualifiers.i:38: Error: Static function m2() & cannot have a qualifier.
+cpp_invalid_qualifiers.i:39: Error: Static function m3() && cannot have a qualifier.
+cpp_invalid_qualifiers.i:39: Warning 405: Method with rvalue ref-qualifier m3() && ignored.
+cpp_invalid_qualifiers.i:40: Error: Static function m4() const cannot have a qualifier.
+cpp_invalid_qualifiers.i:41: Error: Static function m5() & cannot have a qualifier.
+cpp_invalid_qualifiers.i:42: Error: Static function m6() && cannot have a qualifier.
+cpp_invalid_qualifiers.i:42: Warning 405: Method with rvalue ref-qualifier m6() && ignored.
diff --git a/Examples/test-suite/errors/cpp_invalid_template.i b/Examples/test-suite/errors/cpp_invalid_template.i
new file mode 100644
index 000000000..45ad73908
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_invalid_template.i
@@ -0,0 +1,9 @@
+%module xxx
+
+%template(abc) SSS::AAA<int>;
+
+namespace UUU {
+ struct JJJ;
+}
+
+%template(xxx) UUU::JJJ<int>;
diff --git a/Examples/test-suite/errors/cpp_invalid_template.stderr b/Examples/test-suite/errors/cpp_invalid_template.stderr
new file mode 100644
index 000000000..f6bfaaf7d
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_invalid_template.stderr
@@ -0,0 +1,3 @@
+cpp_invalid_template.i:3: Error: Undefined scope 'SSS'
+cpp_invalid_template.i:3: Error: Template 'SSS::AAA' undefined.
+cpp_invalid_template.i:9: Error: 'JJJ' is not defined as a template. (classforward)
diff --git a/Examples/test-suite/errors/cpp_namespace_template_bad.i b/Examples/test-suite/errors/cpp_namespace_template_bad.i
new file mode 100644
index 000000000..f41918f8e
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_namespace_template_bad.i
@@ -0,0 +1,40 @@
+%module xxx
+
+namespace test {
+ template<typename T> T max(T a, T b) { return (a > b) ? a : b; }
+ template<typename T> class vector {
+ public:
+ vector() { }
+ ~vector() { }
+ };
+}
+
+namespace test2 {
+ using namespace test;
+ %template(maxshort) max<short>;
+ %template(vectorshort) vector<short>;
+}
+
+namespace test3 {
+ using test::max;
+ using test::vector;
+ %template(maxlong) max<long>;
+ %template(vectorlong) vector<long>;
+}
+
+namespace test4 {
+ using namespace test;
+ typedef int Integer;
+}
+
+namespace test4 {
+ %template(maxInteger) max<Integer>;
+ %template(vectorInteger) vector<Integer>;
+}
+
+using namespace test;
+namespace test5 {
+ %template(maxdouble) max<double>;
+ %template(vectordouble) vector<double>;
+}
+
diff --git a/Examples/test-suite/errors/cpp_namespace_template_bad.stderr b/Examples/test-suite/errors/cpp_namespace_template_bad.stderr
new file mode 100644
index 000000000..5965d529c
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_namespace_template_bad.stderr
@@ -0,0 +1,9 @@
+cpp_namespace_template_bad.i:14: Error: 'max' resolves to 'test::max' and was incorrectly instantiated in scope 'test2' instead of within scope 'test'.
+cpp_namespace_template_bad.i:15: Error: 'vector' resolves to 'test::vector' and was incorrectly instantiated in scope 'test2' instead of within scope 'test'.
+cpp_namespace_template_bad.i:21: Error: 'max' resolves to 'test::max' and was incorrectly instantiated in scope 'test3' instead of within scope 'test'.
+cpp_namespace_template_bad.i:22: Error: 'vector' resolves to 'test::vector' and was incorrectly instantiated in scope 'test3' instead of within scope 'test'.
+cpp_namespace_template_bad.i:31: Error: 'max' resolves to 'test::max' and was incorrectly instantiated in scope 'test4' instead of within scope 'test'.
+cpp_namespace_template_bad.i:32: Error: 'vector' resolves to 'test::vector' and was incorrectly instantiated in scope 'test4' instead of within scope 'test'.
+cpp_namespace_template_bad.i:37: Error: 'max' resolves to 'test::max' and was incorrectly instantiated in scope 'test5' instead of within scope 'test'.
+cpp_namespace_template_bad.i:37: Error: Template 'max' undefined.
+cpp_namespace_template_bad.i:38: Error: 'vector' resolves to 'test::vector' and was incorrectly instantiated in scope 'test5' instead of within scope 'test'.
diff --git a/Examples/test-suite/errors/cpp_nested_namespace_alias.i b/Examples/test-suite/errors/cpp_nested_namespace_alias.i
new file mode 100644
index 000000000..058d34441
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_nested_namespace_alias.i
@@ -0,0 +1,34 @@
+%module xxx
+
+// C++17 nested namespaces
+
+namespace A
+{
+ namespace B
+ {
+ void ab1();
+ }
+}
+namespace A::B
+{
+ void ab2();
+}
+namespace AAlias = A;
+namespace AAlias::B
+{
+ void ab3();
+}
+namespace A
+{
+ namespace BAlias = B;
+ void ab4();
+}
+namespace A::BAlias
+{
+ void ab5();
+}
+namespace ABAlias = A::B;
+namespace ABAlias
+{
+ void ab6();
+}
diff --git a/Examples/test-suite/errors/cpp_nested_namespace_alias.stderr b/Examples/test-suite/errors/cpp_nested_namespace_alias.stderr
new file mode 100644
index 000000000..2506a3a2c
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_nested_namespace_alias.stderr
@@ -0,0 +1,3 @@
+cpp_nested_namespace_alias.i:18: Warning 308: Namespace alias 'AAlias' not allowed here. Assuming 'A'
+cpp_nested_namespace_alias.i:27: Warning 308: Namespace alias 'BAlias' not allowed here. Assuming 'B'
+cpp_nested_namespace_alias.i:32: Warning 308: Namespace alias 'ABAlias' not allowed here. Assuming 'B'
diff --git a/Examples/test-suite/errors/cpp_nested_template.stderr b/Examples/test-suite/errors/cpp_nested_template.stderr
index 9e46cff74..363a260f6 100644
--- a/Examples/test-suite/errors/cpp_nested_template.stderr
+++ b/Examples/test-suite/errors/cpp_nested_template.stderr
@@ -1,2 +1,4 @@
+cpp_nested_template.i:9: Error: 'Temply' resolves to '::Temply' and was incorrectly instantiated in scope 'A' instead of within scope ''.
cpp_nested_template.i:9: Warning 324: Named nested template instantiations not supported. Processing as if no name was given to %template().
+cpp_nested_template.i:18: Error: 'Temply' resolves to '::Temply' and was incorrectly instantiated in scope 'B' instead of within scope ''.
cpp_nested_template.i:18: Warning 324: Named nested template instantiations not supported. Processing as if no name was given to %template().
diff --git a/Examples/test-suite/errors/cpp_raw_string_termination.i b/Examples/test-suite/errors/cpp_raw_string_termination.i
new file mode 100644
index 000000000..3858b1f1e
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_raw_string_termination.i
@@ -0,0 +1,4 @@
+%module xxx
+
+%feature("docstring") func2 R"ABC(Calculate :math:`D^\nu \rho(x)`.)AB";
+void func2(double* foo, int bar, char** baz);
diff --git a/Examples/test-suite/errors/cpp_raw_string_termination.stderr b/Examples/test-suite/errors/cpp_raw_string_termination.stderr
new file mode 100644
index 000000000..37dd512e0
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_raw_string_termination.stderr
@@ -0,0 +1,2 @@
+cpp_raw_string_termination.i:3: Error: Unterminated raw string, started with R"ABC( is not terminated by )ABC"
+cpp_raw_string_termination.i:3: Error: Syntax error in input(1).
diff --git a/Examples/test-suite/errors/cpp_recursive_typedef.i b/Examples/test-suite/errors/cpp_recursive_typedef.i
index 3d65a8817..82d9f7a4a 100644
--- a/Examples/test-suite/errors/cpp_recursive_typedef.i
+++ b/Examples/test-suite/errors/cpp_recursive_typedef.i
@@ -1,4 +1,4 @@
-%module cpp_recursive_typedef
+%module xxx
typedef std::set<pds> pds;
diff --git a/Examples/test-suite/errors/cpp_refqualifier.i b/Examples/test-suite/errors/cpp_refqualifier.i
new file mode 100644
index 000000000..3980a812c
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_refqualifier.i
@@ -0,0 +1,28 @@
+%module xxx
+
+%ignore Host::h_ignored;
+%ignore Host::i_ignored() &&;
+%ignore Host::j_ignored() const &&;
+
+class Host {
+public:
+ void h1() &;
+ void h2() const &;
+ void h3() &&;
+ void h4() const &&;
+
+ void h() &;
+ void h() const &;
+ void h() &&;
+ void h() const &&;
+
+ void h_ignored() &&;
+ void i_ignored() &&;
+ void i_ignored() &&;
+};
+
+%feature("ignore", "0") Unignore::k_unignored() const &&;
+
+struct Unignore {
+ void k_unignored() const &&;
+};
diff --git a/Examples/test-suite/errors/cpp_refqualifier.stderr b/Examples/test-suite/errors/cpp_refqualifier.stderr
new file mode 100644
index 000000000..ea2cd220a
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_refqualifier.stderr
@@ -0,0 +1,6 @@
+cpp_refqualifier.i:11: Warning 405: Method with rvalue ref-qualifier h3() && ignored.
+cpp_refqualifier.i:12: Warning 405: Method with rvalue ref-qualifier h4() const && ignored.
+cpp_refqualifier.i:16: Warning 405: Method with rvalue ref-qualifier h() && ignored.
+cpp_refqualifier.i:17: Warning 405: Method with rvalue ref-qualifier h() const && ignored.
+cpp_refqualifier.i:15: Warning 512: Overloaded method Host::h() const & ignored,
+cpp_refqualifier.i:14: Warning 512: using non-const method Host::h() & instead.
diff --git a/Examples/test-suite/errors/cpp_shared_ptr.i b/Examples/test-suite/errors/cpp_shared_ptr.i
index edbd0cf87..bdcd30f71 100644
--- a/Examples/test-suite/errors/cpp_shared_ptr.i
+++ b/Examples/test-suite/errors/cpp_shared_ptr.i
@@ -1,4 +1,4 @@
-%module cpp_shared_ptr
+%module xxx
%include <boost_shared_ptr.i>
diff --git a/Examples/test-suite/errors/cpp_template_duplicate_names.i b/Examples/test-suite/errors/cpp_template_duplicate_names.i
new file mode 100644
index 000000000..96076967b
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_template_duplicate_names.i
@@ -0,0 +1,51 @@
+%module xxx
+
+// From test-suite/template_class_reuse.i test
+
+%{
+namespace Space {
+ template <bool B> struct Duplicate1 { void f(){}; };
+}
+%}
+
+// %warnfilter(SWIGWARN_PARSE_REDEFINED) Space::Duplicate1;
+namespace Space {
+ template <bool B> struct Duplicate1 { void f(){}; };
+ template <bool B> struct Duplicate1 { void f(){}; };
+}
+
+
+// %warnfilter(SWIGWARN_PARSE_REDEFINED) Space::Duplicate2;
+%inline %{
+namespace Space {
+ template <int I> struct Duplicate2 { void n(){}; };
+}
+%}
+%template(Duplicate2_0) Space::Duplicate2<0>;
+%template(Duplicate2_0) Space::Duplicate2<0>;
+
+
+// %warnfilter(SWIGWARN_PARSE_REDEFINED) Space::Duplicate3;
+%inline %{
+namespace Space {
+ template <int I> struct Duplicate3 { void n(){}; };
+}
+%}
+%template(Duplicate3) Space::Duplicate3<0>;
+%template(Duplicate3) Space::Duplicate3<0>;
+
+
+%{
+namespace Space {
+ template <bool B> struct Duplicate4 { void f(){}; };
+}
+%}
+
+// %warnfilter(SWIGWARN_PARSE_REDEFINED) Space::Duplicate4;
+namespace Space {
+ template <bool B> struct Duplicate4 { void f(){}; };
+ template <bool B> struct Duplicate4 { void f(){}; };
+}
+%template(Duplicate4) Space::Duplicate4<0>;
+%template(Duplicate4) Space::Duplicate4<0>;
+
diff --git a/Examples/test-suite/errors/cpp_template_duplicate_names.stderr b/Examples/test-suite/errors/cpp_template_duplicate_names.stderr
new file mode 100644
index 000000000..9856ff563
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_template_duplicate_names.stderr
@@ -0,0 +1,14 @@
+cpp_template_duplicate_names.i:14: Warning 302: Identifier 'Duplicate1' redefined (ignored),
+cpp_template_duplicate_names.i:13: Warning 302: previous definition of 'Duplicate1'.
+cpp_template_duplicate_names.i:14: Warning 302: Identifier 'Duplicate1' redefined (ignored),
+cpp_template_duplicate_names.i:13: Warning 302: previous definition of 'Duplicate1'.
+cpp_template_duplicate_names.i:25: Warning 302: Identifier 'Duplicate2_0' redefined (ignored) (Renamed from 'Duplicate2< 0 >'),
+cpp_template_duplicate_names.i:24: Warning 302: previous definition of 'Duplicate2_0' (Renamed from 'Duplicate2< 0 >').
+cpp_template_duplicate_names.i:35: Warning 302: Identifier 'Duplicate3' redefined (ignored) (Renamed from 'Duplicate3< 0 >'),
+cpp_template_duplicate_names.i:31: Warning 302: previous definition of 'Duplicate3'.
+cpp_template_duplicate_names.i:47: Warning 302: Identifier 'Duplicate4' redefined (ignored),
+cpp_template_duplicate_names.i:46: Warning 302: previous definition of 'Duplicate4'.
+cpp_template_duplicate_names.i:47: Warning 302: Identifier 'Duplicate4' redefined (ignored),
+cpp_template_duplicate_names.i:46: Warning 302: previous definition of 'Duplicate4'.
+cpp_template_duplicate_names.i:50: Warning 302: Identifier 'Duplicate4' redefined (ignored) (Renamed from 'Duplicate4< 0 >'),
+cpp_template_duplicate_names.i:46: Warning 302: previous definition of 'Duplicate4'.
diff --git a/Examples/test-suite/errors/cpp_template_friend.i b/Examples/test-suite/errors/cpp_template_friend.i
index c9d1c9d5d..3b8d85eff 100644
--- a/Examples/test-suite/errors/cpp_template_friend.i
+++ b/Examples/test-suite/errors/cpp_template_friend.i
@@ -1,4 +1,4 @@
-%module cpp_template_friend
+%module xxx
template<typename T> T template_friend1(T);
template<typename T> T template_friend1(T);
diff --git a/Examples/test-suite/errors/cpp_template_scope.i b/Examples/test-suite/errors/cpp_template_scope.i
new file mode 100644
index 000000000..ec0f0a577
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_template_scope.i
@@ -0,0 +1,57 @@
+%module xxx
+
+namespace std {
+ template<typename T> class vector {};
+}
+
+struct S1 {};
+struct S2 {};
+struct S3 {};
+struct S4 {};
+struct S5 {};
+struct S6 {};
+struct S7 {};
+
+// valid
+namespace std {
+ %template(vi1) vector<S1>;
+ template class vector<S1>;
+}
+
+// valid
+using namespace std;
+%template(vi2) vector<S2>;
+template class vector<S2>;
+
+// valid
+using std::vector;
+%template(vi3) vector<S3>;
+template class vector<S3>;
+
+// ill-formed
+namespace unrelated {
+ using std::vector;
+ %template(vi4) vector<S4>;
+ template class vector<S4>;
+}
+
+// ill-formed
+namespace unrelated {
+ using namespace std;
+ %template(vi5) vector<S5>;
+ template class vector<S5>;
+}
+
+// ill-formed
+namespace unrelated {
+ namespace std {
+ %template(vi6) vector<S6>;
+ template class vector<S6>;
+ }
+}
+
+// ill-formed
+namespace unrelated {
+ %template(vi7) std::vector<S7>;
+ template class std::vector<S7>;
+}
diff --git a/Examples/test-suite/errors/cpp_template_scope.stderr b/Examples/test-suite/errors/cpp_template_scope.stderr
new file mode 100644
index 000000000..e47630268
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_template_scope.stderr
@@ -0,0 +1,11 @@
+cpp_template_scope.i:18: Warning 320: Explicit template instantiation ignored.
+cpp_template_scope.i:24: Warning 320: Explicit template instantiation ignored.
+cpp_template_scope.i:29: Warning 320: Explicit template instantiation ignored.
+cpp_template_scope.i:34: Error: 'vector' resolves to 'std::vector' and was incorrectly instantiated in scope 'unrelated' instead of within scope 'std'.
+cpp_template_scope.i:35: Warning 320: Explicit template instantiation ignored.
+cpp_template_scope.i:41: Error: 'vector' resolves to 'std::vector' and was incorrectly instantiated in scope 'unrelated' instead of within scope 'std'.
+cpp_template_scope.i:42: Warning 320: Explicit template instantiation ignored.
+cpp_template_scope.i:48: Error: 'vector' resolves to 'std::vector' and was incorrectly instantiated in scope 'unrelated::std' instead of within scope 'std'.
+cpp_template_scope.i:49: Warning 320: Explicit template instantiation ignored.
+cpp_template_scope.i:55: Error: 'std::vector' resolves to 'std::vector' and was incorrectly instantiated in scope 'unrelated' instead of within scope 'std'.
+cpp_template_scope.i:56: Warning 320: Explicit template instantiation ignored.
diff --git a/Examples/test-suite/errors/cpp_using_type_aliasing.i b/Examples/test-suite/errors/cpp_using_type_aliasing.i
deleted file mode 100644
index df65dbd3d..000000000
--- a/Examples/test-suite/errors/cpp_using_type_aliasing.i
+++ /dev/null
@@ -1,13 +0,0 @@
-%module cpp_using_type_aliasing
-
-namespace Space {
- template<typename T> struct Okay {
- };
- struct User {
- protected:
- using OkayInt = Okay<int>;
- };
- struct Derived : User {
- Okay<OkayInt> ff();
- };
-};
diff --git a/Examples/test-suite/errors/cpp_using_type_aliasing.stderr b/Examples/test-suite/errors/cpp_using_type_aliasing.stderr
deleted file mode 100644
index e69de29bb..000000000
--- a/Examples/test-suite/errors/cpp_using_type_aliasing.stderr
+++ /dev/null
diff --git a/Examples/test-suite/errors/doxygen_unknown_command.i b/Examples/test-suite/errors/doxygen_unknown_command.i
new file mode 100644
index 000000000..0f32ee966
--- /dev/null
+++ b/Examples/test-suite/errors/doxygen_unknown_command.i
@@ -0,0 +1,6 @@
+%module xxx
+
+/**
+ There is an \unknown Doxygen comment here.
+ */
+void foo();
diff --git a/Examples/test-suite/errors/doxygen_unknown_command.stderr b/Examples/test-suite/errors/doxygen_unknown_command.stderr
new file mode 100644
index 000000000..e5c32cc4b
--- /dev/null
+++ b/Examples/test-suite/errors/doxygen_unknown_command.stderr
@@ -0,0 +1 @@
+doxygen_unknown_command.i:4: Warning 560: Unknown Doxygen command: unknown.
diff --git a/Examples/test-suite/errors/pp_expressions_bad.i b/Examples/test-suite/errors/pp_expressions_bad.i
new file mode 100644
index 000000000..454437f95
--- /dev/null
+++ b/Examples/test-suite/errors/pp_expressions_bad.i
@@ -0,0 +1,43 @@
+%module xxx
+/* Note: needs -Wextra to see these warnings */
+
+/* Divide by zero */
+#define ZERO 0
+
+#if 1%ZERO
+#endif
+#if 2/ZERO
+#endif
+
+#if 1%(5-5)
+#endif
+#if 2/(55-55)
+#endif
+
+/* Floating point */
+#if 1.2
+#endif
+
+#if 2e3
+#endif
+
+#if 0
+#elif 8.8
+#endif
+
+/* Missing whitespace after preproc directive */
+#if123
+#endif
+
+#if456e
+#endif
+
+#if 0
+#warning This should not warn
+#elif1
+#warning This should also not warn
+#endif
+
+#if(1)
+#warning Warning okay: #if(1)
+#endif
diff --git a/Examples/test-suite/errors/pp_expressions_bad.stderr b/Examples/test-suite/errors/pp_expressions_bad.stderr
new file mode 100644
index 000000000..84104c6a8
--- /dev/null
+++ b/Examples/test-suite/errors/pp_expressions_bad.stderr
@@ -0,0 +1,19 @@
+pp_expressions_bad.i:7: Warning 202: Could not evaluate expression '1%ZERO'
+pp_expressions_bad.i:7: Warning 202: Error: 'Modulo by zero in expression'
+pp_expressions_bad.i:9: Warning 202: Could not evaluate expression '2/ZERO'
+pp_expressions_bad.i:9: Warning 202: Error: 'Division by zero in expression'
+pp_expressions_bad.i:12: Warning 202: Could not evaluate expression '1%(5-5)'
+pp_expressions_bad.i:12: Warning 202: Error: 'Modulo by zero in expression'
+pp_expressions_bad.i:14: Warning 202: Could not evaluate expression '2/(55-55)'
+pp_expressions_bad.i:14: Warning 202: Error: 'Division by zero in expression'
+pp_expressions_bad.i:18: Warning 202: Could not evaluate expression '1.2'
+pp_expressions_bad.i:18: Warning 202: Error: 'Floating point constant in preprocessor expression'
+pp_expressions_bad.i:21: Warning 202: Could not evaluate expression '2e3'
+pp_expressions_bad.i:21: Warning 202: Error: 'Floating point constant in preprocessor expression'
+pp_expressions_bad.i:25: Warning 202: Could not evaluate expression '8.8'
+pp_expressions_bad.i:25: Warning 202: Error: 'Floating point constant in preprocessor expression'
+pp_expressions_bad.i:29: Error: Unknown SWIG preprocessor directive: if123 (if this is a block of target language code, delimit it with %{ and %})
+pp_expressions_bad.i:30: Error: Extraneous #endif.
+pp_expressions_bad.i:32: Error: Unknown SWIG preprocessor directive: if456e (if this is a block of target language code, delimit it with %{ and %})
+pp_expressions_bad.i:33: Error: Extraneous #endif.
+pp_expressions_bad.i:42: Warning 204: CPP #warning, "Warning okay: #if(1)".
diff --git a/Examples/test-suite/errors/pp_invalid_exponents.i b/Examples/test-suite/errors/pp_invalid_exponents.i
new file mode 100644
index 000000000..73dcdb145
--- /dev/null
+++ b/Examples/test-suite/errors/pp_invalid_exponents.i
@@ -0,0 +1,7 @@
+%module xxx
+
+#if 123e
+#endif
+
+#if 456.e
+#endif
diff --git a/Examples/test-suite/errors/pp_invalid_exponents.stderr b/Examples/test-suite/errors/pp_invalid_exponents.stderr
new file mode 100644
index 000000000..735a31ceb
--- /dev/null
+++ b/Examples/test-suite/errors/pp_invalid_exponents.stderr
@@ -0,0 +1,6 @@
+:EOF: Error: Exponent does not have any digits
+pp_invalid_exponents.i:3: Warning 202: Could not evaluate expression '123e'
+pp_invalid_exponents.i:3: Warning 202: Error: 'Syntax error'
+:EOF: Error: Exponent does not have any digits
+pp_invalid_exponents.i:6: Warning 202: Could not evaluate expression '456.e'
+pp_invalid_exponents.i:6: Warning 202: Error: 'Syntax error'
diff --git a/Examples/test-suite/errors/pp_macro_missing_expression.i b/Examples/test-suite/errors/pp_macro_missing_expression.i
index 2c7c9855d..a93a76f2e 100644
--- a/Examples/test-suite/errors/pp_macro_missing_expression.i
+++ b/Examples/test-suite/errors/pp_macro_missing_expression.i
@@ -1,4 +1,4 @@
-// Test "Missing identifier for ..." errrors
+// Test "Missing identifier for ..." errors
%module xxx
#ifdef
diff --git a/Examples/test-suite/errors/pp_missing_file.i b/Examples/test-suite/errors/pp_missing_file.i
index 5e3f0ea27..366f159cc 100644
--- a/Examples/test-suite/errors/pp_missing_file.i
+++ b/Examples/test-suite/errors/pp_missing_file.i
@@ -1,3 +1,3 @@
-%module test
+%module xxx
%include "missing_filename.i"
diff --git a/Examples/test-suite/errors/pp_unknowndirective3.i b/Examples/test-suite/errors/pp_unknowndirective3.i
new file mode 100644
index 000000000..77dfd5bb5
--- /dev/null
+++ b/Examples/test-suite/errors/pp_unknowndirective3.i
@@ -0,0 +1,14 @@
+%module xxx
+
+// Testing is_digits detecting gcc linemarkers
+
+// These are valid
+# 1 "/usr/include/stdc-predef.h" 1 3 4
+# 123 "header1.h"
+
+// These are invalid
+#a1 'a.h'
+#1b 'b.h'
+#1c1 'c.h'
+#d1d 'd.h'
+
diff --git a/Examples/test-suite/errors/pp_unknowndirective3.stderr b/Examples/test-suite/errors/pp_unknowndirective3.stderr
new file mode 100644
index 000000000..35bff8a80
--- /dev/null
+++ b/Examples/test-suite/errors/pp_unknowndirective3.stderr
@@ -0,0 +1,4 @@
+pp_unknowndirective3.i:10: Error: Unknown SWIG preprocessor directive: a1 (if this is a block of target language code, delimit it with %{ and %})
+pp_unknowndirective3.i:11: Error: Unknown SWIG preprocessor directive: 1b (if this is a block of target language code, delimit it with %{ and %})
+pp_unknowndirective3.i:12: Error: Unknown SWIG preprocessor directive: 1c1 (if this is a block of target language code, delimit it with %{ and %})
+pp_unknowndirective3.i:13: Error: Unknown SWIG preprocessor directive: d1d (if this is a block of target language code, delimit it with %{ and %})
diff --git a/Examples/test-suite/exception_order.i b/Examples/test-suite/exception_order.i
index bca745c7e..e2411634b 100644
--- a/Examples/test-suite/exception_order.i
+++ b/Examples/test-suite/exception_order.i
@@ -12,10 +12,10 @@
%include "exception.i"
+// throw is invalid in C++17 and later, only SWIG to use it
+#define TESTCASE_THROW1(T1) throw(T1)
%{
-#if defined(_MSC_VER)
- #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
+#define TESTCASE_THROW1(T1)
%}
/*
@@ -23,7 +23,17 @@
user's throw declarations.
*/
-#if defined(SWIGUTL)
+#if defined(SWIGOCTAVE)
+%exception {
+ try {
+ $action
+ }
+ SWIG_RETHROW_OCTAVE_EXCEPTIONS
+ catch(...) {
+ SWIG_exception(SWIG_RuntimeError,"postcatch unknown");
+ }
+}
+#elif defined(SWIGUTL)
%exception {
try {
$action
@@ -89,16 +99,16 @@
int efoovar;
/* caught by the user's throw definition */
- int foo() throw(E1)
+ int foo() TESTCASE_THROW1(E1)
{
throw E1();
- return 0;
+ return 0;
}
-
- int bar() throw(E2)
+
+ int bar() TESTCASE_THROW1(E2)
{
throw E2();
- return 0;
+ return 0;
}
/* caught by %postexception */
@@ -136,3 +146,4 @@ bool is_python_builtin() { return false; }
%template(ET_i) ET<int>;
%template(ET_d) ET<double>;
+
diff --git a/Examples/test-suite/exception_partial_info.i b/Examples/test-suite/exception_partial_info.i
index 47b046735..3ac465cf6 100644
--- a/Examples/test-suite/exception_partial_info.i
+++ b/Examples/test-suite/exception_partial_info.i
@@ -2,10 +2,10 @@
// This produced compilable code for Tcl, Python in 1.3.27, fails in 1.3.29
+// throw is invalid in C++17 and later, only SWIG to use it
+#define TESTCASE_THROW1(T1) throw(T1)
%{
-#if defined(_MSC_VER)
- #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
+#define TESTCASE_THROW1(T1)
%}
%{
@@ -36,8 +36,8 @@ class ex2 : public myException
class Impl
{
public:
- void f1() throw (myException) { ex1 e; throw e; }
- void f2() throw (myException) { ex2 e; throw e; }
+ void f1() TESTCASE_THROW1(myException) { ex1 e; throw e; }
+ void f2() TESTCASE_THROW1(myException) { ex2 e; throw e; }
};
%}
diff --git a/Examples/test-suite/extend.i b/Examples/test-suite/extend.i
index 29e258f5b..ab0c651a5 100644
--- a/Examples/test-suite/extend.i
+++ b/Examples/test-suite/extend.i
@@ -1,5 +1,9 @@
%module extend
+#ifdef SWIGOCAML
+%warnfilter(SWIGWARN_PARSE_KEYWORD) method;
+#endif
+
%extend Base {
~Base() {
delete $self;
diff --git a/Examples/test-suite/extend_template_method.i b/Examples/test-suite/extend_template_method.i
new file mode 100644
index 000000000..8c03d9b51
--- /dev/null
+++ b/Examples/test-suite/extend_template_method.i
@@ -0,0 +1,92 @@
+%module extend_template_method
+
+%include <std_string.i>
+
+%inline %{
+namespace Space {
+class ExtendMe {
+public:
+ ExtendMe() {}
+ template <typename T>
+ T do_stuff_impl(int a, T b, double d) {
+ return b;
+ }
+};
+}
+%}
+
+%extend Space::ExtendMe {
+ template<typename T>
+ T do_stuff(int a, T b) {
+ return $self->do_stuff_impl(a, b, 4.0);
+ }
+ template<typename T>
+ T do_overloaded_stuff(T b) {
+ return $self->do_stuff_impl(0, b, 4.0);
+ }
+ template<typename T>
+ static T static_method(T t) {
+ return t;
+ }
+ template<typename T>
+ ExtendMe(T x) {
+ Space::ExtendMe *em = new Space::ExtendMe();
+ return em;
+ }
+}
+%template(do_stuff_double) Space::ExtendMe::do_stuff<double>;
+%template(do_stuff_string) Space::ExtendMe::do_stuff<std::string>;
+
+%template(do_overloaded_stuff) Space::ExtendMe::do_overloaded_stuff<std::string>;
+%template(do_overloaded_stuff) Space::ExtendMe::do_overloaded_stuff<double>;
+
+%template(static_method) Space::ExtendMe::static_method<int>;
+
+%template(ExtendMe) Space::ExtendMe::ExtendMe<int>;
+
+%inline %{
+namespace Space {
+template<typename X>
+class TemplateExtendMe {
+public:
+ TemplateExtendMe() {}
+ template <typename T>
+ T template_stuff_impl(X a, T b, double d) {
+ return b;
+ }
+};
+}
+%}
+
+%extend Space::TemplateExtendMe {
+ template<typename T>
+ T do_template_stuff(int a, T b) {
+ return $self->template_stuff_impl(a, b, 4.0);
+ }
+ template<typename T>
+ T do_template_overloaded_stuff(T b) {
+ return $self->template_stuff_impl(0, b, 4.0);
+ }
+ template<typename T>
+ static T static_template_method(T t) {
+ return t;
+ }
+ template<typename T>
+ TemplateExtendMe(T x) {
+ Space::TemplateExtendMe<X> *em = new Space::TemplateExtendMe<X>();
+ return em;
+ }
+
+%template(do_template_stuff_double) do_template_stuff<double>;
+%template(do_template_stuff_string) do_template_stuff<std::string>;
+
+%template(do_template_overloaded_stuff) do_template_overloaded_stuff<std::string>;
+%template(do_template_overloaded_stuff) do_template_overloaded_stuff<double>;
+
+%template(static_template_method) static_template_method<int>;
+
+%template(TemplateExtendMe) Space::TemplateExtendMe::TemplateExtendMe<int>;
+}
+
+%template(TemplateExtend) Space::TemplateExtendMe<int>;
+
diff --git a/Examples/test-suite/extern_throws.i b/Examples/test-suite/extern_throws.i
index eab26244e..92ece4158 100644
--- a/Examples/test-suite/extern_throws.i
+++ b/Examples/test-suite/extern_throws.i
@@ -1,18 +1,18 @@
%module extern_throws
+// throw is invalid in C++17 and later, only SWIG to use it
+#define TESTCASE_THROW1(T1) throw(T1)
%{
-#if defined(_MSC_VER)
- #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
+#define TESTCASE_THROW1(T1)
%}
%inline %{
#include <exception>
-extern int get() throw(std::exception);
+extern int get() TESTCASE_THROW1(std::exception);
%}
%{
-int get() throw(std::exception) { return 0; }
+int get() TESTCASE_THROW1(std::exception) { return 0; }
%}
diff --git a/Examples/test-suite/features.i b/Examples/test-suite/features.i
index 2ccbe725a..a8b56527d 100644
--- a/Examples/test-suite/features.i
+++ b/Examples/test-suite/features.i
@@ -2,6 +2,10 @@
%warnfilter(SWIGWARN_LANG_IDENTIFIER,SWIGWARN_IGNORE_OPERATOR_PLUSEQ);
+#ifdef SWIGOCAML
+%warnfilter(SWIGWARN_PARSE_KEYWORD) method;
+#endif
+
// This testcase checks that %feature is working for templates and non user supplied constructors/destructors and is just generally working
// If the default %exception is used it will not compile. It shouldn't get used.
diff --git a/Examples/test-suite/friends.i b/Examples/test-suite/friends.i
index 2dfee6f3b..1ba1e5e17 100644
--- a/Examples/test-suite/friends.i
+++ b/Examples/test-suite/friends.i
@@ -5,7 +5,12 @@
%warnfilter(SWIGWARN_LANG_IDENTIFIER);
-
+#if defined(SWIGOCTAVE)
+%warnfilter(SWIGWARN_IGNORE_OPERATOR_LSHIFT_MSG) operator<<;
+%warnfilter(SWIGWARN_IGNORE_OPERATOR_RSHIFT_MSG) operator>>;
+#endif
+
+
%inline
{
diff --git a/Examples/test-suite/friends_template.i b/Examples/test-suite/friends_template.i
index 48623f2ca..363e88f16 100644
--- a/Examples/test-suite/friends_template.i
+++ b/Examples/test-suite/friends_template.i
@@ -1,5 +1,10 @@
%module friends_template
+#if defined(SWIGOCTAVE)
+%warnfilter(SWIGWARN_IGNORE_OPERATOR_RSHIFT_MSG) operator>>;
+#endif
+
+
%{
template <typename Type> class MyClass;
diff --git a/Examples/test-suite/funcptr_cpp.i b/Examples/test-suite/funcptr_cpp.i
index b63749dc1..d8ec8de4d 100644
--- a/Examples/test-suite/funcptr_cpp.i
+++ b/Examples/test-suite/funcptr_cpp.i
@@ -15,6 +15,9 @@ int & addByReference(const int &a, int b) { static int val; val = a+b; return va
int call1(int (*d)(const int &, int), int a, int b) { return d(a, b); }
int call2(int * (*d)(const int &, int), int a, int b) { return *d(a, b); }
int call3(int & (*d)(const int &, int), int a, int b) { return d(a, b); }
+int call4(int & (*d)(int &, int *), int a, int b) { return d(a, &b); }
+int call5(int & (*d)(int &, int const * const), int a, int b) { return d(a, &b); }
+int callconst1(int (* const d)(const int &, int), int a, int b) { return d(a, b); }
%}
%constant int (*ADD_BY_VALUE)(const int &, int) = addByValue;
diff --git a/Examples/test-suite/functors.i b/Examples/test-suite/functors.i
new file mode 100644
index 000000000..363123000
--- /dev/null
+++ b/Examples/test-suite/functors.i
@@ -0,0 +1,33 @@
+%module functors
+
+// Rename operator() only if the language does not already do this by default
+#if defined(SWIGCSHARP) || defined(SWIGGO) || defined(SWIGGUILE) || defined(SWIGJAVA) || defined(SWIGJAVASCRIPT) || defined(SWIGPHP) || defined(SWIGSCILAB) || defined(SWIGTCL)
+%rename(Funktor) operator();
+#endif
+
+%inline %{
+class Functor0 {
+ int num;
+public:
+ Functor0(int num) : num(num) {}
+ int operator()() { return -num; }
+ int operate() { return this->operator()(); }
+};
+
+class Functor1 {
+ int num;
+public:
+ Functor1(int num) : num(num) {}
+ int operator()(int x) { return num + x; }
+ int operate(int x) { return this->operator()(x); }
+};
+
+class Functor2 {
+ int num;
+public:
+ Functor2(int num) : num(num) {}
+ int operator()(int x, int x2) { return num + x + x2; }
+ int operate(int x, int x2) { return this->operator()(x, x2); }
+};
+%}
+
diff --git a/Examples/test-suite/global_immutable_vars.i b/Examples/test-suite/global_immutable_vars.i
new file mode 100644
index 000000000..ab0d4f7a8
--- /dev/null
+++ b/Examples/test-suite/global_immutable_vars.i
@@ -0,0 +1,33 @@
+%module global_immutable_vars
+
+// Test immutable and mutable global variables,
+// see http://www.swig.org/Doc4.0/SWIGDocumentation.html#SWIG_readonly_variables
+
+%inline %{
+ int default_mutable_var = 40;
+%}
+
+%immutable;
+%feature("immutable", "0") specific_mutable_var;
+
+%inline %{
+ int global_immutable_var = 41;
+ int specific_mutable_var = 42;
+%}
+
+%mutable;
+%immutable specific_immutable_var;
+%inline %{
+ int global_mutable_var = 43;
+ int specific_immutable_var = 44;
+
+ int check_values(int default_mutable, int global_immutable, int specific_mutable, int global_mutable, int specific_immutable) {
+ return
+ default_mutable == default_mutable_var &&
+ global_immutable == global_immutable_var &&
+ specific_mutable == specific_mutable_var &&
+ global_mutable == global_mutable_var &&
+ specific_immutable == specific_immutable_var;
+ }
+%}
+
diff --git a/Examples/test-suite/global_immutable_vars_cpp.i b/Examples/test-suite/global_immutable_vars_cpp.i
new file mode 100644
index 000000000..40cc08e54
--- /dev/null
+++ b/Examples/test-suite/global_immutable_vars_cpp.i
@@ -0,0 +1,33 @@
+%module global_immutable_vars_cpp
+
+// Test immutable and mutable global variables,
+// see http://www.swig.org/Doc4.0/SWIGDocumentation.html#SWIG_readonly_variables
+
+%inline %{
+ int default_mutable_var = 40;
+%}
+
+%immutable;
+%feature("immutable", "0") specific_mutable_var;
+
+%inline %{
+ int global_immutable_var = 41;
+ int specific_mutable_var = 42;
+%}
+
+%mutable;
+%immutable specific_immutable_var;
+%inline %{
+ int global_mutable_var = 43;
+ int specific_immutable_var = 44;
+
+ int check_values(int default_mutable, int global_immutable, int specific_mutable, int global_mutable, int specific_immutable) {
+ return
+ default_mutable == default_mutable_var &&
+ global_immutable == global_immutable_var &&
+ specific_mutable == specific_mutable_var &&
+ global_mutable == global_mutable_var &&
+ specific_immutable == specific_immutable_var;
+ }
+%}
+
diff --git a/Examples/test-suite/go/Makefile.in b/Examples/test-suite/go/Makefile.in
index 01989b0d3..75debc538 100644
--- a/Examples/test-suite/go/Makefile.in
+++ b/Examples/test-suite/go/Makefile.in
@@ -6,24 +6,10 @@ LANGUAGE = go
GO = @GO@
GOGCC = @GOGCC@
GCCGO = @GCCGO@
-GO1 = @GO1@
-GO12 = @GO12@
-GO13 = @GO13@
-GO15 = @GO15@
-GOC = @GOC@
GOVERSIONOPTION = @GOVERSIONOPTION@
host = @host@
SCRIPTSUFFIX = _runme.go
-GOCOMPILEARG = `if $(GO15); then echo tool compile; elif $(GO1); then echo tool $(GOC:c=g); fi`
-GOLD = `if $(GO15); then echo link; else echo $(GOC:c=l); fi`
-GOTOOL = `if $(GO1) ; then echo go tool; fi`
-GOPACK = `if $(GO1) ; then echo go tool pack; else echo gopack; fi`
-
-GOOBJEXT = `if $(GO15); then echo o; else echo $(GOC:c=); fi`
-
-OSXOLDGOLINKFLAGS = `if [ -n "\`$(GO) $(GOVERSIONOPTION) | grep -E 'go1($|.0|.1|.2|.3)'\`" ] && [ -n "\`echo $(host) | grep darwin\`" ]; then echo "-Wl,-U,__cgo_topofstack"; fi`
-
SO = @SO@
srcdir = @srcdir@
@@ -49,31 +35,26 @@ INCLUDES = -I$(abs_top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)
$(setup)
+$(swig_and_compile_cpp)
$(run_testcase_cpp)
- if ! $(GO15); then \
- $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
- SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- INCLUDES='$(INCLUDES)' SWIGOPT='$(SWIGOPT)' NOLINK=true \
- TARGET='$(TARGETPREFIX)$*$(TARGETSUFFIX)' INTERFACEDIR='$(INTERFACEDIR)' INTERFACE='$*.i' \
- $(LANGUAGE)$(VARIANT)_cpp_nocgo && \
- $(run_testcase_cpp); \
- fi
%.ctest:
$(setup)
+$(swig_and_compile_c)
$(run_testcase)
- if ! $(GO15); then \
- $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' CSRCS='$(CSRCS)' \
- SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
- INCLUDES='$(INCLUDES)' SWIGOPT='$(SWIGOPT)' NOLINK=true \
- TARGET='$(TARGETPREFIX)$*$(TARGETSUFFIX)' INTERFACEDIR='$(INTERFACEDIR)' INTERFACE='$*.i' \
- $(LANGUAGE)$(VARIANT)_nocgo && \
- $(run_testcase); \
- fi
%.multicpptest:
$(setup)
- +$(swig_and_compile_multi_cpp)
+ mkdir -p gopath/$*/src 2>/dev/null || true
+ if ! test -d gopath/$*/src/swigtests; then \
+ (cd gopath/$*/src && ln -s . swigtests); \
+ fi
+ +for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
+ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
+ LIBS='$(LIBS)' INCLUDES='$(INCLUDES)' SWIGOPT='$(SWIGOPT)' NOLINK=true \
+ TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR='$(INTERFACEDIR)' INTERFACE="$$f.i" \
+ GOMOD="$*" \
+ $(LANGUAGE)$(VARIANT)_cpp; \
+ done
$(run_multi_testcase)
li_windows.cpptest:
@@ -82,85 +63,108 @@ li_windows.cpptest:
multi_import.multicpptest:
$(setup)
+ mkdir -p gopath/multi_import/src 2>/dev/null || true
+ if ! test -d gopath/multi_import/src/swigtests; then \
+ (cd gopath/multi_import/src && ln -s . swigtests); \
+ fi
for f in multi_import_b multi_import_a; do \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
LIBS='$(LIBS)' INCLUDES='$(INCLUDES)' SWIGOPT='$(SWIGOPT)' NOLINK=true \
TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR='$(INTERFACEDIR)' INTERFACE="$$f.i" \
+ GOMOD="multi_import" \
$(LANGUAGE)$(VARIANT)_cpp; \
done
$(run_multi_testcase)
go_subdir_import.multicpptest:
$(setup)
- mkdir -p testdir/go_subdir_import/
- mkdir -p gopath/src/testdir/go_subdir_import/
+ mkdir -p gopath/go_subdir_import/src 2>/dev/null || true
+ if ! test -d gopath/go_subdir_import/src/swigtests; then \
+ (cd gopath/go_subdir_import/src && ln -s . swigtests); \
+ fi
+ mkdir -p testdir/go_subdir_import 2>/dev/null || true
+ mkdir -p gopath/go_subdir_import/src/testdir/go_subdir_import 2>/dev/null || true
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
LIBS='$(LIBS)' INTERFACEPATH='$(SRCDIR)$(INTERFACEDIR)go_subdir_import_b.i' \
INCLUDES='$(INCLUDES)' SWIGOPT='$(SWIGOPT) -outdir .' NOLINK=true \
TARGET='$(TARGETPREFIX)go_subdir_import_b$(TARGETSUFFIX)' INTERFACEDIR='$(INTERFACEDIR)' \
INTERFACE='testdir/go_subdir_import/go_subdir_import_b.i' \
+ GOMOD="go_subdir_import" \
$(LANGUAGE)$(VARIANT)_cpp;
for f in testdir/go_subdir_import/go_subdir_import_c go_subdir_import_a ; do \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
LIBS='$(LIBS)' INCLUDES='$(INCLUDES)' SWIGOPT='$(SWIGOPT)' NOLINK=true \
TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR='$(INTERFACEDIR)' INTERFACE="$$f.i" \
+ GOMOD="go_subdir_import" \
$(LANGUAGE)$(VARIANT)_cpp; \
done
- if $(GOGCC); then \
- cp gopath/src/testdir/go_subdir_import/go_subdir_import_b/go_subdir_import_b.a gopath/src/testdir/go_subdir_import/go_subdir_import_b.gox; \
- cp gopath/src/testdir/go_subdir_import/go_subdir_import_b/go_subdir_import_b.a .; \
- cp gopath/src/testdir/go_subdir_import/go_subdir_import_c/go_subdir_import_c.a gopath/src/testdir/go_subdir_import/go_subdir_import_c.gox; \
- cp gopath/src/testdir/go_subdir_import/go_subdir_import_c/go_subdir_import_c.a testdir/go_subdir_import/; \
- fi
$(run_multi_testcase)
# Runs the testcase.
run_testcase = \
if test -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \
- if $(GOGCC) ; then \
- $(COMPILETOOL) $(GCCGO) -c -g -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
- $(COMPILETOOL) $(GCCGO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ $*.a; \
- elif $(GO12) || $(GO13) || $(GO15); then \
- $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
- $(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld $(CC) -extldflags "$(CFLAGS) $(OSXOLDGOLINKFLAGS)" -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
- else \
- $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
- $(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
- fi && \
+ GOPATH=`pwd`/gopath/; \
+ export GOPATH; \
+ CGO_CPPFLAGS="$(CPPFLAGS) $(INCLUDES) -I `cd $(SRCDIR) && pwd` -I `pwd`"; \
+ export CGO_CPPFLAGS; \
+ CGO_CFLAGS="$(CFLAGS)"; \
+ export CGO_CFLAGS; \
+ CGO_CXXFLAGS="$(CXXFLAGS)"; \
+ export CGO_CXXFLAGS; \
+ CGO_LDFLAGS="$(LDFLAGS) -lm"; \
+ export CGO_LDFLAGS; \
+ mkdir gopath/src/swigtests 2>/dev/null || true; \
+ mkdir gopath/src/swigtests/$* 2>/dev/null || true; \
+ cp gopath/src/$*/* gopath/src/swigtests/$*/; \
+ mkdir gopath/src/$*/runme 2>/dev/null || true; \
+ cp $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) gopath/src/$*/runme/runme.go; \
+ (cd gopath/src/$*/runme && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o runme runme.go); \
+ cp gopath/src/$*/runme/runme $*_runme; \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./$*_runme; \
fi
run_testcase_cpp = \
if test -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \
- if $(GOGCC) ; then \
- $(COMPILETOOL) $(GCCGO) -c -g -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
- $(COMPILETOOL) $(GCCGO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ $*.a -lstdc++; \
- elif $(GO12) || $(GO13) || $(GO15); then \
- $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
- $(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld $(CXX) -extldflags "$(CXXFLAGS) $(OSXOLDGOLINKFLAGS)" -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
- else \
- $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
- $(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
- fi && \
+ GOPATH=`pwd`/gopath/; \
+ export GOPATH; \
+ CGO_CPPFLAGS="$(CPPFLAGS) $(INCLUDES) -I `cd $(SRCDIR) && pwd` -I `pwd`"; \
+ export CGO_CPPFLAGS; \
+ CGO_CFLAGS="$(CFLAGS)"; \
+ export CGO_CFLAGS; \
+ CGO_CXXFLAGS="$(CXXFLAGS)"; \
+ export CGO_CXXFLAGS; \
+ CGO_LDFLAGS="$(LDFLAGS) -lm"; \
+ export CGO_LDFLAGS; \
+ mkdir gopath/src/swigtests 2>/dev/null || true; \
+ mkdir gopath/src/swigtests/$* 2>/dev/null || true; \
+ cp gopath/src/$*/* gopath/src/swigtests/$*/; \
+ mkdir gopath/src/$*/runme 2>/dev/null || true; \
+ cp $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) gopath/src/$*/runme/runme.go; \
+ (cd gopath/src/$*/runme && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o runme runme.go); \
+ cp gopath/src/$*/runme/runme $*_runme; \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./$*_runme; \
fi
run_multi_testcase = \
if test -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \
- if $(GOGCC) ; then \
- $(COMPILETOOL) $(GCCGO) -c -g -I . -I gopath/src $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
- files=`cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list`; \
- $(COMPILETOOL) $(GCCGO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ `for f in $$files; do echo $$f.a; done` -lstdc++; \
- elif $(GO12) || $(GO13) || $(GO15); then \
- $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
- $(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -linkmode external -extld $(CXX) -extldflags "$(CXXFLAGS) $(OSXOLDGOLINKFLAGS)" -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
- else \
- $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
- $(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
- fi && \
+ files=`cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list`; \
+ mkdir gopath/$*/src/$* 2>/dev/null || true; \
+ cp $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) gopath/$*/src/$*; \
+ GOPATH="`pwd`/gopath/$*"; \
+ export GOPATH; \
+ CGO_CPPFLAGS="$(CPPFLAGS) $(INCLUDES) `for f in $$files; do echo -I ../$$f; done`"; \
+ export CGO_CPPFLAGS; \
+ CGO_CFLAGS="$(CFLAGS)"; \
+ export CGO_CFLAGS; \
+ CGO_CXXFLAGS="$(CXXFLAGS)"; \
+ export CGO_CXXFLAGS; \
+ CGO_LDFLAGS="$(LDFLAGS) -lm"; \
+ export CGO_LDFLAGS; \
+ (cd gopath/$*/src/$* && \
+ $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o ../../../../$*_runme) && \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./$*_runme; \
fi
@@ -169,25 +173,17 @@ run_multi_testcase = \
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' go_clean
- rm -f mod_a.go mod_a.gox mod_b.go mod_b.gox
- rm -f imports_a.go imports_a.gox imports_b.go imports_b.gox
rm -f clientdata_prop_a.go clientdata_prop_a.gox
rm -f clientdata_prop_b.go clientdata_prop_b.gox
+ rm -f import_stl_a.go import_stl_a.gox
+ rm -f import_stl_b.go import_stl_b.gox
+ rm -f imports_a.go imports_a.gox imports_b.go imports_b.gox
+ rm -f mod_a.go mod_a.gox mod_b.go mod_b.gox
rm -f multi_import_a.go multi_import_a.gox
rm -f multi_import_b.go multi_import_b.gox
- rm -rf go_subdir_import_a.go go_subdir_import_a.gox testdir
rm -f packageoption_a.go packageoption_a.gox
rm -f packageoption_b.go packageoption_b.gox
rm -f packageoption_c.go packageoption_c.gox
- rm -f import_stl_a.go import_stl_a.gox
- rm -f import_stl_b.go import_stl_b.gox
+ rm -f template_typedef_cplx2.go template_typedef_cplx2.gox
+ rm -rf go_subdir_import_a.go go_subdir_import_a.gox testdir
rm -rf gopath
-
-cvsignore:
- @echo '*_gc.c *_wrap.* *.so *.dll *.exp *.lib'
- @echo Makefile
- @echo mod_a.go mod_b.go imports_a.go imports_b.go
- @echo clientdata_prop_a.go clientdata_prop_b.go
- @echo multi_import_a.go multi_import_b.go
- @echo packageoption_a.go packageoption_b.go packageoption_c.go
- @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do echo $$i.go; done
diff --git a/Examples/test-suite/go/abstract_access_runme.go b/Examples/test-suite/go/abstract_access_runme.go
index a2cfeda92..0a0e56fef 100644
--- a/Examples/test-suite/go/abstract_access_runme.go
+++ b/Examples/test-suite/go/abstract_access_runme.go
@@ -1,6 +1,6 @@
package main
-import "./abstract_access"
+import "swigtests/abstract_access"
func main() {
d := abstract_access.NewD()
diff --git a/Examples/test-suite/go/abstract_typedef2_runme.go b/Examples/test-suite/go/abstract_typedef2_runme.go
index ef760e45d..5e2ed1e7a 100644
--- a/Examples/test-suite/go/abstract_typedef2_runme.go
+++ b/Examples/test-suite/go/abstract_typedef2_runme.go
@@ -1,6 +1,6 @@
package main
-import "./abstract_typedef2"
+import "swigtests/abstract_typedef2"
func main() {
abstract_typedef2.NewA_UF()
diff --git a/Examples/test-suite/go/abstract_typedef_runme.go b/Examples/test-suite/go/abstract_typedef_runme.go
index 99ff94ded..1ad49f59d 100644
--- a/Examples/test-suite/go/abstract_typedef_runme.go
+++ b/Examples/test-suite/go/abstract_typedef_runme.go
@@ -1,6 +1,6 @@
package main
-import "./abstract_typedef"
+import "swigtests/abstract_typedef"
func main() {
e := abstract_typedef.NewEngine()
diff --git a/Examples/test-suite/go/abstract_virtual_runme.go b/Examples/test-suite/go/abstract_virtual_runme.go
index b87cf9b5c..d333d50b3 100644
--- a/Examples/test-suite/go/abstract_virtual_runme.go
+++ b/Examples/test-suite/go/abstract_virtual_runme.go
@@ -1,6 +1,6 @@
package main
-import "./abstract_virtual"
+import "swigtests/abstract_virtual"
func main() {
abstract_virtual.NewD()
diff --git a/Examples/test-suite/go/argout_runme.go b/Examples/test-suite/go/argout_runme.go
index 5f7017e73..b2edf54b6 100644
--- a/Examples/test-suite/go/argout_runme.go
+++ b/Examples/test-suite/go/argout_runme.go
@@ -1,6 +1,6 @@
package main
-import wrap "./argout"
+import wrap "swigtests/argout"
func main() {
ip := wrap.New_intp()
diff --git a/Examples/test-suite/go/array_member_runme.go b/Examples/test-suite/go/array_member_runme.go
index d8a8fac2b..d8c3896ee 100644
--- a/Examples/test-suite/go/array_member_runme.go
+++ b/Examples/test-suite/go/array_member_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./array_member"
+import . "swigtests/array_member"
func main() {
f := NewFoo()
diff --git a/Examples/test-suite/go/arrays_global_runme.go b/Examples/test-suite/go/arrays_global_runme.go
index 0ff40090c..9c4a9e57a 100644
--- a/Examples/test-suite/go/arrays_global_runme.go
+++ b/Examples/test-suite/go/arrays_global_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./arrays_global"
+import . "swigtests/arrays_global"
func main() {
SetArray_i(GetArray_const_i())
diff --git a/Examples/test-suite/go/char_binary_runme.go b/Examples/test-suite/go/char_binary_runme.go
index 50f2e121d..3c8c2d72d 100644
--- a/Examples/test-suite/go/char_binary_runme.go
+++ b/Examples/test-suite/go/char_binary_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./char_binary"
+import . "swigtests/char_binary"
func main() {
t := NewTest()
diff --git a/Examples/test-suite/go/class_ignore_runme.go b/Examples/test-suite/go/class_ignore_runme.go
index 82e52eff5..11cf81d91 100644
--- a/Examples/test-suite/go/class_ignore_runme.go
+++ b/Examples/test-suite/go/class_ignore_runme.go
@@ -1,6 +1,6 @@
package main
-import "./class_ignore"
+import "swigtests/class_ignore"
func main() {
a := class_ignore.NewBar()
diff --git a/Examples/test-suite/go/class_scope_weird_runme.go b/Examples/test-suite/go/class_scope_weird_runme.go
index 332586f31..477699061 100644
--- a/Examples/test-suite/go/class_scope_weird_runme.go
+++ b/Examples/test-suite/go/class_scope_weird_runme.go
@@ -1,6 +1,6 @@
package main
-import "./class_scope_weird"
+import "swigtests/class_scope_weird"
func main() {
f := class_scope_weird.NewFoo()
diff --git a/Examples/test-suite/go/compactdefaultargs_runme.go b/Examples/test-suite/go/compactdefaultargs_runme.go
index 46f3ff3f9..c9e90087f 100644
--- a/Examples/test-suite/go/compactdefaultargs_runme.go
+++ b/Examples/test-suite/go/compactdefaultargs_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./compactdefaultargs"
+import . "swigtests/compactdefaultargs"
func main() {
defaults1 := NewDefaults1(1000)
diff --git a/Examples/test-suite/go/constover_runme.go b/Examples/test-suite/go/constover_runme.go
index f961e01b5..51d965e7f 100644
--- a/Examples/test-suite/go/constover_runme.go
+++ b/Examples/test-suite/go/constover_runme.go
@@ -1,9 +1,10 @@
package main
import (
- "./constover"
"fmt"
"os"
+
+ "swigtests/constover"
)
func main() {
diff --git a/Examples/test-suite/go/constructor_copy_runme.go b/Examples/test-suite/go/constructor_copy_runme.go
index d9b77a9db..ca4725549 100644
--- a/Examples/test-suite/go/constructor_copy_runme.go
+++ b/Examples/test-suite/go/constructor_copy_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./constructor_copy"
+import . "swigtests/constructor_copy"
func main() {
f1 := NewFoo1(3)
diff --git a/Examples/test-suite/go/contract_runme.go b/Examples/test-suite/go/contract_runme.go
index b20a1a64f..7c9d0979e 100644
--- a/Examples/test-suite/go/contract_runme.go
+++ b/Examples/test-suite/go/contract_runme.go
@@ -1,6 +1,6 @@
package main
-import "./contract"
+import "swigtests/contract"
func main() {
contract.Test_preassert(1, 2)
diff --git a/Examples/test-suite/go/cpp11_strongly_typed_enumerations_runme.go b/Examples/test-suite/go/cpp11_strongly_typed_enumerations_runme.go
index f4b84b1ee..926b6f756 100644
--- a/Examples/test-suite/go/cpp11_strongly_typed_enumerations_runme.go
+++ b/Examples/test-suite/go/cpp11_strongly_typed_enumerations_runme.go
@@ -1,7 +1,7 @@
package main
import "fmt"
-import . "./cpp11_strongly_typed_enumerations"
+import . "swigtests/cpp11_strongly_typed_enumerations"
func enumCheck(actual int, expected int) int {
if actual != expected {
diff --git a/Examples/test-suite/go/cpp_enum_runme.go b/Examples/test-suite/go/cpp_enum_runme.go
index 7d7db953d..9b8930a44 100644
--- a/Examples/test-suite/go/cpp_enum_runme.go
+++ b/Examples/test-suite/go/cpp_enum_runme.go
@@ -1,6 +1,6 @@
package main
-import "./cpp_enum"
+import "swigtests/cpp_enum"
func main() {
f := cpp_enum.NewFoo()
diff --git a/Examples/test-suite/go/cpp_namespace_runme.go b/Examples/test-suite/go/cpp_namespace_runme.go
index 8482b043f..71affc57d 100644
--- a/Examples/test-suite/go/cpp_namespace_runme.go
+++ b/Examples/test-suite/go/cpp_namespace_runme.go
@@ -1,7 +1,7 @@
// Note: This example assumes that namespaces are flattened
package main
-import "./cpp_namespace"
+import "swigtests/cpp_namespace"
func main() {
n := cpp_namespace.Fact(4)
diff --git a/Examples/test-suite/go/cpp_static_runme.go b/Examples/test-suite/go/cpp_static_runme.go
index ead433466..d482298eb 100644
--- a/Examples/test-suite/go/cpp_static_runme.go
+++ b/Examples/test-suite/go/cpp_static_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./cpp_static"
+import . "swigtests/cpp_static"
func main() {
StaticFunctionTestStatic_func()
diff --git a/Examples/test-suite/go/default_args_runme.go b/Examples/test-suite/go/default_args_runme.go
index 38243ac44..5b6f404e3 100644
--- a/Examples/test-suite/go/default_args_runme.go
+++ b/Examples/test-suite/go/default_args_runme.go
@@ -1,6 +1,6 @@
package main
-import "./default_args"
+import "swigtests/default_args"
func main() {
if default_args.StaticsStaticmethod() != 60 {
diff --git a/Examples/test-suite/go/default_constructor_runme.go b/Examples/test-suite/go/default_constructor_runme.go
index 40a5a6e49..90d960143 100644
--- a/Examples/test-suite/go/default_constructor_runme.go
+++ b/Examples/test-suite/go/default_constructor_runme.go
@@ -1,6 +1,6 @@
package main
-import dc "./default_constructor"
+import dc "swigtests/default_constructor"
func main() {
a := dc.NewA()
diff --git a/Examples/test-suite/go/director_alternating_runme.go b/Examples/test-suite/go/director_alternating_runme.go
index 10f6774a3..2df31db82 100644
--- a/Examples/test-suite/go/director_alternating_runme.go
+++ b/Examples/test-suite/go/director_alternating_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./director_alternating"
+import . "swigtests/director_alternating"
func main() {
id := GetBar().Id()
diff --git a/Examples/test-suite/go/director_basic_runme.go b/Examples/test-suite/go/director_basic_runme.go
index 0ce780bbd..c308f2520 100644
--- a/Examples/test-suite/go/director_basic_runme.go
+++ b/Examples/test-suite/go/director_basic_runme.go
@@ -1,6 +1,6 @@
package main
-import "./director_basic"
+import "swigtests/director_basic"
type GoFoo struct{}
diff --git a/Examples/test-suite/go/director_classic_runme.go b/Examples/test-suite/go/director_classic_runme.go
index 45e89eac5..d8acc1337 100644
--- a/Examples/test-suite/go/director_classic_runme.go
+++ b/Examples/test-suite/go/director_classic_runme.go
@@ -1,7 +1,7 @@
package main
import "fmt"
-import . "./director_classic"
+import . "swigtests/director_classic"
type TargetLangPerson struct{} // From Person
func (p *TargetLangPerson) Id() string {
diff --git a/Examples/test-suite/go/director_default_runme.go b/Examples/test-suite/go/director_default_runme.go
index 2f963b239..557d5c54b 100644
--- a/Examples/test-suite/go/director_default_runme.go
+++ b/Examples/test-suite/go/director_default_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./director_default"
+import . "swigtests/director_default"
func main() {
NewFoo()
diff --git a/Examples/test-suite/go/director_detect_runme.go b/Examples/test-suite/go/director_detect_runme.go
index 9f1ad94a9..f82a0c04a 100644
--- a/Examples/test-suite/go/director_detect_runme.go
+++ b/Examples/test-suite/go/director_detect_runme.go
@@ -1,6 +1,6 @@
package main
-import "./director_detect"
+import "swigtests/director_detect"
type MyBar struct {
val int
diff --git a/Examples/test-suite/go/director_enum_runme.go b/Examples/test-suite/go/director_enum_runme.go
index 5653fda40..3e67417b2 100644
--- a/Examples/test-suite/go/director_enum_runme.go
+++ b/Examples/test-suite/go/director_enum_runme.go
@@ -1,6 +1,6 @@
package main
-import "./director_enum"
+import "swigtests/director_enum"
type MyFoo struct{} // From director_enum.Foo
func (p *MyFoo) Say_hi(val director_enum.EnumDirectorHello) director_enum.EnumDirectorHello {
diff --git a/Examples/test-suite/go/director_exception_runme.go b/Examples/test-suite/go/director_exception_runme.go
index 29df3e40b..167d75193 100644
--- a/Examples/test-suite/go/director_exception_runme.go
+++ b/Examples/test-suite/go/director_exception_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./director_exception"
+import . "swigtests/director_exception"
type Exception struct {
msg string
diff --git a/Examples/test-suite/go/director_extend_runme.go b/Examples/test-suite/go/director_extend_runme.go
index 70e2ab41b..adfb6ddb7 100644
--- a/Examples/test-suite/go/director_extend_runme.go
+++ b/Examples/test-suite/go/director_extend_runme.go
@@ -5,7 +5,7 @@
package main
-import . "./director_extend"
+import . "swigtests/director_extend"
func main() {
m := NewSpObject()
diff --git a/Examples/test-suite/go/director_finalizer_runme.go b/Examples/test-suite/go/director_finalizer_runme.go
index 96fcf860e..5cd9d95e0 100644
--- a/Examples/test-suite/go/director_finalizer_runme.go
+++ b/Examples/test-suite/go/director_finalizer_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./director_finalizer"
+import . "swigtests/director_finalizer"
type MyFoo struct{} // From Foo
func DeleteMyFoo(p Foo) {
diff --git a/Examples/test-suite/go/director_frob_runme.go b/Examples/test-suite/go/director_frob_runme.go
index a6afedf69..7354fa76b 100644
--- a/Examples/test-suite/go/director_frob_runme.go
+++ b/Examples/test-suite/go/director_frob_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./director_frob"
+import . "swigtests/director_frob"
func main() {
foo := NewBravo()
diff --git a/Examples/test-suite/go/director_nested_runme.go b/Examples/test-suite/go/director_nested_runme.go
index 2d3bc77e1..b04893582 100644
--- a/Examples/test-suite/go/director_nested_runme.go
+++ b/Examples/test-suite/go/director_nested_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./director_nested"
+import . "swigtests/director_nested"
type A struct{} // From FooBar_int
func (p *A) Do_step() string {
diff --git a/Examples/test-suite/go/director_profile_runme.go b/Examples/test-suite/go/director_profile_runme.go
index 87edcbe26..da0ea219b 100644
--- a/Examples/test-suite/go/director_profile_runme.go
+++ b/Examples/test-suite/go/director_profile_runme.go
@@ -1,7 +1,7 @@
package main
import "fmt"
-import "./director_profile"
+import "swigtests/director_profile"
type MyB struct{} // From director_profile.B
func (p *MyB) Vfi(a int) int {
diff --git a/Examples/test-suite/go/director_protected_runme.go b/Examples/test-suite/go/director_protected_runme.go
index 24adfe7bd..0012ccdb2 100644
--- a/Examples/test-suite/go/director_protected_runme.go
+++ b/Examples/test-suite/go/director_protected_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./director_protected"
+import . "swigtests/director_protected"
type FooBar struct{} // From Bar
func (p *FooBar) Ping() string {
diff --git a/Examples/test-suite/go/director_string_runme.go b/Examples/test-suite/go/director_string_runme.go
index c5201ab96..0c73b6a29 100644
--- a/Examples/test-suite/go/director_string_runme.go
+++ b/Examples/test-suite/go/director_string_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./director_string"
+import . "swigtests/director_string"
type B struct { // From A
abi A
diff --git a/Examples/test-suite/go/director_unroll_runme.go b/Examples/test-suite/go/director_unroll_runme.go
index 6d2894a72..560034c8a 100644
--- a/Examples/test-suite/go/director_unroll_runme.go
+++ b/Examples/test-suite/go/director_unroll_runme.go
@@ -1,6 +1,6 @@
package main
-import "./director_unroll"
+import "swigtests/director_unroll"
type MyFoo struct{} // From director_unroll.Foo
func (p *MyFoo) Ping() string {
diff --git a/Examples/test-suite/go/disown_runme.go b/Examples/test-suite/go/disown_runme.go
index 3e853de59..ba072a888 100644
--- a/Examples/test-suite/go/disown_runme.go
+++ b/Examples/test-suite/go/disown_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./disown"
+import . "swigtests/disown"
func main() {
a := NewA()
diff --git a/Examples/test-suite/go/dynamic_cast_runme.go b/Examples/test-suite/go/dynamic_cast_runme.go
index 476734805..213bc0ce5 100644
--- a/Examples/test-suite/go/dynamic_cast_runme.go
+++ b/Examples/test-suite/go/dynamic_cast_runme.go
@@ -1,6 +1,6 @@
package main
-import "./dynamic_cast"
+import "swigtests/dynamic_cast"
func main() {
f := dynamic_cast.NewFoo()
diff --git a/Examples/test-suite/go/empty_c_runme.go b/Examples/test-suite/go/empty_c_runme.go
index 831a56118..f093103f6 100644
--- a/Examples/test-suite/go/empty_c_runme.go
+++ b/Examples/test-suite/go/empty_c_runme.go
@@ -1,6 +1,6 @@
package main
-import _ "./empty_c"
+import _ "swigtests/empty_c"
func main() {
}
diff --git a/Examples/test-suite/go/empty_runme.go b/Examples/test-suite/go/empty_runme.go
index f74285cb0..03f423b8b 100644
--- a/Examples/test-suite/go/empty_runme.go
+++ b/Examples/test-suite/go/empty_runme.go
@@ -1,6 +1,6 @@
package main
-import _ "./empty"
+import _ "swigtests/empty"
func main() {
}
diff --git a/Examples/test-suite/go/enum_template_runme.go b/Examples/test-suite/go/enum_template_runme.go
index 269fe7d5b..7f43eab68 100644
--- a/Examples/test-suite/go/enum_template_runme.go
+++ b/Examples/test-suite/go/enum_template_runme.go
@@ -1,6 +1,6 @@
package main
-import "./enum_template"
+import "swigtests/enum_template"
func main() {
if enum_template.MakeETest() != 1 {
diff --git a/Examples/test-suite/go/enums_runme.go b/Examples/test-suite/go/enums_runme.go
index ab193f74b..4a879a048 100644
--- a/Examples/test-suite/go/enums_runme.go
+++ b/Examples/test-suite/go/enums_runme.go
@@ -1,6 +1,6 @@
package main
-import "./enums"
+import "swigtests/enums"
func main() {
enums.Bar2(1)
diff --git a/Examples/test-suite/go/exception_order_runme.go b/Examples/test-suite/go/exception_order_runme.go
index 626a826f8..ee67712fc 100644
--- a/Examples/test-suite/go/exception_order_runme.go
+++ b/Examples/test-suite/go/exception_order_runme.go
@@ -1,7 +1,7 @@
package main
import "strings"
-import . "./exception_order"
+import . "swigtests/exception_order"
func main() {
a := NewA()
diff --git a/Examples/test-suite/go/extend_placement_runme.go b/Examples/test-suite/go/extend_placement_runme.go
index efa776e31..879589679 100644
--- a/Examples/test-suite/go/extend_placement_runme.go
+++ b/Examples/test-suite/go/extend_placement_runme.go
@@ -1,6 +1,6 @@
package main
-import "./extend_placement"
+import "swigtests/extend_placement"
func main() {
foo := extend_placement.NewFoo()
diff --git a/Examples/test-suite/go/extend_template_ns_runme.go b/Examples/test-suite/go/extend_template_ns_runme.go
index 164a31b26..b1dd43a78 100644
--- a/Examples/test-suite/go/extend_template_ns_runme.go
+++ b/Examples/test-suite/go/extend_template_ns_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./extend_template_ns"
+import . "swigtests/extend_template_ns"
func main() {
f := NewFoo_One()
diff --git a/Examples/test-suite/go/extend_template_runme.go b/Examples/test-suite/go/extend_template_runme.go
index 5adb4b3c2..4a6b7099b 100644
--- a/Examples/test-suite/go/extend_template_runme.go
+++ b/Examples/test-suite/go/extend_template_runme.go
@@ -1,6 +1,6 @@
package main
-import "./extend_template"
+import "swigtests/extend_template"
func main() {
f := extend_template.NewFoo_0()
diff --git a/Examples/test-suite/go/extend_variable_runme.go b/Examples/test-suite/go/extend_variable_runme.go
index c6428c467..278bffed6 100644
--- a/Examples/test-suite/go/extend_variable_runme.go
+++ b/Examples/test-suite/go/extend_variable_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./extend_variable"
+import . "swigtests/extend_variable"
func main() {
if FooBar != 42 {
diff --git a/Examples/test-suite/go/extern_c_runme.go b/Examples/test-suite/go/extern_c_runme.go
index 0fb5b21cc..1cbfd9d80 100644
--- a/Examples/test-suite/go/extern_c_runme.go
+++ b/Examples/test-suite/go/extern_c_runme.go
@@ -1,6 +1,6 @@
package main
-import "./extern_c"
+import "swigtests/extern_c"
func main() {
extern_c.RealFunction(2)
diff --git a/Examples/test-suite/go/friends_runme.go b/Examples/test-suite/go/friends_runme.go
index 9f223fcac..b6b9e93f3 100644
--- a/Examples/test-suite/go/friends_runme.go
+++ b/Examples/test-suite/go/friends_runme.go
@@ -1,6 +1,6 @@
package main
-import "./friends"
+import "swigtests/friends"
func main() {
a := friends.NewA(2)
diff --git a/Examples/test-suite/go/fvirtual_runme.go b/Examples/test-suite/go/fvirtual_runme.go
index 8810d5cbb..01b94f419 100644
--- a/Examples/test-suite/go/fvirtual_runme.go
+++ b/Examples/test-suite/go/fvirtual_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./fvirtual"
+import . "swigtests/fvirtual"
func main() {
sw := NewNodeSwitch()
diff --git a/Examples/test-suite/go/global_ns_arg_runme.go b/Examples/test-suite/go/global_ns_arg_runme.go
index ece779c9c..aeacd91a3 100644
--- a/Examples/test-suite/go/global_ns_arg_runme.go
+++ b/Examples/test-suite/go/global_ns_arg_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./global_ns_arg"
+import . "swigtests/global_ns_arg"
func main() {
Foo(1)
diff --git a/Examples/test-suite/go/go_director_inout_runme.go b/Examples/test-suite/go/go_director_inout_runme.go
index 9b9df318e..171b3c223 100644
--- a/Examples/test-suite/go/go_director_inout_runme.go
+++ b/Examples/test-suite/go/go_director_inout_runme.go
@@ -1,7 +1,7 @@
package main
import (
- wrap "./go_director_inout"
+ wrap "swigtests/go_director_inout"
)
type GoMyClass struct {}
diff --git a/Examples/test-suite/go/go_inout_runme.go b/Examples/test-suite/go/go_inout_runme.go
index 9aa0cd0c5..2dc5b9908 100644
--- a/Examples/test-suite/go/go_inout_runme.go
+++ b/Examples/test-suite/go/go_inout_runme.go
@@ -5,7 +5,7 @@ import (
"fmt"
"reflect"
- "./go_inout"
+ "swigtests/go_inout"
)
type S struct {
diff --git a/Examples/test-suite/go/go_subdir_import_runme.go b/Examples/test-suite/go/go_subdir_import_runme.go
index f90a6eb54..a040c993f 100644
--- a/Examples/test-suite/go/go_subdir_import_runme.go
+++ b/Examples/test-suite/go/go_subdir_import_runme.go
@@ -1,9 +1,9 @@
package main
import (
- "go_subdir_import_a"
- "testdir/go_subdir_import/go_subdir_import_b"
- "testdir/go_subdir_import/go_subdir_import_c"
+ "swigtests/go_subdir_import_a"
+ "swigtests/testdir/go_subdir_import/go_subdir_import_b"
+ "swigtests/testdir/go_subdir_import/go_subdir_import_c"
)
func main() {
diff --git a/Examples/test-suite/go/grouping_runme.go b/Examples/test-suite/go/grouping_runme.go
index c63d6fb12..d5f347579 100644
--- a/Examples/test-suite/go/grouping_runme.go
+++ b/Examples/test-suite/go/grouping_runme.go
@@ -1,6 +1,6 @@
package main
-import "./grouping"
+import "swigtests/grouping"
func main() {
x := grouping.Test1(42)
diff --git a/Examples/test-suite/go/import_nomodule_runme.go b/Examples/test-suite/go/import_nomodule_runme.go
index a6bbd7de5..23680159d 100644
--- a/Examples/test-suite/go/import_nomodule_runme.go
+++ b/Examples/test-suite/go/import_nomodule_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./import_nomodule"
+import . "swigtests/import_nomodule"
func main() {
f := Create_Foo()
diff --git a/Examples/test-suite/go/imports_runme.go b/Examples/test-suite/go/imports_runme.go
index 896036cbf..a67ae407b 100644
--- a/Examples/test-suite/go/imports_runme.go
+++ b/Examples/test-suite/go/imports_runme.go
@@ -2,8 +2,8 @@
package main
-import "imports_b"
-import "imports_a"
+import "swigtests/imports_b"
+import "swigtests/imports_a"
func main() {
x := imports_b.NewB()
diff --git a/Examples/test-suite/go/inctest_runme.go b/Examples/test-suite/go/inctest_runme.go
index f8a2c116c..490721e75 100644
--- a/Examples/test-suite/go/inctest_runme.go
+++ b/Examples/test-suite/go/inctest_runme.go
@@ -1,6 +1,6 @@
package main
-import "./inctest"
+import "swigtests/inctest"
func main() {
inctest.NewA()
diff --git a/Examples/test-suite/go/inherit_member_runme.go b/Examples/test-suite/go/inherit_member_runme.go
index 599a0eb56..10dabad96 100644
--- a/Examples/test-suite/go/inherit_member_runme.go
+++ b/Examples/test-suite/go/inherit_member_runme.go
@@ -1,6 +1,6 @@
package main
-import wrap "./inherit_member"
+import wrap "swigtests/inherit_member"
func main() {
s := wrap.NewChild()
diff --git a/Examples/test-suite/go/inherit_missing_runme.go b/Examples/test-suite/go/inherit_missing_runme.go
index ba9a2a516..b4706e974 100644
--- a/Examples/test-suite/go/inherit_missing_runme.go
+++ b/Examples/test-suite/go/inherit_missing_runme.go
@@ -1,6 +1,6 @@
package main
-import "./inherit_missing"
+import "swigtests/inherit_missing"
func main() {
a := inherit_missing.New_Foo()
diff --git a/Examples/test-suite/go/input_runme.go b/Examples/test-suite/go/input_runme.go
index 207bdaa28..c5eb9e45d 100644
--- a/Examples/test-suite/go/input_runme.go
+++ b/Examples/test-suite/go/input_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./input"
+import . "swigtests/input"
func main() {
f := NewFoo()
diff --git a/Examples/test-suite/go/keyword_rename_c_runme.go b/Examples/test-suite/go/keyword_rename_c_runme.go
index 425e38a26..28f6ddd12 100644
--- a/Examples/test-suite/go/keyword_rename_c_runme.go
+++ b/Examples/test-suite/go/keyword_rename_c_runme.go
@@ -1,6 +1,6 @@
package main
-import "./keyword_rename_c"
+import "swigtests/keyword_rename_c"
func main() {
keyword_rename_c.Xgo(1)
diff --git a/Examples/test-suite/go/keyword_rename_runme.go b/Examples/test-suite/go/keyword_rename_runme.go
index e36bc5968..f93c7ab14 100644
--- a/Examples/test-suite/go/keyword_rename_runme.go
+++ b/Examples/test-suite/go/keyword_rename_runme.go
@@ -1,6 +1,6 @@
package main
-import "./keyword_rename"
+import "swigtests/keyword_rename"
func main() {
keyword_rename.Xgo(1)
diff --git a/Examples/test-suite/go/li_attribute_runme.go b/Examples/test-suite/go/li_attribute_runme.go
index 5d2c3d0c3..0702b898f 100644
--- a/Examples/test-suite/go/li_attribute_runme.go
+++ b/Examples/test-suite/go/li_attribute_runme.go
@@ -1,6 +1,6 @@
package main
-import "./li_attribute"
+import "swigtests/li_attribute"
func main() {
aa := li_attribute.NewA(1, 2, 3)
diff --git a/Examples/test-suite/go/li_carrays_cpp_runme.go b/Examples/test-suite/go/li_carrays_cpp_runme.go
index 7ee0a4103..a96291c7b 100644
--- a/Examples/test-suite/go/li_carrays_cpp_runme.go
+++ b/Examples/test-suite/go/li_carrays_cpp_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./li_carrays_cpp"
+import . "swigtests/li_carrays_cpp"
func main() {
d := NewDoubleArray(10)
diff --git a/Examples/test-suite/go/li_carrays_runme.go b/Examples/test-suite/go/li_carrays_runme.go
index 0cbe92cd8..eefc6ad72 100644
--- a/Examples/test-suite/go/li_carrays_runme.go
+++ b/Examples/test-suite/go/li_carrays_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./li_carrays"
+import . "swigtests/li_carrays"
func main() {
d := NewDoubleArray(10)
diff --git a/Examples/test-suite/go/li_cdata_cpp_runme.go b/Examples/test-suite/go/li_cdata_cpp_runme.go
index 42a0ebd08..5849c50d4 100644
--- a/Examples/test-suite/go/li_cdata_cpp_runme.go
+++ b/Examples/test-suite/go/li_cdata_cpp_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./li_cdata_cpp"
+import . "swigtests/li_cdata_cpp"
func main() {
s := "ABC abc"
diff --git a/Examples/test-suite/go/li_cdata_runme.go b/Examples/test-suite/go/li_cdata_runme.go
index f71a3a2c3..0c3e591ce 100644
--- a/Examples/test-suite/go/li_cdata_runme.go
+++ b/Examples/test-suite/go/li_cdata_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./li_cdata"
+import . "swigtests/li_cdata"
func main() {
s := "ABC abc"
diff --git a/Examples/test-suite/go/li_cmalloc_runme.go b/Examples/test-suite/go/li_cmalloc_runme.go
index 45f47b45f..fb1b009c3 100644
--- a/Examples/test-suite/go/li_cmalloc_runme.go
+++ b/Examples/test-suite/go/li_cmalloc_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./li_cmalloc"
+import . "swigtests/li_cmalloc"
func main() {
p := Malloc_int()
diff --git a/Examples/test-suite/go/li_cpointer_cpp_runme.go b/Examples/test-suite/go/li_cpointer_cpp_runme.go
index e2f5a59d1..f422b2310 100644
--- a/Examples/test-suite/go/li_cpointer_cpp_runme.go
+++ b/Examples/test-suite/go/li_cpointer_cpp_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./li_cpointer_cpp"
+import . "swigtests/li_cpointer_cpp"
func main() {
p := New_intp()
diff --git a/Examples/test-suite/go/li_cpointer_runme.go b/Examples/test-suite/go/li_cpointer_runme.go
index 57493b122..1a83bc62f 100644
--- a/Examples/test-suite/go/li_cpointer_runme.go
+++ b/Examples/test-suite/go/li_cpointer_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./li_cpointer"
+import . "swigtests/li_cpointer"
func main() {
p := New_intp()
diff --git a/Examples/test-suite/go/li_std_map_runme.go b/Examples/test-suite/go/li_std_map_runme.go
index 66e74dd60..019ac6e30 100644
--- a/Examples/test-suite/go/li_std_map_runme.go
+++ b/Examples/test-suite/go/li_std_map_runme.go
@@ -1,6 +1,6 @@
package main
-import "./li_std_map"
+import "swigtests/li_std_map"
func main() {
a1 := li_std_map.NewA(3)
diff --git a/Examples/test-suite/go/li_std_vector_ptr_runme.go b/Examples/test-suite/go/li_std_vector_ptr_runme.go
index a9f7fe91c..9a62d3796 100644
--- a/Examples/test-suite/go/li_std_vector_ptr_runme.go
+++ b/Examples/test-suite/go/li_std_vector_ptr_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./li_std_vector_ptr"
+import . "swigtests/li_std_vector_ptr"
import "fmt"
func check(val1 int, val2 int) {
diff --git a/Examples/test-suite/go/member_pointer_runme.go b/Examples/test-suite/go/member_pointer_runme.go
index 9a55bc4b9..02789382e 100644
--- a/Examples/test-suite/go/member_pointer_runme.go
+++ b/Examples/test-suite/go/member_pointer_runme.go
@@ -3,7 +3,7 @@
package main
import "fmt"
-import . "./member_pointer"
+import . "swigtests/member_pointer"
func check(what string, expected float64, actual float64) {
if expected != actual {
diff --git a/Examples/test-suite/go/memberin_extend_c_runme.go b/Examples/test-suite/go/memberin_extend_c_runme.go
index ec8b11e60..696f08abb 100644
--- a/Examples/test-suite/go/memberin_extend_c_runme.go
+++ b/Examples/test-suite/go/memberin_extend_c_runme.go
@@ -1,6 +1,6 @@
package main
-import "./memberin_extend_c"
+import "swigtests/memberin_extend_c"
func main() {
t := memberin_extend_c.NewPerson()
diff --git a/Examples/test-suite/go/minherit_runme.go b/Examples/test-suite/go/minherit_runme.go
index c69fe92c1..f1504af31 100644
--- a/Examples/test-suite/go/minherit_runme.go
+++ b/Examples/test-suite/go/minherit_runme.go
@@ -1,7 +1,7 @@
package main
import "fmt"
-import "./minherit"
+import "swigtests/minherit"
func main() {
a := minherit.NewFoo()
diff --git a/Examples/test-suite/go/mod_runme.go b/Examples/test-suite/go/mod_runme.go
index 581c83918..8d894db8d 100644
--- a/Examples/test-suite/go/mod_runme.go
+++ b/Examples/test-suite/go/mod_runme.go
@@ -1,7 +1,7 @@
package main
-import "mod_a"
-import "mod_b"
+import "swigtests/mod_a"
+import "swigtests/mod_b"
func main() {
c := mod_b.NewC()
diff --git a/Examples/test-suite/go/multi_import_runme.go b/Examples/test-suite/go/multi_import_runme.go
index 973af1e7b..f30913c6d 100644
--- a/Examples/test-suite/go/multi_import_runme.go
+++ b/Examples/test-suite/go/multi_import_runme.go
@@ -1,7 +1,7 @@
package main
-import "multi_import_a"
-import "multi_import_b"
+import "swigtests/multi_import_a"
+import "swigtests/multi_import_b"
func main() {
x := multi_import_b.NewXXX()
diff --git a/Examples/test-suite/go/namespace_class_runme.go b/Examples/test-suite/go/namespace_class_runme.go
index 2ed5567f7..435ee868a 100644
--- a/Examples/test-suite/go/namespace_class_runme.go
+++ b/Examples/test-suite/go/namespace_class_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./namespace_class"
+import . "swigtests/namespace_class"
func main() {
EulerT3DToFrame(1, 1, 1)
diff --git a/Examples/test-suite/go/namespace_typemap_runme.go b/Examples/test-suite/go/namespace_typemap_runme.go
index 056da1567..6da43331b 100644
--- a/Examples/test-suite/go/namespace_typemap_runme.go
+++ b/Examples/test-suite/go/namespace_typemap_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./namespace_typemap"
+import . "swigtests/namespace_typemap"
func main() {
if Stest1("hello") != "hello" {
diff --git a/Examples/test-suite/go/namespace_virtual_method_runme.go b/Examples/test-suite/go/namespace_virtual_method_runme.go
index 3f8e774c6..7ac4d3304 100644
--- a/Examples/test-suite/go/namespace_virtual_method_runme.go
+++ b/Examples/test-suite/go/namespace_virtual_method_runme.go
@@ -1,6 +1,6 @@
package main
-import "./namespace_virtual_method"
+import "swigtests/namespace_virtual_method"
func main() {
_ = namespace_virtual_method.NewSpam()
diff --git a/Examples/test-suite/go/naturalvar_runme.go b/Examples/test-suite/go/naturalvar_runme.go
index e3723e6ab..458745ec4 100644
--- a/Examples/test-suite/go/naturalvar_runme.go
+++ b/Examples/test-suite/go/naturalvar_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./naturalvar"
+import . "swigtests/naturalvar"
func main() {
f := NewFoo()
diff --git a/Examples/test-suite/go/nested_workaround_runme.go b/Examples/test-suite/go/nested_workaround_runme.go
index 5737aaaf7..f42b48764 100644
--- a/Examples/test-suite/go/nested_workaround_runme.go
+++ b/Examples/test-suite/go/nested_workaround_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./nested_workaround"
+import . "swigtests/nested_workaround"
func main() {
inner := NewInner(5)
diff --git a/Examples/test-suite/go/overload_complicated_runme.go b/Examples/test-suite/go/overload_complicated_runme.go
index e3911c218..c238d974f 100644
--- a/Examples/test-suite/go/overload_complicated_runme.go
+++ b/Examples/test-suite/go/overload_complicated_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./overload_complicated"
+import . "swigtests/overload_complicated"
func main() {
var pInt *int
diff --git a/Examples/test-suite/go/overload_copy_runme.go b/Examples/test-suite/go/overload_copy_runme.go
index d35ff70b1..9815d76ef 100644
--- a/Examples/test-suite/go/overload_copy_runme.go
+++ b/Examples/test-suite/go/overload_copy_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./overload_copy"
+import . "swigtests/overload_copy"
func main() {
f := NewFoo()
diff --git a/Examples/test-suite/go/overload_extend2_runme.go b/Examples/test-suite/go/overload_extend2_runme.go
index 121506734..d549098ba 100644
--- a/Examples/test-suite/go/overload_extend2_runme.go
+++ b/Examples/test-suite/go/overload_extend2_runme.go
@@ -1,6 +1,6 @@
package main
-import "./overload_extend2"
+import "swigtests/overload_extend2"
func main() {
f := overload_extend2.NewFoo()
diff --git a/Examples/test-suite/go/overload_extend_c_runme.go b/Examples/test-suite/go/overload_extend_c_runme.go
index e00f0b945..93b91d9e1 100644
--- a/Examples/test-suite/go/overload_extend_c_runme.go
+++ b/Examples/test-suite/go/overload_extend_c_runme.go
@@ -1,6 +1,6 @@
package main
-import "./overload_extend_c"
+import "swigtests/overload_extend_c"
func main() {
f := overload_extend_c.NewFoo()
diff --git a/Examples/test-suite/go/overload_extend_runme.go b/Examples/test-suite/go/overload_extend_runme.go
index 1ba541f13..c1435f376 100644
--- a/Examples/test-suite/go/overload_extend_runme.go
+++ b/Examples/test-suite/go/overload_extend_runme.go
@@ -1,6 +1,6 @@
package main
-import "./overload_extend"
+import "swigtests/overload_extend"
func main() {
f := overload_extend.NewFoo()
diff --git a/Examples/test-suite/go/overload_polymorphic_runme.go b/Examples/test-suite/go/overload_polymorphic_runme.go
index 46f837f49..6a4301f46 100644
--- a/Examples/test-suite/go/overload_polymorphic_runme.go
+++ b/Examples/test-suite/go/overload_polymorphic_runme.go
@@ -1,6 +1,6 @@
package main
-import "./overload_polymorphic"
+import "swigtests/overload_polymorphic"
func main(){
t := overload_polymorphic.NewDerived()
diff --git a/Examples/test-suite/go/overload_rename_runme.go b/Examples/test-suite/go/overload_rename_runme.go
index dca5843c3..982b1786a 100644
--- a/Examples/test-suite/go/overload_rename_runme.go
+++ b/Examples/test-suite/go/overload_rename_runme.go
@@ -1,6 +1,6 @@
package main
-import "./overload_rename"
+import "swigtests/overload_rename"
func main() {
_ = overload_rename.NewFoo(float32(1))
diff --git a/Examples/test-suite/go/overload_simple_runme.go b/Examples/test-suite/go/overload_simple_runme.go
index 5f6d0558b..23a80bf69 100644
--- a/Examples/test-suite/go/overload_simple_runme.go
+++ b/Examples/test-suite/go/overload_simple_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./overload_simple"
+import . "swigtests/overload_simple"
func main() {
if Foo(3) != "foo:int" {
diff --git a/Examples/test-suite/go/overload_subtype_runme.go b/Examples/test-suite/go/overload_subtype_runme.go
index dc56d1ca7..09f7a83f4 100644
--- a/Examples/test-suite/go/overload_subtype_runme.go
+++ b/Examples/test-suite/go/overload_subtype_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./overload_subtype"
+import . "swigtests/overload_subtype"
func main() {
f := NewFoo()
diff --git a/Examples/test-suite/go/overload_template_fast_runme.go b/Examples/test-suite/go/overload_template_fast_runme.go
index b80cb7dd4..3b348f366 100644
--- a/Examples/test-suite/go/overload_template_fast_runme.go
+++ b/Examples/test-suite/go/overload_template_fast_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./overload_template_fast"
+import . "swigtests/overload_template_fast"
func main() {
_ = Foo()
diff --git a/Examples/test-suite/go/overload_template_runme.go b/Examples/test-suite/go/overload_template_runme.go
index 53e1def1b..b85afb4d1 100644
--- a/Examples/test-suite/go/overload_template_runme.go
+++ b/Examples/test-suite/go/overload_template_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./overload_template"
+import . "swigtests/overload_template"
func main() {
_ = Foo()
diff --git a/Examples/test-suite/go/preproc_runme.go b/Examples/test-suite/go/preproc_runme.go
index a15062241..878305463 100644
--- a/Examples/test-suite/go/preproc_runme.go
+++ b/Examples/test-suite/go/preproc_runme.go
@@ -1,6 +1,6 @@
package main
-import "./preproc"
+import "swigtests/preproc"
func main() {
if preproc.GetEndif() != 1 {
diff --git a/Examples/test-suite/go/primitive_ref_runme.go b/Examples/test-suite/go/primitive_ref_runme.go
index 973806955..8dcf9f5a9 100644
--- a/Examples/test-suite/go/primitive_ref_runme.go
+++ b/Examples/test-suite/go/primitive_ref_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./primitive_ref"
+import . "swigtests/primitive_ref"
func main() {
if Ref_int(3) != 3 {
diff --git a/Examples/test-suite/go/profiletest_runme.go b/Examples/test-suite/go/profiletest_runme.go
index 30b6cee69..68509f550 100644
--- a/Examples/test-suite/go/profiletest_runme.go
+++ b/Examples/test-suite/go/profiletest_runme.go
@@ -1,7 +1,7 @@
package main
import "fmt"
-import "./profiletest"
+import "swigtests/profiletest"
func main() {
a := profiletest.NewA()
diff --git a/Examples/test-suite/go/refcount_runme.go b/Examples/test-suite/go/refcount_runme.go
index fdb271cc6..76e30dda3 100644
--- a/Examples/test-suite/go/refcount_runme.go
+++ b/Examples/test-suite/go/refcount_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./refcount"
+import . "swigtests/refcount"
// very innocent example
diff --git a/Examples/test-suite/go/reference_global_vars_runme.go b/Examples/test-suite/go/reference_global_vars_runme.go
index b8cbb304a..f8c125854 100644
--- a/Examples/test-suite/go/reference_global_vars_runme.go
+++ b/Examples/test-suite/go/reference_global_vars_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./reference_global_vars"
+import . "swigtests/reference_global_vars"
func main() {
// const class reference variable
diff --git a/Examples/test-suite/go/rename_scope_runme.go b/Examples/test-suite/go/rename_scope_runme.go
index 995f8c64d..4ad7549ad 100644
--- a/Examples/test-suite/go/rename_scope_runme.go
+++ b/Examples/test-suite/go/rename_scope_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./rename_scope"
+import . "swigtests/rename_scope"
func main() {
a := NewNatural_UP()
diff --git a/Examples/test-suite/go/rename_simple_runme.go b/Examples/test-suite/go/rename_simple_runme.go
index a63023bd1..efe1edc7b 100644
--- a/Examples/test-suite/go/rename_simple_runme.go
+++ b/Examples/test-suite/go/rename_simple_runme.go
@@ -1,7 +1,7 @@
package main
import "fmt"
-import . "./rename_simple"
+import . "swigtests/rename_simple"
func main() {
s := NewNewStruct()
diff --git a/Examples/test-suite/go/rename_strip_encoder_runme.go b/Examples/test-suite/go/rename_strip_encoder_runme.go
index 1d0bcb660..74a0dbaaf 100644
--- a/Examples/test-suite/go/rename_strip_encoder_runme.go
+++ b/Examples/test-suite/go/rename_strip_encoder_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./rename_strip_encoder"
+import . "swigtests/rename_strip_encoder"
func main() {
_ = NewSomeWidget()
diff --git a/Examples/test-suite/go/ret_by_value_runme.go b/Examples/test-suite/go/ret_by_value_runme.go
index 44743d2b7..345868dcd 100644
--- a/Examples/test-suite/go/ret_by_value_runme.go
+++ b/Examples/test-suite/go/ret_by_value_runme.go
@@ -1,6 +1,6 @@
package main
-import "./ret_by_value"
+import "swigtests/ret_by_value"
func main() {
a := ret_by_value.Get_test()
diff --git a/Examples/test-suite/go/return_const_value_runme.go b/Examples/test-suite/go/return_const_value_runme.go
index 790921b74..fc6baa240 100644
--- a/Examples/test-suite/go/return_const_value_runme.go
+++ b/Examples/test-suite/go/return_const_value_runme.go
@@ -1,6 +1,6 @@
package main
-import "./return_const_value"
+import "swigtests/return_const_value"
func main() {
p := return_const_value.Foo_ptrGetPtr()
diff --git a/Examples/test-suite/go/smart_pointer_extend_runme.go b/Examples/test-suite/go/smart_pointer_extend_runme.go
index ee5ce0538..f91c9ac99 100644
--- a/Examples/test-suite/go/smart_pointer_extend_runme.go
+++ b/Examples/test-suite/go/smart_pointer_extend_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./smart_pointer_extend"
+import . "swigtests/smart_pointer_extend"
func main() {
f := NewFoo()
diff --git a/Examples/test-suite/go/smart_pointer_member_runme.go b/Examples/test-suite/go/smart_pointer_member_runme.go
index bf09fe5fc..ca2ac2c76 100644
--- a/Examples/test-suite/go/smart_pointer_member_runme.go
+++ b/Examples/test-suite/go/smart_pointer_member_runme.go
@@ -1,7 +1,7 @@
package main
import "fmt"
-import . "./smart_pointer_member"
+import . "swigtests/smart_pointer_member"
func main() {
f := NewFoo()
diff --git a/Examples/test-suite/go/smart_pointer_multi_runme.go b/Examples/test-suite/go/smart_pointer_multi_runme.go
index d1a5f92f4..a8ec39f54 100644
--- a/Examples/test-suite/go/smart_pointer_multi_runme.go
+++ b/Examples/test-suite/go/smart_pointer_multi_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./smart_pointer_multi"
+import . "swigtests/smart_pointer_multi"
func main() {
f := NewFoo()
diff --git a/Examples/test-suite/go/smart_pointer_multi_typedef_runme.go b/Examples/test-suite/go/smart_pointer_multi_typedef_runme.go
index f71740bbb..6bfd21ef6 100644
--- a/Examples/test-suite/go/smart_pointer_multi_typedef_runme.go
+++ b/Examples/test-suite/go/smart_pointer_multi_typedef_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./smart_pointer_multi_typedef"
+import . "swigtests/smart_pointer_multi_typedef"
func main() {
f := NewFoo()
diff --git a/Examples/test-suite/go/smart_pointer_overload_runme.go b/Examples/test-suite/go/smart_pointer_overload_runme.go
index 5ffeae17c..c28ce6100 100644
--- a/Examples/test-suite/go/smart_pointer_overload_runme.go
+++ b/Examples/test-suite/go/smart_pointer_overload_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./smart_pointer_overload"
+import . "swigtests/smart_pointer_overload"
func main() {
f := NewFoo()
diff --git a/Examples/test-suite/go/smart_pointer_rename_runme.go b/Examples/test-suite/go/smart_pointer_rename_runme.go
index 678c305c8..22c0eb1e9 100644
--- a/Examples/test-suite/go/smart_pointer_rename_runme.go
+++ b/Examples/test-suite/go/smart_pointer_rename_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./smart_pointer_rename"
+import . "swigtests/smart_pointer_rename"
func main() {
f := NewFoo()
diff --git a/Examples/test-suite/go/smart_pointer_simple_runme.go b/Examples/test-suite/go/smart_pointer_simple_runme.go
index 328654225..8a14dcf9b 100644
--- a/Examples/test-suite/go/smart_pointer_simple_runme.go
+++ b/Examples/test-suite/go/smart_pointer_simple_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./smart_pointer_simple"
+import . "swigtests/smart_pointer_simple"
func main() {
f := NewFoo()
diff --git a/Examples/test-suite/go/smart_pointer_templatevariables_runme.go b/Examples/test-suite/go/smart_pointer_templatevariables_runme.go
index bf58ba52c..8f7102d43 100644
--- a/Examples/test-suite/go/smart_pointer_templatevariables_runme.go
+++ b/Examples/test-suite/go/smart_pointer_templatevariables_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./smart_pointer_templatevariables"
+import . "swigtests/smart_pointer_templatevariables"
func main() {
d := NewDiffImContainerPtr_D(Create(1234, 5678))
diff --git a/Examples/test-suite/go/smart_pointer_typedef_runme.go b/Examples/test-suite/go/smart_pointer_typedef_runme.go
index a67a0ccda..5468a2926 100644
--- a/Examples/test-suite/go/smart_pointer_typedef_runme.go
+++ b/Examples/test-suite/go/smart_pointer_typedef_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./smart_pointer_typedef"
+import . "swigtests/smart_pointer_typedef"
func main() {
f := NewFoo()
diff --git a/Examples/test-suite/go/sneaky1_runme.go b/Examples/test-suite/go/sneaky1_runme.go
index ee38ae21b..c17f0ffc6 100644
--- a/Examples/test-suite/go/sneaky1_runme.go
+++ b/Examples/test-suite/go/sneaky1_runme.go
@@ -1,6 +1,6 @@
package main
-import "./sneaky1"
+import "swigtests/sneaky1"
func main() {
_ = sneaky1.Add(3, 4)
diff --git a/Examples/test-suite/go/special_variable_macros_runme.go b/Examples/test-suite/go/special_variable_macros_runme.go
index c4f687ea9..597c48748 100644
--- a/Examples/test-suite/go/special_variable_macros_runme.go
+++ b/Examples/test-suite/go/special_variable_macros_runme.go
@@ -1,6 +1,6 @@
package main
-import "./special_variable_macros"
+import "swigtests/special_variable_macros"
func main() {
name := special_variable_macros.NewName()
diff --git a/Examples/test-suite/go/static_const_member_2_runme.go b/Examples/test-suite/go/static_const_member_2_runme.go
index 0d345c3d6..7586eb404 100644
--- a/Examples/test-suite/go/static_const_member_2_runme.go
+++ b/Examples/test-suite/go/static_const_member_2_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./static_const_member_2"
+import . "swigtests/static_const_member_2"
func main() {
_ = NewTest_int()
diff --git a/Examples/test-suite/go/struct_initialization_runme.go b/Examples/test-suite/go/struct_initialization_runme.go
index 58ac25010..d5eb4e968 100644
--- a/Examples/test-suite/go/struct_initialization_runme.go
+++ b/Examples/test-suite/go/struct_initialization_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./struct_initialization"
+import . "swigtests/struct_initialization"
func main() {
if GetInstanceC1().GetX() != 10 {
diff --git a/Examples/test-suite/go/struct_rename_runme.go b/Examples/test-suite/go/struct_rename_runme.go
index 845dac5be..6d619e090 100644
--- a/Examples/test-suite/go/struct_rename_runme.go
+++ b/Examples/test-suite/go/struct_rename_runme.go
@@ -1,6 +1,6 @@
package main
-import "./struct_rename"
+import "swigtests/struct_rename"
func main() {
_ = struct_rename.NewBar()
diff --git a/Examples/test-suite/go/struct_value_runme.go b/Examples/test-suite/go/struct_value_runme.go
index d0b60bd23..c43a67a88 100644
--- a/Examples/test-suite/go/struct_value_runme.go
+++ b/Examples/test-suite/go/struct_value_runme.go
@@ -1,6 +1,6 @@
package main
-import "./struct_value"
+import "swigtests/struct_value"
func main() {
b := struct_value.NewBar()
diff --git a/Examples/test-suite/go/template_default_arg_runme.go b/Examples/test-suite/go/template_default_arg_runme.go
index 3d9346b05..9558c7496 100644
--- a/Examples/test-suite/go/template_default_arg_runme.go
+++ b/Examples/test-suite/go/template_default_arg_runme.go
@@ -1,6 +1,6 @@
package main
-import "./template_default_arg"
+import "swigtests/template_default_arg"
func main() {
helloInt := template_default_arg.NewHello_int()
diff --git a/Examples/test-suite/go/template_extend1_runme.go b/Examples/test-suite/go/template_extend1_runme.go
index 5d6d376f5..f2469ab15 100644
--- a/Examples/test-suite/go/template_extend1_runme.go
+++ b/Examples/test-suite/go/template_extend1_runme.go
@@ -1,6 +1,6 @@
package main
-import "./template_extend1"
+import "swigtests/template_extend1"
func main() {
a := template_extend1.NewLBaz()
diff --git a/Examples/test-suite/go/template_extend2_runme.go b/Examples/test-suite/go/template_extend2_runme.go
index 312410e27..c3669bc95 100644
--- a/Examples/test-suite/go/template_extend2_runme.go
+++ b/Examples/test-suite/go/template_extend2_runme.go
@@ -1,6 +1,6 @@
package main
-import "./template_extend2"
+import "swigtests/template_extend2"
func main() {
a := template_extend2.NewLBaz()
diff --git a/Examples/test-suite/go/template_inherit_runme.go b/Examples/test-suite/go/template_inherit_runme.go
index c0aca77c4..10071b128 100644
--- a/Examples/test-suite/go/template_inherit_runme.go
+++ b/Examples/test-suite/go/template_inherit_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./template_inherit"
+import . "swigtests/template_inherit"
func main() {
a := NewFooInt()
diff --git a/Examples/test-suite/go/template_ns4_runme.go b/Examples/test-suite/go/template_ns4_runme.go
index 4caf8f587..c1b356b3f 100644
--- a/Examples/test-suite/go/template_ns4_runme.go
+++ b/Examples/test-suite/go/template_ns4_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./template_ns4"
+import . "swigtests/template_ns4"
func main() {
d := Make_Class_DD()
diff --git a/Examples/test-suite/go/template_ns_runme.go b/Examples/test-suite/go/template_ns_runme.go
index 6385eccf9..e77c17bf7 100644
--- a/Examples/test-suite/go/template_ns_runme.go
+++ b/Examples/test-suite/go/template_ns_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./template_ns"
+import . "swigtests/template_ns"
func main() {
p1 := NewPairii(2, 3)
diff --git a/Examples/test-suite/go/template_opaque_runme.go b/Examples/test-suite/go/template_opaque_runme.go
index 201f7ba16..b3bf61043 100644
--- a/Examples/test-suite/go/template_opaque_runme.go
+++ b/Examples/test-suite/go/template_opaque_runme.go
@@ -1,6 +1,6 @@
package main
-import "./template_opaque"
+import "swigtests/template_opaque"
func main() {
v := template_opaque.NewOpaqueVectorType(int64(10))
diff --git a/Examples/test-suite/go/template_ref_type_runme.go b/Examples/test-suite/go/template_ref_type_runme.go
index e4bf626fb..516b6c721 100644
--- a/Examples/test-suite/go/template_ref_type_runme.go
+++ b/Examples/test-suite/go/template_ref_type_runme.go
@@ -1,6 +1,6 @@
package main
-import "./template_ref_type"
+import "swigtests/template_ref_type"
func main() {
xr := template_ref_type.NewXC()
diff --git a/Examples/test-suite/go/template_rename_runme.go b/Examples/test-suite/go/template_rename_runme.go
index 757ac7355..08cf3fb48 100644
--- a/Examples/test-suite/go/template_rename_runme.go
+++ b/Examples/test-suite/go/template_rename_runme.go
@@ -1,6 +1,6 @@
package main
-import "./template_rename"
+import "swigtests/template_rename"
func main() {
i := template_rename.NewIFoo()
diff --git a/Examples/test-suite/go/template_static_runme.go b/Examples/test-suite/go/template_static_runme.go
index 7fa50760a..205813dbf 100644
--- a/Examples/test-suite/go/template_static_runme.go
+++ b/Examples/test-suite/go/template_static_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./template_static"
+import . "swigtests/template_static"
func main() {
FooBar_double(1)
diff --git a/Examples/test-suite/go/template_tbase_template_runme.go b/Examples/test-suite/go/template_tbase_template_runme.go
index 9a52e2fac..a4832439f 100644
--- a/Examples/test-suite/go/template_tbase_template_runme.go
+++ b/Examples/test-suite/go/template_tbase_template_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./template_tbase_template"
+import . "swigtests/template_tbase_template"
func main() {
a := Make_Class_dd()
diff --git a/Examples/test-suite/go/template_type_namespace_runme.go b/Examples/test-suite/go/template_type_namespace_runme.go
index a3712ff59..562fae78d 100644
--- a/Examples/test-suite/go/template_type_namespace_runme.go
+++ b/Examples/test-suite/go/template_type_namespace_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./template_type_namespace"
+import . "swigtests/template_type_namespace"
func main() {
if Foo().Get(0) == "" {
diff --git a/Examples/test-suite/go/template_typedef_cplx3_runme.go b/Examples/test-suite/go/template_typedef_cplx3_runme.go
index d616777e0..52a9bc7f6 100644
--- a/Examples/test-suite/go/template_typedef_cplx3_runme.go
+++ b/Examples/test-suite/go/template_typedef_cplx3_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./template_typedef_cplx3"
+import . "swigtests/template_typedef_cplx3"
func main() {
// this is OK
diff --git a/Examples/test-suite/go/template_typedef_cplx4_runme.go b/Examples/test-suite/go/template_typedef_cplx4_runme.go
index 3e536d6f2..84347e404 100644
--- a/Examples/test-suite/go/template_typedef_cplx4_runme.go
+++ b/Examples/test-suite/go/template_typedef_cplx4_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./template_typedef_cplx4"
+import . "swigtests/template_typedef_cplx4"
func main() {
// this is OK
diff --git a/Examples/test-suite/go/threads_exception_runme.go b/Examples/test-suite/go/threads_exception_runme.go
index 742a827bd..b554f0e28 100644
--- a/Examples/test-suite/go/threads_exception_runme.go
+++ b/Examples/test-suite/go/threads_exception_runme.go
@@ -1,7 +1,7 @@
package main
import "strings"
-import "./threads_exception"
+import "swigtests/threads_exception"
func main() {
t := threads_exception.NewTest()
diff --git a/Examples/test-suite/go/typedef_class_runme.go b/Examples/test-suite/go/typedef_class_runme.go
index ec25162de..157a91745 100644
--- a/Examples/test-suite/go/typedef_class_runme.go
+++ b/Examples/test-suite/go/typedef_class_runme.go
@@ -1,6 +1,6 @@
package main
-import "./typedef_class"
+import "swigtests/typedef_class"
func main() {
a := typedef_class.NewRealA()
diff --git a/Examples/test-suite/go/typedef_funcptr_runme.go b/Examples/test-suite/go/typedef_funcptr_runme.go
new file mode 100644
index 000000000..f76f088af
--- /dev/null
+++ b/Examples/test-suite/go/typedef_funcptr_runme.go
@@ -0,0 +1,29 @@
+package main
+
+import . "swigtests/typedef_funcptr"
+
+func main() {
+ a := 100
+ b := 10
+
+ if Do_op(a,b,Addf) != 110 {
+ panic(0)
+ }
+ if Do_op(a,b,Subf) != 90 {
+ panic(0)
+ }
+
+ if Do_op_typedef_int(a,b,Addf) != 110 {
+ panic(0)
+ }
+ if Do_op_typedef_int(a,b,Subf) != 90 {
+ panic(0)
+ }
+
+ if Do_op_typedef_Integer(a,b,Addf) != 110 {
+ panic(0)
+ }
+ if Do_op_typedef_Integer(a,b,Subf) != 90 {
+ panic(0)
+ }
+}
diff --git a/Examples/test-suite/go/typedef_inherit_runme.go b/Examples/test-suite/go/typedef_inherit_runme.go
index 49097999c..f2dbb3263 100644
--- a/Examples/test-suite/go/typedef_inherit_runme.go
+++ b/Examples/test-suite/go/typedef_inherit_runme.go
@@ -1,6 +1,6 @@
package main
-import "./typedef_inherit"
+import "swigtests/typedef_inherit"
func main() {
a := typedef_inherit.NewFoo()
diff --git a/Examples/test-suite/go/typedef_scope_runme.go b/Examples/test-suite/go/typedef_scope_runme.go
index 1c4314427..9c845bb69 100644
--- a/Examples/test-suite/go/typedef_scope_runme.go
+++ b/Examples/test-suite/go/typedef_scope_runme.go
@@ -1,6 +1,6 @@
package main
-import "./typedef_scope"
+import "swigtests/typedef_scope"
func main() {
b := typedef_scope.NewBar()
diff --git a/Examples/test-suite/go/typemap_namespace_runme.go b/Examples/test-suite/go/typemap_namespace_runme.go
index 45184fd1e..f0860803e 100644
--- a/Examples/test-suite/go/typemap_namespace_runme.go
+++ b/Examples/test-suite/go/typemap_namespace_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./typemap_namespace"
+import . "swigtests/typemap_namespace"
func main() {
if Test1("hello") != "hello" {
diff --git a/Examples/test-suite/go/typemap_ns_using_runme.go b/Examples/test-suite/go/typemap_ns_using_runme.go
index 877e44b3a..00e1131d6 100644
--- a/Examples/test-suite/go/typemap_ns_using_runme.go
+++ b/Examples/test-suite/go/typemap_ns_using_runme.go
@@ -1,6 +1,6 @@
package main
-import "./typemap_ns_using"
+import "swigtests/typemap_ns_using"
func main() {
if typemap_ns_using.Spam(37) != 37 {
diff --git a/Examples/test-suite/go/typemap_out_optimal_runme.go b/Examples/test-suite/go/typemap_out_optimal_runme.go
index 7cbd0ad9b..0cccd97a6 100644
--- a/Examples/test-suite/go/typemap_out_optimal_runme.go
+++ b/Examples/test-suite/go/typemap_out_optimal_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./typemap_out_optimal"
+import . "swigtests/typemap_out_optimal"
func main() {
SetXXDebug(false)
diff --git a/Examples/test-suite/go/typename_runme.go b/Examples/test-suite/go/typename_runme.go
index 0bc15f11a..1e1696d0a 100644
--- a/Examples/test-suite/go/typename_runme.go
+++ b/Examples/test-suite/go/typename_runme.go
@@ -1,6 +1,6 @@
package main
-import "./typename"
+import "swigtests/typename"
func main() {
f := typename.NewFoo()
diff --git a/Examples/test-suite/go/unions_runme.go b/Examples/test-suite/go/unions_runme.go
index ba9c27b17..6e2981192 100644
--- a/Examples/test-suite/go/unions_runme.go
+++ b/Examples/test-suite/go/unions_runme.go
@@ -3,7 +3,7 @@
package main
-import "./unions"
+import "swigtests/unions"
func main() {
// Create new instances of SmallStruct and BigStruct for later use
diff --git a/Examples/test-suite/go/using1_runme.go b/Examples/test-suite/go/using1_runme.go
index 8cc571288..09cc381cc 100644
--- a/Examples/test-suite/go/using1_runme.go
+++ b/Examples/test-suite/go/using1_runme.go
@@ -1,6 +1,6 @@
package main
-import "./using1"
+import "swigtests/using1"
func main() {
if using1.Spam(37) != 37 {
diff --git a/Examples/test-suite/go/using2_runme.go b/Examples/test-suite/go/using2_runme.go
index f679b0c40..8109037f9 100644
--- a/Examples/test-suite/go/using2_runme.go
+++ b/Examples/test-suite/go/using2_runme.go
@@ -1,6 +1,6 @@
package main
-import "./using2"
+import "swigtests/using2"
func main() {
if using2.Spam(37) != 37 {
diff --git a/Examples/test-suite/go/using_composition_runme.go b/Examples/test-suite/go/using_composition_runme.go
index 47e245719..7ef09fef9 100644
--- a/Examples/test-suite/go/using_composition_runme.go
+++ b/Examples/test-suite/go/using_composition_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./using_composition"
+import . "swigtests/using_composition"
func main() {
f := NewFooBar()
diff --git a/Examples/test-suite/go/using_extend_runme.go b/Examples/test-suite/go/using_extend_runme.go
index 830c958e5..dac300ba4 100644
--- a/Examples/test-suite/go/using_extend_runme.go
+++ b/Examples/test-suite/go/using_extend_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./using_extend"
+import . "swigtests/using_extend"
func main() {
f := NewFooBar()
diff --git a/Examples/test-suite/go/using_inherit_runme.go b/Examples/test-suite/go/using_inherit_runme.go
index db29efb64..c8755902f 100644
--- a/Examples/test-suite/go/using_inherit_runme.go
+++ b/Examples/test-suite/go/using_inherit_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./using_inherit"
+import . "swigtests/using_inherit"
func main() {
b := NewBar()
diff --git a/Examples/test-suite/go/using_private_runme.go b/Examples/test-suite/go/using_private_runme.go
index d683ef856..4c86ef514 100644
--- a/Examples/test-suite/go/using_private_runme.go
+++ b/Examples/test-suite/go/using_private_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./using_private"
+import . "swigtests/using_private"
func main() {
f := NewFooBar()
diff --git a/Examples/test-suite/go/using_protected_runme.go b/Examples/test-suite/go/using_protected_runme.go
index 65edb5001..431081827 100644
--- a/Examples/test-suite/go/using_protected_runme.go
+++ b/Examples/test-suite/go/using_protected_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./using_protected"
+import . "swigtests/using_protected"
func main() {
f := NewFooBar()
diff --git a/Examples/test-suite/go/varargs_overload_runme.go b/Examples/test-suite/go/varargs_overload_runme.go
index 52fc1b0e9..50a430894 100644
--- a/Examples/test-suite/go/varargs_overload_runme.go
+++ b/Examples/test-suite/go/varargs_overload_runme.go
@@ -1,6 +1,6 @@
package main
-import "./varargs_overload"
+import "swigtests/varargs_overload"
func main() {
if varargs_overload.Vararg_over1("Hello") != "Hello" {
@@ -35,4 +35,40 @@ func main() {
if varargs_overload.Vararg_over4("Hello", 123) != "Hello" {
panic(8)
}
+
+
+ // Same as above but non-vararg function declared first
+
+ if varargs_overload.Vararg_over6("Hello") != "Hello" {
+ panic(0)
+ }
+ if varargs_overload.Vararg_over6(2) != "2" {
+ panic(1)
+ }
+
+ if varargs_overload.Vararg_over7("Hello") != "Hello" {
+ panic(2)
+ }
+ if varargs_overload.Vararg_over7(2, 2.2) != "2 2.2" {
+ panic(3)
+ }
+
+ if varargs_overload.Vararg_over8("Hello") != "Hello" {
+ panic(4)
+ }
+ if varargs_overload.Vararg_over8(2, 2.2, "hey") != "2 2.2 hey" {
+ panic(5)
+ }
+
+ if varargs_overload.Vararg_over9("Hello") != "Hello" {
+ panic(6)
+ }
+
+ if varargs_overload.Vararg_over9(123) != "123" {
+ panic(7)
+ }
+
+ if varargs_overload.Vararg_over9("Hello", 123) != "Hello" {
+ panic(8)
+ }
}
diff --git a/Examples/test-suite/go/varargs_runme.go b/Examples/test-suite/go/varargs_runme.go
index 4009c3ed3..eb2fa94aa 100644
--- a/Examples/test-suite/go/varargs_runme.go
+++ b/Examples/test-suite/go/varargs_runme.go
@@ -1,6 +1,6 @@
package main
-import "./varargs"
+import "swigtests/varargs"
func main() {
if varargs.Test("Hello") != "Hello" {
diff --git a/Examples/test-suite/go/virtual_derivation_runme.go b/Examples/test-suite/go/virtual_derivation_runme.go
index 48a7033a2..21135308c 100644
--- a/Examples/test-suite/go/virtual_derivation_runme.go
+++ b/Examples/test-suite/go/virtual_derivation_runme.go
@@ -1,6 +1,6 @@
package main
-import . "./virtual_derivation"
+import . "swigtests/virtual_derivation"
// very innocent example
diff --git a/Examples/test-suite/go/virtual_poly_runme.go b/Examples/test-suite/go/virtual_poly_runme.go
index 487b371ba..9973f24c7 100644
--- a/Examples/test-suite/go/virtual_poly_runme.go
+++ b/Examples/test-suite/go/virtual_poly_runme.go
@@ -1,6 +1,6 @@
package main
-import "./virtual_poly"
+import "swigtests/virtual_poly"
func main() {
d := virtual_poly.NewNDouble(3.5)
diff --git a/Examples/test-suite/go/voidtest_runme.go b/Examples/test-suite/go/voidtest_runme.go
index 0a685f081..35c5289fd 100644
--- a/Examples/test-suite/go/voidtest_runme.go
+++ b/Examples/test-suite/go/voidtest_runme.go
@@ -1,6 +1,6 @@
package main
-import "./voidtest"
+import "swigtests/voidtest"
func main() {
voidtest.Globalfunc()
diff --git a/Examples/test-suite/go/wrapmacro_runme.go b/Examples/test-suite/go/wrapmacro_runme.go
index dc7e7bf5b..d792d4ffe 100644
--- a/Examples/test-suite/go/wrapmacro_runme.go
+++ b/Examples/test-suite/go/wrapmacro_runme.go
@@ -1,6 +1,6 @@
package main
-import "./wrapmacro"
+import "swigtests/wrapmacro"
func main() {
a := 2
diff --git a/Examples/test-suite/go_subdir_import.list b/Examples/test-suite/go_subdir_import.list
index e117d32fa..074c795b3 100644
--- a/Examples/test-suite/go_subdir_import.list
+++ b/Examples/test-suite/go_subdir_import.list
@@ -1,3 +1,3 @@
testdir/go_subdir_import/go_subdir_import_c
-go_subdir_import_b
+testdir/go_subdir_import/go_subdir_import_b
go_subdir_import_a
diff --git a/Examples/test-suite/guile/argout_runme.scm b/Examples/test-suite/guile/argout_runme.scm
index 8bbb96cc9..16f2aeb1c 100644
--- a/Examples/test-suite/guile/argout_runme.scm
+++ b/Examples/test-suite/guile/argout_runme.scm
@@ -2,15 +2,19 @@
;; https://www.gnu.org/software/guile/manual/html_node/Void-Pointers-and-Byte-Access.html
(dynamic-call "scm_init_argout_module" (dynamic-link "./libargout"))
-(use-modules (srfi srfi-4) (system foreign))
-
(define initial-value 42)
(define some-s32-data (s32vector initial-value))
-(if (not (= (incp (bytevector->pointer some-s32-data)) initial-value))
- (error "Didn't read s32 data" initial-value some-s32-data))
+;; if we're running guile 1.8, then bytevector->pointer won't exist and this
+;; test is useless
+(if (>= (string->number (major-version)) 2)
+ (begin
+ (use-modules (srfi srfi-4) (system foreign))
+
+ (if (not (= (incp (bytevector->pointer some-s32-data)) initial-value))
+ (error "Didn't read s32 data" initial-value some-s32-data))
-(if (not (= (s32vector-ref some-s32-data 0) (+ initial-value 1)))
- (error "Failed to increment s32 data" some-s32-data))
+ (if (not (= (s32vector-ref some-s32-data 0) (+ initial-value 1)))
+ (error "Failed to increment s32 data" some-s32-data))))
(exit 0)
diff --git a/Examples/test-suite/guile/overload_complicated_runme.scm b/Examples/test-suite/guile/overload_complicated_runme.scm
index a38fb8afe..0630d4ecc 100644
--- a/Examples/test-suite/guile/overload_complicated_runme.scm
+++ b/Examples/test-suite/guile/overload_complicated_runme.scm
@@ -14,8 +14,8 @@
(check (=~ (foo 1 2 "bar" 4) 15))
;; Check second method
-(check (=~ (foo 1 2) 4811.4))
-(check (=~ (foo 1 2 3.2) 4797.2))
-(check (=~ (foo 1 2 3.2 #\Q) 4798.2))
+(check (=~ (foo 1 2) 118))
+(check (=~ (foo 1 2 3.2) 104))
+(check (=~ (foo 1 2 3.2 #\Q) 4798))
(exit 0)
diff --git a/Examples/test-suite/guile/overload_null_runme.scm b/Examples/test-suite/guile/overload_null_runme.scm
new file mode 100644
index 000000000..f764d9c20
--- /dev/null
+++ b/Examples/test-suite/guile/overload_null_runme.scm
@@ -0,0 +1,53 @@
+;; The SWIG modules have "passive" Linkage, i.e., they don't generate
+;; Guile modules (namespaces) but simply put all the bindings into the
+;; current module. That's enough for such a simple test.
+(dynamic-call "scm_init_overload_null_module" (dynamic-link "./liboverload_null"))
+
+(define-macro (check form)
+ `(if (not ,form)
+ (error "Check failed: " ',form)))
+
+(define (=~ a b)
+ (< (abs (- a b)) 1e-8))
+
+(define o (new-Overload))
+(define x (new-X))
+
+(check (=~ 1 (Overload-byval1 o x)))
+(check (=~ 2 (Overload-byval1 o #nil)))
+
+(check (=~ 3 (Overload-byval2 o #nil)))
+(check (=~ 4 (Overload-byval2 o x)))
+
+(check (=~ 5 (Overload-byref1 o x)))
+(check (=~ 6 (Overload-byref1 o #nil)))
+
+(check (=~ 7 (Overload-byref2 o #nil)))
+(check (=~ 8 (Overload-byref2 o x)))
+
+(check (=~ 9 (Overload-byconstref1 o x)))
+(check (=~ 10 (Overload-byconstref1 o #nil)))
+
+(check (=~ 11 (Overload-byconstref2 o #nil)))
+(check (=~ 12 (Overload-byconstref2 o x)))
+
+; const pointer references
+; No SWIGTYPE *const& typemaps for Guile yet
+;(check (=~ 13 (Overload-byval1cpr o x)))
+;(check (=~ 14 (Overload-byval1cpr o #nil)))
+
+;(check (=~ 15 (Overload-byval2cpr o #nil)))
+;(check (=~ 16 (Overload-byval2cpr o x)))
+
+; forward class declaration
+(check (=~ 17 (Overload-byval1forwardptr o x)))
+(check (=~ 18 (Overload-byval1forwardptr o #nil)))
+
+(check (=~ 19 (Overload-byval2forwardptr o #nil)))
+(check (=~ 20 (Overload-byval2forwardptr o x)))
+
+(check (=~ 21 (Overload-byval1forwardref o x)))
+
+(check (=~ 22 (Overload-byval2forwardref o x)))
+
+(exit 0)
diff --git a/Examples/test-suite/ignore_parameter.i b/Examples/test-suite/ignore_parameter.i
index bc0892c3a..604ee3b84 100644
--- a/Examples/test-suite/ignore_parameter.i
+++ b/Examples/test-suite/ignore_parameter.i
@@ -8,12 +8,15 @@
%typemap(freearg) char* a ""; // ensure freearg is not generated (needed for Java at least)
+%ignore unignorable;
+
%inline %{
// global function tests
char* jaguar(char* a, int b, double c) { return a; }
int lotus(char* aa, int bb, double cc) { return bb; }
double tvr(char* aaa, int bbb, double ccc) { return ccc; }
int ferrari(int bb) { return bb; }
+int fiat(int unignorable) { return unignorable; }
// member function tests
struct SportsCars {
@@ -21,6 +24,7 @@ struct SportsCars {
int astonmartin(char* aa, int bb, double cc) { return bb; }
double bugatti(char* aaa, int bbb, double ccc) { return ccc; }
int lamborghini(int bb) { return bb; }
+ int maseratti(int unignorable) { return unignorable; }
};
// constructor tests
diff --git a/Examples/test-suite/ignore_template_constructor.i b/Examples/test-suite/ignore_template_constructor.i
index 31a5505fb..bdffbec3e 100644
--- a/Examples/test-suite/ignore_template_constructor.i
+++ b/Examples/test-suite/ignore_template_constructor.i
@@ -1,12 +1,18 @@
%module ignore_template_constructor
%include std_vector.i
-#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGPERL) || defined(SWIGRUBY)
+#if defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGPERL) || defined(SWIGRUBY)
#define SWIG_GOOD_VECTOR
%ignore std::vector<Flow>::vector(size_type);
%ignore std::vector<Flow>::resize(size_type);
#endif
+#if defined(SWIGJAVA)
+#define SWIG_GOOD_VECTOR
+%ignore std::vector<Flow>::vector(jint);
+%ignore std::vector<Flow>::resize(jint);
+#endif
+
#if defined(SWIGTCL) || defined(SWIGPERL)
#define SWIG_GOOD_VECTOR
/* here, for languages with bad declaration */
diff --git a/Examples/test-suite/import_fragments.i b/Examples/test-suite/import_fragments.i
new file mode 100644
index 000000000..26b87cdb2
--- /dev/null
+++ b/Examples/test-suite/import_fragments.i
@@ -0,0 +1,18 @@
+%module import_fragments
+
+// Check %fragments forced inclusion does not result in code generation when using %import
+%import "import_fragments_a.i"
+
+%{
+template<typename T>
+struct TemplateA4 {};
+%}
+
+%template(TemplateA4Int) TemplateA4<int>;
+
+%inline %{
+int getImport4() {
+ // Requires the ImportA4 fragment to be generated in order to compile
+ return ImportA4;
+}
+%}
diff --git a/Examples/test-suite/import_fragments_a.i b/Examples/test-suite/import_fragments_a.i
new file mode 100644
index 000000000..1babea95f
--- /dev/null
+++ b/Examples/test-suite/import_fragments_a.i
@@ -0,0 +1,48 @@
+#if !defined(SWIGGO)
+// Prevent Go from generating a Go module import - this test is not set up as true multiple modules
+%module import_fragments_a
+#endif
+
+%fragment("ImportA1", "header") %{
+ImportA1_this_will_not_compile;
+%}
+%fragment("ImportA2", "header") %{
+ImportA2_this_will_not_compile;
+%}
+%fragment("ImportA3", "header") %{
+ImportA3_this_will_not_compile;
+%}
+%fragment("ImportA4", "header") %{
+static int ImportA4 = 99;
+%}
+%fragment("ImportA5", "header") %{
+ImportA5_this_will_not_compile;
+%}
+
+%fragment("ImportA1");
+
+%{
+Import_will_not_compile;
+%}
+
+struct StructA {
+ %fragment("ImportA2");
+};
+
+template<typename T>
+struct TemplateA3 {
+ %fragment("ImportA3");
+};
+
+template<typename T>
+struct TemplateA4 {
+ %fragment("ImportA4");
+};
+
+template<typename T>
+struct TemplateA5 {
+ %fragment("ImportA5");
+};
+%template(TemplateA5Double) TemplateA5<double>;
+
+%include "import_fragments_b.i"
diff --git a/Examples/test-suite/import_fragments_b.i b/Examples/test-suite/import_fragments_b.i
new file mode 100644
index 000000000..615db4796
--- /dev/null
+++ b/Examples/test-suite/import_fragments_b.i
@@ -0,0 +1,9 @@
+%module import_fragments_b
+
+%fragment("ImportB", "header") %{
+ImportB_this_will_not_compile;
+%}
+
+%fragment("ImportB");
+
+
diff --git a/Examples/test-suite/imports_a.h b/Examples/test-suite/imports_a.h
index f761ea38c..f441d340b 100644
--- a/Examples/test-suite/imports_a.h
+++ b/Examples/test-suite/imports_a.h
@@ -18,4 +18,12 @@ class A {
virtual MemberEnum member_virtual_test(MemberEnum e) { return e; }
virtual GlobalEnum global_virtual_test(GlobalEnum e) { return global_test(e); }
};
+
+/* This class overrides nothing. Inherited classes should see base functions.
+*/
+class A_Intermediate : public A {
+ public:
+ A_Intermediate(){}
+ ~A_Intermediate(){}
+};
#endif
diff --git a/Examples/test-suite/imports_b.h b/Examples/test-suite/imports_b.h
index f50cee576..328dac273 100644
--- a/Examples/test-suite/imports_b.h
+++ b/Examples/test-suite/imports_b.h
@@ -1,6 +1,6 @@
#include "imports_a.h"
-class B : public A
+class B : public A_Intermediate
{
public:
B() {};
diff --git a/Examples/test-suite/insert_directive.h b/Examples/test-suite/insert_directive.h
new file mode 100644
index 000000000..2187ff5b3
--- /dev/null
+++ b/Examples/test-suite/insert_directive.h
@@ -0,0 +1,2 @@
+// %inserted code %header from file
+int inserted_header4(int i) { return inserted_header3(i); }
diff --git a/Examples/test-suite/insert_directive.i b/Examples/test-suite/insert_directive.i
index 36c3af6c6..3cff40bbf 100644
--- a/Examples/test-suite/insert_directive.i
+++ b/Examples/test-suite/insert_directive.i
@@ -27,9 +27,11 @@ int inserted_header2(int i) { return inserted_header1(i); }
int inserted_header3(int i) { return inserted_header2(i); }
%}
+%header "insert_directive.h"
+
%wrapper %{
// %inserted code %wrapper
-int inserted_wrapper(int i) { return inserted_header3(i); }
+int inserted_wrapper(int i) { return inserted_header4(i); }
%}
%init %{
diff --git a/Examples/test-suite/intermediary_classname.i b/Examples/test-suite/intermediary_classname.i
index 94858a5fb..585967ad4 100644
--- a/Examples/test-suite/intermediary_classname.i
+++ b/Examples/test-suite/intermediary_classname.i
@@ -4,6 +4,12 @@
%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR);
+// throw is invalid in C++17 and later, only SWIG to use it
+#define TESTCASE_THROW2(T1, T2) throw(T1, T2)
+%{
+#define TESTCASE_THROW2(T1, T2)
+%}
+
// change the access to the intermediary class for testing purposes
%pragma(java) jniclassclassmodifiers="public class";
%pragma(csharp) imclassclassmodifiers="public class";
@@ -41,10 +47,6 @@ template<class T> class vector {
void testconst(const T x) { }
};
-#if defined(_MSC_VER)
- #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
-
class Base {
public:
Base() : mVectInt(0) {}
@@ -65,11 +67,8 @@ public:
virtual Base& m1(Base &b) { return b; }
virtual Base* m2(Base *b) { return b; }
// virtual Base m3(Base b) { return b; }
- void throwspec() throw (int, Base) {}
+ void throwspec() TESTCASE_THROW2(int, Base) {}
};
-#if defined(_MSC_VER)
- #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
%}
%template(maxint) maximum<int>;
diff --git a/Examples/test-suite/java/CommentParser.java b/Examples/test-suite/java/CommentParser.java
new file mode 100644
index 000000000..1fc6f646a
--- /dev/null
+++ b/Examples/test-suite/java/CommentParser.java
@@ -0,0 +1,257 @@
+
+import com.sun.source.doctree.*;
+import com.sun.source.util.DocTrees;
+import java.util.HashMap;
+import java.util.Map.Entry;
+import java.util.Map;
+import java.util.Set;
+import java.util.Iterator;
+import java.io.BufferedWriter;
+import java.io.OutputStreamWriter;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.*;
+import java.util.spi.ToolProvider;
+import javax.lang.model.*;
+import javax.lang.model.element.*;
+import javax.lang.model.util.*;
+import jdk.javadoc.doclet.*;
+
+
+public class CommentParser implements Doclet {
+ private static Map<String, String> m_parsedComments = new HashMap<String, String>();
+
+ // We need to implement these base class pure virtual methods.
+
+ @Override
+ public void init(Locale locale, Reporter reporter) {
+ }
+
+ @Override
+ public Set<? extends Option> getSupportedOptions() {
+ return new HashSet<>();
+ }
+
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.latest();
+ }
+
+ @Override
+ public String getName() {
+ return "CommentParser";
+ }
+
+ // Element name must be the fully qualified name of the element.
+ //
+ // If there is no comment associated with this element, simply do nothing.
+ private void storeCommentFor(DocTrees docTrees, String fullName, Element e) {
+ DocCommentTree docCommentTree = docTrees.getDocCommentTree(e);
+ if (docCommentTree == null)
+ return;
+
+ StringBuilder name = new StringBuilder(fullName);
+
+ // We must use signature in the key for methods for compatibility with
+ // the existing tests and to allow distinguishing between overloaded
+ // methods.
+ if (e instanceof ExecutableElement) {
+ ExecutableElement ex = (ExecutableElement)e;
+ name.append("(");
+
+ boolean firstParam = true;
+ for (VariableElement p : ex.getParameters()) {
+ if (firstParam) {
+ firstParam = false;
+ } else {
+ name.append(", ");
+ }
+
+ name.append(p.asType().toString());
+ }
+
+ name.append(")");
+ }
+
+ // For some reason the comment in the source is split into "body" and
+ // "block tags" parts, so we need to concatenate them back together.
+ StringBuilder comment = new StringBuilder();
+ for (DocTree d : docCommentTree.getFullBody()) {
+ comment.append(d.toString());
+ comment.append("\n");
+ }
+
+ boolean firstBlockTag = true;
+ for (DocTree d : docCommentTree.getBlockTags()) {
+ if (firstBlockTag) {
+ firstBlockTag = false;
+ comment.append("\n");
+ }
+
+ comment.append(d.toString());
+ comment.append("\n");
+ }
+
+ m_parsedComments.put(name.toString(), comment.toString());
+ }
+
+ @Override
+ public boolean run(DocletEnvironment docEnv) {
+ /*
+ * This method is called by 'javadoc' and gets the whole parsed java
+ * file, we get comments and store them
+ */
+ DocTrees docTrees = docEnv.getDocTrees();
+ for (TypeElement t : ElementFilter.typesIn(docEnv.getIncludedElements())) {
+ String typeName = t.getQualifiedName().toString();
+
+ storeCommentFor(docTrees, typeName, t);
+
+ for (Element e : t.getEnclosedElements()) {
+ // Omit the method name for ctors: this is a bit weird, but
+ // this is what the existing tests expect.
+ String fullName = typeName;
+ if (e.getKind() != ElementKind.CONSTRUCTOR) {
+ fullName = fullName + "." + e.getSimpleName();
+ }
+
+ storeCommentFor(docTrees, fullName, e);
+ }
+ }
+
+ return true;
+ }
+
+
+ public static int check(Map<String, String> wantedComments) {
+ int errorCount=0;
+ Iterator<Entry<String, String>> it = m_parsedComments.entrySet().iterator();
+
+ while (it.hasNext()) {
+
+ Entry<String, String> e = (Entry<String, String>) it.next();
+ String actualStr = e.getValue();
+ String wantedStr = wantedComments.get(e.getKey());
+ // this may be weird, but I don't know any more effective solution
+ actualStr = actualStr.replace(" ", "");
+ actualStr = actualStr.replaceAll("\t", "");
+ actualStr = actualStr.replace("\n", "");
+
+ // Removing of <br> is temporary solution, since adding of
+ // <br> tag requires changes in all tests. However, <br>
+ // tag should be added more selectively and when this is
+ // implemented, tests should be updated.
+ actualStr = actualStr.replace("<br>", "");
+
+ if (wantedStr != null) {
+ wantedStr = wantedStr.replace(" ", "");
+ wantedStr = wantedStr.replace("\t", "");
+ wantedStr = wantedStr.replace("\n", "");
+ wantedStr = wantedStr.replace("<br>", "");
+ }
+ /* The following lines replace multiple whitespaces with a single one.
+ Although this would be more exact testing, it would also require
+ more work on test maintenance.
+ actualStr = actualStr.replace('\t', ' ');
+ actualStr = actualStr.replaceAll(" +", " ");
+ // actualStr = actualStr.replace("\n", "");
+ if (wantedStr != null) {
+ wantedStr = wantedStr.replace('\t', ' ');
+ wantedStr = wantedStr.replaceAll(" +", " ");
+ // wantedStr = wantedStr.replace("\n", "");
+ } */
+
+ if (!actualStr.equals(wantedStr)) {
+ System.out.println("\n\n////////////////////////////////////////////////////////////////////////");
+ System.out.println("Documentation comments for '" + e.getKey() + "' do not match!");
+ String expectedFileName = "expected.txt";
+ String gotFileName = "got.txt";
+ System.out.println("Output is also saved to files '" + expectedFileName +
+ "' and '" + gotFileName + "'");
+ // here we print original strings, for nicer output
+ System.out.println("\n\n---\nexpected:\n" + wantedStr);
+ System.out.println("\n\n---\ngot:\n" + e.getValue());
+
+ try {
+ // write expected string to file
+ BufferedWriter expectedFile = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(expectedFileName)));
+ if (wantedStr != null)
+ expectedFile.write(wantedStr);
+ expectedFile.close();
+
+ // write translated string to file
+ BufferedWriter gotFile = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(gotFileName)));
+ gotFile.write(e.getValue().replace("<br>", ""));
+ gotFile.close();
+ } catch (IOException ex) {
+ System.out.println("Error when writing output to file: " + ex);
+ }
+
+ errorCount++;
+ }
+ }
+
+ if (m_parsedComments.size() != wantedComments.size()) {
+ System.out.println("Mismatch in the number of comments!\n Expected: " +
+ wantedComments.size() + "\n Parsed: " +
+ m_parsedComments.size());
+ System.out.println("Expected keys: ");
+ printKeys(wantedComments);
+ System.out.println("Parsed keys: ");
+ printKeys(m_parsedComments);
+
+ errorCount++;
+ }
+
+ return errorCount > 0 ? 1 : 0;
+ }
+
+
+ private static void printKeys(Map<String, String> map) {
+
+ Set<String> keys = map.keySet();
+ for (String key : keys) {
+ System.out.println(" " + key);
+ }
+ }
+
+
+ public static void printCommentListForJavaSource() {
+
+ Iterator< Entry<String, String> > it = m_parsedComments.entrySet().iterator();
+
+ while (it.hasNext()) {
+
+ Entry<String, String> e = (Entry<String, String>) it.next();
+ String commentText = e.getValue();
+ commentText = commentText.replace("\\", "\\\\");
+ commentText = commentText.replace("\"", "\\\"");
+ commentText = commentText.replace("\n", "\\n\" +\n\t\t\"");
+ System.out.format("wantedComments.put(\"%s\",\n\t\t\"%s\");\n", e.getKey(), commentText);
+ }
+ }
+
+ public static void parse(String sourcefile) {
+ ToolProvider javadoc = ToolProvider.findFirst("javadoc").orElseThrow();
+ int result = javadoc.run(System.out, System.err, new String[]{"-quiet", "-doclet", "CommentParser", sourcefile});
+ if (result != 0) {
+ System.err.println("Executing javadoc failed.");
+ System.exit(result);
+ }
+ }
+
+
+ public static void main(String argv[]) {
+
+ if (argv.length<1) {
+ System.out.format("Usage:\n\tCommentParser <package to parse>\n");
+ System.exit(1);
+ }
+
+ parse(argv[0]);
+
+ // if we are run as standalone app, print the list of found comments as it would appear in java source
+
+ printCommentListForJavaSource();
+ }
+}
diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in
index e69964352..a449f287c 100644
--- a/Examples/test-suite/java/Makefile.in
+++ b/Examples/test-suite/java/Makefile.in
@@ -6,7 +6,10 @@ LANGUAGE = java
JAVA = @JAVA@
JAVAC = @JAVAC@
JAVAFLAGS = @JAVAFLAGS@
+JAVA_CLASSPATH_SEP = @JAVA_CLASSPATH_SEP@
+JAVA_TOOLS_JAR = @JAVA_TOOLS_JAR@
SCRIPTSUFFIX = _runme.java
+SKIP_DOXYGEN_TEST_CASES = @JAVA_SKIP_DOXYGEN_TEST_CASES@
srcdir = @srcdir@
top_srcdir = ../@top_srcdir@
@@ -28,6 +31,8 @@ CPP_TEST_CASES = \
java_director_exception_feature \
java_director_exception_feature_nspace \
java_director_ptrclass \
+ java_director_typemaps \
+ java_director_typemaps_ptr \
java_enums \
java_jnitypes \
java_lib_arrays_dimensionless \
@@ -39,11 +44,27 @@ CPP_TEST_CASES = \
java_throws \
java_typemaps_proxy \
java_typemaps_typewrapper \
+ li_std_list \
+ li_std_map \
+ li_std_set \
# li_boost_intrusive_ptr
CPP11_TEST_CASES = \
+ cpp11_shared_ptr_const \
+ cpp11_shared_ptr_nullptr_in_containers \
+ cpp11_shared_ptr_overload \
+ cpp11_shared_ptr_template_upcast \
+ cpp11_shared_ptr_upcast \
+ cpp11_std_unordered_map \
+ cpp11_std_unordered_set \
cpp11_strongly_typed_enumerations_simple \
+DOXYGEN_TEST_CASES := \
+ doxygen_parsing_enums_simple \
+ doxygen_parsing_enums_proper \
+ doxygen_parsing_enums_typesafe \
+ doxygen_parsing_enums_typeunsafe \
+
include $(srcdir)/../common.mk
# Overridden variables here
@@ -53,6 +74,7 @@ JAVA_PACKAGEOPT = -package $(JAVA_PACKAGE)
SWIGOPT += $(JAVA_PACKAGEOPT)
# Custom tests - tests with additional commandline options
+cpp17_nspace_nested_namespaces.%: JAVA_PACKAGE = $*Package
director_nspace.%: JAVA_PACKAGE = $*Package
director_nspace_director_name_collision.%: JAVA_PACKAGE = $*Package
java_director_exception_feature_nspace.%: JAVA_PACKAGE = $*Package
@@ -88,14 +110,21 @@ setup = \
mkdir $(JAVA_PACKAGE); \
fi
+# Doxygen test cases need to be compiled together with the CommentParser class.
+CommentParser.class:
+ $(COMPILETOOL) $(JAVAC) -classpath $(JAVA_CLASSPATH) -d . $(srcdir)/CommentParser.java
+
+JAVA_CLASSPATH := .
+$(DOXYGEN_TEST_CASES:=.cpptest): CommentParser.class
+
# Compiles java files then runs the testcase. A testcase is only run if
# a file is found which has _runme.java appended after the testcase name.
# Note Java uses LD_LIBRARY_PATH under Unix, PATH under Cygwin/Windows, SHLIB_PATH on HPUX and DYLD_LIBRARY_PATH on Mac OS X.
run_testcase = \
cd $(JAVA_PACKAGE) && $(COMPILETOOL) $(JAVAC) -classpath . `find . -name "*.java"` && cd .. && \
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
- $(COMPILETOOL) $(JAVAC) -classpath . -d . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
- env LD_LIBRARY_PATH="$(JAVA_PACKAGE):$$LD_LIBRARY_PATH" PATH="$(JAVA_PACKAGE):$$PATH" SHLIB_PATH="$(JAVA_PACKAGE):$$SHLIB_PATH" DYLD_LIBRARY_PATH="$(JAVA_PACKAGE):$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) $(JAVAFLAGS) -classpath . $*_runme; \
+ $(COMPILETOOL) $(JAVAC) -classpath $(JAVA_CLASSPATH) -d . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
+ env LD_LIBRARY_PATH="$(JAVA_PACKAGE):$$LD_LIBRARY_PATH" PATH="$(JAVA_PACKAGE):$$PATH" SHLIB_PATH="$(JAVA_PACKAGE):$$SHLIB_PATH" DYLD_LIBRARY_PATH="$(JAVA_PACKAGE):$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) $(JAVAFLAGS) -classpath $(JAVA_CLASSPATH) $*_runme; \
fi
# Clean: remove testcase directories
diff --git a/Examples/test-suite/java/class_scope_namespace_runme.java b/Examples/test-suite/java/class_scope_namespace_runme.java
new file mode 100644
index 000000000..e55393e2b
--- /dev/null
+++ b/Examples/test-suite/java/class_scope_namespace_runme.java
@@ -0,0 +1,59 @@
+
+import class_scope_namespace.*;
+
+public class class_scope_namespace_runme {
+
+ static {
+ try {
+ System.loadLibrary("class_scope_namespace");
+ } 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[])
+ {
+ A a = new A();
+ B b = new B();
+ C c = new C();
+ D d = new D();
+ E e = new E();
+ F f = new F();
+ G g = new G();
+ H.HH h = new H.HH();
+ I_.II i = new I_.II();
+ J j = new J();
+ K k = new K();
+ L l = new L();
+ M m = new M();
+
+ a.aa(a, a, a);
+ b.bb(b, b);
+ c.cc(c, c);
+ d.dd(d, d, d);
+ e.ee(e, e, e);
+ f.ff(f, f, f, f);
+ g.gg(g, g);
+ h.hh(h);
+ i.ii(i, i);
+ j.jj(j, j, j);
+ k.kk(k, k, k);
+ l.ll(l, l, l);
+ m.mm(m, m, m);
+
+ class_scope_namespace.aaa(a, a, a);
+ class_scope_namespace.bbb(b, b);
+ class_scope_namespace.ccc(c, c);
+ class_scope_namespace.ddd(d, d, d);
+ class_scope_namespace.eee(e, e, e);
+ class_scope_namespace.fff(f, f, f, f);
+ class_scope_namespace.ggg(g, g);
+ class_scope_namespace.hhh(h);
+ class_scope_namespace.iii(i, i);
+ class_scope_namespace.jjj(j, j, j);
+ class_scope_namespace.kkk(k, k, k);
+ class_scope_namespace.lll(l, l, l);
+ class_scope_namespace.mmm(m, m, m);
+ }
+}
diff --git a/Examples/test-suite/java/cpp11_alias_nested_template_scoping_runme.java b/Examples/test-suite/java/cpp11_alias_nested_template_scoping_runme.java
new file mode 100644
index 000000000..7afa83a0f
--- /dev/null
+++ b/Examples/test-suite/java/cpp11_alias_nested_template_scoping_runme.java
@@ -0,0 +1,32 @@
+
+import cpp11_alias_nested_template_scoping.*;
+
+public class cpp11_alias_nested_template_scoping_runme {
+
+ static {
+ try {
+ System.loadLibrary("cpp11_alias_nested_template_scoping");
+ } 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[]) {
+ Yshort ys = new Yshort();
+ short val = 0;
+ val = ys.create1();
+ val = ys.create2();
+ val = ys.create3();
+ val = ys.create4();
+ val = ys.create5();
+ val = ys.create6();
+ val = ys.create7();
+
+ val = ys.create13();
+
+ val = ys.create15();
+ val = ys.create16();
+ val = ys.create17();
+ }
+}
diff --git a/Examples/test-suite/java/cpp11_initializer_list_runme.java b/Examples/test-suite/java/cpp11_initializer_list_runme.java
new file mode 100644
index 000000000..0318c9e90
--- /dev/null
+++ b/Examples/test-suite/java/cpp11_initializer_list_runme.java
@@ -0,0 +1,21 @@
+
+import cpp11_initializer_list.*;
+
+public class cpp11_initializer_list_runme {
+
+ static {
+ try {
+ System.loadLibrary("cpp11_initializer_list");
+ } 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[]) {
+ C c = new C(null);
+ String joined = c.get_joined_string();
+ if (!joined.equals("AbFab"))
+ throw new RuntimeException("Wrong joined string " + joined);
+ }
+}
diff --git a/Examples/test-suite/java/cpp11_raw_string_literals_runme.java b/Examples/test-suite/java/cpp11_raw_string_literals_runme.java
new file mode 100644
index 000000000..396c0ba06
--- /dev/null
+++ b/Examples/test-suite/java/cpp11_raw_string_literals_runme.java
@@ -0,0 +1,67 @@
+import cpp11_raw_string_literals.*;
+
+public class cpp11_raw_string_literals_runme {
+
+ static {
+ try {
+ System.loadLibrary("cpp11_raw_string_literals");
+ } 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[]) {
+ if (cpp11_raw_string_literals.getL() != 100)
+ throw new RuntimeException("failed!");
+
+ if (cpp11_raw_string_literals.getU8() != 100)
+ throw new RuntimeException("failed!");
+
+ if (cpp11_raw_string_literals.getU() != 100)
+ throw new RuntimeException("failed!");
+
+ if (UStruct.U != 100)
+ throw new RuntimeException("failed!");
+
+
+ if (cpp11_raw_string_literals.getR() != 100)
+ throw new RuntimeException("failed!");
+
+ if (cpp11_raw_string_literals.getLR() != 100)
+ throw new RuntimeException("failed!");
+
+ if (cpp11_raw_string_literals.getU8R() != 100)
+ throw new RuntimeException("failed!");
+
+ if (cpp11_raw_string_literals.getUR() != 100)
+ throw new RuntimeException("failed!");
+
+ if (URStruct.UR != 100)
+ throw new RuntimeException("failed!");
+
+
+ if (!cpp11_raw_string_literals.getAa().equals("Wide string"))
+ throw new RuntimeException("failed!");
+
+ if (!cpp11_raw_string_literals.getBb().equals("UTF-8 string"))
+ throw new RuntimeException("failed!");
+
+ if (!cpp11_raw_string_literals.getXx().equals(")I'm an \"ascii\" \\ string."))
+ throw new RuntimeException("failed!");
+
+ if (!cpp11_raw_string_literals.getEe().equals(")I'm an \"ascii\" \\ string."))
+ throw new RuntimeException("failed!");
+
+ if (!cpp11_raw_string_literals.getFf().equals("I'm a \"raw wide\" \\ string."))
+ throw new RuntimeException("failed!");
+
+ if (!cpp11_raw_string_literals.getGg().equals("I'm a \"raw UTF-8\" \\ string."))
+ throw new RuntimeException("failed!");
+
+
+
+ if (!cpp11_raw_string_literalsConstants.mm.equals(")I'm an \"ascii\" \\ string constant with multiple\n\nlines."))
+ throw new RuntimeException("failed!");
+ }
+}
diff --git a/Examples/test-suite/java/cpp11_ref_qualifiers_runme.java b/Examples/test-suite/java/cpp11_ref_qualifiers_runme.java
new file mode 100644
index 000000000..4755f8d1f
--- /dev/null
+++ b/Examples/test-suite/java/cpp11_ref_qualifiers_runme.java
@@ -0,0 +1,56 @@
+
+import cpp11_ref_qualifiers.*;
+
+public class cpp11_ref_qualifiers_runme {
+
+ static {
+ try {
+ System.loadLibrary("cpp11_ref_qualifiers");
+ } 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[]) {
+ Host h = new Host();
+
+ // Basic testing
+ h.h1();
+ h.h2();
+ h.h6();
+ h.h7();
+
+ h.h();
+
+ // %feature testing
+ Features f = new Features();
+ if (!f.F1().equals("F1")) throw new RuntimeException("Fail");
+ if (!f.F2().equals("F2")) throw new RuntimeException("Fail");
+ if (!f.F3().equals("F3")) throw new RuntimeException("Fail");
+
+ if (!f.C1(0).equals("C1")) throw new RuntimeException("Fail");
+ if (!f.C2(0).equals("C2")) throw new RuntimeException("Fail");
+ if (!f.C3(0).equals("C3")) throw new RuntimeException("Fail");
+
+ // %rename testing
+ Renames r = new Renames();
+ r.RR1();
+ r.RR2();
+ r.RR3();
+
+ r.SS1(0);
+ r.SS2(0);
+ r.SS3(0);
+
+ // Conversion operators
+ String s = null;
+ ConversionOperators co = new ConversionOperators();
+ s = co.StringConvertCopy();
+ s = co.StringConvertMove();
+
+ ConversionOperators2 co2 = new ConversionOperators2();
+ s = co2.StringConvertMove();
+ }
+}
+
diff --git a/Examples/test-suite/java/cpp11_ref_qualifiers_rvalue_unignore_runme.java b/Examples/test-suite/java/cpp11_ref_qualifiers_rvalue_unignore_runme.java
new file mode 100644
index 000000000..bbbe6f788
--- /dev/null
+++ b/Examples/test-suite/java/cpp11_ref_qualifiers_rvalue_unignore_runme.java
@@ -0,0 +1,20 @@
+
+import cpp11_ref_qualifiers_rvalue_unignore.*;
+
+public class cpp11_ref_qualifiers_rvalue_unignore_runme {
+
+ static {
+ try {
+ System.loadLibrary("cpp11_ref_qualifiers_rvalue_unignore");
+ } 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[]) {
+ new RefQualifier().m1();
+ new RefQualifier().m2();
+ }
+}
+
diff --git a/Examples/test-suite/java/cpp11_ref_qualifiers_typemaps_runme.java b/Examples/test-suite/java/cpp11_ref_qualifiers_typemaps_runme.java
new file mode 100644
index 000000000..8c6a21b15
--- /dev/null
+++ b/Examples/test-suite/java/cpp11_ref_qualifiers_typemaps_runme.java
@@ -0,0 +1,39 @@
+import cpp11_ref_qualifiers_typemaps.*;
+
+public class cpp11_ref_qualifiers_typemaps_runme {
+ static {
+ try {
+ System.loadLibrary("cpp11_ref_qualifiers_typemaps");
+ } 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[])
+ {
+ {
+ TypemapsNamedParms tm = new TypemapsNamedParms();
+ if (tm.fff(cpp11_ref_qualifiers_typemaps.FF1_MFP) != 2)
+ throw new RuntimeException("failed");
+ if (tm.ccc(cpp11_ref_qualifiers_typemaps.CC4_MFP) != 5)
+ throw new RuntimeException("failed");
+ if (tm.ggg(cpp11_ref_qualifiers_typemaps.GG7_MFP) != 8)
+ throw new RuntimeException("failed");
+ if (tm.hhh(cpp11_ref_qualifiers_typemaps.HH10_MFP) != 11)
+ throw new RuntimeException("failed");
+ }
+ {
+ TypemapsUnnamedParms tm = new TypemapsUnnamedParms();
+ if (tm.fff(cpp11_ref_qualifiers_typemaps.FF1_MFP) != 3)
+ throw new RuntimeException("failed");
+ if (tm.ccc(cpp11_ref_qualifiers_typemaps.CC4_MFP) != 6)
+ throw new RuntimeException("failed");
+ if (tm.ggg(cpp11_ref_qualifiers_typemaps.GG7_MFP) != 9)
+ throw new RuntimeException("failed");
+ if (tm.hhh(cpp11_ref_qualifiers_typemaps.HH10_MFP) != 12)
+ throw new RuntimeException("failed");
+ }
+ }
+}
+
diff --git a/Examples/test-suite/java/cpp11_shared_ptr_overload_runme.java b/Examples/test-suite/java/cpp11_shared_ptr_overload_runme.java
new file mode 100644
index 000000000..27dfe1830
--- /dev/null
+++ b/Examples/test-suite/java/cpp11_shared_ptr_overload_runme.java
@@ -0,0 +1,60 @@
+import cpp11_shared_ptr_overload.*;
+
+public class cpp11_shared_ptr_overload_runme {
+ static {
+ try {
+ System.loadLibrary("cpp11_shared_ptr_overload");
+ } 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[])
+ {
+ String ret = null;
+
+ // ref
+ ret = cpp11_shared_ptr_overload.UseA(new MyType("123"));
+ if (!ret.equals("123 ref")) throw new RuntimeException("UseA fail:" + ret);
+
+ ret = cpp11_shared_ptr_overload.UseB(0, new MyType("123"));
+ if (!ret.equals("123 ref")) throw new RuntimeException("UseB fail:" + ret);
+
+ ret = cpp11_shared_ptr_overload.UseC(0, new MyType("123"), new MyType("456"));
+ if (!ret.equals("123 ref")) throw new RuntimeException("UseC fail:" + ret);
+
+ // sharedptr
+ ret = cpp11_shared_ptr_overload.UseX(new MyType("123"));
+ if (!ret.equals("123 sharedptr")) throw new RuntimeException("UseX fail:" + ret);
+
+ ret = cpp11_shared_ptr_overload.UseY(0, new MyType("123"));
+ if (!ret.equals("123 sharedptr")) throw new RuntimeException("UseY fail:" + ret);
+
+ ret = cpp11_shared_ptr_overload.UseZ(0, new MyType("123"), new MyType("456"));
+ if (!ret.equals("123 sharedptr")) throw new RuntimeException("UseZ fail:" + ret);
+
+ // Combo1-4
+ ret = cpp11_shared_ptr_overload.Combo1(new MyType("XXX"));
+ if (!ret.equals("XXXCombo1")) throw new RuntimeException("Combo1 fail:" + ret);
+
+ ret = cpp11_shared_ptr_overload.Combo2(new MyType("XXX"));
+ if (!ret.equals("XXXCombo2")) throw new RuntimeException("Combo2 fail:" + ret);
+
+ ret = cpp11_shared_ptr_overload.Combo3(new MyType("XXX"));
+ if (!ret.equals("XXXCombo3")) throw new RuntimeException("Combo3 fail:" + ret);
+
+ ret = cpp11_shared_ptr_overload.Combo4(new MyType("XXX"));
+ if (!ret.equals("XXXCombo4")) throw new RuntimeException("Combo4 fail:" + ret);
+
+ // Combo5-7
+ ret = cpp11_shared_ptr_overload.Combo5(new MyType("XXX"));
+ if (!ret.equals("XXXCombo5")) throw new RuntimeException("Combo5 fail:" + ret);
+
+ ret = cpp11_shared_ptr_overload.Combo6(new MyType("XXX"));
+ if (!ret.equals("XXXCombo6")) throw new RuntimeException("Combo6 fail:" + ret);
+
+ ret = cpp11_shared_ptr_overload.Combo7(new MyType("XXX"));
+ if (!ret.equals("XXXCombo7")) throw new RuntimeException("Combo7 fail:" + ret);
+ }
+}
diff --git a/Examples/test-suite/java/cpp11_shared_ptr_template_upcast_runme.java b/Examples/test-suite/java/cpp11_shared_ptr_template_upcast_runme.java
new file mode 100644
index 000000000..2826f580d
--- /dev/null
+++ b/Examples/test-suite/java/cpp11_shared_ptr_template_upcast_runme.java
@@ -0,0 +1,24 @@
+// This is the cpp11_shared_ptr_template_upcast runtime testcase. It checks that SWIG generates the appropriate upcasted shared_ptr type for a template instantiation deriving from a base class.
+// For this case, the expected behavior is: given a cptr with underlying type shared_ptr<Printable<Derived> >, PrintableDerived_SWIGSmartPtrUpcast returns a cptr with
+// underlying type std::shared_ptr< Derived >, where Printable<Derived> inherits from Derived.
+
+import cpp11_shared_ptr_template_upcast.*;
+
+public class cpp11_shared_ptr_template_upcast_runme {
+
+ static {
+ try {
+ System.loadLibrary("cpp11_shared_ptr_template_upcast");
+ } 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[]) {
+ PrintableDerived pd = cpp11_shared_ptr_template_upcast.MakePrintableDerived(20);
+ pd.GetResult();
+ pd.GetFormatted();
+ }
+}
+
diff --git a/Examples/test-suite/java/cpp11_li_std_array_runme.java b/Examples/test-suite/java/cpp11_std_array_runme.java
index 2e2a20138..58fdc176b 100644
--- a/Examples/test-suite/java/cpp11_li_std_array_runme.java
+++ b/Examples/test-suite/java/cpp11_std_array_runme.java
@@ -1,10 +1,10 @@
-import cpp11_li_std_array.*;
+import cpp11_std_array.*;
-public class cpp11_li_std_array_runme {
+public class cpp11_std_array_runme {
static {
try {
- System.loadLibrary("cpp11_li_std_array");
+ System.loadLibrary("cpp11_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);
@@ -43,24 +43,24 @@ public class cpp11_li_std_array_runme {
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});
+ compareContainers(cpp11_std_array.arrayOutVal(), new int[] {-2, -1, 0, 0, 1, 2});
+ compareContainers(cpp11_std_array.arrayOutConstRef(), new int[] {-2, -1, 0, 0, 1, 2});
+ compareContainers(cpp11_std_array.arrayOutRef(), new int[] {-2, -1, 0, 0, 1, 2});
+ compareContainers(cpp11_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}));
+ ai = cpp11_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}));
+ ai = cpp11_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);
+ cpp11_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);
+ cpp11_std_array.arrayInPtr(ai);
compareContainers(ai, new int[] {90, 80, 70, 60, 50, 40});
// fill
diff --git a/Examples/test-suite/java/cpp11_std_unordered_map_runme.java b/Examples/test-suite/java/cpp11_std_unordered_map_runme.java
new file mode 100644
index 000000000..79f683378
--- /dev/null
+++ b/Examples/test-suite/java/cpp11_std_unordered_map_runme.java
@@ -0,0 +1,122 @@
+import cpp11_std_unordered_map.*;
+
+public class cpp11_std_unordered_map_runme {
+
+ static {
+ try {
+ System.loadLibrary("cpp11_std_unordered_map");
+ } 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 checkThat(boolean mustBeTrue) throws Throwable {
+ if (!mustBeTrue) {
+ // Index [2], since this function is one hop away from main, and [1] is the current method.
+ throw new RuntimeException("Test failed at line number " + Thread.currentThread().getStackTrace()[2].getLineNumber());
+ }
+ }
+
+ public static void main(String argv[]) throws Throwable
+ {
+ java.util.AbstractMap<String, Integer> sim = new UnorderedMapStringInt();
+ java.util.AbstractMap<Integer, Integer> iim = new UnorderedMapIntInt();
+
+ checkThat(sim.isEmpty());
+ checkThat(iim.isEmpty());
+ checkThat(sim.size() == 0);
+ checkThat(iim.size() == 0);
+
+ checkThat(sim.get("key") == null);
+ checkThat(iim.get(1) == null);
+
+ checkThat(!sim.containsKey("key"));
+ checkThat(!iim.containsKey(1));
+
+ checkThat(sim.put("key", 2) == null);
+ checkThat(iim.put(1, 2) == null);
+
+ checkThat(sim.size() == 1);
+ checkThat(iim.size() == 1);
+ checkThat(!sim.isEmpty());
+ checkThat(!iim.isEmpty());
+
+ checkThat(sim.get("key") == 2);
+ checkThat(iim.get(1) == 2);
+
+ checkThat(sim.remove("key") == 2);
+ checkThat(iim.remove(1) == 2);
+
+ checkThat(sim.isEmpty());
+ checkThat(iim.isEmpty());
+ checkThat(sim.size() == 0);
+ checkThat(iim.size() == 0);
+
+ checkThat(sim.get("key") == null);
+ checkThat(iim.get(1) == null);
+
+ checkThat(sim.remove("key") == null);
+ checkThat(iim.remove(1) == null);
+
+ checkThat(sim.put("key", 2) == null);
+ checkThat(iim.put(1, 2) == null);
+
+ sim.clear();
+ iim.clear();
+ checkThat(sim.isEmpty());
+ checkThat(iim.isEmpty());
+
+ checkThat(sim.put("key1", 1) == null);
+ checkThat(iim.put(1, 1) == null);
+ checkThat(sim.put("key2", 2) == null);
+ checkThat(iim.put(2, 2) == null);
+
+ checkThat(sim.size() == 2);
+ checkThat(iim.size() == 2);
+ checkThat(sim.get("key1") == 1);
+ checkThat(iim.get(1) == 1);
+ checkThat(sim.get("key2") == 2);
+ checkThat(iim.get(2) == 2);
+
+ checkThat(sim.put("key1", 3) == 1);
+ checkThat(iim.put(1, 3) == 1);
+
+ checkThat(sim.size() == 2);
+ checkThat(iim.size() == 2);
+ checkThat(sim.get("key1") == 3);
+ checkThat(iim.get(1) == 3);
+
+ java.util.Set<java.util.Map.Entry<String, Integer>> sim_es = sim.entrySet();
+ java.util.Map<String, Integer> sim_default = new java.util.HashMap<String, Integer>();
+ sim_default.put("key1", 3);
+ sim_default.put("key2", 2);
+ java.util.Set<java.util.Map.Entry<String, Integer>> sim_es_default = sim_default.entrySet();
+ checkThat(sim_es.size() == sim_es_default.size());
+ for (java.util.Map.Entry<String, Integer> entry : sim_es) {
+ checkThat(sim_es_default.contains(entry));
+ checkThat(sim_default.containsKey(entry.getKey()));
+ checkThat(sim_default.containsValue(entry.getValue()));
+
+ Integer oldValue = entry.getValue();
+ entry.setValue(oldValue + 1);
+ checkThat(sim.get(entry.getKey()) == (oldValue + 1));
+ }
+
+ java.util.Set<java.util.Map.Entry<Integer, Integer>> iim_es = iim.entrySet();
+ java.util.Map<Integer, Integer> iim_default = new java.util.HashMap<Integer, Integer>();
+ iim_default.put(1, 3);
+ iim_default.put(2, 2);
+ java.util.Set<java.util.Map.Entry<Integer, Integer>> iim_es_default = iim_default.entrySet();
+ checkThat(iim_es.size() == iim_es_default.size());
+ for (java.util.Map.Entry<Integer, Integer> entry : iim_es) {
+ checkThat(iim_es_default.contains(entry));
+ checkThat(iim_default.containsKey(entry.getKey()));
+ checkThat(iim_default.containsValue(entry.getValue()));
+
+ Integer oldValue = entry.getValue();
+ entry.setValue(oldValue + 1);
+ checkThat(iim.get(entry.getKey()) == (oldValue + 1));
+ }
+ }
+}
diff --git a/Examples/test-suite/java/cpp11_std_unordered_set_runme.java b/Examples/test-suite/java/cpp11_std_unordered_set_runme.java
new file mode 100644
index 000000000..9d64ab240
--- /dev/null
+++ b/Examples/test-suite/java/cpp11_std_unordered_set_runme.java
@@ -0,0 +1,75 @@
+import cpp11_std_unordered_set.*;
+
+public class cpp11_std_unordered_set_runme {
+
+ static {
+ try {
+ System.loadLibrary("cpp11_std_unordered_set");
+ } 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 checkThat(boolean mustBeTrue) throws Throwable {
+ if (!mustBeTrue) {
+ // Index [2], since this function is one hop away from main, and [1] is the current method.
+ throw new RuntimeException("Test failed at line number " + Thread.currentThread().getStackTrace()[2].getLineNumber());
+ }
+ }
+
+ public static void main(String argv[]) throws Throwable
+ {
+ java.util.AbstractSet<String> ss = new UnorderedSetString();
+
+ checkThat(ss.isEmpty());
+ checkThat(!ss.contains("key"));
+ checkThat(!ss.remove("key"));
+
+ checkThat(ss.add("key"));
+ checkThat(!ss.add("key"));
+ checkThat(ss.contains("key"));
+ checkThat(ss.remove("key"));
+ checkThat(ss.isEmpty());
+ checkThat(ss.size() == 0);
+
+ checkThat(ss.add("key1"));
+ checkThat(ss.add("key2"));
+ checkThat(ss.add("key3"));
+ checkThat(ss.size() == 3);
+
+ ss.clear();
+ checkThat(ss.isEmpty());
+ checkThat(ss.size() == 0);
+
+ checkThat(ss.addAll(java.util.Arrays.asList("one", "two", "three")));
+ checkThat(ss.size() == 3);
+ checkThat(ss.contains("one"));
+ checkThat(!ss.contains("four"));
+
+ checkThat(ss.containsAll(java.util.Arrays.asList("one", "two", "three")));
+ checkThat(ss.containsAll(java.util.Arrays.asList("one", "two")));
+ checkThat(!ss.containsAll(java.util.Arrays.asList("one", "two", "four")));
+ checkThat(!ss.containsAll(java.util.Arrays.asList("one", "two", "three", "four")));
+
+ checkThat(!ss.addAll(java.util.Arrays.asList("one", "two", "three")));
+
+ java.util.Set<String> found = new java.util.HashSet<String>();
+ java.util.Iterator<String> itr = ss.iterator();
+ while (itr.hasNext()) {
+ found.add(itr.next());
+ }
+
+ checkThat(ss.containsAll(found));
+ checkThat(found.containsAll(ss));
+
+ java.util.AbstractSet<String> ss2 = new UnorderedSetString(ss);
+ checkThat(ss2.containsAll(ss));
+ checkThat(ss.containsAll(ss2));
+
+ checkThat(!ss.removeAll(java.util.Arrays.asList("five", "four")));
+ checkThat(ss.removeAll(found));
+ checkThat(ss.isEmpty());
+ checkThat(ss.size() == 0);
+ }
+}
diff --git a/Examples/test-suite/java/cpp11_template_typedefs_runme.java b/Examples/test-suite/java/cpp11_template_typedefs_runme.java
new file mode 100644
index 000000000..473e7cf07
--- /dev/null
+++ b/Examples/test-suite/java/cpp11_template_typedefs_runme.java
@@ -0,0 +1,19 @@
+import cpp11_template_typedefs.*;
+
+public class cpp11_template_typedefs_runme {
+
+ static {
+ try {
+ System.loadLibrary("cpp11_template_typedefs");
+ } 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[]) {
+ int alloc1 = cpp11_template_typedefs.get_bucket_allocator1();
+ int alloc2 = cpp11_template_typedefs.get_bucket_allocator2();
+ }
+}
+
diff --git a/Examples/test-suite/java/cpp17_nested_namespaces_runme.java b/Examples/test-suite/java/cpp17_nested_namespaces_runme.java
new file mode 100644
index 000000000..ac29dee19
--- /dev/null
+++ b/Examples/test-suite/java/cpp17_nested_namespaces_runme.java
@@ -0,0 +1,32 @@
+import cpp17_nested_namespaces.*;
+
+public class cpp17_nested_namespaces_runme {
+
+ static {
+ try {
+ System.loadLibrary("cpp17_nested_namespaces");
+ } 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[]) {
+ new A1Struct().A1Method();
+ new B1Struct().B1Method();
+ new C1Struct().C1Method();
+ cpp17_nested_namespaces.createA1Struct().A1Method();
+ cpp17_nested_namespaces.createB1Struct().B1Method();
+ cpp17_nested_namespaces.createC1Struct().C1Method();
+
+ new B2Struct().B2Method();
+ new C2Struct().C2Method();
+ cpp17_nested_namespaces.createB2Struct().B2Method();
+ cpp17_nested_namespaces.createC2Struct().C2Method();
+
+ new B3Struct().B3Method();
+ new C3Struct().C3Method();
+ cpp17_nested_namespaces.createB3Struct().B3Method();
+ cpp17_nested_namespaces.createC3Struct().C3Method();
+ }
+}
diff --git a/Examples/test-suite/java/cpp17_nspace_nested_namespaces_runme.java b/Examples/test-suite/java/cpp17_nspace_nested_namespaces_runme.java
new file mode 100644
index 000000000..e603484ab
--- /dev/null
+++ b/Examples/test-suite/java/cpp17_nspace_nested_namespaces_runme.java
@@ -0,0 +1,30 @@
+public class cpp17_nspace_nested_namespaces_runme {
+
+ static {
+ try {
+ System.loadLibrary("cpp17_nspace_nested_namespaces");
+ } 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[]) {
+ new cpp17_nspace_nested_namespacesPackage.A1.A1Struct().A1Method();
+ new cpp17_nspace_nested_namespacesPackage.A1.B1.B1Struct().B1Method();
+ new cpp17_nspace_nested_namespacesPackage.A1.B1.C1.C1Struct().C1Method();
+ cpp17_nspace_nested_namespacesPackage.cpp17_nspace_nested_namespaces.createA1Struct().A1Method();
+ cpp17_nspace_nested_namespacesPackage.cpp17_nspace_nested_namespaces.createB1Struct().B1Method();
+ cpp17_nspace_nested_namespacesPackage.cpp17_nspace_nested_namespaces.createC1Struct().C1Method();
+
+ new cpp17_nspace_nested_namespacesPackage.A2.B2.B2Struct().B2Method();
+ new cpp17_nspace_nested_namespacesPackage.A2.B2.C2.C2Struct().C2Method();
+ cpp17_nspace_nested_namespacesPackage.cpp17_nspace_nested_namespaces.createB2Struct().B2Method();
+ cpp17_nspace_nested_namespacesPackage.cpp17_nspace_nested_namespaces.createC2Struct().C2Method();
+
+ new cpp17_nspace_nested_namespacesPackage.A3.B3.B3Struct().B3Method();
+ new cpp17_nspace_nested_namespacesPackage.A3.B3.C3.C3Struct().C3Method();
+ cpp17_nspace_nested_namespacesPackage.cpp17_nspace_nested_namespaces.createB3Struct().B3Method();
+ cpp17_nspace_nested_namespacesPackage.cpp17_nspace_nested_namespaces.createC3Struct().C3Method();
+ }
+}
diff --git a/Examples/test-suite/java/director_classes_runme.java b/Examples/test-suite/java/director_classes_runme.java
index 5fbb9ea35..5992b5dd9 100644
--- a/Examples/test-suite/java/director_classes_runme.java
+++ b/Examples/test-suite/java/director_classes_runme.java
@@ -16,6 +16,7 @@ Expected output if PrintDebug enabled:
Base - Val(444.555)
Base - Ref(444.555)
Base - Ptr(444.555)
+Base - ConstPtrRef(444.555)
Base - FullyOverloaded(int 10)
Base - FullyOverloaded(bool 1)
Base - SemiOverloaded(int -678)
@@ -26,6 +27,7 @@ Base - DefaultParms(10, 1.1)
Derived - Val(444.555)
Derived - Ref(444.555)
Derived - Ptr(444.555)
+Derived - ConstPtrRef(444.555)
Derived - FullyOverloaded(int 10)
Derived - FullyOverloaded(bool 1)
Derived - SemiOverloaded(int -678)
@@ -36,6 +38,7 @@ Derived - DefaultParms(10, 1.1)
JavaDerived - Val(444.555)
JavaDerived - Ref(444.555)
JavaDerived - Ptr(444.555)
+JavaDerived - ConstPtrRef(444.555)
JavaDerived - FullyOverloaded(int 10)
JavaDerived - FullyOverloaded(bool True)
JavaDerived - SemiOverloaded(-678)
@@ -67,7 +70,7 @@ public class director_classes_runme {
void run()
{
- if (director_classes.getPrintDebug()) System.out.println("------------ Start ------------ ");
+ if (director_classes.getPrintDebug()) System.out.println("------------ Start ------------");
Caller myCaller = new Caller();
@@ -96,7 +99,7 @@ public class director_classes_runme {
myBase.delete();
}
- if (director_classes.getPrintDebug()) System.out.println("------------ Finish ------------ ");
+ if (director_classes.getPrintDebug()) System.out.println("------------ Finish ------------");
}
void makeCalls(Caller myCaller, Base myBase)
@@ -111,6 +114,7 @@ public class director_classes_runme {
if (myCaller.ValCall(dh).getVal() != dh.getVal()) throw new RuntimeException("failed");
if (myCaller.RefCall(dh).getVal() != dh.getVal()) throw new RuntimeException("failed");
if (myCaller.PtrCall(dh).getVal() != dh.getVal()) throw new RuntimeException("failed");
+ if (myCaller.ConstPtrRefCall(dh).getVal() != dh.getVal()) throw new RuntimeException("failed");
// Fully overloaded method test (all methods in base class are overloaded)
if (!myCaller.FullyOverloadedCall(10).equals(baseSimpleName + "::FullyOverloaded(int)")) {
@@ -170,6 +174,11 @@ class JavaDerived extends Base
if (director_classes.getPrintDebug()) System.out.println("JavaDerived - Ptr(" + x.getVal() + ")");
return x;
}
+ public DoubleHolder ConstPtrRef(DoubleHolder x)
+ {
+ if (director_classes.getPrintDebug()) System.out.println("JavaDerived - ConstPtrRef(" + x.getVal() + ")");
+ return x;
+ }
public String FullyOverloaded(int x)
{
if (director_classes.getPrintDebug()) System.out.println("JavaDerived - FullyOverloaded(int " + x + ")");
diff --git a/Examples/test-suite/java/director_exception_catches_runme.java b/Examples/test-suite/java/director_exception_catches_runme.java
new file mode 100644
index 000000000..c6fed192d
--- /dev/null
+++ b/Examples/test-suite/java/director_exception_catches_runme.java
@@ -0,0 +1,35 @@
+
+import director_exception_catches.*;
+
+public class director_exception_catches_runme {
+
+ static {
+ try {
+ System.loadLibrary("director_exception_catches");
+ } 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[]) {
+
+ BaseClass b = new director_exception_catches_MyClass();
+
+ try {
+ String s = BaseClass.call_description(b);
+ throw new RuntimeException("Failed to catch exception");
+ } catch (NullPointerException e) {
+ if (!e.getMessage().startsWith("Testing exception thrown in BaseClass.description"))
+ throw new RuntimeException("Unexpected exception message: " + e.getMessage());
+ }
+ }
+}
+
+class director_exception_catches_MyClass extends BaseClass {
+ @Override
+ public String description() {
+ throw new NullPointerException("Testing exception thrown in BaseClass.description");
+ }
+}
+
diff --git a/Examples/test-suite/java/director_ownership_runme.java b/Examples/test-suite/java/director_ownership_runme.java
new file mode 100644
index 000000000..c038f56a4
--- /dev/null
+++ b/Examples/test-suite/java/director_ownership_runme.java
@@ -0,0 +1,42 @@
+import director_ownership.*;
+
+public class director_ownership_runme {
+
+ static {
+ try {
+ System.loadLibrary("director_ownership");
+ } 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 set_content_and_release(Container container, ContentBase content) {
+ content.swigReleaseOwnership();
+ container.set_content(content);
+ }
+
+ public static void main(String argv[]) {
+
+ Container container = new Container();
+
+ // make a content in java (cMemoryOwn true)
+ ContentBase content_java = new ContentDerived();
+
+ // make a content in c++ (cMemoryOwn true)
+ ContentBase content_cpp = director_ownership.make_content();
+
+ set_content_and_release(container, content_java);
+ if (!container.get_content().get_name().equals("ContentDerived"))
+ throw new RuntimeException("did not get ContentDerived");
+
+ // when swigReleaseOwnership() is called on content_cpp, swig tries a static_cast to director and calls the method
+ // director->swig_java_change_ownership. The content created in c++ native library is not a director, therefore a
+ // segfault may occur.
+ // With a check done using dynamic_cast this issue could be avoided.
+ set_content_and_release(container, content_cpp);
+ if (!container.get_content().get_name().equals("ContentDerived"))
+ throw new RuntimeException("did not get ContentDerived");
+ }
+}
+
diff --git a/Examples/test-suite/java/director_smartptr_runme.java b/Examples/test-suite/java/director_smartptr_runme.java
index 710ece710..53d68f995 100644
--- a/Examples/test-suite/java/director_smartptr_runme.java
+++ b/Examples/test-suite/java/director_smartptr_runme.java
@@ -33,6 +33,19 @@ public class director_smartptr_runme {
director_smartptr.Foo myFoo2 = new director_smartptr.Foo().makeFoo();
check(myFoo2.pong(), "Foo::pong();Foo::ping()");
check(director_smartptr.Foo.callPong(myFoo2), "Foo::pong();Foo::ping()");
+
+ director_smartptr.FooDerived myBarFooDerived = new director_smartptr_MyBarFooDerived();
+ check(myBarFooDerived.ping(), "director_smartptr_MyBarFooDerived.ping()");
+ check(director_smartptr.FooDerived.callPong(myBarFooDerived), "director_smartptr_MyBarFooDerived.pong();director_smartptr_MyBarFooDerived.ping()");
+ check(director_smartptr.FooDerived.callUpcall(myBarFooDerived, fooBar), "overrideDerived;Bar::Foo2::Foo2Bar()");
+
+ director_smartptr.Foo myFoo3 = myBarFoo.makeFoo();
+ myFoo3.swigReleaseOwnership();
+ myFoo3.swigTakeOwnership();
+ director_smartptr.FooDerived myBarFooDerived2 = new director_smartptr_MyBarFooDerived();
+ myBarFooDerived2.swigReleaseOwnership();
+ myBarFooDerived2.swigTakeOwnership();
+
}
}
@@ -58,3 +71,26 @@ class director_smartptr_MyBarFoo extends director_smartptr.Foo {
return new director_smartptr.Foo();
}
}
+
+class director_smartptr_MyBarFooDerived extends director_smartptr.FooDerived {
+
+ @Override
+ public String ping() {
+ return "director_smartptr_MyBarFooDerived.ping()";
+ }
+
+ @Override
+ public String pong() {
+ return "director_smartptr_MyBarFooDerived.pong();" + ping();
+ }
+
+ @Override
+ public String upcall(director_smartptr.FooBar fooBarPtr) {
+ return "overrideDerived;" + fooBarPtr.FooBarDo();
+ }
+
+ @Override
+ public director_smartptr.Foo makeFoo() {
+ return new director_smartptr.Foo();
+ }
+}
diff --git a/Examples/test-suite/java/director_string_runme.java b/Examples/test-suite/java/director_string_runme.java
index a6ed67100..67cb0fe60 100644
--- a/Examples/test-suite/java/director_string_runme.java
+++ b/Examples/test-suite/java/director_string_runme.java
@@ -19,7 +19,7 @@ public class director_string_runme {
director_string_A c = new director_string_A("hi");
for (int i=0; i<3; i++) {
s = c.call_get(i);
- if (!s.equals(new Integer(i).toString())) throw new RuntimeException("director_string_A.get(" + i + ") failed. Got:" + s);
+ if (!s.equals(Integer.valueOf(i).toString())) throw new RuntimeException("director_string_A.get(" + i + ") failed. Got:" + s);
}
director_string_B b = new director_string_B("hello");
@@ -50,7 +50,7 @@ class director_string_A extends A {
super(first);
}
public String get(int n) {
- return new Integer(n).toString();
+ return Integer.valueOf(n).toString();
}
}
diff --git a/Examples/test-suite/java/director_thread_runme.java b/Examples/test-suite/java/director_thread_runme.java
index c67d4104f..9bc4a93b5 100644
--- a/Examples/test-suite/java/director_thread_runme.java
+++ b/Examples/test-suite/java/director_thread_runme.java
@@ -30,6 +30,12 @@ class director_thread_Derived extends Foo {
}
public void do_foo() {
+ // Not all operating systems can name threads, so only test on those that can
+ if (Foo.namedThread()) {
+ String threadName = Thread.currentThread().getName();
+ if (!threadName.equals("MyThreadName"))
+ throw new RuntimeException("Unexpected thread name: " + threadName);
+ }
setVal(getVal() - 1);
}
}
diff --git a/Examples/test-suite/java/doxygen_alias_runme.java b/Examples/test-suite/java/doxygen_alias_runme.java
new file mode 100644
index 000000000..98cd97752
--- /dev/null
+++ b/Examples/test-suite/java/doxygen_alias_runme.java
@@ -0,0 +1,28 @@
+
+import doxygen_alias.*;
+import java.util.HashMap;
+
+public class doxygen_alias_runme {
+ static {
+ try {
+ System.loadLibrary("doxygen_alias");
+ } 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[])
+ {
+ CommentParser.parse("doxygen_alias");
+
+ HashMap<String, String> wantedComments = new HashMap<String, String>();
+ wantedComments.put("doxygen_alias.doxygen_alias.make_something()",
+ " A function returning something.<br>\n" +
+ " <br>\n" +
+ " @return A new object which may be null.\n" +
+ "");
+
+ System.exit(CommentParser.check(wantedComments));
+ }
+}
diff --git a/Examples/test-suite/java/doxygen_basic_notranslate_runme.java b/Examples/test-suite/java/doxygen_basic_notranslate_runme.java
new file mode 100644
index 000000000..621cc9eef
--- /dev/null
+++ b/Examples/test-suite/java/doxygen_basic_notranslate_runme.java
@@ -0,0 +1,94 @@
+
+import doxygen_basic_notranslate.*;
+import java.util.HashMap;
+
+public class doxygen_basic_notranslate_runme {
+ static {
+ try {
+ System.loadLibrary("doxygen_basic_notranslate");
+ } 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[])
+ {
+ CommentParser.parse("doxygen_basic_notranslate");
+
+ HashMap<String, String> wantedComments = new HashMap<String, String>();
+ wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function3(int)",
+ " \n" +
+ " A test for overloaded functions\n" +
+ " This is function \\b one\n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function4()",
+ " \n" +
+ " A test of some mixed tag usage\n" +
+ " \\if CONDITION\n" +
+ " This \\a code fragment shows us something \\.\n" +
+ " \\par Minuses:\n" +
+ " \\arg it's senseless\n" +
+ " \\arg it's stupid\n" +
+ " \\arg it's null\n" +
+ " \n" +
+ " \\warning This may not work as expected\n" +
+ " \n" +
+ " \\code\n" +
+ " int main() { while(true); }\n" +
+ " \\endcode\n" +
+ " \\endif\n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function()",
+ " \n" +
+ " \\brief\n" +
+ " Brief description.\n" +
+ " \n" +
+ " The comment text\n" +
+ " \\author Some author\n" +
+ " \\return Some number\n" +
+ " \\sa function2\n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function5(int)",
+ " This is a post comment. ");
+ wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function7(doxygen_basic_notranslate.SWIGTYPE_p_p_p_Shape)",
+ " \n" +
+ " Test for a parameter with difficult type\n" +
+ " (mostly for python)\n" +
+ " @param a Very strange param\n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function3(int, int)",
+ " \n" +
+ " A test for overloaded functions\n" +
+ " This is function \\b two\n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function6(int)",
+ " \n" +
+ " Test for default args\n" +
+ " @param a Some parameter, default is 42\n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function6()",
+ " \n" +
+ " Test for default args\n" +
+ " @param a Some parameter, default is 42\n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function1()",
+ " Single line comment ");
+ wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function2()",
+ " \n" +
+ " A test of a very very very very very very very very very very very very very very very very\n" +
+ " very very very very very long comment string.\n" +
+ " \n" +
+ "");
+
+ // and ask the parser to check comments for us
+ System.exit(CommentParser.check(wantedComments));
+ }
+}
diff --git a/Examples/test-suite/java/doxygen_basic_translate_runme.java b/Examples/test-suite/java/doxygen_basic_translate_runme.java
new file mode 100644
index 000000000..c64262a67
--- /dev/null
+++ b/Examples/test-suite/java/doxygen_basic_translate_runme.java
@@ -0,0 +1,100 @@
+
+import doxygen_basic_translate.*;
+import java.util.HashMap;
+
+public class doxygen_basic_translate_runme {
+ static {
+ try {
+ System.loadLibrary("doxygen_basic_translate");
+ } 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[])
+ {
+ CommentParser.parse("doxygen_basic_translate");
+
+ HashMap<String, String> wantedComments = new HashMap<String, String>();
+
+ wantedComments.put("doxygen_basic_translate.doxygen_basic_translate.function()",
+ " \n" +
+ " Brief description.\n" +
+ " \n" +
+ " The comment text.\n" +
+ " @author Some author\n" +
+ " @return Some number\n" +
+ " @see function2\n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_basic_translate.doxygen_basic_translate.function2()",
+ " A test of a very very very very very very very very very very very very very very very very \n" +
+ " very very very very very long comment string. \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_basic_translate.doxygen_basic_translate.function4()",
+ " A test of some mixed tag usage \n" +
+ " If: CONDITION {\n" +
+ " This <i>code </i>fragment shows us something . \n" +
+ " <p alt=\"Minuses: \">\n" +
+ " <li>it's senseless \n" +
+ " </li><li>it's stupid \n" +
+ " </li><li>it's null \n" +
+ " \n" +
+ " </li></p>Warning: This may not work as expected \n" +
+ " \n" +
+ " {@code \n" +
+ "int main() { while(true); } \n" +
+ "\n" +
+ "// Test blank line in code block \n" +
+ " }\n" +
+ " }\n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_basic_translate.doxygen_basic_translate.function3(int)",
+ " A test for overloaded functions \n" +
+ " This is function <b>one </b>\n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_basic_translate.doxygen_basic_translate.function5(int)",
+ " This is a post comment. \n" +
+ "");
+ wantedComments.put("doxygen_basic_translate.doxygen_basic_translate.function6(int)",
+ " Test for default args \n" +
+ " @param a Some parameter, default is 42" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_basic_translate.doxygen_basic_translate.function6()",
+ " Test for default args \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_basic_translate.doxygen_basic_translate.function7(doxygen_basic_translate.SWIGTYPE_p_p_p_Shape)",
+ " Test for a parameter with difficult type \n" +
+ " (mostly for python) \n" +
+ " @param a Very strange param \n" +
+ "");
+ wantedComments.put("doxygen_basic_translate.doxygen_basic_translate.function3(int, int)",
+ " A test for overloaded functions \n" +
+ " This is function <b>two </b>\n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_basic_translate.doxygen_basic_translate.Atan2(double, double)",
+ " Multiple parameters test.\n" +
+ " \n" +
+ " @param y Vertical coordinate.\n" +
+ " @param x Horizontal coordinate.\n" +
+ " @return Arc tangent of <code>y/x</code>.\n" +
+ "");
+ wantedComments.put("doxygen_basic_translate.doxygen_basic_translate.function8()",
+ " Test variadic function\n" +
+ "");
+
+ wantedComments.put("doxygen_basic_translate.doxygen_basic_translate.function9(int)",
+ " Test unnamed argument\n" +
+ "");
+
+ // and ask the parser to check comments for us
+ System.exit(CommentParser.check(wantedComments));
+ }
+}
diff --git a/Examples/test-suite/java/doxygen_basic_translate_style2_runme.java b/Examples/test-suite/java/doxygen_basic_translate_style2_runme.java
new file mode 100644
index 000000000..28cf2daba
--- /dev/null
+++ b/Examples/test-suite/java/doxygen_basic_translate_style2_runme.java
@@ -0,0 +1,93 @@
+
+import doxygen_basic_translate_style2.*;
+import java.util.HashMap;
+
+public class doxygen_basic_translate_style2_runme {
+ static {
+ try {
+ System.loadLibrary("doxygen_basic_translate_style2");
+ } 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[])
+ {
+ CommentParser.parse("doxygen_basic_translate_style2");
+
+ HashMap<String, String> wantedComments = new HashMap<String, String>();
+
+ wantedComments.put("doxygen_basic_translate_style2.doxygen_basic_translate_style2.function()",
+ " \n" +
+ " Brief description.\n" +
+ " \n" +
+ " The comment text.\n" +
+ " @author Some author\n" +
+ " @return Some number\n" +
+ " @see function2\n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_basic_translate_style2.doxygen_basic_translate_style2.function2()",
+ " A test of a very very very very very very very very very very very very very very very very \n" +
+ " very very very very very long comment string. \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_basic_translate_style2.doxygen_basic_translate_style2.function4()",
+ " A test of some mixed tag usage \n" +
+ " If: CONDITION {\n" +
+ " This <i>code </i>fragment shows us something . \n" +
+ " <p alt=\"Minuses: \">\n" +
+ " <li>it's senseless \n" +
+ " </li><li>it's stupid \n" +
+ " </li><li>it's null \n" +
+ " \n" +
+ " </li></p>Warning: This may not work as expected \n" +
+ " \n" +
+ " {@code \n" +
+ "int main() { while(true); } \n" +
+ "\n" +
+ "// Test blank line in code block \n" +
+ " }\n" +
+ " }\n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_basic_translate_style2.doxygen_basic_translate_style2.function3(int)",
+ " A test for overloaded functions \n" +
+ " This is function <b>one </b>\n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_basic_translate_style2.doxygen_basic_translate_style2.function5(int)",
+ " This is a post comment. \n" +
+ "");
+ wantedComments.put("doxygen_basic_translate_style2.doxygen_basic_translate_style2.function6(int)",
+ " Test for default args \n" +
+ " @param a Some parameter, default is 42" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_basic_translate_style2.doxygen_basic_translate_style2.function6()",
+ " Test for default args \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_basic_translate_style2.doxygen_basic_translate_style2.function7(doxygen_basic_translate_style2.SWIGTYPE_p_p_p_Shape)",
+ " Test for a parameter with difficult type \n" +
+ " (mostly for python) \n" +
+ " @param a Very strange param \n" +
+ "");
+ wantedComments.put("doxygen_basic_translate_style2.doxygen_basic_translate_style2.function3(int, int)",
+ " A test for overloaded functions \n" +
+ " This is function <b>two </b>\n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_basic_translate_style2.doxygen_basic_translate_style2.Atan2(double, double)",
+ " Multiple parameters test.\n" +
+ " \n" +
+ " @param y Vertical coordinate.\n" +
+ " @param x Horizontal coordinate.\n" +
+ " @return Arc tangent of <code>y/x</code>.\n" +
+ "");
+
+ // and ask the parser to check comments for us
+ System.exit(CommentParser.check(wantedComments));
+ }
+}
diff --git a/Examples/test-suite/java/doxygen_basic_translate_style3_runme.java b/Examples/test-suite/java/doxygen_basic_translate_style3_runme.java
new file mode 100644
index 000000000..a0953644a
--- /dev/null
+++ b/Examples/test-suite/java/doxygen_basic_translate_style3_runme.java
@@ -0,0 +1,93 @@
+
+import doxygen_basic_translate_style3.*;
+import java.util.HashMap;
+
+public class doxygen_basic_translate_style3_runme {
+ static {
+ try {
+ System.loadLibrary("doxygen_basic_translate_style3");
+ } 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[])
+ {
+ CommentParser.parse("doxygen_basic_translate_style3");
+
+ HashMap<String, String> wantedComments = new HashMap<String, String>();
+
+ wantedComments.put("doxygen_basic_translate_style3.doxygen_basic_translate_style3.function()",
+ " \n" +
+ " Brief description.\n" +
+ " \n" +
+ " The comment text.\n" +
+ " @author Some author\n" +
+ " @return Some number\n" +
+ " @see function2\n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_basic_translate_style3.doxygen_basic_translate_style3.function2()",
+ " A test of a very very very very very very very very very very very very very very very very \n" +
+ " very very very very very long comment string. \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_basic_translate_style3.doxygen_basic_translate_style3.function4()",
+ " A test of some mixed tag usage \n" +
+ " If: CONDITION {\n" +
+ " This <i>code </i>fragment shows us something . \n" +
+ " <p alt=\"Minuses: \">\n" +
+ " <li>it's senseless \n" +
+ " </li><li>it's stupid \n" +
+ " </li><li>it's null \n" +
+ " \n" +
+ " </li></p>Warning: This may not work as expected \n" +
+ " \n" +
+ " {@code \n" +
+ "int main() { while(true); } \n" +
+ "\n" +
+ "int testBlankLine() {} \n" +
+ " }\n" +
+ " }\n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_basic_translate_style3.doxygen_basic_translate_style3.function3(int)",
+ " A test for overloaded functions \n" +
+ " This is function <b>one </b>\n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_basic_translate_style3.doxygen_basic_translate_style3.function5(int)",
+ " This is a post comment. \n" +
+ "");
+ wantedComments.put("doxygen_basic_translate_style3.doxygen_basic_translate_style3.function6(int)",
+ " Test for default args \n" +
+ " @param a Some parameter, default is 42" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_basic_translate_style3.doxygen_basic_translate_style3.function6()",
+ " Test for default args \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_basic_translate_style3.doxygen_basic_translate_style3.function7(doxygen_basic_translate_style3.SWIGTYPE_p_p_p_Shape)",
+ " Test for a parameter with difficult type \n" +
+ " (mostly for python) \n" +
+ " @param a Very strange param \n" +
+ "");
+ wantedComments.put("doxygen_basic_translate_style3.doxygen_basic_translate_style3.function3(int, int)",
+ " A test for overloaded functions \n" +
+ " This is function <b>two </b>\n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_basic_translate_style3.doxygen_basic_translate_style3.Atan2(double, double)",
+ " Multiple parameters test.\n" +
+ " \n" +
+ " @param y Vertical coordinate.\n" +
+ " @param x Horizontal coordinate.\n" +
+ " @return Arc tangent of <code>y/x</code>.\n" +
+ "");
+
+ // and ask the parser to check comments for us
+ System.exit(CommentParser.check(wantedComments));
+ }
+}
diff --git a/Examples/test-suite/java/doxygen_code_blocks_runme.java b/Examples/test-suite/java/doxygen_code_blocks_runme.java
new file mode 100644
index 000000000..8e8373b78
--- /dev/null
+++ b/Examples/test-suite/java/doxygen_code_blocks_runme.java
@@ -0,0 +1,75 @@
+
+import doxygen_code_blocks.*;
+import java.util.HashMap;
+
+public class doxygen_code_blocks_runme {
+ static {
+ try {
+ System.loadLibrary("doxygen_code_blocks");
+ } 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[])
+ {
+ CommentParser.parse("doxygen_code_blocks");
+
+ HashMap<String, String> wantedComments = new HashMap<String, String>();
+
+ wantedComments.put("doxygen_code_blocks.doxygen_code_blocks.function()",
+ " Test for code blocks\n \n" +
+ " \n \n" +
+ " {@code \n" +
+ " simple code block \n" +
+ " }\n \n" +
+ " \n \n" +
+ " More advanced usage with C++ characters:\n \n" +
+ " {@code \n" +
+ " std::vector<int> first; // empty vector of ints \n" +
+ " std::vector<int> second (4,100); // four ints with value 100 \n" +
+ " std::vector<int> third (second.begin(),second.end()); // iterating through second \n" +
+ " std::vector<int> fourth (third); // a copy of third \n" +
+ " // the iterator constructor can also be used to construct from arrays: \n" +
+ " int myints[] = {16,2,77,29}; \n" +
+ " std::vector<int> fifth (myints, myints + sizeof(myints) / sizeof(int) ); \n" +
+ " \n" +
+ " std::cout << \"The contents of fifth are:\"; \n" +
+ " for (std::vector<int>::iterator it = fifth.begin(); it != fifth.end(); ++it) \n" +
+ " std::cout << \' \' << *it; \n" +
+ " std::cout << \'\\n\'; \n" +
+ " }\n \n" +
+ " \n \n" +
+ " A code block for C:\n \n" +
+ " {@code \n" +
+ " printf(\"hello world\"); \n" +
+ " }\n \n" +
+ " \n \n" +
+ " A code block for Java:\n \n" +
+ " {@code \n" +
+ " public class HelloWorld { \n" +
+ " public static void main(String[] args) { \n" +
+ " // Prints \"Hello, World\" to the terminal window. \n" +
+ " System.out.println(\"Hello, World\"); \n" +
+ " } \n" +
+ " } \n" +
+ " }\n \n" +
+ " \n \n" +
+ " A code block for python:\n \n" +
+ " {@code \n" +
+ " print(\'hello world\') \n" +
+ " }\n \n" +
+ " \n \n" +
+ " A python doctest example:\n \n" +
+ " {@code \n" +
+ " >>> 1 + 1 \n" +
+ " 2 \n" +
+ " } \n" +
+ " \n" +
+ "");
+
+ // and ask the parser to check comments for us
+ System.exit(CommentParser.check(wantedComments));
+ }
+}
diff --git a/Examples/test-suite/java/doxygen_ignore_runme.java b/Examples/test-suite/java/doxygen_ignore_runme.java
new file mode 100644
index 000000000..29b6e0640
--- /dev/null
+++ b/Examples/test-suite/java/doxygen_ignore_runme.java
@@ -0,0 +1,40 @@
+
+import doxygen_ignore.*;
+import java.util.HashMap;
+
+public class doxygen_ignore_runme {
+ static {
+ try {
+ System.loadLibrary("doxygen_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[])
+ {
+ CommentParser.parse("doxygen_ignore");
+
+ HashMap<String, String> wantedComments = new HashMap<String, String>();
+ wantedComments.put("doxygen_ignore.doxygen_ignore.func()",
+ " A contrived example of ignoring too many commands in one comment.<br>\n" +
+ " <br>\n" +
+ " <br>\n" +
+ " <br>\n" +
+ " <br>\n" +
+ " This is specific to <i>Java</i>.<br>\n" +
+ " <br>\n" +
+ " <br>\n" +
+ " <br>\n" +
+ " <br>\n" +
+ " Command ignored, but anything here is still included.<br>\n" +
+ " <br>\n" +
+ "\n" +
+ "\n" +
+ "\n" +
+ "");
+
+ System.exit(CommentParser.check(wantedComments));
+ }
+}
diff --git a/Examples/test-suite/java/doxygen_misc_constructs_runme.java b/Examples/test-suite/java/doxygen_misc_constructs_runme.java
new file mode 100644
index 000000000..cae2b2192
--- /dev/null
+++ b/Examples/test-suite/java/doxygen_misc_constructs_runme.java
@@ -0,0 +1,198 @@
+
+import doxygen_misc_constructs.*;
+import java.util.HashMap;
+
+public class doxygen_misc_constructs_runme {
+ static {
+ try {
+ System.loadLibrary("doxygen_misc_constructs");
+ } 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[])
+ {
+ CommentParser.parse("doxygen_misc_constructs");
+
+ HashMap<String, String> wantedComments = new HashMap<String, String>();
+
+ wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.getConnection()",
+ "\n" +
+ "\n" +
+ " This function returns connection id.\n" +
+ "\n" +
+ "");
+ wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.getAddress(doxygen_misc_constructs.SWIGTYPE_p_int, int)",
+ " Returns address of file line.\n" +
+ " \n" +
+ " @param fileName name of the file, where the source line is located\n" +
+ " @param line line number\n" +
+ " {@link Connection::getId() }<br>\n" +
+ "\n" +
+ "");
+ wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.getG_zipCode()",
+ " Tag endlink must be recognized also when it is the last token\n" +
+ " in the comment.\n" +
+ " \n" +
+ " {@link Connection::getId() }<br>\n" +
+ " {@link debugIdeTraceProfilerCoverageSample.py Python example. }\n" +
+ "\n" +
+ "");
+ wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.setG_zipCode(int)",
+ " Tag endlink must be recognized also when it is the last token\n" +
+ " in the comment.\n" +
+ "\n" +
+ " {@link Connection::getId() }<br>\n" +
+ " {@link debugIdeTraceProfilerCoverageSample.py Python example. }\n" +
+ "\n" +
+ "");
+ wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.getG_counter()",
+ " Tag endlink must be recognized also when followed by nonspace character.\n" +
+ "\n" +
+ " {@link Connection::getId() }<br>\n" +
+ "\n" +
+ "");
+ wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.waitTime(int)",
+ " Determines how long the <code>isystem.connect</code> should wait for running\n" +
+ " instances to respond. Only one of <code>lfWaitXXX</code> flags from IConnect::ELaunchFlags\n" +
+ " may be specified.\n" +
+ "\n" +
+ "");
+ wantedComments.put("doxygen_misc_constructs.CConnectionConfig",
+ " This class contains information for connection to winIDEA. Its methods\n" +
+ " return reference to self, so we can use it like this:\n" +
+ " <pre>\n" +
+ " CConnectionConfig config = new CConnectionConfig();\n" +
+ " config.discoveryPort(5534).dllPath(\"C:\\\\myWinIDEA\\\\connect.dll\").id(\"main\");\n" +
+ " </pre>\n" +
+ "\n" +
+ " All parameters are optional. Set only what is required, default values are\n" +
+ " used for unspecified parameters.\n" +
+ " <p>\n" +
+ "\n" +
+ " {@link advancedWinIDEALaunching.py Python example. }<br>\n" +
+ "\n" +
+ "");
+ wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.getAddress(doxygen_misc_constructs.SWIGTYPE_p_int, int, boolean)",
+ " Returns address of file line.\n" +
+ "\n" +
+ " @param fileName name of the file, where the source line is located\n" +
+ " @param line line number\n" +
+ " @param isGetSize if set, for every object location both address and size are returned\n" +
+ "\n" +
+ " {@link Connection::getId() }<br>\n" +
+ "\n" +
+ "");
+ wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.setG_counter(char)",
+ " Tag endlink must be recognized also when followed by nonspace character.\n" +
+ "\n" +
+ " {@link Connection::getId() }<br>\n" +
+ "\n" +
+ "");
+
+ wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum",
+ " Class description.\n" +
+ "\n");
+
+ wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.ENested",
+ " Enum description.\n" +
+ "\n");
+
+ wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.ENested.ONE",
+ " desc of one\n");
+
+ wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.ENested.TWO",
+ " desc of two\n");
+
+ wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.ENested.THREE",
+ " desc of three\n");
+
+ wantedComments.put("doxygen_misc_constructs.StructWithReturnComment",
+ " @return This is a bad place for this tag, but it should be ignored.");
+
+ wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.showList()",
+" An example of a list in a documentation comment.<br>\n" +
+" <br>\n" +
+" - The first item of the list.<br>\n" +
+" - The second list item, on<br>\n" +
+" several indented lines,<br>\n" +
+" showing that the indentation<br>\n" +
+" is preserved.<br>\n" +
+" - And the final list item after it.<br>\n" +
+" <br>\n" +
+" And this is not a list item any more.\n" +
+ "");
+ wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.isNoSpaceValidA()",
+ " This comment without space after '*' is valid in Doxygen.\n" +
+ "\n" +
+ "");
+
+ wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.isNoSpaceValidB()",
+ " .This comment without space after '*' is valid in Doxygen.\n" +
+ "\n" +
+ "");
+
+ wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.backslashA()",
+ " Backslash following<code>word</code> is a valid doxygen command. Output contains\n" +
+ " 'followingword' with 'word' in code font.\n" +
+ "\n" +
+ "");
+
+ wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.backslashB()",
+ " Doxy command without trailing space is ignored - nothing appears\n" +
+ " on output. Standalone \\ and '\\' get to output.\n" +
+ " Standalone @ and '@' get to output.\n" +
+ " Commands \"in quoted \\b strings are treated as plain text\".\n" +
+ " Commands not recognized by Doxygen are ignored.\n" +
+ " Backslashes in DOS paths d:and words\n" +
+ " following them do not appear on output, we must quote them with\n" +
+ " double quotes: \"d:\\xyz\\qwe\\myfile\", \"@something\". Single quotes do not help:\n" +
+ " 'd:'. Escaping works: d:\\xyz\\qwe\\myfile. Unix\n" +
+ " paths of course have no such problems: /xyz/qwe/myfile\n" +
+ " Commands for escaped symbols:\n" +
+ " $ @ \\ &amp; ~ &lt; &gt; # % &quot; . :: @text ::text" +
+ "\n");
+
+ wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.backslashC()",
+ " Backslash e at end of <i>line</i> froze SWIG\n" +
+ " <i>with</i> old comment parser.\n" +
+ " @see MyClass#fun(char,float)\n" +
+ "");
+
+ wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.cycle(int, java.lang.String)",
+ " The next line contains expression:\n" +
+ " <pre>\n" +
+ " ['retVal &lt; 10', 'g_counter == 23 &amp;&amp; g_mode &amp; 3']\n" +
+ " </pre>\n" +
+ "\n" +
+ " Both words should be emphasized <b>isystem.connect</b>.\n" +
+ " But not the last period. For <b>example</b>, comma should not be emphasized.\n" +
+ " Similar <b>for</b>: double colon.\n" +
+ "\n" +
+ " Spaces at the start of line should be taken into account:\n" +
+ " @param id used as prefix in log\n" +
+ " statements. The default value is empty string, which is OK if\n" +
+ " there is only one app. instance. Example:\n" +
+ " <pre>\n" +
+ " ctrl.setBP(\"func1\");\n" +
+ " </pre>\n" +
+ " If we set the id to <code>main_</code>, we get:\n" +
+ " <pre>\n" +
+ " main_ctrl.setBP(\"func1\");\n" +
+ " </pre>\n" +
+ "\n" +
+ " @param fileName name of the log file\n");
+
+ wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.doc_ends_with_quote()",
+ "This doc comment ends with a quote: \"and that's ok\"");
+
+ wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.doc_with_triple_quotes()",
+ "This comment contains embedded triple-quoted string:\n" +
+ "\"\"\"How quaint\"\"\"");
+
+ // and ask the parser to check comments for us
+ System.exit(CommentParser.check(wantedComments));
+ }
+}
diff --git a/Examples/test-suite/java/doxygen_nested_class_runme.java b/Examples/test-suite/java/doxygen_nested_class_runme.java
new file mode 100644
index 000000000..e9d1a068e
--- /dev/null
+++ b/Examples/test-suite/java/doxygen_nested_class_runme.java
@@ -0,0 +1,40 @@
+import doxygen_nested_class.*;
+import java.util.HashMap;
+
+public class doxygen_nested_class_runme {
+ static {
+ try {
+ System.loadLibrary("doxygen_nested_class");
+ } 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[])
+ {
+ CommentParser.parse("doxygen_nested_class");
+
+ HashMap<String, String> wantedComments = new HashMap<String, String>();
+
+ wantedComments.put("doxygen_nested_class.DoxOuter()",
+ " DoxOuter constructor ");
+ wantedComments.put("doxygen_nested_class.DoxOuter.DoxInner",
+ " DoxInner class description ");
+ wantedComments.put("doxygen_nested_class.DoxOuter.DoxInner()",
+ " DoxInner constructor ");
+ wantedComments.put("doxygen_nested_class.DoxOuter.DoxInner.setDoxInt(int)",
+ " doxInt variable ");
+ wantedComments.put("doxygen_nested_class.DoxOuter.DoxInner.getDoxInt()",
+ " doxInt variable ");
+ wantedComments.put("doxygen_nested_class.DoxOuter.DoxInner.doxMethod()",
+ " doxMethod description ");
+ wantedComments.put("doxygen_nested_class.DoxOuter.DoxInner.doxStaticMethod()",
+ " doxStaticMethod description ");
+ wantedComments.put("doxygen_nested_class.DoxOuter.DoxInner.doxShort",
+ " doxShort const variable ");
+
+ // and ask the parser to check comments for us
+ System.exit(CommentParser.check(wantedComments));
+ }
+}
diff --git a/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java b/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java
new file mode 100644
index 000000000..6b1e2b08e
--- /dev/null
+++ b/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java
@@ -0,0 +1,58 @@
+
+import doxygen_parsing_enums_proper.*;
+import java.util.HashMap;
+
+public class doxygen_parsing_enums_proper_runme {
+ static {
+ try {
+ System.loadLibrary("doxygen_parsing_enums_proper");
+ } 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[])
+ {
+ CommentParser.parse("doxygen_parsing_enums_proper");
+
+ HashMap<String, String> wantedComments = new HashMap<String, String>();
+
+ wantedComments.put("doxygen_parsing_enums_proper.SomeAnotherEnum2.SOME_ITEM_10",
+ "Post comment for the first item \n" +
+ "");
+ wantedComments.put("doxygen_parsing_enums_proper.SomeAnotherEnum.SOME_ITEM_1",
+ " The comment for the first item \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_parsing_enums_proper.SomeAnotherEnum",
+ " Testing comments before enum items \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_parsing_enums_proper.SomeAnotherEnum2.SOME_ITEM_30",
+ "Post comment for the third item \n" +
+ "");
+ wantedComments.put("doxygen_parsing_enums_proper.SomeAnotherEnum2",
+ " Testing comments after enum items \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_parsing_enums_proper.SomeAnotherEnum.SOME_ITEM_3",
+ " The comment for the third item \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_parsing_enums_proper.SomeAnotherEnum.SOME_ITEM_2",
+ " The comment for the second item \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_parsing_enums_proper.SomeAnotherEnum2.SOME_ITEM_20",
+ "Post comment for the second item \n" +
+ "");
+ wantedComments.put("doxygen_parsing_enums_proper.SomeEnumWithTrailingComma.SOME_ITEM_100",
+ "Post comment after comma.");
+ wantedComments.put("doxygen_parsing_enums_proper.SomeEnumWithTrailingComma.SOME_ITEM_200",
+ "Post comment after last comma.");
+
+ // and ask the parser to check comments for us
+ System.exit(CommentParser.check(wantedComments));
+ }
+}
diff --git a/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java b/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java
new file mode 100644
index 000000000..1e0dd74ee
--- /dev/null
+++ b/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java
@@ -0,0 +1,50 @@
+
+import doxygen_parsing_enums_simple.*;
+import java.util.HashMap;
+
+public class doxygen_parsing_enums_simple_runme {
+ static {
+ try {
+ System.loadLibrary("doxygen_parsing_enums_simple");
+ } 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[])
+ {
+ CommentParser.parse("doxygen_parsing_enums_simple");
+
+ HashMap<String, String> wantedComments = new HashMap<String, String>();
+
+ wantedComments.put("doxygen_parsing_enums_simple.doxygen_parsing_enums_simpleConstants.SOME_ITEM_30",
+ "Post comment for the third item \n" +
+ "");
+ wantedComments.put("doxygen_parsing_enums_simple.doxygen_parsing_enums_simpleConstants.SOME_ITEM_3",
+ " The comment for the third item \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_parsing_enums_simple.doxygen_parsing_enums_simpleConstants.SOME_ITEM_2",
+ " The comment for the second item \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_parsing_enums_simple.doxygen_parsing_enums_simpleConstants.SOME_ITEM_10",
+ "Post comment for the first item \n" +
+ "");
+ wantedComments.put("doxygen_parsing_enums_simple.doxygen_parsing_enums_simpleConstants.SOME_ITEM_20",
+ "Post comment for the second item \n" +
+ "");
+ wantedComments.put("doxygen_parsing_enums_simple.doxygen_parsing_enums_simpleConstants.SOME_ITEM_1",
+ " The comment for the first item \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_parsing_enums_simple.doxygen_parsing_enums_simpleConstants.SOME_ITEM_100",
+ "Post comment after comma.");
+ wantedComments.put("doxygen_parsing_enums_simple.doxygen_parsing_enums_simpleConstants.SOME_ITEM_200",
+ "Post comment after last comma.");
+
+ // and ask the parser to check comments for us
+ System.exit(CommentParser.check(wantedComments));
+ }
+}
diff --git a/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java b/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java
new file mode 100644
index 000000000..7cf3b17ef
--- /dev/null
+++ b/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java
@@ -0,0 +1,59 @@
+
+import doxygen_parsing_enums_typesafe.*;
+import java.util.HashMap;
+
+public class doxygen_parsing_enums_typesafe_runme {
+ static {
+ try {
+ System.loadLibrary("doxygen_parsing_enums_typesafe");
+ } 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[])
+ {
+ CommentParser.parse("doxygen_parsing_enums_typesafe");
+
+ HashMap<String, String> wantedComments = new HashMap<String, String>();
+
+ wantedComments.put("doxygen_parsing_enums_typesafe.SomeAnotherEnum.SOME_ITEM_1",
+ " The comment for the first item \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_parsing_enums_typesafe.SomeAnotherEnum2",
+ " Testing comments after enum items \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_parsing_enums_typesafe.SomeAnotherEnum.SOME_ITEM_2",
+ " The comment for the second item \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_parsing_enums_typesafe.SomeAnotherEnum2.SOME_ITEM_20",
+ "Post comment for the second item \n" +
+ "");
+ wantedComments.put("doxygen_parsing_enums_typesafe.SomeAnotherEnum",
+ " Testing comments before enum items \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_parsing_enums_typesafe.SomeAnotherEnum2.SOME_ITEM_10",
+ "Post comment for the first item \n" +
+ "");
+ wantedComments.put("doxygen_parsing_enums_typesafe.SomeAnotherEnum.SOME_ITEM_3",
+ " The comment for the third item \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_parsing_enums_typesafe.SomeAnotherEnum2.SOME_ITEM_30",
+ "Post comment for the third item \n" +
+ "");
+ wantedComments.put("doxygen_parsing_enums_typesafe.SomeEnumWithTrailingComma.SOME_ITEM_100",
+ "Post comment after comma.");
+ wantedComments.put("doxygen_parsing_enums_typesafe.SomeEnumWithTrailingComma.SOME_ITEM_200",
+ "Post comment after last comma.");
+
+
+ // and ask the parser to check comments for us
+ System.exit(CommentParser.check(wantedComments));
+ }
+}
diff --git a/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java b/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java
new file mode 100644
index 000000000..3a41fe56f
--- /dev/null
+++ b/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java
@@ -0,0 +1,58 @@
+
+import doxygen_parsing_enums_typeunsafe.*;
+import java.util.HashMap;
+
+public class doxygen_parsing_enums_typeunsafe_runme {
+ static {
+ try {
+ System.loadLibrary("doxygen_parsing_enums_typeunsafe");
+ } 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[])
+ {
+ CommentParser.parse("doxygen_parsing_enums_typeunsafe");
+
+ HashMap<String, String> wantedComments = new HashMap<String, String>();
+
+ wantedComments.put("doxygen_parsing_enums_typeunsafe.SomeAnotherEnum.SOME_ITEM_2",
+ " The comment for the second item \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_parsing_enums_typeunsafe.SomeAnotherEnum.SOME_ITEM_3",
+ " The comment for the third item \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_parsing_enums_typeunsafe.SomeAnotherEnum.SOME_ITEM_1",
+ " The comment for the first item \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_parsing_enums_typeunsafe.SomeAnotherEnum2.SOME_ITEM_20",
+ "Post comment for the second item \n" +
+ "");
+ wantedComments.put("doxygen_parsing_enums_typeunsafe.SomeAnotherEnum",
+ " Testing comments before enum items \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_parsing_enums_typeunsafe.SomeAnotherEnum2",
+ " Testing comments after enum items \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_parsing_enums_typeunsafe.SomeAnotherEnum2.SOME_ITEM_30",
+ "Post comment for the third item \n" +
+ "");
+ wantedComments.put("doxygen_parsing_enums_typeunsafe.SomeAnotherEnum2.SOME_ITEM_10",
+ "Post comment for the first item \n" +
+ "");
+ wantedComments.put("doxygen_parsing_enums_typeunsafe.SomeEnumWithTrailingComma.SOME_ITEM_100",
+ "Post comment after comma.");
+ wantedComments.put("doxygen_parsing_enums_typeunsafe.SomeEnumWithTrailingComma.SOME_ITEM_200",
+ "Post comment after last comma.");
+
+ // and ask the parser to check comments for us
+ System.exit(CommentParser.check(wantedComments));
+ }
+}
diff --git a/Examples/test-suite/java/doxygen_parsing_runme.java b/Examples/test-suite/java/doxygen_parsing_runme.java
new file mode 100644
index 000000000..29e524f78
--- /dev/null
+++ b/Examples/test-suite/java/doxygen_parsing_runme.java
@@ -0,0 +1,139 @@
+
+import doxygen_parsing.*;
+import java.util.HashMap;
+
+public class doxygen_parsing_runme {
+ static {
+ try {
+ System.loadLibrary("doxygen_parsing");
+ } 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[])
+ {
+ CommentParser.parse("doxygen_parsing");
+
+ HashMap<String, String> wantedComments = new HashMap<String, String>();
+
+ wantedComments.put("doxygen_parsing.SomeAnotherClass",
+ " SomeAnotherClass description");
+ wantedComments.put("doxygen_parsing.SomeAnotherClass(int)",
+ " First overloaded constructor.");
+ wantedComments.put("doxygen_parsing.SomeAnotherClass(java.lang.String)",
+ " Second overloaded constructor.");
+ wantedComments.put("doxygen_parsing.SomeAnotherClass.getClassAttr()",
+ " The class attribute comment \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_parsing.SomeAnotherClass.setClassAttr3(int)",
+ "The class attribute post-comment with details \n" +
+ "");
+ wantedComments.put("doxygen_parsing.SomeAnotherStruct.setStructAttr3(int)",
+ "The struct attribute post-comment with details \n" +
+ "");
+ wantedComments.put("doxygen_parsing.SomeAnotherClass.classMethodExtended2(int, int)",
+ " The class method with parameter \n" +
+ " \n" +
+ " @param a Parameter a \n" +
+ " @param b Parameter b \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_parsing.SomeStruct",
+ " The struct comment \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_parsing.SomeStruct.setWidth(int)",
+ "**immutable** image width in pixels \n" +
+ "");
+ wantedComments.put("doxygen_parsing.SomeStruct.getWidth()",
+ "**immutable** image width in pixels \n" +
+ "");
+ wantedComments.put("doxygen_parsing.doxygen_parsing.setSomeVar(int)",
+ " The var comment \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_parsing.SomeAnotherStruct.structMethod()",
+ " The struct method comment \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_parsing.doxygen_parsing.someFunction()",
+ " The function comment \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_parsing.SomeAnotherClass.classMethodExtended(int, int)",
+ " The class method with parameter \n" +
+ " \n" +
+ " @param a Parameter a \n" +
+ " @param b Parameter b \n" +
+ "");
+ wantedComments.put("doxygen_parsing.SomeAnotherClass.setClassAttr(int)",
+ " The class attribute comment \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_parsing.SomeAnotherStruct.structMethodExtended(int, int)",
+ " The struct method with parameter \n" +
+ " \n" +
+ " @param a Parameter a \n" +
+ " @param b Parameter b \n" +
+ "");
+ wantedComments.put("doxygen_parsing.SomeAnotherStruct.getStructAttr()",
+ " The struct attribute comment \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_parsing.SomeClass",
+ " The class comment \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_parsing.SomeAnotherStruct.getStructAttr3()",
+ "The struct attribute post-comment with details \n" +
+ "");
+ wantedComments.put("doxygen_parsing.doxygen_parsing.getSomeVar()",
+ " The var comment \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_parsing.SomeAnotherStruct.setStructAttr2(int)",
+ "The struct attribute post-comment \n" +
+ "");
+ wantedComments.put("doxygen_parsing.SomeAnotherClass.getClassAttr2()",
+ "The class attribute post-comment \n" +
+ "");
+ wantedComments.put("doxygen_parsing.SomeAnotherStruct.getStructAttr2()",
+ "The struct attribute post-comment \n" +
+ "");
+ wantedComments.put("doxygen_parsing.SomeAnotherStruct.setStructAttr(int)",
+ " The struct attribute comment \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_parsing.SomeEnum",
+ " The enum comment \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_parsing.SomeAnotherClass.getClassAttr3()",
+ "The class attribute post-comment with details \n" +
+ "");
+ wantedComments.put("doxygen_parsing.SomeAnotherClass.classMethod()",
+ " The class method comment.<br>\n" +
+ " <br>\n" +
+ " {@link SomeAnotherClass#classMethodExtended(int,int) a link text }\n" +
+ "");
+ wantedComments.put("doxygen_parsing.SomeAnotherStruct.structMethodExtended2(int, int)",
+ " The struct method with parameter \n" +
+ " \n" +
+ " @param a Parameter a \n" +
+ " @param b Parameter b \n" +
+ " \n" +
+ "");
+ wantedComments.put("doxygen_parsing.SomeAnotherClass.setClassAttr2(int)",
+ "The class attribute post-comment \n" +
+ "");
+ wantedComments.put("doxygen_parsing.doxygen_parsingConstants.CONSTANT_VALUE",
+ "The constant comment \n" +
+ "");
+
+ // and ask the parser to check comments for us
+ System.exit(CommentParser.check(wantedComments));
+ }
+}
diff --git a/Examples/test-suite/java/doxygen_translate_all_tags_runme.java b/Examples/test-suite/java/doxygen_translate_all_tags_runme.java
new file mode 100644
index 000000000..56272bf84
--- /dev/null
+++ b/Examples/test-suite/java/doxygen_translate_all_tags_runme.java
@@ -0,0 +1,154 @@
+
+import doxygen_translate_all_tags.*;
+import java.util.HashMap;
+
+public class doxygen_translate_all_tags_runme {
+ static {
+ try {
+ System.loadLibrary("doxygen_translate_all_tags");
+ } 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[])
+ {
+ CommentParser.parse("doxygen_translate_all_tags");
+
+ HashMap<String, String> wantedComments = new HashMap<String, String>();
+
+ wantedComments.put("doxygen_translate_all_tags.doxygen_translate_all_tags.func01(int)",
+ " <i>Hello </i>\n\n\n" +
+ " <a id=\"theAnchor\"></a>\n\n\n" +
+ " <li>some list item</li>\n\n" +
+ " This is attention!\n" +
+ " You were warned!\n" +
+ " @author lots of them\n" +
+ " @author Zubr\n\n" +
+ " <b>boldword</b>\n\n" +
+ " Some brief description,\n" +
+ " extended to many lines.\n\n" +
+ " Not everything works right now...\n" +
+ " <code>codeword</code>\n\n\n\n\n\n" +
+ " <i>citationword</i>\n" +
+ " {@code some test code }\n\n" +
+ " Code immediately following text. Pydoc translation must add an\n" +
+ " empty line before:\n" +
+ " {@code more test code }");
+
+ wantedComments.put("doxygen_translate_all_tags.doxygen_translate_all_tags.func02(int)",
+ " Conditional comment: SOMECONDITION \n" +
+ " Some conditional comment \n" +
+ " End of conditional comment.\n" +
+ " Copyright: some copyright \n" +
+ " 1970 - 2012 \n" +
+ " @deprecated Now use another function \n" +
+ " This is very large \n" +
+ " and detailed description of some thing \n");
+
+ wantedComments.put("doxygen_translate_all_tags.doxygen_translate_all_tags.func03(int)",
+ " Comment for <b>func03()</b>.\n" +
+ " <i>italicword </i>\n" +
+ " <i>emphazedWord </i>\n" +
+ " @ example someFile.txt\n" +
+ " Some details on using the example");
+
+ wantedComments.put("doxygen_translate_all_tags.doxygen_translate_all_tags.func04(int)",
+ " @exception SuperError \n" +
+ " \\sqrt{(x_2-x_1)^2+(y_2-y_1)^2} \n" +
+ " \\sqrt{(x_2-x_1)^2+(y_2-y_1)^2} \n" +
+ " \\sqrt{(x_2-x_1)^2+(y_2-y_1)^2} \n\n" +
+ "Math immediately following text. Pydoc translation must add an\n" +
+ "empty line before:\n\n" +
+ " \\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}\n" +
+ " This will only appear in hmtl \n");
+
+ wantedComments.put("doxygen_translate_all_tags.doxygen_translate_all_tags.func05(int)",
+ " If: ANOTHERCONDITION {\n" +
+ " First part of comment \n" +
+ " If: SECONDCONDITION {\n" +
+ " Nested condition text \n" +
+ " }Else if: THIRDCONDITION {\n" +
+ " The third condition text \n" +
+ " }Else: {The last text block \n" +
+ " }\n" +
+ " }Else: {Second part of comment \n" +
+ " If: CONDITION {\n" +
+ " Second part extended \n" +
+ " }\n" +
+ " }\n" +
+ " If not: SOMECONDITION {\n" +
+ " This is printed if not \n" +
+ " }\n" +
+ " <img src=testImage.bmp alt=\"Hello, world!\" />\n" +
+ " Some text \n" +
+ " describing invariant. \n");
+
+ wantedComments.put("doxygen_translate_all_tags.doxygen_translate_all_tags.func06(int)",
+ " Comment for <b>func06()</b>.\n" +
+ " This will only appear in LATeX \n" +
+ " <ul> \n" +
+ " <li>Some unordered list \n" +
+ " </li><li>With lots of items \n" +
+ " </li><li>lots of lots of items \n" +
+ " </li></ul> \n" +
+ " {@link someMember Some description follows} with text after\n" +
+ " This will only appear in man\n");
+
+ wantedComments.put("doxygen_translate_all_tags.doxygen_translate_all_tags.func07(int, int, int, int)",
+ " Comment for <b>func07()</b>.\n" +
+ " Note: Here \n" +
+ " is the note! \n" +
+ " This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.\n" +
+ " <code>someword </code>\n" +
+ " @package superPackage \n" +
+ " <p alt=\"The paragraph title \">\n" +
+ " The paragraph text. \n" +
+ " Maybe even multiline \n" +
+ " </p>\n" +
+ " @param a the first param\n" +
+ " @param b parameter with intent(in)\n" +
+ " @param c parameter with intent(out)\n" +
+ " @param d parameter with intent(in,out)\n");
+
+ wantedComments.put("doxygen_translate_all_tags.doxygen_translate_all_tags.func08(int)",
+ "<a id=\"someAnchor\"></a>\n" +
+ "Text after anchor.\n" +
+ "<a href=\"#someAnchor\">Anchor description</a>\n" +
+ "<a href=\"#someAnchor\">someAnchor</a> not quoted text is not part of ref tag\n" +
+ "<a href=\"#someAnchor\">someAnchor</a>\n" +
+ " Remarks: Some remark text \n" +
+ " Remarks: Another remarks section \n" +
+ " @return Whatever \n" +
+ " @return it \n" +
+ " @return may return \n");
+
+ wantedComments.put("doxygen_translate_all_tags.doxygen_translate_all_tags.func09(int)",
+ " This will only appear in RTF \n" +
+ " @see someOtherMethod \n" +
+ " @see function \n" +
+ " Same as \n" +
+ " brief description \n" +
+ " @since version 0.0.0.1 \n" +
+ " @throws superException \n" +
+ " @throws RuntimeError \n");
+
+ wantedComments.put("doxygen_translate_all_tags.doxygen_translate_all_tags.func10(int, float)",
+ " TODO: Some very important task \n" +
+ " @param b B is mentioned again... \n" +
+ " {@literal \n" +
+ "very long \n" +
+ "text with tags <sometag> \n" +
+ " }\n" +
+ " @version 0.0.0.2 \n" +
+ " Warning: This is senseless! \n" +
+ " This will only appear in XML \n" +
+ " Here goes test of symbols: \n" +
+ " $ @ \\ &amp; ~ &lt; &gt; # % &quot; . :: \n" +
+ " And here goes simple text \n" +
+ "");
+ // and ask the parser to check comments for us
+ System.exit(CommentParser.check(wantedComments));
+ }
+}
diff --git a/Examples/test-suite/java/doxygen_translate_links_runme.java b/Examples/test-suite/java/doxygen_translate_links_runme.java
new file mode 100644
index 000000000..afee4eac6
--- /dev/null
+++ b/Examples/test-suite/java/doxygen_translate_links_runme.java
@@ -0,0 +1,61 @@
+
+import doxygen_translate_links.*;
+import java.util.HashMap;
+
+public class doxygen_translate_links_runme {
+ static {
+ try {
+ System.loadLibrary("doxygen_translate_links");
+ } 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[])
+ {
+ CommentParser.parse("doxygen_translate_links");
+
+ HashMap<String, String> wantedComments = new HashMap<String, String>();
+
+
+ wantedComments.put("doxygen_translate_links.doxygen_translate_links.function()",
+ " \n" +
+ " Testing typenames converting in @ link \n" +
+ " \n" +
+ " {@link superFunc(int,String) \n" +
+ " Test for std_string member \n" +
+ " }\n" +
+ " \n" +
+ " {@link superFunc(int,int,SWIGTYPE_p_void) \n" +
+ " Test for simple types \n" +
+ " }\n" +
+ " \n" +
+ " {@link superFunc(SWIGTYPE_p_p_Shape) \n" +
+ " Test for custom types \n" +
+ " }\n" +
+ " \n" +
+ " {@link superFunc(SWIGTYPE_p_p_p_int) \n" +
+ " Test for complex types \n" +
+ " }\n" +
+ " \n" +
+ " same works for 'See also:' links: \n" +
+ " \n" +
+ " @see superFunc(int,String)\n" +
+ " @see superFunc(int,int,SWIGTYPE_p_void)\n" +
+ " @see superFunc(SWIGTYPE_p_p_Shape)\n" +
+ " @see superFunc(SWIGTYPE_p_p_p_int)\n" +
+ " \n" +
+ " some failing params: \n" +
+ " \n" +
+ " @see superFunc() \n" +
+ " @see superFunc() \n" +
+ " @see superFunc() \n" +
+ " \n" +
+ " \n" +
+ "");
+
+ // and ask the parser to check comments for us
+ System.exit(CommentParser.check(wantedComments));
+ }
+} \ No newline at end of file
diff --git a/Examples/test-suite/java/doxygen_translate_runme.java b/Examples/test-suite/java/doxygen_translate_runme.java
new file mode 100644
index 000000000..b049a6466
--- /dev/null
+++ b/Examples/test-suite/java/doxygen_translate_runme.java
@@ -0,0 +1,271 @@
+
+import doxygen_translate.*;
+import java.util.HashMap;
+import java.util.Map;
+
+public class doxygen_translate_runme {
+ static {
+ try {
+ System.loadLibrary("doxygen_translate");
+ } 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[])
+ {
+ CommentParser.parse("doxygen_translate");
+
+ Map<String, String> wantedComments = new HashMap<String, String>();
+
+ wantedComments.put("doxygen_translate.doxygen_translate.function(int, float)",
+ " <i>Hello </i>\n" +
+ " \n" +
+ " <li>some list item</li>\n" +
+ " \n" +
+ " @author lots of them \n" +
+ " \n" +
+ " @author Zubr \n" +
+ " \n" +
+ " <b>boldword </b>\n" +
+ " \n" +
+ " <code>codeword </code>\n" +
+ " \n" +
+ " <i>citationword </i>\n" +
+ " \n" +
+ " {@code some test code }\n" +
+ " \n" +
+ " Conditional comment: SOMECONDITION \n" +
+ " Some conditional comment \n" +
+ " End of conditional comment.\n" +
+ " \n" +
+ " Copyright: some copyright \n" +
+ " \n" +
+ " @deprecated Now use another function \n" +
+ " \n" +
+ " <i>italicword </i>\n" +
+ " \n" +
+ " @ example someFile.txt\n" +
+ " Some details on using the example\n" +
+ " \n" +
+ " @exception SuperError \n" +
+ " \n" +
+ " If: ANOTHERCONDITION {\n" +
+ " First part of comment \n" +
+ " If: SECONDCONDITION {\n" +
+ " Nested condition text}\n" +
+ " Else if: THIRDCONDITION {\n" +
+ " The third condition text}\n" +
+ " Else: {The last text block}}\n" +
+ " \n" +
+ " Else: {Second part of comment \n" +
+ " If: CONDITION {\n" +
+ " Second part extended}}\n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " If not: SOMECONDITION {\n" +
+ " This is printed if not}\n" +
+ " \n" +
+ " \n" +
+ " <img src=testImage.bmp alt=\"Hello, world!\"/>\n" +
+ " \n" +
+ " <ul> \n" +
+ " \n" +
+ " <li>Some unordered list</li>\n" +
+ " <li>With lots of items</li>\n" +
+ " <li>lots of lots of items</li>\n" +
+ " \n" +
+ " </ul> \n" +
+ " \n" +
+ " {@link someMember Some description follows }\n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " Note: Here \n" +
+ " is the note! \n" +
+ " \n" +
+ " This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.\n" +
+ " \n" +
+ " <code>someword </code>\n" +
+ " \n" +
+ " @package superPackage \n" +
+ " \n" +
+ " <p alt=\"The paragraph title \">\n" +
+ " The paragraph text. \n" +
+ " Maybe even multiline</p>\n" +
+ " \n" +
+ " @param a the first param \n" +
+ " \n" +
+ " Remarks: Some remark text \n" +
+ " \n" +
+ " Remarks: Another remarks section \n" +
+ " \n" +
+ " @return Whatever \n" +
+ " \n" +
+ " @return it \n" +
+ " \n" +
+ " @return may return \n" +
+ " \n" +
+ " @see someOtherMethod \n" +
+ " \n" +
+ " @see function \n" +
+ " \n" +
+ " @since version 0.0.0.1 \n" +
+ " \n" +
+ " @throws superException \n" +
+ " \n" +
+ " @throws RuntimeError \n" +
+ " \n" +
+ " TODO: Some very important task \n" +
+ " \n" +
+ " @param b B is mentioned again... \n" +
+ " \n" +
+ " {@literal \n" +
+ "very long \n" +
+ "text with tags <sometag> \n" +
+ " }\n" +
+ " \n" +
+ " @version 0.0.0.2 \n" +
+ " \n" +
+ " Warning: This is senseless! \n" +
+ " \n" +
+ " Here goes test of symbols: \n" +
+ " $ @ \\ &amp; ~ &lt; &gt; # % &quot; . :: \n" +
+ " \n" +
+ " And here goes simple text \n" +
+ " \n" +
+ "");
+
+ wantedComments.put("doxygen_translate.doxygen_translate.htmlFunction(int, float)",
+ " Test for html tags. See Doxygen doc for list of tags recognized by Doxygen. \n" +
+ " \n" +
+ " <a href=\"http://acme.com/index.html\">This is link</a> \n" +
+ " <b>bold</b> \n" +
+ " <blockquote cite=\"http://www.worldwildlife.org/who/index.html\"> \n" +
+ " Quotation block. \n" +
+ " </blockquote> \n" +
+ " <br> \n" +
+ " <center>center</center> \n" +
+ " <code>this is code</code> \n" +
+ "\n" +
+ " <dl>\n" +
+ " <dt>Starts an item title.</dt>\n" +
+ " <dd>Starts an item description.</dd>\n" +
+ " </dl>\n" +
+ "\n" +
+ " <dfn> Starts a piece of text displayed in a typewriter font. \n" +
+ " </dfn> \n" +
+ " <div> Starts a section with a specific style (HTML only) \n" +
+ " </div> \n" +
+ " <em> Starts a piece of text displayed in an italic font.</em> \n" +
+ "\n" +
+ " <form> 'Form' does not generate any output. \n" +
+ " </form> \n" +
+ " <hr> \n" +
+ " <h1> Heading 1 \n" +
+ " </h1> \n" +
+ " <h2> Heading 2 \n" +
+ " </h2> \n" +
+ " <h3> Heading 3 \n" +
+ " </h3> \n" +
+ " <i>Starts a piece of text displayed in an italic font.</i> \n" +
+ " <input>Input tag. \n" +
+ " \n" +
+ " <img src=\"slika.png\"> \n" +
+ " <meta>Meta tag. \n" +
+ " <multicol>Multicol is ignored by doxygen. \n" +
+ " </multicol> \n" +
+ " \n" +
+ " <ol> \n" +
+ " <li>List item 1.</li> \n" +
+ " <li>List item 2.</li> \n" +
+ " </ol> \n" +
+ " \n" +
+ " <p> Starts a new paragraph. \n" +
+ " </p> \n" +
+ " <pre> Starts a preformatted fragment. \n" +
+ " </pre> \n" +
+ " <small> Starts a section of text displayed in a smaller font. \n" +
+ " </small> \n" +
+ " <span> Starts an inline text fragment with a specific style.</span> \n" +
+ " \n" +
+ " <strong> Starts a section of bold text.</strong> \n" +
+ " <sub> Starts a piece of text displayed in subscript.</sub> \n" +
+ " <sup> Starts a piece of text displayed in superscript.</sup> \n" +
+ " \n" +
+ " <table border = '1'> \n" +
+ " <caption>Animals</caption> \n" +
+ " <tr><th> Column 1 </th><th> Column 2 </th></tr> \n" +
+ " <tr><td> cow </td><td> dog </td></tr> \n" +
+ " <tr><td> cat </td><td> mouse </td></tr> \n" +
+ " <tr><td> horse </td><td> parrot </td></tr> \n" +
+ " </table> \n" +
+ " \n" +
+ " <tt> Starts a piece of text displayed in a typewriter font. \n" +
+ " </tt> \n" +
+ " <kbd> Starts a piece of text displayed in a typewriter font. \n" +
+ " </kbd> \n" +
+ " \n" +
+ " <ul>\n" +
+ " <li>List item 1.</li>\n" +
+ " <li>List item 2.</li>\n" +
+ " <li>List item 3.</li>\n" +
+ " </ul>\n" +
+ " \n" +
+ " <var> Starts a piece of text displayed in an italic font.</var> \n" +
+ " \n" +
+ "\n" +
+ "<u>underlined \\b bold text - doxy commands are ignored inside 'htmlonly' section </u>\n" +
+ "\n" +
+ "");
+
+ wantedComments.put("doxygen_translate.doxygen_translate.htmlTableFunction(int)",
+ "The meaning of flags:\n" +
+ "\n" +
+ " @param byFlags bits marking required items:\n" +
+ " <table>\n" +
+ " <tr><th> Size in bits</th><th> Items Required </th></tr>\n" +
+ " <tr><td> 1 - 8 </td><td> 1 </td></tr>\n" +
+ " <tr><td> 9 - 16 </td><td> 2 </td></tr>\n" +
+ " <tr><td> 17 - 32 </td><td> 4 </td></tr>\n" +
+ " </table>\n" +
+ " Almost all combinations of above flags are supported by\n" +
+ " <code>htmlTable...</code> functions.\n" +
+ "");
+
+
+ wantedComments.put("doxygen_translate.doxygen_translate.htmlEntitiesFunction(int, float)",
+ "All entities are treated as commands &copy; &trade; &reg;\n" +
+ "should work also&lt;in text \n" +
+ "&gt; \n" +
+ "&amp; \n" +
+ "&apos; \n" +
+ "&quot; \n" +
+ "&lsquo; \n" +
+ "&rsquo; \n" +
+ "&ldquo; \n" +
+ "&rdquo; \n" +
+ "&ndash; \n" +
+ "&mdash; \n" +
+ "&nbsp; \n" +
+ "&times; \n" +
+ "&minus; \n" +
+ "&sdot; \n" +
+ "&sim; \n" +
+ "&le; \n" +
+ "&ge; \n" +
+ "&larr; \n" +
+ "&rarr; \n" +
+ "Not an html entity - ignored by Doxygen. \n" +
+ "Not an &amp;text html entity - ampersand is replaced with entity.\n" +
+ "");
+
+ // and ask the parser to check comments for us
+ System.exit(CommentParser.check(wantedComments));
+ }
+}
diff --git a/Examples/test-suite/java/enum_macro_runme.java b/Examples/test-suite/java/enum_macro_runme.java
index 4ac7409ee..c05793347 100644
--- a/Examples/test-suite/java/enum_macro_runme.java
+++ b/Examples/test-suite/java/enum_macro_runme.java
@@ -88,6 +88,30 @@ public class enum_macro_runme {
{
Greeks13 a = null;
}
+ {
+ Greeks15 a = Greeks15.alpha15;
+ a = Greeks15.beta15;
+ a = Greeks15.theta15;
+ a = Greeks15.delta15;
+ if (a.swigValue() != 153)
+ throw new RuntimeException("Greeks15");
+ }
+ {
+ Greeks16 a = Greeks16.alpha16;
+ a = Greeks16.beta16;
+ a = Greeks16.theta16;
+ a = Greeks16.delta16;
+ if (a.swigValue() != 163)
+ throw new RuntimeException("Greeks16");
+ }
+ {
+ Greeks17 a = Greeks17.alpha17;
+ a = Greeks17.beta17;
+ a = Greeks17.theta17;
+ a = Greeks17.delta17;
+ if (a.swigValue() != 173)
+ throw new RuntimeException("Greeks17");
+ }
}
}
diff --git a/Examples/test-suite/java/extend_template_method_runme.java b/Examples/test-suite/java/extend_template_method_runme.java
new file mode 100644
index 000000000..e957be0bd
--- /dev/null
+++ b/Examples/test-suite/java/extend_template_method_runme.java
@@ -0,0 +1,63 @@
+
+import extend_template_method.*;
+
+public class extend_template_method_runme {
+
+ static {
+ try {
+ System.loadLibrary("extend_template_method");
+ } 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[]) {
+ {
+ ExtendMe em = new ExtendMe();
+
+ {
+ double ret_double = em.do_stuff_double(1, 1.1);
+ if (ret_double != 1.1)
+ throw new RuntimeException("double failed " + ret_double);
+ String ret_string = em.do_stuff_string(1, "hello there");
+ if (!ret_string.equals("hello there"))
+ throw new RuntimeException("string failed " + ret_string);
+ }
+ {
+ double ret_double = em.do_overloaded_stuff(1.1);
+ if (ret_double != 1.1)
+ throw new RuntimeException("double failed " + ret_double);
+ String ret_string = em.do_overloaded_stuff("hello there");
+ if (!ret_string.equals("hello there"))
+ throw new RuntimeException("string failed " + ret_string);
+ }
+ if (ExtendMe.static_method(123) != 123)
+ throw new RuntimeException("static_method failed");
+ ExtendMe em2 = new ExtendMe(123);
+ }
+ {
+ TemplateExtend em = new TemplateExtend();
+
+ {
+ double ret_double = em.do_template_stuff_double(1, 1.1);
+ if (ret_double != 1.1)
+ throw new RuntimeException("double failed " + ret_double);
+ String ret_string = em.do_template_stuff_string(1, "hello there");
+ if (!ret_string.equals("hello there"))
+ throw new RuntimeException("string failed " + ret_string);
+ }
+ {
+ double ret_double = em.do_template_overloaded_stuff(1.1);
+ if (ret_double != 1.1)
+ throw new RuntimeException("double failed " + ret_double);
+ String ret_string = em.do_template_overloaded_stuff("hello there");
+ if (!ret_string.equals("hello there"))
+ throw new RuntimeException("string failed " + ret_string);
+ }
+ if (TemplateExtend.static_template_method(123) != 123)
+ throw new RuntimeException("static_template_method failed");
+ TemplateExtend em2 = new TemplateExtend(123);
+ }
+ }
+}
diff --git a/Examples/test-suite/java/java_director_assumeoverride_runme.java b/Examples/test-suite/java/java_director_assumeoverride_runme.java
index e876a79c9..6c4d6918e 100644
--- a/Examples/test-suite/java/java_director_assumeoverride_runme.java
+++ b/Examples/test-suite/java/java_director_assumeoverride_runme.java
@@ -18,7 +18,7 @@ public class java_director_assumeoverride_runme {
public static void main(String argv[]) {
OverrideMe overrideMe = new MyOverrideMe();
- // MyOverrideMe doesn't actually override func(), but because assumeoverride
+ // MyOverrideMe doesn't actually override funk(), but because assumeoverride
// was set to true, the C++ side will believe it was overridden.
if (!java_director_assumeoverride.isFuncOverridden(overrideMe)) {
throw new RuntimeException ( "isFuncOverridden()" );
diff --git a/Examples/test-suite/java/java_director_exception_feature_nspace_runme.java b/Examples/test-suite/java/java_director_exception_feature_nspace_runme.java
index ea7da5c1a..884b04c6e 100644
--- a/Examples/test-suite/java/java_director_exception_feature_nspace_runme.java
+++ b/Examples/test-suite/java/java_director_exception_feature_nspace_runme.java
@@ -126,19 +126,28 @@ public class java_director_exception_feature_nspace_runme {
try { b.genericpong(1); fail("No exception thrown in genericpong(1)"); }
catch (MyJavaException1 e) {
failif( ! java_director_exception_feature_nspace_Consts.GENERICPONGEXCP1.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'");
+ StackTraceElement[] st = e.getStackTrace();
+ failif( st.length != 5, "Stack length is only " + st.length);
+ failif( ! st[0].toString().startsWith("java_director_exception_feature_nspace_MyFooDirectorImpl.genericpong(java_director_exception_feature_nspace_runme.java:"), "Incorrect top of stack: " + st[0]);
}
try { b.genericpong(2); fail("No exception thrown in genericpong(2)");}
catch (java_director_exception_feature_nspace_NewCheckedException e) {
failif( ! java_director_exception_feature_nspace_Consts.GENERICPONGEXCP2.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'");
+ StackTraceElement[] st = e.getStackTrace();
+ failif( st.length != 5, "Stack length is only " + st.length);
+ failif( ! st[0].toString().startsWith("java_director_exception_feature_nspace_MyFooDirectorImpl.genericpong(java_director_exception_feature_nspace_runme.java:"), "Incorrect top of stack: " + st[0]);
}
try { b.genericpong(3); fail("No exception thrown in genericpong(3)");}
catch (java_director_exception_feature_nspace_NewUncheckedException e) {
failif( ! java_director_exception_feature_nspace_Consts.GENERICPONGEXCP3.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'");
+ StackTraceElement[] st = e.getStackTrace();
+ failif( st.length != 5, "Stack length is only " + st.length);
+ failif( ! st[0].toString().startsWith("java_director_exception_feature_nspace_MyFooDirectorImpl.genericpong(java_director_exception_feature_nspace_runme.java:"), "Incorrect top of stack: " + st[0]);
}
try { b.genericpong(4); fail("No exception thrown in genericpong(4)");}
catch (RuntimeException e) {
- failif ( e.getClass() != RuntimeException.class, "Exception " + e + " is not exactly RumtimeException");
- failif( ! java_director_exception_feature_nspace_Consts.GENERICPONGEXCP4.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'");
+ failif ( e.getClass() != RuntimeException.class, "Exception " + e + " is not exactly RuntimeException");
+ failif( ! "Unspecified DirectorException message".equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'");
}
}
catch (Exception e) {
diff --git a/Examples/test-suite/java/java_director_exception_feature_runme.java b/Examples/test-suite/java/java_director_exception_feature_runme.java
index 2e919c18a..d9763c992 100644
--- a/Examples/test-suite/java/java_director_exception_feature_runme.java
+++ b/Examples/test-suite/java/java_director_exception_feature_runme.java
@@ -127,19 +127,28 @@ public class java_director_exception_feature_runme {
try { b.genericpong(1); fail("No exception thrown in genericpong(1)"); }
catch (MyJavaException1 e) {
failif( ! java_director_exception_feature_Consts.GENERICPONGEXCP1.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'");
+ StackTraceElement[] st = e.getStackTrace();
+ failif( st.length != 5, "Stack length is only " + st.length);
+ failif( ! st[0].toString().startsWith("java_director_exception_feature_MyFooDirectorImpl.genericpong(java_director_exception_feature_runme.java:"), "Incorrect top of stack: " + st[0]);
}
try { b.genericpong(2); fail("No exception thrown in genericpong(2)");}
catch (NewCheckedException e) {
failif( ! java_director_exception_feature_Consts.GENERICPONGEXCP2.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'");
+ StackTraceElement[] st = e.getStackTrace();
+ failif( st.length != 5, "Stack length is only " + st.length);
+ failif( ! st[0].toString().startsWith("java_director_exception_feature_MyFooDirectorImpl.genericpong(java_director_exception_feature_runme.java:"), "Incorrect top of stack: " + st[0]);
}
try { b.genericpong(3); fail("No exception thrown in genericpong(3)");}
catch (NewUncheckedException e) {
failif( ! java_director_exception_feature_Consts.GENERICPONGEXCP3.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'");
+ StackTraceElement[] st = e.getStackTrace();
+ failif( st.length != 5, "Stack length is only " + st.length);
+ failif( ! st[0].toString().startsWith("java_director_exception_feature_MyFooDirectorImpl.genericpong(java_director_exception_feature_runme.java:"), "Incorrect top of stack: " + st[0]);
}
try { b.genericpong(4); fail("No exception thrown in genericpong(4)");}
catch (RuntimeException e) {
- failif ( e.getClass() != RuntimeException.class, "Exception " + e + " is not exactly RumtimeException");
- failif( ! java_director_exception_feature_Consts.GENERICPONGEXCP4.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'");
+ failif ( e.getClass() != RuntimeException.class, "Exception " + e + " is not exactly RuntimeException");
+ failif( ! "Unspecified DirectorException message".equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'");
}
}
diff --git a/Examples/test-suite/java/java_director_typemaps_ptr_runme.java b/Examples/test-suite/java/java_director_typemaps_ptr_runme.java
new file mode 100644
index 000000000..c387270cd
--- /dev/null
+++ b/Examples/test-suite/java/java_director_typemaps_ptr_runme.java
@@ -0,0 +1,200 @@
+// Test director pointer typemaps in typemaps.i - similar to java_director_typemaps.i testcase
+
+import java_director_typemaps_ptr.*;
+import java.math.BigInteger;
+
+public class java_director_typemaps_ptr_runme {
+
+ static {
+ try {
+ System.loadLibrary("java_director_typemaps_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);
+ }
+ }
+
+
+ public static void main(String argv[]) {
+ java_director_typemaps_ptr_MyQuux myquux = new java_director_typemaps_ptr_MyQuux();
+ Quux quux = myquux;
+ quux.etest();
+ myquux.testing_nulls = true;
+ quux.nulltest();
+ }
+}
+
+class java_director_typemaps_ptr_MyQuux extends Quux {
+ public java_director_typemaps_ptr_MyQuux() {
+ super();
+ }
+ public boolean testing_nulls = false;
+
+ public void director_method_output(
+ boolean[] bool_arg,
+
+ byte[] signed_char_arg,
+ short[] unsigned_char_arg,
+
+ short[] short_arg,
+ int[] unsigned_short_arg,
+
+ int[] int_arg,
+ long[] unsigned_int_arg,
+
+ int[] long_arg,
+ long[] unsigned_long_arg,
+
+ long[] long_long_arg,
+ // BigInteger[] unsigned_long_long_arg,
+
+ float[] float_arg,
+ double[] double_arg)
+ {
+ if (testing_nulls) {
+ if (bool_arg != null) throw new RuntimeException("not null bool_arg");
+ if (signed_char_arg != null) throw new RuntimeException("not null signed_char_arg");
+ if (unsigned_char_arg != null) throw new RuntimeException("not null unsigned_char_arg");
+ if (short_arg != null) throw new RuntimeException("not null short_arg");
+ if (unsigned_short_arg != null) throw new RuntimeException("not null unsigned_short_arg");
+ if (int_arg != null) throw new RuntimeException("not null int_arg");
+ if (unsigned_int_arg != null) throw new RuntimeException("not null unsigned_int_arg");
+ if (long_arg != null) throw new RuntimeException("not null long_arg");
+ if (unsigned_long_arg != null) throw new RuntimeException("not null unsigned_long_arg");
+ if (long_long_arg != null) throw new RuntimeException("not null long_long_arg");
+ // if (unsigned_long_long_arg != null) throw new RuntimeException("not null unsigned_long_long_arg");
+ if (float_arg != null) throw new RuntimeException("not null float_arg");
+ if (double_arg != null) throw new RuntimeException("not null double_arg");
+ }
+ if (bool_arg != null) bool_arg[0] = true;
+ if (signed_char_arg != null) signed_char_arg[0] = 1;
+ if (unsigned_char_arg != null) unsigned_char_arg[0] = 2;
+ if (short_arg != null) short_arg[0] = 3;
+ if (unsigned_short_arg != null) unsigned_short_arg[0] = 4;
+ if (int_arg != null) int_arg[0] = 5;
+ if (unsigned_int_arg != null) unsigned_int_arg[0] = 6;
+ if (long_arg != null) long_arg[0] = 7;
+ if (unsigned_long_arg != null) unsigned_long_arg[0] = 8;
+ if (long_long_arg != null) long_long_arg[0] = 9;
+ // if (unsigned_long_long_arg != null) unsigned_long_long_arg[0] = 10;
+ if (float_arg != null) float_arg[0] = 11;
+ if (double_arg != null) double_arg[0] = 12;
+ }
+
+ public void director_method_inout(
+ boolean[] bool_arg,
+
+ byte[] signed_char_arg,
+ short[] unsigned_char_arg,
+
+ short[] short_arg,
+ int[] unsigned_short_arg,
+
+ int[] int_arg,
+ long[] unsigned_int_arg,
+
+ int[] long_arg,
+ long[] unsigned_long_arg,
+
+ long[] long_long_arg,
+ // BigInteger[] unsigned_long_long_arg,
+
+ float[] float_arg,
+ double[] double_arg)
+ {
+ if (testing_nulls) {
+ if (bool_arg != null) throw new RuntimeException("not null bool_arg");
+ if (signed_char_arg != null) throw new RuntimeException("not null signed_char_arg");
+ if (unsigned_char_arg != null) throw new RuntimeException("not null unsigned_char_arg");
+ if (short_arg != null) throw new RuntimeException("not null short_arg");
+ if (unsigned_short_arg != null) throw new RuntimeException("not null unsigned_short_arg");
+ if (int_arg != null) throw new RuntimeException("not null int_arg");
+ if (unsigned_int_arg != null) throw new RuntimeException("not null unsigned_int_arg");
+ if (long_arg != null) throw new RuntimeException("not null long_arg");
+ if (unsigned_long_arg != null) throw new RuntimeException("not null unsigned_long_arg");
+ if (long_long_arg != null) throw new RuntimeException("not null long_long_arg");
+ // if (unsigned_long_long_arg != null) throw new RuntimeException("not null unsigned_long_long_arg");
+ if (float_arg != null) throw new RuntimeException("not null float_arg");
+ if (double_arg != null) throw new RuntimeException("not null double_arg");
+ } else {
+ if (bool_arg[0]) throw new RuntimeException("unexpected value for bool_arg");
+ if (signed_char_arg[0] != 101) throw new RuntimeException("unexpected value for signed_char_arg");
+ if (unsigned_char_arg[0] != 101) throw new RuntimeException("unexpected value for unsigned_char_arg");
+ if (short_arg[0] != 101) throw new RuntimeException("unexpected value for short_arg");
+ if (unsigned_short_arg[0] != 101) throw new RuntimeException("unexpected value for unsigned_short_arg");
+ if (int_arg[0] != 101) throw new RuntimeException("unexpected value for int_arg");
+ if (unsigned_int_arg[0] != 101) throw new RuntimeException("unexpected value for unsigned_int_arg");
+ if (long_arg[0] != 101) throw new RuntimeException("unexpected value for long_arg");
+ if (unsigned_long_arg[0] != 101) throw new RuntimeException("unexpected value for unsigned_long_arg");
+ if (long_long_arg[0] != 101) throw new RuntimeException("unexpected value for long_long_arg");
+ // if (unsigned_long_long_arg[0] != 101) throw new RuntimeException("unexpected value for unsigned_long_long_arg");
+ if (float_arg[0] != 101) throw new RuntimeException("unexpected value for float_arg");
+ if (double_arg[0] != 101) throw new RuntimeException("unexpected value for double_arg");
+ }
+
+ if (bool_arg != null) bool_arg[0] = false;
+ if (signed_char_arg != null) signed_char_arg[0] = 11;
+ if (unsigned_char_arg != null) unsigned_char_arg[0] = 12;
+ if (short_arg != null) short_arg[0] = 13;
+ if (unsigned_short_arg != null) unsigned_short_arg[0] = 14;
+ if (int_arg != null) int_arg[0] = 15;
+ if (unsigned_int_arg != null) unsigned_int_arg[0] = 16;
+ if (long_arg != null) long_arg[0] = 17;
+ if (unsigned_long_arg != null) unsigned_long_arg[0] = 18;
+ if (long_long_arg != null) long_long_arg[0] = 19;
+ // if (unsigned_long_long_arg != null) unsigned_long_long_arg[0] = 110;
+ if (float_arg != null) float_arg[0] = 111;
+ if (double_arg != null) double_arg[0] = 112;
+ }
+
+ public void director_method_nameless_args(
+ boolean[] bool_arg,
+
+ byte[] signed_char_arg,
+ short[] unsigned_char_arg,
+
+ short[] short_arg,
+ int[] unsigned_short_arg,
+
+ int[] int_arg,
+ long[] unsigned_int_arg,
+
+ int[] long_arg,
+ long[] unsigned_long_arg,
+
+ long[] long_long_arg,
+ // BigInteger[] unsigned_long_long_arg,
+
+ float[] float_arg,
+ double[] double_arg)
+ {
+ if (testing_nulls) {
+ if (bool_arg != null) throw new RuntimeException("not null bool_arg");
+ if (signed_char_arg != null) throw new RuntimeException("not null signed_char_arg");
+ if (unsigned_char_arg != null) throw new RuntimeException("not null unsigned_char_arg");
+ if (short_arg != null) throw new RuntimeException("not null short_arg");
+ if (unsigned_short_arg != null) throw new RuntimeException("not null unsigned_short_arg");
+ if (int_arg != null) throw new RuntimeException("not null int_arg");
+ if (unsigned_int_arg != null) throw new RuntimeException("not null unsigned_int_arg");
+ if (long_arg != null) throw new RuntimeException("not null long_arg");
+ if (unsigned_long_arg != null) throw new RuntimeException("not null unsigned_long_arg");
+ if (long_long_arg != null) throw new RuntimeException("not null long_long_arg");
+ // if (unsigned_long_long_arg != null) throw new RuntimeException("not null unsigned_long_long_arg");
+ if (float_arg != null) throw new RuntimeException("not null float_arg");
+ if (double_arg != null) throw new RuntimeException("not null double_arg");
+ }
+ if (bool_arg != null) bool_arg[0] = true;
+ if (signed_char_arg != null) signed_char_arg[0] = 12;
+ if (unsigned_char_arg != null) unsigned_char_arg[0] = 13;
+ if (short_arg != null) short_arg[0] = 14;
+ if (unsigned_short_arg != null) unsigned_short_arg[0] = 15;
+ if (int_arg != null) int_arg[0] = 16;
+ if (unsigned_int_arg != null) unsigned_int_arg[0] = 17;
+ if (long_arg != null) long_arg[0] = 18;
+ if (unsigned_long_arg != null) unsigned_long_arg[0] = 19;
+ if (long_long_arg != null) long_long_arg[0] = 20;
+ // if (unsigned_long_long_arg != null) unsigned_long_long_arg[0] = 111;
+ if (float_arg != null) float_arg[0] = 112;
+ if (double_arg != null) double_arg[0] = 113;
+ }
+}
diff --git a/Examples/test-suite/java/java_director_typemaps_runme.java b/Examples/test-suite/java/java_director_typemaps_runme.java
new file mode 100644
index 000000000..a6ab1df39
--- /dev/null
+++ b/Examples/test-suite/java/java_director_typemaps_runme.java
@@ -0,0 +1,151 @@
+// Test director reference typemaps in typemaps.i - similar to java_director_typemaps_ptr.i testcase
+
+import java_director_typemaps.*;
+import java.math.BigInteger;
+
+public class java_director_typemaps_runme {
+
+ static {
+ try {
+ System.loadLibrary("java_director_typemaps");
+ } 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[]) {
+ Quux quux = new java_director_typemaps_MyQuux();
+ quux.etest();
+ }
+}
+
+class java_director_typemaps_MyQuux extends Quux {
+ public java_director_typemaps_MyQuux() {
+ super();
+ }
+
+ public void director_method_output(
+ boolean[] bool_arg,
+
+ byte[] signed_char_arg,
+ short[] unsigned_char_arg,
+
+ short[] short_arg,
+ int[] unsigned_short_arg,
+
+ int[] int_arg,
+ long[] unsigned_int_arg,
+
+ int[] long_arg,
+ long[] unsigned_long_arg,
+
+ long[] long_long_arg,
+ // BigInteger[] unsigned_long_long_arg,
+
+ float[] float_arg,
+ double[] double_arg)
+ {
+ bool_arg[0] = true;
+ signed_char_arg[0] = 1;
+ unsigned_char_arg[0] = 2;
+ short_arg[0] = 3;
+ unsigned_short_arg[0] = 4;
+ int_arg[0] = 5;
+ unsigned_int_arg[0] = 6;
+ long_arg[0] = 7;
+ unsigned_long_arg[0] = 8;
+ long_long_arg[0] = 9;
+ // unsigned_long_long_arg[0] = 10;
+ float_arg[0] = 11;
+ double_arg[0] = 12;
+ }
+
+ public void director_method_inout(
+ boolean[] bool_arg,
+
+ byte[] signed_char_arg,
+ short[] unsigned_char_arg,
+
+ short[] short_arg,
+ int[] unsigned_short_arg,
+
+ int[] int_arg,
+ long[] unsigned_int_arg,
+
+ int[] long_arg,
+ long[] unsigned_long_arg,
+
+ long[] long_long_arg,
+ // BigInteger[] unsigned_long_long_arg,
+
+ float[] float_arg,
+ double[] double_arg)
+ {
+ if (bool_arg[0]) throw new RuntimeException("unexpected value for bool_arg");
+
+ if (signed_char_arg[0] != 101) throw new RuntimeException("unexpected value for signed_char_arg");
+ if (unsigned_char_arg[0] != 101) throw new RuntimeException("unexpected value for unsigned_char_arg");
+ if (short_arg[0] != 101) throw new RuntimeException("unexpected value for short_arg");
+ if (unsigned_short_arg[0] != 101) throw new RuntimeException("unexpected value for unsigned_short_arg");
+ if (int_arg[0] != 101) throw new RuntimeException("unexpected value for int_arg");
+ if (unsigned_int_arg[0] != 101) throw new RuntimeException("unexpected value for unsigned_int_arg");
+ if (long_arg[0] != 101) throw new RuntimeException("unexpected value for long_arg");
+ if (unsigned_long_arg[0] != 101) throw new RuntimeException("unexpected value for unsigned_long_arg");
+ if (long_long_arg[0] != 101) throw new RuntimeException("unexpected value for long_long_arg");
+ // if (unsigned_long_long_arg[0] != 101) throw new RuntimeException("unexpected value for unsigned_long_long_arg");
+ if (float_arg[0] != 101) throw new RuntimeException("unexpected value for float_arg");
+ if (double_arg[0] != 101) throw new RuntimeException("unexpected value for double_arg");
+
+ bool_arg[0] = false;
+ signed_char_arg[0] = 11;
+ unsigned_char_arg[0] = 12;
+ short_arg[0] = 13;
+ unsigned_short_arg[0] = 14;
+ int_arg[0] = 15;
+ unsigned_int_arg[0] = 16;
+ long_arg[0] = 17;
+ unsigned_long_arg[0] = 18;
+ long_long_arg[0] = 19;
+ // unsigned_long_long_arg[0] = 110;
+ float_arg[0] = 111;
+ double_arg[0] = 112;
+ }
+
+ public void director_method_nameless_args(
+ boolean[] bool_arg,
+
+ byte[] signed_char_arg,
+ short[] unsigned_char_arg,
+
+ short[] short_arg,
+ int[] unsigned_short_arg,
+
+ int[] int_arg,
+ long[] unsigned_int_arg,
+
+ int[] long_arg,
+ long[] unsigned_long_arg,
+
+ long[] long_long_arg,
+ // BigInteger[] unsigned_long_long_arg,
+
+ float[] float_arg,
+ double[] double_arg)
+ {
+ bool_arg[0] = true;
+ signed_char_arg[0] = 12;
+ unsigned_char_arg[0] = 13;
+ short_arg[0] = 14;
+ unsigned_short_arg[0] = 15;
+ int_arg[0] = 16;
+ unsigned_int_arg[0] = 17;
+ long_arg[0] = 18;
+ unsigned_long_arg[0] = 19;
+ long_long_arg[0] = 20;
+ // unsigned_long_long_arg[0] = 111;
+ float_arg[0] = 112;
+ double_arg[0] = 113;
+ }
+}
diff --git a/Examples/test-suite/java/java_enums_runme.java b/Examples/test-suite/java/java_enums_runme.java
index bc7d41636..754d391fa 100644
--- a/Examples/test-suite/java/java_enums_runme.java
+++ b/Examples/test-suite/java/java_enums_runme.java
@@ -13,6 +13,12 @@ public class java_enums_runme implements stuff {
public static void main(String argv[])
{
+ if (WithTrailingComma.Second != 1)
+ throw new RuntimeException("Incorrect value for Second");
+
+ if (WithTrailingCommaAndIgnoredFirstItem.SecondNonIgnoredOne != 2)
+ throw new RuntimeException("Incorrect value for SecondNonIgnoredOne");
+
int number = 200;
// Switch statement will only compile if these enums are initialised
diff --git a/Examples/test-suite/java/java_throws_runme.java b/Examples/test-suite/java/java_throws_runme.java
index 0365b69ed..16eab7cad 100644
--- a/Examples/test-suite/java/java_throws_runme.java
+++ b/Examples/test-suite/java/java_throws_runme.java
@@ -93,6 +93,28 @@ public class java_throws_runme {
if (!pass)
throw new RuntimeException("Test 6 failed");
+ // Interface function
+ pass = false;
+ try {
+ InterfaceTestImpl iti = new InterfaceTestImpl();
+ iti.imethod(true);
+ }
+ catch (MyException e) { pass = true; }
+
+ if (!pass)
+ throw new RuntimeException("Test interface 1 failed");
+
+ pass = false;
+ try {
+ InterfaceTestImpl iti = new InterfaceTestImpl();
+ iti.imethod(false);
+ pass = true;
+ }
+ catch (MyException e) { pass = false; }
+
+ if (!pass)
+ throw new RuntimeException("Test interface 2 failed");
+
// Global function
pass = false;
try {
diff --git a/Examples/test-suite/java/li_boost_shared_ptr_director_runme.java b/Examples/test-suite/java/li_boost_shared_ptr_director_runme.java
new file mode 100644
index 000000000..9349c622b
--- /dev/null
+++ b/Examples/test-suite/java/li_boost_shared_ptr_director_runme.java
@@ -0,0 +1,129 @@
+import li_boost_shared_ptr_director.*;
+
+public class li_boost_shared_ptr_director_runme {
+
+ static {
+ try {
+ System.loadLibrary("li_boost_shared_ptr_director");
+ } 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 check(int got, int expected) {
+ if (got != expected)
+ throw new RuntimeException("Failed, got: " + got + " expected: " + expected);
+ }
+
+ public static void main(String argv[]) {
+ li_boost_shared_ptr_director_Derived a = new li_boost_shared_ptr_director_Derived(false);
+ li_boost_shared_ptr_director_Derived b = new li_boost_shared_ptr_director_Derived(true);
+
+ check(li_boost_shared_ptr_director.call_ret_c_shared_ptr(a), 1);
+ check(li_boost_shared_ptr_director.call_ret_c_shared_ptr(b), -1);
+ check(li_boost_shared_ptr_director.call_ret_c_by_value(a), 1);
+
+ check(li_boost_shared_ptr_director.call_ret_c_shared_ptr(a), 1);
+ check(li_boost_shared_ptr_director.call_ret_c_shared_ptr(b), -1);
+ check(li_boost_shared_ptr_director.call_ret_c_by_value(a), 1);
+
+ check(li_boost_shared_ptr_director.call_take_c_by_value(a), 5);
+ check(li_boost_shared_ptr_director.call_take_c_by_ref(a), 6);
+ check(li_boost_shared_ptr_director.call_take_c_by_pointer(a), 7);
+ check(li_boost_shared_ptr_director.call_take_c_by_pointer_ref(a), 8);
+ check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_value(a), 9);
+ check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_ref(a), 10);
+ check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_pointer(a), 11);
+ check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_pointer_ref(a), 12);
+
+ check(li_boost_shared_ptr_director.call_take_c_by_pointer_with_null(a), -2);
+ check(li_boost_shared_ptr_director.call_take_c_by_pointer_ref_with_null(a), -3);
+ check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_value_with_null(a), -4);
+ check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_ref_with_null(a), -5);
+ check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_pointer_with_null(a), -6);
+ check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_pointer_ref_with_null(a), -7);
+ }
+}
+
+class li_boost_shared_ptr_director_Derived extends Base {
+
+ private boolean return_none;
+
+ li_boost_shared_ptr_director_Derived(boolean flag) {
+ super();
+ this.return_none = flag;
+ }
+
+ @Override
+ public C ret_c_shared_ptr() {
+ if (this.return_none)
+ return null;
+ else
+ return new C();
+ }
+
+ @Override
+ public C ret_c_by_value() {
+ return new C();
+ }
+
+ @Override
+ public int take_c_by_value(C c) {
+ return c.get_m();
+ }
+
+ @Override
+ public int take_c_by_ref(C c) {
+ return c.get_m();
+ }
+
+ @Override
+ public int take_c_by_pointer(C c) {
+ if (c != null)
+ return c.get_m();
+ else
+ return -2;
+ }
+
+ @Override
+ public int take_c_by_pointer_ref(C c) {
+ if (c != null)
+ return c.get_m();
+ else
+ return -3;
+ }
+
+ @Override
+ public int take_c_shared_ptr_by_value(C c) {
+ if (c != null)
+ return c.get_m();
+ else
+ return -4;
+ }
+
+ @Override
+ public int take_c_shared_ptr_by_ref(C c) {
+ if (c != null)
+ return c.get_m();
+ else
+ return -5;
+ }
+
+ @Override
+ public int take_c_shared_ptr_by_pointer(C c) {
+ if (c != null)
+ return c.get_m();
+ else
+ return -6;
+ }
+
+ @Override
+ public int take_c_shared_ptr_by_pointer_ref(C c) {
+ if (c != null)
+ return c.get_m();
+ else
+ return -7;
+ }
+
+}
diff --git a/Examples/test-suite/java/li_std_list_runme.java b/Examples/test-suite/java/li_std_list_runme.java
new file mode 100644
index 000000000..96412fdaf
--- /dev/null
+++ b/Examples/test-suite/java/li_std_list_runme.java
@@ -0,0 +1,180 @@
+import li_std_list.*;
+
+public class li_std_list_runme {
+
+ static {
+ try {
+ System.loadLibrary("li_std_list");
+ } 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[]) throws Throwable
+ {
+ IntList v1 = new IntList();
+ DoubleList v2 = new DoubleList();
+
+ if (!v1.isEmpty()) throw new RuntimeException("v1 test (1) failed");
+ if (v1.size() != 0) throw new RuntimeException("v1 test (2) failed");
+ if (!v1.add(123)) throw new RuntimeException("v1 test (3) failed");
+ if (v1.size() != 1) throw new RuntimeException("v1 test (4) failed");
+ if (v1.isEmpty()) throw new RuntimeException("v1 test (5) failed");
+
+ int sum = 0;
+ for (int n : v1) {
+ if (n != 123) throw new RuntimeException("v1 loop test failed");
+ sum += n;
+ }
+ if (sum != 123) throw new RuntimeException("v1 sum test failed");
+ if (v1.get(0) != 123) throw new RuntimeException("v1 test failed");
+ v1.clear();
+ if (!v1.isEmpty()) throw new RuntimeException("v1 test clear failed");
+ v1.add(123);
+
+ if (v1.set(0, 456) != 123) throw new RuntimeException("v1 test (6) failed");
+ if (v1.size() != 1) throw new RuntimeException("v1 test (7) failed");
+ if (v1.get(0) != 456) throw new RuntimeException("v1 test (8) failed");
+
+ java.util.Iterator<Integer> v1_iterator = v1.iterator();
+ if (!v1_iterator.hasNext()) throw new RuntimeException("v1 test (9) failed");
+ if (v1_iterator.next() != 456) throw new RuntimeException("v1 test (10) failed");
+ if (v1_iterator.hasNext()) throw new RuntimeException("v1 test (11) failed");
+ try {
+ v1_iterator.next();
+ throw new RuntimeException("v1 test (12) failed");
+ } catch (java.util.NoSuchElementException e) {
+ }
+
+ if (v1.remove(Integer.valueOf(123))) throw new RuntimeException("v1 test (13) failed");
+ if (!v1.remove(Integer.valueOf(456))) throw new RuntimeException("v1 test (14) failed");
+ if (!v1.isEmpty()) throw new RuntimeException("v1 test (15) failed");
+ if (v1.size() != 0) throw new RuntimeException("v1 test (16) failed");
+ if (v1.remove(Integer.valueOf(456))) throw new RuntimeException("v1 test (17) failed");
+
+ if (new IntList(3, 0).size() != 3) throw new RuntimeException("constructor initial size test failed");
+ for (int n : new IntList(10, 999))
+ if (n != 999) throw new RuntimeException("constructor initialization with value failed");
+ for (int n : new IntList(new IntList(10, 999)))
+ if (n != 999) throw new RuntimeException("copy constructor initialization with value failed");
+
+ StructList v4 = new StructList();
+ StructPtrList v5 = new StructPtrList();
+ StructConstPtrList v6 = new StructConstPtrList();
+
+ v4.add(new Struct(12));
+ v5.add(new Struct(34));
+ v6.add(new Struct(56));
+
+ if (v4.get(0).getNum() != 12) throw new RuntimeException("v4 test failed");
+ if (v5.get(0).getNum() != 34) throw new RuntimeException("v5 test failed");
+ if (v6.get(0).getNum() != 56) throw new RuntimeException("v6 test failed");
+
+ for (Struct s : v4) {
+ if (s.getNum() != 12) throw new RuntimeException("v4 loop test failed");
+ }
+ for (Struct s : v5) {
+ if (s.getNum() != 34) throw new RuntimeException("v5 loop test failed");
+ }
+ for (Struct s : v6) {
+ if (s.getNum() != 56) throw new RuntimeException("v6 loop test failed");
+ }
+
+ StructList v7 = li_std_list.CopyContainerStruct(new StructList());
+ v7.add(new Struct(1));
+ v7.add(new Struct(23));
+ v7.add(new Struct(456));
+ v7.add(new Struct(7890));
+ if (v7.size() != 4) throw new RuntimeException("v7 test (1) failed");
+ {
+ double[] a7 = {1, 23, 456, 7890};
+ int i7 = 0;
+ for (Struct s7 : v7) {
+ if (s7.getNum() != a7[i7]) throw new RuntimeException("v7 test (2) failed");
+ i7++;
+ }
+ if (i7 != a7.length) throw new RuntimeException("v7 test (3) failed");
+ }
+ if (v7.remove(2).getNum() != 456) throw new RuntimeException("v7 test (4) failed");
+ {
+ double[] a7 = {1, 23, 7890};
+ int i7 = 0;
+ for (Struct s7 : v7) {
+ if (s7.getNum() != a7[i7]) throw new RuntimeException("v7 test (5) failed");
+ i7++;
+ }
+ if (i7 != a7.length) throw new RuntimeException("v7 test (6) failed");
+ }
+ v7.add(1, new Struct(123));
+ {
+ double[] a7 = {1, 123, 23, 7890};
+ int i7 = 0;
+ for (Struct s7 : v7) {
+ if (s7.getNum() != a7[i7]) throw new RuntimeException("v7 test (7) failed");
+ i7++;
+ }
+ if (i7 != a7.length) throw new RuntimeException("v7 test (8) failed");
+ }
+
+ BoolList v8 = new BoolList();
+ if (!v8.add(true)) throw new RuntimeException("v8 test (1) failed");;
+ if (v8.get(0) != true) throw new RuntimeException("v8 test (2) failed");;
+ if (v8.set(0, false) != true) throw new RuntimeException("v8 test (3) failed");;
+ if (v8.set(0, false) != false) throw new RuntimeException("v8 test (4) failed");;
+ if (v8.size() != 1) throw new RuntimeException("v8 test (5) failed");;
+
+ java.util.ArrayList<Boolean> bl = new java.util.ArrayList<Boolean>(java.util.Arrays.asList(true, false, true, false));
+ BoolList bv = new BoolList(java.util.Arrays.asList(true, false, true, false));
+ BoolList bv2 = new BoolList(bl);
+ java.util.ArrayList<Boolean> bl2 = new java.util.ArrayList<Boolean>(bv);
+ boolean bbb1 = bv.get(0);
+ Boolean bbb2 = bv.get(0);
+
+ IntList v9 = new IntList(java.util.Arrays.asList(10, 20, 30, 40));
+ v9.add(50);
+ v9.add(60);
+ v9.add(70);
+ if (v9.size() != 7) throw new RuntimeException("v9 test (1) failed");
+ if (!v9.remove(Integer.valueOf(60))) throw new RuntimeException("v9 test (2) failed");
+ if (v9.size() != 6) throw new RuntimeException("v9 test (3) failed");
+ v9.addFirst(-10);
+ v9.addLast(80);
+ if (v9.size() != 8) throw new RuntimeException("v9 test (4) failed");
+ if (v9.get(0) != -10) throw new RuntimeException("v9 test (5) failed");;
+ if (v9.get(v9.size()-1) != 80) throw new RuntimeException("v9 test (6) failed");;
+ v9.removeFirst();
+ if (v9.get(0) != 10) throw new RuntimeException("v9 test (7) failed");;
+ v9.removeLast();
+ if (v9.size() != 6) throw new RuntimeException("v9 test (8) failed");
+ if (v9.get(v9.size()-1) != 70) throw new RuntimeException("v9 test (9) failed");;
+
+ IntList v10 = new IntList(java.util.Arrays.asList(10, 20, 30, 40, 50));
+ v10.subList(1, 4).clear(); // Recommended way to call protected method removeRange(1,3)
+ if (v10.size() != 2) throw new RuntimeException("v10 test (1) failed");
+ if (v10.get(0) != 10) throw new RuntimeException("v10 test (2) failed");
+ if (v10.get(1) != 50) throw new RuntimeException("v10 test (3) failed");
+ v10.addAll(1, java.util.Arrays.asList(22, 33));
+ if (v10.size() != 4) throw new RuntimeException("v10 test (4) failed");
+ if (v10.get(1) != 22) throw new RuntimeException("v10 test (5) failed");
+ if (v10.get(2) != 33) throw new RuntimeException("v10 test (6) failed");
+
+ v10.add(v10.size(), 55);
+ if (v10.size() != 5) throw new RuntimeException("v10 test (7) failed");
+ if (v10.get(4) != 55) throw new RuntimeException("v10 test (8) failed");
+
+ IntList v11 = new IntList(java.util.Arrays.asList(11, 22, 33, 44));
+ v11.listIterator(0);
+ v11.listIterator(v11.size());
+ try {
+ v11.listIterator(v11.size() + 1);
+ throw new RuntimeException("v11 test (1) failed");
+ } catch (IndexOutOfBoundsException e) {
+ }
+ try {
+ v11.listIterator(-1);
+ throw new RuntimeException("v11 test (2) failed");
+ } catch (IndexOutOfBoundsException e) {
+ }
+ }
+}
diff --git a/Examples/test-suite/java/li_std_map_runme.java b/Examples/test-suite/java/li_std_map_runme.java
new file mode 100644
index 000000000..7ad4370cc
--- /dev/null
+++ b/Examples/test-suite/java/li_std_map_runme.java
@@ -0,0 +1,122 @@
+import li_std_map.*;
+
+public class li_std_map_runme {
+
+ static {
+ try {
+ System.loadLibrary("li_std_map");
+ } 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 checkThat(boolean mustBeTrue) throws Throwable {
+ if (!mustBeTrue) {
+ // Index [2], since this function is one hop away from main, and [1] is the current method.
+ throw new RuntimeException("Test failed at line number " + Thread.currentThread().getStackTrace()[2].getLineNumber());
+ }
+ }
+
+ public static void main(String argv[]) throws Throwable
+ {
+ java.util.AbstractMap<String, Integer> sim = new StringIntMap();
+ java.util.AbstractMap<Integer, Integer> iim = new IntIntMap();
+
+ checkThat(sim.isEmpty());
+ checkThat(iim.isEmpty());
+ checkThat(sim.size() == 0);
+ checkThat(iim.size() == 0);
+
+ checkThat(sim.get("key") == null);
+ checkThat(iim.get(1) == null);
+
+ checkThat(!sim.containsKey("key"));
+ checkThat(!iim.containsKey(1));
+
+ checkThat(sim.put("key", 2) == null);
+ checkThat(iim.put(1, 2) == null);
+
+ checkThat(sim.size() == 1);
+ checkThat(iim.size() == 1);
+ checkThat(!sim.isEmpty());
+ checkThat(!iim.isEmpty());
+
+ checkThat(sim.get("key") == 2);
+ checkThat(iim.get(1) == 2);
+
+ checkThat(sim.remove("key") == 2);
+ checkThat(iim.remove(1) == 2);
+
+ checkThat(sim.isEmpty());
+ checkThat(iim.isEmpty());
+ checkThat(sim.size() == 0);
+ checkThat(iim.size() == 0);
+
+ checkThat(sim.get("key") == null);
+ checkThat(iim.get(1) == null);
+
+ checkThat(sim.remove("key") == null);
+ checkThat(iim.remove(1) == null);
+
+ checkThat(sim.put("key", 2) == null);
+ checkThat(iim.put(1, 2) == null);
+
+ sim.clear();
+ iim.clear();
+ checkThat(sim.isEmpty());
+ checkThat(iim.isEmpty());
+
+ checkThat(sim.put("key1", 1) == null);
+ checkThat(iim.put(1, 1) == null);
+ checkThat(sim.put("key2", 2) == null);
+ checkThat(iim.put(2, 2) == null);
+
+ checkThat(sim.size() == 2);
+ checkThat(iim.size() == 2);
+ checkThat(sim.get("key1") == 1);
+ checkThat(iim.get(1) == 1);
+ checkThat(sim.get("key2") == 2);
+ checkThat(iim.get(2) == 2);
+
+ checkThat(sim.put("key1", 3) == 1);
+ checkThat(iim.put(1, 3) == 1);
+
+ checkThat(sim.size() == 2);
+ checkThat(iim.size() == 2);
+ checkThat(sim.get("key1") == 3);
+ checkThat(iim.get(1) == 3);
+
+ java.util.Set<java.util.Map.Entry<String, Integer>> sim_es = sim.entrySet();
+ java.util.Map<String, Integer> sim_default = new java.util.HashMap<String, Integer>();
+ sim_default.put("key1", 3);
+ sim_default.put("key2", 2);
+ java.util.Set<java.util.Map.Entry<String, Integer>> sim_es_default = sim_default.entrySet();
+ checkThat(sim_es.size() == sim_es_default.size());
+ for (java.util.Map.Entry<String, Integer> entry : sim_es) {
+ checkThat(sim_es_default.contains(entry));
+ checkThat(sim_default.containsKey(entry.getKey()));
+ checkThat(sim_default.containsValue(entry.getValue()));
+
+ Integer oldValue = entry.getValue();
+ entry.setValue(oldValue + 1);
+ checkThat(sim.get(entry.getKey()) == (oldValue + 1));
+ }
+
+ java.util.Set<java.util.Map.Entry<Integer, Integer>> iim_es = iim.entrySet();
+ java.util.Map<Integer, Integer> iim_default = new java.util.HashMap<Integer, Integer>();
+ iim_default.put(1, 3);
+ iim_default.put(2, 2);
+ java.util.Set<java.util.Map.Entry<Integer, Integer>> iim_es_default = iim_default.entrySet();
+ checkThat(iim_es.size() == iim_es_default.size());
+ for (java.util.Map.Entry<Integer, Integer> entry : iim_es) {
+ checkThat(iim_es_default.contains(entry));
+ checkThat(iim_default.containsKey(entry.getKey()));
+ checkThat(iim_default.containsValue(entry.getValue()));
+
+ Integer oldValue = entry.getValue();
+ entry.setValue(oldValue + 1);
+ checkThat(iim.get(entry.getKey()) == (oldValue + 1));
+ }
+ }
+}
diff --git a/Examples/test-suite/java/li_std_set_runme.java b/Examples/test-suite/java/li_std_set_runme.java
new file mode 100644
index 000000000..0e013eba1
--- /dev/null
+++ b/Examples/test-suite/java/li_std_set_runme.java
@@ -0,0 +1,90 @@
+import li_std_set.*;
+
+public class li_std_set_runme {
+
+ static {
+ try {
+ System.loadLibrary("li_std_set");
+ } 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 checkThat(boolean mustBeTrue) throws Throwable {
+ if (!mustBeTrue) {
+ // Index [2], since this function is one hop away from main, and [1] is the current method.
+ throw new RuntimeException("Test failed at line number " + Thread.currentThread().getStackTrace()[2].getLineNumber());
+ }
+ }
+
+ public static void main(String argv[]) throws Throwable
+ {
+ java.util.AbstractSet<String> ss = new StringSet();
+
+ checkThat(ss.isEmpty());
+ checkThat(!ss.contains("key"));
+ checkThat(!ss.remove("key"));
+
+ checkThat(ss.add("key"));
+ checkThat(!ss.add("key"));
+ checkThat(ss.contains("key"));
+ checkThat(ss.remove("key"));
+ checkThat(ss.isEmpty());
+ checkThat(ss.size() == 0);
+
+ checkThat(ss.add("key1"));
+ checkThat(ss.add("key2"));
+ checkThat(ss.add("key3"));
+ checkThat(ss.size() == 3);
+
+ ss.clear();
+ checkThat(ss.isEmpty());
+ checkThat(ss.size() == 0);
+
+ checkThat(ss.addAll(java.util.Arrays.asList("one", "two", "three")));
+ checkThat(ss.size() == 3);
+ checkThat(ss.contains("one"));
+ checkThat(!ss.contains("four"));
+
+ checkThat(ss.containsAll(java.util.Arrays.asList("one", "two", "three")));
+ checkThat(ss.containsAll(java.util.Arrays.asList("one", "two")));
+ checkThat(!ss.containsAll(java.util.Arrays.asList("one", "two", "four")));
+ checkThat(!ss.containsAll(java.util.Arrays.asList("one", "two", "three", "four")));
+
+ checkThat(!ss.addAll(java.util.Arrays.asList("one", "two", "three")));
+
+ java.util.Set<String> found = new java.util.HashSet<String>();
+ java.util.Iterator<String> itr = ss.iterator();
+ while (itr.hasNext()) {
+ found.add(itr.next());
+ }
+
+ checkThat(ss.containsAll(found));
+ checkThat(found.containsAll(ss));
+
+ java.util.AbstractSet<String> ss2 = new StringSet(ss);
+ checkThat(ss2.containsAll(ss));
+ checkThat(ss.containsAll(ss2));
+
+ checkThat(!ss.removeAll(java.util.Arrays.asList("five", "four")));
+ checkThat(ss.removeAll(found));
+ checkThat(ss.isEmpty());
+ checkThat(ss.size() == 0);
+
+ // Check a set of another type.
+ java.util.AbstractSet<Foo> fooSet = new FooSet();
+ checkThat(fooSet.isEmpty());
+ checkThat(fooSet.add(new Foo(17)));
+ checkThat(fooSet.size() == 1);
+
+ // And a set of primitive type.
+ java.util.AbstractSet<Integer> intSet = new IntSet();
+ checkThat(intSet.isEmpty());
+ checkThat(intSet.add(17));
+ checkThat(!intSet.add(17));
+ checkThat(intSet.size() == 1);
+ checkThat(intSet.add(289));
+ checkThat(intSet.size() == 2);
+ }
+}
diff --git a/Examples/test-suite/java/li_std_vector_runme.java b/Examples/test-suite/java/li_std_vector_runme.java
index b422655a4..d4c0c95c7 100644
--- a/Examples/test-suite/java/li_std_vector_runme.java
+++ b/Examples/test-suite/java/li_std_vector_runme.java
@@ -4,21 +4,68 @@ public class li_std_vector_runme {
static {
try {
- System.loadLibrary("li_std_vector");
+ System.loadLibrary("li_std_vector");
} 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 checkThat(boolean mustBeTrue) throws Throwable {
+ if (!mustBeTrue) {
+ // Index [2], since this function is one hop away from main, and [1] is the current method.
+ throw new RuntimeException("Test failed at line number " + Thread.currentThread().getStackTrace()[2].getLineNumber());
+ }
+ }
+
public static void main(String argv[]) throws Throwable
{
IntVector v1 = li_std_vector.vecintptr(new IntVector());
IntPtrVector v2 = li_std_vector.vecintptr(new IntPtrVector());
IntConstPtrVector v3 = li_std_vector.vecintconstptr(new IntConstPtrVector());
+ checkThat(v1.isEmpty());
+ checkThat(v1.size() == 0);
+ checkThat(v1.add(123));
+ checkThat(v1.size() == 1);
+ checkThat(!v1.isEmpty());
+
+ int sum = 0;
+ for (int n : v1) {
+ checkThat(n == 123);
+ sum += n;
+ }
+ checkThat(sum == 123);
+ checkThat(v1.get(0) == 123);
+ v1.clear();
+ checkThat(v1.isEmpty());
v1.add(123);
- if (v1.get(0) != 123) throw new RuntimeException("v1 test failed");
+
+ checkThat(v1.set(0, 456) == 123);
+ checkThat(v1.size() == 1);
+ checkThat(v1.get(0) == 456);
+
+ java.util.Iterator<Integer> v1_iterator = v1.iterator();
+ checkThat(v1_iterator.hasNext());
+ checkThat(v1_iterator.next() == 456);
+ checkThat(!v1_iterator.hasNext());
+ try {
+ v1_iterator.next();
+ checkThat(false);
+ } catch (java.util.NoSuchElementException e) {
+ }
+
+ checkThat(!v1.remove(Integer.valueOf(123)));
+ checkThat(v1.remove(Integer.valueOf(456)));
+ checkThat(v1.isEmpty());
+ checkThat(v1.size() == 0);
+ checkThat(!v1.remove(Integer.valueOf(456)));
+
+ checkThat(new IntVector(3, 0).size() == 3);
+ for (int n : new IntVector(10, 999))
+ checkThat(n == 999);
+ for (int n : new IntVector(new IntVector(10, 999)))
+ checkThat(n == 999);
StructVector v4 = li_std_vector.vecstruct(new StructVector());
StructPtrVector v5 = li_std_vector.vecstructptr(new StructPtrVector());
@@ -28,9 +75,109 @@ public class li_std_vector_runme {
v5.add(new Struct(34));
v6.add(new Struct(56));
- Struct s = null;
- if (v4.get(0).getNum() != 12) throw new RuntimeException("v4 test failed");
- if (v5.get(0).getNum() != 34) throw new RuntimeException("v5 test failed");
- if (v6.get(0).getNum() != 56) throw new RuntimeException("v6 test failed");
+ checkThat(v4.get(0).getNum() == 12);
+ checkThat(v5.get(0).getNum() == 34);
+ checkThat(v6.get(0).getNum() == 56);
+
+ for (Struct s : v4) {
+ checkThat(s.getNum() == 12);
+ }
+ for (Struct s : v5) {
+ checkThat(s.getNum() == 34);
+ }
+ for (Struct s : v6) {
+ checkThat(s.getNum() == 56);
+ }
+
+ StructVector v7 = li_std_vector.vecstruct(new StructVector());
+ v7.add(new Struct(1));
+ v7.add(new Struct(23));
+ v7.add(new Struct(456));
+ v7.add(new Struct(7890));
+ checkThat(v7.size() == 4);
+ {
+ double[] a7 = {1, 23, 456, 7890};
+ int i7 = 0;
+ for (Struct s7 : v7) {
+ checkThat(s7.getNum() == a7[i7]);
+ i7++;
+ }
+ checkThat(i7 == a7.length);
+ }
+ checkThat(v7.remove(2).getNum() == 456);
+ {
+ double[] a7 = {1, 23, 7890};
+ int i7 = 0;
+ for (Struct s7 : v7) {
+ checkThat(s7.getNum() == a7[i7]);
+ i7++;
+ }
+ checkThat(i7 == a7.length);
+ }
+ v7.add(1, new Struct(123));
+ {
+ double[] a7 = {1, 123, 23, 7890};
+ int i7 = 0;
+ for (Struct s7 : v7) {
+ checkThat(s7.getNum() == a7[i7]);
+ i7++;
+ }
+ checkThat(i7 == a7.length);
+ }
+
+ BoolVector v8 = new BoolVector();
+ checkThat(v8.add(true));
+ checkThat(v8.get(0) == true);
+ checkThat(v8.set(0, false) == true);
+ checkThat(v8.set(0, false) == false);
+ checkThat(v8.size() == 1);
+
+ java.util.ArrayList<Boolean> bl = new java.util.ArrayList<Boolean>(java.util.Arrays.asList(true, false, true, false));
+ BoolVector bv = new BoolVector(java.util.Arrays.asList(true, false, true, false));
+ BoolVector bv2 = new BoolVector(bl);
+ java.util.ArrayList<Boolean> bl2 = new java.util.ArrayList<Boolean>(bv);
+ boolean bbb1 = bv.get(0);
+ Boolean bbb2 = bv.get(0);
+
+ IntVector v9 = new IntVector(java.util.Arrays.asList(10, 20, 30, 40));
+ v9.add(50);
+ v9.add(60);
+ v9.add(70);
+ checkThat(v9.size() == 7);
+ checkThat(v9.remove(Integer.valueOf(60)));
+ checkThat(v9.size() == 6);
+
+ IntVector v10 = new IntVector(java.util.Arrays.asList(10, 20, 30, 40, 50));
+ v10.subList(1, 4).clear(); // Recommended way to call protected method removeRange(1,3)
+ checkThat(v10.size() == 2);
+ checkThat(v10.get(0) == 10);
+ checkThat(v10.get(1) == 50);
+ v10.addAll(1, java.util.Arrays.asList(22, 33));
+ checkThat(v10.size() == 4);
+ checkThat(v10.get(1) == 22);
+ checkThat(v10.get(2) == 33);
+
+ v10.add(v10.size(), 55);
+ checkThat(v10.size() == 5);
+ checkThat(v10.get(4) == 55);
+
+ IntVector v11 = new IntVector(java.util.Arrays.asList(11, 22, 33, 44));
+ v11.listIterator(0);
+ v11.listIterator(v11.size());
+ try {
+ v11.listIterator(v11.size() + 1);
+ checkThat(false);
+ } catch (IndexOutOfBoundsException e) {
+ }
+ try {
+ v11.listIterator(-1);
+ checkThat(false);
+ } catch (IndexOutOfBoundsException e) {
+ }
+
+ IntVector arrayInit = new IntVector(new int[]{1, 2, 3, 4, 5});
+ checkThat(arrayInit.size() == 5);
+ checkThat(arrayInit.get(0) == 1);
+ checkThat(arrayInit.get(4) == 5);
}
}
diff --git a/Examples/test-suite/java/long_long_runme.java b/Examples/test-suite/java/long_long_runme.java
index 76aa0705d..65a0e79b3 100644
--- a/Examples/test-suite/java/long_long_runme.java
+++ b/Examples/test-suite/java/long_long_runme.java
@@ -84,14 +84,14 @@ public class long_long_runme {
ArrayList<BigInteger> bigIntegers = new ArrayList<BigInteger>();
for (int i=0; i<nums.length; ++i) {
- BigInteger bi = new BigInteger(new Long(nums[i]).toString());
+ BigInteger bi = new BigInteger(Long.valueOf(nums[i]).toString());
bigIntegers.add(bi);
}
{
- BigInteger bi = new BigInteger(new Long(Long.MAX_VALUE).toString());
+ BigInteger bi = new BigInteger(Long.valueOf(Long.MAX_VALUE).toString());
bigIntegers.add(bi.add(BigInteger.ONE));
- bi = new BigInteger(new Long(Long.MIN_VALUE).toString());
+ bi = new BigInteger(Long.valueOf(Long.MIN_VALUE).toString());
bigIntegers.add(bi.subtract(BigInteger.ONE));
}
diff --git a/Examples/test-suite/java/member_pointer_const_runme.java b/Examples/test-suite/java/member_pointer_const_runme.java
new file mode 100644
index 000000000..89735d3eb
--- /dev/null
+++ b/Examples/test-suite/java/member_pointer_const_runme.java
@@ -0,0 +1,60 @@
+import member_pointer_const.*;
+
+public class member_pointer_const_runme {
+
+ static {
+ try {
+ System.loadLibrary("member_pointer_const");
+ } 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 SWIGTYPE_m_Shape__f_void__double memberPtr = null;
+
+ public static void main(String argv[]) {
+ // Get the pointers
+
+ SWIGTYPE_m_Shape__f_void__double area_pt = member_pointer_const.areapt();
+ SWIGTYPE_m_Shape__f_void__double perim_pt = member_pointer_const.perimeterpt();
+
+ // Create some objects
+
+ Square s = new Square(10);
+
+ // Do some calculations
+
+ check( "Square area ", 100.0, member_pointer_const.do_op(s,area_pt) );
+ check( "Square perim", 40.0, member_pointer_const.do_op(s,perim_pt) );
+
+ memberPtr = member_pointer_const.getAreavar();
+ memberPtr = member_pointer_const.getPerimetervar();
+
+ // Try the variables
+ check( "Square area ", 100.0, member_pointer_const.do_op(s,member_pointer_const.getAreavar()) );
+ check( "Square perim", 40.0, member_pointer_const.do_op(s,member_pointer_const.getPerimetervar()) );
+
+ // Modify one of the variables
+ member_pointer_const.setAreavar(perim_pt);
+
+ check( "Square perimeter", 40.0, member_pointer_const.do_op(s,member_pointer_const.getAreavar()) );
+
+ // Try the constants
+
+ memberPtr = member_pointer_const.AREAPT;
+ memberPtr = member_pointer_const.PERIMPT;
+ memberPtr = member_pointer_const.NULLPT;
+
+ check( "Square area ", 100.0, member_pointer_const.do_op(s,member_pointer_const.AREAPT) );
+ check( "Square perim", 40.0, member_pointer_const.do_op(s,member_pointer_const.PERIMPT) );
+
+ // Typedefs
+ check( "Square perim", 40.0, member_pointer_const.do_op_td(s,perim_pt) );
+ }
+
+ private static void check(String what, double expected, double actual) {
+ if (expected != actual)
+ throw new RuntimeException("Failed: " + what + " Expected: " + expected + " Actual: " + actual);
+ }
+}
diff --git a/Examples/test-suite/java/member_pointer_runme.java b/Examples/test-suite/java/member_pointer_runme.java
index f8dcfbcb8..d0520a99c 100644
--- a/Examples/test-suite/java/member_pointer_runme.java
+++ b/Examples/test-suite/java/member_pointer_runme.java
@@ -49,6 +49,8 @@ public class member_pointer_runme {
check( "Square area ", 100.0, member_pointer.do_op(s,member_pointer.AREAPT) );
check( "Square perim", 40.0, member_pointer.do_op(s,member_pointer.PERIMPT) );
+ // Typedefs
+ check( "Square perim", 40.0, member_pointer.do_op_td(s,perim_pt) );
}
private static void check(String what, double expected, double actual) {
diff --git a/Examples/test-suite/java/namespace_chase_runme.java b/Examples/test-suite/java/namespace_chase_runme.java
new file mode 100644
index 000000000..9b4898bd0
--- /dev/null
+++ b/Examples/test-suite/java/namespace_chase_runme.java
@@ -0,0 +1,26 @@
+
+import namespace_chase.*;
+
+public class namespace_chase_runme {
+
+ static {
+ try {
+ System.loadLibrary("namespace_chase");
+ } 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[])
+ {
+ Struct1A s1a = new Struct1A();
+ Struct1B s1b = new Struct1B();
+ Struct1C s1c = new Struct1C();
+
+ namespace_chase.sss3a(s1a, s1b, s1c);
+ namespace_chase.sss3b(s1a, s1b, s1c);
+ // needs fixing
+// namespace_chase.sss3c(s1a, s1b, s1c);
+ }
+}
diff --git a/Examples/test-suite/java/namespace_template_runme.java b/Examples/test-suite/java/namespace_template_runme.java
new file mode 100644
index 000000000..c0c7ba135
--- /dev/null
+++ b/Examples/test-suite/java/namespace_template_runme.java
@@ -0,0 +1,32 @@
+
+import namespace_template.*;
+
+public class namespace_template_runme {
+
+ static {
+ try {
+ System.loadLibrary("namespace_template");
+ } 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[]) {
+ vectorchar vc = new vectorchar();
+ vectorshort vs = new vectorshort();
+ vectorint vi = new vectorint();
+ vectorlong vl = new vectorlong();
+
+ vc.blah((char)10);
+ vs.blah((short)10);
+ vi.blah(10);
+ vl.blah(10);
+
+ vc.vectoruse(vc, vc);
+ vs.vectoruse(vs, vs);
+ vi.vectoruse(vi, vi);
+ vl.vectoruse(vl, vl);
+ }
+}
+
diff --git a/Examples/test-suite/java/native_directive_runme.java b/Examples/test-suite/java/native_directive_runme.java
new file mode 100644
index 000000000..fc83ba2d0
--- /dev/null
+++ b/Examples/test-suite/java/native_directive_runme.java
@@ -0,0 +1,22 @@
+import native_directive.*;
+
+public class native_directive_runme {
+
+ static {
+ try {
+ System.loadLibrary("native_directive");
+ } 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[]) {
+ String s = "abc.DEF-123";
+ if (native_directive.CountAlphas(s) != 6)
+ throw new RuntimeException("CountAlphas failed");
+ if (native_directive.CountAlphaCharacters(s) != 6)
+ throw new RuntimeException("CountAlphaCharacters failed");
+ }
+}
+
diff --git a/Examples/test-suite/java/nested_inheritance_interface_runme.java b/Examples/test-suite/java/nested_inheritance_interface_runme.java
new file mode 100644
index 000000000..8436ec294
--- /dev/null
+++ b/Examples/test-suite/java/nested_inheritance_interface_runme.java
@@ -0,0 +1,32 @@
+import nested_inheritance_interface.*;
+import java.util.Arrays;
+
+public class nested_inheritance_interface_runme {
+
+ static {
+ try {
+ System.loadLibrary("nested_inheritance_interface");
+ } 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 takeIA(IASwigInterface ia) {
+ }
+
+ public static void main(String argv[]) {
+ Class[] BNInterfaces = B.N.class.getInterfaces();
+ String expectedInterfacesString = "[interface nested_inheritance_interface.IASwigInterface]";
+ String actualInterfacesString = Arrays.toString(BNInterfaces);
+ if (!expectedInterfacesString.equals(actualInterfacesString))
+ throw new RuntimeException("Expected interfaces for " + B.N.class.getName() + ": \n" + expectedInterfacesString + "\n" + "Actual interfaces: \n" + actualInterfacesString);
+
+ if (!IASwigInterface.class.isInterface())
+ throw new RuntimeException(IASwigInterface.class.getName() + " should be an interface but is not");
+
+ // overloaded methods check
+ B.N d = new B.N();
+ takeIA(d);
+ }
+}
diff --git a/Examples/test-suite/java/proxycode_runme.java b/Examples/test-suite/java/proxycode_runme.java
new file mode 100644
index 000000000..cf981e723
--- /dev/null
+++ b/Examples/test-suite/java/proxycode_runme.java
@@ -0,0 +1,42 @@
+import proxycode.*;
+
+public class proxycode_runme {
+
+ static {
+ try {
+ System.loadLibrary("proxycode");
+ } 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[]) throws Throwable
+ {
+ if (new Proxy1().proxycode1(100) != 101)
+ throw new RuntimeException("Fail");
+ if (new Proxy2().proxycode2a(100) != 102)
+ throw new RuntimeException("Fail");
+ if (new Proxy2().proxycode2b(100) != 102)
+ throw new RuntimeException("Fail");
+ if (new Proxy3().proxycode3(100) != 103)
+ throw new RuntimeException("Fail");
+
+ if (new Proxy4().proxycode4(100) != 104)
+ throw new RuntimeException("Fail");
+ if (new Proxy4.Proxy4Nested().proxycode4nested(100) != 144)
+ throw new RuntimeException("Fail");
+
+ if (new Proxy5a().proxycode5((short)100) != (short)100)
+ throw new RuntimeException("Fail");
+ if (new Proxy5b().proxycode5(100) != 100)
+ throw new RuntimeException("Fail");
+ if (new Proxy5b().proxycode5(100, 100) != 255)
+ throw new RuntimeException("Fail");
+
+ long t1 = 10;
+ long t2 = 100;
+ Proxy6 p = new Proxy6().proxyUseT(t1, t2);
+ p.useT(t1, t2);
+ }
+}
diff --git a/Examples/test-suite/java/rename1_runme.java b/Examples/test-suite/java/rename1_runme.java
index 058de41fd..c04baf81f 100644
--- a/Examples/test-suite/java/rename1_runme.java
+++ b/Examples/test-suite/java/rename1_runme.java
@@ -24,7 +24,6 @@ public class rename1_runme {
xyz.tMethod2(0);
xyz.tMethodNotXYZ2(notxyz);
xyz.opNotXYZ2();
- xyz.opXYZ2();
}
{
XYZDouble xyz = new XYZDouble();
@@ -36,7 +35,6 @@ public class rename1_runme {
xyz.tMethod1(0);
xyz.tMethodNotXYZ1(notxyz);
xyz.opNotXYZ1();
- xyz.opXYZ1();
}
{
XYZKlass xyz = new XYZKlass();
@@ -48,7 +46,6 @@ public class rename1_runme {
xyz.tMethod3(new Klass());
xyz.tMethodNotXYZ3(notxyz);
xyz.opNotXYZ3();
- xyz.opXYZ3();
}
{
XYZEnu xyz = new XYZEnu();
@@ -60,7 +57,6 @@ public class rename1_runme {
xyz.tMethod4(Enu.En1);
xyz.tMethodNotXYZ4(notxyz);
xyz.opNotXYZ4();
- xyz.opXYZ4();
}
{
ABC abc = new ABC();
diff --git a/Examples/test-suite/java/rename2_runme.java b/Examples/test-suite/java/rename2_runme.java
index b6a62dd1e..b97cc59ed 100644
--- a/Examples/test-suite/java/rename2_runme.java
+++ b/Examples/test-suite/java/rename2_runme.java
@@ -24,7 +24,6 @@ public class rename2_runme {
xyz.tMethod2(0);
xyz.tMethodNotXYZ2(notxyz);
xyz.opNotXYZ2();
- xyz.opXYZ2();
}
{
XYZDouble xyz = new XYZDouble();
@@ -36,7 +35,6 @@ public class rename2_runme {
xyz.tMethod1(0);
xyz.tMethodNotXYZ1(notxyz);
xyz.opNotXYZ1();
- xyz.opXYZ1();
}
{
XYZKlass xyz = new XYZKlass();
@@ -48,7 +46,6 @@ public class rename2_runme {
xyz.tMethod3(new Klass());
xyz.tMethodNotXYZ3(notxyz);
xyz.opNotXYZ3();
- xyz.opXYZ3();
}
{
XYZEnu xyz = new XYZEnu();
@@ -60,7 +57,6 @@ public class rename2_runme {
xyz.tMethod4(Enu.En1);
xyz.tMethodNotXYZ4(notxyz);
xyz.opNotXYZ4();
- xyz.opXYZ4();
}
{
ABC abc = new ABC();
diff --git a/Examples/test-suite/java/rename3_runme.java b/Examples/test-suite/java/rename3_runme.java
index e1b090af8..222d54899 100644
--- a/Examples/test-suite/java/rename3_runme.java
+++ b/Examples/test-suite/java/rename3_runme.java
@@ -24,7 +24,6 @@ public class rename3_runme {
xyz.tMethod2(0);
xyz.tMethodNotXYZ2(notxyz);
xyz.opNotXYZ2();
- xyz.opXYZ2();
}
{
XYZDouble xyz = new XYZDouble();
@@ -36,7 +35,6 @@ public class rename3_runme {
xyz.tMethod1(0);
xyz.tMethodNotXYZ1(notxyz);
xyz.opNotXYZ1();
- xyz.opXYZ1();
}
{
XYZKlass xyz = new XYZKlass();
@@ -48,7 +46,6 @@ public class rename3_runme {
xyz.tMethod3(new Klass());
xyz.tMethodNotXYZ3(notxyz);
xyz.opNotXYZ3();
- xyz.opXYZ3();
}
{
XYZEnu xyz = new XYZEnu();
@@ -60,7 +57,6 @@ public class rename3_runme {
xyz.tMethod4(Enu.En1);
xyz.tMethodNotXYZ4(notxyz);
xyz.opNotXYZ4();
- xyz.opXYZ4();
}
{
ABC abc = new ABC();
diff --git a/Examples/test-suite/java/rename4_runme.java b/Examples/test-suite/java/rename4_runme.java
index 69f909e9e..ef92dd300 100644
--- a/Examples/test-suite/java/rename4_runme.java
+++ b/Examples/test-suite/java/rename4_runme.java
@@ -24,7 +24,6 @@ public class rename4_runme {
xyz.tMethod2(0);
xyz.tMethodNotXYZ2(notxyz);
xyz.opNotXYZ2();
- xyz.opXYZ2();
}
{
XYZDouble xyz = new XYZDouble();
@@ -36,7 +35,6 @@ public class rename4_runme {
xyz.tMethod1(0);
xyz.tMethodNotXYZ1(notxyz);
xyz.opNotXYZ1();
- xyz.opXYZ1();
}
{
XYZKlass xyz = new XYZKlass();
@@ -48,7 +46,6 @@ public class rename4_runme {
xyz.tMethod3(new Klass());
xyz.tMethodNotXYZ3(notxyz);
xyz.opNotXYZ3();
- xyz.opXYZ3();
}
{
XYZEnu xyz = new XYZEnu();
@@ -60,7 +57,6 @@ public class rename4_runme {
xyz.tMethod4(Enu.En1);
xyz.tMethodNotXYZ4(notxyz);
xyz.opNotXYZ4();
- xyz.opXYZ4();
}
{
ABC abc = new ABC();
diff --git a/Examples/test-suite/java/template_class_reuse_name_runme.java b/Examples/test-suite/java/template_class_reuse_name_runme.java
new file mode 100644
index 000000000..cda91d00d
--- /dev/null
+++ b/Examples/test-suite/java/template_class_reuse_name_runme.java
@@ -0,0 +1,57 @@
+import template_class_reuse_name.*;
+
+public class template_class_reuse_name_runme {
+
+ static {
+ try {
+ System.loadLibrary("template_class_reuse_name");
+ } 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[])
+ {
+ new Bool1().tt();
+ new Bool1False().ff();
+
+ new Bool2().tt();
+ new Bool2False().ff();
+
+ new Bool3().tt();
+ new Bool3False().ff();
+
+ new Bool4().tt();
+ new Bool4False().ff();
+
+
+ new BoolForward1().tt();
+ new BoolForward1False().ff();
+
+ new BoolForward2().tt();
+ new BoolForward2False().ff();
+
+ new BoolForward3().tt();
+ new BoolForward3False().ff();
+
+ new BoolForward4().tt();
+ new BoolForward4False().ff();
+
+
+ new IntBool1().tt();
+ new IntBool1False().ff();
+
+ new IntBool2().tt();
+ new IntBool2False().ff();
+
+ new IntBool3().tt();
+ new IntBool3False().ff();
+
+ new IntBool4().tt();
+ new IntBool4False().ff();
+
+ new Duplicate2_0().n();
+ new Duplicate3().n();
+ }
+}
diff --git a/Examples/test-suite/java/template_default_cache_runme.java b/Examples/test-suite/java/template_default_cache_runme.java
new file mode 100644
index 000000000..90b584261
--- /dev/null
+++ b/Examples/test-suite/java/template_default_cache_runme.java
@@ -0,0 +1,18 @@
+import template_default_cache.*;
+
+public class template_default_cache_runme {
+
+ static {
+ try {
+ System.loadLibrary("template_default_cache");
+ } 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[]) {
+ AModelPtr ap = template_default_cache.get_mp_a();
+ BModelPtr bp = template_default_cache.get_mp_b();
+ }
+}
diff --git a/Examples/test-suite/java/template_parameters_global_scope_runme.java b/Examples/test-suite/java/template_parameters_global_scope_runme.java
new file mode 100644
index 000000000..a536fe476
--- /dev/null
+++ b/Examples/test-suite/java/template_parameters_global_scope_runme.java
@@ -0,0 +1,75 @@
+import template_parameters_global_scope.*;
+
+public class template_parameters_global_scope_runme {
+
+ static {
+ try {
+ System.loadLibrary("template_parameters_global_scope");
+ } 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[]) {
+
+ int alloc = 0;
+
+ // Check 1
+ alloc = template_parameters_global_scope.Bucket1();
+ alloc = template_parameters_global_scope.Bucket2();
+ alloc = template_parameters_global_scope.Bucket3();
+ alloc = template_parameters_global_scope.Bucket4();
+ alloc = template_parameters_global_scope.Bucket5();
+ alloc = template_parameters_global_scope.Bucket6();
+
+ // Check 2
+ alloc = template_parameters_global_scope.Spade1();
+ alloc = template_parameters_global_scope.Spade2();
+ alloc = template_parameters_global_scope.Spade3();
+ alloc = template_parameters_global_scope.Spade4();
+ alloc = template_parameters_global_scope.Spade5();
+ alloc = template_parameters_global_scope.Spade6();
+
+ // Check 3
+ alloc = template_parameters_global_scope.Ball1();
+ alloc = template_parameters_global_scope.Ball2();
+ alloc = template_parameters_global_scope.Ball3();
+ alloc = template_parameters_global_scope.Ball4();
+ alloc = template_parameters_global_scope.Ball5();
+ alloc = template_parameters_global_scope.Ball6();
+
+ // Check 4
+ alloc = template_parameters_global_scope.Bat1();
+ alloc = template_parameters_global_scope.Bat2();
+ alloc = template_parameters_global_scope.Bat3();
+ alloc = template_parameters_global_scope.Bat4();
+ alloc = template_parameters_global_scope.Bat5();
+ alloc = template_parameters_global_scope.Bat6();
+
+ // Check 5
+ alloc = template_parameters_global_scope.Chair1();
+ alloc = template_parameters_global_scope.Chair2();
+ alloc = template_parameters_global_scope.Chair3();
+ alloc = template_parameters_global_scope.Chair4();
+ alloc = template_parameters_global_scope.Chair5();
+ alloc = template_parameters_global_scope.Chair6();
+
+ // Check 6
+ alloc = template_parameters_global_scope.Table1();
+ alloc = template_parameters_global_scope.Table2();
+ alloc = template_parameters_global_scope.Table3();
+ alloc = template_parameters_global_scope.Table4();
+ alloc = template_parameters_global_scope.Table5();
+ alloc = template_parameters_global_scope.Table6();
+
+ /*
+ alloc = template_parameters_global_scope.rejig1();
+ alloc = template_parameters_global_scope.rejig2();
+ alloc = template_parameters_global_scope.rejig3();
+ alloc = template_parameters_global_scope.rejig4();
+ alloc = template_parameters_global_scope.rejig5();
+ alloc = template_parameters_global_scope.rejig6();
+ */
+ }
+}
diff --git a/Examples/test-suite/java/template_partial_specialization_runme.java b/Examples/test-suite/java/template_partial_specialization_runme.java
index ef8c4e80e..097c33d86 100644
--- a/Examples/test-suite/java/template_partial_specialization_runme.java
+++ b/Examples/test-suite/java/template_partial_specialization_runme.java
@@ -23,10 +23,10 @@ public class template_partial_specialization_runme {
new G().g();
new H().h();
- new I().i();
new J().j();
new K().k();
- new L().l();
+ new M().m();
+ new N().n();
new BB().b();
new BBB().b();
diff --git a/Examples/test-suite/java/template_partial_specialization_typedef_runme.java b/Examples/test-suite/java/template_partial_specialization_typedef_runme.java
index 6ae95eb6a..04653cdc0 100644
--- a/Examples/test-suite/java/template_partial_specialization_typedef_runme.java
+++ b/Examples/test-suite/java/template_partial_specialization_typedef_runme.java
@@ -23,10 +23,10 @@ public class template_partial_specialization_typedef_runme {
new G().g();
new H().h();
- new I().i();
new J().j();
new K().k();
- new L().l();
+ new M().m();
+ new N().n();
new BB().b();
new BBB().b();
diff --git a/Examples/test-suite/java/template_using_directive_and_declaration_forward_runme.java b/Examples/test-suite/java/template_using_directive_and_declaration_forward_runme.java
index 080945e02..3aab5fa8f 100644
--- a/Examples/test-suite/java/template_using_directive_and_declaration_forward_runme.java
+++ b/Examples/test-suite/java/template_using_directive_and_declaration_forward_runme.java
@@ -19,32 +19,32 @@ public class template_using_directive_and_declaration_forward_runme {
template_using_directive_and_declaration_forward.useit1b(new Thing1Int());
template_using_directive_and_declaration_forward.useit1c(new Thing1Int());
-//BROKEN template_using_directive_and_declaration_forward.useit2(new Thing2Int());
+ template_using_directive_and_declaration_forward.useit2(new Thing2Int());
template_using_directive_and_declaration_forward.useit2a(new Thing2Int());
template_using_directive_and_declaration_forward.useit2b(new Thing2Int());
template_using_directive_and_declaration_forward.useit2c(new Thing2Int());
template_using_directive_and_declaration_forward.useit2d(new Thing2Int());
-//BROKEN template_using_directive_and_declaration_forward.useit3(new Thing3Int());
+ template_using_directive_and_declaration_forward.useit3(new Thing3Int());
template_using_directive_and_declaration_forward.useit3a(new Thing3Int());
template_using_directive_and_declaration_forward.useit3b(new Thing3Int());
template_using_directive_and_declaration_forward.useit3c(new Thing3Int());
template_using_directive_and_declaration_forward.useit3d(new Thing3Int());
-//BROKEN template_using_directive_and_declaration_forward.useit4(new Thing4Int());
+ template_using_directive_and_declaration_forward.useit4(new Thing4Int());
template_using_directive_and_declaration_forward.useit4a(new Thing4Int());
template_using_directive_and_declaration_forward.useit4b(new Thing4Int());
template_using_directive_and_declaration_forward.useit4c(new Thing4Int());
template_using_directive_and_declaration_forward.useit4d(new Thing4Int());
-//BROKEN template_using_directive_and_declaration_forward.useit5(new Thing5Int());
+ template_using_directive_and_declaration_forward.useit5(new Thing5Int());
template_using_directive_and_declaration_forward.useit5a(new Thing5Int());
template_using_directive_and_declaration_forward.useit5b(new Thing5Int());
template_using_directive_and_declaration_forward.useit5c(new Thing5Int());
template_using_directive_and_declaration_forward.useit5d(new Thing5Int());
-//BROKEN template_using_directive_and_declaration_forward.useit7(new Thing7Int());
+ template_using_directive_and_declaration_forward.useit7(new Thing7Int());
template_using_directive_and_declaration_forward.useit7a(new Thing7Int());
template_using_directive_and_declaration_forward.useit7b(new Thing7Int());
template_using_directive_and_declaration_forward.useit7c(new Thing7Int());
diff --git a/Examples/test-suite/java/template_using_directive_typedef_runme.java b/Examples/test-suite/java/template_using_directive_typedef_runme.java
new file mode 100644
index 000000000..bec077399
--- /dev/null
+++ b/Examples/test-suite/java/template_using_directive_typedef_runme.java
@@ -0,0 +1,31 @@
+
+import template_using_directive_typedef.*;
+
+public class template_using_directive_typedef_runme {
+
+ static {
+ try {
+ System.loadLibrary("template_using_directive_typedef");
+ } 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[]) {
+ Vector_Obj vo = new Vector_Obj();
+
+ Holder h = new Holder();
+ h.holder_use1(vo, vo, vo);
+ h.holder_use2(vo, vo, vo);
+ h.holder_use3(vo, vo, vo);
+
+ template_using_directive_typedef.tns_holder_use(vo, vo);
+ template_using_directive_typedef.tns_use(vo, vo, vo);
+ template_using_directive_typedef.global_holder_use(vo);
+ template_using_directive_typedef.global_use(vo, vo, vo);
+ template_using_directive_typedef.ns1_holder_use(vo);
+ template_using_directive_typedef.ns2_holder_use(vo, vo, vo, vo);
+ }
+}
+
diff --git a/Examples/test-suite/java/typedef_classforward_same_name_runme.java b/Examples/test-suite/java/typedef_classforward_same_name_runme.java
new file mode 100644
index 000000000..86e713d14
--- /dev/null
+++ b/Examples/test-suite/java/typedef_classforward_same_name_runme.java
@@ -0,0 +1,26 @@
+
+import typedef_classforward_same_name.*;
+
+public class typedef_classforward_same_name_runme {
+
+ static {
+ try {
+ System.loadLibrary("typedef_classforward_same_name");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+ Foo foo = new Foo();
+ foo.setX(5);
+ if (typedef_classforward_same_name.extractFoo(foo) != 5)
+ throw new RuntimeException("unexpected value");
+
+ Boo boo = new Boo();
+ boo.setX(5);
+ if (typedef_classforward_same_name.extractBoo(boo) != 5)
+ throw new RuntimeException("unexpected value");
+ }
+}
diff --git a/Examples/test-suite/java/typedef_funcptr_runme.java b/Examples/test-suite/java/typedef_funcptr_runme.java
new file mode 100644
index 000000000..0dd44cecd
--- /dev/null
+++ b/Examples/test-suite/java/typedef_funcptr_runme.java
@@ -0,0 +1,34 @@
+
+import typedef_funcptr.*;
+
+public class typedef_funcptr_runme {
+
+ static {
+ try {
+ System.loadLibrary("typedef_funcptr");
+ } 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[]) {
+ int a = 100;
+ int b = 10;
+
+ if (typedef_funcptr.do_op(a,b,typedef_funcptr.addf) != 110)
+ throw new RuntimeException("addf failed");
+ if (typedef_funcptr.do_op(a,b,typedef_funcptr.subf) != 90)
+ throw new RuntimeException("subf failed");
+
+ if (typedef_funcptr.do_op_typedef_int(a,b,typedef_funcptr.addf) != 110)
+ throw new RuntimeException("addf failed");
+ if (typedef_funcptr.do_op_typedef_int(a,b,typedef_funcptr.subf) != 90)
+ throw new RuntimeException("subf failed");
+
+ if (typedef_funcptr.do_op_typedef_Integer(a,b,typedef_funcptr.addf) != 110)
+ throw new RuntimeException("addf failed");
+ if (typedef_funcptr.do_op_typedef_Integer(a,b,typedef_funcptr.subf) != 90)
+ throw new RuntimeException("subf failed");
+ }
+}
diff --git a/Examples/test-suite/java/typemap_template_parms_runme.java b/Examples/test-suite/java/typemap_template_parms_runme.java
new file mode 100644
index 000000000..3957ed6d3
--- /dev/null
+++ b/Examples/test-suite/java/typemap_template_parms_runme.java
@@ -0,0 +1,23 @@
+import typemap_template_parms.*;
+
+public class typemap_template_parms_runme {
+
+ static {
+ try {
+ System.loadLibrary("typemap_template_parms");
+ } 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[]) {
+ Xint xint = new Xint();
+ int i = 0;
+ i = xint.bake();
+ i = xint.make();
+ i = xint.lake();
+ i = xint.rake();
+ i = xint.take();
+ }
+}
diff --git a/Examples/test-suite/java_director.i b/Examples/test-suite/java_director.i
index 03d733d6a..6b2cb6dfe 100644
--- a/Examples/test-suite/java_director.i
+++ b/Examples/test-suite/java_director.i
@@ -7,6 +7,7 @@
%module(directors="1") java_director
%typemap(javafinalize) SWIGTYPE %{
+ @SuppressWarnings("deprecation")
protected void finalize() {
// System.out.println("Finalizing " + this);
delete();
diff --git a/Examples/test-suite/java_director_assumeoverride.i b/Examples/test-suite/java_director_assumeoverride.i
index cddebb4d7..f0eb37049 100644
--- a/Examples/test-suite/java_director_assumeoverride.i
+++ b/Examples/test-suite/java_director_assumeoverride.i
@@ -4,7 +4,7 @@
class OverrideMe {
public:
virtual ~OverrideMe() {}
- virtual void func() {};
+ virtual void funk() {};
};
#include "java_director_assumeoverride_wrap.h"
@@ -23,7 +23,7 @@ bool isFuncOverridden(OverrideMe* f) {
class OverrideMe {
public:
virtual ~OverrideMe();
- virtual void func();
+ virtual void funk();
};
bool isFuncOverridden(OverrideMe* f);
diff --git a/Examples/test-suite/java_director_exception_feature.i b/Examples/test-suite/java_director_exception_feature.i
index d6f1e3f55..7978ac2a1 100644
--- a/Examples/test-suite/java_director_exception_feature.i
+++ b/Examples/test-suite/java_director_exception_feature.i
@@ -4,18 +4,11 @@
%warnfilter(SWIGWARN_TYPEMAP_DIRECTORTHROWS_UNDEF) MyNS::Foo::directorthrows_warning;
-%{
-#if defined(_MSC_VER)
- #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
-
-#include <string>
-%}
-
%include <std_string.i>
// DEFINE exceptions in header section using std::runtime_error
%{
+ #include <string>
#include <exception>
#include <iostream>
@@ -39,7 +32,6 @@
%feature("director:except") MyNS::Foo::ping {
jthrowable $error = jenv->ExceptionOccurred();
if ($error) {
- jenv->ExceptionClear(); // clear java exception since mapping to c++ exception
if (Swig::ExceptionMatches(jenv,$error,"$packagepath/MyJavaException1")) {
throw 1;
} else if (Swig::ExceptionMatches(jenv,$error,"$packagepath/MyJavaException2")) {
@@ -68,7 +60,6 @@
%feature("director:except") MyNS::Foo::pong %{
jthrowable $error = jenv->ExceptionOccurred();
if ($error) {
- jenv->ExceptionClear();
$directorthrowshandlers
throw ::MyNS::Unexpected(Swig::JavaExceptionMessage(jenv,$error).message());
}
@@ -118,7 +109,10 @@
%feature("director:except") MyNS::Foo::genericpong {
jthrowable $error = jenv->ExceptionOccurred();
if ($error) {
- jenv->ExceptionClear();
+ if (Swig::ExceptionMatches(jenv,$error,"UnconstructableException")) {
+ // Purposefully test NULL
+ throw Swig::DirectorException(jenv, NULL);
+ }
throw Swig::DirectorException(jenv,$error);
}
}
@@ -128,9 +122,10 @@
%}
%feature ("except",throws="Exception") MyNS::Bar::genericpong %{
- try { $action }
- catch (Swig::DirectorException & direxcp) {
- direxcp.raiseJavaException(jenv); // jenv always available in JNI code
+ try {
+ $action
+ } catch (Swig::DirectorException & direxcp) {
+ direxcp.throwException(jenv); // jenv always available in JNI code
return $null;
}
%}
@@ -170,6 +165,18 @@ namespace MyNS {
%catches(MyNS::Exception1,MyNS::Exception2,MyNS::Unexpected) MyNS::Foo::pong;
%catches(MyNS::Exception1,MyNS::Exception2,MyNS::Unexpected) MyNS::Bar::pong;
+%{
+// throw is deprecated in C++11 and invalid in C++17 and later
+#if defined(__cplusplus) && __cplusplus >= 201103L
+#define throw(TYPE1, TYPE2)
+#else
+#define throw(TYPE1, TYPE2) throw(TYPE1, TYPE2)
+#if defined(_MSC_VER)
+ #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+#endif
+%}
+
%inline %{
namespace MyNS {
@@ -182,7 +189,7 @@ public:
virtual std::string ping(int excp) throw(int,MyNS::Exception2) = 0;
virtual std::string pong(int excp) /* throws MyNS::Exception1 MyNS::Exception2 MyNS::Unexpected) */ = 0;
virtual std::string genericpong(int excp) /* unspecified throws - exception is always DirectorException in C++, translated back to whatever thrown in java */ = 0;
- virtual std::string directorthrows_warning(int excp) throw(double) { return std::string(); }
+ virtual std::string directorthrows_warning(int excp) throw(int,double) { return std::string(); }
};
// Make a bar from a foo, so a call to Java Bar
diff --git a/Examples/test-suite/java_director_exception_feature_nspace.i b/Examples/test-suite/java_director_exception_feature_nspace.i
index 264c2a938..b52c1acf4 100644
--- a/Examples/test-suite/java_director_exception_feature_nspace.i
+++ b/Examples/test-suite/java_director_exception_feature_nspace.i
@@ -11,18 +11,11 @@
#define PACKAGESLASH "java_director_exception_feature_nspacePackage/"
%}
-%{
-#if defined(_MSC_VER)
- #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
-
-#include <string>
-%}
-
%include <std_string.i>
// DEFINE exceptions in header section using std::runtime_error
%{
+ #include <string>
#include <exception>
#include <iostream>
@@ -46,7 +39,6 @@
%feature("director:except") MyNS::Foo::ping {
jthrowable $error = jenv->ExceptionOccurred();
if ($error) {
- jenv->ExceptionClear(); // clear java exception since mapping to c++ exception
if (Swig::ExceptionMatches(jenv,$error,"$packagepath/MyNS/MyJavaException1")) {
throw 1;
} else if (Swig::ExceptionMatches(jenv,$error,"$packagepath/MyNS/MyJavaException2")) {
@@ -75,7 +67,6 @@
%feature("director:except") MyNS::Foo::pong %{
jthrowable $error = jenv->ExceptionOccurred();
if ($error) {
- jenv->ExceptionClear();
$directorthrowshandlers
throw ::MyNS::Unexpected(Swig::JavaExceptionMessage(jenv,$error).message());
}
@@ -125,7 +116,10 @@
%feature("director:except") MyNS::Foo::genericpong {
jthrowable $error = jenv->ExceptionOccurred();
if ($error) {
- jenv->ExceptionClear();
+ if (Swig::ExceptionMatches(jenv,$error,"java_director_exception_feature_nspace_UnconstructibleException")) {
+ // Purposefully test NULL
+ throw Swig::DirectorException(jenv, NULL);
+ }
throw Swig::DirectorException(jenv,$error);
}
}
@@ -135,9 +129,10 @@
%}
%feature ("except",throws="Exception") MyNS::Bar::genericpong %{
- try { $action }
- catch (Swig::DirectorException & direxcp) {
- direxcp.raiseJavaException(jenv); // jenv always available in JNI code
+ try {
+ $action
+ } catch (Swig::DirectorException & direxcp) {
+ direxcp.throwException(jenv); // jenv always available in JNI code
return $null;
}
%}
@@ -177,6 +172,18 @@ namespace MyNS {
%catches(MyNS::Exception1,MyNS::Exception2,MyNS::Unexpected) MyNS::Foo::pong;
%catches(MyNS::Exception1,MyNS::Exception2,MyNS::Unexpected) MyNS::Bar::pong;
+%{
+// throw is deprecated in C++11 and invalid in C++17 and later
+#if defined(__cplusplus) && __cplusplus >= 201103L
+#define throw(TYPE1, TYPE2)
+#else
+#define throw(TYPE1, TYPE2) throw(TYPE1, TYPE2)
+#if defined(_MSC_VER)
+ #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+#endif
+%}
+
%inline %{
namespace MyNS {
diff --git a/Examples/test-suite/java_director_typemaps.i b/Examples/test-suite/java_director_typemaps.i
new file mode 100644
index 000000000..2ffdeae89
--- /dev/null
+++ b/Examples/test-suite/java_director_typemaps.i
@@ -0,0 +1,368 @@
+%module(directors="1") java_director_typemaps
+// Test director reference typemaps in typemaps.i - similar to java_director_typemaps_ptr.i testcase
+
+%feature("director", assumeoverride=1) Quux;
+
+%include <typemaps.i>
+
+%apply bool& OUTPUT {bool&};
+
+%apply signed char& OUTPUT {signed char&};
+%apply unsigned char& OUTPUT {unsigned char&};
+
+%apply short& OUTPUT {short&};
+%apply unsigned short& OUTPUT {unsigned short&};
+
+%apply int& OUTPUT {int&};
+%apply unsigned int& OUTPUT {unsigned int&};
+
+%apply long& OUTPUT {long&};
+%apply unsigned long& OUTPUT {unsigned long&};
+
+%apply long long& OUTPUT {long long&};
+// %apply unsigned long long& OUTPUT {unsigned long long&};
+
+%apply float& OUTPUT {float&};
+%apply double& OUTPUT {double&};
+
+%apply bool& OUTPUT {bool& boolarg_output};
+
+%apply signed char& OUTPUT {signed char& signed_chararg_output};
+%apply unsigned char& OUTPUT {unsigned char& unsigned_chararg_output};
+
+%apply short& OUTPUT {short& shortarg_output};
+%apply unsigned short& OUTPUT {unsigned short& unsigned_shortarg_output};
+
+%apply int& OUTPUT {int& intarg_output};
+%apply unsigned int& OUTPUT {unsigned int& unsigned_intarg_output};
+
+%apply long& OUTPUT {long& longarg_output};
+%apply unsigned long& OUTPUT {unsigned long& unsigned_longarg_output};
+
+%apply long long& OUTPUT {long long& long_longarg_output};
+// %apply unsigned long long& OUTPUT {unsigned long long& unsigned_long_longarg_output};
+
+%apply float& OUTPUT {float& floatarg_output};
+%apply double& OUTPUT {double& doublearg_output};
+
+%apply bool& INOUT {bool& boolarg_inout};
+
+%apply signed char& INOUT {signed char& signed_chararg_inout};
+%apply unsigned char& INOUT {unsigned char& unsigned_chararg_inout};
+
+%apply short& INOUT {short& shortarg_inout};
+%apply unsigned short& INOUT {unsigned short& unsigned_shortarg_inout};
+
+%apply int& INOUT {int& intarg_inout};
+%apply unsigned int& INOUT {unsigned int& unsigned_intarg_inout};
+
+%apply long& INOUT {long& longarg_inout};
+%apply unsigned long& INOUT {unsigned long& unsigned_longarg_inout};
+
+%apply long long& INOUT {long long& long_longarg_inout};
+// %apply unsigned long long& INOUT {unsigned long long& unsigned_long_longarg_inout};
+
+%apply float& INOUT {float& floatarg_inout};
+%apply double& INOUT {double& doublearg_inout};
+
+%{
+#include <stdexcept>
+#define verify(ok) if (!(ok)) throw std::runtime_error(# ok);
+%}
+%inline %{
+
+class Quux {
+public:
+ Quux() {}
+ virtual ~Quux() {}
+
+ virtual void director_method_output(
+ bool& boolarg_output,
+
+ signed char& signed_chararg_output,
+ unsigned char& unsigned_chararg_output,
+
+ short& shortarg_output,
+ unsigned short& unsigned_shortarg_output,
+
+ int& intarg_output,
+ unsigned int& unsigned_intarg_output,
+
+ long& longarg_output,
+ unsigned long& unsigned_longarg_output,
+
+ long long& long_longarg_output,
+ // unsigned long long& unsigned_long_longarg_output,
+
+ float& floatarg_output,
+ double& doublearg_output)
+ {
+ boolarg_output = false;
+
+ signed_chararg_output = 50;
+ unsigned_chararg_output = 50;
+
+ shortarg_output = 50;
+ unsigned_shortarg_output = 50;
+
+ intarg_output = 50;
+ unsigned_intarg_output = 50;
+
+ longarg_output = 50;
+ unsigned_longarg_output = 50;
+
+ long_longarg_output = 50;
+ // unsigned_long_longarg_output = 50;
+
+ floatarg_output = 50;
+ doublearg_output = 50;
+ }
+
+ virtual void director_method_inout(
+ bool& boolarg_inout,
+
+ signed char& signed_chararg_inout,
+ unsigned char& unsigned_chararg_inout,
+
+ short& shortarg_inout,
+ unsigned short& unsigned_shortarg_inout,
+
+ int& intarg_inout,
+ unsigned int& unsigned_intarg_inout,
+
+ long& longarg_inout,
+ unsigned long& unsigned_longarg_inout,
+
+ long long& long_longarg_inout,
+ // unsigned long long& unsigned_long_longarg_inout,
+
+ float& floatarg_inout,
+ double& doublearg_inout)
+ {
+ boolarg_inout = false;
+
+ signed_chararg_inout = 50;
+ unsigned_chararg_inout = 50;
+
+ shortarg_inout = 50;
+ unsigned_shortarg_inout = 50;
+
+ intarg_inout = 50;
+ unsigned_intarg_inout = 50;
+
+ longarg_inout = 50;
+ unsigned_longarg_inout = 50;
+
+ long_longarg_inout = 50;
+ // unsigned_long_longarg_inout = 50;
+
+ floatarg_inout = 50;
+ doublearg_inout = 50;
+ }
+
+ virtual void director_method_nameless_args(
+ bool& ,
+
+ signed char& ,
+ unsigned char& ,
+
+ short& ,
+ unsigned short& ,
+
+ int& ,
+ unsigned int& ,
+
+ long& ,
+ unsigned long& ,
+
+ long long& ,
+ // unsigned long long& ,
+
+ float& ,
+ double&)
+ {
+ }
+
+ void etest() {
+ bool boolarg_inout = false;
+
+ signed char signed_chararg_inout = 111;
+ unsigned char unsigned_chararg_inout = 150;
+
+ short shortarg_inout = 150;
+ unsigned short unsigned_shortarg_inout = 150;
+
+ int intarg_inout = 150;
+ unsigned int unsigned_intarg_inout = 150;
+
+ long longarg_inout = 150;
+ unsigned long unsigned_longarg_inout = 150;
+
+ long long long_longarg_inout = 150;
+ // unsigned long long unsigned_long_longarg_inout = 150;
+
+ float floatarg_inout = 150;
+ double doublearg_inout = 150;
+
+ director_method_output(
+ boolarg_inout,
+
+ signed_chararg_inout,
+ unsigned_chararg_inout,
+
+ shortarg_inout,
+ unsigned_shortarg_inout,
+
+ intarg_inout,
+ unsigned_intarg_inout,
+
+ longarg_inout,
+ unsigned_longarg_inout,
+
+ long_longarg_inout,
+ // unsigned_long_longarg_inout,
+
+ floatarg_inout,
+ doublearg_inout);
+
+ verify(boolarg_inout == true);
+ verify(signed_chararg_inout == 1);
+ verify(unsigned_chararg_inout == 2);
+
+ verify(shortarg_inout == 3);
+ verify(unsigned_shortarg_inout == 4);
+
+ verify(intarg_inout == 5);
+ verify(unsigned_intarg_inout == 6);
+
+ verify(longarg_inout == 7);
+ verify(unsigned_longarg_inout == 8);
+
+ verify(long_longarg_inout == 9);
+ // verify(unsigned_long_longarg_inout == 10);
+
+ verify(floatarg_inout == 11);
+ verify(doublearg_inout == 12);
+
+ boolarg_inout = false;
+
+ signed_chararg_inout = 101;
+ unsigned_chararg_inout = 101;
+
+ shortarg_inout = 101;
+ unsigned_shortarg_inout = 101;
+
+ intarg_inout = 101;
+ unsigned_intarg_inout = 101;
+
+ longarg_inout = 101;
+ unsigned_longarg_inout = 101;
+
+ long_longarg_inout = 101;
+ // unsigned_long_longarg_inout = 101;
+
+ floatarg_inout = 101;
+ doublearg_inout = 101;
+
+ director_method_inout(
+ boolarg_inout,
+
+ signed_chararg_inout,
+ unsigned_chararg_inout,
+
+ shortarg_inout,
+ unsigned_shortarg_inout,
+
+ intarg_inout,
+ unsigned_intarg_inout,
+
+ longarg_inout,
+ unsigned_longarg_inout,
+
+ long_longarg_inout,
+ // unsigned_long_longarg_inout,
+
+ floatarg_inout,
+ doublearg_inout);
+
+ verify(boolarg_inout == false);
+ verify(signed_chararg_inout == 11);
+ verify(unsigned_chararg_inout == 12);
+
+ verify(shortarg_inout == 13);
+ verify(unsigned_shortarg_inout == 14);
+
+ verify(intarg_inout == 15);
+ verify(unsigned_intarg_inout == 16);
+
+ verify(longarg_inout == 17);
+ verify(unsigned_longarg_inout == 18);
+
+ verify(long_longarg_inout == 19);
+ // verify(unsigned_long_longarg_inout == 110);
+
+ verify(floatarg_inout == 111);
+ verify(doublearg_inout == 112);
+
+ director_method_nameless_args(
+ boolarg_inout,
+
+ signed_chararg_inout,
+ unsigned_chararg_inout,
+
+ shortarg_inout,
+ unsigned_shortarg_inout,
+
+ intarg_inout,
+ unsigned_intarg_inout,
+
+ longarg_inout,
+ unsigned_longarg_inout,
+
+ long_longarg_inout,
+ // unsigned_long_longarg_inout,
+
+ floatarg_inout,
+ doublearg_inout);
+
+ verify(boolarg_inout == true);
+ verify(signed_chararg_inout == 12);
+ verify(unsigned_chararg_inout == 13);
+
+ verify(shortarg_inout == 14);
+ verify(unsigned_shortarg_inout == 15);
+
+ verify(intarg_inout == 16);
+ verify(unsigned_intarg_inout == 17);
+
+ verify(longarg_inout == 18);
+ verify(unsigned_longarg_inout == 19);
+
+ verify(long_longarg_inout == 20);
+ // verify(unsigned_long_longarg_inout == 111);
+
+ verify(floatarg_inout == 112);
+ verify(doublearg_inout == 113);
+ }
+};
+%}
+
+%clear bool&;
+
+%clear signed char&;
+%clear unsigned char&;
+
+%clear short&;
+%clear unsigned short&;
+
+%clear int&;
+%clear unsigned int&;
+
+%clear long&;
+%clear unsigned long&;
+
+%clear long long&;
+// %clear unsigned long long&;
+
+%clear float&;
+%clear double&;
diff --git a/Examples/test-suite/java_director_typemaps_ptr.i b/Examples/test-suite/java_director_typemaps_ptr.i
new file mode 100644
index 000000000..578001ac1
--- /dev/null
+++ b/Examples/test-suite/java_director_typemaps_ptr.i
@@ -0,0 +1,433 @@
+%module(directors="1") java_director_typemaps
+// Test director pointer typemaps in typemaps.i - similar to java_director_typemaps.i testcase
+
+%feature("director", assumeoverride=1) Quux;
+
+%include <typemaps.i>
+
+%apply bool* OUTPUT {bool*};
+
+%apply signed char* OUTPUT {signed char*};
+%apply unsigned char* OUTPUT {unsigned char*};
+
+%apply short* OUTPUT {short*};
+%apply unsigned short* OUTPUT {unsigned short*};
+
+%apply int* OUTPUT {int*};
+%apply unsigned int* OUTPUT {unsigned int*};
+
+%apply long* OUTPUT {long*};
+%apply unsigned long* OUTPUT {unsigned long*};
+
+%apply long long* OUTPUT {long long*};
+// %apply unsigned long long* OUTPUT {unsigned long long*};
+
+%apply float* OUTPUT {float*};
+%apply double* OUTPUT {double*};
+
+%apply bool* OUTPUT {bool* boolarg_output};
+
+%apply signed char* OUTPUT {signed char* signed_chararg_output};
+%apply unsigned char* OUTPUT {unsigned char* unsigned_chararg_output};
+
+%apply short* OUTPUT {short* shortarg_output};
+%apply unsigned short* OUTPUT {unsigned short* unsigned_shortarg_output};
+
+%apply int* OUTPUT {int* intarg_output};
+%apply unsigned int* OUTPUT {unsigned int* unsigned_intarg_output};
+
+%apply long* OUTPUT {long* longarg_output};
+%apply unsigned long* OUTPUT {unsigned long* unsigned_longarg_output};
+
+%apply long long* OUTPUT {long long* long_longarg_output};
+// %apply unsigned long long* OUTPUT {unsigned long long* unsigned_long_longarg_output};
+
+%apply float* OUTPUT {float* floatarg_output};
+%apply double* OUTPUT {double* doublearg_output};
+
+%apply bool* INOUT {bool* boolarg_inout};
+
+%apply signed char* INOUT {signed char* signed_chararg_inout};
+%apply unsigned char* INOUT {unsigned char* unsigned_chararg_inout};
+
+%apply short* INOUT {short* shortarg_inout};
+%apply unsigned short* INOUT {unsigned short* unsigned_shortarg_inout};
+
+%apply int* INOUT {int* intarg_inout};
+%apply unsigned int* INOUT {unsigned int* unsigned_intarg_inout};
+
+%apply long* INOUT {long* longarg_inout};
+%apply unsigned long* INOUT {unsigned long* unsigned_longarg_inout};
+
+%apply long long* INOUT {long long* long_longarg_inout};
+// %apply unsigned long long* INOUT {unsigned long long* unsigned_long_longarg_inout};
+
+%apply float* INOUT {float* floatarg_inout};
+%apply double* INOUT {double* doublearg_inout};
+
+%{
+#include <stdexcept>
+#define verify(ok) if (!(ok)) throw std::runtime_error(# ok);
+%}
+%inline %{
+
+class Quux {
+public:
+ Quux() {}
+ virtual ~Quux() {}
+
+ virtual void director_method_output(
+ bool* boolarg_output,
+
+ signed char* signed_chararg_output,
+ unsigned char* unsigned_chararg_output,
+
+ short* shortarg_output,
+ unsigned short* unsigned_shortarg_output,
+
+ int* intarg_output,
+ unsigned int* unsigned_intarg_output,
+
+ long* longarg_output,
+ unsigned long* unsigned_longarg_output,
+
+ long long* long_longarg_output,
+ // unsigned long long* unsigned_long_longarg_output,
+
+ float* floatarg_output,
+ double* doublearg_output)
+ {
+ if (boolarg_output) *boolarg_output = false;
+
+ if (signed_chararg_output) *signed_chararg_output = 50;
+ if (unsigned_chararg_output) *unsigned_chararg_output = 50;
+
+ if (shortarg_output) *shortarg_output = 50;
+ if (unsigned_shortarg_output) *unsigned_shortarg_output = 50;
+
+ if (intarg_output) *intarg_output = 50;
+ if (unsigned_intarg_output) *unsigned_intarg_output = 50;
+
+ if (longarg_output) *longarg_output = 50;
+ if (unsigned_longarg_output) *unsigned_longarg_output = 50;
+
+ if (long_longarg_output) *long_longarg_output = 50;
+ // if (unsigned_long_longarg_output) *unsigned_long_longarg_output = 50;
+
+ if (floatarg_output) *floatarg_output = 50;
+ if (doublearg_output) *doublearg_output = 50;
+ }
+
+ virtual void director_method_inout(
+ bool* boolarg_inout,
+
+ signed char* signed_chararg_inout,
+ unsigned char* unsigned_chararg_inout,
+
+ short* shortarg_inout,
+ unsigned short* unsigned_shortarg_inout,
+
+ int* intarg_inout,
+ unsigned int* unsigned_intarg_inout,
+
+ long* longarg_inout,
+ unsigned long* unsigned_longarg_inout,
+
+ long long* long_longarg_inout,
+ // unsigned long long* unsigned_long_longarg_inout,
+
+ float* floatarg_inout,
+ double* doublearg_inout)
+ {
+ if (boolarg_inout) *boolarg_inout = false;
+
+ if (signed_chararg_inout) *signed_chararg_inout = 50;
+ if (unsigned_chararg_inout) *unsigned_chararg_inout = 50;
+
+ if (shortarg_inout) *shortarg_inout = 50;
+ if (unsigned_shortarg_inout) *unsigned_shortarg_inout = 50;
+
+ if (intarg_inout) *intarg_inout = 50;
+ if (unsigned_intarg_inout) *unsigned_intarg_inout = 50;
+
+ if (longarg_inout) *longarg_inout = 50;
+ if (unsigned_longarg_inout) *unsigned_longarg_inout = 50;
+
+ if (long_longarg_inout) *long_longarg_inout = 50;
+ // if (unsigned_long_longarg_inout) *unsigned_long_longarg_inout = 50;
+
+ if (floatarg_inout) *floatarg_inout = 50;
+ if (doublearg_inout) *doublearg_inout = 50;
+ }
+
+ virtual void director_method_nameless_args(
+ bool* ,
+
+ signed char* ,
+ unsigned char* ,
+
+ short* ,
+ unsigned short* ,
+
+ int* ,
+ unsigned int* ,
+
+ long* ,
+ unsigned long* ,
+
+ long long* ,
+ // unsigned long long* ,
+
+ float* ,
+ double*)
+ {
+ }
+
+ void etest() {
+ bool boolarg_inout = false;
+
+ signed char signed_chararg_inout = 111;
+ unsigned char unsigned_chararg_inout = 150;
+
+ short shortarg_inout = 150;
+ unsigned short unsigned_shortarg_inout = 150;
+
+ int intarg_inout = 150;
+ unsigned int unsigned_intarg_inout = 150;
+
+ long longarg_inout = 150;
+ unsigned long unsigned_longarg_inout = 150;
+
+ long long long_longarg_inout = 150;
+ // unsigned long long unsigned_long_longarg_inout = 150;
+
+ float floatarg_inout = 150;
+ double doublearg_inout = 150;
+
+ director_method_output(
+ &boolarg_inout,
+
+ &signed_chararg_inout,
+ &unsigned_chararg_inout,
+
+ &shortarg_inout,
+ &unsigned_shortarg_inout,
+
+ &intarg_inout,
+ &unsigned_intarg_inout,
+
+ &longarg_inout,
+ &unsigned_longarg_inout,
+
+ &long_longarg_inout,
+ // &unsigned_long_longarg_inout,
+
+ &floatarg_inout,
+ &doublearg_inout);
+
+ verify(boolarg_inout == true);
+ verify(signed_chararg_inout == 1);
+ verify(unsigned_chararg_inout == 2);
+
+ verify(shortarg_inout == 3);
+ verify(unsigned_shortarg_inout == 4);
+
+ verify(intarg_inout == 5);
+ verify(unsigned_intarg_inout == 6);
+
+ verify(longarg_inout == 7);
+ verify(unsigned_longarg_inout == 8);
+
+ verify(long_longarg_inout == 9);
+ // verify(unsigned_long_longarg_inout == 10);
+
+ verify(floatarg_inout == 11);
+ verify(doublearg_inout == 12);
+
+ boolarg_inout = false;
+
+ signed_chararg_inout = 101;
+ unsigned_chararg_inout = 101;
+
+ shortarg_inout = 101;
+ unsigned_shortarg_inout = 101;
+
+ intarg_inout = 101;
+ unsigned_intarg_inout = 101;
+
+ longarg_inout = 101;
+ unsigned_longarg_inout = 101;
+
+ long_longarg_inout = 101;
+ // unsigned_long_longarg_inout = 101;
+
+ floatarg_inout = 101;
+ doublearg_inout = 101;
+
+ director_method_inout(
+ &boolarg_inout,
+
+ &signed_chararg_inout,
+ &unsigned_chararg_inout,
+
+ &shortarg_inout,
+ &unsigned_shortarg_inout,
+
+ &intarg_inout,
+ &unsigned_intarg_inout,
+
+ &longarg_inout,
+ &unsigned_longarg_inout,
+
+ &long_longarg_inout,
+ // &unsigned_long_longarg_inout,
+
+ &floatarg_inout,
+ &doublearg_inout);
+
+ verify(boolarg_inout == false);
+ verify(signed_chararg_inout == 11);
+ verify(unsigned_chararg_inout == 12);
+
+ verify(shortarg_inout == 13);
+ verify(unsigned_shortarg_inout == 14);
+
+ verify(intarg_inout == 15);
+ verify(unsigned_intarg_inout == 16);
+
+ verify(longarg_inout == 17);
+ verify(unsigned_longarg_inout == 18);
+
+ verify(long_longarg_inout == 19);
+ // verify(unsigned_long_longarg_inout == 110);
+
+ verify(floatarg_inout == 111);
+ verify(doublearg_inout == 112);
+
+ director_method_nameless_args(
+ &boolarg_inout,
+
+ &signed_chararg_inout,
+ &unsigned_chararg_inout,
+
+ &shortarg_inout,
+ &unsigned_shortarg_inout,
+
+ &intarg_inout,
+ &unsigned_intarg_inout,
+
+ &longarg_inout,
+ &unsigned_longarg_inout,
+
+ &long_longarg_inout,
+ // &unsigned_long_longarg_inout,
+
+ &floatarg_inout,
+ &doublearg_inout);
+
+ verify(boolarg_inout == true);
+ verify(signed_chararg_inout == 12);
+ verify(unsigned_chararg_inout == 13);
+
+ verify(shortarg_inout == 14);
+ verify(unsigned_shortarg_inout == 15);
+
+ verify(intarg_inout == 16);
+ verify(unsigned_intarg_inout == 17);
+
+ verify(longarg_inout == 18);
+ verify(unsigned_longarg_inout == 19);
+
+ verify(long_longarg_inout == 20);
+ // verify(unsigned_long_longarg_inout == 111);
+
+ verify(floatarg_inout == 112);
+ verify(doublearg_inout == 113);
+ }
+
+ void nulltest() {
+ director_method_output(
+ NULL,
+
+ NULL,
+ NULL,
+
+ NULL,
+ NULL,
+
+ NULL,
+ NULL,
+
+ NULL,
+ NULL,
+
+ NULL,
+ // NULL,
+
+ NULL,
+ NULL);
+
+ director_method_inout(
+ NULL,
+
+ NULL,
+ NULL,
+
+ NULL,
+ NULL,
+
+ NULL,
+ NULL,
+
+ NULL,
+ NULL,
+
+ NULL,
+ // NULL,
+
+ NULL,
+ NULL);
+
+ director_method_nameless_args(
+ NULL,
+
+ NULL,
+ NULL,
+
+ NULL,
+ NULL,
+
+ NULL,
+ NULL,
+
+ NULL,
+ NULL,
+
+ NULL,
+ // NULL,
+
+ NULL,
+ NULL);
+ }
+};
+%}
+
+%clear bool*;
+
+%clear signed char*;
+%clear unsigned char*;
+
+%clear short*;
+%clear unsigned short*;
+
+%clear int*;
+%clear unsigned int*;
+
+%clear long*;
+%clear unsigned long*;
+
+%clear long long*;
+// %clear unsigned long long*;
+
+%clear float*;
+%clear double*;
diff --git a/Examples/test-suite/java_enums.i b/Examples/test-suite/java_enums.i
index 855913d06..cad492652 100644
--- a/Examples/test-suite/java_enums.i
+++ b/Examples/test-suite/java_enums.i
@@ -18,6 +18,21 @@ import java.io.*; // For Serializable
// Set default Java const code generation
%javaconst(1);
+// Test enums with trailing comma after the last item.
+enum WithTrailingComma
+{
+ First,
+ Second,
+};
+
+%ignore ReallyFirstOneIsIgnored;
+enum WithTrailingCommaAndIgnoredFirstItem
+{
+ ReallyFirstOneIsIgnored,
+ FirstNonIgnoredOne,
+ SecondNonIgnoredOne,
+};
+
// Change the default generation so that these enums are generated into an interface instead of a class
%typemap(javaclassmodifiers) enum stuff "public interface"
diff --git a/Examples/test-suite/java_throws.i b/Examples/test-suite/java_throws.i
index 48a0eeabc..6cd47b448 100644
--- a/Examples/test-suite/java_throws.i
+++ b/Examples/test-suite/java_throws.i
@@ -2,6 +2,12 @@
%module java_throws
+// throw is invalid in C++17 and later, only SWIG to use it
+#define TESTCASE_THROW1(T1) throw(T1)
+%{
+#define TESTCASE_THROW1(T1)
+%}
+
// Exceptions are chosen at random but are ones which have to have a try catch block to compile
%typemap(in, throws=" ClassNotFoundException") int num {
$1 = (int)$input;
@@ -39,13 +45,7 @@ short full_of_exceptions(int num) {
return $null;
}
%inline %{
-#if defined(_MSC_VER)
- #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
-bool throw_spec_function(int value) throw (int) { throw (int)0; }
-#if defined(_MSC_VER)
- #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
+bool throw_spec_function(int value) TESTCASE_THROW1(int) { throw (int)0; }
%}
%catches(int) catches_function(int value);
@@ -126,6 +126,24 @@ JAVAEXCEPTION(FeatureTest::staticMethod)
};
%}
+%include <swiginterface.i>
+%interface_impl(InterfaceTest);
+JAVAEXCEPTION(imethod)
+
+%inline %{
+ struct InterfaceTest {
+ virtual void imethod(bool raise) = 0;
+ virtual ~InterfaceTest() {}
+ };
+
+ struct InterfaceTestImpl : InterfaceTest {
+ void imethod(bool raise) {
+ if (raise)
+ throw MyException("raise message");
+ }
+ };
+%}
+
// Mixing except feature and typemaps when both generate a class for the throws clause
%typemap(in, throws="ClassNotFoundException") int both {
$1 = (int)$input;
@@ -165,6 +183,7 @@ try {
// Need to handle the checked exception in NoExceptTest.delete()
%typemap(javafinalize) SWIGTYPE %{
+ @SuppressWarnings("deprecation")
protected void finalize() {
try {
delete();
diff --git a/Examples/test-suite/javascript/Makefile.in b/Examples/test-suite/javascript/Makefile.in
index b430f236f..fed028388 100644
--- a/Examples/test-suite/javascript/Makefile.in
+++ b/Examples/test-suite/javascript/Makefile.in
@@ -13,6 +13,9 @@ srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
+C_TEST_CASES += \
+ ccomplextest \
+
SWIGEXE = $(top_builddir)/swig
SWIG_LIB_DIR = $(top_srcdir)/Lib
@@ -51,6 +54,7 @@ ifeq (node,$(JSENGINE))
# dunno... ignoring generously
apply_signed_char.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\"
constant_pointers.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\"
+ director_basic.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\"
enum_thorough.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\"
setup_node = \
@@ -66,14 +70,14 @@ 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 && \
- $(COMPILETOOL) $(NODEGYP) --loglevel=silent --directory $* configure build 1>>/dev/null
+ MAKEFLAGS= $(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 && \
- $(COMPILETOOL) $(NODEGYP) --loglevel=silent --directory $* configure build 1>>/dev/null
+ MAKEFLAGS= $(COMPILETOOL) $(NODEGYP) --loglevel=silent --directory $* configure build 1>>/dev/null
run_testcase = \
if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then \
@@ -83,12 +87,12 @@ ifeq (node,$(JSENGINE))
%.ctest:
$(_setup)
- $(swig_and_compile_c)
+ +$(swig_and_compile_c)
$(run_testcase)
%.cpptest:
$(_setup)
- $(swig_and_compile_cpp)
+ +$(swig_and_compile_cpp)
$(run_testcase)
%.multicpptest:
@@ -133,4 +137,5 @@ clean:
rm -f mod_a$${ext} mod_b$${ext}; \
rm -f multi_import_a$${ext} multi_import_b$${ext}; \
rm -f packageoption_a$${ext} packageoption_b$${ext} packageoption_c$${ext}; \
+ rm -f template_typedef_cplx2$${ext}; \
done
diff --git a/Examples/test-suite/javascript/class_scope_weird_runme.js b/Examples/test-suite/javascript/class_scope_weird_runme.js
index 73c118d61..ca18c1b4d 100644
--- a/Examples/test-suite/javascript/class_scope_weird_runme.js
+++ b/Examples/test-suite/javascript/class_scope_weird_runme.js
@@ -4,3 +4,14 @@ f = new class_scope_weird.Foo();
g = new class_scope_weird.Foo(3);
if (f.bar(3) != 3)
throw RuntimeError;
+
+// Test missing new keyword during constructor call
+var caughtException = false;
+try {
+ g = class_scope_weird.Foo(4);
+} catch (err) {
+ caughtException = true;
+}
+if (!caughtException) {
+ throw new Error("Instantiation exception not thrown");
+}
diff --git a/Examples/test-suite/javascript/complextest_runme.js b/Examples/test-suite/javascript/complextest_runme.js
index b87d6bffa..1d9825f3b 100644
--- a/Examples/test-suite/javascript/complextest_runme.js
+++ b/Examples/test-suite/javascript/complextest_runme.js
@@ -8,8 +8,16 @@ a_c = complextest.Conj(a);
if (a_c.toString() != expected.toString())
throw "Error in Conj(a)";
-a_c_f = complextest.Conjf(a);
-if (a_c_f.toString() != expected.toString())
+a_c = complextest.Conjf(a);
+if (a_c.toString() != expected.toString())
+ throw "Error in Conjf(a)";
+
+a_c = complextest.Conj2(a);
+if (a_c.toString() != expected.toString())
+ throw "Error in Conj(a)";
+
+a_c = complextest.Conjf2(a);
+if (a_c.toString() != expected.toString())
throw "Error in Conjf(a)";
v = new complextest.VectorStdCplx();
@@ -19,4 +27,5 @@ v.add([4,3]);
v.add(1);
// TODO: how to check validity?
-complextest.Copy_h(v);
+complextest.CopyHalf(v);
+complextest.CopyHalfRef(v);
diff --git a/Examples/test-suite/javascript/integers_runme.js b/Examples/test-suite/javascript/integers_runme.js
new file mode 100644
index 000000000..0356176ad
--- /dev/null
+++ b/Examples/test-suite/javascript/integers_runme.js
@@ -0,0 +1,18 @@
+var integers = require("integers");
+
+var val = 3902408827
+ret = integers.signed_long_identity(val)
+if (ret != val)
+ throw "Incorrect value: " + ret
+
+ret = integers.unsigned_long_identity(val)
+if (ret != val)
+ throw "Incorrect value: " + ret
+
+ret = integers.signed_long_long_identity(val)
+if (ret != val)
+ throw "Incorrect value: " + ret
+
+ret = integers.unsigned_long_long_identity(val)
+if (ret != val)
+ throw "Incorrect value: " + ret
diff --git a/Examples/test-suite/javascript/li_typemaps_runme.js b/Examples/test-suite/javascript/li_typemaps_runme.js
new file mode 100644
index 000000000..c0b1b43b0
--- /dev/null
+++ b/Examples/test-suite/javascript/li_typemaps_runme.js
@@ -0,0 +1,50 @@
+var li_typemaps = require("li_typemaps");
+
+function check(a, b) {
+ if (a !== b) {
+ throw new Error("Not equal: " + a + " " + b)
+ }
+}
+
+function check_array(a, b) {
+ if (a.length != b.length)
+ throw new Error("Array length mismatch " + a.length + " " + b.length)
+ if (!a.every(function(element, index) { return element === b[index]; }))
+ throw new Error("Arrays don't match a:" + a + " b:" + b)
+}
+
+// Check double INPUT typemaps
+check(li_typemaps.in_double(22.22), 22.22)
+check(li_typemaps.inr_double(22.22), 22.22)
+
+// Check double OUTPUT typemaps
+check_array(li_typemaps.out_double(22.22), [22.22])
+check_array(li_typemaps.outr_double(22.22), [22.22])
+
+// Check double INOUT typemaps
+check_array(li_typemaps.inout_double(22.22), [22.22])
+check_array(li_typemaps.inoutr_double(22.22), [22.22])
+
+// check long long
+check(li_typemaps.in_ulonglong(20), 20)
+check(li_typemaps.inr_ulonglong(20), 20)
+check_array(li_typemaps.out_ulonglong(20), [20])
+check_array(li_typemaps.outr_ulonglong(20), [20])
+check_array(li_typemaps.inout_ulonglong(20), [20])
+check_array(li_typemaps.inoutr_ulonglong(20), [20])
+
+// check bools
+check(li_typemaps.in_bool(true), true)
+check(li_typemaps.inr_bool(false), false)
+check_array(li_typemaps.out_bool(true), [true])
+check_array(li_typemaps.outr_bool(false), [false])
+check_array(li_typemaps.inout_bool(true), [true])
+check_array(li_typemaps.inoutr_bool(false), [false])
+
+// the others
+check_array(li_typemaps.inoutr_int2(1,2), [1, 2])
+
+fi = li_typemaps.out_foo(10)
+check(fi[0].a, 10)
+check(fi[1], 20)
+check(fi[2], 30)
diff --git a/Examples/test-suite/javascript/native_directive_runme.js b/Examples/test-suite/javascript/native_directive_runme.js
new file mode 100644
index 000000000..5c1d69cf1
--- /dev/null
+++ b/Examples/test-suite/javascript/native_directive_runme.js
@@ -0,0 +1,9 @@
+var native_directive = require("native_directive");
+
+(function main() {
+ var s = "abc.DEF-123";
+ if (native_directive.CountAlphas(s) !== 6)
+ throw "CountAlphas failed";
+ if (native_directive.CountAlphaCharacters(s) !== 6)
+ throw "CountAlphaCharacters failed";
+})();
diff --git a/Examples/test-suite/javascript/null_pointer_runme.js b/Examples/test-suite/javascript/null_pointer_runme.js
index 7c0d61244..8a9b61186 100644
--- a/Examples/test-suite/javascript/null_pointer_runme.js
+++ b/Examples/test-suite/javascript/null_pointer_runme.js
@@ -1,6 +1,6 @@
var null_pointer = require("null_pointer");
-if (!null_pointer.func(null)) {
+if (!null_pointer.funk(null)) {
throw new Error("Javascript 'null' should be converted into NULL.");
}
diff --git a/Examples/test-suite/javascript/overload_null_runme.js b/Examples/test-suite/javascript/overload_null_runme.js
new file mode 100644
index 000000000..f1e35cac7
--- /dev/null
+++ b/Examples/test-suite/javascript/overload_null_runme.js
@@ -0,0 +1,49 @@
+// There are no typecheck typemaps in Javascript yet, so most of this test
+// does not actually worked - the check functions have thus been commented out.
+var overload_null = require("overload_null");
+
+var check = function(expected, actual) {
+ if (expected !== actual) {
+ throw new Error(a + " does not equal " + b);
+ }
+};
+
+
+var o = new overload_null.Overload();
+var x = new overload_null.X();
+
+check(1, o.byval1(x));
+// check(2, o.byval1(null));
+
+// check(3, o.byval2(null));
+check(4, o.byval2(x));
+
+check(5, o.byref1(x));
+// check(6, o.byref1(null));
+
+// check(7, o.byref2(null));
+check(8, o.byref2(x));
+
+check(9, o.byconstref1(x));
+// check(10, o.byconstref1(null));
+
+// check(11, o.byconstref2(null));
+check(12, o.byconstref2(x));
+
+// const pointer references
+check(13, o.byval1cpr(x));
+// check(14, o.byval1cpr(null));
+
+// check(15, o.byval2cpr(null));
+check(16, o.byval2cpr(x));
+
+// forward class declaration
+check(17, o.byval1forwardptr(x));
+// check(18, o.byval1forwardptr(null));
+
+// check(19, o.byval2forwardptr(null));
+check(20, o.byval2forwardptr(x));
+
+check(21, o.byval1forwardref(x));
+
+check(22, o.byval2forwardref(x));
diff --git a/Examples/test-suite/javascript/rename1_runme.js b/Examples/test-suite/javascript/rename1_runme.js
index 68ecc11b6..7b2ac37b6 100644
--- a/Examples/test-suite/javascript/rename1_runme.js
+++ b/Examples/test-suite/javascript/rename1_runme.js
@@ -10,7 +10,6 @@ function part1() {
xyz.tMethod2(0);
xyz.tMethodNotXYZ2(notxyz);
xyz.opNotXYZ2();
- xyz.opXYZ2();
}
function part2() {
@@ -23,7 +22,6 @@ function part2() {
xyz.tMethod1(0);
xyz.tMethodNotXYZ1(notxyz);
xyz.opNotXYZ1();
- xyz.opXYZ1();
}
function part3(){
@@ -36,7 +34,6 @@ function part3(){
xyz.tMethod3(new rename.Klass());
xyz.tMethodNotXYZ3(notxyz);
xyz.opNotXYZ3();
- xyz.opXYZ3();
}
function part4() {
@@ -49,7 +46,6 @@ function part4() {
xyz.tMethod4(rename.En1);
xyz.tMethodNotXYZ4(notxyz);
xyz.opNotXYZ4();
- xyz.opXYZ4();
}
function part5() {
diff --git a/Examples/test-suite/javascript/rename2_runme.js b/Examples/test-suite/javascript/rename2_runme.js
index 99f478596..040c798bb 100644
--- a/Examples/test-suite/javascript/rename2_runme.js
+++ b/Examples/test-suite/javascript/rename2_runme.js
@@ -10,7 +10,6 @@ function part1() {
xyz.tMethod2(0);
xyz.tMethodNotXYZ2(notxyz);
xyz.opNotXYZ2();
- xyz.opXYZ2();
}
function part2() {
@@ -23,7 +22,6 @@ function part2() {
xyz.tMethod1(0);
xyz.tMethodNotXYZ1(notxyz);
xyz.opNotXYZ1();
- xyz.opXYZ1();
}
function part3(){
@@ -36,7 +34,6 @@ function part3(){
xyz.tMethod3(new rename.Klass());
xyz.tMethodNotXYZ3(notxyz);
xyz.opNotXYZ3();
- xyz.opXYZ3();
}
function part4() {
@@ -49,7 +46,6 @@ function part4() {
xyz.tMethod4(rename.En1);
xyz.tMethodNotXYZ4(notxyz);
xyz.opNotXYZ4();
- xyz.opXYZ4();
}
function part5() {
diff --git a/Examples/test-suite/javascript/rename3_runme.js b/Examples/test-suite/javascript/rename3_runme.js
index 237029fbb..fb9393b03 100644
--- a/Examples/test-suite/javascript/rename3_runme.js
+++ b/Examples/test-suite/javascript/rename3_runme.js
@@ -10,7 +10,6 @@ function part1() {
xyz.tMethod2(0);
xyz.tMethodNotXYZ2(notxyz);
xyz.opNotXYZ2();
- xyz.opXYZ2();
}
function part2() {
@@ -23,7 +22,6 @@ function part2() {
xyz.tMethod1(0);
xyz.tMethodNotXYZ1(notxyz);
xyz.opNotXYZ1();
- xyz.opXYZ1();
}
function part3(){
@@ -36,7 +34,6 @@ function part3(){
xyz.tMethod3(new rename.Klass());
xyz.tMethodNotXYZ3(notxyz);
xyz.opNotXYZ3();
- xyz.opXYZ3();
}
function part4() {
@@ -49,7 +46,6 @@ function part4() {
xyz.tMethod4(rename.En1);
xyz.tMethodNotXYZ4(notxyz);
xyz.opNotXYZ4();
- xyz.opXYZ4();
}
function part5() {
diff --git a/Examples/test-suite/javascript/rename4_runme.js b/Examples/test-suite/javascript/rename4_runme.js
index fed50dceb..1c3d8e77f 100644
--- a/Examples/test-suite/javascript/rename4_runme.js
+++ b/Examples/test-suite/javascript/rename4_runme.js
@@ -10,7 +10,6 @@ function part1() {
xyz.tMethod2(0);
xyz.tMethodNotXYZ2(notxyz);
xyz.opNotXYZ2();
- xyz.opXYZ2();
}
function part2() {
@@ -23,7 +22,6 @@ function part2() {
xyz.tMethod1(0);
xyz.tMethodNotXYZ1(notxyz);
xyz.opNotXYZ1();
- xyz.opXYZ1();
}
function part3(){
@@ -36,7 +34,6 @@ function part3(){
xyz.tMethod3(new rename.Klass());
xyz.tMethodNotXYZ3(notxyz);
xyz.opNotXYZ3();
- xyz.opXYZ3();
}
function part4() {
@@ -49,7 +46,6 @@ function part4() {
xyz.tMethod4(rename.En1);
xyz.tMethodNotXYZ4(notxyz);
xyz.opNotXYZ4();
- xyz.opXYZ4();
}
function part5() {
diff --git a/Examples/test-suite/javascript/string_simple_runme.js b/Examples/test-suite/javascript/string_simple_runme.js
index 39ae84e9e..71fbb7bd0 100644
--- a/Examples/test-suite/javascript/string_simple_runme.js
+++ b/Examples/test-suite/javascript/string_simple_runme.js
@@ -3,7 +3,7 @@ var string_simple = require("string_simple");
// Test unicode string
var str = "olé";
-var copy = string_simple.copy_string(str);
+var copy = string_simple.copy_str(str);
if (str !== copy) {
throw "Error: copy is not equal: original="+str+", copy="+copy;
diff --git a/Examples/test-suite/keyword_rename.i b/Examples/test-suite/keyword_rename.i
index 46c3338b3..23c01087d 100644
--- a/Examples/test-suite/keyword_rename.i
+++ b/Examples/test-suite/keyword_rename.i
@@ -4,6 +4,8 @@
%module keyword_rename
+%feature("kwargs");
+
#pragma SWIG nowarn=SWIGWARN_PARSE_KEYWORD
%inline %{
diff --git a/Examples/test-suite/kwargs_feature.i b/Examples/test-suite/kwargs_feature.i
index a8d1c38d8..2b662caeb 100644
--- a/Examples/test-suite/kwargs_feature.i
+++ b/Examples/test-suite/kwargs_feature.i
@@ -100,3 +100,29 @@
int foo_mm(int min = 1, int max = 2) {return min + max; }
%}
+
+
+// Extended constructors
+%extend Extending0 {
+ Extending0() { return new Extending0(); }
+}
+%extend Extending1 {
+ Extending1(int one) { return new Extending1(); }
+}
+%extend Extending2 {
+ Extending2(int one, const char *two) { return new Extending2(); }
+}
+%extend ExtendingOptArgs1 {
+ ExtendingOptArgs1(int one = 0) { return new ExtendingOptArgs1(); }
+}
+%extend ExtendingOptArgs2 {
+ ExtendingOptArgs2(int one = 0, const char* two = NULL) { return new ExtendingOptArgs2(); }
+}
+
+%inline %{
+struct Extending0 {};
+struct Extending1 {};
+struct Extending2 {};
+struct ExtendingOptArgs1 {};
+struct ExtendingOptArgs2 {};
+%}
diff --git a/Examples/test-suite/li_attribute.i b/Examples/test-suite/li_attribute.i
index 4f9497afb..95389b2b6 100644
--- a/Examples/test-suite/li_attribute.i
+++ b/Examples/test-suite/li_attribute.i
@@ -95,6 +95,7 @@ struct MyFoo; // %attribute2 does not work with templates
// class/struct attribute with get/set methods using return/pass by reference
%attribute2(MyClass, MyFoo, Foo, GetFoo, SetFoo);
+%attribute2ref(MyClass, MyFoo, Foo2);
%inline %{
struct MyFoo {
MyFoo() : x(-1) {}
@@ -102,9 +103,11 @@ struct MyFoo; // %attribute2 does not work with templates
};
class MyClass {
MyFoo foo;
+ MyFoo foo2;
public:
MyFoo& GetFoo() { return foo; }
void SetFoo(const MyFoo& other) { foo = other; }
+ MyFoo& Foo2() { return foo2; }
};
%}
diff --git a/Examples/test-suite/li_boost_shared_ptr_bits.i b/Examples/test-suite/li_boost_shared_ptr_bits.i
index b61fd2aa6..7cf84010e 100644
--- a/Examples/test-suite/li_boost_shared_ptr_bits.i
+++ b/Examples/test-suite/li_boost_shared_ptr_bits.i
@@ -4,6 +4,10 @@
#define SHARED_PTR_WRAPPERS_IMPLEMENTED
#endif
+#ifdef SWIGOCAML
+%warnfilter(SWIGWARN_PARSE_KEYWORD) val;
+#endif
+
#if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED)
%include <boost_shared_ptr.i>
diff --git a/Examples/test-suite/li_boost_shared_ptr_director.i b/Examples/test-suite/li_boost_shared_ptr_director.i
new file mode 100644
index 000000000..b2d9fc131
--- /dev/null
+++ b/Examples/test-suite/li_boost_shared_ptr_director.i
@@ -0,0 +1,138 @@
+%module(directors="1") "li_boost_shared_ptr_director"
+
+%{
+#include <boost/shared_ptr.hpp>
+%}
+
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGOCTAVE) || defined(SWIGRUBY) || defined(SWIGR)
+#define SHARED_PTR_WRAPPERS_IMPLEMENTED
+#endif
+
+#if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED)
+
+%include <boost_shared_ptr.i>
+%shared_ptr(C);
+%feature("director") Base;
+
+%inline %{
+struct C {
+ C() : m(1) {}
+ C(int n) : m(n) {}
+ int get_m() { return m; }
+private:
+ int m;
+};
+
+struct Base {
+ Base() {}
+ virtual boost::shared_ptr<C> ret_c_shared_ptr() = 0;
+ virtual C ret_c_by_value() = 0;
+ virtual int take_c_by_value(C c) = 0;
+ virtual int take_c_by_ref(C& c) = 0;
+ virtual int take_c_by_pointer(C* c) = 0;
+ virtual int take_c_by_pointer_ref(C*const& c) = 0;
+ virtual int take_c_shared_ptr_by_value(boost::shared_ptr<C> c) = 0;
+ virtual int take_c_shared_ptr_by_ref(boost::shared_ptr<C>& c) = 0;
+ virtual int take_c_shared_ptr_by_pointer(boost::shared_ptr<C>* c) = 0;
+ virtual int take_c_shared_ptr_by_pointer_ref(boost::shared_ptr<C>*const&c) = 0;
+ virtual int take_many_args(
+ C v1, C v2,
+ C &r1, C &r2,
+ C *p1, C *p2,
+ C *const& cr1, C *const& cr2,
+ boost::shared_ptr<C> sv1, boost::shared_ptr<C> sv2,
+ boost::shared_ptr<C> &sr1, boost::shared_ptr<C> &sr2,
+ boost::shared_ptr<C> *sp1, boost::shared_ptr<C> *sp2,
+ boost::shared_ptr<C> *const& spr1, boost::shared_ptr<C> *const& spr2
+ ) = 0;
+ virtual ~Base() {}
+};
+
+int call_ret_c_shared_ptr(Base* b) {
+ boost::shared_ptr<C> ptr = b->ret_c_shared_ptr();
+ if (ptr) {
+ return ptr->get_m();
+ } else {
+ return -1;
+ }
+}
+
+int call_ret_c_by_value(Base* b) {
+ C c = b->ret_c_by_value();
+ return c.get_m();
+}
+
+int call_take_c_by_value(Base* b) {
+ C c(5);
+ return b->take_c_by_value(c);
+}
+
+int call_take_c_by_ref(Base* b) {
+ C c(6);
+ return b->take_c_by_ref(c);
+}
+
+int call_take_c_by_pointer(Base* b) {
+ C c(7);
+ return b->take_c_by_pointer(&c);
+}
+
+int call_take_c_by_pointer_ref(Base* b) {
+ C c(8);
+ C* p(&c);
+ return b->take_c_by_pointer_ref(p);
+}
+
+int call_take_c_by_pointer_with_null(Base* b) {
+ C* p = NULL;
+ return b->take_c_by_pointer(p);
+}
+
+int call_take_c_by_pointer_ref_with_null(Base* b) {
+ C* p = NULL;
+ return b->take_c_by_pointer_ref(p);
+}
+
+int call_take_c_shared_ptr_by_value(Base* b) {
+ boost::shared_ptr<C> ptr(new C(9));
+ return b->take_c_shared_ptr_by_value(ptr);
+}
+
+int call_take_c_shared_ptr_by_value_with_null(Base* b) {
+ boost::shared_ptr<C> ptr;
+ return b->take_c_shared_ptr_by_value(ptr);
+}
+
+int call_take_c_shared_ptr_by_ref(Base* b) {
+ boost::shared_ptr<C> ptr(new C(10));
+ return b->take_c_shared_ptr_by_ref(ptr);
+}
+
+int call_take_c_shared_ptr_by_ref_with_null(Base* b) {
+ boost::shared_ptr<C> ptr;
+ return b->take_c_shared_ptr_by_ref(ptr);
+}
+
+int call_take_c_shared_ptr_by_pointer(Base* b) {
+ boost::shared_ptr<C> ptr(new C(11));
+ return b->take_c_shared_ptr_by_pointer(&ptr);
+}
+
+int call_take_c_shared_ptr_by_pointer_with_null(Base* b) {
+ boost::shared_ptr<C> ptr;
+ return b->take_c_shared_ptr_by_pointer(&ptr);
+}
+
+int call_take_c_shared_ptr_by_pointer_ref(Base* b) {
+ boost::shared_ptr<C> *ptr = new boost::shared_ptr<C>(new C(12));
+ return b->take_c_shared_ptr_by_pointer_ref(ptr);
+}
+
+int call_take_c_shared_ptr_by_pointer_ref_with_null(Base* b) {
+ boost::shared_ptr<C> *ptr = new boost::shared_ptr<C>();
+ return b->take_c_shared_ptr_by_pointer_ref(ptr);
+}
+
+%}
+
+#endif
diff --git a/Examples/test-suite/li_implicit.i b/Examples/test-suite/li_implicit.i
index 0ce10dd6e..9f3ea318b 100644
--- a/Examples/test-suite/li_implicit.i
+++ b/Examples/test-suite/li_implicit.i
@@ -1,4 +1,7 @@
-%module("nocastmode") li_implicit
+%module li_implicit
+
+// Tests nocastmode
+
#pragma SWIG nowarn=SWIGWARN_PP_CPP_WARNING
%include implicit.i
diff --git a/Examples/test-suite/li_std_auto_ptr.i b/Examples/test-suite/li_std_auto_ptr.i
index 5fdc5fa35..d83732af0 100644
--- a/Examples/test-suite/li_std_auto_ptr.i
+++ b/Examples/test-suite/li_std_auto_ptr.i
@@ -4,19 +4,43 @@
#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" // auto_ptr deprecation
#endif
+
+#if defined(__clang__)
+#pragma clang diagnostic push
+// Suppress 'auto_ptr<>' is deprecated
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+#endif
%}
-#if defined(SWIGCSHARP) || defined(SWIGJAVA) || defined(SWIGPYTHON)
+#if defined(SWIGCSHARP) || defined(SWIGJAVA) || defined(SWIGPYTHON) || defined(SWIGRUBY)
%include "std_auto_ptr.i"
%auto_ptr(Klass)
-%inline %{
-
+%{
+#if __cplusplus < 201703L
#include <memory>
+#else
+// Simple std::auto_ptr implementation for testing after its removal in C++17
+namespace std {
+ template <class T> class auto_ptr {
+ T *ptr;
+ public:
+ auto_ptr(T *ptr = 0) : ptr(ptr) {}
+ auto_ptr(auto_ptr&& a) : ptr(a.ptr) { a.ptr = 0;}
+ ~auto_ptr() { delete ptr; }
+ T *release() { T *p = ptr; ptr = 0; return p; }
+ auto_ptr& operator=(auto_ptr&& a) { if (&a != this) { delete ptr; ptr = a.ptr; a.ptr = 0; } return *this; }
+ };
+}
+#endif
+
#include <string>
#include "swig_examples_lock.h"
+%}
+
+%inline %{
class Klass {
public:
diff --git a/Examples/test-suite/li_std_containers_overload.i b/Examples/test-suite/li_std_containers_overload.i
new file mode 100644
index 000000000..5e7c28e37
--- /dev/null
+++ b/Examples/test-suite/li_std_containers_overload.i
@@ -0,0 +1,33 @@
+%module li_std_containers_overload
+
+// Suppress warning that ought not to appear, but there is no easy fix
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) VectorOverload;
+
+%include <std_string.i>
+%include <std_vector.i>
+
+%inline %{
+struct X {};
+struct Y {};
+%}
+
+%template(VectorX) std::vector<X>;
+%template(VectorY) std::vector<Y>;
+%template(VectorString) std::vector<std::string>;
+%template(VectorInt) std::vector<int>;
+
+%inline %{
+using namespace std;
+string VectorOverload(vector<X> v) {
+ return "vector<X>";
+}
+string VectorOverload(vector<Y> v) {
+ return "vector<Y>";
+}
+string VectorOverload(vector<string> v) {
+ return "vector<string>";
+}
+string VectorOverload(vector<int> v) {
+ return "vector<int>";
+}
+%}
diff --git a/Examples/test-suite/li_std_deque.i b/Examples/test-suite/li_std_deque.i
index 152bc86c1..c2f4a7f45 100644
--- a/Examples/test-suite/li_std_deque.i
+++ b/Examples/test-suite/li_std_deque.i
@@ -36,8 +36,8 @@ std::deque<float> half(const std::deque<float>& v) {
}
void halve_in_place(std::deque<double>& v) {
- std::transform(v.begin(),v.end(),v.begin(),
- std::bind2nd(std::divides<double>(),2.0));
+ for (std::deque<double>::iterator it = v.begin(); it != v.end(); ++it)
+ *it /= 2.0;
}
%}
diff --git a/Examples/test-suite/li_std_except.i b/Examples/test-suite/li_std_except.i
index b79d36bc1..60bce999d 100644
--- a/Examples/test-suite/li_std_except.i
+++ b/Examples/test-suite/li_std_except.i
@@ -2,13 +2,12 @@
%include <std_except.i>
+// throw is invalid in C++17 and later, only SWIG to use it
+#define TESTCASE_THROW1(T1) throw(T1)
%{
-#if defined(_MSC_VER)
- #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
+#define TESTCASE_THROW1(T1)
%}
-
%inline %{
struct E1 : public std::exception
{
@@ -19,22 +18,23 @@
};
struct Test {
- int foo1() throw(std::bad_exception) { return 0; }
- int foo2() throw(std::logic_error) { return 0; }
- int foo3() throw(E1) { return 0; }
- int foo4() throw(E2) { return 0; }
+ int foo1() TESTCASE_THROW1(std::bad_exception) { return 0; }
+ int foo2() TESTCASE_THROW1(std::logic_error) { return 0; }
+ int foo3() TESTCASE_THROW1(E1) { return 0; }
+ int foo4() TESTCASE_THROW1(E2) { return 0; }
// all the STL exceptions...
- void throw_bad_cast() throw(std::bad_cast) { throw std::bad_cast(); }
- void throw_bad_exception() throw(std::bad_exception) { throw std::bad_exception(); }
- void throw_domain_error() throw(std::domain_error) { throw std::domain_error("oops"); }
- void throw_exception() throw(std::exception) { throw std::exception(); }
- void throw_invalid_argument() throw(std::invalid_argument) { throw std::invalid_argument("oops"); }
- void throw_length_error() throw(std::length_error) { throw std::length_error("oops"); }
- void throw_logic_error() throw(std::logic_error) { throw std::logic_error("oops"); }
- void throw_out_of_range() throw(std::out_of_range) { throw std::out_of_range("oops"); }
- void throw_overflow_error() throw(std::overflow_error) { throw std::overflow_error("oops"); }
- void throw_range_error() throw(std::range_error) { throw std::range_error("oops"); }
- void throw_runtime_error() throw(std::runtime_error) { throw std::runtime_error("oops"); }
- void throw_underflow_error() throw(std::underflow_error) { throw std::underflow_error("oops"); }
+ void throw_bad_cast() TESTCASE_THROW1(std::bad_cast) { throw std::bad_cast(); }
+ void throw_bad_exception() TESTCASE_THROW1(std::bad_exception) { throw std::bad_exception(); }
+ void throw_domain_error() TESTCASE_THROW1(std::domain_error) { throw std::domain_error("oops"); }
+ void throw_exception() TESTCASE_THROW1(std::exception) { throw std::exception(); }
+ void throw_invalid_argument() TESTCASE_THROW1(std::invalid_argument) { throw std::invalid_argument("oops"); }
+ void throw_length_error() TESTCASE_THROW1(std::length_error) { throw std::length_error("oops"); }
+ void throw_logic_error() TESTCASE_THROW1(std::logic_error) { throw std::logic_error("oops"); }
+ void throw_out_of_range() TESTCASE_THROW1(std::out_of_range) { throw std::out_of_range("oops"); }
+ void throw_overflow_error() TESTCASE_THROW1(std::overflow_error) { throw std::overflow_error("oops"); }
+ void throw_range_error() TESTCASE_THROW1(std::range_error) { throw std::range_error("oops"); }
+ void throw_runtime_error() TESTCASE_THROW1(std::runtime_error) { throw std::runtime_error("oops"); }
+ void throw_underflow_error() TESTCASE_THROW1(std::underflow_error) { throw std::underflow_error("oops"); }
};
%}
+
diff --git a/Examples/test-suite/li_std_except_as_class.i b/Examples/test-suite/li_std_except_as_class.i
index 01ed1f07c..3d9706c80 100644
--- a/Examples/test-suite/li_std_except_as_class.i
+++ b/Examples/test-suite/li_std_except_as_class.i
@@ -5,23 +5,23 @@
* if there were also functions throwing 'std::logic_error' and
* 'std::exception' then the bug would not be fully replicated */
+// throw is invalid in C++17 and later, only SWIG to use it
+#define TESTCASE_THROW2(T1, T2) throw(T1, T2)
%{
-#if defined(_MSC_VER)
- #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
+#define TESTCASE_THROW2(T1, T2)
%}
%{
#include <exception>
#include <stdexcept>
-void test_domain_error() throw(std::domain_error)
+void test_domain_error() TESTCASE_THROW2(std::domain_error, int)
{ throw std::domain_error("std::domain_error"); }
%}
%include <std_string.i>
#define SWIG_STD_EXCEPTIONS_AS_CLASSES
%include <std_except.i>
-void test_domain_error() throw(std::domain_error)
+void test_domain_error() TESTCASE_THROW2(std::domain_error, int)
{ throw std::domain_error("std::domain_error"); }
%inline %{
@@ -31,3 +31,4 @@ bool is_python_builtin() { return true; }
bool is_python_builtin() { return false; }
#endif
%}
+
diff --git a/Examples/test-suite/li_std_list.i b/Examples/test-suite/li_std_list.i
index bae475eea..2ed5b9ad7 100644
--- a/Examples/test-suite/li_std_list.i
+++ b/Examples/test-suite/li_std_list.i
@@ -1,6 +1,7 @@
%module li_std_list
%include "std_list.i"
+%include "std_string.i"
%{
#include <algorithm>
@@ -8,19 +9,18 @@
#include <numeric>
%}
-namespace std {
- %template(IntList) list<int>;
-}
-
+%template(BoolList) std::list<bool>;
+%template(CharList) std::list<char>;
+%template(ShortList) std::list<short>;
+%template(IntList) std::list<int>;
+%template(LongList) std::list<long>;
+%template(UCharList) std::list<unsigned char>;
+%template(UIntList) std::list<unsigned int>;
+%template(UShortList) std::list<unsigned short>;
+%template(ULongList) std::list<unsigned long>;
+%template(FloatList) std::list<float>;
%template(DoubleList) std::list<double>;
-
-%inline %{
-typedef float Real;
-%}
-
-namespace std {
- %template(RealList) list<Real>;
-}
+%template(StringList) std::list<std::string>;
%inline %{
@@ -30,17 +30,43 @@ double average(std::list<int> v) {
void halve_in_place(std::list<double>& v) {
- std::transform(v.begin(),v.end(),v.begin(),
- std::bind2nd(std::divides<double>(),2.0));
+ for (std::list<double>::iterator it = v.begin(); it != v.end(); ++it)
+ *it /= 2.0;
}
struct Struct {
double num;
Struct() : num(0.0) {}
Struct(double d) : num(d) {}
-// bool operator==(const Struct &other) { return (num == other.num); }
};
-%}
+const std::list<Struct> & CopyContainerStruct(const std::list<Struct> & container) { return container; }
+const std::list<Struct *> & CopyContainerStructPtr(const std::list<Struct *> & container) { return container; }
+const std::list<const Struct *> & CopyContainerStructConstPtr(const std::list<const Struct *> & container) { return container; }
+
+const std::list<float> & listreal(const std::list<float> & list) { return list; }
+
+const std::list<int> & listint(const std::list<int> & list) { return list; }
+const std::list<int *> & listintptr(const std::list<int *> & list) { return list; }
+const std::list<const int *> & listintconstptr(const std::list<const int *> & list) { return list; }
+
+const std::list<Struct> & liststruct(const std::list<Struct> & list) { return list; }
+const std::list<Struct *> & liststructptr(const std::list<Struct *> & list) { return list; }
+const std::list<const Struct *> & liststructconstptr(const std::list<const Struct *> & list) { return list; }
+enum Fruit {
+ APPLE,
+ BANANNA,
+ PEAR,
+ KIWI,
+};
+%}
+#if !defined(SWIGR)
+%template(IntPtrList) std::list<int *>;
+%template(IntConstPtrList) std::list<const int *>;
+#endif
+%template(StructList) std::list<Struct>;
+%template(StructPtrList) std::list<Struct *>;
+%template(StructConstPtrList) std::list<const Struct *>;
+%template(FruitList) std::list<enum Fruit>;
diff --git a/Examples/test-suite/li_std_map.i b/Examples/test-suite/li_std_map.i
index bf24c35e1..161ec6aca 100644
--- a/Examples/test-suite/li_std_map.i
+++ b/Examples/test-suite/li_std_map.i
@@ -1,6 +1,10 @@
%module("templatereduce") li_std_map
%feature("trackobjects");
+#ifdef SWIGOCAML
+%warnfilter(SWIGWARN_PARSE_KEYWORD) val;
+#endif
+
%inline %{
namespace another {
struct map {
@@ -117,4 +121,25 @@ namespace std {
}
}
+%ignore LengthCompare::operator();
+%inline %{
+struct LengthCompare {
+ bool operator() (std::string s1, std::string s2) const {
+ return s1.size() < s2.size();
+ }
+};
+%}
+
+// A map sorted by string lengths
+%template(StringLengthNumberMap) std::map< std::string, int, LengthCompare >;
+%inline %{
+std::map< std::string, int, LengthCompare > MyMap;
+void populate(std::map< std::string, int, LengthCompare >&m) {
+ m["aa"] = 2;
+ m["xxxx"] = 4;
+ m["a"] = 1;
+ m["aaaaa"] = 5;
+ m["zzz"] = 3;
+}
+%}
diff --git a/Examples/test-suite/li_std_set.i b/Examples/test-suite/li_std_set.i
index 2dcc2f17c..507272d8d 100644
--- a/Examples/test-suite/li_std_set.i
+++ b/Examples/test-suite/li_std_set.i
@@ -1,5 +1,5 @@
/*
- * a test of set containers.
+ * a test of set containers.
* Languages should define swig::LANGUAGE_OBJ to be
* an entity of their native pointer type which can be
* included in a STL container.
@@ -13,22 +13,42 @@
%include <std_string.i>
%include <std_set.i>
-%include <std_multiset.i>
%include <std_vector.i>
-%template(set_string) std::set<std::string>;
-%template(set_int) std::multiset<int>;
-
-
-%template(v_int) std::vector<int>;
-
-
-
+// Use language macros since Java and C# don't have multiset support (yet)
+// and uses different naming conventions.
+#if defined(SWIGRUBY) || defined(SWIGPYTHON)
+ %include <std_multiset.i>
+ %template(set_int) std::multiset<int>;
+ %template(v_int) std::vector<int>;
+ %template(set_string) std::set<std::string>;
+#elif defined(SWIGJAVA) || defined(SWIGCSHARP)
+ // This operator is only defined because it's needed to store objects of
+ // type Foo in std::set in C++, we don't need to wrap it.
+ %ignore operator<;
+ %inline %{
+ struct Foo
+ {
+ explicit Foo(int n) : n(n) {}
+
+ int n;
+
+ friend bool operator<(Foo foo1, Foo foo2)
+ {
+ return foo1.n < foo2.n;
+ }
+ };
+ %}
+
+ %template(IntSet) std::set<int>;
+ %template(StringSet) std::set<std::string>;
+ %template(FooSet) std::set<Foo>;
+#endif
#if defined(SWIGRUBY)
-%template(LanguageSet) std::set<swig::LANGUAGE_OBJ>;
+%template(LanguageSet) std::set<swig::LANGUAGE_OBJ>;
#endif
#if defined(SWIGPYTHON)
-%template(pyset) std::set<swig::SwigPtr_PyObject>;
+%template(pyset) std::set<swig::SwigPtr_PyObject>;
#endif
diff --git a/Examples/test-suite/li_std_string.i b/Examples/test-suite/li_std_string.i
index a1a55ed85..47a9090b7 100644
--- a/Examples/test-suite/li_std_string.i
+++ b/Examples/test-suite/li_std_string.i
@@ -6,6 +6,11 @@
%apply std::string& INOUT { std::string &inout }
#endif
+// throw is invalid in C++17 and later, only SWIG to use it
+#define TESTCASE_THROW1(T1) throw(T1)
+%{
+#define TESTCASE_THROW1(T1)
+%}
%inline %{
@@ -17,6 +22,12 @@ const std::string& test_const_reference(const std::string &x) {
return x;
}
+void test_const_reference_returning_void(const std::string &) {
+}
+
+void test_const_reference_returning_void(const std::string &, int) {
+}
+
void test_pointer(std::string *x) {
}
@@ -49,32 +60,23 @@ void test_reference_inout(std::string &inout) {
inout += inout;
}
-#if defined(_MSC_VER)
- #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
-
-void test_throw() throw(std::string){
+void test_throw() TESTCASE_THROW1(std::string){
static std::string x = "test_throw message";
throw x;
}
-void test_const_reference_throw() throw(const std::string &){
+void test_const_reference_throw() TESTCASE_THROW1(const std::string &){
static std::string x = "test_const_reference_throw message";
throw x;
}
-void test_pointer_throw() throw(std::string *) {
+void test_pointer_throw() TESTCASE_THROW1(std::string *) {
throw new std::string("foo");
}
-void test_const_pointer_throw() throw(const std::string *) {
+void test_const_pointer_throw() TESTCASE_THROW1(const std::string *) {
throw new std::string("foo");
}
-
-#if defined(_MSC_VER)
- #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
-
%}
/* Old way, now std::string is a %naturalvar by default
@@ -154,6 +156,5 @@ public:
const char *get_null(const char *a) {
return a == 0 ? a : "non-null";
}
-
-
%}
+
diff --git a/Examples/test-suite/li_std_string_extra.i b/Examples/test-suite/li_std_string_extra.i
index 6bef12ff4..1fc2225ca 100644
--- a/Examples/test-suite/li_std_string_extra.i
+++ b/Examples/test-suite/li_std_string_extra.i
@@ -49,6 +49,14 @@ std::basic_string<char,std::char_traits<char>,std::allocator<char> > test_value_
return x;
}
+std::basic_string<char,std::char_traits<char>,std::allocator<char> > test_value_basic_overload(std::basic_string<char,std::char_traits<char>,std::allocator<char> > x) {
+ return x;
+}
+
+std::basic_string<char,std::char_traits<char>,std::allocator<char> > test_value_basic_overload(int) {
+ return "int";
+}
+
#ifdef SWIGPYTHON_BUILTIN
bool is_python_builtin() { return true; }
#else
diff --git a/Examples/test-suite/li_std_vector.i b/Examples/test-suite/li_std_vector.i
index ada146cc4..33fb79720 100644
--- a/Examples/test-suite/li_std_vector.i
+++ b/Examples/test-suite/li_std_vector.i
@@ -48,8 +48,8 @@ std::vector<Real> half(const std::vector<Real>& v) {
}
void halve_in_place(std::vector<double>& v) {
- std::transform(v.begin(),v.end(),v.begin(),
- std::bind2nd(std::divides<double>(),2.0));
+ for (std::vector<double>::iterator it = v.begin(); it != v.end(); ++it)
+ *it /= 2.0;
}
struct Struct {
diff --git a/Examples/test-suite/li_std_vector_back_reference.i b/Examples/test-suite/li_std_vector_back_reference.i
new file mode 100644
index 000000000..be41f4740
--- /dev/null
+++ b/Examples/test-suite/li_std_vector_back_reference.i
@@ -0,0 +1,14 @@
+%module li_std_vector_back_reference
+
+%include <std_vector.i>
+
+%inline %{
+// #include <iostream>
+struct Wheel {
+ int size;
+ Wheel(int sz = 0) : size(sz) {}
+// ~Wheel() { std::cout << "~Wheel" << std::endl; }
+};
+%}
+
+%template(VectorWheel) std::vector<Wheel>;
diff --git a/Examples/test-suite/li_std_vector_extra.i b/Examples/test-suite/li_std_vector_extra.i
index 531898a0e..70b776b37 100644
--- a/Examples/test-suite/li_std_vector_extra.i
+++ b/Examples/test-suite/li_std_vector_extra.i
@@ -12,17 +12,6 @@
#include <algorithm>
#include <functional>
#include <numeric>
-
-
-#if defined(__clang__)
-// Suppress:
-// warning: destination for this 'memset' call is a pointer to dynamic class
-// 'Test::B'; vtable pointer will be overwritten [-Wdynamic-class-memaccess]
-// memset(v_def,0,sizeof(Type));
-// Better generated code is probably needed though
-#pragma clang diagnostic ignored "-Wdynamic-class-memaccess"
-#endif
-
%}
namespace std {
@@ -73,8 +62,8 @@ std::vector<Real> half(const std::vector<Real>& v) {
}
void halve_in_place(std::vector<double>& v) {
- std::transform(v.begin(),v.end(),v.begin(),
- std::bind2nd(std::divides<double>(),2.0));
+ for (std::vector<double>::iterator it = v.begin(); it != v.end(); ++it)
+ *it /= 2.0;
}
%}
@@ -140,6 +129,7 @@ std::vector<std::string> vecStr(std::vector<std::string> v) {
double *makeDoublePtr(double v) { return new double(v); }
int extractInt(int *p) { return *p; }
short extractConstShort(const short *p) { return *p; }
+ short extractConstShort2(std::vector<const short *>::value_type p) { return *p; }
%}
%template(pyvector) std::vector<swig::SwigPtr_PyObject>;
diff --git a/Examples/test-suite/li_std_vector_ptr.i b/Examples/test-suite/li_std_vector_ptr.i
index 4d6794717..dcf1128e0 100644
--- a/Examples/test-suite/li_std_vector_ptr.i
+++ b/Examples/test-suite/li_std_vector_ptr.i
@@ -5,12 +5,29 @@
%template(IntPtrVector) std::vector<int *>;
+#ifdef SWIGOCAML
+%warnfilter(SWIGWARN_PARSE_KEYWORD) val;
+#endif
+
%inline %{
#include <iostream>
using namespace std;
int* makeIntPtr(int v) {
return new int(v);
}
+std::vector<int *>::value_type makeIntPtr2(int v) {
+ return new int(v);
+}
+int getIntValue(int *p) {
+ return *p;
+}
+int getIntValue2(std::vector<int *>::const_reference p) {
+ return *p;
+}
+int getIntValue3(std::vector<int *>::reference p) {
+ return *p;
+}
+
double* makeDoublePtr(double v) {
return new double(v);
}
diff --git a/Examples/test-suite/li_std_wstring.i b/Examples/test-suite/li_std_wstring.i
index 80f860338..a790ca7e0 100644
--- a/Examples/test-suite/li_std_wstring.i
+++ b/Examples/test-suite/li_std_wstring.i
@@ -1,29 +1,18 @@
%module li_std_wstring
-%include <std_basic_string.i>
-%include <std_wstring.i>
-
-%inline %{
+// The languages below are yet to provide std_wstring.i
+#if !(defined(SWIGD) || defined(SWIGGO) || defined(SWIGGUILE) || defined(SWIGJAVASCRIPT) || defined(SWIGLUA) || defined(SWIGMZSCHEME) || defined(SWIGOCAML) || defined(SWIGOCTAVE) || defined(SWIGPERL) || defined(SWIGPHP) || defined(SWIGR) || defined(SWIGSCILAB))
-struct A : std::wstring
-{
- A(const std::wstring& s) : std::wstring(s)
- {
- }
-};
+%include <std_wstring.i>
-struct B
-{
- B(const std::wstring& s) : cname(0), name(s), a(s)
- {
- }
-
- char *cname;
- std::wstring name;
- A a;
+// throw is invalid in C++17 and later, only SWIG to use it
+#define TESTCASE_THROW1(T1) throw(T1)
+%{
+#define TESTCASE_THROW1(T1)
+%}
-};
-
+%inline %{
+#include <string>
wchar_t test_wcvalue(wchar_t x) {
return x;
@@ -57,47 +46,36 @@ const std::wstring& test_const_reference(const std::wstring &x) {
void test_pointer(std::wstring *x) {
}
-std::wstring *test_pointer_out() {
- static std::wstring x = L"x";
- return &x;
-}
-
void test_const_pointer(const std::wstring *x) {
}
-const std::wstring *test_const_pointer_out() {
- static std::wstring x = L"x";
- return &x;
-}
-
void test_reference(std::wstring &x) {
}
-std::wstring& test_reference_out() {
- static std::wstring x = L"x";
- return x;
+bool test_equal_abc(const std::wstring &s) {
+ return L"abc" == s;
}
-#if defined(_MSC_VER)
- #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
-
-void test_throw() throw(std::wstring){
- static std::wstring x = L"x";
+void test_throw() TESTCASE_THROW1(std::wstring){
+ static std::wstring x = L"throwing test_throw";
throw x;
}
-#if defined(_MSC_VER)
- #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
+const char * non_utf8_c_str() {
+ return "h\xe9llo";
+}
-#ifdef SWIGPYTHON_BUILTIN
-bool is_python_builtin() { return true; }
-#else
-bool is_python_builtin() { return false; }
-#endif
+size_t size_wstring(const std::wstring& s) {
+ return s.size();
+}
+
+struct wchar_test_struct {
+ wchar_t wchar_t_member;
+ wchar_t* wchar_t_ptr_member;
+};
%}
+#endif
diff --git a/Examples/test-suite/li_std_wstring_inherit.i b/Examples/test-suite/li_std_wstring_inherit.i
new file mode 100644
index 000000000..54c6bd8c4
--- /dev/null
+++ b/Examples/test-suite/li_std_wstring_inherit.i
@@ -0,0 +1,39 @@
+%module li_std_wstring_inherit
+%include <std_basic_string.i>
+%include <std_wstring.i>
+
+
+%inline %{
+
+struct A : std::wstring
+{
+ A(const std::wstring& s) : std::wstring(s)
+ {
+ }
+};
+
+struct B
+{
+ B(const std::wstring& s) : cname(0), name(s), a(s)
+ {
+ }
+
+ char *cname;
+ std::wstring name;
+ A a;
+
+};
+
+std::wstring test_value(std::wstring x) {
+ return x;
+}
+
+#ifdef SWIGPYTHON_BUILTIN
+bool is_python_builtin() { return true; }
+#else
+bool is_python_builtin() { return false; }
+#endif
+
+%}
+
+
diff --git a/Examples/test-suite/li_typemaps.i b/Examples/test-suite/li_typemaps.i
index a53c1c74a..d508c1c84 100644
--- a/Examples/test-suite/li_typemaps.i
+++ b/Examples/test-suite/li_typemaps.i
@@ -2,6 +2,7 @@
%include "typemaps.i"
+%apply int *OUTPUT { int *OUTPUT2 };
%apply int &INOUT { int &INOUT2 };
%newobject out_foo;
%inline %{
@@ -51,10 +52,13 @@ void out_longlong(long long x, long long *OUTPUT) { *OUTPUT = x; }
void out_ulonglong(unsigned long long x, unsigned long long *OUTPUT) { *OUTPUT = x; }
/* Tests a returning a wrapped pointer and an output argument */
-struct Foo *out_foo(int a, int *OUTPUT) {
+struct Foo *out_foo(int a, int *OUTPUT, int *OUTPUT2) {
struct Foo *f = new struct Foo();
f->a = a;
*OUTPUT = a * 2;
+ struct Foo *f2 = new struct Foo();
+ f2->a = a;
+ *OUTPUT2 = a * 3;
return f;
}
diff --git a/Examples/test-suite/lua/Makefile.in b/Examples/test-suite/lua/Makefile.in
index 7a77bbb9e..92559bb8f 100644
--- a/Examples/test-suite/lua/Makefile.in
+++ b/Examples/test-suite/lua/Makefile.in
@@ -15,6 +15,7 @@ top_builddir = @top_builddir@
CPP_TEST_CASES += \
lua_no_module_global \
lua_inherit_getitem \
+ lua_lightuserdata \
C_TEST_CASES += \
@@ -58,9 +59,3 @@ run_testcase = \
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' lua_clean
-
-cvsignore:
- @echo '*wrap* *.so *.dll *.exp *.lib'
- @echo Makefile
- @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do echo $$i.lua; done
- @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do if grep -q $${i}_runme.lua CVS/Entries ; then echo $${i}_runme.lua; fi; done
diff --git a/Examples/test-suite/lua/abstract_access_runme.lua b/Examples/test-suite/lua/abstract_access_runme.lua
index c1d836136..70467ee2b 100644
--- a/Examples/test-suite/lua/abstract_access_runme.lua
+++ b/Examples/test-suite/lua/abstract_access_runme.lua
@@ -6,7 +6,7 @@ local env = _ENV -- Lua 5.2
if not env then env = getfenv () end -- Lua 5.1
setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
--- trying to instantiate pure virual classes
+-- trying to instantiate pure virtual classes
-- should fail
assert(pcall(abstract_access.A)==false)
assert(pcall(abstract_access.B)==false)
diff --git a/Examples/test-suite/lua/li_std_string_runme.lua b/Examples/test-suite/lua/li_std_string_runme.lua
index 956bea0fc..a36bf7ef6 100644
--- a/Examples/test-suite/lua/li_std_string_runme.lua
+++ b/Examples/test-suite/lua/li_std_string_runme.lua
@@ -32,8 +32,8 @@ assert(is_std_string(cobj) and cobj:c_str()=="x") -- check type & value
test_const_pointer(cobj)
--- this shouldnt work, but it does
--- swig doesnt appear to diff between const object ptrs & object ptrs very well
+-- this shouldn't work, but it does
+-- swig doesn't appear to diff between const object ptrs & object ptrs very well
test_pointer(cobj) -- this wants an non const object (give it a const one!)
-- refs are also wrappered as ptrs (unless the correct typemaps are applied)
diff --git a/Examples/test-suite/lua/li_typemaps_runme.lua b/Examples/test-suite/lua/li_typemaps_runme.lua
index 7456d8245..342634a5b 100644
--- a/Examples/test-suite/lua/li_typemaps_runme.lua
+++ b/Examples/test-suite/lua/li_typemaps_runme.lua
@@ -38,5 +38,5 @@ assert(li_typemaps.inoutr_bool(false)==false)
a,b=li_typemaps.inoutr_int2(1,2)
assert(a==1 and b==2)
-f,i=li_typemaps.out_foo(10)
-assert(f.a==10 and i==20)
+f,i,i2=li_typemaps.out_foo(10)
+assert(f.a==10 and i==20 and i2==30)
diff --git a/Examples/test-suite/lua/lua_lightuserdata_runme.lua b/Examples/test-suite/lua/lua_lightuserdata_runme.lua
new file mode 100644
index 000000000..c1c3c1d73
--- /dev/null
+++ b/Examples/test-suite/lua/lua_lightuserdata_runme.lua
@@ -0,0 +1,7 @@
+require("import") -- the import fn
+import("lua_lightuserdata") -- import lib
+
+local t = lua_lightuserdata
+local d = t.get_lightuserdata()
+local r = t.check_lighuserdata(d)
+assert(r)
diff --git a/Examples/test-suite/lua/newobject2_runme.lua b/Examples/test-suite/lua/newobject2_runme.lua
index cf6c87ae7..748c95372 100644
--- a/Examples/test-suite/lua/newobject2_runme.lua
+++ b/Examples/test-suite/lua/newobject2_runme.lua
@@ -1,8 +1,8 @@
require("import") -- the import fn
import("newobject2",true) -- import code
-foo1 = newobject2.makeFoo() -- lua doesnt yet support static fns properly
-assert(newobject2.fooCount() == 1) -- lua doesnt yet support static fns properly
+foo1 = newobject2.makeFoo() -- lua doesn't yet support static fns properly
+assert(newobject2.fooCount() == 1) -- lua doesn't yet support static fns properly
foo2 = newobject2.makeFoo()
assert(newobject2.fooCount() == 2)
diff --git a/Examples/test-suite/lua/overload_complicated_runme.lua b/Examples/test-suite/lua/overload_complicated_runme.lua
index e8ef43107..3decfa87d 100644
--- a/Examples/test-suite/lua/overload_complicated_runme.lua
+++ b/Examples/test-suite/lua/overload_complicated_runme.lua
@@ -12,11 +12,11 @@ assert(oc.foo(1,1,"test",1) == 15)
p1 = oc.Pop(nil)
p1 = oc.Pop(nil,false)
-assert(p1:hip(true) == 701)
+assert(p1:hip(false) == 701)
assert(p1:hip(nil) == 702)
-assert(p1:hop(true) == 801)
+assert(p1:hop(false) == 801)
assert(p1:hop(nil) == 805)
-assert(oc.muzak(true) == 3001)
+assert(oc.muzak(false) == 3001)
assert(oc.muzak(nil) == 3002)
diff --git a/Examples/test-suite/lua/overload_null_runme.lua b/Examples/test-suite/lua/overload_null_runme.lua
new file mode 100644
index 000000000..69b7de2db
--- /dev/null
+++ b/Examples/test-suite/lua/overload_null_runme.lua
@@ -0,0 +1,41 @@
+require("import") -- the import fn
+import("overload_null") -- import lib into global
+
+o = overload_null.Overload()
+x = overload_null.X()
+
+assert(1 == o:byval1(x))
+assert(2 == o:byval1(nil))
+
+assert(3 == o:byval2(nil))
+assert(4 == o:byval2(x))
+
+assert(5 == o:byref1(x))
+assert(6 == o:byref1(nil))
+
+assert(7 == o:byref2(nil))
+assert(8 == o:byref2(x))
+
+assert(9 == o:byconstref1(x))
+assert(10 == o:byconstref1(nil))
+
+assert(11 == o:byconstref2(nil))
+assert(12 == o:byconstref2(x))
+
+-- const pointer references
+assert(13 == o:byval1cpr(x))
+assert(14 == o:byval1cpr(nil))
+
+assert(15 == o:byval2cpr(nil))
+assert(16 == o:byval2cpr(x))
+
+-- forward class declaration
+assert(17 == o:byval1forwardptr(x))
+assert(18 == o:byval1forwardptr(nil))
+
+assert(19 == o:byval2forwardptr(nil))
+assert(20 == o:byval2forwardptr(x))
+
+assert(21 == o:byval1forwardref(x))
+
+assert(22 == o:byval2forwardref(x))
diff --git a/Examples/test-suite/lua_lightuserdata.i b/Examples/test-suite/lua_lightuserdata.i
new file mode 100644
index 000000000..9069b6ab4
--- /dev/null
+++ b/Examples/test-suite/lua_lightuserdata.i
@@ -0,0 +1,17 @@
+%module lua_lightuserdata
+
+%native(get_lightuserdata) int get_lightuserdata(lua_State* L);
+%{
+static int foo;
+int get_lightuserdata(lua_State* L)
+{
+ lua_pushlightuserdata(L, &foo);
+ return 1;
+}
+%}
+
+%inline %{
+bool check_lighuserdata(const void* d) {
+ return d == &foo;
+}
+%}
diff --git a/Examples/test-suite/member_funcptr_galore.i b/Examples/test-suite/member_funcptr_galore.i
index 9a012f306..27c2f02a7 100644
--- a/Examples/test-suite/member_funcptr_galore.i
+++ b/Examples/test-suite/member_funcptr_galore.i
@@ -1,5 +1,17 @@
%module member_funcptr_galore
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) extra2;
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) extra3;
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) pp2;
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) pp3;
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) pp5;
+
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) ccextra2;
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) ccextra3;
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) cc2;
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) cc3;
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) cc5;
+
%{
#if defined(__SUNPRO_CC)
#pragma error_messages (off, badargtype2w) /* Formal argument ... is being passed extern "C" ... */
@@ -27,6 +39,8 @@ public:
void move(double dx, double dy);
virtual double area(Shape &ref, int & (FunkSpace::Funktions::*d)(const int &, int)) { return 0.0; }
+ virtual double area_const(Shape &ref, int & (FunkSpace::Funktions::*)(const int &, int) const) { return 0.0; } // Note: unnamed parameter
+ virtual double zyx(int (FunkSpace::Funktions::*)() const) { return 0.0; } // Note: unnamed parameter
virtual double abc(Thing<short> ts, Thing< const Space::Shape * > tda[]) { return 0.0; }
virtual ~Shape() {}
};
@@ -55,6 +69,10 @@ double do_op(Space::Shape *s, double (Space::Shape::*m)(void)) {
return (s->*m)();
}
+double do_op_const(Space::Shape *s, double (Space::Shape::*m)(void) const) {
+ return (s->*m)();
+}
+
double (Space::Shape::*areapt(Space::Shape &ref, int & (FunkSpace::Funktions::*d)(const int &, int)))(Space::Shape &, int & (FunkSpace::Funktions::*d)(const int &, int)) {
return &Space::Shape::area;
}
@@ -75,6 +93,7 @@ double (Space::Shape::*abcvar)(Thing<short>, Thing< const Space::Shape * >[]) =
/* Some constants */
%constant double (Space::Shape::*AREAPT)(Space::Shape &, int & (FunkSpace::Funktions::*)(const int &, int)) = &Space::Shape::area;
+%constant double (Space::Shape::*AREAPT_CONST)(Space::Shape &, int & (FunkSpace::Funktions::*)(const int &, int) const) = &Space::Shape::area_const;
%constant double (Space::Shape::*PERIMPT)(Thing<short>, Thing< const Space::Shape * >[]) = &Space::Shape::abc;
%constant double (Space::Shape::*NULLPT)(void) = 0;
@@ -94,3 +113,115 @@ int call3(int & (FunkSpace::Funktions::*d)(const int &, int), int a, int b) { Fu
int unreal1(double (Space::Shape::*memptr)(Space::Shape &, int & (FunkSpace::Funktions::*)(const int &, int))) { return 0; }
int unreal2(double (Space::Shape::*memptr)(Thing<short>)) { return 0; }
%}
+
+
+%inline %{
+struct Funcs {
+ short FF(bool) { return 0; }
+ short CC(bool) const { return 0; }
+};
+
+class MemberFuncPtrs
+{
+public:
+ // member const function pointers, unnamed parameters
+ int aaa1(short (Funcs::* )(bool) const) const;
+ int aaa2(short (Funcs::* const *&)(bool) const) const;
+ int aaa3(short (Funcs::* *& )(bool) const) const;
+ int aaa4(short (Funcs::* *const& )(bool) const) const;
+ int aaa5(short (Funcs::* & )(bool) const) const;
+ int aaa6(short (Funcs::* const)(bool) const) const;
+ int aaa7(short (Funcs::* const&)(bool) const) const;
+
+ // member non-const function pointers, unnamed parameters
+ int bbb1(short (Funcs::* )(bool)) const;
+ int bbb2(short (Funcs::* const *&)(bool)) const;
+ int bbb3(short (Funcs::* *& )(bool)) const;
+ int bbb4(short (Funcs::* *const& )(bool)) const;
+ int bbb5(short (Funcs::* & )(bool)) const;
+ int bbb6(short (Funcs::* const)(bool)) const;
+ int bbb7(short (Funcs::* const&)(bool)) const;
+
+ // member const function pointers, named parameters
+ int ppp1(short (Funcs::* pp1)(bool) const) const;
+ int ppp2(short (Funcs::* const *& pp2)(bool) const) const;
+ int ppp3(short (Funcs::* *& pp3)(bool) const) const;
+ int ppp4(short (Funcs::* *const& pp4)(bool) const) const;
+ int ppp5(short (Funcs::* & pp5)(bool) const) const;
+ int ppp6(short (Funcs::* const pp6)(bool) const) const;
+ int ppp7(short (Funcs::* const& pp7)(bool) const) const;
+
+ // member non-const function pointers, named parameters
+ int qqq1(short (Funcs::* qq1)(bool)) const;
+ int qqq2(short (Funcs::* const *& qq2)(bool)) const;
+ int qqq3(short (Funcs::* *& qq3)(bool)) const;
+ int qqq4(short (Funcs::* *const& qq4)(bool)) const;
+ int qqq5(short (Funcs::* & qq5)(bool)) const;
+ int qqq6(short (Funcs::* const qq6)(bool)) const;
+ int qqq7(short (Funcs::* const& qq7)(bool)) const;
+};
+
+// member const function pointers, unnamed parameters
+int MemberFuncPtrs::aaa1(short (Funcs::* )(bool) const) const { return 0; }
+int MemberFuncPtrs::aaa2(short (Funcs::* const *&)(bool) const) const { return 0; }
+int MemberFuncPtrs::aaa3(short (Funcs::* *& )(bool) const) const { return 0; }
+int MemberFuncPtrs::aaa4(short (Funcs::* *const& )(bool) const) const { return 0; }
+int MemberFuncPtrs::aaa5(short (Funcs::* & )(bool) const) const { return 0; }
+int MemberFuncPtrs::aaa6(short (Funcs::* const)(bool) const) const { return 0; }
+int MemberFuncPtrs::aaa7(short (Funcs::* const&)(bool) const) const { return 0; }
+
+// member non-const function pointers, unnamed parameters
+int MemberFuncPtrs::bbb1(short (Funcs::* )(bool)) const { return 0; }
+int MemberFuncPtrs::bbb2(short (Funcs::* const *&)(bool)) const { return 0; }
+int MemberFuncPtrs::bbb3(short (Funcs::* *& )(bool)) const { return 0; }
+int MemberFuncPtrs::bbb4(short (Funcs::* *const& )(bool)) const { return 0; }
+int MemberFuncPtrs::bbb5(short (Funcs::* & )(bool)) const { return 0; }
+int MemberFuncPtrs::bbb6(short (Funcs::* const)(bool)) const { return 0; }
+int MemberFuncPtrs::bbb7(short (Funcs::* const&)(bool)) const { return 0; }
+
+// member const function pointers, named parameters
+int MemberFuncPtrs::ppp1(short (Funcs::* pp1)(bool) const) const { return 0; }
+int MemberFuncPtrs::ppp2(short (Funcs::* const *& pp2)(bool) const) const { return 0; }
+int MemberFuncPtrs::ppp3(short (Funcs::* *& pp3)(bool) const) const { return 0; }
+int MemberFuncPtrs::ppp4(short (Funcs::* *const& pp4)(bool) const) const { return 0; }
+int MemberFuncPtrs::ppp5(short (Funcs::* & pp5)(bool) const) const { return 0; }
+int MemberFuncPtrs::ppp6(short (Funcs::* const pp6)(bool) const) const { return 0; }
+int MemberFuncPtrs::ppp7(short (Funcs::* const& pp7)(bool) const) const { return 0; }
+
+// member non-const function pointers, named parameters
+int MemberFuncPtrs::qqq1(short (Funcs::* qq1)(bool)) const { return 0; }
+int MemberFuncPtrs::qqq2(short (Funcs::* const *& qq2)(bool)) const { return 0; }
+int MemberFuncPtrs::qqq3(short (Funcs::* *& qq3)(bool)) const { return 0; }
+int MemberFuncPtrs::qqq4(short (Funcs::* *const& qq4)(bool)) const { return 0; }
+int MemberFuncPtrs::qqq5(short (Funcs::* & qq5)(bool)) const { return 0; }
+int MemberFuncPtrs::qqq6(short (Funcs::* const qq6)(bool)) const { return 0; }
+int MemberFuncPtrs::qqq7(short (Funcs::* const& qq7)(bool)) const { return 0; }
+
+// member non-const function pointer variables
+short (Funcs::* pp1)(bool) = &Funcs::FF;
+
+short (Funcs::* const * extra2)(bool) = &pp1;
+short (Funcs::* * extra3)(bool) = &pp1;
+short (Funcs::* *const extra4)(bool) = &pp1;
+
+short (Funcs::* const *& pp2)(bool) = extra2;
+short (Funcs::* *& pp3)(bool) = extra3;
+short (Funcs::* *const& pp4)(bool) = extra4;
+short (Funcs::* & pp5)(bool) = pp1;
+short (Funcs::* const pp6)(bool) = &Funcs::FF;
+short (Funcs::* const& pp7)(bool) = pp1;
+
+// member const function pointer variables
+short (Funcs::* cc1)(bool) const = &Funcs::CC;
+
+short (Funcs::* const * ccextra2)(bool) const = &cc1;
+short (Funcs::* * ccextra3)(bool) const = &cc1;
+short (Funcs::* *const ccextra4)(bool) const = &cc1;
+
+short (Funcs::* const *& cc2)(bool) const = ccextra2;
+short (Funcs::* *& cc3)(bool) const = ccextra3;
+short (Funcs::* *const& cc4)(bool) const = ccextra4;
+short (Funcs::* & cc5)(bool) const = cc1;
+short (Funcs::* const cc6)(bool) const = &Funcs::CC;
+short (Funcs::* const& cc7)(bool) const = cc1;
+%}
diff --git a/Examples/test-suite/member_pointer.i b/Examples/test-suite/member_pointer.i
index fe454302a..e3b4f85ab 100644
--- a/Examples/test-suite/member_pointer.i
+++ b/Examples/test-suite/member_pointer.i
@@ -44,17 +44,22 @@ public:
virtual double perimeter(void);
};
+/* Typedef */
+typedef double (Shape::*PerimeterFunc_td)(void);
+
extern double do_op(Shape *s, double (Shape::*m)(void));
+extern double do_op_td(Shape *s, PerimeterFunc_td m);
/* Functions that return member pointers */
extern double (Shape::*areapt())(void);
extern double (Shape::*perimeterpt())(void);
+extern PerimeterFunc_td perimeterpt_td();
/* Global variables that are member pointers */
extern double (Shape::*areavar)(void);
extern double (Shape::*perimetervar)(void);
-
+extern PerimeterFunc_td perimetervar_td;
%}
%{
@@ -88,6 +93,10 @@ double do_op(Shape *s, double (Shape::*m)(void)) {
return (s->*m)();
}
+double do_op_td(Shape *s, PerimeterFunc_td m) {
+ return (s->*m)();
+}
+
double (Shape::*areapt())(void) {
return &Shape::area;
}
@@ -96,9 +105,14 @@ double (Shape::*perimeterpt())(void) {
return &Shape::perimeter;
}
+PerimeterFunc_td perimeterpt_td() {
+ return &Shape::perimeter;
+}
+
/* Member pointer variables */
double (Shape::*areavar)(void) = &Shape::area;
double (Shape::*perimetervar)(void) = &Shape::perimeter;
+PerimeterFunc_td perimetervar_td = &Shape::perimeter;
%}
diff --git a/Examples/test-suite/member_pointer_const.i b/Examples/test-suite/member_pointer_const.i
new file mode 100644
index 000000000..4af712f7f
--- /dev/null
+++ b/Examples/test-suite/member_pointer_const.i
@@ -0,0 +1,149 @@
+%module member_pointer_const
+// Same as member_pointer.i but using member pointer const functions
+
+%{
+#if defined(__SUNPRO_CC)
+#pragma error_messages (off, badargtype2w) /* Formal argument ... is being passed extern "C" ... */
+#pragma error_messages (off, wbadinit) /* Using extern "C" ... to initialize ... */
+#pragma error_messages (off, wbadasg) /* Assigning extern "C" ... */
+#endif
+%}
+
+%inline %{
+class Shape {
+public:
+ Shape() {
+ nshapes++;
+ }
+ virtual ~Shape() {
+ nshapes--;
+ };
+ double x, y;
+ double *z;
+
+ void move(double dx, double dy);
+ virtual double area(void) const = 0;
+ virtual double perimeter(void) const = 0;
+ static int nshapes;
+};
+
+class Circle : public Shape {
+private:
+ double radius;
+public:
+ Circle(double r) : radius(r) { };
+ virtual double area(void) const;
+ virtual double perimeter(void) const;
+};
+
+class Square : public Shape {
+private:
+ double width;
+public:
+ Square(double w) : width(w) { };
+ virtual double area(void) const;
+ virtual double perimeter(void) const;
+};
+
+/* Typedef */
+typedef double (Shape::*PerimeterFunc_td)(void) const;
+
+extern double do_op(Shape *s, double (Shape::*m)(void) const);
+extern double do_op_td(Shape *s, PerimeterFunc_td m);
+
+/* Functions that return member pointers */
+
+extern double (Shape::*areapt())(void) const;
+extern double (Shape::*perimeterpt())(void) const;
+extern PerimeterFunc_td perimeterpt_td();
+
+/* Global variables that are member pointers */
+extern double (Shape::*areavar)(void) const;
+extern double (Shape::*perimetervar)(void) const;
+extern PerimeterFunc_td perimetervar_td;
+%}
+
+%{
+# define SWIG_M_PI 3.14159265358979323846
+
+/* Move the shape to a new location */
+void Shape::move(double dx, double dy) {
+ x += dx;
+ y += dy;
+}
+
+int Shape::nshapes = 0;
+
+double Circle::area(void) const {
+ return SWIG_M_PI*radius*radius;
+}
+
+double Circle::perimeter(void) const {
+ return 2*SWIG_M_PI*radius;
+}
+
+double Square::area(void) const {
+ return width*width;
+}
+
+double Square::perimeter(void) const {
+ return 4*width;
+}
+
+double do_op(Shape *s, double (Shape::*m)(void) const) {
+ return (s->*m)();
+}
+
+double do_op_td(Shape *s, PerimeterFunc_td m) {
+ return (s->*m)();
+}
+
+double (Shape::*areapt())(void) const {
+ return &Shape::area;
+}
+
+double (Shape::*perimeterpt())(void) const {
+ return &Shape::perimeter;
+}
+
+PerimeterFunc_td perimeterpt_td() {
+ return &Shape::perimeter;
+}
+
+/* Member pointer variables */
+double (Shape::*areavar)(void) const = &Shape::area;
+double (Shape::*perimetervar)(void) const = &Shape::perimeter;
+PerimeterFunc_td perimetervar_td = &Shape::perimeter;
+%}
+
+
+/* Some constants */
+%constant double (Shape::*AREAPT)(void) const = &Shape::area;
+%constant double (Shape::*PERIMPT)(void) const = &Shape::perimeter;
+%constant double (Shape::*NULLPT)(void) const = 0;
+
+/*
+%inline %{
+ struct Funktions {
+ void retByRef(int & (*d)(double)) {}
+ };
+ void byRef(int & (Funktions::*d)(double)) {}
+%}
+*/
+
+%inline %{
+
+struct Funktions {
+ int addByValue(const int &a, int b) const { return a+b; }
+ int * addByPointer(const int &a, int b) const { static int val; val = a+b; return &val; }
+ int & addByReference(const int &a, int b) const { static int val; val = a+b; return val; }
+};
+
+int call1(int (Funktions::*d)(const int &, int) const, int a, int b) { Funktions f; return (f.*d)(a, b); }
+//int call2(int * (Funktions::*d)(const int &, int) const, int a, int b) { Funktions f; return *(f.*d)(a, b); }
+//int call3(int & (Funktions::*d)(const int &, int) const, int a, int b) { Funktions f; return (f.*d)(a, b); }
+%}
+
+%constant int (Funktions::*ADD_BY_VALUE)(const int &, int) const = &Funktions::addByValue;
+//%constant int * (Funktions::*ADD_BY_POINTER)(const int &, int) const = &Funktions::addByPointer;
+//%constant int & (Funktions::*ADD_BY_REFERENCE)(const int &, int) const = &Funktions::addByReference;
diff --git a/Examples/test-suite/minherit2.i b/Examples/test-suite/minherit2.i
index 7d470d30e..2baea6495 100644
--- a/Examples/test-suite/minherit2.i
+++ b/Examples/test-suite/minherit2.i
@@ -17,8 +17,8 @@
#if defined(SWIGCSHARP)
#define javaclassmodifiers csclassmodifiers
#define javabody csbody
-#define javafinalize csfinalize
-#define javadestruct csdestruct
+#define javafinalize csdispose
+#define javadestruct csdisposing
#define javaout csout
#define javainterfaces csinterfaces
#define javabase csbase
diff --git a/Examples/test-suite/multiple_inheritance_interfaces.i b/Examples/test-suite/multiple_inheritance_interfaces.i
index 2972922fb..98ec37b4f 100644
--- a/Examples/test-suite/multiple_inheritance_interfaces.i
+++ b/Examples/test-suite/multiple_inheritance_interfaces.i
@@ -64,3 +64,32 @@ struct DerivedOverloaded : public BaseOverloaded {
virtual void identical_overload(int i, const PTypedef &p = PTypedef()) {}
};
%}
+
+
+#if defined(SWIGJAVA) || defined(SWIGCSHARP)
+%interface(Space::X)
+#endif
+
+// Test the csinterfacemodifiers and javainterfacemodifiers typemaps.
+#if defined(SWIGCSHARP)
+/* change access from default "public class" to "internal class" */
+%typemap(csclassmodifiers) InternalAccess "internal class"
+/* The following modifiers are also needed with the above access modifier change */
+%typemap(csclassmodifiers) Space::X "internal class"
+%typemap(csinterfacemodifiers) Space::X "internal interface"
+#elif defined(SWIGJAVA)
+%typemap(javaclassmodifiers) InternalAccess "final /*notpublic*/ class"
+%typemap(javaclassmodifiers) Space::X "final class"
+%typemap(javainterfacemodifiers) Space::X "/*notpublic*/ interface"
+#endif
+
+%inline %{
+struct InternalAccess {};
+namespace Space {
+ class X {
+ public:
+ virtual void x(const InternalAccess& date) const = 0;
+ virtual ~X() {}
+ };
+}
+%}
diff --git a/Examples/test-suite/multiple_inheritance_shared_ptr.i b/Examples/test-suite/multiple_inheritance_shared_ptr.i
index 5a08e5e6e..3c061e1a9 100644
--- a/Examples/test-suite/multiple_inheritance_shared_ptr.i
+++ b/Examples/test-suite/multiple_inheritance_shared_ptr.i
@@ -50,9 +50,9 @@
%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)
+SWIG_SHARED_PTR_INTERFACE_TYPEMAPS(, Space::ABase1)
+SWIG_SHARED_PTR_INTERFACE_TYPEMAPS(, Space::CBase1)
+SWIG_SHARED_PTR_INTERFACE_TYPEMAPS(, Space::CBase2)
%interface_impl(Space::ABase1)
%interface_impl(Space::CBase1)
%interface_impl(Space::CBase2)
diff --git a/Examples/test-suite/multivalue.i b/Examples/test-suite/multivalue.i
index 59f3d7643..3bc3471a1 100644
--- a/Examples/test-suite/multivalue.i
+++ b/Examples/test-suite/multivalue.i
@@ -11,14 +11,14 @@ back to this behavior, use: */
void divide_l(int a, int b, int *OUTPUT, int *OUTPUT);
-/* Multiple values as vectors. By issueing: */
+/* Multiple values as vectors. By issuing: */
%values_as_vector;
/* vectors instead of lists will be used. */
void divide_v(int a, int b, int *OUTPUT, int *OUTPUT);
/* Multiple values for multiple-value continuations.
- (This is the most elegant way.) By issueing: */
+ (This is the most elegant way.) By issuing: */
%multiple_values;
/* multiple values are passed to the multiple-value
continuation, as created by `call-with-values' or the
@@ -26,6 +26,11 @@ void divide_v(int a, int b, int *OUTPUT, int *OUTPUT);
void divide_mv(int a, int b, int *OUTPUT, int *OUTPUT);
+#else
+%include "typemaps.i"
+void divide_l(int a, int b, int *OUTPUT, int *OUTPUT);
+void divide_v(int a, int b, int *OUTPUT, int *OUTPUT);
+void divide_mv(int a, int b, int *OUTPUT, int *OUTPUT);
#endif
%{
@@ -49,4 +54,3 @@ void divide_mv(int a, int b, int *quotient_p, int *remainder_p)
}
%}
-
diff --git a/Examples/test-suite/mzscheme/Makefile.in b/Examples/test-suite/mzscheme/Makefile.in
index 3e15f8610..6a8ef74e4 100644
--- a/Examples/test-suite/mzscheme/Makefile.in
+++ b/Examples/test-suite/mzscheme/Makefile.in
@@ -10,10 +10,70 @@ srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
+FAILING_CPP_TESTS = \
+allowexcept \
+apply_strings \
+arrays_dimensionless \
+arrays_global \
+char_strings \
+chartest \
+class_scope_weird \
+constant_pointers \
+cpp_basic \
+cpp_enum \
+curiously_recurring_template_pattern \
+default_arg_expressions \
+default_constructor \
+derived_nested \
+director_ignore \
+enum_thorough \
+extend \
+friends \
+global_scope_types \
+inherit_member \
+li_attribute \
+li_attribute_template \
+li_boost_shared_ptr \
+li_std_combinations \
+li_std_map \
+li_std_pair \
+li_std_pair_using \
+li_std_string \
+li_std_vector \
+li_windows \
+member_funcptr_galore \
+member_pointer \
+member_pointer_const \
+memberin_extend \
+namespace_spaces \
+naturalvar \
+naturalvar_more \
+nested_class \
+nested_template_base \
+ordering \
+preproc_constants \
+samename \
+static_const_member \
+string_constants \
+template_default2 \
+template_specialization_defarg \
+template_typemaps \
+typemap_variables \
+valuewrapper_opaque \
+
+FAILING_C_TESTS = \
+enums \
+integers \
+preproc_constants_c \
+preproc_line_file \
+
+FAILING_MULTI_CPP_TESTS = \
+multi_import \
+
include $(srcdir)/../common.mk
# Overridden variables here
-# none!
+SWIGOPT += -w524 # Suppress SWIGWARN_LANG_EXPERIMENTAL warning
# Custom tests - tests with additional commandline options
# none!
diff --git a/Examples/test-suite/mzscheme/name_runme.scm b/Examples/test-suite/mzscheme/name_runme.scm
index 1782c6481..94df9131d 100644
--- a/Examples/test-suite/mzscheme/name_runme.scm
+++ b/Examples/test-suite/mzscheme/name_runme.scm
@@ -1,7 +1,7 @@
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
;; Guile modules (namespaces) but simply put all the bindings into the
;; current module. That's enough for such a simple test.
-(load-extension "./name.so")
+(load-extension "name.so")
(foo-2)
bar-2
diff --git a/Examples/test-suite/mzscheme/unions_runme.scm b/Examples/test-suite/mzscheme/unions_runme.scm
index c44847cfc..1c39cb94c 100644
--- a/Examples/test-suite/mzscheme/unions_runme.scm
+++ b/Examples/test-suite/mzscheme/unions_runme.scm
@@ -25,13 +25,15 @@
(if (not (= Jill1 200))
(begin
(display "Runtime test 1 failed.")
- (exit 1))))
+ (exit 1))
+ (void)))
(let ((Num1 (EmbeddedUnionTest-number-get eut)))
(if (not (= Num1 1))
(begin
(display "Runtime test 2 failed.")
- (exit 1))))
+ (exit 1))
+ (void)))
;; that should do
diff --git a/Examples/test-suite/name_warnings.i b/Examples/test-suite/name_warnings.i
index 3455c03bf..0b62ec5d7 100644
--- a/Examples/test-suite/name_warnings.i
+++ b/Examples/test-suite/name_warnings.i
@@ -40,9 +40,7 @@ namespace std
#endif
virtual ~A() {}
-#ifndef SWIGGO // func is a keyword in Go.
- virtual int func() = 0;
-#endif
+ virtual int funk() = 0;
private:
typedef complex False;
};
diff --git a/Examples/test-suite/namespace_chase.i b/Examples/test-suite/namespace_chase.i
new file mode 100644
index 000000000..5e3921d0d
--- /dev/null
+++ b/Examples/test-suite/namespace_chase.i
@@ -0,0 +1,36 @@
+%module namespace_chase
+
+%inline %{
+ namespace Space1A {
+ struct Struct1A {};
+ namespace Space1B {
+ struct Struct1B {};
+ namespace Space1C {
+ struct Struct1C {};
+ }
+ }
+ }
+ namespace Space2A {
+ using namespace Space1A;
+ namespace Space2B {
+ using namespace Space1B;
+ namespace Space2C {
+ using namespace Space1C;
+ }
+ }
+ }
+ namespace Space3 {
+ using namespace Space2A;
+ void sss3a(Space1A::Struct1A, Space1A::Space1B::Struct1B, Space1A::Space1B::Space1C::Struct1C) {}
+ void sss3b(Struct1A, Space1B::Struct1B, Space1B::Space1C::Struct1C) {}
+ // To fix: the last two parameters below fail and result in SWIGTYPE_ types instead of proxy classes
+ void sss3c(Space2A::Struct1A, Space2A::Space1B::Struct1B, Space2A::Space1B::Space1C::Struct1C) {}
+ }
+ namespace Space4 {
+ using namespace Space2A;
+ using namespace Space2A::Space2B;
+ using namespace Space2A::Space2B::Space2C;
+ void sss4a(Struct1A, Struct1B, Space2C::Struct1C) {}
+ void sss4b(Struct1A, Struct1B, Struct1C) {}
+ }
+%}
diff --git a/Examples/test-suite/namespace_template.i b/Examples/test-suite/namespace_template.i
index a36abb19b..8a4b6dca9 100644
--- a/Examples/test-suite/namespace_template.i
+++ b/Examples/test-suite/namespace_template.i
@@ -2,10 +2,10 @@
%module namespace_template
-%warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector<int>; /* Ruby, wrong class name */
-%warnfilter(SWIGWARN_RUBY_WRONG_NAME) test2::vector<short>; /* Ruby, wrong class name */
-%warnfilter(SWIGWARN_RUBY_WRONG_NAME) test3::vector<long>; /* Ruby, wrong class name */
-%warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector<test4::Integer>; /* Ruby, wrong class name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) test::vector<int>; /* Ruby, wrong class name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) test::vector<short>; /* Ruby, wrong class name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) test::vector<long>; /* Ruby, wrong class name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) test::vector<test::Char>; /* Ruby, wrong class name */
%{
#ifdef max
@@ -23,20 +23,9 @@ namespace test {
char * blah(T x) {
return (char *) "vector::blah";
}
+ void vectoruse(vector<T> a, test::vector<T> b) {}
};
}
-
-namespace test2 {
- using namespace test;
-}
-
-namespace test3 {
- using test::max;
- using test::vector;
-}
-
-using namespace test2;
-namespace T4 = test;
%}
namespace test {
@@ -48,6 +37,7 @@ namespace test {
char * blah(T x) {
return (char *) "vector::blah";
}
+ void vectoruse(vector<T> a, test::vector<T> b) {}
};
}
@@ -55,30 +45,26 @@ using namespace test;
%template(maxint) max<int>;
%template(vectorint) vector<int>;
-namespace test2 {
- using namespace test;
+namespace test {
%template(maxshort) max<short>;
%template(vectorshort) vector<short>;
}
-namespace test3 {
- using test::max;
- using test::vector;
+namespace test {
%template(maxlong) max<long>;
%template(vectorlong) vector<long>;
}
%inline %{
-namespace test4 {
- using namespace test;
- typedef int Integer;
+namespace test {
+ typedef char Char;
}
%}
-namespace test4 {
- %template(maxInteger) max<Integer>;
- %template(vectorInteger) vector<Integer>;
+namespace test {
+ %template(maxchar) max<Char>;
+ %template(vectorchar) vector<Char>;
}
diff --git a/Examples/test-suite/native_directive.i b/Examples/test-suite/native_directive.i
new file mode 100644
index 000000000..3d4858032
--- /dev/null
+++ b/Examples/test-suite/native_directive.i
@@ -0,0 +1,102 @@
+%module native_directive
+
+%{
+#include <ctype.h>
+int alpha_count(const char *instring) {
+ int count = 0;
+ const char *s = instring;
+ while (s && *s) {
+ if (isalpha((int)*s))
+ count++;
+ s++;
+ };
+ return count;
+}
+%}
+
+%inline %{
+int CountAlphas(const char *instring) {
+ return alpha_count(instring);
+}
+%}
+
+// Languages that support %native should code up language specific implementations below
+
+#if defined(SWIGJAVA)
+%native(CountAlphaCharacters) int alpha_count(const char *inputString);
+%{
+extern "C" JNIEXPORT jint JNICALL Java_native_1directive_native_1directiveJNI_CountAlphaCharacters(JNIEnv *jenv, jclass jcls, jstring instring) {
+ jint jresult = 0 ;
+ (void)jcls;
+
+ if (instring) {
+ const char *s = (char *)jenv->GetStringUTFChars(instring, 0);
+ if (s) {
+ jresult = (jint)alpha_count(s);
+ jenv->ReleaseStringUTFChars(instring, s);
+ }
+ }
+ return jresult;
+}
+%}
+#endif
+
+
+// TODO: C#
+// TODO: Python
+
+
+#ifdef SWIGJAVASCRIPT
+%native(CountAlphaCharacters) void JavaScript_alpha_count();
+%{
+#ifdef SWIG_V8_VERSION /* engine = node || v8 */
+
+static SwigV8ReturnValue JavaScript_alpha_count(const SwigV8Arguments &args) {
+ SWIGV8_HANDLESCOPE();
+ SWIGV8_VALUE jsresult;
+ char *arg1 = (char *)0;
+ int res1;
+ char *buf1 = 0;
+ int alloc1 = 0;
+ int result;
+ if(args.Length() != 1) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for _wrap_alpha_count.");
+ res1 = SWIG_AsCharPtrAndSize(args[0], &buf1, NULL, &alloc1);
+ if (!SWIG_IsOK(res1))
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "alpha_count" "', argument " "1"" of type '" "char const *""'");
+ arg1 = reinterpret_cast< char * >(buf1);
+ result = (int)alpha_count((char const *)arg1);
+ jsresult = SWIG_From_int(static_cast< int >(result));
+ if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
+ SWIGV8_RETURN(jsresult);
+fail:
+ SWIGV8_RETURN(SWIGV8_UNDEFINED());
+}
+
+#else /* engine = jsc */
+
+static JSValueRef JavaScript_alpha_count(JSContextRef context, JSObjectRef function,
+ JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
+{
+ char *arg1 = (char *)0;
+ int res1;
+ char *buf1 = 0;
+ int alloc1 = 0;
+ int result;
+ JSValueRef jsresult;
+ if (argc != 1) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments.");
+ res1 = SWIG_JSC_AsCharPtrAndSize(context, argv[0], &buf1, NULL, &alloc1);
+ if (!SWIG_IsOK(res1))
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "alpha_count" "', argument " "1"" of type '" "char const *""'");
+ arg1 = reinterpret_cast< char * >(buf1);
+ result = (int)alpha_count((char const *)arg1);
+ jsresult = SWIG_From_int SWIG_JSC_FROM_CALL_ARGS(static_cast< int >(result));
+ if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
+ return jsresult;
+fail:
+ return JSValueMakeUndefined(context);
+}
+
+#endif /* engine */
+%}
+#endif /* SWIGJAVASCRIPT */
+
diff --git a/Examples/test-suite/nested.i b/Examples/test-suite/nested.i
index 216ee4224..6c4ffe34a 100644
--- a/Examples/test-suite/nested.i
+++ b/Examples/test-suite/nested.i
@@ -44,42 +44,6 @@ struct OuterStructNamed {
%}
-#if !defined(SWIGSCILAB)
-
-%inline %{
-
-struct OuterStructUnnamed {
- struct {
- double xx;
- } inner_struct_unnamed;
- union {
- double yy;
- int zz;
- } inner_union_unnamed;
-};
-
-typedef struct OuterStruct {
- union {
-
- struct outer_nested_struct {
- union inner_nested_union {
-#define BAD_STYLE 1
- int red;
- struct TestStruct green;
- } InnerNestedUnion;
-
- struct inner_nested_struct {
- int blue;
- } InnerNestedStruct;
- } OuterNestedStruct;
-
- } EmbeddedUnion;
-} OuterStruct;
-
-%}
-
-#else
-
%inline %{
struct OutStUnnamed {
@@ -112,6 +76,51 @@ typedef struct OutSt {
%}
-#endif
+%inline %{
+ typedef struct {
+ union x_union {
+ int x;
+ } duplicate_p;
+ } x_t;
+
+ typedef struct {
+ union y_union {
+ int y;
+ } duplicate_p;
+ } y_t;
+
+ typedef struct A {
+ union a_union {
+ int a;
+ } duplicate_p;
+ } a_t;
+
+ typedef struct B {
+ union b_union {
+ int b;
+ } duplicate_p;
+ } b_t;
+
+ typedef struct {
+ union {
+ int c;
+ } duplicate_p;
+ } c_t;
+
+ typedef struct {
+ union {
+ int d;
+ } duplicate_p;
+ } d_t;
+
+ void set_union_values(int startval, x_t *x, y_t *y, a_t *a, b_t *b, c_t *c, d_t *d) {
+ x->duplicate_p.x = startval++;
+ y->duplicate_p.y = startval++;
+ a->duplicate_p.a = startval++;
+ b->duplicate_p.b = startval++;
+ c->duplicate_p.c = startval++;
+ d->duplicate_p.d = startval++;
+ }
+%}
diff --git a/Examples/test-suite/nested_in_template.i b/Examples/test-suite/nested_in_template.i
new file mode 100644
index 000000000..81d5b6289
--- /dev/null
+++ b/Examples/test-suite/nested_in_template.i
@@ -0,0 +1,34 @@
+%module nested_in_template
+
+#if !defined(SWIGCSHARP) && !defined(SWIGJAVA)
+%feature("flatnested");
+#endif
+
+%inline %{
+template <int>
+struct OuterTemplate;
+
+template <>
+struct OuterTemplate<1>
+{
+ struct AbstractBase
+ {
+ virtual bool IsSameAs(const AbstractBase& other) const = 0;
+ virtual ~AbstractBase() {}
+ };
+
+ struct ConcreteDerived : AbstractBase
+ {
+ ConcreteDerived() : m_value(0) {}
+ explicit ConcreteDerived(int value) : m_value(value) {}
+
+ virtual bool IsSameAs(const AbstractBase& other) const {
+ return m_value == static_cast<const ConcreteDerived&>(other).m_value;
+ }
+
+ int m_value;
+ };
+};
+%}
+
+%template(OuterTemplate1) OuterTemplate<1>;
diff --git a/Examples/test-suite/nested_inheritance_interface.i b/Examples/test-suite/nested_inheritance_interface.i
new file mode 100644
index 000000000..f8335c0af
--- /dev/null
+++ b/Examples/test-suite/nested_inheritance_interface.i
@@ -0,0 +1,20 @@
+%module nested_inheritance_interface
+
+%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(IA)
+#endif
+
+#if !defined(SWIGCSHARP) && !defined(SWIGJAVA)
+%feature ("flatnested");
+#endif
+
+
+%inline %{
+struct IA {};
+struct B { struct N : IA {}; };
+%}
diff --git a/Examples/test-suite/nested_structs.i b/Examples/test-suite/nested_structs.i
index c70924958..48bd9f2b9 100644
--- a/Examples/test-suite/nested_structs.i
+++ b/Examples/test-suite/nested_structs.i
@@ -12,6 +12,10 @@
#endif
+#ifdef SWIGOCAML
+%warnfilter(SWIGWARN_PARSE_KEYWORD) val;
+#endif
+
// bug #491476
%inline %{
struct Outer {
diff --git a/Examples/test-suite/nested_template_base.i b/Examples/test-suite/nested_template_base.i
index 0b0272224..4d99e8af5 100644
--- a/Examples/test-suite/nested_template_base.i
+++ b/Examples/test-suite/nested_template_base.i
@@ -1,5 +1,9 @@
%module nested_template_base
+#ifdef SWIGOCAML
+%warnfilter(SWIGWARN_PARSE_KEYWORD) val;
+#endif
+
%inline %{
template <class T> class OuterT {
public:
diff --git a/Examples/test-suite/newobject3.i b/Examples/test-suite/newobject3.i
new file mode 100644
index 000000000..ef12cd401
--- /dev/null
+++ b/Examples/test-suite/newobject3.i
@@ -0,0 +1,25 @@
+/**
+ * Regression test for PHP bug: https://sourceforge.net/p/swig/bugs/1350/
+ */
+
+%module newobject3
+
+%newobject factory::create;
+%inline %{
+class Product {};
+class factory {
+public:
+ Product * create(short id, short type = 0);
+ Product * create(const char * name, short type = 0);
+};
+%}
+
+%{
+Product * factory::create(short id, short type) {
+ return (id && type >= 0) ? new Product : NULL;
+}
+
+Product * factory::create(const char * name, short type) {
+ return (name && type >= 0) ? new Product : NULL;
+}
+%}
diff --git a/Examples/test-suite/not_c_keywords.i b/Examples/test-suite/not_c_keywords.i
new file mode 100644
index 000000000..013575bc6
--- /dev/null
+++ b/Examples/test-suite/not_c_keywords.i
@@ -0,0 +1,13 @@
+%module not_c_keywords
+
+%extend ComplexStruct {
+void init() {
+ $self->complex = 123;
+}
+}
+
+%inline %{
+struct ComplexStruct {
+ int complex; /* complex as variable name */
+};
+%}
diff --git a/Examples/test-suite/null_pointer.i b/Examples/test-suite/null_pointer.i
index 0da827f99..f40d6929f 100644
--- a/Examples/test-suite/null_pointer.i
+++ b/Examples/test-suite/null_pointer.i
@@ -1,11 +1,9 @@
%module null_pointer
-%warnfilter(SWIGWARN_PARSE_KEYWORD) func; // 'func' is a Go keyword, renamed as 'Xfunc'
-
%inline {
struct A {};
- bool func(A* a) {
+ bool funk(A* a) {
return !a;
}
diff --git a/Examples/test-suite/ocaml/Makefile.in b/Examples/test-suite/ocaml/Makefile.in
index ecdf32e9f..c44f02a72 100644
--- a/Examples/test-suite/ocaml/Makefile.in
+++ b/Examples/test-suite/ocaml/Makefile.in
@@ -3,7 +3,9 @@
#######################################################################
LANGUAGE = ocaml
-OCAMLC = @OCAMLC@
+OCAMLP4WHERE =`$(COMPILETOOL) @CAMLP4@ -where`
+OCC =$(COMPILETOOL) @OCAMLC@
+OCAMLPP = -pp "camlp4o ./swigp4.cmo"
VARIANT = _static
SCRIPTSUFFIX = _runme.ml
@@ -11,67 +13,99 @@ srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
-C_TEST_CASES =
+FAILING_CPP_TESTS = \
+allprotected \
+apply_signed_char \
+apply_strings \
+cpp_enum \
+default_constructor \
+director_binary_string \
+director_comparison_operators \
+director_enum \
+director_primitives \
+director_redefined \
+director_string \
+enum_thorough \
+li_windows \
+member_pointer_const \
+preproc_constants \
+smart_pointer_inherit \
+
+FAILING_C_TESTS = \
+enums \
+preproc_constants_c \
+
+CPP_TEST_CASES += \
+ inout \
+
+C_TEST_CASES += \
+ multivalue \
+
+ml_runme = $(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)
run_testcase = \
- if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) -a \
- -f $(top_srcdir)/Examples/test-suite/$*.list ] ; then \
- $(COMPILETOOL) $(OCAMLC) -c $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
- $(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme `cat $(top_srcdir)/Examples/test-suite/$(*).list | sed -e 's/\(.*\)/\1_wrap.o \1.cmo/g'`&& $(RUNTOOL) ./runme; \
- elif [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
- $(COMPILETOOL) $(OCAMLC) -c $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
- $(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme $(srcdir)/$(*).cmo $(srcdir)/$(*)_runme.cmo $(srcdir)/$(*)_wrap.o && \
- $(RUNTOOL) ./runme; \
+ if [ -f $(srcdir)/$(ml_runme) ]; then \
+ if [ $(srcdir) != . ]; then \
+ cp $(srcdir)/$(ml_runme) $(ml_runme); \
+ fi ; \
+ $(OCC) $(OCAMLPP) -c $(ml_runme) && \
+ if [ -f $(top_srcdir)/Examples/test-suite/$*.list ]; then \
+ $(OCC) swig.cmo -custom -g -cc '$(CXX)' -o $*_runme `cat $(top_srcdir)/Examples/test-suite/$(*).list | sed -e 's/\(.*\)/\1_wrap.o \1.cmo/g'`&& $(RUNTOOL) ./$*_runme; \
+ else \
+ $(OCC) swig.cmo -custom -g -cc '$(CXX)' -o $*_runme $(*).cmo $(*)_runme.cmo $(*)_wrap.o && $(RUNTOOL) ./$*_runme; \
+ fi ; \
fi ;
-check_quant:
- : > testing
- : > success
- $(MAKE) check
- echo "Failed:" > results
- diff testing success | sed 's/^< //p;d' >> results
- echo "Success:" >> results
- cat success >> results
-
include $(srcdir)/../common.mk
# Overridden variables here
-# none!
+SWIGOPT += -w524 # Suppress SWIGWARN_LANG_EXPERIMENTAL warning
# Custom tests - tests with additional commandline options
# none!
# Rules for the different types of tests
%.cpptest:
- echo $@ >> testing
$(setup)
+$(swig_and_compile_cpp)
$(run_testcase)
- if [ -f $(@:%.cpptest=%_wrap.o) ] ; then \
- echo $@ >> success ; \
- fi
%.ctest:
- echo $@ >> testing
$(setup)
+$(swig_and_compile_c)
$(run_testcase)
- if [ -f $(@:%.ctest=%_wrap.o) ] ; then \
- echo $@ >> success ; \
- fi
%.multicpptest:
- echo $@ >> testing
+$(swig_and_compile_multi_cpp)
$(setup)
$(run_testcase)
- if [ -f $(@:%.multicpptest=%_runtime_wrap.o) ] ; then \
- echo $@ >> success ; \
- fi
+
+swig.cmi:
+ env SWIG_LIB=$(SWIG_LIB_DIR) $(SWIGEXE) -ocaml -co swig.mli
+ $(OCC) -c swig.mli
+swig.cmo:
+ env SWIG_LIB=$(SWIG_LIB_DIR) $(SWIGEXE) -ocaml -co swig.ml
+ $(OCC) -c swig.ml
+swigp4.cmi:
+ env SWIG_LIB=$(SWIG_LIB_DIR) $(SWIGEXE) -ocaml -co swigp4.ml
+ $(OCC) -I $(OCAMLP4WHERE) -pp "camlp4o pa_extend.cmo q_MLast.cmo" -c swigp4.ml
+extra_objects: swig.cmi swig.cmo swigp4.cmi
+
+$(C_TEST_CASES:=.ctest): extra_objects
+$(CPP_TEST_CASES:=.cpptest): extra_objects
+$(MULTI_CPP_TEST_CASES:=.multicpptest): extra_objects
# Clean
%.clean:
- @rm -f $*.ml $*.mli;
+ @rm -f $*.ml $*.mli $*_runme;
+ @if test $(srcdir) != .; then rm -f $(ml_runme); fi
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' ocaml_clean
+ rm -f clientdata_prop_a.ml clientdata_prop_b.ml
+ rm -f import_stl_a.ml import_stl_b.ml
+ rm -f imports_a.ml imports_b.ml
+ rm -f mod_a.ml mod_b.ml
+ rm -f multi_import_a.ml multi_import_b.ml
+ rm -f packageoption_a.ml packageoption_b.ml packageoption_c.ml
+ rm -f template_typedef_cplx2.ml
diff --git a/Examples/test-suite/ocaml/abstract_access_runme.ml b/Examples/test-suite/ocaml/abstract_access_runme.ml
new file mode 100644
index 000000000..77ad88667
--- /dev/null
+++ b/Examples/test-suite/ocaml/abstract_access_runme.ml
@@ -0,0 +1,5 @@
+open Swig
+open Abstract_access
+
+let d = new_D '()
+let _ = assert ((d -> "do_x" () as int) = 1)
diff --git a/Examples/test-suite/ocaml/abstract_typedef2_runme.ml b/Examples/test-suite/ocaml/abstract_typedef2_runme.ml
new file mode 100644
index 000000000..64aa19b91
--- /dev/null
+++ b/Examples/test-suite/ocaml/abstract_typedef2_runme.ml
@@ -0,0 +1,4 @@
+open Swig
+open Abstract_typedef2
+
+let a = new_A_UF '()
diff --git a/Examples/test-suite/ocaml/abstract_typedef_runme.ml b/Examples/test-suite/ocaml/abstract_typedef_runme.ml
new file mode 100644
index 000000000..728c25b3b
--- /dev/null
+++ b/Examples/test-suite/ocaml/abstract_typedef_runme.ml
@@ -0,0 +1,6 @@
+open Swig
+open Abstract_typedef
+
+let e = new_Engine '()
+let a = new_A '()
+let _ = assert ((a -> "write" (e) as bool) = true)
diff --git a/Examples/test-suite/ocaml/abstract_virtual_runme.ml b/Examples/test-suite/ocaml/abstract_virtual_runme.ml
new file mode 100644
index 000000000..60f4f4ab7
--- /dev/null
+++ b/Examples/test-suite/ocaml/abstract_virtual_runme.ml
@@ -0,0 +1,5 @@
+open Swig
+open Abstract_virtual
+
+let d = new_D '()
+let e = new_E '()
diff --git a/Examples/test-suite/ocaml/aggregate_runme.ml b/Examples/test-suite/ocaml/aggregate_runme.ml
new file mode 100644
index 000000000..f8fff0f30
--- /dev/null
+++ b/Examples/test-suite/ocaml/aggregate_runme.ml
@@ -0,0 +1,15 @@
+open Swig
+open Aggregate
+
+let _ =
+ assert((_move (_UP '()) as int) = (_UP '() as int));
+ assert((_move (_DOWN '()) as int) = (_DOWN '() as int));
+ assert((_move (_LEFT '()) as int) = (_LEFT '() as int));
+ assert((_move (_RIGHT '()) as int) = (_RIGHT '() as int));
+;;
+
+let _ =
+ try
+ _move(0 to int)
+ with Failure _ -> exit 0
+let _ = raise (Failure "0 test failed")
diff --git a/Examples/test-suite/ocaml/allowexcept_runme.ml b/Examples/test-suite/ocaml/allowexcept_runme.ml
new file mode 100644
index 000000000..9c8c9de7f
--- /dev/null
+++ b/Examples/test-suite/ocaml/allowexcept_runme.ml
@@ -0,0 +1,7 @@
+open Swig
+open Allowexcept
+
+let _ =
+ assert (_global_variable '() = C_void);
+ assert (_Foo_static_member_variable '() = C_void)
+;;
diff --git a/Examples/test-suite/ocaml/cast_operator_runme.ml b/Examples/test-suite/ocaml/cast_operator_runme.ml
new file mode 100644
index 000000000..99c390a19
--- /dev/null
+++ b/Examples/test-suite/ocaml/cast_operator_runme.ml
@@ -0,0 +1,5 @@
+open Swig
+open Cast_operator
+
+let a = new_A '()
+let _ = assert ((a -> "tochar" () as string) = "hi")
diff --git a/Examples/test-suite/ocaml/catches_runme.ml b/Examples/test-suite/ocaml/catches_runme.ml
new file mode 100644
index 000000000..ab38e635d
--- /dev/null
+++ b/Examples/test-suite/ocaml/catches_runme.ml
@@ -0,0 +1,39 @@
+open Swig
+open Catches
+
+let _ =
+ try
+ ignore (_test_catches '(1)); assert false
+ with Failure s ->
+ assert (s = "C++ int exception thrown, value: 1")
+
+ try
+ ignore (_test_catches '(2)); assert false
+ with Failure s ->
+ assert (s = "two")
+
+ try
+ ignore (_test_catches '(3)); assert false
+ with Failure s ->
+ assert (s = "C++ ThreeException const & exception thrown")
+
+ try
+ ignore (_test_exception_specification '(1)); assert false
+ with Failure s ->
+ assert (s = "C++ int exception thrown, value: 1")
+
+ try
+ ignore (_test_exception_specification '(2)); assert false
+ with Failure s ->
+ assert (s = "unknown exception")
+
+ try
+ ignore (_test_exception_specification '(3)); assert false
+ with Failure s ->
+ assert (s = "unknown exception")
+
+ try
+ ignore (_test_catches_all '(1)); assert false
+ with Failure s ->
+ assert (s = "unknown exception")
+;;
diff --git a/Examples/test-suite/ocaml/char_binary_runme.ml b/Examples/test-suite/ocaml/char_binary_runme.ml
new file mode 100644
index 000000000..2d3aba1b3
--- /dev/null
+++ b/Examples/test-suite/ocaml/char_binary_runme.ml
@@ -0,0 +1,24 @@
+open Swig
+open Char_binary
+
+let _ =
+ let t = new_Test '() in
+ assert (t -> strlen ("hile") as int = 4);
+ assert (t -> ustrlen ("hile") as int = 4);
+ assert (t -> strlen ("hil\x00") as int = 4);
+ assert (t -> ustrlen ("hil\x00") as int = 4);
+
+ let pc = _new_pchar '(5) in
+ assert (_pchar_setitem '(pc, 0, 'h') = C_void);
+ assert (_pchar_setitem '(pc, 1, 'o') = C_void);
+ assert (_pchar_setitem '(pc, 2, 'l') = C_void);
+ assert (_pchar_setitem '(pc, 3, 'a') = C_void);
+ assert (_pchar_setitem '(pc, 4, 0) = C_void);
+ assert (t -> strlen (pc) as int = 4);
+ assert (t -> ustrlen (pc) as int = 4);
+ ignore (_var_pchar '(pc));
+ assert (_var_pchar '() as string = "hola");
+ ignore (_var_namet '(pc));
+ assert (_var_namet '() as string = "hola");
+ _delete_pchar(pc)
+;;
diff --git a/Examples/test-suite/ocaml/char_constant_runme.ml b/Examples/test-suite/ocaml/char_constant_runme.ml
new file mode 100644
index 000000000..9d0ce6903
--- /dev/null
+++ b/Examples/test-suite/ocaml/char_constant_runme.ml
@@ -0,0 +1,16 @@
+open Swig
+open Char_constant
+
+let _ =
+ assert (_CHAR_CONSTANT '() as char = 'x');
+ assert (_STRING_CONSTANT '() as string = "xyzzy");
+ assert (_ESC_CONST '() as char = '\x01');
+ assert (_NULL_CONST '() as char = '\x00');
+ assert (_SPECIALCHARA '() as char = 'A');
+ assert (_SPECIALCHARB '() as char = 'B');
+ assert (_SPECIALCHARC '() as char = 'C');
+ assert (_SPECIALCHARD '() as char = 'D');
+ assert (_SPECIALCHARE '() as char = 'E');
+ assert (_ia '() as char = 'a');
+ assert (_ib '() as char = 'b');
+;;
diff --git a/Examples/test-suite/ocaml/chartest_runme.ml b/Examples/test-suite/ocaml/chartest_runme.ml
new file mode 100644
index 000000000..3a2c81d03
--- /dev/null
+++ b/Examples/test-suite/ocaml/chartest_runme.ml
@@ -0,0 +1,25 @@
+open Swig
+open Chartest
+
+let _ =
+ assert (_GetPrintableChar '() as char = 'a');
+ assert (_GetUnprintableChar '() as char = '\127');
+ assert (_printable_global_char '() as char = 'a');
+ assert (_unprintable_global_char '() as char = '\127');
+ assert (_globchar0 '() as char = '\x00');
+ assert (_globchar1 '() as char = '\x01');
+ assert (_globchar2 '() as char = '\n');
+ assert (_globcharA '() as char = 'A');
+ assert (_globcharB '() as char = 'B');
+ assert (_globcharC '() as char = 'C');
+ assert (_globcharD '() as char = 'D');
+ assert (_globcharE '() as char = 'E');
+ assert (_CharTestClass_memberchar0 '() as char = '\x00');
+ assert (_CharTestClass_memberchar1 '() as char = '\x01');
+ assert (_CharTestClass_memberchar2 '() as char = '\n');
+ assert (_CharTestClass_membercharA '() as char = 'A');
+ assert (_CharTestClass_membercharB '() as char = 'B');
+ assert (_CharTestClass_membercharC '() as char = 'C');
+ assert (_CharTestClass_membercharD '() as char = 'D');
+ assert (_CharTestClass_membercharE '() as char = 'E');
+;;
diff --git a/Examples/test-suite/ocaml/class_scope_weird_runme.ml b/Examples/test-suite/ocaml/class_scope_weird_runme.ml
new file mode 100644
index 000000000..de7f457d4
--- /dev/null
+++ b/Examples/test-suite/ocaml/class_scope_weird_runme.ml
@@ -0,0 +1,6 @@
+open Swig
+open Class_scope_weird
+
+let f = new_Foo (C_void)
+let g = new_Foo (C_int 3)
+let _ = assert (get_int ((invoke f) "bar" (C_int 3)) = 3)
diff --git a/Examples/test-suite/ocaml/constover_runme.ml b/Examples/test-suite/ocaml/constover_runme.ml
new file mode 100644
index 000000000..0ca2a5c01
--- /dev/null
+++ b/Examples/test-suite/ocaml/constover_runme.ml
@@ -0,0 +1,16 @@
+open Swig
+open Constover
+
+let test_str = "test" to string
+let _ =
+ assert ((_test (test_str) as string) = "test");
+ assert ((_test_pconst (test_str) as string) = "test_pconst");
+;;
+
+let f = new_Foo '()
+let _ =
+ assert ((f -> "test" (test_str) as string) = "test");
+ assert ((f -> "test_pconst" (test_str) as string) = "test_pconst");
+ assert ((f -> "test_constm" (test_str) as string) = "test_constmethod");
+ assert ((f -> "test_pconstm" (test_str) as string) = "test_pconstmethod");
+;;
diff --git a/Examples/test-suite/ocaml/constructor_rename_runme.ml b/Examples/test-suite/ocaml/constructor_rename_runme.ml
new file mode 100644
index 000000000..5e5553838
--- /dev/null
+++ b/Examples/test-suite/ocaml/constructor_rename_runme.ml
@@ -0,0 +1,5 @@
+open Swig
+open Constructor_rename
+
+let x = new_RenamedConstructor '()
+let _ = assert ((x -> ":classof" () as string) = "Foo")
diff --git a/Examples/test-suite/ocaml/conversion_runme.ml b/Examples/test-suite/ocaml/conversion_runme.ml
new file mode 100644
index 000000000..8e4c19f2d
--- /dev/null
+++ b/Examples/test-suite/ocaml/conversion_runme.ml
@@ -0,0 +1,9 @@
+open Swig
+open Conversion
+
+let _ =
+ let bar = new_Bar '() in
+ assert (bar -> ":classof" () as string = "Bar");
+ let foo = bar -> toFoo () in
+ assert (foo -> ":classof" () as string = "Foo");
+;;
diff --git a/Examples/test-suite/ocaml/cpp_nodefault_runme.ml b/Examples/test-suite/ocaml/cpp_nodefault_runme.ml
new file mode 100644
index 000000000..a0bd84071
--- /dev/null
+++ b/Examples/test-suite/ocaml/cpp_nodefault_runme.ml
@@ -0,0 +1,17 @@
+open Swig
+open Cpp_nodefault
+
+let foo1 = new_Foo '(1, 2)
+let _ = foo1 -> "[a]" (5)
+let _ = assert ((foo1 -> "[a]" () as int) = 5)
+
+let foo2 = _create '(1, 2)
+let _ = _consume '(foo1,foo2)
+
+let bar1 = new_Bar '()
+let gvar = _gvar '()
+let args = (C_list [ gvar ; foo2 ])
+let _ = bar1 -> "consume" (args)
+let foo3 = bar1 -> "create" (1, 2)
+let _ = foo3 -> "[a]" (6)
+let _ = assert ((foo3 -> "[a]" () as int) = 6)
diff --git a/Examples/test-suite/ocaml/cpp_static_runme.ml b/Examples/test-suite/ocaml/cpp_static_runme.ml
new file mode 100644
index 000000000..9b04abced
--- /dev/null
+++ b/Examples/test-suite/ocaml/cpp_static_runme.ml
@@ -0,0 +1,17 @@
+open Swig
+open Cpp_static
+
+let _ = _StaticFunctionTest_static_func (C_void)
+let _ = _StaticFunctionTest_static_func_2 (C_int 1)
+let _ = _StaticFunctionTest_static_func_3 (C_list [C_int 1; C_int 2])
+
+let _ = assert (get_int (_StaticMemberTest_static_int (C_void)) = 99)
+let _ = _StaticMemberTest_static_int (C_int 10)
+let _ = assert (get_int (_StaticMemberTest_static_int (C_void)) = 10)
+
+let _ = assert (get_int (_StaticBase_statty (C_void)) = 11)
+let _ = assert (get_int (_StaticDerived_statty (C_void)) = 111)
+let _ = _StaticBase_statty (C_int 22)
+let _ = _StaticDerived_statty (C_int 222)
+let _ = assert (get_int (_StaticBase_statty (C_void)) = 22)
+let _ = assert (get_int (_StaticDerived_statty (C_void)) = 222)
diff --git a/Examples/test-suite/ocaml/default_arg_values_runme.ml b/Examples/test-suite/ocaml/default_arg_values_runme.ml
new file mode 100644
index 000000000..e9edcb9d9
--- /dev/null
+++ b/Examples/test-suite/ocaml/default_arg_values_runme.ml
@@ -0,0 +1,17 @@
+open Swig
+open Default_arg_values
+
+let _ =
+ let d = new_Display '() in
+ assert (d -> draw1 () as float = 0.);
+ let arg = C_float 12. in
+ assert (d -> draw1 (arg) as float = 12.);
+ let arg = C_float 123. in
+ let p = _createPtr '(arg) in
+ assert (d -> draw2 () as float = 0.);
+ assert (d -> draw2 (p) as float = 123.);
+ assert (d -> bool0 () as bool = false);
+ assert (d -> bool1 () as bool = true);
+ assert (d -> mybool0 () as bool = false);
+ assert (d -> mybool1 () as bool = true)
+;;
diff --git a/Examples/test-suite/ocaml/default_args_runme.ml b/Examples/test-suite/ocaml/default_args_runme.ml
new file mode 100644
index 000000000..1654b011f
--- /dev/null
+++ b/Examples/test-suite/ocaml/default_args_runme.ml
@@ -0,0 +1,58 @@
+open Swig
+open Default_args
+
+let _ =
+ assert (_anonymous '() as int = 7771);
+ assert (_anonymous '(1234) as int = 1234);
+ assert (_booltest '() as bool = true);
+ assert (_booltest '(true) as bool = true);
+ assert (_booltest '(false) as bool = false);
+ let ec = new_EnumClass '() in
+ assert (ec -> blah () as bool = true);
+ let de = new_DerivedEnumClass '() in
+ assert (de -> accelerate () = C_void);
+ let args = _SLOW '() in
+ assert (de -> accelerate (args) = C_void);
+ assert (_Statics_staticmethod '() as int = 60);
+ assert (_cfunc1 '(1) as float = 2.);
+ assert (_cfunc2 '(1) as float = 3.);
+ assert (_cfunc3 '(1) as float = 4.);
+
+ let f = new_Foo '() in
+ assert (f -> newname () = C_void);
+ assert (f -> newname (1) = C_void);
+ (* TODO: There needs to be a more elegant way to pass NULL/nullptr. *)
+ let args = C_list [ C_int 2 ; C_ptr (0L, 0L) ] in
+ assert (f -> double_if_void_ptr_is_null (args) as int = 4);
+ assert (f -> double_if_void_ptr_is_null (3) as int = 6);
+ let args = C_list [ C_int 4 ; C_ptr (0L, 0L) ] in
+ assert (f -> double_if_handle_is_null (args) as int = 8);
+ assert (f -> double_if_handle_is_null (5) as int = 10);
+ let args = C_list [ C_int 6 ; C_ptr (0L, 0L) ] in
+ assert (f -> double_if_dbl_ptr_is_null (args) as int = 12);
+ assert (f -> double_if_dbl_ptr_is_null (7) as int = 14);
+
+ let k = new_Klass '(22) in
+ let k2 = _Klass_inc (C_list [ C_int 100 ; k ]) in
+ assert (k2 -> "[val]" () as int = 122);
+ let k2 = _Klass_inc '(100) in
+ assert (k2 -> "[val]" () as int = 99);
+ let k2 = _Klass_inc '() in
+ assert (k2 -> "[val]" () as int = 0);
+
+ assert (_seek '() = C_void);
+ assert (_seek (C_int64 10L) = C_void);
+
+ assert (_slightly_off_square '(10) as int = 102);
+ assert (_slightly_off_square '() as int = 291);
+
+ assert (_casts1 '() as char = '\x00');
+ assert (_casts2 '() as string = "Hello");
+ assert (_casts1 '("Ciao") as string = "Ciao");
+ assert (_chartest1 '() as char = 'x');
+ assert (_chartest2 '() as char = '\x00');
+ assert (_chartest3 '() as char = '\x01');
+ assert (_chartest4 '() as char = '\n');
+ assert (_chartest5 '() as char = 'B');
+ assert (_chartest6 '() as char = 'C');
+;;
diff --git a/Examples/test-suite/ocaml/director_default_runme.ml b/Examples/test-suite/ocaml/director_default_runme.ml
new file mode 100644
index 000000000..4fd655a00
--- /dev/null
+++ b/Examples/test-suite/ocaml/director_default_runme.ml
@@ -0,0 +1,25 @@
+open Swig
+open Director_default
+
+let director_default_MyFoo ob meth args =
+ match meth with
+ "Msg" -> (match args with
+ | C_list [ msg ] -> C_string ("director_default_MyFoo-" ^ (msg as string))
+ | _ -> raise (Failure "director_default_MyFoo::Msg()"))
+ | _ -> (invoke ob) meth args
+
+let _ =
+ let a = new_derived_object new_Foo (director_default_MyFoo) '(10) in
+ assert (a -> GetMsg () as string = "director_default_MyFoo-default");
+ assert (a -> GetMsg ("boo") as string = "director_default_MyFoo-boo");
+ let f = new_Foo '(10) in
+ assert (f -> GetMsg () as string = "Foo-default");
+ assert (f -> GetMsg ("boo") as string = "Foo-boo");
+
+ let b = new_Bar '(1) in
+ assert (b -> GetMsg () as string = "Bar-default");
+ assert (b -> GetMsg ("boo") as string = "Bar-boo");
+ let b2 = new_Bar '() in
+ assert (b2 -> GetMsg () as string = "Bar-default");
+ assert (b2 -> GetMsg ("boo") as string = "Bar-boo");
+;;
diff --git a/Examples/test-suite/ocaml/director_exception_catches_runme.ml b/Examples/test-suite/ocaml/director_exception_catches_runme.ml
new file mode 100644
index 000000000..322cdda45
--- /dev/null
+++ b/Examples/test-suite/ocaml/director_exception_catches_runme.ml
@@ -0,0 +1,15 @@
+open Swig
+open Director_exception_catches
+
+exception CustomException of string
+
+let new_MyClass ob meth args =
+ match meth with
+ | "description" -> raise (CustomException "CustomException thrown in description().")
+ | _ -> (invoke ob) meth args
+
+let b = new_derived_object new_BaseClass (new_MyClass) '()
+try
+ ignore (_BaseClass_call_description (b)); assert false
+with CustomException s ->
+ assert (s = "CustomException thrown in description().")
diff --git a/Examples/test-suite/ocaml/director_exception_nothrow_runme.ml b/Examples/test-suite/ocaml/director_exception_nothrow_runme.ml
new file mode 100644
index 000000000..5b2b4b3d2
--- /dev/null
+++ b/Examples/test-suite/ocaml/director_exception_nothrow_runme.ml
@@ -0,0 +1,12 @@
+open Swig
+open Director_exception_nothrow
+
+let _MyBar ob meth args =
+ match meth with
+ | "pang" -> C_string "_MyBar::pang()"
+ | _ -> (invoke ob) meth args
+
+let a = new_derived_object new_Bar (_MyBar) '()
+let _ = assert (_MyBar a "pang" '() as string = "_MyBar::pang()")
+let b = new_Bar '()
+let _ = assert (b -> pang () as string = "Bar::pang()")
diff --git a/Examples/test-suite/ocaml/director_exception_runme.ml b/Examples/test-suite/ocaml/director_exception_runme.ml
new file mode 100644
index 000000000..1cd769b20
--- /dev/null
+++ b/Examples/test-suite/ocaml/director_exception_runme.ml
@@ -0,0 +1,46 @@
+open Swig
+open Director_exception
+
+exception MyException of string * string
+
+let director_exception_MyFoo ob meth args =
+ match meth with
+ "ping" -> raise (Failure "MyFoo::ping() EXCEPTION")
+ | _ -> (invoke ob) meth args
+
+let director_exception_MyFoo2 ob meth args =
+ match meth with
+ "ping" -> (C_bool true)
+ | _ -> (invoke ob) meth args
+
+let director_exception_MyFoo3 ob meth args =
+ match meth with
+ "ping" -> raise (MyException ("foo", "bar"))
+ | _ -> (invoke ob) meth args
+
+(* Check that Failure is raised by MyFoo.ping() (via MyFoo.pong()). *)
+let a =
+ new_derived_object
+ new_Foo (director_exception_MyFoo) '()
+let a = _launder(a)
+try
+ let _ = a -> pong () in assert false
+with Failure s -> assert(s = "MyFoo::ping() EXCEPTION")
+
+let a =
+ new_derived_object
+ new_Foo (director_exception_MyFoo2) '()
+let a = _launder(a)
+try
+ let _ = a -> pong () in assert false
+with Failure s -> assert(s = "No appropriate conversion found.")
+
+let a =
+ new_derived_object
+ new_Foo (director_exception_MyFoo3) '()
+let a = _launder(a)
+try
+ let _ = a -> pong () in assert false
+with MyException (s1, s2) ->
+ assert (s1 = "foo");
+ assert (s2 = "bar");
diff --git a/Examples/test-suite/ocaml/director_frob_runme.ml b/Examples/test-suite/ocaml/director_frob_runme.ml
new file mode 100644
index 000000000..137a88ef3
--- /dev/null
+++ b/Examples/test-suite/ocaml/director_frob_runme.ml
@@ -0,0 +1,5 @@
+open Swig
+open Director_frob
+
+let foo = new_Bravo '()
+assert (foo -> abs_method () as string = "Bravo::abs_method()")
diff --git a/Examples/test-suite/ocaml/director_ignore_runme.ml b/Examples/test-suite/ocaml/director_ignore_runme.ml
new file mode 100644
index 000000000..b0d3b1451
--- /dev/null
+++ b/Examples/test-suite/ocaml/director_ignore_runme.ml
@@ -0,0 +1,18 @@
+open Swig
+open Director_ignore
+
+let _DIgnoresDerived ob meth args =
+ match meth with
+ | "OverloadedMethod" -> C_int 0
+ | _ -> (invoke ob) meth args
+
+let a =new_derived_object new_DIgnores (_DIgnoresDerived) '()
+let _ = assert (a -> Triple (5) as int = 15)
+
+let _DAbstractIgnoresDerived ob meth args =
+ match meth with
+ | "OverloadedMethod" -> C_int 0
+ | _ -> (invoke ob) meth args
+
+let a = new_derived_object new_DAbstractIgnores (_DAbstractIgnoresDerived) '()
+let _ = assert (a -> Quadruple (5) as int = 20)
diff --git a/Examples/test-suite/ocaml/director_pass_by_value_runme.ml b/Examples/test-suite/ocaml/director_pass_by_value_runme.ml
new file mode 100644
index 000000000..af862f189
--- /dev/null
+++ b/Examples/test-suite/ocaml/director_pass_by_value_runme.ml
@@ -0,0 +1,24 @@
+open Swig
+open Director_pass_by_value
+
+let passByVal = ref [| |]
+
+let director_pass_by_value_Derived ob meth args =
+ match meth with
+ | "virtualMethod" -> passByVal := Array.append !passByVal [|args|]; C_void
+ | _ -> (invoke ob) meth args
+
+let d =
+ new_derived_object
+ new_DirectorPassByValueAbstractBase
+ (director_pass_by_value_Derived)
+ '()
+
+let _ =
+ let caller = new_Caller '() in
+ assert (caller -> call_virtualMethod (d) = C_void);
+ assert (Array.length !passByVal = 1);
+ let a = List.hd (fnhelper (!passByVal.(0))) in
+ assert (a -> getVal () as int = 0x12345678);
+ assert (a -> "~" () = C_void);
+;;
diff --git a/Examples/test-suite/ocaml/director_unroll_runme.ml b/Examples/test-suite/ocaml/director_unroll_runme.ml
new file mode 100644
index 000000000..747d9adf6
--- /dev/null
+++ b/Examples/test-suite/ocaml/director_unroll_runme.ml
@@ -0,0 +1,15 @@
+open Swig
+open Director_unroll
+
+let director_unroll_MyFoo ob meth args =
+ match meth with
+ | "ping" -> C_string "MyFoo::ping()"
+ | _ -> (invoke ob) meth args
+
+let a = new_derived_object
+ new_Foo (director_unroll_MyFoo) '()
+
+let b = new_Bar '()
+let _ = b -> set (a)
+let c = b -> get ()
+let _ = assert ((a -> "&" () as int) = (c -> "&" () as int))
diff --git a/Examples/test-suite/ocaml/dynamic_cast_runme.ml b/Examples/test-suite/ocaml/dynamic_cast_runme.ml
new file mode 100644
index 000000000..54391d9a0
--- /dev/null
+++ b/Examples/test-suite/ocaml/dynamic_cast_runme.ml
@@ -0,0 +1,9 @@
+open Swig
+open Dynamic_cast
+
+let f = new_Foo '()
+let b = new_Bar '()
+
+let x = f -> blah ()
+let y = b -> blah ()
+assert (_do_test '(y) as string = "Bar::test")
diff --git a/Examples/test-suite/ocaml/exception_classname_runme.ml b/Examples/test-suite/ocaml/exception_classname_runme.ml
new file mode 100644
index 000000000..8467ed6e8
--- /dev/null
+++ b/Examples/test-suite/ocaml/exception_classname_runme.ml
@@ -0,0 +1,5 @@
+open Swig
+open Exception_classname
+
+let a = new_Exception '()
+assert (a -> testfunc () as int = 42)
diff --git a/Examples/test-suite/ocaml/exception_order_runme.ml b/Examples/test-suite/ocaml/exception_order_runme.ml
new file mode 100644
index 000000000..9e987c84b
--- /dev/null
+++ b/Examples/test-suite/ocaml/exception_order_runme.ml
@@ -0,0 +1,17 @@
+open Swig
+open Exception_order
+
+let a = new_A '()
+
+let check meth args expected =
+ try
+ ignore ((invoke a) meth (args)); assert false
+ with Failure msg -> assert (msg = expected)
+
+let _ =
+ check "foo" '() "C++ E1 exception thrown";
+ check "bar" '() "C++ E2 exception thrown";
+ check "foobar" '() "postcatch unknown";
+ check "barfoo" (C_int 1) "C++ E1 exception thrown";
+ check "barfoo" (C_int 2) "C++ E2 * exception thrown";
+;;
diff --git a/Examples/test-suite/ocaml/extend_constructor_destructor_runme.ml b/Examples/test-suite/ocaml/extend_constructor_destructor_runme.ml
new file mode 100644
index 000000000..432d9d7dc
--- /dev/null
+++ b/Examples/test-suite/ocaml/extend_constructor_destructor_runme.ml
@@ -0,0 +1,12 @@
+open Swig
+open Extend_constructor_destructor
+
+let check o v =
+ assert ((o -> "[ivar]" () as int) = v);
+ ignore (o -> "~" ());
+ assert ((_globalVar '() as int) = -v)
+
+let ctors = [new_AStruct; new_BStruct; new_CStruct; new_DStruct; new_EStruct;
+ new_FStruct; new_GStruct]
+
+let _ = List.iteri (fun i c -> let j = succ i in check (c (C_int j)) j) ctors
diff --git a/Examples/test-suite/ocaml/extend_placement_runme.ml b/Examples/test-suite/ocaml/extend_placement_runme.ml
new file mode 100644
index 000000000..31d9ae671
--- /dev/null
+++ b/Examples/test-suite/ocaml/extend_placement_runme.ml
@@ -0,0 +1,53 @@
+open Swig
+open Extend_placement
+
+let _ =
+ let f = new_Foo '() in
+ assert (f -> spam () as int = 1);
+ assert (new_Foo '(1) -> spam () as int = 1);
+ let f = new_Foo '(1, 1) in
+ assert (f -> spam () as int = 1);
+ assert (f -> spam ("hello") as int = 2);
+ assert (f -> spam (1) as int = 1);
+ assert (f -> spam (1, 2) as int = 3);
+ assert (f -> spam (2, 4, 6) as int = 6);
+ assert (f -> spam (f) as int = 0);
+ let arg = C_double 1. in
+ assert (f -> spam (f, arg) as int = 0);
+
+ assert (new_Bar '() -> spam () as int = 1);
+ let b = new_Bar '(1) in
+ assert (b -> spam () as int = 1);
+ assert (b -> spam ("hello") as int = 2);
+ assert (b -> spam (1) as int = 1);
+ assert (b -> spam (1, 2) as int = 3);
+ assert (b -> spam (2, 4, 6) as int = 6);
+ assert (b -> spam (b) as int = 0);
+ let arg = C_double 1. in
+ assert (b -> spam (b, arg) as int = 0);
+
+ assert (new_FooTi '() -> spam () as int = 1);
+ assert (new_FooTi '(1) -> spam () as int = 1);
+ let f = new_FooTi '(1, 1) in
+ assert (f -> spam () as int = 1);
+ assert (f -> spam ("hello") as int = 2);
+ assert (f -> spam (1) as int = 1);
+ assert (f -> spam (1, 2) as int = 3);
+ assert (f -> spam (2, 4, 6) as int = 6);
+ let foo = new_Foo '() in
+ assert (f -> spam (foo) as int = 0);
+ let arg = C_double 1. in
+ assert (f -> spam (foo, arg) as int = 0);
+
+ assert (new_BarTi '() -> spam () as int = 1);
+ let b = new_BarTi '(1) in
+ assert (b -> spam () as int = 1);
+ assert (b -> spam ("hello") as int = 2);
+ assert (b -> spam (1) as int = 1);
+ assert (b -> spam (1, 2) as int = 3);
+ assert (b -> spam (2, 4, 6) as int = 6);
+ let bar = new_Bar '() in
+ assert (b -> spam (bar) as int = 0);
+ let arg = C_double 1. in
+ assert (b -> spam (bar, arg) as int = 0);
+;;
diff --git a/Examples/test-suite/ocaml/extend_runme.ml b/Examples/test-suite/ocaml/extend_runme.ml
new file mode 100644
index 000000000..695282f9c
--- /dev/null
+++ b/Examples/test-suite/ocaml/extend_runme.ml
@@ -0,0 +1,26 @@
+open Swig
+open Extend
+
+let _ =
+ let base1 = new_Base '() and base2 = new_Base '(10) in
+ assert ((base1 -> "[value]" () as int) = 0);
+ assert ((base2 -> "[value]" () as int) = 10);
+ let cint = C_int 5 in
+ assert ((base1 -> "method" (cint) as int) = 5);
+ assert ((_Base_zeroVal '() as int) = 0);
+ assert ((base2 -> "currentValue" () as int) = 10);
+ let cint = C_int 7 in
+ assert ((base2 -> "extendmethod" (cint) as int) = 14);
+;;
+
+let _ =
+ let der1 = new_Derived '(0) and der2 = new_Derived '(17) in
+ assert ((der1 -> "[value]" () as int) = 0);
+ let cint = C_int 5 in
+ assert ((der1 -> "method" (cint) as int) = 10);
+ assert ((der2 -> "[value]" () as int) = 34);
+ let cfloat = C_float 200. in
+ ignore (der2 -> "[extendval]" (cfloat));
+ assert (abs_float ((der2 -> "[actualval]" () as float) -. 2.) < 0.001);
+ assert (abs_float ((der2 -> "[extendval]" () as float) -. 200.) < 0.001);
+;;
diff --git a/Examples/test-suite/ocaml/extend_special_variables_runme.ml b/Examples/test-suite/ocaml/extend_special_variables_runme.ml
new file mode 100644
index 000000000..387d8fd0a
--- /dev/null
+++ b/Examples/test-suite/ocaml/extend_special_variables_runme.ml
@@ -0,0 +1,14 @@
+open Swig
+open Extend_special_variables
+
+let f = new_ForExtensionNewName '()
+let s = f -> "extended_renamed" () as string
+let s2 = f -> "extended_renamed" (10) as string
+
+let _ =
+ assert (s = "name:extended symname:extended_renamed wrapname: overname:__SWIG_0 decl:ForExtension::extended() fulldecl:char const * ForExtension::extended() parentclasssymname:ForExtensionNewName parentclassname:ForExtension")
+ assert (s2 = "name:extended symname:extended_renamed wrapname: overname:__SWIG_1 decl:ForExtension::extended(int) fulldecl:char const * ForExtension::extended(int) parentclasssymname:ForExtensionNewName parentclassname:ForExtension")
+;;
+
+let e = new_ExtendTemplateInt '()
+let _ = e -> "extending" ()
diff --git a/Examples/test-suite/ocaml/extend_template_runme.ml b/Examples/test-suite/ocaml/extend_template_runme.ml
new file mode 100644
index 000000000..2d611a14a
--- /dev/null
+++ b/Examples/test-suite/ocaml/extend_template_runme.ml
@@ -0,0 +1,8 @@
+open Swig
+open Extend_template
+
+let f = new_Foo_0 '()
+let _ =
+ assert((f -> "test1" (37) as int) = 37);
+ assert((f -> "test2" (42) as int) = 42);
+;;
diff --git a/Examples/test-suite/ocaml/extend_typedef_class_runme.ml b/Examples/test-suite/ocaml/extend_typedef_class_runme.ml
new file mode 100644
index 000000000..b5d97e2ad
--- /dev/null
+++ b/Examples/test-suite/ocaml/extend_typedef_class_runme.ml
@@ -0,0 +1,12 @@
+open Swig
+open Extend_typedef_class
+
+let test_obj o v =
+ let cint = C_int v in
+ let _ = o -> "[membervar]" (cint) in
+ assert ((o -> "getvar" () as int) = v)
+
+let ctors = [new_AClass; new_BClass; new_CClass; new_DClass; new_AStruct;
+ new_BStruct; new_CStruct; new_DStruct]
+
+let _ = List.iteri (fun i c -> test_obj (c '()) i) ctors
diff --git a/Examples/test-suite/ocaml/extern_c_runme.ml b/Examples/test-suite/ocaml/extern_c_runme.ml
new file mode 100644
index 000000000..18e672255
--- /dev/null
+++ b/Examples/test-suite/ocaml/extern_c_runme.ml
@@ -0,0 +1,4 @@
+open Swig
+open Extern_c
+
+let _ = _RealFunction '(2)
diff --git a/Examples/test-suite/ocaml/funcptr_cpp_runme.ml b/Examples/test-suite/ocaml/funcptr_cpp_runme.ml
new file mode 100644
index 000000000..bdc077d4e
--- /dev/null
+++ b/Examples/test-suite/ocaml/funcptr_cpp_runme.ml
@@ -0,0 +1,13 @@
+open Swig
+open Funcptr_cpp
+
+let _ =
+ let fp = _ADD_BY_VALUE '() in
+ assert (_call1 '(fp, 10, 11) as int = 21);
+ let fp = _ADD_BY_POINTER '() in
+ assert (_call2 '(fp, 12, 13) as int = 25);
+ let fp = _ADD_BY_REFERENCE '() in
+ assert (_call3 '(fp, 14, 15) as int = 29);
+ let fp = _ADD_BY_VALUE_C '() in
+ assert (_call1 '(fp, 2, 3) as int = 5);
+;;
diff --git a/Examples/test-suite/ocaml/fvirtual_runme.ml b/Examples/test-suite/ocaml/fvirtual_runme.ml
new file mode 100644
index 000000000..6b0782b20
--- /dev/null
+++ b/Examples/test-suite/ocaml/fvirtual_runme.ml
@@ -0,0 +1,10 @@
+open Swig
+open Fvirtual
+
+let _ =
+ let sw = new_NodeSwitch '() and n = new_Node '() in
+ assert (n -> addChild (n) as int = 1);
+ assert (sw -> addChild (n) as int = 2);
+ assert (sw -> addChild (sw) as int = 2);
+ assert (sw -> addChild (n, false) as int = 3)
+;;
diff --git a/Examples/test-suite/ocaml/global_ns_arg_runme.ml b/Examples/test-suite/ocaml/global_ns_arg_runme.ml
new file mode 100644
index 000000000..7717e52d9
--- /dev/null
+++ b/Examples/test-suite/ocaml/global_ns_arg_runme.ml
@@ -0,0 +1,5 @@
+open Swig
+open Global_ns_arg
+
+let _ = assert ((_foo '(1) as int) = 1)
+let _ = assert ((_bar_fn '() as int) = 1)
diff --git a/Examples/test-suite/ocaml/global_vars_runme.ml b/Examples/test-suite/ocaml/global_vars_runme.ml
new file mode 100644
index 000000000..75df89499
--- /dev/null
+++ b/Examples/test-suite/ocaml/global_vars_runme.ml
@@ -0,0 +1,15 @@
+open Swig
+open Global_vars
+
+_init '()
+
+let _ =
+ assert (_b '() as string = "string b");
+ assert (_b '("a string value") as string = "a string value");
+ assert (_b '() as string = "a string value");
+ assert (_x '() as int = 1234);
+ assert (_x '(9876) as int = 9876);
+ assert (_x '() as int = 9876);
+ assert (_Hi '() as int = 0);
+ assert (_Hola '() as int = 1);
+;;
diff --git a/Examples/test-suite/ocaml/ignore_parameter_runme.ml b/Examples/test-suite/ocaml/ignore_parameter_runme.ml
new file mode 100644
index 000000000..358b25ebb
--- /dev/null
+++ b/Examples/test-suite/ocaml/ignore_parameter_runme.ml
@@ -0,0 +1,20 @@
+open Swig
+open Ignore_parameter
+
+let _ =
+ assert (get_string (_jaguar (C_list [ C_int 200 ; C_float 0. ])) = "hello");
+ assert (get_int (_lotus (C_list [ C_string "fast" ; C_float 0. ])) = 101);
+ assert (get_float (_tvr (C_list [ C_string "fast" ; C_int 200 ])) = 8.8);
+ assert (get_int (_ferrari (C_void)) = 101);
+;;
+let sc = new_SportsCars (C_void)
+let _ =
+ assert (get_string ((invoke sc) "daimler" (C_list [ C_int 200 ; C_float 0. ])) = "hello");
+ assert (get_int ((invoke sc) "astonmartin" (C_list [ C_string "fast" ; C_float 0. ])) = 101);
+ assert (get_float ((invoke sc) "bugatti" (C_list [ C_string "fast" ; C_int 200 ])) = 8.8);
+ assert (get_int ((invoke sc) "lamborghini" (C_void)) = 101);
+;;
+let mc = new_MiniCooper (C_list [ C_int 200 ; C_float 0. ])
+let mm = new_MorrisMinor (C_list [ C_string "slow" ; C_float 0. ])
+let fa = new_FordAnglia (C_list [ C_string "slow" ; C_int 200 ])
+let aa = new_AustinAllegro (C_void)
diff --git a/Examples/test-suite/ocaml/inctest_runme.ml b/Examples/test-suite/ocaml/inctest_runme.ml
new file mode 100644
index 000000000..886751109
--- /dev/null
+++ b/Examples/test-suite/ocaml/inctest_runme.ml
@@ -0,0 +1,7 @@
+open Swig
+open Inctest
+
+let _ = new_A '()
+let _ = new_B '()
+let _ = assert (_importtest1 '(5) as int = 15)
+let _ = assert (_importtest2 '("black") as string = "white")
diff --git a/Examples/test-suite/ocaml/inherit_missing_runme.ml b/Examples/test-suite/ocaml/inherit_missing_runme.ml
new file mode 100644
index 000000000..3d1901356
--- /dev/null
+++ b/Examples/test-suite/ocaml/inherit_missing_runme.ml
@@ -0,0 +1,10 @@
+open Swig
+open Inherit_missing
+
+let _ =
+ let a = _new_Foo '() and b = new_Bar '() and c = new_Spam '() in
+ assert (_do_blah '(a) as string = "Foo::blah");
+ assert (_do_blah '(b) as string = "Bar::blah");
+ assert (_do_blah '(c) as string = "Spam::blah");
+ assert (_delete_Foo '(a) = C_void)
+;;
diff --git a/Examples/test-suite/ocaml/inout_runme.ml b/Examples/test-suite/ocaml/inout_runme.ml
new file mode 100644
index 000000000..767bb43e6
--- /dev/null
+++ b/Examples/test-suite/ocaml/inout_runme.ml
@@ -0,0 +1,8 @@
+open Swig
+open Inout
+
+let _ =
+ assert (_AddOne1 '(1.) as float = 2.);
+ assert (_AddOne3 '(1, 1, 1) = C_list ['2.;'2.;'2.]);
+ assert (_AddOne1r '(1.) as float = 2.);
+;;
diff --git a/Examples/test-suite/ocaml/li_cpointer_cpp_runme.ml b/Examples/test-suite/ocaml/li_cpointer_cpp_runme.ml
new file mode 100644
index 000000000..1daf6b5bd
--- /dev/null
+++ b/Examples/test-suite/ocaml/li_cpointer_cpp_runme.ml
@@ -0,0 +1,10 @@
+open Swig
+open Li_cpointer_cpp
+
+let _ =
+ let p = _new_intp '() in
+ assert (_intp_value '(p) as int = 0);
+ assert (_intp_assign '(p, 3) = C_void);
+ assert (_intp_value '(p) as int = 3);
+ assert (_delete_intp '(p) = C_void)
+;;
diff --git a/Examples/test-suite/ocaml/li_std_except_runme.ml b/Examples/test-suite/ocaml/li_std_except_runme.ml
new file mode 100644
index 000000000..e6ad14dc3
--- /dev/null
+++ b/Examples/test-suite/ocaml/li_std_except_runme.ml
@@ -0,0 +1,18 @@
+open Swig
+open Li_std_except
+
+let _ =
+ let t = new_Test '() in
+ try let _ = t -> throw_bad_cast () in assert false with Failure s -> ();
+ try let _ = t -> throw_bad_exception () in assert false with Failure s -> ();
+ try let _ = t -> throw_domain_error () in assert false with Failure s -> assert (s = "oops");
+ try let _ = t -> throw_exception () in assert false with Failure s -> ();
+ try let _ = t -> throw_invalid_argument () in assert false with Invalid_argument s -> assert (s = "oops");
+ try let _ = t -> throw_length_error () in assert false with Failure s -> assert (s = "oops");
+ try let _ = t -> throw_logic_error () in assert false with Failure s -> assert (s = "oops");
+ try let _ = t -> throw_out_of_range () in assert false with Failure s -> assert (s = "oops");
+ try let _ = t -> throw_overflow_error () in assert false with Failure s -> assert (s = "oops");
+ try let _ = t -> throw_range_error () in assert false with Failure s -> assert (s = "oops");
+ try let _ = t -> throw_runtime_error () in assert false with Failure s -> assert (s = "oops");
+ try let _ = t -> throw_underflow_error () in assert false with Failure s -> assert (s = "oops");
+;;
diff --git a/Examples/test-suite/ocaml/li_std_vector_runme.ml b/Examples/test-suite/ocaml/li_std_vector_runme.ml
new file mode 100644
index 000000000..64e9ec9f2
--- /dev/null
+++ b/Examples/test-suite/ocaml/li_std_vector_runme.ml
@@ -0,0 +1,23 @@
+open Swig
+open Li_std_vector
+
+let _ =
+ let iv = new_IntVector '() in
+ assert (iv -> "empty" () as bool);
+ assert ((iv -> "size" () as int) = 0);
+ ignore (iv -> "push_back" (123));
+ assert ((iv -> "empty" () as bool) = false);
+ assert ((iv -> "size" () as int) = 1);
+ assert ((iv -> "[]" (0) as int) = 123);
+ ignore (iv -> "clear" ());
+ assert (iv -> "empty" () as bool);
+ assert ((iv -> "size" () as int) = 0);
+;;
+
+let _ =
+ let rv = new_RealVector '() in
+ ignore (rv -> "push_back" (100.));
+ ignore (rv -> "push_back" (200.));
+ assert ((rv -> "[]" (0) as float) = 100.);
+ assert ((rv -> "[]" (1) as float) = 200.);
+;;
diff --git a/Examples/test-suite/ocaml/memberin_extend_runme.ml b/Examples/test-suite/ocaml/memberin_extend_runme.ml
new file mode 100644
index 000000000..e2cca2275
--- /dev/null
+++ b/Examples/test-suite/ocaml/memberin_extend_runme.ml
@@ -0,0 +1,10 @@
+open Swig
+open Memberin_extend
+
+let _ =
+ let em1 = new_ExtendMe '() and em2 = new_ExtendMe '() in
+ assert (em1 -> "[thing]" ("em1thing") = C_void);
+ assert (em2 -> "[thing]" ("em2thing") = C_void);
+ assert (em1 -> "[thing]" () as string = "em1thing");
+ assert (em2 -> "[thing]" () as string = "em2thing");
+;;
diff --git a/Examples/test-suite/ocaml/multivalue_runme.ml b/Examples/test-suite/ocaml/multivalue_runme.ml
new file mode 100644
index 000000000..d7e19e7d8
--- /dev/null
+++ b/Examples/test-suite/ocaml/multivalue_runme.ml
@@ -0,0 +1,8 @@
+open Swig
+open Multivalue
+
+let _ =
+ assert (_divide_l '(37, 5) = C_list ['7;'2]);
+ assert (_divide_v '(41, 7) = C_list ['5;'6]);
+ assert (_divide_mv '(91, 13) = C_list ['7;'0]);
+;;
diff --git a/Examples/test-suite/ocaml/namespace_virtual_method_runme.ml b/Examples/test-suite/ocaml/namespace_virtual_method_runme.ml
new file mode 100644
index 000000000..3c5b2cf34
--- /dev/null
+++ b/Examples/test-suite/ocaml/namespace_virtual_method_runme.ml
@@ -0,0 +1,4 @@
+open Swig
+open Namespace_virtual_method
+
+let x = new_Spam '()
diff --git a/Examples/test-suite/ocaml/newobject2_runme.ml b/Examples/test-suite/ocaml/newobject2_runme.ml
new file mode 100644
index 000000000..eb9a191bc
--- /dev/null
+++ b/Examples/test-suite/ocaml/newobject2_runme.ml
@@ -0,0 +1,16 @@
+open Swig
+open Newobject2
+
+let _ =
+ assert (_fooCount '() as int = 0);
+ let foo1 = _makeFoo '() in
+ assert (_fooCount '() as int = 1);
+ assert (_do_stuff '(foo1) = C_void);
+ let foo2 = _makeFoo '() in
+ assert (_fooCount '() as int = 2);
+ assert (_do_stuff '(foo2) = C_void);
+ ignore (foo1 -> "~" ());
+ assert (_fooCount '() as int = 1);
+ ignore (foo2 -> "~" ());
+ assert (_fooCount '() as int = 0)
+;;
diff --git a/Examples/test-suite/ocaml/overload_bool_runme.ml b/Examples/test-suite/ocaml/overload_bool_runme.ml
new file mode 100644
index 000000000..fefd07429
--- /dev/null
+++ b/Examples/test-suite/ocaml/overload_bool_runme.ml
@@ -0,0 +1,26 @@
+open Swig
+open Overload_bool
+
+let _ =
+ assert (_overloaded '(true) as string = "bool");
+ assert (_overloaded '(false) as string = "bool");
+ assert (_overloaded '(0) as string = "int");
+ assert (_overloaded '(1) as string = "int");
+ assert (_overloaded '(2) as string = "int");
+ assert (_overloaded '("1234") as string = "string");
+ assert (_boolfunction '(true) as string = "true");
+ assert (_boolfunction '(false) as string = "false");
+ assert (_intfunction '(true) as string = "int");
+ assert (_intfunction '(false) as string = "int");
+
+ assert (_overloaded_ref '(true) as string = "bool");
+ assert (_overloaded_ref '(false) as string = "bool");
+ assert (_overloaded_ref '(0) as string = "int");
+ assert (_overloaded_ref '(1) as string = "int");
+ assert (_overloaded_ref '(2) as string = "int");
+ assert (_overloaded_ref '("1234") as string = "string");
+ assert (_boolfunction_ref '(true) as string = "true");
+ assert (_boolfunction_ref '(false) as string = "false");
+ assert (_intfunction_ref '(true) as string = "int");
+ assert (_intfunction_ref '(false) as string = "int");
+;;
diff --git a/Examples/test-suite/ocaml/overload_extend_runme.ml b/Examples/test-suite/ocaml/overload_extend_runme.ml
new file mode 100644
index 000000000..3793cdbb0
--- /dev/null
+++ b/Examples/test-suite/ocaml/overload_extend_runme.ml
@@ -0,0 +1,11 @@
+open Swig
+open Overload_extend
+
+let _ =
+ let f = new_Foo '() in
+ assert (f -> test () as int = 0);
+ assert (f -> test (3) as int = 1);
+ assert (f -> test ("hello") as int = 2);
+ assert (f -> test (3., 2.) as float = 5.);
+ assert (f -> test (3.) as float = 1003.)
+;;
diff --git a/Examples/test-suite/ocaml/overload_method_runme.ml b/Examples/test-suite/ocaml/overload_method_runme.ml
new file mode 100644
index 000000000..0303ba2a3
--- /dev/null
+++ b/Examples/test-suite/ocaml/overload_method_runme.ml
@@ -0,0 +1,11 @@
+open Swig
+open Overload_method
+
+let _ =
+ let b = new_Base '() in
+ assert (b -> "method" () as int = 42);
+ assert (b -> "overloaded_method" () as int = 42);
+ assert (b -> "overloaded_method" (5) = C_void);
+ assert (b -> "overloaded_method" () as int = 5);
+ assert (b -> "method" () as int = 5);
+;;
diff --git a/Examples/test-suite/ocaml/overload_numeric_runme.ml b/Examples/test-suite/ocaml/overload_numeric_runme.ml
new file mode 100644
index 000000000..0342d63e0
--- /dev/null
+++ b/Examples/test-suite/ocaml/overload_numeric_runme.ml
@@ -0,0 +1,14 @@
+open Swig
+open Overload_numeric
+
+let _ =
+ let n = new_Nums '() in
+ let arg = C_char 'c' in
+ assert (n -> over (arg) as string = "signed char");
+ let arg = C_short 2 in
+ assert (n -> over (arg) as string = "short");
+ assert (n -> over (2) as string = "int");
+ let arg = C_float 2. in
+ assert (n -> over (arg) as string = "float");
+ assert (n -> over (2.) as string = "double")
+;;
diff --git a/Examples/test-suite/ocaml/overload_polymorphic_runme.ml b/Examples/test-suite/ocaml/overload_polymorphic_runme.ml
new file mode 100644
index 000000000..5ed5f45f4
--- /dev/null
+++ b/Examples/test-suite/ocaml/overload_polymorphic_runme.ml
@@ -0,0 +1,9 @@
+open Swig
+open Overload_polymorphic
+
+let _ =
+ let t = new_Derived '() in
+ assert (_test (t) as int = 0);
+ assert (_test '(1) as int = 1);
+ assert (_test2 (t) as int = 1)
+;;
diff --git a/Examples/test-suite/ocaml/overload_rename_runme.ml b/Examples/test-suite/ocaml/overload_rename_runme.ml
new file mode 100644
index 000000000..9e012c0c5
--- /dev/null
+++ b/Examples/test-suite/ocaml/overload_rename_runme.ml
@@ -0,0 +1,7 @@
+open Swig
+open Overload_rename
+
+let _ = new_Foo (C_float 1.)
+let _ = new_Foo (C_list [ C_float 1. ; C_float 1. ])
+let _ = new_Foo_int (C_list [ C_float 1. ; C_int 1 ])
+let _ = new_Foo_int (C_list [ C_float 1. ; C_int 1 ; C_float 1. ])
diff --git a/Examples/test-suite/ocaml/overload_subtype_runme.ml b/Examples/test-suite/ocaml/overload_subtype_runme.ml
new file mode 100644
index 000000000..6f0aeab56
--- /dev/null
+++ b/Examples/test-suite/ocaml/overload_subtype_runme.ml
@@ -0,0 +1,8 @@
+open Swig
+open Overload_subtype
+
+let _ =
+ let f = new_Foo '() and b = new_Bar '() in
+ assert (_spam (f) as int = 1);
+ assert (_spam (b) as int = 2)
+;;
diff --git a/Examples/test-suite/ocaml/overload_template_runme.ml b/Examples/test-suite/ocaml/overload_template_runme.ml
new file mode 100644
index 000000000..42a4a397a
--- /dev/null
+++ b/Examples/test-suite/ocaml/overload_template_runme.ml
@@ -0,0 +1,60 @@
+open Swig
+open Overload_template
+
+let _ =
+ assert (_foo '() as int = 3);
+ assert (_maximum '(3, 4) as int = 4);
+ assert (_maximum '(3.4, 5.2) as float > 5.);
+ assert (_mix1 '("hi") as int = 101);
+ assert (_mix1 '(1.0, 1.0) as int = 102);
+ assert (_mix1 '(1.0) as int = 103);
+ assert (_mix2 '("hi") as int = 101);
+ assert (_mix2 '(1.0, 1.0) as int = 102);
+ assert (_mix2 '(1.0) as int = 103);
+ assert (_mix3 '("hi") as int = 101);
+ assert (_mix3 '(1.0, 1.0) as int = 102);
+ assert (_mix3 '(1.0) as int = 103);
+
+ assert (_overtparams1 '(100) as int = 10);
+ assert (_overtparams1 '(100.0, 100) as int = 20);
+ assert (_overtparams2 '(100.0, 100) as int = 40);
+ assert (_overloaded '() as int = 60);
+ assert (_overloaded '(100.0, 100) as int = 70);
+ assert (_overloadedagain '("hello") as int = 80);
+ assert (_overloadedagain '() as int = 90);
+
+ assert (_specialization '(10) as int = 202);
+ assert (_specialization '(10.0) as int = 203);
+ assert (_specialization '(10, 10) as int = 204);
+ assert (_specialization '(10.0, 10.0) as int = 205);
+ assert (_specialization '("hi", "hi") as int = 201);
+
+ assert (_xyz '() = C_void);
+ assert (_xyz_int '() = C_void);
+ assert (_xyz_double '() = C_void);
+
+ assert (_overload '("hi") as int = 0);
+ assert (_overload '(1) as int = 10);
+ assert (_overload '(1, 1) as int = 20);
+ assert (_overload '(1, "hello") as int = 30);
+ let k = new_Klass '() in
+ assert (_overload '(k) as int = 10);
+ assert (_overload '(k, k) as int = 20);
+ assert (_overload '(k, "hello") as int = 30);
+ assert (_overload '(10.0, "hi") as int = 40);
+ assert (_overload '() as int = 50);
+
+ assert (_nsoverload '("hi") as int = 1000);
+ assert (_nsoverload '(1) as int = 1010);
+ assert (_nsoverload '(1, 1) as int = 1020);
+ assert (_nsoverload '(1, "hello") as int = 1030);
+ assert (_nsoverload '(k) as int = 1010);
+ assert (_nsoverload '(k, k) as int = 1020);
+ assert (_nsoverload '(k, "hello") as int = 1030);
+ assert (_nsoverload '(10.0, "hi") as int = 1040);
+ assert (_nsoverload '() as int = 1050);
+
+ assert (_A_foo '(1) = C_void);
+ let b = new_B '() in
+ assert (b -> foo(1) = C_void);
+;;
diff --git a/Examples/test-suite/ocaml/primitive_ref_runme.ml b/Examples/test-suite/ocaml/primitive_ref_runme.ml
new file mode 100644
index 000000000..7c96caac2
--- /dev/null
+++ b/Examples/test-suite/ocaml/primitive_ref_runme.ml
@@ -0,0 +1,20 @@
+open Swig
+open Primitive_ref
+
+let _ =
+ assert (_ref_int '(3) as int = 3);
+ assert (_ref_short '(3) as int = 3);
+ assert (_ref_ushort '(3) as int = 3);
+ assert (_ref_long '(3) as int = 3);
+ assert (_ref_ulong '(3) as int = 3);
+ assert (_ref_schar '(3) as int = 3);
+ assert (_ref_uchar '(3) as int = 3);
+ assert (_ref_float '(3.5) as float = 3.5);
+ assert (_ref_double '(3.5) as float = 3.5);
+ assert (_ref_bool '(true) as bool = true);
+ let arg = C_char 'x' in
+ assert (_ref_char '(arg) as char = 'x');
+ assert (_ref_over '(0) as int = 0);
+ let a = new_A '(12) in
+ assert (_ref_over '(a) as int = 12);
+;;
diff --git a/Examples/test-suite/ocaml/reference_global_vars_runme.ml b/Examples/test-suite/ocaml/reference_global_vars_runme.ml
new file mode 100644
index 000000000..adde1b82e
--- /dev/null
+++ b/Examples/test-suite/ocaml/reference_global_vars_runme.ml
@@ -0,0 +1,57 @@
+open Swig
+open Reference_global_vars
+
+let _ =
+ let tc = _getconstTC '() in
+ assert (tc -> "[num]" () as int = 33);
+
+ let _ = _var_bool (_createref_bool (C_bool false)) in
+ assert (_value_bool (_var_bool '()) as bool = false);
+
+ let _ = _var_bool (_createref_bool (C_bool true)) in
+ assert (_value_bool (_var_bool '()) as bool = true);
+
+ let _ = _var_char (_createref_char (C_char 'w')) in
+ assert (_value_char (_var_char '()) as char = 'w');
+
+ let _ = _var_unsigned_char (_createref_unsigned_char (C_uchar 'w')) in
+ assert (_value_unsigned_char (_var_unsigned_char '()) as char = 'w');
+
+ let _ = _var_signed_char (_createref_signed_char (C_uchar 'w')) in
+ assert (_value_signed_char (_var_signed_char '()) as char = 'w');
+
+ let _ = _var_short (_createref_short (C_short 10)) in
+ assert (_value_short (_var_short '()) as int = 10);
+
+ let _ = _var_unsigned_short (_createref_unsigned_short (C_ushort 10)) in
+ assert (_value_unsigned_short (_var_unsigned_short '()) as int = 10);
+
+ let _ = _var_int (_createref_int (C_int 10)) in
+ assert (_value_int (_var_int '()) as int = 10);
+
+ let _ = _var_unsigned_int (_createref_unsigned_int (C_int 10)) in
+ assert (_value_unsigned_int (_var_unsigned_int '()) as int = 10);
+
+ let _ = _var_long (_createref_long (C_int64 10L)) in
+ assert (_value_long (_var_long '()) as int = 10);
+
+ let _ = _var_unsigned_long (_createref_unsigned_long (C_int64 10L)) in
+ assert (_value_unsigned_long (_var_unsigned_long '()) as int = 10);
+
+ let _ = _var_long_long (_createref_long_long (C_int64 0x6FFFFFFFFFFFFFF8L)) in
+ assert (_value_long_long (_var_long_long '()) = C_int64 0x6FFFFFFFFFFFFFF8L);
+
+ let _ = _var_unsigned_long_long (_createref_unsigned_long_long (C_int64 0x6FFFFFFFFFFFFFF8L)) in
+ assert (_value_unsigned_long_long (_var_unsigned_long_long '()) = C_int64 0x6FFFFFFFFFFFFFF8L);
+
+ let _ = _var_float (_createref_float (C_float 10.)) in
+ assert (_value_float (_var_float '()) as float = 10.);
+
+ let _ = _var_double (_createref_double (C_double 10.)) in
+ assert (_value_double (_var_double '()) as float = 10.);
+
+ let tc = new_TestClass '(20) in
+ let _ = _var_TestClass (_createref_TestClass (tc)) in
+ let tc = _value_TestClass (_var_TestClass '()) in
+ assert (tc -> "[num]" () as int = 20);
+;;
diff --git a/Examples/test-suite/ocaml/rename_predicates_runme.ml b/Examples/test-suite/ocaml/rename_predicates_runme.ml
new file mode 100644
index 000000000..984600207
--- /dev/null
+++ b/Examples/test-suite/ocaml/rename_predicates_runme.ml
@@ -0,0 +1,40 @@
+open Swig
+open Rename_predicates
+
+let _ =
+ let r = new_RenamePredicates '(123) in
+ assert (r -> MF_member_function () = C_void);
+ assert (_RenamePredicates_MF_static_member_function '() = C_void);
+ assert (r -> MF_member_function () = C_void);
+ assert (r -> MF_extend_function_before () = C_void);
+ assert (r -> MF_extend_function_after () = C_void);
+ assert (_GF_global_function '() = C_void);
+
+ assert (r -> "[MV_member_variable]" () as int = 123);
+ assert (r -> "[MV_member_variable]" (1234) = C_void);
+ assert (r -> "[MV_member_variable]" () as int = 1234);
+
+ assert (_RenamePredicates_MV_static_member_variable '() as int = 456);
+ assert (_RenamePredicates_MV_static_member_variable '(4567) as int = 4567);
+ assert (_RenamePredicates_MV_static_member_variable '() as int = 4567);
+
+ assert (_GV_global_variable '() as int = 789);
+ assert (_GV_global_variable '(7890) as int = 7890);
+ assert (_GV_global_variable '() as int = 7890);
+
+ assert (_UC_UPPERCASE '() = C_void);
+ assert (_LC_lowercase '() = C_void);
+ assert (_TI_Title '() = C_void);
+ assert (_FU_FirstUpperCase '() = C_void);
+ assert (_FL_firstLowerCase '() = C_void);
+ assert (_CA_CamelCase '() = C_void);
+ assert (_LC_lowerCamelCase '() = C_void);
+ assert (_UC_under_case_it '() = C_void);
+
+ let ex = new_ExtendCheck '() in
+ assert (ex -> MF_real_member1 () = C_void);
+ assert (ex -> MF_real_member2 () = C_void);
+ assert (ex -> EX_EXTENDMETHOD1 () = C_void);
+ assert (ex -> EX_EXTENDMETHOD2 () = C_void);
+ assert (ex -> EX_EXTENDMETHOD3 () = C_void)
+;;
diff --git a/Examples/test-suite/ocaml/sizet_runme.ml b/Examples/test-suite/ocaml/sizet_runme.ml
new file mode 100644
index 000000000..5f72459c9
--- /dev/null
+++ b/Examples/test-suite/ocaml/sizet_runme.ml
@@ -0,0 +1,10 @@
+open Swig
+open Sizet
+
+let _ =
+ let s = C_int64 2000L in
+ assert (_test1 '(s) as int = 2000);
+ assert (_test2 '(s) as int = 2000);
+ assert (_test3 '(s) as int = 2000);
+ assert (_test4 '(s) as int = 2000);
+;;
diff --git a/Examples/test-suite/ocaml/special_variable_macros_runme.ml b/Examples/test-suite/ocaml/special_variable_macros_runme.ml
new file mode 100644
index 000000000..7f4980ea3
--- /dev/null
+++ b/Examples/test-suite/ocaml/special_variable_macros_runme.ml
@@ -0,0 +1,14 @@
+open Swig
+open Special_variable_macros
+
+let _ =
+ let name = new_Name '() in
+ assert (_testFred '(name) as string = "none");
+ assert (_testJack '(name) as string = "$specialname");
+ assert (_testJill '(name) as string = "jilly");
+ assert (_testMary '(name) as string = "SWIGTYPE_p_NameWrap");
+ assert (_testJames '(name) as string = "SWIGTYPE_Name");
+ assert (_testJim '(name) as string = "multiname num");
+ let arg = new_PairIntBool '(10, false) in
+ assert (_testJohn '(arg) as int = 123);
+;;
diff --git a/Examples/test-suite/ocaml/special_variables_runme.ml b/Examples/test-suite/ocaml/special_variables_runme.ml
new file mode 100644
index 000000000..b569a54be
--- /dev/null
+++ b/Examples/test-suite/ocaml/special_variables_runme.ml
@@ -0,0 +1,36 @@
+open Swig
+open Special_variables
+
+let _ =
+ assert (_ExceptionVars '(1.0, 2.0) as string =
+ "result = Space::exceptionvars(arg1,arg2); Space::exceptionvars ExceptionVars _wrap_ExceptionVarsspecial_variables ");
+ assert (_overloadedmethod '() as string =
+ "result = Space::overloadedmethod(); Space::overloadedmethod overloadedmethod __SWIG_1 _wrap_overloadedmethod__SWIG_1special_variables ");
+ assert (_overloadedmethod '(10.0) as string =
+ "result = Space::overloadedmethod(arg1); Space::overloadedmethod overloadedmethod __SWIG_0 _wrap_overloadedmethod__SWIG_0special_variables ");
+
+ let _ = new_ABC '(0, 0.0) in
+ assert (_declaration '() as string = "SpaceNamespace::ABC::ABC(int,double) SpaceNamespace::ABC::ABC(int,double)");
+ let a = new_ABC '() in
+ assert (_declaration '() as string = "SpaceNamespace::ABC::ABC() SpaceNamespace::ABC::ABC()");
+ ignore (a -> instancemethod (1));
+ assert (_declaration '() as string = "short * SpaceNamespace::ABC::instancemethod(int) SpaceNamespace::ABC::instancemethod(int)");
+ ignore (a -> instancemethod (1, false));
+ assert (_declaration '() as string = "short * SpaceNamespace::ABC::instancemethod(int,bool) SpaceNamespace::ABC::instancemethod(int,bool)");
+ ignore (a -> constmethod (1));
+ assert (_declaration '() as string = "short * SpaceNamespace::ABC::constmethod(int) const SpaceNamespace::ABC::constmethod(int) const");
+ ignore (_ABC_staticmethod '(0, false));
+ assert (_declaration '() as string = "short * SpaceNamespace::ABC::staticmethod(int,bool) SpaceNamespace::ABC::staticmethod(int,bool)");
+ ignore (a -> "~" ());
+ assert (_declaration '() as string = "SpaceNamespace::ABC::~ABC() SpaceNamespace::ABC::~ABC()");
+ let abc = new_TemplateABC '() in
+ assert (_declaration '() as string = "SpaceNamespace::Template< SpaceNamespace::ABC >::Template() SpaceNamespace::Template< SpaceNamespace::ABC >::Template()");
+ let arg = new_ABC '() in
+ ignore (abc -> tmethod (arg));
+ assert (_declaration '() as string = "std::string SpaceNamespace::Template< SpaceNamespace::ABC >::tmethod(SpaceNamespace::ABC) SpaceNamespace::Template< SpaceNamespace::ABC >::tmethod(SpaceNamespace::ABC)");
+ ignore (abc -> "~" ());
+ assert (_declaration '() as string = "SpaceNamespace::Template< SpaceNamespace::ABC >::~Template() SpaceNamespace::Template< SpaceNamespace::ABC >::~Template()");
+ let arg = new_TemplateABC '() in
+ ignore (_globtemplate (arg));
+ assert (_declaration '() as string = "void SpaceNamespace::globtemplate(SpaceNamespace::Template< SpaceNamespace::ABC >) SpaceNamespace::globtemplate(SpaceNamespace::Template< SpaceNamespace::ABC >)");
+;;
diff --git a/Examples/test-suite/ocaml/static_const_member_runme.ml b/Examples/test-suite/ocaml/static_const_member_runme.ml
new file mode 100644
index 000000000..02dd2fe4b
--- /dev/null
+++ b/Examples/test-suite/ocaml/static_const_member_runme.ml
@@ -0,0 +1,9 @@
+open Swig
+open Static_const_member
+
+let _ =
+ assert (_X_PN '() as int = 0);
+ assert (_X_CN '() as int = 1);
+ assert (_X_EN '() as int = 2);
+ assert (_X_CHARTEST '() as char = 'A');
+;;
diff --git a/Examples/test-suite/ocaml/string_simple_runme.ml b/Examples/test-suite/ocaml/string_simple_runme.ml
new file mode 100644
index 000000000..327fb85d2
--- /dev/null
+++ b/Examples/test-suite/ocaml/string_simple_runme.ml
@@ -0,0 +1,9 @@
+open Swig
+open String_simple
+
+let str = "olé"
+
+let copy = _copy_str (C_string str) as string
+
+let _ = if str <> copy then
+ raise (Failure ("Error: copy is not equal: original="^str^", copy="^copy))
diff --git a/Examples/test-suite/ocaml/struct_value_runme.ml b/Examples/test-suite/ocaml/struct_value_runme.ml
new file mode 100644
index 000000000..73688bef3
--- /dev/null
+++ b/Examples/test-suite/ocaml/struct_value_runme.ml
@@ -0,0 +1,11 @@
+open Swig
+open Struct_value
+
+let b = new_Bar (C_void)
+let a = (invoke b) "[a]" (C_void)
+let _ = (invoke a) "[x]" (C_int 3)
+let _ = assert((invoke a) "[x]" (C_void) = C_int 3)
+
+let bb = (invoke b) "[b]" (C_void)
+let _ = (invoke bb) "[x]" (C_int 3)
+let _ = assert((invoke bb) "[x]" (C_void) = C_int 3)
diff --git a/Examples/test-suite/ocaml/swig_exception_runme.ml b/Examples/test-suite/ocaml/swig_exception_runme.ml
new file mode 100644
index 000000000..5bf36c36f
--- /dev/null
+++ b/Examples/test-suite/ocaml/swig_exception_runme.ml
@@ -0,0 +1,13 @@
+open Swig
+open Swig_exception
+
+let _ =
+ let c = new_Circle '(10) and s = new_Square '(10) in
+ assert (_Shape_nshapes '() as int = 2);
+ try
+ ignore (c -> throwException ()); assert false
+ with Sys_error msg -> assert (msg = "OK");
+ let _ = c -> "~" () in
+ let _ = s -> "~" () in
+ assert (_Shape_nshapes '() as int = 0);
+;;
diff --git a/Examples/test-suite/ocaml/template_default_arg_overloaded_extend_runme.ml b/Examples/test-suite/ocaml/template_default_arg_overloaded_extend_runme.ml
new file mode 100644
index 000000000..27fb9b543
--- /dev/null
+++ b/Examples/test-suite/ocaml/template_default_arg_overloaded_extend_runme.ml
@@ -0,0 +1,17 @@
+open Swig
+open Template_default_arg_overloaded_extend
+
+let _ =
+ let rs = new_ResultSet '() and sp = new_SearchPoint '() in
+ assert (rs -> go_get_method (0, sp) as int = -1);
+ assert (rs -> go_get_method (0, sp, 100) as int = 100);
+ assert (rs -> go_get_template (0, sp) as int = -2);
+ assert (rs -> go_get_template (0, sp, 100) as int = 100);
+
+ assert (rs -> over () as string = "over(int)");
+ assert (rs -> over (10) as string = "over(int)");
+ assert (rs -> over (sp) as string = "over(giai2::SearchPoint, int)");
+ assert (rs -> over (sp, 10) as string = "over(giai2::SearchPoint, int)");
+ assert (rs -> over (true, sp) as string = "over(bool, gaia2::SearchPoint, int)");
+ assert (rs -> over (true, sp, 10) as string = "over(bool, gaia2::SearchPoint, int)");
+;;
diff --git a/Examples/test-suite/ocaml/template_default_arg_runme.ml b/Examples/test-suite/ocaml/template_default_arg_runme.ml
new file mode 100644
index 000000000..94f2291f1
--- /dev/null
+++ b/Examples/test-suite/ocaml/template_default_arg_runme.ml
@@ -0,0 +1,52 @@
+open Swig
+open Template_default_arg
+
+let _ =
+ let helloInt = new_Hello_int '() and enumArg = _hi '() in
+ assert (helloInt -> foo (enumArg) = C_void);
+ assert (helloInt -> foo () = C_void);
+
+ let x = new_X_int '() in
+ assert (x -> meth (20.0, 200) as int = 200);
+ assert (x -> meth (20) as int = 20);
+ assert (x -> meth () as int = 0);
+
+ let x = new_Y_unsigned '() in
+ let args = C_list [ C_double 20.0 ; C_uint 200l ] in
+ assert (x -> meth (args) as int = 200);
+ let args = C_uint 20l in
+ assert (x -> meth (args) as int = 20);
+ assert (x -> meth () as int = 0);
+
+ let x = new_X_longlong '() in
+ assert (x -> meth (20.0) as int = 0);
+ let x = new_X_longlong '(20.0) in
+ assert (x -> meth (20.0) as int = 0);
+ let args = C_list [ C_double 20.0 ; C_int64 200L ] in
+ let x = new_X_longlong '(args) in
+ assert (x -> meth (20.0) as int = 0);
+
+ let x = new_X_int '() in
+ assert (x -> meth (20.0) as int = 0);
+ let x = new_X_int '(20.0) in
+ assert (x -> meth (20.0) as int = 0);
+ let x = new_X_int '(20.0, 200) in
+ assert (x -> meth (20.0) as int = 0);
+
+ let arg = new_Foo_int '() in
+ assert (_ott '(arg) as int = 30);
+ assert (_ott '() as int = 10);
+ assert (_ott '(1) as int = 10);
+ assert (_ott '(1, 1) as int = 10);
+ assert (_ott '("hi") as int = 20);
+ assert (_ott '("hi", 1) as int = 20);
+ assert (_ott '("hi", 1, 1) as int = 20);
+
+ let arg = new_Hello_int '() in
+ assert (_ottstring '(arg, "hi") as int = 40);
+ assert (_ottstring '(arg) as int = 40);
+ assert (_ottint '(arg, 1) as int = 50);
+ assert (_ottint '(arg) as int = 50);
+ assert (_ott '(arg, 1.0) as int = 60);
+ assert (_ott '(arg) as int = 60);
+;;
diff --git a/Examples/test-suite/ocaml/template_extend1_runme.ml b/Examples/test-suite/ocaml/template_extend1_runme.ml
new file mode 100644
index 000000000..b9b5a67d6
--- /dev/null
+++ b/Examples/test-suite/ocaml/template_extend1_runme.ml
@@ -0,0 +1,8 @@
+open Swig
+open Template_extend1
+
+let _ =
+ let a = new_lBaz '() and b = new_dBaz '() in
+ assert (a -> foo () as string = "lBaz::foo");
+ assert (b -> foo () as string = "dBaz::foo")
+;;
diff --git a/Examples/test-suite/ocaml/template_extend2_runme.ml b/Examples/test-suite/ocaml/template_extend2_runme.ml
new file mode 100644
index 000000000..67f260f87
--- /dev/null
+++ b/Examples/test-suite/ocaml/template_extend2_runme.ml
@@ -0,0 +1,8 @@
+open Swig
+open Template_extend2
+
+let _ =
+ let a = new_lBaz '() and b = new_dBaz '() in
+ assert (a -> foo () as string = "lBaz::foo");
+ assert (b -> foo () as string = "dBaz::foo")
+;;
diff --git a/Examples/test-suite/ocaml/template_inherit_runme.ml b/Examples/test-suite/ocaml/template_inherit_runme.ml
new file mode 100644
index 000000000..1f3761cd2
--- /dev/null
+++ b/Examples/test-suite/ocaml/template_inherit_runme.ml
@@ -0,0 +1,22 @@
+open Swig
+open Template_inherit
+
+let _ =
+ let a = new_FooInt '() and b = new_FooDouble '() and c = new_BarInt '()
+ and d = new_BarDouble '() and e = new_FooUInt '() and f = new_BarUInt '() in
+ assert (a -> blah () as string = "Foo");
+ assert (b -> blah () as string = "Foo");
+ assert (e -> blah () as string = "Foo");
+ assert (c -> blah () as string = "Bar");
+ assert (d -> blah () as string = "Bar");
+ assert (f -> blah () as string = "Bar");
+ assert (c -> foomethod () as string = "foomethod");
+ assert (d -> foomethod () as string = "foomethod");
+ assert (f -> foomethod () as string = "foomethod");
+ assert (_invoke_blah_int '(a) as string = "Foo");
+ assert (_invoke_blah_int '(c) as string = "Bar");
+ assert (_invoke_blah_double '(b) as string = "Foo");
+ assert (_invoke_blah_double '(d) as string = "Bar");
+ assert (_invoke_blah_uint '(e) as string = "Foo");
+ assert (_invoke_blah_uint '(f) as string = "Bar")
+;;
diff --git a/Examples/test-suite/ocaml/template_opaque_runme.ml b/Examples/test-suite/ocaml/template_opaque_runme.ml
new file mode 100644
index 000000000..cb9e18905
--- /dev/null
+++ b/Examples/test-suite/ocaml/template_opaque_runme.ml
@@ -0,0 +1,5 @@
+open Swig
+open Template_opaque
+
+let v = new_OpaqueVectorType (C_uint 10l)
+let _ = _FillVector '(v)
diff --git a/Examples/test-suite/ocaml/template_ref_type_runme.ml b/Examples/test-suite/ocaml/template_ref_type_runme.ml
new file mode 100644
index 000000000..2db2f9b28
--- /dev/null
+++ b/Examples/test-suite/ocaml/template_ref_type_runme.ml
@@ -0,0 +1,6 @@
+open Swig
+open Template_ref_type
+
+let xr = new_XC '()
+let y = new_Y '()
+let _ = y -> find (xr)
diff --git a/Examples/test-suite/ocaml/template_rename_runme.ml b/Examples/test-suite/ocaml/template_rename_runme.ml
new file mode 100644
index 000000000..be19aa107
--- /dev/null
+++ b/Examples/test-suite/ocaml/template_rename_runme.ml
@@ -0,0 +1,12 @@
+open Swig
+open Template_rename
+
+let _ =
+ let i = new_iFoo '() and d = new_dFoo '() in
+ assert (i -> blah_test (4) as int = 4);
+ assert (i -> spam_test (5) as int = 5);
+ assert (i -> groki_test (6) as int = 6);
+ assert (d -> blah_test (7) as int = 7);
+ assert (d -> spam (8) as int = 8);
+ assert (d -> grok_test (9) as int = 9)
+;;
diff --git a/Examples/test-suite/ocaml/template_tbase_template_runme.ml b/Examples/test-suite/ocaml/template_tbase_template_runme.ml
new file mode 100644
index 000000000..724776a24
--- /dev/null
+++ b/Examples/test-suite/ocaml/template_tbase_template_runme.ml
@@ -0,0 +1,5 @@
+open Swig
+open Template_tbase_template
+
+let a = _make_Class_dd '()
+assert (a -> test () as string = "test")
diff --git a/Examples/test-suite/ocaml/throw_exception_runme.ml b/Examples/test-suite/ocaml/throw_exception_runme.ml
index 8781926b6..5c4c0922a 100644
--- a/Examples/test-suite/ocaml/throw_exception_runme.ml
+++ b/Examples/test-suite/ocaml/throw_exception_runme.ml
@@ -1,28 +1,25 @@
-(* Throw exception test *)
-
open Swig
open Throw_exception
-let x = new_Foo C_void ;;
-let _ =
- try
- (invoke x) "test_int" C_void
- with (Failure "Exception(37): Thrown exception from C++ (int)\n") ->
- try
- (invoke x) "test_msg" C_void
- with (Failure "Exception(0): Dead\n") ->
- try
- (invoke x) "test_cls" C_void
- with (Failure "Exception(0): Thrown exception from C++ (unknown)\n") ->
- try
- (invoke x) "test_multi" (C_int 1)
- with (Failure "Exception(37): Thrown exception from C++ (int)\n") ->
- try
- (invoke x) "test_multi" (C_int 2)
- with (Failure "Exception(0): Dead\n") ->
+let x = new_Foo '()
+
+let check meth args expected =
try
- (invoke x) "test_multi" (C_int 3)
- with (Failure "Exception(0): Thrown exception from C++ (unknown)\n") ->
- exit 0
+ let _ = ((invoke x) meth (args)) in assert false
+ with Failure msg -> assert (msg = expected)
-let _ = exit 1
+let _ =
+ check "test_int" '() "C++ int exception thrown, value: 37";
+ check "test_msg" '() "Dead";
+ check "test_cls" '() "C++ CError exception thrown";
+ check "test_cls_ptr" '() "C++ CError * exception thrown";
+ check "test_cls_ref" '() "C++ CError & exception thrown";
+ check "test_cls_td" '() "C++ Namespace::ErrorTypedef exception thrown";
+ check "test_cls_ptr_td" '() "C++ Namespace::ErrorPtr exception thrown";
+ check "test_cls_ref_td" '() "C++ Namespace::ErrorRef exception thrown";
+ check "test_array" '() "C++ int [10] exception thrown";
+ check "test_enum" '() "C++ Namespace::EnumTest exception thrown";
+ check "test_multi" '(1) "C++ int exception thrown, value: 37";
+ check "test_multi" '(2) "Dead";
+ check "test_multi" '(3) "C++ CError exception thrown";
+;;
diff --git a/Examples/test-suite/ocaml/typedef_class_runme.ml b/Examples/test-suite/ocaml/typedef_class_runme.ml
new file mode 100644
index 000000000..969c3e420
--- /dev/null
+++ b/Examples/test-suite/ocaml/typedef_class_runme.ml
@@ -0,0 +1,13 @@
+open Swig
+open Typedef_class
+
+let a = new_RealA '()
+let _ = a -> "[a]" (3)
+
+let b = new_B '()
+let _ = assert (b -> testA (a) as int = 3)
+
+let bb = new_BB '()
+let bb2 = new_BB '(2)
+let _ = assert (bb -> aa_method (1.) as int = 0)
+let bbb = new_BBB '()
diff --git a/Examples/test-suite/ocaml/typedef_classforward_same_name_runme.ml b/Examples/test-suite/ocaml/typedef_classforward_same_name_runme.ml
new file mode 100644
index 000000000..304f74b7a
--- /dev/null
+++ b/Examples/test-suite/ocaml/typedef_classforward_same_name_runme.ml
@@ -0,0 +1,11 @@
+open Swig
+open Typedef_classforward_same_name
+
+let _ =
+ let foo = new_Foo '() in
+ ignore (foo -> "[x]" (5));
+ assert (_extractFoo '(foo) as int = 5);
+ let boo = new_Boo '() in
+ ignore (boo -> "[x]" (5));
+ assert (_extractBoo '(boo) as int = 5)
+;;
diff --git a/Examples/test-suite/ocaml/typedef_inherit_runme.ml b/Examples/test-suite/ocaml/typedef_inherit_runme.ml
new file mode 100644
index 000000000..6352fd4ad
--- /dev/null
+++ b/Examples/test-suite/ocaml/typedef_inherit_runme.ml
@@ -0,0 +1,11 @@
+open Swig
+open Typedef_inherit
+
+let _ =
+ let a = new_Foo '() and b = new_Bar '() in
+ assert (_do_blah (a) as string = "Foo::blah");
+ assert (_do_blah (b) as string = "Bar::blah");
+ let c = new_Spam '() and d = new_Grok '() in
+ assert (_do_blah2 (c) as string = "Spam::blah");
+ assert (_do_blah2 (d) as string = "Grok::blah")
+;;
diff --git a/Examples/test-suite/ocaml/typedef_mptr_runme.ml b/Examples/test-suite/ocaml/typedef_mptr_runme.ml
index 3bdaac4ba..36aafe695 100644
--- a/Examples/test-suite/ocaml/typedef_mptr_runme.ml
+++ b/Examples/test-suite/ocaml/typedef_mptr_runme.ml
@@ -1,16 +1,13 @@
open Swig
open Typedef_mptr
-let soci x = (string_of_int (get_int x))
-
-let x = new_Foo C_void
-let add_res = _do_op (C_list [ x ; C_int 2 ; C_int 1 ; _add ])
-and sub_res = _do_op (C_list [ x ; C_int 2 ; C_int 1 ; _sub ])
let _ =
- if add_res <> (C_int 3) || sub_res <> (C_int 1) then
- raise (Failure ("Bad result:" ^
- " (add " ^ (soci add_res) ^ ") " ^
- " (sub " ^ (soci sub_res) ^ ")"))
-let _ = Printf.printf "2 + 1 = %d, 2 - 1 = %d\n"
- (get_int add_res)
- (get_int sub_res)
+ let f = new_Foo '() in
+ let args = C_list [ C_int 2 ; C_int 1 ; _add '() ] in
+ assert (f -> do_op (args) as int = 3);
+ let args = C_list [ C_int 2 ; C_int 1 ; _sub '() ] in
+ assert (f -> do_op (args) as int = 1);
+
+ assert (_do_op (C_list [ f ; C_int 2 ; C_int 1 ; _add '() ]) = C_int 3);
+ assert (_do_op (C_list [ f ; C_int 2 ; C_int 1 ; _sub '() ]) = C_int 1);
+;;
diff --git a/Examples/test-suite/ocaml/typedef_reference_runme.ml b/Examples/test-suite/ocaml/typedef_reference_runme.ml
new file mode 100644
index 000000000..4c9cc6fca
--- /dev/null
+++ b/Examples/test-suite/ocaml/typedef_reference_runme.ml
@@ -0,0 +1,11 @@
+open Swig
+open Typedef_reference
+
+let _ =
+ let i = _copy_intp '(2) in
+ assert (_somefunc '(i) as int = 2);
+ assert (_delete_intp '(i) = C_void);
+ let i = _copy_intp '(3) in
+ assert (_otherfunc '(i) as int = 3);
+ assert (_delete_intp '(i) = C_void);
+;;
diff --git a/Examples/test-suite/ocaml/typemap_arrays_runme.ml b/Examples/test-suite/ocaml/typemap_arrays_runme.ml
new file mode 100644
index 000000000..611e1d338
--- /dev/null
+++ b/Examples/test-suite/ocaml/typemap_arrays_runme.ml
@@ -0,0 +1,4 @@
+open Swig
+open Typemap_arrays
+
+let _ = assert (_sumA '(0) as int = 60)
diff --git a/Examples/test-suite/ocaml/typemap_delete_runme.ml b/Examples/test-suite/ocaml/typemap_delete_runme.ml
new file mode 100644
index 000000000..0cffb025b
--- /dev/null
+++ b/Examples/test-suite/ocaml/typemap_delete_runme.ml
@@ -0,0 +1,5 @@
+open Swig
+open Typemap_delete
+
+let r = new_Rect '(123)
+let _ = assert (r -> "[val]" () as int = 123)
diff --git a/Examples/test-suite/ocaml/types_directive_runme.ml b/Examples/test-suite/ocaml/types_directive_runme.ml
new file mode 100644
index 000000000..8503d00ff
--- /dev/null
+++ b/Examples/test-suite/ocaml/types_directive_runme.ml
@@ -0,0 +1,14 @@
+open Swig
+open Types_directive
+
+let _ =
+ (* Check that a Time1 instance is accepted where a Date instance is expected. *)
+ let d1 = new_Time1 '(2001, 2, 3, 60) in
+ let newDate = _add '(d1, 7) in
+ assert (newDate -> "[day]" () as int = 10);
+
+ (* Check that a Time2 instance is accepted where a Date instance is expected. *)
+ let d2 = new_Time2 '(1999, 8, 7, 60) in
+ let newDate = _add '(d2, 7) in
+ assert (newDate -> "[day]" () as int = 14)
+;;
diff --git a/Examples/test-suite/ocaml/unions_runme.ml b/Examples/test-suite/ocaml/unions_runme.ml
index cbf1628ac..c451cb2be 100644
--- a/Examples/test-suite/ocaml/unions_runme.ml
+++ b/Examples/test-suite/ocaml/unions_runme.ml
@@ -8,21 +8,21 @@ let b = new_BigStruct C_void
let c = new_UnionTest C_void
let d = new_EmbeddedUnionTest C_void
-let _ = (invoke a) "jill" (C_short 3)
-let _ = (invoke b) "jack" (C_char 'a') (* Int conversion *)
-let _ = (invoke b) "smallstruct" a (* Put a in b *)
-let _ = (invoke c) "bs" b
+let _ = (invoke a) "[jill]" (C_short 3)
+let _ = (invoke b) "[jack]" (C_char 'a') (* Int conversion *)
+let _ = (invoke b) "[smallstruct]" a (* Put a in b *)
+let _ = (invoke c) "[bs]" b
-let _ = if get_int ((invoke a) "jill" C_void) != 3 then
+let _ = if get_int ((invoke a) "[jill]" C_void) != 3 then
raise (Failure "jill value is not preserved")
-let _ = if get_int ((invoke b) "jack" C_void) != (int_of_char 'a') then
+let _ = if get_int ((invoke b) "[jack]" C_void) != (int_of_char 'a') then
raise (Failure "jack value is not preserved")
-let _ = if get_int ((invoke ((invoke b) "smallstruct" C_void))
- "jill" C_void) != 3 then
+let _ = if get_int ((invoke ((invoke b) "[smallstruct]" C_void))
+ "[jill]" C_void) != 3 then
raise (Failure "jill value is not embedded in bigstruct")
-let _ = if get_int ((invoke ((invoke c) "bs" C_void))
- "jack" C_void) != (int_of_char 'a') then
+let _ = if get_int ((invoke ((invoke c) "[bs]" C_void))
+ "[jack]" C_void) != (int_of_char 'a') then
raise (Failure "union set of bigstruct did not take")
-let _ = if get_int ((invoke ((invoke c) "ss" C_void))
- "jill" C_void) != (int_of_char 'a') then
+let _ = if get_int ((invoke ((invoke c) "[ss]" C_void))
+ "[jill]" C_void) != (int_of_char 'a') then
raise (Failure "corresponding union values are not the same")
diff --git a/Examples/test-suite/ocaml/using1_runme.ml b/Examples/test-suite/ocaml/using1_runme.ml
new file mode 100644
index 000000000..defda603c
--- /dev/null
+++ b/Examples/test-suite/ocaml/using1_runme.ml
@@ -0,0 +1,4 @@
+open Swig
+open Using1
+
+let _ = assert (_spam '(37) as int = 37)
diff --git a/Examples/test-suite/ocaml/using_extend_runme.ml b/Examples/test-suite/ocaml/using_extend_runme.ml
new file mode 100644
index 000000000..0b7c57f65
--- /dev/null
+++ b/Examples/test-suite/ocaml/using_extend_runme.ml
@@ -0,0 +1,12 @@
+open Swig
+open Using_extend
+
+let _ =
+ let f = new_FooBar '() in
+ assert (f -> blah (3) as int = 3);
+ assert (f -> blah (3.5) as float = 3.5);
+ assert (f -> blah ("hello") as string = "hello");
+ assert (f -> blah (3, 4) as int = 7);
+ assert (f -> blah (3.5, 7.5) as float = 11.);
+ assert (f -> duh (3) as int = 3)
+;;
diff --git a/Examples/test-suite/ocaml/using_inherit_runme.ml b/Examples/test-suite/ocaml/using_inherit_runme.ml
new file mode 100644
index 000000000..2c49c5e6f
--- /dev/null
+++ b/Examples/test-suite/ocaml/using_inherit_runme.ml
@@ -0,0 +1,24 @@
+open Swig
+open Using_inherit
+
+let _ =
+ let b = new_Bar '() in
+ assert (b -> test (3) as int = 3);
+ assert (b -> test (3.5) as float = 3.5);
+ let b = new_Bar2 '() in
+ assert (b -> test (3) as int = 6);
+ assert (b -> test (3.5) as float = 7.0);
+ let b = new_Bar3 '() in
+ assert (b -> test (3) as int = 6);
+ assert (b -> test (3.5) as float = 7.0);
+ let b = new_Bar4 '() in
+ assert (b -> test (3) as int = 6);
+ assert (b -> test (3.5) as float = 7.0);
+
+ let f = new_Fred1 '() in
+ assert (f -> test (3) as int = 3);
+ assert (f -> test (3.5) as float = 7.0);
+ let f = new_Fred2 '() in
+ assert (f -> test (3) as int = 3);
+ assert (f -> test (3.5) as float = 7.0)
+;;
diff --git a/Examples/test-suite/ocaml/using_pointers_runme.ml b/Examples/test-suite/ocaml/using_pointers_runme.ml
new file mode 100644
index 000000000..98fd3fb48
--- /dev/null
+++ b/Examples/test-suite/ocaml/using_pointers_runme.ml
@@ -0,0 +1,10 @@
+open Swig
+open Using_pointers
+
+let f = new_FooBar '()
+try
+ ignore (f -> exception_spec (1)); assert false
+with Failure _ -> ()
+try
+ ignore (f -> exception_spec (2)); assert false
+with Failure _ -> ()
diff --git a/Examples/test-suite/ocaml/using_private_runme.ml b/Examples/test-suite/ocaml/using_private_runme.ml
new file mode 100644
index 000000000..026cbfd91
--- /dev/null
+++ b/Examples/test-suite/ocaml/using_private_runme.ml
@@ -0,0 +1,10 @@
+open Swig
+open Using_private
+
+let _ =
+ let f = new_FooBar '() in
+ let _ = f -> "[x]" (3) in
+ assert (f -> blah (4) as int = 4);
+ assert (f -> defaulted () as int = -1);
+ assert (f -> defaulted (222) as int = 222)
+;;
diff --git a/Examples/test-suite/ocaml/using_protected_runme.ml b/Examples/test-suite/ocaml/using_protected_runme.ml
index 4dc4fe1c9..29647c288 100644
--- a/Examples/test-suite/ocaml/using_protected_runme.ml
+++ b/Examples/test-suite/ocaml/using_protected_runme.ml
@@ -2,7 +2,7 @@ open Swig
open Using_protected
let f = new_FooBar C_void
-let _ = (invoke f) "x" (C_int 3)
+let _ = (invoke f) "[x]" (C_int 3)
let _ = if (invoke f) "blah" (C_int 4) <> (C_int 4) then
raise (Failure "blah(int)")
diff --git a/Examples/test-suite/ocaml/valuewrapper_runme.ml b/Examples/test-suite/ocaml/valuewrapper_runme.ml
new file mode 100644
index 000000000..0e2d73136
--- /dev/null
+++ b/Examples/test-suite/ocaml/valuewrapper_runme.ml
@@ -0,0 +1,8 @@
+open Swig
+open Valuewrapper
+
+let _ =
+ let x1 = new_Xi '(5) and y1 = new_YXi '() in
+ assert (y1 -> spam (x1) as int = 0);
+ assert (y1 -> spam () as int = 0)
+;;
diff --git a/Examples/test-suite/ocaml/varargs_overload_runme.ml b/Examples/test-suite/ocaml/varargs_overload_runme.ml
new file mode 100644
index 000000000..418f881e3
--- /dev/null
+++ b/Examples/test-suite/ocaml/varargs_overload_runme.ml
@@ -0,0 +1,29 @@
+open Swig
+open Varargs_overload
+
+let _ =
+ assert (_vararg_over1 '("Hello") as string = "Hello");
+ assert (_vararg_over1 '(2) as string = "2");
+ assert (_vararg_over2 '("Hello") as string = "Hello");
+ assert (_vararg_over2 '(2, 2.2) as string = "2 2.2");
+
+ assert (_vararg_over3 '("Hello") as string = "Hello");
+ assert (_vararg_over3 '(2, 2.2, "hey") as string = "2 2.2 hey");
+ assert (_vararg_over4 '("Hello") as string = "Hello");
+ assert (_vararg_over4 '(123) as string = "123");
+ assert (_vararg_over4 '("Hello", 123) as string = "Hello");
+
+
+ (* Same as above but non-vararg function declared first *)
+
+ assert (_vararg_over6 '("Hello") as string = "Hello");
+ assert (_vararg_over6 '(2) as string = "2");
+ assert (_vararg_over7 '("Hello") as string = "Hello");
+ assert (_vararg_over7 '(2, 2.2) as string = "2 2.2");
+
+ assert (_vararg_over8 '("Hello") as string = "Hello");
+ assert (_vararg_over8 '(2, 2.2, "hey") as string = "2 2.2 hey");
+ assert (_vararg_over9 '("Hello") as string = "Hello");
+ assert (_vararg_over9 '(123) as string = "123");
+ assert (_vararg_over9 '("Hello", 123) as string = "Hello");
+;;
diff --git a/Examples/test-suite/ocaml/wrapmacro_runme.ml b/Examples/test-suite/ocaml/wrapmacro_runme.ml
new file mode 100644
index 000000000..f11136360
--- /dev/null
+++ b/Examples/test-suite/ocaml/wrapmacro_runme.ml
@@ -0,0 +1,10 @@
+open Swig
+open Wrapmacro
+
+let _ =
+ let args = C_list [ C_int64 2L ; C_int64 1L ] in
+ assert (_maximum '(args) as int = 2);
+ let args = C_list [ C_double (2. /. 7.) ; C_double 256. ] in
+ assert (_maximum '(args) as float = 256.);
+ assert (_GUINT16_SWAP_LE_BE_CONSTANT '(0x1234) as int = 0x3412);
+;;
diff --git a/Examples/test-suite/octave/Makefile.in b/Examples/test-suite/octave/Makefile.in
index be47904e2..9602d85f5 100644
--- a/Examples/test-suite/octave/Makefile.in
+++ b/Examples/test-suite/octave/Makefile.in
@@ -5,6 +5,7 @@
LANGUAGE = octave
OCTAVE = @OCTAVE@
SCRIPTSUFFIX = _runme.m
+PCHSUPPORT = @PCHSUPPORT@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
@@ -16,20 +17,18 @@ CPP_TEST_CASES += \
octave_cell_deref\
octave_dim
+CPP11_TEST_CASES += \
+ cpp11_shared_ptr_const \
+ cpp11_shared_ptr_nullptr_in_containers \
+ cpp11_shared_ptr_overload \
+ cpp11_shared_ptr_upcast \
+
CPP_TEST_BROKEN += \
implicittest \
li_implicit \
li_std_set \
li_std_stream
-#C_TEST_CASES +=
-
-#
-# This test only works with modern C compilers
-#
-#C_TEST_CASES += \
-# complextest
-
include $(srcdir)/../common.mk
# Overridden variables here
@@ -55,11 +54,28 @@ CSRCS = octave_empty.c
+$(swig_and_compile_multi_cpp)
$(run_testcase)
+# Pre-compile Octave headers, if supported
+
+ifeq (yes,$(PCHSUPPORT))
+
+export OCTHEADERSSRC = @top_srcdir@/Lib/octave/octheaders.hpp
+export OCTHEADERS = @top_builddir@/Examples/test-suite/octave/octheaders.hpp
+export OCTHEADERSGCH = $(OCTHEADERS).gch
+export SWIGOCTHDROPT = -DSWIG_OCTAVE_EXTERNAL_OCTHEADERS
+export IOCTHEADERS = -I@top_builddir@/Examples/test-suite/octave @PCHINCLUDEARG@ $(OCTHEADERS)@PCHINCLUDEEXT@
+
+$(OCTHEADERSGCH): $(OCTHEADERSSRC)
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile octave_precompile_headers
+
+$(NOT_BROKEN_TEST_CASES) $(BROKEN_TEST_CASES): $(OCTHEADERSGCH)
+
+endif
+
# Runs the testcase. A testcase is only run if
# a file is found which has _runme.m appended after the testcase name.
run_testcase = \
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
- env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH OCTAVE_PATH=$(srcdir):$$OCTAVE_PATH $(RUNTOOL) $(OCTAVE) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH OCTAVE_PATH=$(srcdir) OCTAVE_HISTFILE=/dev/null $(RUNTOOL) $(OCTAVE) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
fi
# Clean: remove the generated .m file
@@ -70,20 +86,6 @@ run_testcase = \
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' octave_clean
-cvsignore:
- @echo '*wrap* *.mc *.so *.dll *.exp *.lib'
- @echo Makefile
- @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do echo $$i.m; done
- @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do if grep -q $${i}_runme.m CVS/Entries ; then echo $${i}_runme.m; fi; done
- @echo clientdata_prop_a.m
- @echo clientdata_prop_b.m
- @echo imports_a.m
- @echo imports_b.m
- @echo mod_a.m mod_b.m
- @echo hugemod.h hugemod_a.i hugemod_b.i hugemod_a.m hugemod_b.m hugemod_runme.m
- @echo template_typedef_import.m
-
-
hugemod:
perl hugemod.pl
$(MAKE) hugemod_a.cpptest
diff --git a/Examples/test-suite/octave/abstract_access_runme.m b/Examples/test-suite/octave/abstract_access_runme.m
index e49343a92..e47223c47 100644
--- a/Examples/test-suite/octave/abstract_access_runme.m
+++ b/Examples/test-suite/octave/abstract_access_runme.m
@@ -2,6 +2,6 @@ abstract_access
d = abstract_access.D();
if (d.do_x() != 1)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/abstract_typedef_runme.m b/Examples/test-suite/octave/abstract_typedef_runme.m
index e57f71504..6f90b8159 100644
--- a/Examples/test-suite/octave/abstract_typedef_runme.m
+++ b/Examples/test-suite/octave/abstract_typedef_runme.m
@@ -10,7 +10,7 @@ a = A();
if (a.write(e) != 1)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/callback_runme.m b/Examples/test-suite/octave/callback_runme.m
index db9f7888d..95df598f1 100644
--- a/Examples/test-suite/octave/callback_runme.m
+++ b/Examples/test-suite/octave/callback_runme.m
@@ -2,39 +2,39 @@ _callback
callback
if (foo(2) != 2)
- error
+ error("failed");
endif
if (A_bar(2) != 4)
- error
+ error("failed");
endif
if (foobar(3, _callback.foo) != foo(3))
- error
+ error("failed");
endif
if (foobar(3, foo) != foo(3))
- error
+ error("failed");
endif
if (foobar(3, A_bar) != A_bar(3))
- error
+ error("failed");
endif
if (foobar(3, foof) != foof(3))
- error
+ error("failed");
endif
if (foobar_i(3, foo_i) != foo_i(3))
- error
+ error("failed");
endif
if (foobar_d(3.5, foo_d) != foo_d(3.5))
- error
+ error("failed");
endif
a = A();
if (foobarm(3, a, A.foom_cb_ptr) != a.foom(3))
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/class_ignore_runme.m b/Examples/test-suite/octave/class_ignore_runme.m
index 3e52047c2..53cad9570 100644
--- a/Examples/test-suite/octave/class_ignore_runme.m
+++ b/Examples/test-suite/octave/class_ignore_runme.m
@@ -8,5 +8,5 @@ class_ignore
a = class_ignore.Bar();
if (!strcmp(class_ignore.do_blah(a),"Bar::blah"))
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/class_scope_weird_runme.m b/Examples/test-suite/octave/class_scope_weird_runme.m
index 2fc857808..b0e975359 100644
--- a/Examples/test-suite/octave/class_scope_weird_runme.m
+++ b/Examples/test-suite/octave/class_scope_weird_runme.m
@@ -3,5 +3,5 @@ class_scope_weird
f = class_scope_weird.Foo();
g = class_scope_weird.Foo(3);
if (f.bar(3) != 3)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/compactdefaultargs_runme.m b/Examples/test-suite/octave/compactdefaultargs_runme.m
index 08e872724..ada60dcbe 100644
--- a/Examples/test-suite/octave/compactdefaultargs_runme.m
+++ b/Examples/test-suite/octave/compactdefaultargs_runme.m
@@ -4,21 +4,21 @@ defaults1 = Defaults1(1000);
defaults1 = Defaults1();
if (defaults1.ret(10.0) != 10.0)
- error
+ error("failed");
endif
if (defaults1.ret() != -1.0)
- error
+ error("failed");
endif
defaults2 = Defaults2(1000);
defaults2 = Defaults2();
if (defaults2.ret(10.0) != 10.0)
- error
+ error("failed");
endif
if (defaults2.ret() != -1.0)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/complextest_runme.m b/Examples/test-suite/octave/complextest_runme.m
index 6a5433f1f..cd9c4a8b7 100644
--- a/Examples/test-suite/octave/complextest_runme.m
+++ b/Examples/test-suite/octave/complextest_runme.m
@@ -15,10 +15,16 @@ if (complextest.Conjf(a) != a.conjugate())
error("bad complex mapping")
endif
+if (complextest.Conj2(a) != a.conjugate())
+ error("bad complex mapping")
+endif
+
+if (complextest.Conjf2(a) != a.conjugate())
+ error("bad complex mapping")
+endif
+
v = (complex(1,2), complex(2,3), complex(4,3), 1);
-try
- complextest.Copy_h(v);
-catch
-end_try_catch
+complextest.CopyHalf(v);
+complextest.CopyHalfRef(v);
diff --git a/Examples/test-suite/octave/constructor_copy_runme.m b/Examples/test-suite/octave/constructor_copy_runme.m
index e450214c6..b6d3c3b6a 100644
--- a/Examples/test-suite/octave/constructor_copy_runme.m
+++ b/Examples/test-suite/octave/constructor_copy_runme.m
@@ -10,7 +10,7 @@ f11 = Foo1(f1);
if (f1.x != f11.x)
- error
+ error("failed");
endif
@@ -23,7 +23,7 @@ catch
end_try_catch
if (!good)
- error
+ error("failed");
endif
@@ -31,7 +31,7 @@ bi = Bari(5);
bc = Bari(bi);
if (bi.x != bc.x)
- error
+ error("failed");
endif
@@ -44,6 +44,6 @@ catch
end_try_catch
if (!good)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/default_args_runme.m b/Examples/test-suite/octave/default_args_runme.m
index 3d00f63e0..d2c6b4a6f 100644
--- a/Examples/test-suite/octave/default_args_runme.m
+++ b/Examples/test-suite/octave/default_args_runme.m
@@ -7,19 +7,19 @@ default_args
if (default_args.Statics.staticmethod() != 60)
- error
+ error("failed");
endif
if (default_args.cfunc1(1) != 2)
- error
+ error("failed");
endif
if (default_args.cfunc2(1) != 3)
- error
+ error("failed");
endif
if (default_args.cfunc3(1) != 4)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/director_abstract_runme.m b/Examples/test-suite/octave/director_abstract_runme.m
index 657e2e1d9..c96cf7554 100644
--- a/Examples/test-suite/octave/director_abstract_runme.m
+++ b/Examples/test-suite/octave/director_abstract_runme.m
@@ -28,17 +28,17 @@ MyExample3=@() subclass(director_abstract.Example3_i(),'Color',@(self,r,g,b) b);
me1 = MyExample1();
if (director_abstract.Example1.get_color(me1, 1,2,3) != 1)
- error
+ error("failed");
endif
me2 = MyExample2(1,2);
if (me2.get_color(me2, 1,2,3) != 2)
- error
+ error("failed");
endif
me3 = MyExample3();
if (me3.get_color(me3, 1,2,3) != 3)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/director_basic_runme.m b/Examples/test-suite/octave/director_basic_runme.m
index 9de54a385..9a411a703 100644
--- a/Examples/test-suite/octave/director_basic_runme.m
+++ b/Examples/test-suite/octave/director_basic_runme.m
@@ -33,7 +33,7 @@ endif
a = director_basic.A1(1);
if (a.rg(2) != 2)
- error
+ error("failed");
endif
function self=OctClass()
@@ -62,16 +62,16 @@ bd = dd.cmethod(b);
cc.method(b);
if (c.cmethod != 7)
- error
+ error("failed");
endif
if (bc.x != 34)
- error
+ error("failed");
endif
if (bd.x != 16)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/director_enum_runme.m b/Examples/test-suite/octave/director_enum_runme.m
index 96f158d39..59a5ccf8b 100644
--- a/Examples/test-suite/octave/director_enum_runme.m
+++ b/Examples/test-suite/octave/director_enum_runme.m
@@ -6,5 +6,5 @@ b = director_enum.Foo();
a = MyFoo();
if (a.say_hi(director_enum.hello) != b.say_hello(director_enum.hi))
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/director_nested_runme.m b/Examples/test-suite/octave/director_nested_runme.m
index 6e1d0ded9..614af0c60 100644
--- a/Examples/test-suite/octave/director_nested_runme.m
+++ b/Examples/test-suite/octave/director_nested_runme.m
@@ -31,9 +31,9 @@ c = FooBar_int_get_self(cc);
c.advance();
if (!strcmp(c.get_name(),"FooBar::get_name hello"))
- error
+ error("failed");
endif
if (!strcmp(c.name(),"FooBar::get_name hello"))
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/director_unroll_runme.m b/Examples/test-suite/octave/director_unroll_runme.m
index 6ca213c4c..607b9d5ef 100644
--- a/Examples/test-suite/octave/director_unroll_runme.m
+++ b/Examples/test-suite/octave/director_unroll_runme.m
@@ -11,6 +11,6 @@ c = b.get();
if (swig_this(a) != swig_this(c))
a,c
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/enum_template_runme.m b/Examples/test-suite/octave/enum_template_runme.m
index a9f940a9f..1474ce1cc 100644
--- a/Examples/test-suite/octave/enum_template_runme.m
+++ b/Examples/test-suite/octave/enum_template_runme.m
@@ -6,13 +6,13 @@ endif
enum_template
if (enum_template.MakeETest() != 1)
- error
+ error("failed");
endif
enum_template.TakeETest(0);
try
a=enum_template.TakeETest(0);
- error
+ error("failed");
catch
end_try_catch
diff --git a/Examples/test-suite/octave/enums_runme.m b/Examples/test-suite/octave/enums_runme.m
index b654d9d04..5f6bd6951 100644
--- a/Examples/test-suite/octave/enums_runme.m
+++ b/Examples/test-suite/octave/enums_runme.m
@@ -6,18 +6,18 @@ enums.bar3(1)
enums.bar1(1)
if (enums.cvar.enumInstance != 2)
- error
+ error("failed");
endif
if (enums.cvar.Slap != 10)
- error
+ error("failed");
endif
if (enums.cvar.Mine != 11)
- error
+ error("failed");
endif
if (enums.cvar.Thigh != 12)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/extend_template_ns_runme.m b/Examples/test-suite/octave/extend_template_ns_runme.m
index e79a00dda..7196fac73 100644
--- a/Examples/test-suite/octave/extend_template_ns_runme.m
+++ b/Examples/test-suite/octave/extend_template_ns_runme.m
@@ -7,9 +7,9 @@ extend_template_ns
f = Foo_One();
if (f.test1(37) != 37)
- error
+ error("failed");
endif
if (f.test2(42) != 42)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/extend_template_runme.m b/Examples/test-suite/octave/extend_template_runme.m
index 1cad7bfc9..125bd4a5a 100644
--- a/Examples/test-suite/octave/extend_template_runme.m
+++ b/Examples/test-suite/octave/extend_template_runme.m
@@ -2,9 +2,9 @@ extend_template
f = extend_template.Foo_0();
if (f.test1(37) != 37)
- error
+ error("failed");
endif
if (f.test2(42) != 42)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/extend_variable_runme.m b/Examples/test-suite/octave/extend_variable_runme.m
index c55b6c55c..89af26c9d 100644
--- a/Examples/test-suite/octave/extend_variable_runme.m
+++ b/Examples/test-suite/octave/extend_variable_runme.m
@@ -1,6 +1,6 @@
extend_variable
if (Foo.Bar != 42)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/friends_runme.m b/Examples/test-suite/octave/friends_runme.m
index 31211567f..50a5b20ef 100644
--- a/Examples/test-suite/octave/friends_runme.m
+++ b/Examples/test-suite/octave/friends_runme.m
@@ -8,25 +8,25 @@ friends
a = friends.A(2);
if (friends.get_val1(a) != 2)
- error
+ error("failed");
endif
if (friends.get_val2(a) != 4)
- error
+ error("failed");
endif
if (friends.get_val3(a) != 6)
- error
+ error("failed");
endif
# nice overload working fine
if (friends.get_val1(1,2,3) != 1)
- error
+ error("failed");
endif
b = friends.B(3);
# David's case
if (friends.mix(a,b) != 5)
- error
+ error("failed");
endif
di = friends.D_d(2);
@@ -34,18 +34,18 @@ dd = friends.D_d(3.3);
# incredible template overloading working just fine
if (friends.get_val1(di) != 2)
- error
+ error("failed");
endif
if (friends.get_val1(dd) != 3.3)
- error
+ error("failed");
endif
friends.set(di, 4);
friends.set(dd, 1.3);
if (friends.get_val1(di) != 4)
- error
+ error("failed");
endif
if (friends.get_val1(dd) != 1.3)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/grouping_runme.m b/Examples/test-suite/octave/grouping_runme.m
index 6d1a2d673..4e2c9ea2d 100644
--- a/Examples/test-suite/octave/grouping_runme.m
+++ b/Examples/test-suite/octave/grouping_runme.m
@@ -7,14 +7,14 @@ grouping
x = grouping.test1(42);
if (x != 42)
- error
+ error("failed");
endif
grouping.test2(42);
x = (grouping.do_unary(37, grouping.NEGATE));
if (x != -37)
- error
+ error("failed");
endif
grouping.cvar.test3 = 42;
diff --git a/Examples/test-suite/octave/iadd_runme.m b/Examples/test-suite/octave/iadd_runme.m
index c386c669e..70cd75dae 100644
--- a/Examples/test-suite/octave/iadd_runme.m
+++ b/Examples/test-suite/octave/iadd_runme.m
@@ -6,5 +6,5 @@ f.AsA.x = 3;
f.AsA += f.AsA;
if (f.AsA.x != 6)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/inout_runme.m b/Examples/test-suite/octave/inout_runme.m
index 74caaff46..c5d293eb6 100644
--- a/Examples/test-suite/octave/inout_runme.m
+++ b/Examples/test-suite/octave/inout_runme.m
@@ -2,26 +2,26 @@ inout
a = inout.AddOne1(1);
if (a != 2)
- error
+ error("failed");
endif
a = inout.AddOne3(1,1,1);
if (a != [2,2,2])
- error
+ error("failed");
endif
a = inout.AddOne1p((1,1));
if (a != (2,2))
- error
+ error("failed");
endif
a = inout.AddOne2p((1,1),1);
if (a != [(2,2),2])
- error
+ error("failed");
endif
a = inout.AddOne3p(1,(1,1),1);
if (a != [2,(2,2),2])
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/inplaceadd_runme.m b/Examples/test-suite/octave/inplaceadd_runme.m
index 2bc193793..50b680aba 100644
--- a/Examples/test-suite/octave/inplaceadd_runme.m
+++ b/Examples/test-suite/octave/inplaceadd_runme.m
@@ -3,22 +3,22 @@ a = inplaceadd.A(7);
a += 5;
if (a.val != 12)
- error
+ error("failed");
endif
a -= 5;
if a.val != 7:
- error
+ error("failed");
endif
a *= 2;
if (a.val != 14)
- error
+ error("failed");
endif
a += a;
if (a.val != 28)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/input_runme.m b/Examples/test-suite/octave/input_runme.m
index 1a92d032b..477ffaac1 100644
--- a/Examples/test-suite/octave/input_runme.m
+++ b/Examples/test-suite/octave/input_runme.m
@@ -7,21 +7,21 @@ input
f = Foo();
if (f.foo(2) != 4)
- error
+ error("failed");
endif
try
a=f.foo();
- error
+ error("failed");
catch
end_try_catch
if (!strcmp(sfoo("Hello"),"Hello world"))
- error
+ error("failed");
endif
try
a=sfoo();
- error
+ error("failed");
catch
end_try_catch
diff --git a/Examples/test-suite/octave/li_attribute_runme.m b/Examples/test-suite/octave/li_attribute_runme.m
index ed051d9df..5e239045f 100644
--- a/Examples/test-suite/octave/li_attribute_runme.m
+++ b/Examples/test-suite/octave/li_attribute_runme.m
@@ -8,7 +8,7 @@ li_attribute
aa = li_attribute.A(1,2,3);
if (aa.a != 1)
- error
+ error("failed");
endif
aa.a = 3;
if (aa.a != 3)
@@ -20,31 +20,31 @@ if (aa.b != 2)
endif
aa.b = 5;
if (aa.b != 5)
- error
+ error("failed");
endif
if (aa.d != aa.b)
- error
+ error("failed");
endif
if (aa.c != 3)
- error
+ error("failed");
endif
pi = li_attribute.Param_i(7);
if (pi.value != 7)
- error
+ error("failed");
endif
pi.value=3;
if (pi.value != 3)
- error
+ error("failed");
endif
b = li_attribute.B(aa);
if (b.a.c != 3)
- error
+ error("failed");
endif
# class/struct attribute with get/set methods using return/pass by reference
@@ -53,38 +53,38 @@ myFoo.x = 8;
myClass = li_attribute.MyClass();
myClass.Foo = myFoo;
if (myClass.Foo.x != 8)
- error
+ error("failed");
endif
# class/struct attribute with get/set methods using return/pass by value
myClassVal = li_attribute.MyClassVal();
if (myClassVal.ReadWriteFoo.x != -1)
- error
+ error("failed");
endif
if (myClassVal.ReadOnlyFoo.x != -1)
- error
+ error("failed");
endif
myClassVal.ReadWriteFoo = myFoo;
if (myClassVal.ReadWriteFoo.x != 8)
- error
+ error("failed");
endif
if (myClassVal.ReadOnlyFoo.x != 8)
- error
+ error("failed");
endif
# string attribute with get/set methods using return/pass by value
myStringyClass = li_attribute.MyStringyClass("initial string");
if (myStringyClass.ReadWriteString != "initial string")
- error
+ error("failed");
endif
if (myStringyClass.ReadOnlyString != "initial string")
- error
+ error("failed");
endif
myStringyClass.ReadWriteString = "changed string";
if (myStringyClass.ReadWriteString != "changed string")
- error
+ error("failed");
endif
if (myStringyClass.ReadOnlyString != "changed string")
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/li_carrays_cpp_runme.m b/Examples/test-suite/octave/li_carrays_cpp_runme.m
index b3b520920..57e3e9a87 100644
--- a/Examples/test-suite/octave/li_carrays_cpp_runme.m
+++ b/Examples/test-suite/octave/li_carrays_cpp_runme.m
@@ -11,5 +11,5 @@ d(0) = 7;
d(5) = d(0) + 3;
if (d(5) + d(0) != 17)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/li_carrays_runme.m b/Examples/test-suite/octave/li_carrays_runme.m
index c6b5f1619..5f180cce3 100644
--- a/Examples/test-suite/octave/li_carrays_runme.m
+++ b/Examples/test-suite/octave/li_carrays_runme.m
@@ -11,5 +11,5 @@ d(0) = 7;
d(5) = d(0) + 3;
if (d(5) + d(0) != 17)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/li_cmalloc_runme.m b/Examples/test-suite/octave/li_cmalloc_runme.m
index 92bcd9515..5daea2cb9 100644
--- a/Examples/test-suite/octave/li_cmalloc_runme.m
+++ b/Examples/test-suite/octave/li_cmalloc_runme.m
@@ -17,6 +17,6 @@ catch
end_try_catch
if (ok != 1)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/li_cpointer_cpp_runme.m b/Examples/test-suite/octave/li_cpointer_cpp_runme.m
index 463cf44f8..3551a17a9 100644
--- a/Examples/test-suite/octave/li_cpointer_cpp_runme.m
+++ b/Examples/test-suite/octave/li_cpointer_cpp_runme.m
@@ -5,7 +5,7 @@ p = new_intp();
intp_assign(p,3);
if (intp_value(p) != 3)
- error
+ error("failed");
endif
delete_intp(p);
diff --git a/Examples/test-suite/octave/li_cpointer_runme.m b/Examples/test-suite/octave/li_cpointer_runme.m
index ce055cddd..995cc2abf 100644
--- a/Examples/test-suite/octave/li_cpointer_runme.m
+++ b/Examples/test-suite/octave/li_cpointer_runme.m
@@ -10,7 +10,7 @@ p = new_intp();
intp_assign(p,3);
if (intp_value(p) != 3)
- error
+ error("failed");
endif
delete_intp(p);
diff --git a/Examples/test-suite/octave/li_cstring_runme.m b/Examples/test-suite/octave/li_cstring_runme.m
index 8aea6b709..4a706d33f 100644
--- a/Examples/test-suite/octave/li_cstring_runme.m
+++ b/Examples/test-suite/octave/li_cstring_runme.m
@@ -7,15 +7,15 @@ li_cstring
if (count("ab\0ab\0ab\0", 0) != 3)
- error
+ error("failed");
endif
if (!strcmp(test1(),"Hello World"))
- error
+ error("failed");
endif
if (!strcmp(test2()," !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_"))
- error
+ error("failed");
endif
if (!strcmp(test3("hello"),"hello-suffix"))
@@ -27,18 +27,18 @@ if (!strcmp(test4("hello"),"hello-suffix"))
endif
if (!strcmp(test5(4),'xxxx'))
- error
+ error("failed");
endif
if (!strcmp(test6(10),'xxxxx'))
- error
+ error("failed");
endif
if (!strcmp(test7(),"Hello world!"))
- error
+ error("failed");
endif
if (!strcmp(test8()," !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_"))
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/li_cwstring_runme.m b/Examples/test-suite/octave/li_cwstring_runme.m
index 1fb0962e7..5b9055110 100644
--- a/Examples/test-suite/octave/li_cwstring_runme.m
+++ b/Examples/test-suite/octave/li_cwstring_runme.m
@@ -6,38 +6,38 @@ endif
li_cwstring
if (count("ab\0ab\0ab\0", 0) != 3)
- error
+ error("failed");
endif
if (!strcmp(test1(),"Hello World"))
- error
+ error("failed");
endif
if (!strcmp(test2()," !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_"))
- error
+ error("failed");
endif
if (!strcmp(test3("hello"),"hello-suffix"))
- error
+ error("failed");
endif
if (!strcmp(test4("hello"),"hello-suffix"))
- error
+ error("failed");
endif
if (!strcmp(test5(4),'xxxx'))
- error
+ error("failed");
endif
if (!strcmp(test6(10),'xxxxx'))
- error
+ error("failed");
endif
if (!strcmp(test7(),"Hello world!"))
- error
+ error("failed");
endif
if (!strcmp(test8()," !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_"))
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/li_factory_runme.m b/Examples/test-suite/octave/li_factory_runme.m
index 5ea9b779f..7c07825f4 100644
--- a/Examples/test-suite/octave/li_factory_runme.m
+++ b/Examples/test-suite/octave/li_factory_runme.m
@@ -8,11 +8,11 @@ li_factory
circle = Geometry_create(Geometry.CIRCLE);
r = circle.radius();
if (r != 1.5)
- error
+ error("failed");
endif
point = Geometry_create(Geometry.POINT);
w = point.width();
if (w != 1.0)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/li_std_carray_runme.m b/Examples/test-suite/octave/li_std_carray_runme.m
index 4943fa8a2..f7212dc9a 100644
--- a/Examples/test-suite/octave/li_std_carray_runme.m
+++ b/Examples/test-suite/octave/li_std_carray_runme.m
@@ -9,7 +9,7 @@ endfor
i = 0;
for d in v3,
if (d != i)
- error
+ error("failed");
endif
i = i + 1;
endfor
@@ -29,7 +29,7 @@ for v3 in m3,
j = 0;
for d in v3,
if (d != i + j)
- error
+ error("failed");
endif
j = j + 1;
endfor
@@ -39,7 +39,7 @@ endfor
for i=0:len(m3),
for j=0:len(m3),
if (m3(i,j) != i + j)
- error
+ error("failed");
endif
endfor
endfor
diff --git a/Examples/test-suite/octave/li_std_containers_overload_runme.m b/Examples/test-suite/octave/li_std_containers_overload_runme.m
new file mode 100644
index 000000000..786d63466
--- /dev/null
+++ b/Examples/test-suite/octave/li_std_containers_overload_runme.m
@@ -0,0 +1,37 @@
+# do not dump Octave core
+if exist("crash_dumps_octave_core", "builtin")
+ crash_dumps_octave_core(0);
+endif
+
+li_std_containers_overload
+
+function check(got, expected)
+ if (!strcmp(got, expected))
+ error("Failed check. '%s' != '%s'", got, expected)
+ endif
+end
+
+v = VectorX();
+check(VectorOverload(v), "vector<X>");
+
+v = VectorY();
+check(VectorOverload(v), "vector<Y>");
+
+v = VectorInt();
+check(VectorOverload(v), "vector<int>");
+
+v = VectorString();
+check(VectorOverload(v), "vector<string>");
+
+# TODO: Conversion from an Octave sequence not implemented yet
+# v = {X()};
+# check(VectorOverload(v), "vector<X>");
+
+# v = {Y()};
+# check(VectorOverload(v), "vector<Y>");
+
+# v = {1, 2, 3};
+# check(VectorOverload(v), "vector<int>");
+
+# v = {"aaa", "bbb", "ccc"};
+# check(VectorOverload(v), "vector<string>");
diff --git a/Examples/test-suite/octave/li_std_set_runme.m b/Examples/test-suite/octave/li_std_set_runme.m
index 9bd4f152c..7f43f2f13 100644
--- a/Examples/test-suite/octave/li_std_set_runme.m
+++ b/Examples/test-suite/octave/li_std_set_runme.m
@@ -11,15 +11,15 @@ for i in s:
sum = sum + i
if (sum != "abc")
- error
+ error("failed");
i = s.__iter__()
if i.next() != "a":
- error
+ error("failed");
if i.next() != "b":
- error
+ error("failed");
if i.next() != "c":
- error
+ error("failed");
b = s.begin()
@@ -28,7 +28,7 @@ sum = ""
while (b != e):
sum = sum + b.next()
if sum != "abc":
- error
+ error("failed");
b = s.rbegin()
e = s.rend()
@@ -37,7 +37,7 @@ while (b != e):
sum = sum + b.next()
if sum != "cba":
- error
+ error("failed");
@@ -49,11 +49,11 @@ si.append(3)
i = si.__iter__()
if i.next() != 1:
- error
+ error("failed");
if i.next() != 2:
- error
+ error("failed");
if i.next() != 3:
- error
+ error("failed");
@@ -68,17 +68,17 @@ sum = ""
while (b != e):
sum = sum + b.next()
if sum != "ac":
- error
+ error("failed");
b = s.begin()
e = s.end()
if e - b != 2:
- error
+ error("failed");
m = b + 1
if m.value() != "c":
- error
+ error("failed");
@@ -93,4 +93,4 @@ for i in s:
sum = sum + (i,)
if sum != (1, 'hello', (1, 2)):
- error
+ error("failed");
diff --git a/Examples/test-suite/octave/li_std_stream_runme.m b/Examples/test-suite/octave/li_std_stream_runme.m
index bf9402e16..cedc8e59c 100644
--- a/Examples/test-suite/octave/li_std_stream_runme.m
+++ b/Examples/test-suite/octave/li_std_stream_runme.m
@@ -8,6 +8,6 @@ o << a << " " << 2345 << " " << 1.435;
if (o.str() != "A class 2345 1.435")
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/li_std_string_extra_runme.m b/Examples/test-suite/octave/li_std_string_extra_runme.m
index 8d506af8a..15e18eec7 100644
--- a/Examples/test-suite/octave/li_std_string_extra_runme.m
+++ b/Examples/test-suite/octave/li_std_string_extra_runme.m
@@ -140,23 +140,23 @@ endif
if (li_std_string_extra.test_reference_input("hello") != "hello")
- error
+ error("failed");
endif
s = li_std_string_extra.test_reference_inout("hello");
if (s != "hellohello")
- error
+ error("failed");
endif
if (li_std_string_extra.stdstring_empty() != "")
- error
+ error("failed");
endif
if (li_std_string_extra.c_empty() != "")
- error
+ error("failed");
endif
#if (li_std_string_extra.c_null() != None)
-# error
+# error("failed");
#endif
diff --git a/Examples/test-suite/octave/li_std_wstream_runme.m b/Examples/test-suite/octave/li_std_wstream_runme.m
index a017e8acd..4f1c62166 100644
--- a/Examples/test-suite/octave/li_std_wstream_runme.m
+++ b/Examples/test-suite/octave/li_std_wstream_runme.m
@@ -9,6 +9,6 @@ o = wostringstream();
o << a << u" " << 2345 << u" " << 1.435 << wends;
if (o.str() != "A class 2345 1.435\0")
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/li_std_wstring_runme.m b/Examples/test-suite/octave/li_std_wstring_runme.m
deleted file mode 100644
index cbccc0c12..000000000
--- a/Examples/test-suite/octave/li_std_wstring_runme.m
+++ /dev/null
@@ -1,95 +0,0 @@
-# do not dump Octave core
-if exist("crash_dumps_octave_core", "builtin")
- crash_dumps_octave_core(0);
-endif
-
-li_std_wstring
-
-x="h";
-
-if (li_std_wstring.test_wcvalue(x) != x)
- error("bad string mapping")
-endif
-
-x="hello";
-if (li_std_wstring.test_ccvalue(x) != x)
- error("bad string mapping")
-endif
-
-if (li_std_wstring.test_cvalue(x) != x)
- error("bad string mapping")
-endif
-
-if (li_std_wstring.test_value(x) != x)
- error("bad string mapping")
-endif
-
-if (li_std_wstring.test_const_reference(x) != x)
- error("bad string mapping")
-endif
-
-
-s = li_std_wstring.wstring("he");
-s = s + "llo";
-
-if (s != x)
- error("bad string mapping")
-endif
-
-if (s(1:4) != x(1:4))
- error("bad string mapping")
-endif
-
-if (li_std_wstring.test_value(s) != x)
- error("bad string mapping")
-endif
-
-if (li_std_wstring.test_const_reference(s) != x)
- error("bad string mapping")
-endif
-
-a = li_std_wstring.A(s);
-
-if (li_std_wstring.test_value(a) != x)
- error("bad string mapping")
-endif
-
-if (li_std_wstring.test_const_reference(a) != x)
- error("bad string mapping")
-endif
-
-b = li_std_wstring.wstring(" world");
-
-if (a + b != "hello world")
- error("bad string mapping")
-endif
-
-if (a + " world" != "hello world")
- error("bad string mapping")
-endif
-
-if ("hello" + b != "hello world")
- error("bad string mapping")
-endif
-
-c = "hello" + b;
-if (c.find_last_of("l") != 9)
- error("bad string mapping")
-endif
-
-s = "hello world";
-
-b = li_std_wstring.B("hi");
-
-b.name = li_std_wstring.wstring("hello");
-if (b.name != "hello")
- error("bad string mapping")
-endif
-
-
-b.a = li_std_wstring.A("hello");
-if (b.a != "hello")
- error("bad string mapping")
-endif
-
-
diff --git a/Examples/test-suite/octave/multi_import_runme.m b/Examples/test-suite/octave/multi_import_runme.m
index 2b7a610d4..d22ff5c81 100644
--- a/Examples/test-suite/octave/multi_import_runme.m
+++ b/Examples/test-suite/octave/multi_import_runme.m
@@ -8,22 +8,22 @@ multi_import_b;
x = multi_import_b.XXX();
if (x.testx() != 0)
- error
+ error("failed");
endif
y = multi_import_b.YYY();
if (y.testx() != 0)
- error
+ error("failed");
endif
if (y.testy() != 1)
- error
+ error("failed");
endif
z = multi_import_a.ZZZ();
if (z.testx() != 0)
- error
+ error("failed");
endif
if (z.testz() != 2)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/namespace_typemap_runme.m b/Examples/test-suite/octave/namespace_typemap_runme.m
index ca3730773..d7e338104 100644
--- a/Examples/test-suite/octave/namespace_typemap_runme.m
+++ b/Examples/test-suite/octave/namespace_typemap_runme.m
@@ -1,106 +1,106 @@
namespace_typemap
if (!strcmp(stest1("hello"),"hello"))
- error
+ error("failed");
endif
if (!strcmp(stest2("hello"),"hello"))
- error
+ error("failed");
endif
if (!strcmp(stest3("hello"),"hello"))
- error
+ error("failed");
endif
if (!strcmp(stest4("hello"),"hello"))
- error
+ error("failed");
endif
if (!strcmp(stest5("hello"),"hello"))
- error
+ error("failed");
endif
if (!strcmp(stest6("hello"),"hello"))
- error
+ error("failed");
endif
if (!strcmp(stest7("hello"),"hello"))
- error
+ error("failed");
endif
if (!strcmp(stest8("hello"),"hello"))
- error
+ error("failed");
endif
if (!strcmp(stest9("hello"),"hello"))
- error
+ error("failed");
endif
if (!strcmp(stest10("hello"),"hello"))
- error
+ error("failed");
endif
if (!strcmp(stest11("hello"),"hello"))
- error
+ error("failed");
endif
if (!strcmp(stest12("hello"),"hello"))
- error
+ error("failed");
endif
c = complex(2,3);
r = real(c);
if (ctest1(c) != r)
- error
+ error("failed");
endif
if (ctest2(c) != r)
- error
+ error("failed");
endif
if (ctest3(c) != r)
- error
+ error("failed");
endif
if (ctest4(c) != r)
- error
+ error("failed");
endif
if (ctest5(c) != r)
- error
+ error("failed");
endif
if (ctest6(c) != r)
- error
+ error("failed");
endif
if (ctest7(c) != r)
- error
+ error("failed");
endif
if (ctest8(c) != r)
- error
+ error("failed");
endif
if (ctest9(c) != r)
- error
+ error("failed");
endif
if (ctest10(c) != r)
- error
+ error("failed");
endif
if (ctest11(c) != r)
- error
+ error("failed");
endif
if (ctest12(c) != r)
- error
+ error("failed");
endif
try
ttest1(-14)
- error
+ error("failed");
catch
end_try_catch
diff --git a/Examples/test-suite/octave/naturalvar_runme.m b/Examples/test-suite/octave/naturalvar_runme.m
index 6059b0273..40546f26c 100644
--- a/Examples/test-suite/octave/naturalvar_runme.m
+++ b/Examples/test-suite/octave/naturalvar_runme.m
@@ -14,6 +14,6 @@ cvar.s = "hello";
b.s = "hello";
if (b.s != cvar.s)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/null_pointer_runme.m b/Examples/test-suite/octave/null_pointer_runme.m
index 9d55d8be2..72362f451 100644
--- a/Examples/test-suite/octave/null_pointer_runme.m
+++ b/Examples/test-suite/octave/null_pointer_runme.m
@@ -5,4 +5,4 @@ endif
null_pointer;
-assert(func([]));
+assert(funk([]));
diff --git a/Examples/test-suite/octave/octave_cell_deref_runme.m b/Examples/test-suite/octave/octave_cell_deref_runme.m
index d00d17282..0a45999d3 100644
--- a/Examples/test-suite/octave/octave_cell_deref_runme.m
+++ b/Examples/test-suite/octave/octave_cell_deref_runme.m
@@ -5,8 +5,8 @@ endif
octave_cell_deref;
-assert(func("hello"));
-assert(func({"hello"}));
+assert(funk("hello"));
+assert(funk({"hello"}));
c = func2();
assert(strcmp(c{1}, "hello"));
diff --git a/Examples/test-suite/octave/overload_complicated_runme.m b/Examples/test-suite/octave/overload_complicated_runme.m
index 879bdc890..bbfc7ba19 100644
--- a/Examples/test-suite/octave/overload_complicated_runme.m
+++ b/Examples/test-suite/octave/overload_complicated_runme.m
@@ -5,15 +5,15 @@ endif
overload_complicated
-pInt = None;
+pInt = []; # NULL
# Check the correct constructors are available
p = Pop(pInt);
-p = Pop(pInt, 0);
+p = Pop(pInt, false);
# Check overloaded in const only and pointers/references which target languages cannot disambiguate
-if (p.hip(0) != 701)
+if (p.hip(false) != 701)
error("Test 1 failed")
endif
@@ -26,16 +26,16 @@ if (p.hop(pInt) != 805)
error("Test 3 failed")
endif
-if (p.hop(0) != 801)
+if (p.hop(false) != 801)
error("Test 4 failed")
endif
# Few more variations and order shuffled
-if (p.pop(0) != 901)
+if (p.pop(false) != 901)
error("Test 5 failed")
endif
-if (p.pop(pInt) != 902)
+if (p.pop(pInt) != 904)
error("Test 6 failed")
endif
@@ -48,12 +48,12 @@ if (p.bop(pInt) != 1001)
error("Test 8 failed")
endif
-if (p.bip(pInt) != 2001)
+if (p.bip(pInt) != 2002)
error("Test 9 failed")
endif
# Globals
-if (muzak(0) != 3001)
+if (muzak(false) != 3001)
error("Test 10 failed")
endif
diff --git a/Examples/test-suite/octave/overload_extend2_runme.m b/Examples/test-suite/octave/overload_extend2_runme.m
index 6db6b66bb..e4611948e 100644
--- a/Examples/test-suite/octave/overload_extend2_runme.m
+++ b/Examples/test-suite/octave/overload_extend2_runme.m
@@ -2,29 +2,29 @@ overload_extend2
f = overload_extend2.Foo();
if (f.test(3) != 1)
- error
+ error("failed");
endif
if (f.test("hello") != 2)
- error
+ error("failed");
endif
if (f.test(3.5,2.5) != 3)
- error
+ error("failed");
endif
if (f.test("hello",20) != 1020)
- error
+ error("failed");
endif
if (f.test("hello",20,100) != 120)
- error
+ error("failed");
endif
# C default args
if (f.test(f) != 30)
- error
+ error("failed");
endif
if (f.test(f,100) != 120)
- error
+ error("failed");
endif
if (f.test(f,100,200) != 300)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/overload_extend_c_runme.m b/Examples/test-suite/octave/overload_extend_c_runme.m
index 79b92ca47..2a6c5c21e 100644
--- a/Examples/test-suite/octave/overload_extend_c_runme.m
+++ b/Examples/test-suite/octave/overload_extend_c_runme.m
@@ -7,18 +7,18 @@ overload_extend_c
f = overload_extend_c.Foo();
if (f.test() != 0)
- error
+ error("failed");
endif
if (f.test(3) != 1)
- error
+ error("failed");
endif
if (f.test("hello") != 2)
- error
+ error("failed");
endif
if (f.test(3,2) != 5)
- error
+ error("failed");
endif
if (f.test(3.1)-.1 != 1003) # :)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/overload_extend_runme.m b/Examples/test-suite/octave/overload_extend_runme.m
index d9959804f..a29f1910e 100644
--- a/Examples/test-suite/octave/overload_extend_runme.m
+++ b/Examples/test-suite/octave/overload_extend_runme.m
@@ -7,18 +7,18 @@ overload_extend
f = overload_extend.Foo();
if (f.test() != 0)
- error
+ error("failed");
endif
if (f.test(3) != 1)
- error
+ error("failed");
endif
if (f.test("hello") != 2)
- error
+ error("failed");
endif
if (f.test(3,2) != 5)
- error
+ error("failed");
endif
if (f.test(3.1)-.1 != 1003) # :)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/overload_null_runme.m b/Examples/test-suite/octave/overload_null_runme.m
new file mode 100644
index 000000000..a7c346c26
--- /dev/null
+++ b/Examples/test-suite/octave/overload_null_runme.m
@@ -0,0 +1,52 @@
+# do not dump Octave core
+if exist("crash_dumps_octave_core", "builtin")
+ crash_dumps_octave_core(0);
+endif
+
+overload_null
+
+function check(a, b)
+ if (a != b)
+ error("%i does not equal %i", a, b);
+ endif
+end
+
+o = Overload();
+x = X();
+null = []; # NULL pointer
+
+check(1, o.byval1(x));
+check(2, o.byval1(null));
+
+check(3, o.byval2(null));
+check(4, o.byval2(x));
+
+check(5, o.byref1(x));
+check(6, o.byref1(null));
+
+check(7, o.byref2(null));
+check(8, o.byref2(x));
+
+check(9, o.byconstref1(x));
+check(10, o.byconstref1(null));
+
+check(11, o.byconstref2(null));
+check(12, o.byconstref2(x));
+
+# const pointer references
+check(13, o.byval1cpr(x));
+check(14, o.byval1cpr(null));
+
+check(15, o.byval2cpr(null));
+check(16, o.byval2cpr(x));
+
+# forward class declaration
+check(17, o.byval1forwardptr(x));
+check(18, o.byval1forwardptr(null));
+
+check(19, o.byval2forwardptr(null));
+check(20, o.byval2forwardptr(x));
+
+check(21, o.byval1forwardref(x));
+
+check(22, o.byval2forwardref(x));
diff --git a/Examples/test-suite/octave/preproc_runme.m b/Examples/test-suite/octave/preproc_runme.m
index e9af66e78..80f1d32ba 100644
--- a/Examples/test-suite/octave/preproc_runme.m
+++ b/Examples/test-suite/octave/preproc_runme.m
@@ -6,18 +6,18 @@ endif
preproc
if (preproc.cvar.endif != 1)
- error
+ error("failed");
endif
if (preproc.cvar.define != 1)
- error
+ error("failed");
endif
if (preproc.cvar.defined != 1)
- error
+ error("failed");
endif
if (2*preproc.one != preproc.two)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/primitive_ref_runme.m b/Examples/test-suite/octave/primitive_ref_runme.m
index 68a5750c3..799b6db17 100644
--- a/Examples/test-suite/octave/primitive_ref_runme.m
+++ b/Examples/test-suite/octave/primitive_ref_runme.m
@@ -1,53 +1,53 @@
primitive_ref
if (ref_int(3) != 3)
- error
+ error("failed");
endif
if (ref_uint(3) != 3)
- error
+ error("failed");
endif
if (ref_short(3) != 3)
- error
+ error("failed");
endif
if (ref_ushort(3) != 3)
- error
+ error("failed");
endif
if (ref_long(3) != 3)
- error
+ error("failed");
endif
if (ref_ulong(3) != 3)
- error
+ error("failed");
endif
if (ref_schar(3) != 3)
- error
+ error("failed");
endif
if (ref_uchar(3) != 3)
- error
+ error("failed");
endif
if (ref_float(3.5) != 3.5)
- error
+ error("failed");
endif
if (ref_double(3.5) != 3.5)
- error
+ error("failed");
endif
if (ref_bool(true) != true)
- error
+ error("failed");
endif
if (!strcmp(ref_char('x'),'x'))
- error
+ error("failed");
endif
if (ref_over(0) != 0)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/reference_global_vars_runme.m b/Examples/test-suite/octave/reference_global_vars_runme.m
index 67ad9c514..c7f4f56b7 100644
--- a/Examples/test-suite/octave/reference_global_vars_runme.m
+++ b/Examples/test-suite/octave/reference_global_vars_runme.m
@@ -2,90 +2,90 @@ reference_global_vars
# const class reference variable
if (getconstTC().num != 33)
- error
+ error("failed");
endif
# primitive reference variables
cvar.var_bool = createref_bool(false);
if (value_bool(cvar.var_bool) != 0)
- error
+ error("failed");
endif
cvar.var_bool = createref_bool(true);
if (value_bool(cvar.var_bool) != 1)
- error
+ error("failed");
endif
cvar.var_char = createref_char('w');
if (!strcmp(value_char(cvar.var_char),'w'))
- error
+ error("failed");
endif
cvar.var_unsigned_char = createref_unsigned_char(10);
if (value_unsigned_char(cvar.var_unsigned_char) != 10)
- error
+ error("failed");
endif
cvar.var_signed_char = createref_signed_char(10);
if (value_signed_char(cvar.var_signed_char) != 10)
- error
+ error("failed");
endif
cvar.var_short = createref_short(10);
if (value_short(cvar.var_short) != 10)
- error
+ error("failed");
endif
cvar.var_unsigned_short = createref_unsigned_short(10);
if (value_unsigned_short(cvar.var_unsigned_short) != 10)
- error
+ error("failed");
endif
cvar.var_int = createref_int(10);
if (value_int(cvar.var_int) != 10)
- error
+ error("failed");
endif
cvar.var_unsigned_int = createref_unsigned_int(10);
if (value_unsigned_int(cvar.var_unsigned_int) != 10)
- error
+ error("failed");
endif
cvar.var_long = createref_long(10);
if (value_long(cvar.var_long) != 10)
- error
+ error("failed");
endif
cvar.var_unsigned_long = createref_unsigned_long(10);
if (value_unsigned_long(cvar.var_unsigned_long) != 10)
- error
+ error("failed");
endif
cvar.var_long_long = createref_long_long(int64(0x6FFFFFFFFFFFFFF8));
if (value_long_long(cvar.var_long_long) != int64(0x6FFFFFFFFFFFFFF8))
- error
+ error("failed");
endif
#ull = abs(0xFFFFFFF2FFFFFFF0)
ull = uint64(55834574864);
cvar.var_unsigned_long_long = createref_unsigned_long_long(ull);
if (value_unsigned_long_long(cvar.var_unsigned_long_long) != ull)
- error
+ error("failed");
endif
cvar.var_float = createref_float(10.5);
if (value_float(cvar.var_float) != 10.5)
- error
+ error("failed");
endif
cvar.var_double = createref_double(10.5);
if (value_double(cvar.var_double) != 10.5)
- error
+ error("failed");
endif
# class reference variable
cvar.var_TestClass = createref_TestClass(TestClass(20));
if (value_TestClass(cvar.var_TestClass).num != 20)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/rename_scope_runme.m b/Examples/test-suite/octave/rename_scope_runme.m
index 154f99dfe..776d218c5 100644
--- a/Examples/test-suite/octave/rename_scope_runme.m
+++ b/Examples/test-suite/octave/rename_scope_runme.m
@@ -4,11 +4,11 @@ a = Natural_UP();
b = Natural_BP();
if (a.rtest() != 1)
- error
+ error("failed");
endif
if (b.rtest() != 1)
- error
+ error("failed");
endif
f = @equals;
diff --git a/Examples/test-suite/octave/ret_by_value_runme.m b/Examples/test-suite/octave/ret_by_value_runme.m
index 67f80aae2..c1c508353 100644
--- a/Examples/test-suite/octave/ret_by_value_runme.m
+++ b/Examples/test-suite/octave/ret_by_value_runme.m
@@ -7,9 +7,9 @@ ret_by_value
a = ret_by_value.get_test();
if (a.myInt != 100)
- error
+ error("failed");
endif
if (a.myShort != 200)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/return_const_value_runme.m b/Examples/test-suite/octave/return_const_value_runme.m
index 1219c9293..8b363f297 100644
--- a/Examples/test-suite/octave/return_const_value_runme.m
+++ b/Examples/test-suite/octave/return_const_value_runme.m
@@ -2,10 +2,10 @@ return_const_value
p = return_const_value.Foo_ptr.getPtr();
if (p.getVal() != 17)
- error("Runtime test1 faild. p.getVal()=", p.getVal())
+ error("Runtime test1 failed. p.getVal()=", p.getVal())
endif
p = return_const_value.Foo_ptr.getConstPtr();
if (p.getVal() != 17)
- error("Runtime test2 faild. p.getVal()=", p.getVal())
+ error("Runtime test2 failed. p.getVal()=", p.getVal())
endif
diff --git a/Examples/test-suite/octave/smart_pointer_extend_runme.m b/Examples/test-suite/octave/smart_pointer_extend_runme.m
index 6c9258e6d..cf82f7350 100644
--- a/Examples/test-suite/octave/smart_pointer_extend_runme.m
+++ b/Examples/test-suite/octave/smart_pointer_extend_runme.m
@@ -9,7 +9,7 @@ f = Foo();
b = Bar(f);
if (b.extension() != f.extension())
- error
+ error("failed");
endif
@@ -18,15 +18,15 @@ d = CDerived();
p = CPtr();
if (b.bar() != p.bar())
- error
+ error("failed");
endif
if (d.foo() != p.foo())
- error
+ error("failed");
endif
if (b.hello() != p.hello())
- error
+ error("failed");
endif
@@ -36,11 +36,11 @@ d = DFoo();
dp = DPtrFoo(d);
if (d.SExt(1) != dp.SExt(1))
- error
+ error("failed");
endif
if (d.Ext(1) != dp.Ext(1))
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/smart_pointer_member_runme.m b/Examples/test-suite/octave/smart_pointer_member_runme.m
index 30251c3a8..1c2d0e9ed 100644
--- a/Examples/test-suite/octave/smart_pointer_member_runme.m
+++ b/Examples/test-suite/octave/smart_pointer_member_runme.m
@@ -4,7 +4,7 @@ f = Foo();
f.y = 1;
if (f.y != 1)
- error
+ error("failed");
endif
b = Bar(f);
@@ -15,18 +15,18 @@ if (f.y != 2)
endif
if (swig_this(b.x) != swig_this(f.x))
- error
+ error("failed");
endif
if (b.z != f.z)
- error
+ error("failed");
endif
try
if (Foo.z == Bar.z)
- error
+ error("failed");
endif
- error
+ error("failed");
catch
end_try_catch
diff --git a/Examples/test-suite/octave/smart_pointer_multi_runme.m b/Examples/test-suite/octave/smart_pointer_multi_runme.m
index 71ef9109a..ea15d04b9 100644
--- a/Examples/test-suite/octave/smart_pointer_multi_runme.m
+++ b/Examples/test-suite/octave/smart_pointer_multi_runme.m
@@ -7,11 +7,11 @@ g = Grok(b);
s.x = 3;
if (s.getx() != 3)
- error
+ error("failed");
endif
g.x = 4;
if (g.getx() != 4)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/smart_pointer_multi_typedef_runme.m b/Examples/test-suite/octave/smart_pointer_multi_typedef_runme.m
index 4b77e0eea..c2ab78714 100644
--- a/Examples/test-suite/octave/smart_pointer_multi_typedef_runme.m
+++ b/Examples/test-suite/octave/smart_pointer_multi_typedef_runme.m
@@ -7,12 +7,12 @@ g = Grok(b);
s.x = 3;
if (s.getx() != 3)
- error
+ error("failed");
endif
g.x = 4;
if (g.getx() != 4)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/smart_pointer_overload_runme.m b/Examples/test-suite/octave/smart_pointer_overload_runme.m
index a5df0ded4..1bfb68354 100644
--- a/Examples/test-suite/octave/smart_pointer_overload_runme.m
+++ b/Examples/test-suite/octave/smart_pointer_overload_runme.m
@@ -10,23 +10,23 @@ b = Bar(f);
if (f.test(3) != 1)
- error
+ error("failed");
endif
if (f.test(3.5) != 2)
- error
+ error("failed");
endif
if (f.test("hello") != 3)
- error
+ error("failed");
endif
if (b.test(3) != 1)
- error
+ error("failed");
endif
if (b.test(3.5) != 2)
- error
+ error("failed");
endif
if (b.test("hello") != 3)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/smart_pointer_rename_runme.m b/Examples/test-suite/octave/smart_pointer_rename_runme.m
index 5eb6d4c3c..307bd8f95 100644
--- a/Examples/test-suite/octave/smart_pointer_rename_runme.m
+++ b/Examples/test-suite/octave/smart_pointer_rename_runme.m
@@ -9,14 +9,14 @@ f = Foo();
b = Bar(f);
if (b.test() != 3)
- error
+ error("failed");
endif
if (b.ftest1(1) != 1)
- error
+ error("failed");
endif
if (b.ftest2(2,3) != 2)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/smart_pointer_simple_runme.m b/Examples/test-suite/octave/smart_pointer_simple_runme.m
index 30b1387c4..c15c43ca9 100644
--- a/Examples/test-suite/octave/smart_pointer_simple_runme.m
+++ b/Examples/test-suite/octave/smart_pointer_simple_runme.m
@@ -10,11 +10,11 @@ b = Bar(f);
b.x = 3;
if (b.getx() != 3)
- error
+ error("failed");
endif
fp = b.__deref__();
fp.x = 4;
if (fp.getx() != 4)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/smart_pointer_templatevariables_runme.m b/Examples/test-suite/octave/smart_pointer_templatevariables_runme.m
index 4884fa24b..ee45f68f9 100644
--- a/Examples/test-suite/octave/smart_pointer_templatevariables_runme.m
+++ b/Examples/test-suite/octave/smart_pointer_templatevariables_runme.m
@@ -3,17 +3,17 @@ smart_pointer_templatevariables
d = DiffImContainerPtr_D(create(1234, 5678));
if (d.id != 1234)
- error
+ error("failed");
endif
#if (d.xyz != 5678):
-# error
+# error("failed");
d.id = 4321;
#d.xyz = 8765
if (d.id != 4321)
- error
+ error("failed");
endif
#if (d.xyz != 8765):
-# error
+# error("failed");
diff --git a/Examples/test-suite/octave/smart_pointer_typedef_runme.m b/Examples/test-suite/octave/smart_pointer_typedef_runme.m
index 0e1c8a61e..3a094670f 100644
--- a/Examples/test-suite/octave/smart_pointer_typedef_runme.m
+++ b/Examples/test-suite/octave/smart_pointer_typedef_runme.m
@@ -10,11 +10,11 @@ b = Bar(f);
b.x = 3;
if (b.getx() != 3)
- error
+ error("failed");
endif
fp = b.__deref__();
fp.x = 4;
if (fp.getx() != 4)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/static_const_member_2_runme.m b/Examples/test-suite/octave/static_const_member_2_runme.m
index 73260bae7..8619fd1eb 100644
--- a/Examples/test-suite/octave/static_const_member_2_runme.m
+++ b/Examples/test-suite/octave/static_const_member_2_runme.m
@@ -18,6 +18,6 @@ end_try_catch
if (Foo.BAZ.val != 2*Foo.BAR.val)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/std_containers_runme.m b/Examples/test-suite/octave/std_containers_runme.m
index eae3d5d9f..d069b585c 100644
--- a/Examples/test-suite/octave/std_containers_runme.m
+++ b/Examples/test-suite/octave/std_containers_runme.m
@@ -132,7 +132,7 @@ s.append(3);
j=1;
for i in s,
if (i != j)
- error
+ error("failed");
endif
j = j + 1;
endfor
diff --git a/Examples/test-suite/octave/struct_value_runme.m b/Examples/test-suite/octave/struct_value_runme.m
index ff344047e..7f7448bb6 100644
--- a/Examples/test-suite/octave/struct_value_runme.m
+++ b/Examples/test-suite/octave/struct_value_runme.m
@@ -9,10 +9,10 @@ b = struct_value.Bar();
b.a.x = 3;
if (b.a.x != 3)
- error
+ error("failed");
endif
b.b.x = 3;
if (b.b.x != 3)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/swigobject_runme.m b/Examples/test-suite/octave/swigobject_runme.m
index 73167e497..9ab3aa8c6 100644
--- a/Examples/test-suite/octave/swigobject_runme.m
+++ b/Examples/test-suite/octave/swigobject_runme.m
@@ -11,7 +11,7 @@ a1 = a_ptr(a);
a2 = a_ptr(a);
if (swig_this(a1) != swig_this(a2))
- error
+ error("failed");
endif
@@ -20,7 +20,7 @@ xstr1 = printf("0x%x",lthis);
xstr2 = pointer_str(a);
if (xstr1 != xstr2)
- error
+ error("failed");
endif
s = str(a.this);
@@ -29,5 +29,5 @@ r = repr(a.this);
v1 = v_ptr(a);
v2 = v_ptr(a);
if (uint64(v1) != uint64(v2))
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/template_extend1_runme.m b/Examples/test-suite/octave/template_extend1_runme.m
index 5035debf5..05e534107 100644
--- a/Examples/test-suite/octave/template_extend1_runme.m
+++ b/Examples/test-suite/octave/template_extend1_runme.m
@@ -9,9 +9,9 @@ a = template_extend1.lBaz();
b = template_extend1.dBaz();
if (!strcmp(a.foo(),"lBaz::foo"))
- error
+ error("failed");
endif
if (!strcmp(b.foo(),"dBaz::foo"))
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/template_extend2_runme.m b/Examples/test-suite/octave/template_extend2_runme.m
index 24472a9ed..e9b5fb799 100644
--- a/Examples/test-suite/octave/template_extend2_runme.m
+++ b/Examples/test-suite/octave/template_extend2_runme.m
@@ -9,9 +9,9 @@ a = template_extend2.lBaz();
b = template_extend2.dBaz();
if (!strcmp(a.foo(),"lBaz::foo"))
- error
+ error("failed");
endif
if (!strcmp(b.foo(),"dBaz::foo"))
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/template_inherit_runme.m b/Examples/test-suite/octave/template_inherit_runme.m
index 368cce227..72d7e7511 100644
--- a/Examples/test-suite/octave/template_inherit_runme.m
+++ b/Examples/test-suite/octave/template_inherit_runme.m
@@ -12,62 +12,62 @@ e = FooUInt();
f = BarUInt();
if (!strcmp(a.blah(),"Foo"))
- error
+ error("failed");
endif
if (!strcmp(b.blah(),"Foo"))
- error
+ error("failed");
endif
if (!strcmp(e.blah(),"Foo"))
- error
+ error("failed");
endif
if (!strcmp(c.blah(),"Bar"))
- error
+ error("failed");
endif
if (!strcmp(d.blah(),"Bar"))
- error
+ error("failed");
endif
if (!strcmp(f.blah(),"Bar"))
- error
+ error("failed");
endif
if (!strcmp(c.foomethod(),"foomethod"))
- error
+ error("failed");
endif
if (!strcmp(d.foomethod(),"foomethod"))
- error
+ error("failed");
endif
if (!strcmp(f.foomethod(),"foomethod"))
- error
+ error("failed");
endif
if (!strcmp(invoke_blah_int(a),"Foo"))
- error
+ error("failed");
endif
if (!strcmp(invoke_blah_int(c),"Bar"))
- error
+ error("failed");
endif
if (!strcmp(invoke_blah_double(b),"Foo"))
- error
+ error("failed");
endif
if (!strcmp(invoke_blah_double(d),"Bar"))
- error
+ error("failed");
endif
if (!strcmp(invoke_blah_uint(e),"Foo"))
- error
+ error("failed");
endif
if (!strcmp(invoke_blah_uint(f),"Bar"))
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/template_ns4_runme.m b/Examples/test-suite/octave/template_ns4_runme.m
index b5746427b..6dff55694 100644
--- a/Examples/test-suite/octave/template_ns4_runme.m
+++ b/Examples/test-suite/octave/template_ns4_runme.m
@@ -7,5 +7,5 @@ template_ns4
d = make_Class_DD();
if (!strcmp(d.test(),"test"))
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/template_ns_runme.m b/Examples/test-suite/octave/template_ns_runme.m
index 29a2f53f6..44b13e62c 100644
--- a/Examples/test-suite/octave/template_ns_runme.m
+++ b/Examples/test-suite/octave/template_ns_runme.m
@@ -3,19 +3,19 @@ p1 = pairii(2,3);
p2 = pairii(p1);
if (p2.first != 2)
- error
+ error("failed");
endif
if (p2.second != 3)
- error
+ error("failed");
endif
p3 = pairdd(3.5,2.5);
p4 = pairdd(p3);
if (p4.first != 3.5)
- error
+ error("failed");
endif
if (p4.second != 2.5)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/template_tbase_template_runme.m b/Examples/test-suite/octave/template_tbase_template_runme.m
index da8ec4c69..b1bfd8f7d 100644
--- a/Examples/test-suite/octave/template_tbase_template_runme.m
+++ b/Examples/test-suite/octave/template_tbase_template_runme.m
@@ -2,5 +2,5 @@ template_tbase_template
a = make_Class_dd();
if (!strcmp(a.test(),"test"))
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/template_typedef_cplx2_runme.m b/Examples/test-suite/octave/template_typedef_cplx2_runme.m
index 94d3beb79..eb783fe81 100644
--- a/Examples/test-suite/octave/template_typedef_cplx2_runme.m
+++ b/Examples/test-suite/octave/template_typedef_cplx2_runme.m
@@ -12,10 +12,10 @@ catch
error("is not an instance")
end_try_catch
-if (findstr('ArithUnaryFunction',swig_type(d)) != 1)
+if (strfind('ArithUnaryFunction',swig_type(d)) != 1)
d
error("is not an ArithUnaryFunction")
- error
+ error("failed");
endif
try
@@ -26,7 +26,7 @@ catch
error("is not an instance")
end_try_catch
-if (findstr('ArithUnaryFunction',swig_type(e)) != 1)
+if (strfind('ArithUnaryFunction',swig_type(e)) != 1)
e
error("is not an ArithUnaryFunction")
endif
@@ -44,7 +44,7 @@ catch
error("is not an instance")
end_try_catch
-if (findstr('ArithUnaryFunction',swig_type(c)) != 1)
+if (strfind('ArithUnaryFunction',swig_type(c)) != 1)
c
error("is not an ArithUnaryFunction")
endif
@@ -57,7 +57,7 @@ catch
error("is not an instance")
end_try_catch
-if (findstr('ArithUnaryFunction',swig_type(f)) != 1)
+if (strfind('ArithUnaryFunction',swig_type(f)) != 1)
f
error("is not an ArithUnaryFunction")
endif
@@ -74,10 +74,10 @@ catch
error("is not an instance")
end_try_catch
-if (findstr('ArithUnaryFunction',swig_type(g)) != 1)
+if (strfind('ArithUnaryFunction',swig_type(g)) != 1)
g
error("is not an ArithUnaryFunction")
- error
+ error("failed");
endif
@@ -89,7 +89,7 @@ catch
error("is not an instance")
end_try_catch
-if (findstr('ArithUnaryFunction',swig_type(h)) == -1)
+if (strfind('ArithUnaryFunction',swig_type(h)) == -1)
h
error("is not an ArithUnaryFunction")
endif
@@ -98,6 +98,6 @@ try
a = g.get_value();
catch
error(g, "has not get_value() method")
- error
+ error("failed");
end_try_catch
diff --git a/Examples/test-suite/octave/template_typedef_cplx_runme.m b/Examples/test-suite/octave/template_typedef_cplx_runme.m
index d00981cec..9e3e3888f 100644
--- a/Examples/test-suite/octave/template_typedef_cplx_runme.m
+++ b/Examples/test-suite/octave/template_typedef_cplx_runme.m
@@ -12,7 +12,7 @@ catch
error("is not an instance")
end_try_catch
-if (findstr("ArithUnaryFunction",swig_type(d)) != 1)
+if (strfind("ArithUnaryFunction",swig_type(d)) != 1)
d
error("is not an ArithUnaryFunction")
endif
@@ -24,7 +24,7 @@ catch
error(e, "is not an instance")
end_try_catch
-if (findstr('ArithUnaryFunction',swig_type(e)) != 1);
+if (strfind('ArithUnaryFunction',swig_type(e)) != 1);
c
error("is not an ArithUnaryFunction")
endif
@@ -42,7 +42,7 @@ catch
error("is not an instance")
end_try_catch
-if (findstr('ArithUnaryFunction',swig_type(c)) != 1)
+if (strfind('ArithUnaryFunction',swig_type(c)) != 1)
c
error("is not an ArithUnaryFunction")
endif
@@ -55,7 +55,7 @@ catch
error("is not an instance")
end_try_catch
-if (findstr('ArithUnaryFunction',swig_type(f)) != 1)
+if (strfind('ArithUnaryFunction',swig_type(f)) != 1)
f
error("is not an ArithUnaryFunction")
endif
@@ -72,7 +72,7 @@ catch
error("is not an instance")
end_try_catch
-if (findstr('ArithUnaryFunction',swig_type(g)) != 1)
+if (strfind('ArithUnaryFunction',swig_type(g)) != 1)
g
error("is not an ArithUnaryFunction")
endif
@@ -86,7 +86,7 @@ catch
error("is not an instance")
end_try_catch
-if (findstr('ArithUnaryFunction',swig_type(h)) != 1)
+if (strfind('ArithUnaryFunction',swig_type(h)) != 1)
h
error("is not an ArithUnaryFunction")
endif
diff --git a/Examples/test-suite/octave/template_typedef_runme.m b/Examples/test-suite/octave/template_typedef_runme.m
index 8d8af795b..2a734e207 100644
--- a/Examples/test-suite/octave/template_typedef_runme.m
+++ b/Examples/test-suite/octave/template_typedef_runme.m
@@ -8,7 +8,7 @@ try
a = swig_this(d);
a = swig_this(c);
catch
- error
+ error("failed");
end_try_catch
try
@@ -37,15 +37,15 @@ end_try_catch
# the old large format
if (strcmp("<unknown>",swig_typequery("vfncs::ArithUnaryFunction<vfncs::arith_traits<float,double>::argument_type,vfncs::arith_traits<float,double >::result_type > *")))
- error
+ error("failed");
endif
# the reduced format
if (strcmp("<unknown>",swig_typequery("vfncs::ArithUnaryFunction<double,double> *")))
- error
+ error("failed");
endif
# this is a bad name
if (!strcmp("<unknown>",swig_typequery("vfncs::ArithUnaryFunction<double,doublex> *")))
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/typemap_namespace_runme.m b/Examples/test-suite/octave/typemap_namespace_runme.m
index ec62a3910..e67781c66 100644
--- a/Examples/test-suite/octave/typemap_namespace_runme.m
+++ b/Examples/test-suite/octave/typemap_namespace_runme.m
@@ -1,10 +1,10 @@
typemap_namespace
if (!strcmp(test1("hello"),"hello"))
- error
+ error("failed");
endif
if (!strcmp(test2("hello"),"hello"))
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/typemap_ns_using_runme.m b/Examples/test-suite/octave/typemap_ns_using_runme.m
index dd3f657f0..d94241b9c 100644
--- a/Examples/test-suite/octave/typemap_ns_using_runme.m
+++ b/Examples/test-suite/octave/typemap_ns_using_runme.m
@@ -1,5 +1,5 @@
typemap_ns_using
if (typemap_ns_using.spam(37) != 37)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/types_directive_runme.m b/Examples/test-suite/octave/types_directive_runme.m
index 0757c6c39..5ad4af1bb 100644
--- a/Examples/test-suite/octave/types_directive_runme.m
+++ b/Examples/test-suite/octave/types_directive_runme.m
@@ -3,13 +3,13 @@ types_directive
d1 = Time1(2001, 2, 3, 60);
newDate = add(d1, 7); # check that a Time1 instance is accepted where Date is expected
if (newDate.day != 10)
- error
+ error("failed");
endif
d2 = Time2(1999, 8, 7, 60);
newDate = add(d2, 7); # check that a Time2 instance is accepted where Date is expected
if (newDate.day != 14)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/using1_runme.m b/Examples/test-suite/octave/using1_runme.m
index 9253a1d35..e25128ec7 100644
--- a/Examples/test-suite/octave/using1_runme.m
+++ b/Examples/test-suite/octave/using1_runme.m
@@ -6,5 +6,5 @@ endif
using1
if (using1.spam(37) != 37)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/using2_runme.m b/Examples/test-suite/octave/using2_runme.m
index 7cc668940..0213ee7c6 100644
--- a/Examples/test-suite/octave/using2_runme.m
+++ b/Examples/test-suite/octave/using2_runme.m
@@ -6,5 +6,5 @@ endif
using2
if (using2.spam(37) != 37)
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/virtual_poly_runme.m b/Examples/test-suite/octave/virtual_poly_runme.m
index 0c7c95153..363f86798 100644
--- a/Examples/test-suite/octave/virtual_poly_runme.m
+++ b/Examples/test-suite/octave/virtual_poly_runme.m
@@ -10,23 +10,23 @@ dc = d.copy();
ic = i.copy();
if (d.get() != dc.get())
- error
+ error("failed");
endif
if (i.get() != ic.get())
- error
+ error("failed");
endif
virtual_poly.incr(ic);
if ((i.get() + 1) != ic.get())
- error
+ error("failed");
endif
dr = d.ref_this();
if (d.get() != dr.get())
- error
+ error("failed");
endif
@@ -35,10 +35,10 @@ endif
#
ddc = virtual_poly.NDouble_narrow(d.nnumber());
if (d.get() != ddc.get())
- error
+ error("failed");
endif
dic = virtual_poly.NInt_narrow(i.nnumber());
if (i.get() != dic.get())
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave/voidtest_runme.m b/Examples/test-suite/octave/voidtest_runme.m
index fb411ee4e..c4815a597 100644
--- a/Examples/test-suite/octave/voidtest_runme.m
+++ b/Examples/test-suite/octave/voidtest_runme.m
@@ -27,16 +27,16 @@ end_try_catch
v1 = voidtest.vfunc1(f);
v2 = voidtest.vfunc2(f);
if (swig_this(v1) != swig_this(v2))
- error
+ error("failed");
endif
v3 = voidtest.vfunc3(v1);
if (swig_this(v3) != swig_this(f))
- error
+ error("failed");
endif
v4 = voidtest.vfunc1(f);
if (swig_this(v4) != swig_this(v1))
- error
+ error("failed");
endif
diff --git a/Examples/test-suite/octave_cell_deref.i b/Examples/test-suite/octave_cell_deref.i
index 2e92ec4de..272ba7c99 100644
--- a/Examples/test-suite/octave_cell_deref.i
+++ b/Examples/test-suite/octave_cell_deref.i
@@ -1,7 +1,7 @@
%module octave_cell_deref
%inline {
- bool func(const char* s) {
+ bool funk(const char* s) {
return !strcmp("hello",s);
}
diff --git a/Examples/test-suite/overload_arrays.i b/Examples/test-suite/overload_arrays.i
index 42c08390a..272c96a3d 100644
--- a/Examples/test-suite/overload_arrays.i
+++ b/Examples/test-suite/overload_arrays.i
@@ -18,9 +18,10 @@
%rename(Foos) Foo;
#endif
+#ifdef SWIGOCAML
+%warnfilter(SWIGWARN_PARSE_KEYWORD) type;
+#endif
-
-#ifndef SWIG_NO_OVERLOAD
%immutable Spam::type;
%inline %{
@@ -130,8 +131,6 @@ static char *bar(void *[SIZE]) {
%}
-#endif
-
%inline {
class ClassA
diff --git a/Examples/test-suite/overload_complicated.i b/Examples/test-suite/overload_complicated.i
index 63ed32b3a..08abaaed6 100644
--- a/Examples/test-suite/overload_complicated.i
+++ b/Examples/test-suite/overload_complicated.i
@@ -1,27 +1,27 @@
// A complicated test of overloaded functions
%module overload_complicated
-#ifndef SWIG_NO_OVERLOAD
-
-// Different warning filters needed for scripting languages (eg Python) and for statically typed languages (eg C#).
-%warnfilter(509, 516) Pop::Pop; // Overloaded xxxx is shadowed by xxxx at xxx:y. | Overloaded method xxxx ignored. Method at xxx:y used.
-%warnfilter(509, 516) Pop::hip; // Overloaded xxxx is shadowed by xxxx at xxx:y. | Overloaded method xxxx ignored. Method at xxx:y used.
-%warnfilter(509, 516) Pop::hop; // Overloaded xxxx is shadowed by xxxx at xxx:y. | Overloaded method xxxx ignored. Method at xxx:y used.
-%warnfilter(509, 516) Pop::pop; // Overloaded xxxx is shadowed by xxxx at xxx:y. | Overloaded method xxxx ignored. Method at xxx:y used.
-%warnfilter(516) Pop::bop; // Overloaded method xxxx ignored. Method at xxx:y used.
-%warnfilter(516) Pop::bip; // Overloaded method xxxx ignored. Method at xxx:y used.
-%warnfilter(509, 516) ::muzak; // Overloaded xxxx is shadowed by xxxx at xxx:y. | Overloaded method xxxx ignored. Method at xxx:y used.
+// Different overloaded warning filters needed for scripting languages (eg Python) and for statically typed languages (eg C#).
+%warnfilter(509, 516) Pop::Pop;
+%warnfilter(509, 516) Pop::hip;
+%warnfilter(509, 516) Pop::hop;
+%warnfilter(509, 516) Pop::pop;
+%warnfilter(516) Pop::bop;
+%warnfilter(516) Pop::bip;
+%warnfilter(509, 516) ::muzak;
+%warnfilter(509, 516) foo;
%typemap(in, numinputs=0) int l { $1 = 4711; }
%inline %{
-double foo(int, int, char *, int) {
+int foo(int, int, char *, int) {
return 15;
}
-double foo(int i, int j, double k = 17.4, int l = 18, char m = 'P') {
- return i + j + k + l + (int) m;
+int foo(int i, int j, double k = 17.4, int l = 18 /* Note numinputs typemap above */, char m = 'P') {
+ int sum = i + j + (int)k + l + (int)m;
+ return sum;
}
struct Pop {
@@ -67,6 +67,3 @@ int muzak(int& i) { return 3003; }
int muzak(const int* i) { return 3004; }
%}
-
-#endif
-
diff --git a/Examples/test-suite/overload_copy.i b/Examples/test-suite/overload_copy.i
index a685f76e2..238d011a6 100644
--- a/Examples/test-suite/overload_copy.i
+++ b/Examples/test-suite/overload_copy.i
@@ -1,7 +1,6 @@
// Tests copy constructor
%module overload_copy
-#ifndef SWIG_NO_OVERLOAD
%inline %{
class Foo {
@@ -11,6 +10,3 @@ public:
};
%}
-
-#endif
-
diff --git a/Examples/test-suite/overload_method.i b/Examples/test-suite/overload_method.i
index 8b44b8172..f282df6e2 100644
--- a/Examples/test-suite/overload_method.i
+++ b/Examples/test-suite/overload_method.i
@@ -1,6 +1,11 @@
/* This test confirms the fix to sourceforge bug #3478922 for R */
%module overload_method
+
+#ifdef SWIGOCAML
+%warnfilter(SWIGWARN_PARSE_KEYWORD) method;
+#endif
+
%inline %{
class Base
{
diff --git a/Examples/test-suite/overload_null.i b/Examples/test-suite/overload_null.i
new file mode 100644
index 000000000..d4879fdb5
--- /dev/null
+++ b/Examples/test-suite/overload_null.i
@@ -0,0 +1,52 @@
+%module overload_null
+
+%{
+struct F {};
+%}
+
+%inline %{
+struct X {};
+struct Y {};
+struct F;
+
+struct Overload {
+ int byval1(X x) { return 1; }
+ int byval1(Y* y) { return 2; }
+
+ int byval2(Y* y) { return 3; }
+ int byval2(X x) { return 4; }
+
+ int byref1(X& x) { return 5; }
+ int byref1(Y* y) { return 6; }
+
+ int byref2(Y* y) { return 7; }
+ int byref2(X& x) { return 8; }
+
+ int byconstref1(const X& x) { return 9; }
+ int byconstref1(Y* y) { return 10; }
+
+ int byconstref2(Y* y) { return 11; }
+ int byconstref2(const X& x) { return 12; }
+
+ // const pointer references
+ int byval1cpr(X x) { return 13; }
+ int byval1cpr(Y*const& y) { return 14; }
+
+ int byval2cpr(Y*const& y) { return 15; }
+ int byval2cpr(X x) { return 16; }
+
+ // forward class declaration
+ int byval1forwardptr(X x) { return 17; }
+ int byval1forwardptr(F* f) { return 18; }
+
+ int byval2forwardptr(F* f) { return 19; }
+ int byval2forwardptr(X x) { return 20; }
+
+ int byval1forwardref(X x) { return 21; }
+ int byval1forwardref(F& f) { return -21; }
+
+ int byval2forwardref(F& f) { return -22; }
+ int byval2forwardref(X x) { return 22; }
+
+};
+%}
diff --git a/Examples/test-suite/overload_simple.i b/Examples/test-suite/overload_simple.i
index 6bedf6cef..ba1900b40 100644
--- a/Examples/test-suite/overload_simple.i
+++ b/Examples/test-suite/overload_simple.i
@@ -19,7 +19,10 @@
%rename(Foos) Foo;
#endif
-#ifndef SWIG_NO_OVERLOAD
+#ifdef SWIGOCAML
+%warnfilter(SWIGWARN_PARSE_KEYWORD) type;
+#endif
+
%immutable Spam::type;
%inline %{
@@ -177,8 +180,6 @@ long long ll(long long ull) { return ull; }
%malloc(void);
%free(void);
-#endif
-
%inline {
class ClassA
diff --git a/Examples/test-suite/perl5/README b/Examples/test-suite/perl5/README
index 804dec8e8..f15c07849 100644
--- a/Examples/test-suite/perl5/README
+++ b/Examples/test-suite/perl5/README
@@ -6,7 +6,7 @@ Test::More Support
==
Test::More is a standard perl test harness tool.
-Support was added for for using Test::More in 1.3.28.
+Support was added for using Test::More in 1.3.28.
If adding a new test to this suite, please use Test::More.
There are a few legacy test cases which do not use Test::More and these ought to be converted:
diff --git a/Examples/test-suite/perl5/director_classes_runme.pl b/Examples/test-suite/perl5/director_classes_runme.pl
index a4fddeed9..5e72703e0 100644
--- a/Examples/test-suite/perl5/director_classes_runme.pl
+++ b/Examples/test-suite/perl5/director_classes_runme.pl
@@ -1,6 +1,6 @@
use strict;
use warnings;
-use Test::More tests => 29;
+use Test::More tests => 32;
BEGIN { use_ok 'director_classes' }
require_ok 'director_classes';
@@ -10,6 +10,7 @@ require_ok 'director_classes';
sub Val { $_[1] }
sub Ref { $_[1] }
sub Ptr { $_[1] }
+ sub ConstPtrRef { $_[1] }
sub FullyOverloaded {
my $rv = shift->SUPER::FullyOverloaded(@_);
$rv =~ s/Base/__PACKAGE__/sge;
@@ -45,6 +46,7 @@ sub makeCalls { my($caller, $base) = @_;
is($caller->ValCall($dh)->{val}, $dh->{val}, "$bname.Val");
is($caller->RefCall($dh)->{val}, $dh->{val}, "$bname.Ref");
is($caller->PtrCall($dh)->{val}, $dh->{val}, "$bname.Ptr");
+ is($caller->ConstPtrRefCall($dh)->{val}, $dh->{val}, "$bname.ConstPtrRef");
is($caller->FullyOverloadedCall(1),
"${bname}::FullyOverloaded(int)",
"$bname.FullyOverloaded(int)");
diff --git a/Examples/test-suite/perl5/global_vars_runme.pl b/Examples/test-suite/perl5/global_vars_runme.pl
index b645f7bac..6375aa7da 100644
--- a/Examples/test-suite/perl5/global_vars_runme.pl
+++ b/Examples/test-suite/perl5/global_vars_runme.pl
@@ -1,6 +1,6 @@
use strict;
use warnings;
-use Test::More tests => 4;
+use Test::More tests => 6;
BEGIN { use_ok('global_vars') }
require_ok('global_vars');
@@ -9,3 +9,9 @@ isa_ok($an, 'global_vars::A');
$global_vars::ap = $an;
is($global_vars::ap, $an, "global var assignment");
+# Regression test for https://sourceforge.net/p/swig/bugs/564/ - changing the
+# value in C/C++ apparently wasn't reflected in Perl:
+$global_vars::x = 17;
+is($global_vars::x, 17, "global var assignment");
+global_vars::init();
+is($global_vars::x, 1234, "C++ global var change visible in Perl");
diff --git a/Examples/test-suite/perl5/li_typemaps_runme.pl b/Examples/test-suite/perl5/li_typemaps_runme.pl
index a573b89a0..2755862a2 100644
--- a/Examples/test-suite/perl5/li_typemaps_runme.pl
+++ b/Examples/test-suite/perl5/li_typemaps_runme.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
use strict;
use warnings;
-use Test::More tests => 415;
+use Test::More tests => 416;
BEGIN { use_ok('li_typemaps') }
require_ok('li_typemaps');
@@ -75,10 +75,11 @@ SKIP: {
batch('ulonglong', $c);
}
-my($foo, $int) = li_typemaps::out_foo(10);
+my($foo, $int, $int2) = li_typemaps::out_foo(10);
isa_ok($foo, 'li_typemaps::Foo');
is($foo->{a}, 10);
is($int, 20);
+is($int2, 30);
my($a, $b) = li_typemaps::inoutr_int2(13, 31);
is($a, 13);
diff --git a/Examples/test-suite/perl5/overload_null_runme.pl b/Examples/test-suite/perl5/overload_null_runme.pl
new file mode 100644
index 000000000..7cc5090de
--- /dev/null
+++ b/Examples/test-suite/perl5/overload_null_runme.pl
@@ -0,0 +1,44 @@
+use strict;
+use warnings;
+use Test::More tests => 24;
+BEGIN { use_ok('overload_null') }
+require_ok('overload_null');
+
+my $o = new overload_null::Overload();
+my $x = new overload_null::X();
+
+is(1, $o->byval1($x));
+is(2, $o->byval1(undef));
+
+is(3, $o->byval2(undef));
+is(4, $o->byval2($x));
+
+is(5, $o->byref1($x));
+is(6, $o->byref1(undef));
+
+is(7, $o->byref2(undef));
+is(8, $o->byref2($x));
+
+is(9, $o->byconstref1($x));
+is(10, $o->byconstref1(undef));
+
+is(11, $o->byconstref2(undef));
+is(12, $o->byconstref2($x));
+
+# const pointer references
+is(13, $o->byval1cpr($x));
+is(14, $o->byval1cpr(undef));
+
+is(15, $o->byval2cpr(undef));
+is(16, $o->byval2cpr($x));
+
+# forward class declaration
+is(17, $o->byval1forwardptr($x));
+is(18, $o->byval1forwardptr(undef));
+
+is(19, $o->byval2forwardptr(undef));
+is(20, $o->byval2forwardptr($x));
+
+is(21, $o->byval1forwardref($x));
+
+is(22, $o->byval2forwardref($x));
diff --git a/Examples/test-suite/perl5/run-perl-test.pl b/Examples/test-suite/perl5/run-perl-test.pl
index 106bf002b..5ea4e5115 100644
--- a/Examples/test-suite/perl5/run-perl-test.pl
+++ b/Examples/test-suite/perl5/run-perl-test.pl
@@ -7,7 +7,7 @@ use strict;
my $command = shift @ARGV;
-my $output = `$^X $command 2>&1`;
+my $output = `$^X -I. $command 2>&1`;
die "SWIG Perl test failed: \n\n$output\n"
if $?;
diff --git a/Examples/test-suite/perl5/scilab_multivalue_runme.pl b/Examples/test-suite/perl5/scilab_multivalue_runme.pl
new file mode 100644
index 000000000..8be8834f7
--- /dev/null
+++ b/Examples/test-suite/perl5/scilab_multivalue_runme.pl
@@ -0,0 +1,88 @@
+use strict;
+use warnings;
+use Test::More tests => 44;
+BEGIN { use_ok('scilab_multivalue') }
+require_ok('scilab_multivalue');
+
+my($a, $b, $c, $d, $ret);
+
+# OUTPUT
+
+($a, $b) = scilab_multivalue::output2();
+is($a, 1, "[a, b] = output2(): a");
+is($b, 2, "[a, b] = output2(): b");
+
+($ret, $a, $b) = scilab_multivalue::output2Ret();
+is($ret, 3, "[a, b] = output2Ret(): b");
+is($a, 1, "[a, b] = output2Ret(): a");
+is($b, 2, "[a, b] = output2Ret(): b");
+
+($c, $d) = scilab_multivalue::output2Input2(1, 2);
+is($c, 2, "[c, d] = output2Input2(1, 2): c");
+is($d, 4, "[c, d] = output2Input2(1, 2): d");
+
+($ret, $c, $d) = scilab_multivalue::output2Input2Ret(1, 2);
+is($ret, 6, "[ret, c, d] = output2Input2Ret(1, 2): ret");
+is($c, 2, "[ret, c, d] = output2Input2Ret(1, 2): c");
+is($d, 4, "[ret, c, d = output2Input2Ret(1, 2): d");
+
+($ret, $a, $b, $c) = scilab_multivalue::output3Input1Ret(10);
+is($ret, 10, "[ret, a, b, c] = output3Input1Ret(10): ret");
+is($a, 11, "[ret, a, b, c] = output3Input1Ret(10): a");
+is($b, 12, "[ret, a, b, c] = output3Input1Ret(10): b");
+is($c, 13, "[ret, a, b, c] = output3Input1Ret(10): c");
+
+($ret, $a, $b, $c) = scilab_multivalue::output3Input3Ret(10, 20, 30);
+is($ret, 66, "[ret, a, b, c] = output3Input1Ret(10, 20, 30): ret");
+is($a, 11, "[ret, a, b, c] = output3Input1Ret(10, 20, 30): a");
+is($b, 22, "[ret, a, b, c] = output3Input1Ret(10, 20, 30): b");
+is($c, 33, "[ret, a, b, c] = output3Input1Ret(10, 20, 30): c");
+
+
+# INOUT
+
+($a, $b) = scilab_multivalue::inout2(1, 2);
+is($a, 2, "[a, b] = output2(1, 2): a");
+is($b, 4, "[a, b] = output2(1, 2): b");
+
+($ret, $a, $b) = scilab_multivalue::inout2Ret(1, 2);
+is($ret, 6, "[a, b] = inout2Ret(1, 2): b");
+is($a, 2, "[a, b] = inout2Ret(1, 2): a");
+is($b, 4, "[a, b] = inout2Ret(1, 2): b");
+
+($c, $d) = scilab_multivalue::inout2Input2(1, 2, 1, 1);
+is($c, 2, "[c, d] = inout2Input2(1, 2): c");
+is($d, 3, "[c, d] = inout2Input2(1, 2): d");
+
+($ret, $c, $d) = scilab_multivalue::inout2Input2Ret(1, 2, 1, 1);
+is($ret, 5, "[c, d] = inout2Input2Ret(1, 2): ret");
+is($c, 2, "[c, d] = inout2Input2Ret(1, 2): c");
+is($d, 3, "[c, d] = inout2Input2Ret(1, 4): d");
+
+($ret, $a, $b, $c) = scilab_multivalue::inout3Input1Ret(10, 1, 2, 3);
+is($ret, 10, "[ret, a, b, c] = output3Input1Ret(ret, 1, 2, 3): ret");
+is($a, 11, "[ret, a, b, c] = output3Input1Ret(ret, 1, 2, 3): a");
+is($b, 12, "[ret, a, b, c] = output3Input1Ret(ret, 1, 2, 3): b");
+is($c, 13, "[ret, a, b, c] = output3Input1Ret(ret, 1, 2, 3): c");
+
+($ret, $a, $b, $c) = scilab_multivalue::inout3Input3Ret(10, 1, 20, 2, 30, 3);
+is($ret, 66, "[ret, a, b, c] = output3Input1Ret(10, 20, 30): ret");
+is($a, 11, "[ret, a, b, c] = inout3Input1Ret(10, 1, 20, 2, 30, 3): a");
+is($b, 22, "[ret, a, b, c] = inout3Input1Ret(10, 1, 20, 2, 30, 3): b");
+is($c, 33, "[ret, a, b, c] = inout3Input1Ret(10, 1, 20, 2, 30, 3): c");
+
+
+# CLASS
+
+$a = scilab_multivalue::ClassA->new();
+
+($ret, $c, $d) = $a->output2Input2Ret(1, 2);
+is($ret, 6, "[ret, c, d] = ClassA_output2Input2Ret(a, 1, 2): ret");
+is($c, 2, "[c, d] = ClassA_output2Input2Ret(a, 1, 2): c");
+is($d, 4, "[c, d] = ClassA_output2Input2Ret(a, 1, 2): d");
+
+($ret, $c, $d) = $a->inout2Input2Ret(1, 2, 1, 1);
+is($ret, 5, "[ret, c, d] = ClassA_inout2Input2Ret(a, 1, 2): ret");
+is($c, 2, "[c, d] = ClassA_inout2Input2(a, 1, 2): c");
+is($d, 3, "[c, d] = ClassA_inout2Input2(a, 1, 2): d");
+
diff --git a/Examples/test-suite/php/Makefile.in b/Examples/test-suite/php/Makefile.in
index c554e2b17..693615bc6 100644
--- a/Examples/test-suite/php/Makefile.in
+++ b/Examples/test-suite/php/Makefile.in
@@ -14,6 +14,7 @@ CPP_TEST_CASES += \
li_factory \
php_iterator \
php_namewarn_rename \
+ php_pragma \
include $(srcdir)/../common.mk
@@ -78,3 +79,4 @@ clean:
rm -f mod_a.php mod_b.php php_mod_a.h php_mod_b.h
rm -f multi_import_a.php multi_import_b.php php_multi_import_a.h php_multi_import_b.h
rm -f packageoption_a.php packageoption_b.php packageoption_c.php php_packageoption_a.h php_packageoption_b.h php_packageoption_c.h
+ rm -f template_typedef_cplx2.php php_template_typedef_cplx2.h
diff --git a/Examples/test-suite/php/abstract_inherit_ok_runme.php b/Examples/test-suite/php/abstract_inherit_ok_runme.php
index c2d86499b..c2c343dac 100644
--- a/Examples/test-suite/php/abstract_inherit_ok_runme.php
+++ b/Examples/test-suite/php/abstract_inherit_ok_runme.php
@@ -3,7 +3,7 @@
require "tests.php";
require "abstract_inherit_ok.php";
-check::classes(array(Foo,Spam));
+check::classes(array('Foo','Spam'));
$spam=new Spam();
check::equal(0,$spam->blah(),"spam object method");
diff --git a/Examples/test-suite/php/abstract_inherit_runme.php b/Examples/test-suite/php/abstract_inherit_runme.php
index 3554e6fd8..514bbc3b0 100644
--- a/Examples/test-suite/php/abstract_inherit_runme.php
+++ b/Examples/test-suite/php/abstract_inherit_runme.php
@@ -3,7 +3,7 @@
require "tests.php";
require "abstract_inherit.php";
-check::classes(array(Foo,Bar,Spam,NRFilter_i,NRRCFilter_i,NRRCFilterpro_i,NRRCFilterpri_i));
+check::classes(array('Foo','Bar','Spam','NRFilter_i','NRRCFilter_i','NRRCFilterpro_i','NRRCFilterpri_i'));
// This constructor attempt should fail as there isn't one
//$spam=new Spam();
diff --git a/Examples/test-suite/php/add_link_runme.php b/Examples/test-suite/php/add_link_runme.php
index 7523bd604..3e16fa1df 100644
--- a/Examples/test-suite/php/add_link_runme.php
+++ b/Examples/test-suite/php/add_link_runme.php
@@ -4,15 +4,15 @@ require "tests.php";
require "add_link.php";
// No new functions, except the flat functions
-check::functions(array(new_foo,foo_blah));
+check::functions(array('new_foo','foo_blah'));
-check::classes(array(Foo));
+check::classes(array('Foo'));
$foo=new foo();
-check::is_a($foo,foo);
+check::is_a($foo,'foo');
$foo_blah=$foo->blah();
-check::is_a($foo_blah,foo);
+check::is_a($foo_blah,'foo');
//fails, can't be called as a class method, should allow and make it nil?
//$class_foo_blah=foo::blah();
diff --git a/Examples/test-suite/php/argout_runme.php b/Examples/test-suite/php/argout_runme.php
index 33fbd8129..8b66613fd 100644
--- a/Examples/test-suite/php/argout_runme.php
+++ b/Examples/test-suite/php/argout_runme.php
@@ -3,7 +3,7 @@
require "tests.php";
require "argout.php";
-check::functions(array(incp,incr,inctr,new_intp,copy_intp,delete_intp,intp_assign,intp_value,voidhandle,handle));
+check::functions(array('incp','incr','inctr','new_intp','copy_intp','delete_intp','intp_assign','intp_value','voidhandle','handle'));
$ip=copy_intp(42);
check::equal(42,incp($ip),"42==incp($ip)");
@@ -30,7 +30,7 @@ unset($handle);
#$handledata=handle($handle);
#check::equal($handledata,"Here it is","\$handledata != \"Here it is\"");
-unset($handle);
+$handle=NULL;
voidhandle($handle);
check::isnull($handle,'$handle not null');
diff --git a/Examples/test-suite/php/arrayptr_runme.php b/Examples/test-suite/php/arrayptr_runme.php
index 3b9baed05..86b7f8628 100644
--- a/Examples/test-suite/php/arrayptr_runme.php
+++ b/Examples/test-suite/php/arrayptr_runme.php
@@ -4,7 +4,7 @@ require "tests.php";
require "arrayptr.php";
// No new functions
-check::functions(array(foo));
+check::functions(array('foo'));
// No new classes
check::classes(array());
// now new vars
diff --git a/Examples/test-suite/php/arrays_global_runme.php b/Examples/test-suite/php/arrays_global_runme.php
index 12a7806c9..95a300775 100644
--- a/Examples/test-suite/php/arrays_global_runme.php
+++ b/Examples/test-suite/php/arrays_global_runme.php
@@ -3,17 +3,17 @@
require "tests.php";
require "arrays_global.php";
-check::functions(array(test_a,test_b,new_simplestruct,new_material));
-check::classes(array(arrays_global,SimpleStruct,Material));
-check::globals(array(array_c,array_sc,array_uc,array_s,array_us,array_i,array_ui,array_l,array_ul,array_ll,array_f,array_d,array_struct,array_structpointers,array_ipointers,array_enum,array_enumpointers,array_const_i,beginstring_fix44a,beginstring_fix44b,beginstring_fix44c,beginstring_fix44d,beginstring_fix44e,beginstring_fix44f,chitmat,hitmat_val,hitmat,simplestruct_double_field));
+check::functions(array('test_a','test_b','new_simplestruct','new_material'));
+check::classes(array('arrays_global','SimpleStruct','Material'));
+check::globals(array('array_c','array_sc','array_uc','array_s','array_us','array_i','array_ui','array_l','array_ul','array_ll','array_f','array_d','array_struct','array_structpointers','array_ipointers','array_enum','array_enumpointers','array_const_i','beginstring_fix44a','beginstring_fix44b','beginstring_fix44c','beginstring_fix44d','beginstring_fix44e','beginstring_fix44f','chitmat','hitmat_val','hitmat','simplestruct_double_field'));
// The size of array_c is 2, but the last byte is \0, so we can only store a
// single byte string in it.
-check::set(array_c,"Z");
-check::equal("Z",check::get(array_c),"set array_c");
-check::set(array_c,"xy");
-check::equal("x",check::get(array_c),"set array_c");
-check::set(array_c,"h");
-check::equal("h",check::get(array_c),"set array_c");
+check::set("array_c","Z");
+check::equal("Z",check::get("array_c"),"set array_c");
+check::set("array_c","xy");
+check::equal("x",check::get("array_c"),"set array_c");
+check::set("array_c","h");
+check::equal("h",check::get("array_c"),"set array_c");
check::done();
?>
diff --git a/Examples/test-suite/php/arrays_global_twodim_runme.php b/Examples/test-suite/php/arrays_global_twodim_runme.php
index 40ecf1719..d9f50a6de 100644
--- a/Examples/test-suite/php/arrays_global_twodim_runme.php
+++ b/Examples/test-suite/php/arrays_global_twodim_runme.php
@@ -3,14 +3,14 @@
require "tests.php";
require "arrays_global_twodim.php";
-check::functions(array(fn_taking_arrays,get_2d_array,new_simplestruct,new_material));
-check::classes(array(arrays_global_twodim,SimpleStruct,Material));
-check::globals(array(array_c,array_sc,array_uc,array_s,array_us,array_i,array_ui,array_l,array_ul,array_ll,array_f,array_d,array_struct,array_structpointers,array_ipointers,array_enum,array_enumpointers,array_const_i,chitmat,hitmat_val,hitmat,simplestruct_double_field));
+check::functions(array('fn_taking_arrays','get_2d_array','new_simplestruct','new_material'));
+check::classes(array('arrays_global_twodim','SimpleStruct','Material'));
+check::globals(array('array_c','array_sc','array_uc','array_s','array_us','array_i','array_ui','array_l','array_ul','array_ll','array_f','array_d','array_struct','array_structpointers','array_ipointers','array_enum','array_enumpointers','array_const_i','chitmat','hitmat_val','hitmat','simplestruct_double_field'));
$a1=array(10,11,12,13);
$a2=array(14,15,16,17);
$a=array($a1,$a2);
-$_a=check::get(array_const_i);
+$_a=check::get('array_const_i');
for($x=0;$x<count($a1);$x++) {
for($y=0;$y<2;$y++) {
diff --git a/Examples/test-suite/php/arrays_runme.php b/Examples/test-suite/php/arrays_runme.php
index ae17d05e7..c6e9e8f70 100644
--- a/Examples/test-suite/php/arrays_runme.php
+++ b/Examples/test-suite/php/arrays_runme.php
@@ -2,12 +2,12 @@
require "tests.php";
require "arrays.php";
-check::functions(array(fn_taking_arrays,newintpointer,setintfrompointer,getintfrompointer,array_pointer_func));
-check::classes(array(arrays,SimpleStruct,ArrayStruct,CartPoseData_t));
-check::globals(array(simplestruct_double_field,arraystruct_array_c,arraystruct_array_sc,arraystruct_array_uc,arraystruct_array_s,arraystruct_array_us,arraystruct_array_i,arraystruct_array_ui,arraystruct_array_l,arraystruct_array_ul,arraystruct_array_ll,arraystruct_array_f,arraystruct_array_d,arraystruct_array_struct,arraystruct_array_structpointers,arraystruct_array_ipointers,arraystruct_array_enum,arraystruct_array_enumpointers,arraystruct_array_const_i,cartposedata_t_p));
+check::functions(array('fn_taking_arrays','newintpointer','setintfrompointer','getintfrompointer','array_pointer_func'));
+check::classes(array('arrays','SimpleStruct','ArrayStruct','CartPoseData_t'));
+check::globals(array('simplestruct_double_field','arraystruct_array_c','arraystruct_array_sc','arraystruct_array_uc','arraystruct_array_s','arraystruct_array_us','arraystruct_array_i','arraystruct_array_ui','arraystruct_array_l','arraystruct_array_ul','arraystruct_array_ll','arraystruct_array_f','arraystruct_array_d','arraystruct_array_struct','arraystruct_array_structpointers','arraystruct_array_ipointers','arraystruct_array_enum','arraystruct_array_enumpointers','arraystruct_array_const_i','cartposedata_t_p'));
$ss=new simplestruct();
-check::classname(simplestruct,$ss);
+check::classname('simplestruct',$ss);
$as=new arraystruct();
$as->array_c="abc";
diff --git a/Examples/test-suite/php/arrays_scope_runme.php b/Examples/test-suite/php/arrays_scope_runme.php
index c208b7518..11c180870 100644
--- a/Examples/test-suite/php/arrays_scope_runme.php
+++ b/Examples/test-suite/php/arrays_scope_runme.php
@@ -4,11 +4,11 @@ require "tests.php";
require "arrays_scope.php";
// New functions
-check::functions(array(new_bar,bar_blah));
+check::functions(array('new_bar','bar_blah'));
// New classes
-check::classes(array(arrays_scope,Bar));
+check::classes(array('arrays_scope','Bar'));
// New vars
-check::globals(array(bar_adata,bar_bdata,bar_cdata));
+check::globals(array('bar_adata','bar_bdata','bar_cdata'));
$bar=new bar();
diff --git a/Examples/test-suite/php/casts_runme.php b/Examples/test-suite/php/casts_runme.php
index 10522dca4..a9623a328 100644
--- a/Examples/test-suite/php/casts_runme.php
+++ b/Examples/test-suite/php/casts_runme.php
@@ -4,13 +4,13 @@ require "tests.php";
require "casts.php";
// No new functions
-check::functions(array(new_a,a_hello,new_b));
+check::functions(array('new_a','a_hello','new_b'));
// No new classes
-check::classes(array(A,B));
+check::classes(array('A','B'));
// now new vars
check::globals(array());
-# Make sure $b inherites hello() from class A
+# Make sure $b inherits hello() from class A
$b=new B();
$b->hello();
diff --git a/Examples/test-suite/php/class_ignore_runme.php b/Examples/test-suite/php/class_ignore_runme.php
index d5ce36217..ae4881f27 100644
--- a/Examples/test-suite/php/class_ignore_runme.php
+++ b/Examples/test-suite/php/class_ignore_runme.php
@@ -3,8 +3,8 @@
require "tests.php";
require "class_ignore.php";
-check::functions(array(do_blah,new_bar,bar_blah,new_boo,boo_away,new_far,new_hoo));
-check::classes(array(class_ignore,Bar,Boo,Far,Hoo));
+check::functions(array('do_blah','new_bar','bar_blah','new_boo','boo_away','new_far','new_hoo'));
+check::classes(array('class_ignore','Bar','Boo','Far','Hoo'));
// No new vars
check::globals(array());
diff --git a/Examples/test-suite/php/cpp_basic_runme.php b/Examples/test-suite/php/cpp_basic_runme.php
index 6a8522e3e..b24cf7000 100644
--- a/Examples/test-suite/php/cpp_basic_runme.php
+++ b/Examples/test-suite/php/cpp_basic_runme.php
@@ -4,11 +4,11 @@ require "tests.php";
require "cpp_basic.php";
// New functions
-check::functions(array(foo_func1,foo_func2,foo___str__,foosubsub___str__,bar_test,bar_testfoo,get_func1_ptr,get_func2_ptr,test_func_ptr,fl_window_show));
+check::functions(array('foo_func1','foo_func2','foo___str__','foosubsub___str__','bar_test','bar_testfoo','get_func1_ptr','get_func2_ptr','test_func_ptr','fl_window_show'));
// New classes
-check::classes(array(cpp_basic,Foo,FooSub,FooSubSub,Bar,Fl_Window));
+check::classes(array('cpp_basic','Foo','FooSub','FooSubSub','Bar','Fl_Window'));
// New vars
-check::globals(array(foo_num,foo_func_ptr,bar_fptr,bar_fref,bar_fval,bar_cint,bar_global_fptr,bar_global_fref,bar_global_fval));
+check::globals(array('foo_num','foo_func_ptr','bar_fptr','bar_fref','bar_fval','bar_cint','bar_global_fptr','bar_global_fref','bar_global_fval'));
$f = new Foo(3);
$f->func_ptr = get_func1_ptr();
diff --git a/Examples/test-suite/php/cpp_static_runme.php b/Examples/test-suite/php/cpp_static_runme.php
index 9b436b87c..20b50dd9e 100644
--- a/Examples/test-suite/php/cpp_static_runme.php
+++ b/Examples/test-suite/php/cpp_static_runme.php
@@ -4,11 +4,11 @@ require "tests.php";
require "cpp_static.php";
// New functions
-check::functions(array(staticfunctiontest_static_func,staticfunctiontest_static_func_2,staticfunctiontest_static_func_3,is_python_builtin));
+check::functions(array('staticfunctiontest_static_func','staticfunctiontest_static_func_2','staticfunctiontest_static_func_3','is_python_builtin','staticmembertest_grab_int','staticbase_grab_statty_base','staticderived_grab_statty_derived'));
// New classes
-check::classes(array(StaticMemberTest,StaticFunctionTest,cpp_static,StaticBase,StaticDerived));
+check::classes(array('StaticMemberTest','StaticFunctionTest','cpp_static','StaticBase','StaticDerived'));
// New vars
-check::globals(array(staticmembertest_static_int,staticbase_statty,staticderived_statty));
+check::globals(array('staticmembertest_static_int','staticbase_statty','staticderived_statty'));
check::done();
?>
diff --git a/Examples/test-suite/php/director_abstract_runme.php b/Examples/test-suite/php/director_abstract_runme.php
index ca3d676da..1a119cfd5 100644
--- a/Examples/test-suite/php/director_abstract_runme.php
+++ b/Examples/test-suite/php/director_abstract_runme.php
@@ -4,9 +4,9 @@ require "tests.php";
require "director_abstract.php";
// No new functions
-check::functions(array(foo_ping,foo_pong,example0_getxsize,example0_color,example0_get_color,example1_getxsize,example1_color,example1_get_color,example2_getxsize,example2_color,example2_get_color,example4_getxsize,example4_color,example4_get_color,example3_i_color,example3_i_get_color,g,a_f));
+check::functions(array('foo_ping','foo_pong','example0_getxsize','example0_color','example0_get_color','example1_getxsize','example1_color','example1_get_color','example2_getxsize','example2_color','example2_get_color','example4_getxsize','example4_color','example4_get_color','example3_i_color','example3_i_get_color','g','a_f'));
// No new classes
-check::classes(array(director_abstract,Foo,Example0,Example1,Example2,Example4,Example3_i,A));
+check::classes(array('director_abstract','Foo','Example0','Example1','Example2','Example4','Example3_i','A'));
// now new vars
check::globals(array());
diff --git a/Examples/test-suite/php/director_basic_runme.php b/Examples/test-suite/php/director_basic_runme.php
index de6b50502..478a36f80 100644
--- a/Examples/test-suite/php/director_basic_runme.php
+++ b/Examples/test-suite/php/director_basic_runme.php
@@ -4,11 +4,11 @@ require "tests.php";
require "director_basic.php";
// No new functions
-check::functions(array(foo_ping,foo_pong,foo_get_self,a_f,a_rg,a1_ff,myclass_method,myclass_vmethod,myclass_pmethod,myclass_cmethod,myclass_get_self,myclass_call_pmethod,myclasst_i_method));
+check::functions(array('foo_ping','foo_pong','foo_get_self','a_f','a_rg','a1_ff','myclass_method','myclass_vmethod','myclass_pmethod','myclass_cmethod','myclass_get_self','myclass_call_pmethod','myclasst_i_method','myclass_nonvirtual','myclass_nonoverride','myclass_call_nonvirtual','myclass_call_nonoverride','myclass_connect'));
// No new classes
-check::classes(array(Foo,A,A1,Bar,MyClass,MyClassT_i));
+check::classes(array('Foo','A','A1','Bar','MyClass','MyClassT_i'));
// now new vars
-check::globals(array(bar_x));
+check::globals(array('bar_x'));
class PhpFoo extends Foo {
function ping() {
diff --git a/Examples/test-suite/php/director_classic_runme.php b/Examples/test-suite/php/director_classic_runme.php
index d2da1b1ba..a44881e04 100644
--- a/Examples/test-suite/php/director_classic_runme.php
+++ b/Examples/test-suite/php/director_classic_runme.php
@@ -4,9 +4,9 @@ require "tests.php";
require "director_classic.php";
// No new functions
-check::functions(array(being_id,person_id,child_id,grandchild_id,caller_delcallback,caller_setcallback,caller_resetcallback,caller_call,caller_baseclass));
+check::functions(array('being_id','person_id','child_id','grandchild_id','caller_delcallback','caller_setcallback','caller_resetcallback','caller_call','caller_baseclass'));
// No new classes
-check::classes(array(Being,Person,Child,GrandChild,OrphanPerson,OrphanChild,Caller));
+check::classes(array('Being','Person','Child','GrandChild','OrphanPerson','OrphanChild','Caller'));
// now new vars
check::globals(array());
diff --git a/Examples/test-suite/php/director_default_runme.php b/Examples/test-suite/php/director_default_runme.php
index f97fc7425..c459ce3ec 100644
--- a/Examples/test-suite/php/director_default_runme.php
+++ b/Examples/test-suite/php/director_default_runme.php
@@ -4,9 +4,9 @@ require "tests.php";
require "director_default.php";
// No new functions
-check::functions(array(foo_msg,foo_getmsg,bar_msg,bar_getmsg,defaultsbase_defaultargs,defaultsderived_defaultargs));
+check::functions(array('foo_msg','foo_getmsg','bar_msg','bar_getmsg','defaultsbase_defaultargs','defaultsderived_defaultargs'));
// No new classes
-check::classes(array(Foo,Bar,DefaultsBase,DefaultsDerived));
+check::classes(array('Foo','Bar','DefaultsBase','DefaultsDerived'));
// now new vars
check::globals(array());
diff --git a/Examples/test-suite/php/director_detect_runme.php b/Examples/test-suite/php/director_detect_runme.php
index cc19c0302..a6d3aebd6 100644
--- a/Examples/test-suite/php/director_detect_runme.php
+++ b/Examples/test-suite/php/director_detect_runme.php
@@ -4,9 +4,9 @@ require "tests.php";
require "director_detect.php";
// No new functions
-check::functions(array(foo_cloner,foo_get_value,foo_get_class,foo_just_do_it,bar_baseclass,bar_cloner,bar_get_value,bar_get_class,bar_just_do_it));
+check::functions(array('foo_cloner','foo_get_value','foo_get_class','foo_just_do_it','bar_baseclass','bar_cloner','bar_get_value','bar_get_class','bar_just_do_it'));
// No new classes
-check::classes(array(A,Foo,Bar));
+check::classes(array('A','Foo','Bar'));
// now new vars
check::globals(array());
diff --git a/Examples/test-suite/php/director_enum_runme.php b/Examples/test-suite/php/director_enum_runme.php
index 8f6487a28..0571ec0da 100644
--- a/Examples/test-suite/php/director_enum_runme.php
+++ b/Examples/test-suite/php/director_enum_runme.php
@@ -4,9 +4,9 @@ require "tests.php";
require "director_enum.php";
// No new functions
-check::functions(array(foo_say_hello,foo_say_hi,foo_say_bye,foo_say_hi_ref,foo_ping,foo_ping_ref,foo_ping_member_enum,a_f,a2_f));
+check::functions(array('foo_say_hello','foo_say_hi','foo_say_bye','foo_say_hi_ref','foo_ping','foo_ping_ref','foo_ping_member_enum','a_f','a2_f'));
// No new classes
-check::classes(array(director_enum,Foo,A,B,A2,B2));
+check::classes(array('director_enum','Foo','A','B','A2','B2'));
// now new vars
check::globals(array());
diff --git a/Examples/test-suite/php/director_exception_runme.php b/Examples/test-suite/php/director_exception_runme.php
index 8b852c2ce..dd2d04e8a 100644
--- a/Examples/test-suite/php/director_exception_runme.php
+++ b/Examples/test-suite/php/director_exception_runme.php
@@ -4,9 +4,9 @@ require "tests.php";
require "director_exception.php";
// No new functions
-check::functions(array(foo_ping,foo_pong,launder,bar_ping,bar_pong,bar_pang,returnalltypes_return_int,returnalltypes_return_double,returnalltypes_return_const_char_star,returnalltypes_return_std_string,returnalltypes_return_bar,returnalltypes_call_int,returnalltypes_call_double,returnalltypes_call_const_char_star,returnalltypes_call_std_string,returnalltypes_call_bar,is_python_builtin));
+check::functions(array('foo_ping','foo_pong','launder','bar_ping','bar_pong','returnalltypes_return_int','returnalltypes_return_double','returnalltypes_return_const_char_star','returnalltypes_return_std_string','returnalltypes_return_bar','returnalltypes_call_int','returnalltypes_call_double','returnalltypes_call_const_char_star','returnalltypes_call_std_string','returnalltypes_call_bar','is_python_builtin'));
// No new classes
-check::classes(array(director_exception,Foo,Exception1,Exception2,Base,Bar,ReturnAllTypes));
+check::classes(array('director_exception','Foo','Exception1','Exception2','Base','Bar','ReturnAllTypes'));
// now new vars
check::globals(array());
diff --git a/Examples/test-suite/php/director_extend_runme.php b/Examples/test-suite/php/director_extend_runme.php
index f283aefbe..7aa2e0f78 100644
--- a/Examples/test-suite/php/director_extend_runme.php
+++ b/Examples/test-suite/php/director_extend_runme.php
@@ -4,9 +4,9 @@ require "tests.php";
require "director_extend.php";
// No new functions
-check::functions(array(spobject_getfoobar,spobject_dummy,spobject_exceptionmethod));
+check::functions(array('spobject_getfoobar','spobject_dummy','spobject_exceptionmethod'));
// No new classes
-check::classes(array(SpObject));
+check::classes(array('SpObject'));
// now new vars
check::globals(array());
diff --git a/Examples/test-suite/php/director_finalizer_runme.php b/Examples/test-suite/php/director_finalizer_runme.php
index 0fcddfd8b..96bb5c179 100644
--- a/Examples/test-suite/php/director_finalizer_runme.php
+++ b/Examples/test-suite/php/director_finalizer_runme.php
@@ -4,16 +4,16 @@ require "tests.php";
require "director_finalizer.php";
// No new functions
-check::functions(array(foo_orstatus,deletefoo,getstatus,launder,resetstatus));
+check::functions(array('foo_orstatus','deletefoo','getstatus','launder','resetstatus'));
// No new classes
-check::classes(array(director_finalizer,Foo));
+check::classes(array('director_finalizer','Foo'));
// now new vars
check::globals(array());
class MyFoo extends Foo {
function __destruct() {
$this->orStatus(2);
- if (method_exists(parent, "__destruct")) {
+ if (method_exists(get_parent_class(), "__destruct")) {
parent::__destruct();
}
}
diff --git a/Examples/test-suite/php/director_frob_runme.php b/Examples/test-suite/php/director_frob_runme.php
index 548b0b804..450a1234b 100644
--- a/Examples/test-suite/php/director_frob_runme.php
+++ b/Examples/test-suite/php/director_frob_runme.php
@@ -4,11 +4,11 @@ require "tests.php";
require "director_frob.php";
// No new functions
-check::functions(array(alpha_abs_method,bravo_abs_method,charlie_abs_method,ops_opint,ops_opintstarstarconst,ops_opintamp,ops_opintstar,ops_opconstintintstar,prims_ull,prims_callull,corecallbacks_on3dengineredrawn,corecallbacks_on3dengineredrawn2));
+check::functions(array('alpha_abs_method','bravo_abs_method','charlie_abs_method','ops_opint','ops_opintstarstarconst','ops_opintamp','ops_opintstar','ops_opconstintintstar','prims_ull','prims_callull','corecallbacks_on3dengineredrawn','corecallbacks_on3dengineredrawn2'));
// No new classes
-check::classes(array(Alpha,Bravo,Charlie,Delta,Ops,Prims,corePoint3d,coreCallbacks_On3dEngineRedrawnData,coreCallbacksOn3dEngineRedrawnData,coreCallbacks));
+check::classes(array('Alpha','Bravo','Charlie','Delta','Ops','Prims','corePoint3d','coreCallbacks_On3dEngineRedrawnData','coreCallbacksOn3dEngineRedrawnData','coreCallbacks'));
// now new vars
-check::globals(array(corecallbacks_on3dengineredrawndata__eye,corecallbacks_on3dengineredrawndata__at,corecallbackson3dengineredrawndata__eye,corecallbackson3dengineredrawndata__at));
+check::globals(array('corecallbacks_on3dengineredrawndata__eye','corecallbacks_on3dengineredrawndata__at','corecallbackson3dengineredrawndata__eye','corecallbackson3dengineredrawndata__at'));
$foo = new Bravo();
$s = $foo->abs_method();
diff --git a/Examples/test-suite/php/director_nested_runme.php b/Examples/test-suite/php/director_nested_runme.php
index 4965e94f7..9a094a182 100644
--- a/Examples/test-suite/php/director_nested_runme.php
+++ b/Examples/test-suite/php/director_nested_runme.php
@@ -4,9 +4,9 @@ require "tests.php";
require "director_nested.php";
// No new functions
-check::functions(array(foo_int_advance,foo_int_do_advance,bar_step,bar_do_advance,bar_do_step,foobar_int_get_value,foobar_int_get_name,foobar_int_name,foobar_int_get_self,foobar_int_do_advance,foobar_int_do_step));
+check::functions(array('foo_int_advance','foo_int_do_advance','bar_step','bar_do_advance','bar_do_step','foobar_int_get_value','foobar_int_get_name','foobar_int_name','foobar_int_get_self','foobar_int_do_advance','foobar_int_do_step'));
// No new classes
-check::classes(array(Foo_int,Bar,FooBar_int));
+check::classes(array('Foo_int','Bar','FooBar_int'));
// now new vars
check::globals(array());
diff --git a/Examples/test-suite/php/director_profile_runme.php b/Examples/test-suite/php/director_profile_runme.php
index c72421341..c6f4c3c94 100644
--- a/Examples/test-suite/php/director_profile_runme.php
+++ b/Examples/test-suite/php/director_profile_runme.php
@@ -4,9 +4,9 @@ require "tests.php";
require "director_profile.php";
// No new functions
-check::functions(array(b_fn,b_vfi,b_fi,b_fj,b_fk,b_fl,b_get_self,b_vfs,b_fs));
+check::functions(array('b_fn','b_vfi','b_fi','b_fj','b_fk','b_fl','b_get_self','b_vfs','b_fs'));
// No new classes
-check::classes(array(A,B));
+check::classes(array('A','B'));
// now new vars
check::globals(array());
diff --git a/Examples/test-suite/php/director_protected_runme.php b/Examples/test-suite/php/director_protected_runme.php
index 18586ca62..e759fed25 100644
--- a/Examples/test-suite/php/director_protected_runme.php
+++ b/Examples/test-suite/php/director_protected_runme.php
@@ -3,9 +3,9 @@
require "tests.php";
require "director_protected.php";
-check::functions(array(foo_pong,foo_s,foo_q,foo_ping,foo_pang,foo_used,foo_cheer,bar_create,bar_callping,bar_callcheer,bar_cheer,bar_pong,bar_used,bar_ping,bar_pang,a_draw,b_draw));
-check::classes(array(Foo,Bar,PrivateFoo,A,B,AA,BB));
-check::globals(array(bar_a));
+check::functions(array('foo_pong','foo_s','foo_q','foo_ping','foo_pang','foo_used','foo_cheer','bar_create','bar_callping','bar_callcheer','bar_cheer','bar_pong','bar_used','bar_ping','bar_pang','a_draw','b_draw'));
+check::classes(array('Foo','Bar','PrivateFoo','A','B','AA','BB'));
+check::globals(array('bar_a'));
class FooBar extends Bar {
protected function ping() {
diff --git a/Examples/test-suite/php/director_stl_runme.php b/Examples/test-suite/php/director_stl_runme.php
index 29addd261..f7a5c0aa0 100644
--- a/Examples/test-suite/php/director_stl_runme.php
+++ b/Examples/test-suite/php/director_stl_runme.php
@@ -4,9 +4,9 @@ require "tests.php";
require "director_stl.php";
// No new functions
-check::functions(array(foo_bar,foo_ping,foo_pong,foo_tping,foo_tpong,foo_pident,foo_vident,foo_vsecond,foo_tpident,foo_tvident,foo_tvsecond,foo_vidents,foo_tvidents));
+check::functions(array('foo_bar','foo_ping','foo_pong','foo_tping','foo_tpong','foo_pident','foo_vident','foo_vsecond','foo_tpident','foo_tvident','foo_tvsecond','foo_vidents','foo_tvidents'));
// No new classes
-check::classes(array(Foo));
+check::classes(array('Foo'));
// now new vars
check::globals(array());
diff --git a/Examples/test-suite/php/director_string_runme.php b/Examples/test-suite/php/director_string_runme.php
index 5ac583f78..77e84c9bf 100644
--- a/Examples/test-suite/php/director_string_runme.php
+++ b/Examples/test-suite/php/director_string_runme.php
@@ -4,11 +4,11 @@ require "tests.php";
require "director_string.php";
// No new functions
-check::functions(array(a_get_first,a_call_get_first,a_string_length,a_process_text,a_call_process_func,stringvector_size,stringvector_is_empty,stringvector_clear,stringvector_push,stringvector_pop,stringvector_capacity,stringvector_reserve));
+check::functions(array('a_get_first','a_call_get_first','a_string_length','a_process_text','a_call_process_func','stringvector_size','stringvector_is_empty','stringvector_clear','stringvector_push','stringvector_pop','stringvector_capacity','stringvector_reserve'));
// No new classes
-check::classes(array(A,StringVector));
+check::classes(array('A','StringVector'));
// now new vars
-check::globals(array(a,a_call,a_m_strings,stringvector));
+check::globals(array('a','a_call','a_m_strings','stringvector'));
class B extends A {
function get_first() {
diff --git a/Examples/test-suite/php/director_thread_runme.php b/Examples/test-suite/php/director_thread_runme.php
index ab0563213..2a640a022 100644
--- a/Examples/test-suite/php/director_thread_runme.php
+++ b/Examples/test-suite/php/director_thread_runme.php
@@ -8,11 +8,11 @@ require "director_thread.php";
exit(0);
// No new functions
-check::functions(array(millisecondsleep,foo_stop,foo_run,foo_do_foo));
+check::functions(array('millisecondsleep','foo_stop','foo_run','foo_do_foo'));
// No new classes
-check::classes(array(director_thread,Foo));
+check::classes(array('director_thread','Foo'));
// now new vars
-check::globals(array(foo_val));
+check::globals(array('foo_val'));
class Derived extends Foo {
function do_foo() {
diff --git a/Examples/test-suite/php/director_unroll_runme.php b/Examples/test-suite/php/director_unroll_runme.php
index 626b1f07d..e3101887d 100644
--- a/Examples/test-suite/php/director_unroll_runme.php
+++ b/Examples/test-suite/php/director_unroll_runme.php
@@ -4,11 +4,11 @@ require "tests.php";
require "director_unroll.php";
// No new functions
-check::functions(array(foo_ping,foo_pong));
+check::functions(array('foo_ping','foo_pong'));
// No new classes
-check::classes(array(Foo,Bar));
+check::classes(array('Foo','Bar'));
// now new vars
-check::globals(array(bar));
+check::globals(array('bar'));
class MyFoo extends Foo {
function ping() {
@@ -23,7 +23,10 @@ $b = new Bar();
$b->set($a);
$c = $b->get();
-check::equal($a->this, $c->this, "this failed");
+// FIXME: This doesn't work for checking that they wrap the same C++ object
+// because the two objects have different PHP resources, and we can't easily
+// look inside those resources to see which C++ objects they refer to.
+//check::equal($a->_cPtr, $c->_cPtr, "_cPtr check failed");
check::done();
?>
diff --git a/Examples/test-suite/php/evil_diamond_prop_runme.php b/Examples/test-suite/php/evil_diamond_prop_runme.php
index 02d9944d6..9bdb7435f 100644
--- a/Examples/test-suite/php/evil_diamond_prop_runme.php
+++ b/Examples/test-suite/php/evil_diamond_prop_runme.php
@@ -31,7 +31,9 @@ check::is_a($spam,"spam");
check::equal(1,$spam->_foo,"1==spam->_foo");
check::equal(2,$spam->_bar,"2==spam->_bar");
// multiple inheritance not supported in PHP
+set_error_handler(NULL, 0); // Don't complain that _baz is unknown.
check::equal(null,$spam->_baz,"null==spam->_baz");
+restore_error_handler();
check::equal(4,$spam->_spam,"4==spam->_spam");
check::done();
diff --git a/Examples/test-suite/php/exception_order_runme.php b/Examples/test-suite/php/exception_order_runme.php
index acb83561a..77f115fa1 100644
--- a/Examples/test-suite/php/exception_order_runme.php
+++ b/Examples/test-suite/php/exception_order_runme.php
@@ -2,9 +2,9 @@
require "tests.php";
require "exception_order.php";
-check::functions(array(a_foo,a_bar,a_foobar,a_barfoo,is_python_builtin));
-check::classes(array(A,E1,E2,E3,exception_order,ET_i,ET_d));
-check::globals(array(efoovar,foovar,cfoovar,a_sfoovar,a_foovar,a_efoovar));
+check::functions(array('a_foo','a_bar','a_foobar','a_barfoo','is_python_builtin'));
+check::classes(array('A','E1','E2','E3','exception_order','ET_i','ET_d'));
+check::globals(array('efoovar','foovar','cfoovar','a_sfoovar','a_foovar','a_efoovar'));
$a = new A();
try {
diff --git a/Examples/test-suite/php/grouping_runme.php b/Examples/test-suite/php/grouping_runme.php
index 51446f473..8bad7cd4c 100644
--- a/Examples/test-suite/php/grouping_runme.php
+++ b/Examples/test-suite/php/grouping_runme.php
@@ -6,14 +6,14 @@ require "grouping.php";
check::functions(array("test1","test2","do_unary","negate"));
check::equal(5,test1(5),"5==test1(5)");
check::resource(test2(7),"_p_int","_p_int==test2(7)");
-check::globals(array(test3));
+check::globals(array('test3'));
//check::equal(37,test3_get(),'37==test3_get()');
check::equal(37,check::get("test3"),'37==get(test3)');
//test3_set(38);
-check::set(test3,38);
+check::set('test3',38);
//check::equal(38,test3_get(),'38==test3_get() after test3_set(37)');
-check::equal(38,check::get(test3),'38==get(test3) after set(test)');
+check::equal(38,check::get('test3'),'38==get(test3) after set(test)');
check::equal(-5,negate(5),"-5==negate(5)");
check::equal(7,do_unary(-7,NEGATE),"7=do_unary(-7,NEGATE)");
diff --git a/Examples/test-suite/php/ignore_parameter_runme.php b/Examples/test-suite/php/ignore_parameter_runme.php
index 1c8c76ad4..b9c2b777d 100644
--- a/Examples/test-suite/php/ignore_parameter_runme.php
+++ b/Examples/test-suite/php/ignore_parameter_runme.php
@@ -4,9 +4,9 @@ require "tests.php";
require "ignore_parameter.php";
// New functions
-check::functions(array(jaguar,lotus,tvr,ferrari,sportscars_daimler,sportscars_astonmartin,sportscars_bugatti,sportscars_lamborghini));
+check::functions(array('jaguar','lotus','tvr','ferrari','fiat','sportscars_daimler','sportscars_astonmartin','sportscars_bugatti','sportscars_lamborghini','sportscars_maseratti'));
// New classes
-check::classes(array(ignore_parameter,SportsCars,MiniCooper,MorrisMinor,FordAnglia,AustinAllegro));
+check::classes(array('ignore_parameter','SportsCars','MiniCooper','MorrisMinor','FordAnglia','AustinAllegro'));
// No new vars
check::globals(array());
diff --git a/Examples/test-suite/php/import_nomodule_runme.php b/Examples/test-suite/php/import_nomodule_runme.php
index 41836ba0f..e5ea761f7 100644
--- a/Examples/test-suite/php/import_nomodule_runme.php
+++ b/Examples/test-suite/php/import_nomodule_runme.php
@@ -3,9 +3,9 @@ require "tests.php";
require "import_nomodule.php";
// No new functions
-check::functions(array(create_foo,delete_foo,test1,is_python_builtin));
+check::functions(array('create_foo','delete_foo','test1','is_python_builtin'));
// No new classes
-check::classes(array(import_nomodule,Bar));
+check::classes(array('import_nomodule','Bar'));
// now new vars
check::globals(array());
diff --git a/Examples/test-suite/php/li_carrays_cpp_runme.php b/Examples/test-suite/php/li_carrays_cpp_runme.php
index e0f9ffe92..3e8a443f6 100644
--- a/Examples/test-suite/php/li_carrays_cpp_runme.php
+++ b/Examples/test-suite/php/li_carrays_cpp_runme.php
@@ -3,14 +3,14 @@ require "tests.php";
require "li_carrays_cpp.php";
// Check functions.
-check::functions(array(new_intarray,delete_intarray,intarray_getitem,intarray_setitem,doublearray_getitem,doublearray_setitem,doublearray_cast,doublearray_frompointer,xyarray_getitem,xyarray_setitem,xyarray_cast,xyarray_frompointer,delete_abarray,abarray_getitem,abarray_setitem,shortarray_getitem,shortarray_setitem,shortarray_cast,shortarray_frompointer,sum_array));
+check::functions(array('new_intarray','delete_intarray','intarray_getitem','intarray_setitem','doublearray_getitem','doublearray_setitem','doublearray_cast','doublearray_frompointer','xyarray_getitem','xyarray_setitem','xyarray_cast','xyarray_frompointer','delete_abarray','abarray_getitem','abarray_setitem','shortarray_getitem','shortarray_setitem','shortarray_cast','shortarray_frompointer','sum_array'));
// Check classes.
// NB An "li_carrays_cpp" class is created as a mock namespace.
-check::classes(array(li_carrays_cpp,doubleArray,AB,XY,XYArray,shortArray));
+check::classes(array('li_carrays_cpp','doubleArray','AB','XY','XYArray','shortArray'));
// Check global variables.
-check::globals(array(xy_x,xy_y,globalxyarray,ab_a,ab_b,globalabarray));
+check::globals(array('xy_x','xy_y','globalxyarray','ab_a','ab_b','globalabarray'));
$d = new doubleArray(10);
diff --git a/Examples/test-suite/php/li_carrays_runme.php b/Examples/test-suite/php/li_carrays_runme.php
index 40e82f9ea..abe358101 100644
--- a/Examples/test-suite/php/li_carrays_runme.php
+++ b/Examples/test-suite/php/li_carrays_runme.php
@@ -3,14 +3,14 @@ require "tests.php";
require "li_carrays.php";
// Check functions.
-check::functions(array(new_intarray,delete_intarray,intarray_getitem,intarray_setitem,doublearray_getitem,doublearray_setitem,doublearray_cast,doublearray_frompointer,xyarray_getitem,xyarray_setitem,xyarray_cast,xyarray_frompointer,delete_abarray,abarray_getitem,abarray_setitem,shortarray_getitem,shortarray_setitem,shortarray_cast,shortarray_frompointer,sum_array));
+check::functions(array('new_intarray','delete_intarray','intarray_getitem','intarray_setitem','doublearray_getitem','doublearray_setitem','doublearray_cast','doublearray_frompointer','xyarray_getitem','xyarray_setitem','xyarray_cast','xyarray_frompointer','delete_abarray','abarray_getitem','abarray_setitem','shortarray_getitem','shortarray_setitem','shortarray_cast','shortarray_frompointer','sum_array'));
// Check classes.
// NB An "li_carrays" class is created as a mock namespace.
-check::classes(array(li_carrays,doubleArray,AB,XY,XYArray,shortArray));
+check::classes(array('li_carrays','doubleArray','AB','XY','XYArray','shortArray'));
// Check global variables.
-check::globals(array(xy_x,xy_y,globalxyarray,ab_a,ab_b,globalabarray));
+check::globals(array('xy_x','xy_y','globalxyarray','ab_a','ab_b','globalabarray'));
$d = new doubleArray(10);
diff --git a/Examples/test-suite/php/li_factory_runme.php b/Examples/test-suite/php/li_factory_runme.php
index 6623e2a8c..982d7b1fd 100644
--- a/Examples/test-suite/php/li_factory_runme.php
+++ b/Examples/test-suite/php/li_factory_runme.php
@@ -4,9 +4,9 @@ require "tests.php";
require "li_factory.php";
// No new functions
-check::functions(array(geometry_draw,geometry_create,geometry_clone_,point_draw,point_width,point_clone_,circle_draw,circle_radius,circle_clone_));
+check::functions(array('geometry_draw','geometry_create','geometry_clone_','point_draw','point_width','point_clone_','circle_draw','circle_radius','circle_clone_'));
// No new classes
-check::classes(array(Geometry,Point,Circle));
+check::classes(array('Geometry','Point','Circle'));
// now new vars
check::globals(array());
diff --git a/Examples/test-suite/php/li_std_string_runme.php b/Examples/test-suite/php/li_std_string_runme.php
index ad62247e1..04ee3fc86 100644
--- a/Examples/test-suite/php/li_std_string_runme.php
+++ b/Examples/test-suite/php/li_std_string_runme.php
@@ -27,5 +27,8 @@ check::equal(Structure::StaticMemberString2(), $s, "StaticMemberString2 test 2")
// below broken ?
//check::equal(Structure::ConstStaticMemberString(), "const static member string", "ConstStaticMemberString test");
+// This used to give "Undefined variable: r"
+li_std_string::test_const_reference_returning_void("foo");
+
check::done();
?>
diff --git a/Examples/test-suite/php/newobject1_runme.php b/Examples/test-suite/php/newobject1_runme.php
index 5853a72c0..863e3e423 100644
--- a/Examples/test-suite/php/newobject1_runme.php
+++ b/Examples/test-suite/php/newobject1_runme.php
@@ -4,9 +4,9 @@ require "tests.php";
require "newobject1.php";
// No new functions
-check::functions(array(foo_makefoo,foo_makemore,foo_foocount));
+check::functions(array('foo_makefoo','foo_makemore','foo_foocount'));
// No new classes
-check::classes(array(Foo));
+check::classes(array('Foo'));
// now new vars
check::globals(array());
diff --git a/Examples/test-suite/php/newobject3_runme.php b/Examples/test-suite/php/newobject3_runme.php
new file mode 100644
index 000000000..edd5d8608
--- /dev/null
+++ b/Examples/test-suite/php/newobject3_runme.php
@@ -0,0 +1,18 @@
+<?php
+
+require "tests.php";
+require "newobject3.php";
+
+$factory = new factory();
+
+check::classname("Product", $factory->create(7));
+check::classname("Product", $factory->create(7, 6));
+check::classname("Product", $factory->create("test"));
+check::classname("Product", $factory->create("test", 2));
+
+check::isnull($factory->create(0), "create(0) should be NULL");
+check::isnull($factory->create(7, -1), "create(7, -1) should be NULL");
+check::isnull($factory->create(0, -1), "create(0, -1) should be NULL");
+check::isnull($factory->create("bad", -1), "create(\"bad\", -1) should be NULL");
+
+?>
diff --git a/Examples/test-suite/php/overload_null_runme.php b/Examples/test-suite/php/overload_null_runme.php
new file mode 100644
index 000000000..22824d4fb
--- /dev/null
+++ b/Examples/test-suite/php/overload_null_runme.php
@@ -0,0 +1,46 @@
+<?php
+
+require "tests.php";
+require "overload_null.php";
+
+$o = new Overload();
+$x = new X();
+
+check::equal(1, $o->byval1($x), "test 1");
+check::equal(2, $o->byval1(null), "test 2");
+
+check::equal(3, $o->byval2(null), "test 3");
+check::equal(4, $o->byval2($x), "test 4");
+
+check::equal(5, $o->byref1($x), "test 5");
+check::equal(6, $o->byref1(null), "test 6");
+
+check::equal(7, $o->byref2(null), "test 7");
+check::equal(8, $o->byref2($x), "test 8");
+
+check::equal(9, $o->byconstref1($x), "test 9");
+check::equal(10, $o->byconstref1(null), "test 10");
+
+check::equal(11, $o->byconstref2(null), "test 11");
+check::equal(12, $o->byconstref2($x), "test 12");
+
+# const pointer references
+check::equal(13, $o->byval1cpr($x), "test 13");
+check::equal(14, $o->byval1cpr(null), "test 14");
+
+check::equal(15, $o->byval2cpr(null), "test 15");
+check::equal(16, $o->byval2cpr($x), "test 16");
+
+# forward class declaration
+check::equal(17, $o->byval1forwardptr($x), "test 17");
+check::equal(18, $o->byval1forwardptr(null), "test 18");
+
+check::equal(19, $o->byval2forwardptr(null), "test 19");
+check::equal(20, $o->byval2forwardptr($x), "test 20");
+
+check::equal(21, $o->byval1forwardref($x), "test 21");
+
+check::equal(22, $o->byval2forwardref($x), "test 22");
+
+check::done();
+?>
diff --git a/Examples/test-suite/php/overload_rename_runme.php b/Examples/test-suite/php/overload_rename_runme.php
index dce4c6cb3..0357f91a6 100644
--- a/Examples/test-suite/php/overload_rename_runme.php
+++ b/Examples/test-suite/php/overload_rename_runme.php
@@ -6,7 +6,7 @@ require "overload_rename.php";
// No new functions
check::functions(array());
// No new classes
-check::classes(array(Foo));
+check::classes(array('Foo'));
// now new vars
check::globals(array());
diff --git a/Examples/test-suite/php/php_iterator_runme.php b/Examples/test-suite/php/php_iterator_runme.php
index d69a5b385..fd645ccb2 100644
--- a/Examples/test-suite/php/php_iterator_runme.php
+++ b/Examples/test-suite/php/php_iterator_runme.php
@@ -3,8 +3,8 @@
require "tests.php";
require "php_iterator.php";
-check::functions(array(myiterator_rewind,myiterator_key,myiterator_current,myiterator_next,myiterator_valid));
-check::classes(array(MyIterator));
+check::functions(array('myiterator_rewind','myiterator_key','myiterator_current','myiterator_next','myiterator_valid'));
+check::classes(array('MyIterator'));
// No new global variables.
check::globals(array());
diff --git a/Examples/test-suite/php/php_pragma_runme.php b/Examples/test-suite/php/php_pragma_runme.php
new file mode 100644
index 000000000..c76cfc9b5
--- /dev/null
+++ b/Examples/test-suite/php/php_pragma_runme.php
@@ -0,0 +1,11 @@
+<?php
+
+require "tests.php";
+require "php_pragma.php";
+
+
+check::equal('1.5',(new ReflectionExtension('php_pragma'))->getVersion(),"1.5==version(php_pragma)");
+
+check::done();
+
+?>
diff --git a/Examples/test-suite/php/prefix_runme.php b/Examples/test-suite/php/prefix_runme.php
index ead064f5b..fcf7c66f6 100644
--- a/Examples/test-suite/php/prefix_runme.php
+++ b/Examples/test-suite/php/prefix_runme.php
@@ -4,9 +4,9 @@ require "tests.php";
require "prefix.php";
// No new functions
-check::functions(array(foo_get_self));
+check::functions(array('foo_get_self'));
// No new classes
-check::classes(array(ProjectFoo));
+check::classes(array('ProjectFoo'));
// now new vars
check::globals(array());
diff --git a/Examples/test-suite/php/preproc_constants_c_runme.php b/Examples/test-suite/php/preproc_constants_c_runme.php
index af9b76e1c..20868dcc0 100644
--- a/Examples/test-suite/php/preproc_constants_c_runme.php
+++ b/Examples/test-suite/php/preproc_constants_c_runme.php
@@ -62,5 +62,8 @@ check::equal(gettype(preproc_constants_c::EXPR_OR), "integer", "preproc_constant
check::equal(gettype(preproc_constants_c::EXPR_LAND), "integer", "preproc_constants.EXPR_LAND has unexpected type");
check::equal(gettype(preproc_constants_c::EXPR_LOR), "integer", "preproc_constants.EXPR_LOR has unexpected type");
check::equal(gettype(preproc_constants_c::EXPR_CONDITIONAL), "double", "preproc_constants.EXPR_CONDITIONAL has unexpected type");
+check::equal(gettype(preproc_constants_c::EXPR_MIXED1), "double", "preproc_constants.EXPR_MIXED1 has unexpected type");
+check::equal(gettype(preproc_constants_c::EXPR_WCHAR_MAX), "integer", "preproc_constants.EXPR_WCHAR_MAX has unexpected type");
+check::equal(gettype(preproc_constants_c::EXPR_WCHAR_MIN), "integer", "preproc_constants.EXPR_WCHAR_MIN has unexpected type");
?>
diff --git a/Examples/test-suite/php/preproc_constants_runme.php b/Examples/test-suite/php/preproc_constants_runme.php
index 5c9119b3e..bd216c269 100644
--- a/Examples/test-suite/php/preproc_constants_runme.php
+++ b/Examples/test-suite/php/preproc_constants_runme.php
@@ -61,5 +61,8 @@ check::equal(gettype(preproc_constants::EXPR_OR), "integer", "preproc_constants.
check::equal(gettype(preproc_constants::EXPR_LAND), "boolean", "preproc_constants.EXPR_LAND has unexpected type");
check::equal(gettype(preproc_constants::EXPR_LOR), "boolean", "preproc_constants.EXPR_LOR has unexpected type");
check::equal(gettype(preproc_constants::EXPR_CONDITIONAL), "double", "preproc_constants.EXPR_CONDITIONAL has unexpected type");
+check::equal(gettype(preproc_constants::EXPR_MIXED1), "double", "preproc_constants.EXPR_MIXED1 has unexpected type");
+check::equal(gettype(preproc_constants::EXPR_WCHAR_MAX), "integer", "preproc_constants.EXPR_WCHAR_MAX has unexpected type");
+check::equal(gettype(preproc_constants::EXPR_WCHAR_MIN), "integer", "preproc_constants.EXPR_WCHAR_MIN has unexpected type");
?>
diff --git a/Examples/test-suite/php/sym_runme.php b/Examples/test-suite/php/sym_runme.php
index 483aaa980..127d28fd9 100644
--- a/Examples/test-suite/php/sym_runme.php
+++ b/Examples/test-suite/php/sym_runme.php
@@ -6,7 +6,7 @@ require "sym.php";
// No new functions
check::functions(array());
// No new classes
-check::classes(array(flim,flam));
+check::classes(array('flim','flam'));
// now new vars
check::globals(array());
diff --git a/Examples/test-suite/php/template_arg_typename_runme.php b/Examples/test-suite/php/template_arg_typename_runme.php
index 7d60285e3..e609240e7 100644
--- a/Examples/test-suite/php/template_arg_typename_runme.php
+++ b/Examples/test-suite/php/template_arg_typename_runme.php
@@ -6,11 +6,11 @@ require "template_arg_typename.php";
// No new functions
check::functions(array());
// No new classes
-check::classes(array(UnaryFunction_bool_bool,BoolUnaryFunction_bool));
+check::classes(array('UnaryFunction_bool_bool','BoolUnaryFunction_bool'));
$ufbb=new unaryfunction_bool_bool();
check::is_a($ufbb,"unaryfunction_bool_bool");
-unset($whatisthis);
+$whatisthis=NULL;
$bufb=new boolunaryfunction_bool($whatisthis);
check::is_a($bufb,"boolunaryfunction_bool");
diff --git a/Examples/test-suite/php/template_construct_runme.php b/Examples/test-suite/php/template_construct_runme.php
index 3a3986f7e..b227d9fec 100644
--- a/Examples/test-suite/php/template_construct_runme.php
+++ b/Examples/test-suite/php/template_construct_runme.php
@@ -3,7 +3,7 @@
require "tests.php";
require "template_construct.php";
-check::classes(array(Foo_int));
+check::classes(array('Foo_int'));
$foo_int=new foo_int(3);
check::is_a($foo_int,"foo_int","Made a foo_int");
diff --git a/Examples/test-suite/php/tests.php b/Examples/test-suite/php/tests.php
index d3fd66868..20fa1ed98 100644
--- a/Examples/test-suite/php/tests.php
+++ b/Examples/test-suite/php/tests.php
@@ -1,8 +1,15 @@
<?php
-// do we have true global vars or just GETSET functions?
-// Used to filter out get/set global functions to fake vars...
-define(GETSET,1);
+function die_on_error($errno, $errstr, $file, $line) {
+ if ($file !== Null) {
+ print $file;
+ if ($line !== Null) print ":$line";
+ print ": ";
+ }
+ print "$errstr\n";
+ exit(1);
+}
+set_error_handler("die_on_error", -1);
$_original_functions=get_defined_functions();
$_original_globals=1;
@@ -10,7 +17,11 @@ $_original_classes=get_declared_classes();
$_original_globals=array_keys($GLOBALS);
class check {
- function get_extra_classes($ref=FALSE) {
+ // do we have true global vars or just GETSET functions?
+ // Used to filter out get/set global functions to fake vars...
+ const GETSET = 1;
+
+ static function get_extra_classes($ref=FALSE) {
static $extra;
global $_original_classes;
if ($ref===FALSE) $f=$_original_classes;
@@ -22,7 +33,7 @@ class check {
return $extra;
}
- function get_extra_functions($ref=FALSE,$gs=false) {
+ static function get_extra_functions($ref=FALSE,$gs=false) {
static $extra;
static $extrags; // for get/setters
global $_original_functions;
@@ -31,11 +42,11 @@ class check {
$extra=array();
$extrags=array();
$df=get_defined_functions();
- $df=array_flip($df[internal]);
- foreach($_original_functions[internal] as $func) unset($df[$func]);
+ $df=array_flip($df['internal']);
+ foreach($_original_functions['internal'] as $func) unset($df[$func]);
// Now chop out any get/set accessors
foreach(array_keys($df) as $func)
- if ((GETSET && preg_match('/_[gs]et$/', $func)) ||
+ if ((self::GETSET && preg_match('/_[gs]et$/', $func)) ||
preg_match('/^new_/', $func) ||
preg_match('/_(alter|get)_newobject$/', $func))
$extrags[]=$func;
@@ -46,11 +57,11 @@ class check {
return $extra;
}
- function get_extra_globals($ref=FALSE) {
+ static function get_extra_globals($ref=FALSE) {
static $extra;
global $_original_globals;
if (! is_array($extra)) {
- if (GETSET) {
+ if (self::GETSET) {
$_extra=array();
foreach(check::get_extra_functions(false,1) as $global) {
if (preg_match('/^(.*)_[sg]et$/', $global, $match))
@@ -72,16 +83,17 @@ class check {
return $extra;
}
- function classname($string,$object) {
+ static function classname($string,$object) {
if (!is_object($object))
return check::fail("The second argument is a " . gettype($object) . ", not an object.");
if (strtolower($string)!=strtolower($classname=get_class($object))) return check::fail("Object: \$object is of class %s not class %s",$classname,$string);
return TRUE;
}
- function classmethods($classname,$methods) {
+ static function classmethods($classname,$methods) {
if (is_object($classname)) $classname=get_class($classname);
$classmethods=array_flip(get_class_methods($classname));
+ $message=NULL;
$missing=array();
$extra=array();
foreach($methods as $method) {
@@ -98,19 +110,19 @@ class check {
return TRUE;
}
- function set($var,$value) {
+ static function set($var,$value) {
$func=$var."_set";
- if (GETSET) $func($value);
+ if (self::GETSET) $func($value);
else $_GLOBALS[$var]=$value;
}
- function &get($var) {
+ static function get($var) {
$func=$var."_get";
- if (GETSET) return $func();
+ if (self::GETSET) return $func();
else return $_GLOBALS[$var];
}
- function is_a($a,$b) {
+ static function is_a($a,$b) {
if (is_object($a)) $a=strtolower(get_class($a));
if (is_object($b)) $a=strtolower(get_class($b));
$parents=array();
@@ -119,11 +131,11 @@ class check {
$parents[]=$c;
$c=strtolower(get_parent_class($c));
}
- if ($c!=$b) return check::fail("Class $a does not inherit from class $b\nHierachy:\n %s\n",join("\n ",$parents));
+ if ($c!=$b) return check::fail("Class $a does not inherit from class $b\nHierarchy:\n %s\n",join("\n ",$parents));
return TRUE;
}
- function classparent($a,$b) {
+ static function classparent($a,$b) {
if (is_object($a)) $a=get_class($a);
if (is_object($b)) $a=get_class($b);
$parent=get_parent_class($a);
@@ -132,7 +144,7 @@ class check {
return TRUE;
}
- function classes($classes) {
+ static function classes($classes) {
if (! is_array($classes)) $classes=array($classes);
$message=array();
$missing=array();
@@ -148,7 +160,7 @@ class check {
return TRUE;
}
- function functions($functions) {
+ static function functions($functions) {
if (! is_array($functions)) $functions=array($functions);
$message=array();
$missing=array();
@@ -165,13 +177,13 @@ class check {
return TRUE;
}
- function globals($globals) {
+ static function globals($globals) {
if (! is_array($globals)) $globals=array($globals);
$message=array();
$missing=array();
$extra=array_flip(check::get_extra_globals());
foreach ($globals as $glob) {
- if (GETSET) {
+ if (self::GETSET) {
if (! isset($extra[$glob])) $missing[]=$glob;
else unset($extra[$glob]);
} else {
@@ -187,30 +199,30 @@ class check {
}
- function functionref($a,$type,$message) {
+ static function functionref($a,$type,$message) {
if (! preg_match("/^_[a-f0-9]+$type$/i", $a))
return check::fail($message);
return TRUE;
}
- function equal($a,$b,$message) {
+ static function equal($a,$b,$message) {
if (! ($a===$b)) return check::fail($message . ": '$a'!=='$b'");
return TRUE;
}
- function resource($a,$b,$message) {
+ static function resource($a,$b,$message) {
$resource=trim(check::var_dump($a));
if (! preg_match("/^resource\([0-9]+\) of type \($b\)/i", $resource))
return check::fail($message);
return TRUE;
}
- function isnull($a,$message) {
+ static function isnull($a,$message) {
$value=trim(check::var_dump($a));
return check::equal($value,"NULL",$message);
}
- function var_dump($arg) {
+ static function var_dump($arg) {
ob_start();
var_dump($arg);
$result=ob_get_contents();
@@ -218,19 +230,19 @@ class check {
return $result;
}
- function fail($pattern) {
+ static function fail($pattern) {
$args=func_get_args();
print("Failed on: ".call_user_func_array("sprintf",$args)."\n");
exit(1);
}
- function warn($pattern) {
+ static function warn($pattern) {
$args=func_get_args();
print("Warning on: ".call_user_func_array("sprintf",$args)."\n");
return FALSE;
}
- function done() {
+ static function done() {
# print $_SERVER[argv][0]." ok\n";
}
}
diff --git a/Examples/test-suite/php/threads_exception_runme.php b/Examples/test-suite/php/threads_exception_runme.php
index 9e4d04e10..80717eb88 100644
--- a/Examples/test-suite/php/threads_exception_runme.php
+++ b/Examples/test-suite/php/threads_exception_runme.php
@@ -4,11 +4,11 @@ require "tests.php";
require "threads_exception.php";
// Check functions
-check::functions(array(test_simple,test_message,test_hosed,test_unknown,test_multi,is_python_builtin));
+check::functions(array('test_simple','test_message','test_hosed','test_unknown','test_multi','is_python_builtin'));
// Check classes.
-check::classes(array(Exc,Test,threads_exception));
-// Chek globals.
-check::globals(array(exc_code,exc_msg));
+check::classes(array('Exc','Test','threads_exception'));
+// Check globals.
+check::globals(array('exc_code','exc_msg'));
$t = new Test();
try {
diff --git a/Examples/test-suite/php/typedef_reference_runme.php b/Examples/test-suite/php/typedef_reference_runme.php
index 88a70f8d3..83e75fb66 100644
--- a/Examples/test-suite/php/typedef_reference_runme.php
+++ b/Examples/test-suite/php/typedef_reference_runme.php
@@ -3,7 +3,7 @@
require "tests.php";
require "typedef_reference.php";
-check::functions(array(somefunc,otherfunc,new_intp,copy_intp,delete_intp,intp_assign,intp_value));
+check::functions(array('somefunc','otherfunc','new_intp','copy_intp','delete_intp','intp_assign','intp_value'));
$int2=copy_intp(2);
check::equal(2,somefunc($int2)," test passing intp to somefunc");
$int3=copy_intp(3);
diff --git a/Examples/test-suite/php5/Makefile.in b/Examples/test-suite/php5/Makefile.in
deleted file mode 100644
index 391ca2c53..000000000
--- a/Examples/test-suite/php5/Makefile.in
+++ /dev/null
@@ -1,80 +0,0 @@
-#######################################################################
-# Makefile for php5 test-suite
-#######################################################################
-
-LANGUAGE = php5
-SCRIPTSUFFIX = _runme.php
-
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-top_builddir = @top_builddir@
-
-CPP_TEST_CASES += \
- callback \
- li_factory \
- php_iterator \
- php_namewarn_rename \
-
-include $(srcdir)/../common.mk
-
-# Overridden variables here
-TARGETPREFIX =# Should be php_ for Windows, empty otherwise
-
-# Custom tests - tests with additional commandline options
-prefix.cpptest: SWIGOPT += -prefix Project
-
-# write out tests without a _runme.php
-missingcpptests:
- for test in $(CPP_TEST_CASES) ; do test -f $${test}_runme.php || echo $${test}; done
-
-missingctests:
- for test in $(C_TEST_CASES) ; do test -f $${test}_runme.php || echo $${test}; done
-
-missingtests: missingcpptests missingctests
-
-# Rules for the different types of tests
-%.cpptest:
- $(setup)
- +$(swig_and_compile_cpp)
- +$(run_testcase)
-
-%.ctest:
- $(setup)
- +$(swig_and_compile_c)
- +$(run_testcase)
-
-%.multicpptest:
- $(setup)
- +$(swig_and_compile_multi_cpp)
- +$(run_testcase)
-
-# Smart target
-%.test:
- @echo ' $(C_TEST_CASES) '|grep -F -v ' $* ' >/dev/null ||\
- $(MAKE) $*.ctest
- @echo ' $(CPP_TEST_CASES) '|grep -F -v ' $* ' >/dev/null ||\
- $(MAKE) $*.cpptest
- @echo ' $(MULTI_CPP_TEST_CASES) '|grep -F -v ' $* ' >/dev/null ||\
- $(MAKE) $*.multicpptest
-
-# Runs the testcase. Tries to run testcase_runme.php, and if that's not
-# found, runs testcase.php, except for multicpptests.
-run_testcase = \
- if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
- $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP5_SCRIPT=$(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL='$(RUNTOOL)' php5_run; \
- elif [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*.php -a ! -f $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list ]; then \
- $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP5_SCRIPT=$(SCRIPTDIR)/$(SCRIPTPREFIX)$*.php RUNTOOL='$(RUNTOOL)' php5_run; \
- fi
-
-# Clean: remove the generated .php file
-%.clean:
- @rm -f $*.php php_$*.h
-
-clean:
- $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' php5_clean
- rm -f clientdata_prop_a.php clientdata_prop_b.php php_clientdata_prop_a.h php_clientdata_prop_b.h
- rm -f import_stl_a.php import_stl_b.php php_import_stl_a.h php_import_stl_b.h
- rm -f imports_a.php imports_b.php php_imports_a.h php_imports_b.h
- rm -f mod_a.php mod_b.php php_mod_a.h php_mod_b.h
- rm -f multi_import_a.php multi_import_b.php php_multi_import_a.h php_multi_import_b.h
- rm -f packageoption_a.php packageoption_b.php packageoption_c.php php_packageoption_a.h php_packageoption_b.h php_packageoption_c.h
diff --git a/Examples/test-suite/php5/abstract_inherit_ok_runme.php b/Examples/test-suite/php5/abstract_inherit_ok_runme.php
deleted file mode 100644
index c2d86499b..000000000
--- a/Examples/test-suite/php5/abstract_inherit_ok_runme.php
+++ /dev/null
@@ -1,12 +0,0 @@
-<?php
-
-require "tests.php";
-require "abstract_inherit_ok.php";
-
-check::classes(array(Foo,Spam));
-$spam=new Spam();
-
-check::equal(0,$spam->blah(),"spam object method");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/abstract_inherit_runme.php b/Examples/test-suite/php5/abstract_inherit_runme.php
deleted file mode 100644
index 3554e6fd8..000000000
--- a/Examples/test-suite/php5/abstract_inherit_runme.php
+++ /dev/null
@@ -1,14 +0,0 @@
-<?php
-
-require "tests.php";
-require "abstract_inherit.php";
-
-check::classes(array(Foo,Bar,Spam,NRFilter_i,NRRCFilter_i,NRRCFilterpro_i,NRRCFilterpri_i));
-// This constructor attempt should fail as there isn't one
-//$spam=new Spam();
-
-//check::equal(0,$spam->blah(),"spam object method");
-//check::equal(0,Spam::blah($spam),"spam class method");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/add_link_runme.php b/Examples/test-suite/php5/add_link_runme.php
deleted file mode 100644
index 7523bd604..000000000
--- a/Examples/test-suite/php5/add_link_runme.php
+++ /dev/null
@@ -1,22 +0,0 @@
-<?php
-
-require "tests.php";
-require "add_link.php";
-
-// No new functions, except the flat functions
-check::functions(array(new_foo,foo_blah));
-
-check::classes(array(Foo));
-
-$foo=new foo();
-check::is_a($foo,foo);
-
-$foo_blah=$foo->blah();
-check::is_a($foo_blah,foo);
-
-//fails, can't be called as a class method, should allow and make it nil?
-//$class_foo_blah=foo::blah();
-//check::is_a($class_foo_blah,foo);
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/argout_runme.php b/Examples/test-suite/php5/argout_runme.php
deleted file mode 100644
index 33fbd8129..000000000
--- a/Examples/test-suite/php5/argout_runme.php
+++ /dev/null
@@ -1,38 +0,0 @@
-<?php
-
-require "tests.php";
-require "argout.php";
-
-check::functions(array(incp,incr,inctr,new_intp,copy_intp,delete_intp,intp_assign,intp_value,voidhandle,handle));
-
-$ip=copy_intp(42);
-check::equal(42,incp($ip),"42==incp($ip)");
-check::equal(43,intp_value($ip),"43=$ip");
-
-$p=copy_intp(2);
-check::equal(2,incp($p),"2==incp($p)");
-check::equal(3,intp_value($p),"3==$p");
-
-$r=copy_intp(7);
-check::equal(7,incr($r),"7==incr($r)");
-check::equal(8,intp_value($r),"8==$r");
-
-$tr=copy_intp(4);
-check::equal(4,inctr($tr),"4==incr($tr)");
-check::equal(5,intp_value($tr),"5==$tr");
-
-# Check the voidhandle call, first with null
-unset($handle);
-# FIXME: Call-time pass-by-reference has been deprecated for ages, and was
-# removed in PHP 5.4. We need to rework
-#voidhandle(&$handle);
-#check::resource($handle,"_p_void",'$handle is not _p_void');
-#$handledata=handle($handle);
-#check::equal($handledata,"Here it is","\$handledata != \"Here it is\"");
-
-unset($handle);
-voidhandle($handle);
-check::isnull($handle,'$handle not null');
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/arrayptr_runme.php b/Examples/test-suite/php5/arrayptr_runme.php
deleted file mode 100644
index 3b9baed05..000000000
--- a/Examples/test-suite/php5/arrayptr_runme.php
+++ /dev/null
@@ -1,14 +0,0 @@
-<?php
-
-require "tests.php";
-require "arrayptr.php";
-
-// No new functions
-check::functions(array(foo));
-// No new classes
-check::classes(array());
-// now new vars
-check::globals(array());
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/arrays_global_runme.php b/Examples/test-suite/php5/arrays_global_runme.php
deleted file mode 100644
index 12a7806c9..000000000
--- a/Examples/test-suite/php5/arrays_global_runme.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-require "tests.php";
-require "arrays_global.php";
-
-check::functions(array(test_a,test_b,new_simplestruct,new_material));
-check::classes(array(arrays_global,SimpleStruct,Material));
-check::globals(array(array_c,array_sc,array_uc,array_s,array_us,array_i,array_ui,array_l,array_ul,array_ll,array_f,array_d,array_struct,array_structpointers,array_ipointers,array_enum,array_enumpointers,array_const_i,beginstring_fix44a,beginstring_fix44b,beginstring_fix44c,beginstring_fix44d,beginstring_fix44e,beginstring_fix44f,chitmat,hitmat_val,hitmat,simplestruct_double_field));
-// The size of array_c is 2, but the last byte is \0, so we can only store a
-// single byte string in it.
-check::set(array_c,"Z");
-check::equal("Z",check::get(array_c),"set array_c");
-check::set(array_c,"xy");
-check::equal("x",check::get(array_c),"set array_c");
-check::set(array_c,"h");
-check::equal("h",check::get(array_c),"set array_c");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/arrays_global_twodim_runme.php b/Examples/test-suite/php5/arrays_global_twodim_runme.php
deleted file mode 100644
index 40ecf1719..000000000
--- a/Examples/test-suite/php5/arrays_global_twodim_runme.php
+++ /dev/null
@@ -1,22 +0,0 @@
-<?php
-
-require "tests.php";
-require "arrays_global_twodim.php";
-
-check::functions(array(fn_taking_arrays,get_2d_array,new_simplestruct,new_material));
-check::classes(array(arrays_global_twodim,SimpleStruct,Material));
-check::globals(array(array_c,array_sc,array_uc,array_s,array_us,array_i,array_ui,array_l,array_ul,array_ll,array_f,array_d,array_struct,array_structpointers,array_ipointers,array_enum,array_enumpointers,array_const_i,chitmat,hitmat_val,hitmat,simplestruct_double_field));
-$a1=array(10,11,12,13);
-$a2=array(14,15,16,17);
-$a=array($a1,$a2);
-
-$_a=check::get(array_const_i);
-
-for($x=0;$x<count($a1);$x++) {
- for($y=0;$y<2;$y++) {
- check::equal($a[$y][$x],get_2d_array($_a,$y,$x),"check array $x,$y");
- }
-}
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/arrays_runme.php b/Examples/test-suite/php5/arrays_runme.php
deleted file mode 100644
index ae17d05e7..000000000
--- a/Examples/test-suite/php5/arrays_runme.php
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php
-require "tests.php";
-require "arrays.php";
-
-check::functions(array(fn_taking_arrays,newintpointer,setintfrompointer,getintfrompointer,array_pointer_func));
-check::classes(array(arrays,SimpleStruct,ArrayStruct,CartPoseData_t));
-check::globals(array(simplestruct_double_field,arraystruct_array_c,arraystruct_array_sc,arraystruct_array_uc,arraystruct_array_s,arraystruct_array_us,arraystruct_array_i,arraystruct_array_ui,arraystruct_array_l,arraystruct_array_ul,arraystruct_array_ll,arraystruct_array_f,arraystruct_array_d,arraystruct_array_struct,arraystruct_array_structpointers,arraystruct_array_ipointers,arraystruct_array_enum,arraystruct_array_enumpointers,arraystruct_array_const_i,cartposedata_t_p));
-
-$ss=new simplestruct();
-check::classname(simplestruct,$ss);
-
-$as=new arraystruct();
-$as->array_c="abc";
-check::equal($as->array_c,"a",'$as->array_c=="a"');
-check::equal(isset($as->array_const_i),TRUE,'isset($as->array_const_i)');
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/arrays_scope_runme.php b/Examples/test-suite/php5/arrays_scope_runme.php
deleted file mode 100644
index c208b7518..000000000
--- a/Examples/test-suite/php5/arrays_scope_runme.php
+++ /dev/null
@@ -1,16 +0,0 @@
-<?php
-
-require "tests.php";
-require "arrays_scope.php";
-
-// New functions
-check::functions(array(new_bar,bar_blah));
-// New classes
-check::classes(array(arrays_scope,Bar));
-// New vars
-check::globals(array(bar_adata,bar_bdata,bar_cdata));
-
-$bar=new bar();
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/callback_runme.php b/Examples/test-suite/php5/callback_runme.php
deleted file mode 100644
index fefa32502..000000000
--- a/Examples/test-suite/php5/callback_runme.php
+++ /dev/null
@@ -1,9 +0,0 @@
-<?php
-
-require "tests.php";
-require "callback.php";
-// In 2.0.6 and earlier, the constant was misnamed.
-if (gettype(callback::FOO_I_Cb_Ptr) !== 'resource') die("callback::FOO_I_Cb_Ptr not a resource\n");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/casts_runme.php b/Examples/test-suite/php5/casts_runme.php
deleted file mode 100644
index 10522dca4..000000000
--- a/Examples/test-suite/php5/casts_runme.php
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php
-
-require "tests.php";
-require "casts.php";
-
-// No new functions
-check::functions(array(new_a,a_hello,new_b));
-// No new classes
-check::classes(array(A,B));
-// now new vars
-check::globals(array());
-
-# Make sure $b inherites hello() from class A
-$b=new B();
-$b->hello();
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/char_strings_runme.php b/Examples/test-suite/php5/char_strings_runme.php
deleted file mode 100644
index e06ee9d2b..000000000
--- a/Examples/test-suite/php5/char_strings_runme.php
+++ /dev/null
@@ -1,43 +0,0 @@
-<?php
-
-require "tests.php";
-require "char_strings.php";
-
-$CPLUSPLUS_MSG = "A message from the deep dark world of C++, where anything is possible.";
-$OTHERLAND_MSG_10 = "Little message from the safe world.10";
-
-check::equal(GetCharHeapString(), $CPLUSPLUS_MSG, "failed GetCharHeapString");
-check::equal(GetConstCharProgramCodeString(), $CPLUSPLUS_MSG, "failed GetConstCharProgramCodeString");
-check::equal(GetCharStaticString(), $CPLUSPLUS_MSG, "failed GetCharStaticString");
-check::equal(GetCharStaticStringFixed(), $CPLUSPLUS_MSG, "failed GetCharStaticStringFixed");
-check::equal(GetConstCharStaticStringFixed(), $CPLUSPLUS_MSG, "failed GetConstCharStaticStringFixed");
-
-check::equal(SetCharHeapString($OTHERLAND_MSG_10, 10), true, "failed GetConstCharStaticStringFixed");
-check::equal(SetCharStaticString($OTHERLAND_MSG_10, 10), true, "failed SetCharStaticString");
-check::equal(SetCharArrayStaticString($OTHERLAND_MSG_10, 10), true, "failed SetCharArrayStaticString");
-check::equal(SetConstCharHeapString($OTHERLAND_MSG_10, 10), true, "failed SetConstCharHeapString");
-check::equal(SetConstCharStaticString($OTHERLAND_MSG_10, 10), true, "failed SetConstCharStaticString");
-check::equal(SetConstCharArrayStaticString($OTHERLAND_MSG_10, 10), true, "failed SetConstCharArrayStaticString");
-
-check::equal(CharPingPong($OTHERLAND_MSG_10), $OTHERLAND_MSG_10, "failed CharPingPong");
-
-Global_char_set($OTHERLAND_MSG_10);
-check::equal(Global_char_get(), $OTHERLAND_MSG_10, "failed Global_char_get");
-
-Global_char_array1_set($OTHERLAND_MSG_10);
-check::equal(Global_char_array1_get(), $OTHERLAND_MSG_10, "failed Global_char_array1_get");
-
-Global_char_array2_set($OTHERLAND_MSG_10);
-check::equal(Global_char_array2_get(), $OTHERLAND_MSG_10, "failed Global_char_array2_get");
-
-check::equal(Global_const_char_get(), $CPLUSPLUS_MSG, "failed Global_const_char");
-check::equal(Global_const_char_array1_get(), $CPLUSPLUS_MSG, "failed Global_const_char_array1");
-check::equal(Global_const_char_array2_get(), $CPLUSPLUS_MSG, "failed Global_const_char_array2");
-
-check::equal(GetCharPointerRef(), $CPLUSPLUS_MSG, "failed GetCharPointerRef");
-check::equal(SetCharPointerRef($OTHERLAND_MSG_10, 10), true, "failed SetCharPointerRef");
-check::equal(GetConstCharPointerRef(), $CPLUSPLUS_MSG, "failed GetConstCharPointerRef");
-check::equal(SetConstCharPointerRef($OTHERLAND_MSG_10, 10), true, "failed SetConstCharPointerRef");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/class_ignore_runme.php b/Examples/test-suite/php5/class_ignore_runme.php
deleted file mode 100644
index d5ce36217..000000000
--- a/Examples/test-suite/php5/class_ignore_runme.php
+++ /dev/null
@@ -1,16 +0,0 @@
-<?php
-
-require "tests.php";
-require "class_ignore.php";
-
-check::functions(array(do_blah,new_bar,bar_blah,new_boo,boo_away,new_far,new_hoo));
-check::classes(array(class_ignore,Bar,Boo,Far,Hoo));
-// No new vars
-check::globals(array());
-
-$bar=new bar();
-do_blah($bar);
-check::classparent($bar,"");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/conversion_namespace_runme.php b/Examples/test-suite/php5/conversion_namespace_runme.php
deleted file mode 100644
index e21ff7438..000000000
--- a/Examples/test-suite/php5/conversion_namespace_runme.php
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php
-
-require "tests.php";
-require "conversion_namespace.php";
-
-check::classes(array("Foo","Bar"));
-$bar=new Bar;
-check::classname("bar",$bar);
-$foo=$bar->toFoo();
-check::classname("foo",$foo);
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/conversion_ns_template_runme.php b/Examples/test-suite/php5/conversion_ns_template_runme.php
deleted file mode 100644
index 9702eedb7..000000000
--- a/Examples/test-suite/php5/conversion_ns_template_runme.php
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-
-require "tests.php";
-require "conversion_ns_template.php";
-
-check::classes(array("conversion_ns_template","Foo_One","Bar_One","Hi"));
-// this is too hard, I'm not sure what to test for,
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/conversion_runme.php b/Examples/test-suite/php5/conversion_runme.php
deleted file mode 100644
index 1a10ff4f4..000000000
--- a/Examples/test-suite/php5/conversion_runme.php
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php
-
-require "tests.php";
-require "conversion.php";
-
-check::classes(array("Foo","Bar"));
-$bar=new Bar;
-check::classname("bar",$bar);
-$foo=$bar->toFoo();
-check::classname("foo",$foo);
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/cpp11_strongly_typed_enumerations_runme.php b/Examples/test-suite/php5/cpp11_strongly_typed_enumerations_runme.php
deleted file mode 100644
index bee59b209..000000000
--- a/Examples/test-suite/php5/cpp11_strongly_typed_enumerations_runme.php
+++ /dev/null
@@ -1,169 +0,0 @@
-<?php
-
-require "tests.php";
-require "cpp11_strongly_typed_enumerations.php";
-
-function enumCheck($actual, $expected) {
- check::equal($actual, $expected, "Enum value mismatch");
- return $expected + 1;
-}
-
-
-$val = 0;
-$val = enumCheck(Enum1_Val1, $val);
-$val = enumCheck(Enum1_Val2, $val);
-$val = enumCheck(Enum1_Val3, 13);
-$val = enumCheck(Enum1_Val4, $val);
-$val = enumCheck(Enum1_Val5a, 13);
-$val = enumCheck(Enum1_Val6a, $val);
-
-$val = 0;
-$val = enumCheck(Enum2_Val1, $val);
-$val = enumCheck(Enum2_Val2, $val);
-$val = enumCheck(Enum2_Val3, 23);
-$val = enumCheck(Enum2_Val4, $val);
-$val = enumCheck(Enum2_Val5b, 23);
-$val = enumCheck(Enum2_Val6b, $val);
-
-$val = 0;
-$val = enumCheck(Val1, $val);
-$val = enumCheck(Val2, $val);
-$val = enumCheck(Val3, 43);
-$val = enumCheck(Val4, $val);
-
-$val = 0;
-$val = enumCheck(Enum5_Val1, $val);
-$val = enumCheck(Enum5_Val2, $val);
-$val = enumCheck(Enum5_Val3, 53);
-$val = enumCheck(Enum5_Val4, $val);
-
-$val = 0;
-$val = enumCheck(Enum6_Val1, $val);
-$val = enumCheck(Enum6_Val2, $val);
-$val = enumCheck(Enum6_Val3, 63);
-$val = enumCheck(Enum6_Val4, $val);
-
-$val = 0;
-$val = enumCheck(Enum7td_Val1, $val);
-$val = enumCheck(Enum7td_Val2, $val);
-$val = enumCheck(Enum7td_Val3, 73);
-$val = enumCheck(Enum7td_Val4, $val);
-
-$val = 0;
-$val = enumCheck(Enum8_Val1, $val);
-$val = enumCheck(Enum8_Val2, $val);
-$val = enumCheck(Enum8_Val3, 83);
-$val = enumCheck(Enum8_Val4, $val);
-
-$val = 0;
-$val = enumCheck(Enum10_Val1, $val);
-$val = enumCheck(Enum10_Val2, $val);
-$val = enumCheck(Enum10_Val3, 103);
-$val = enumCheck(Enum10_Val4, $val);
-
-$val = 0;
-$val = enumCheck(Class1::Enum12_Val1, 1121);
-$val = enumCheck(Class1::Enum12_Val2, 1122);
-$val = enumCheck(Class1::Enum12_Val3, $val);
-$val = enumCheck(Class1::Enum12_Val4, $val);
-$val = enumCheck(Class1::Enum12_Val5c, 1121);
-$val = enumCheck(Class1::Enum12_Val6c, $val);
-
-$val = 0;
-$val = enumCheck(Class1::Val1, 1131);
-$val = enumCheck(Class1::Val2, 1132);
-$val = enumCheck(Class1::Val3, $val);
-$val = enumCheck(Class1::Val4, $val);
-$val = enumCheck(Class1::Val5d, 1131);
-$val = enumCheck(Class1::Val6d, $val);
-
-$val = 0;
-$val = enumCheck(Class1::Enum14_Val1, 1141);
-$val = enumCheck(Class1::Enum14_Val2, 1142);
-$val = enumCheck(Class1::Enum14_Val3, $val);
-$val = enumCheck(Class1::Enum14_Val4, $val);
-$val = enumCheck(Class1::Enum14_Val5e, 1141);
-$val = enumCheck(Class1::Enum14_Val6e, $val);
-
-# Requires nested class support to work
-#$val = 0;
-#$val = enumCheck(Class1::Struct1.Enum12_Val1, 3121);
-#$val = enumCheck(Class1::Struct1.Enum12_Val2, 3122);
-#$val = enumCheck(Class1::Struct1.Enum12_Val3, $val);
-#$val = enumCheck(Class1::Struct1.Enum12_Val4, $val);
-#$val = enumCheck(Class1::Struct1.Enum12_Val5f, 3121);
-#$val = enumCheck(Class1::Struct1.Enum12_Val6f, $val);
-#
-#$val = 0;
-#$val = enumCheck(Class1::Struct1.$val1, 3131);
-#$val = enumCheck(Class1::Struct1.$val2, 3132);
-#$val = enumCheck(Class1::Struct1.$val3, $val);
-#$val = enumCheck(Class1::Struct1.$val4, $val);
-#
-#$val = 0;
-#$val = enumCheck(Class1::Struct1.Enum14_Val1, 3141);
-#$val = enumCheck(Class1::Struct1.Enum14_Val2, 3142);
-#$val = enumCheck(Class1::Struct1.Enum14_Val3, $val);
-#$val = enumCheck(Class1::Struct1.Enum14_Val4, $val);
-#$val = enumCheck(Class1::Struct1.Enum14_Val5g, 3141);
-#$val = enumCheck(Class1::Struct1.Enum14_Val6g, $val);
-
-$val = 0;
-$val = enumCheck(Class2::Enum12_Val1, 2121);
-$val = enumCheck(Class2::Enum12_Val2, 2122);
-$val = enumCheck(Class2::Enum12_Val3, $val);
-$val = enumCheck(Class2::Enum12_Val4, $val);
-$val = enumCheck(Class2::Enum12_Val5h, 2121);
-$val = enumCheck(Class2::Enum12_Val6h, $val);
-
-$val = 0;
-$val = enumCheck(Class2::Val1, 2131);
-$val = enumCheck(Class2::Val2, 2132);
-$val = enumCheck(Class2::Val3, $val);
-$val = enumCheck(Class2::Val4, $val);
-$val = enumCheck(Class2::Val5i, 2131);
-$val = enumCheck(Class2::Val6i, $val);
-
-$val = 0;
-$val = enumCheck(Class2::Enum14_Val1, 2141);
-$val = enumCheck(Class2::Enum14_Val2, 2142);
-$val = enumCheck(Class2::Enum14_Val3, $val);
-$val = enumCheck(Class2::Enum14_Val4, $val);
-$val = enumCheck(Class2::Enum14_Val5j, 2141);
-$val = enumCheck(Class2::Enum14_Val6j, $val);
-
-# Requires nested class support to work
-#$val = 0;
-#$val = enumCheck(Class2::Struct1.Enum12_Val1, 4121);
-#$val = enumCheck(Class2::Struct1.Enum12_Val2, 4122);
-#$val = enumCheck(Class2::Struct1.Enum12_Val3, $val);
-#$val = enumCheck(Class2::Struct1.Enum12_Val4, $val);
-#$val = enumCheck(Class2::Struct1.Enum12_Val5k, 4121);
-#$val = enumCheck(Class2::Struct1.Enum12_Val6k, $val);
-#
-#$val = 0;
-#$val = enumCheck(Class2::Struct1.$val1, 4131);
-#$val = enumCheck(Class2::Struct1.$val2, 4132);
-#$val = enumCheck(Class2::Struct1.$val3, $val);
-#$val = enumCheck(Class2::Struct1.$val4, $val);
-#$val = enumCheck(Class2::Struct1.$val5l, 4131);
-#$val = enumCheck(Class2::Struct1.$val6l, $val);
-#
-#$val = 0;
-#$val = enumCheck(Class2::Struct1.Enum14_Val1, 4141);
-#$val = enumCheck(Class2::Struct1.Enum14_Val2, 4142);
-#$val = enumCheck(Class2::Struct1.Enum14_Val3, $val);
-#$val = enumCheck(Class2::Struct1.Enum14_Val4, $val);
-#$val = enumCheck(Class2::Struct1.Enum14_Val5m, 4141);
-#$val = enumCheck(Class2::Struct1.Enum14_Val6m, $val);
-
-$class1 = new Class1();
-enumCheck($class1->class1Test1(Enum1_Val5a), 13);
-enumCheck($class1->class1Test2(Class1::Enum12_Val5c), 1121);
-#enumCheck($class1.class1Test3(Class1::Struct1.Enum12_Val5f), 3121);
-
-enumCheck(globalTest1(Enum1_Val5a), 13);
-enumCheck(globalTest2(Class1::Enum12_Val5c), 1121);
-#enumCheck(globalTest3(Class1::Struct1.Enum12_Val5f), 3121);
-
-?>
diff --git a/Examples/test-suite/php5/cpp_basic_runme.php b/Examples/test-suite/php5/cpp_basic_runme.php
deleted file mode 100644
index 6a8522e3e..000000000
--- a/Examples/test-suite/php5/cpp_basic_runme.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-
-require "tests.php";
-require "cpp_basic.php";
-
-// New functions
-check::functions(array(foo_func1,foo_func2,foo___str__,foosubsub___str__,bar_test,bar_testfoo,get_func1_ptr,get_func2_ptr,test_func_ptr,fl_window_show));
-// New classes
-check::classes(array(cpp_basic,Foo,FooSub,FooSubSub,Bar,Fl_Window));
-// New vars
-check::globals(array(foo_num,foo_func_ptr,bar_fptr,bar_fref,bar_fval,bar_cint,bar_global_fptr,bar_global_fref,bar_global_fval));
-
-$f = new Foo(3);
-$f->func_ptr = get_func1_ptr();
-check::equal(test_func_ptr($f, 7), 2*7*3, "get_func1_ptr() didn't work");
-$f->func_ptr = get_func2_ptr();
-check::equal(test_func_ptr($f, 7), -7*3, "get_func2_ptr() didn't work");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/cpp_static_runme.php b/Examples/test-suite/php5/cpp_static_runme.php
deleted file mode 100644
index 9b436b87c..000000000
--- a/Examples/test-suite/php5/cpp_static_runme.php
+++ /dev/null
@@ -1,14 +0,0 @@
-<?php
-
-require "tests.php";
-require "cpp_static.php";
-
-// New functions
-check::functions(array(staticfunctiontest_static_func,staticfunctiontest_static_func_2,staticfunctiontest_static_func_3,is_python_builtin));
-// New classes
-check::classes(array(StaticMemberTest,StaticFunctionTest,cpp_static,StaticBase,StaticDerived));
-// New vars
-check::globals(array(staticmembertest_static_int,staticbase_statty,staticderived_statty));
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/director_abstract_runme.php b/Examples/test-suite/php5/director_abstract_runme.php
deleted file mode 100644
index ca3d676da..000000000
--- a/Examples/test-suite/php5/director_abstract_runme.php
+++ /dev/null
@@ -1,62 +0,0 @@
-<?php
-
-require "tests.php";
-require "director_abstract.php";
-
-// No new functions
-check::functions(array(foo_ping,foo_pong,example0_getxsize,example0_color,example0_get_color,example1_getxsize,example1_color,example1_get_color,example2_getxsize,example2_color,example2_get_color,example4_getxsize,example4_color,example4_get_color,example3_i_color,example3_i_get_color,g,a_f));
-// No new classes
-check::classes(array(director_abstract,Foo,Example0,Example1,Example2,Example4,Example3_i,A));
-// now new vars
-check::globals(array());
-
-class MyFoo extends Foo {
- function ping() {
- return "MyFoo::ping()";
- }
-}
-
-$a = new MyFoo();
-
-check::equal($a->ping(), "MyFoo::ping()", "MyFoo::ping failed");
-
-check::equal($a->pong(), "Foo::pong();MyFoo::ping()", "MyFoo::pong failed");
-
-class MyExample1 extends Example1 {
- function Color($r, $g, $b) {
- return $r;
- }
-}
-
-class MyExample2 extends Example1 {
- function Color($r, $g, $b) {
- return $g;
- }
-}
-
-class MyExample3 extends Example1 {
- function Color($r, $g, $b) {
- return $b;
- }
-}
-
-$me1 = new MyExample1();
-check::equal($me1->Color(1, 2, 3), 1, "Example1_get_color failed");
-
-$me2 = new MyExample2(1, 2);
-check::equal($me2->Color(1, 2, 3), 2, "Example2_get_color failed");
-
-$me3 = new MyExample3();
-check::equal($me3->Color(1, 2, 3), 3, "Example3_get_color failed");
-
-$class = new ReflectionClass('Example1');
-check::equal($class->isAbstract(), true, "Example1 abstractness failed");
-
-$class = new ReflectionClass('Example2');
-check::equal($class->isAbstract(), true, "Example2 abstractness failed");
-
-$class = new ReflectionClass('Example3_i');
-check::equal($class->isAbstract(), true, "Example3_i abstractness failed");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/director_basic_runme.php b/Examples/test-suite/php5/director_basic_runme.php
deleted file mode 100644
index de6b50502..000000000
--- a/Examples/test-suite/php5/director_basic_runme.php
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-
-require "tests.php";
-require "director_basic.php";
-
-// No new functions
-check::functions(array(foo_ping,foo_pong,foo_get_self,a_f,a_rg,a1_ff,myclass_method,myclass_vmethod,myclass_pmethod,myclass_cmethod,myclass_get_self,myclass_call_pmethod,myclasst_i_method));
-// No new classes
-check::classes(array(Foo,A,A1,Bar,MyClass,MyClassT_i));
-// now new vars
-check::globals(array(bar_x));
-
-class PhpFoo extends Foo {
- function ping() {
- return "PhpFoo::ping()";
- }
-}
-
-$a = new PhpFoo();
-
-check::equal($a->ping(), "PhpFoo::ping()", "ping failed");
-
-check::equal($a->pong(), "Foo::pong();PhpFoo::ping()", "pong failed");
-
-$b = new Foo();
-
-check::equal($b->ping(), "Foo::ping()", "ping failed");
-
-check::equal($b->pong(), "Foo::pong();Foo::ping()", "pong failed");
-
-$a = new A1(1);
-
-check::equal($a->rg(2), 2, "rg failed");
-
-class PhpClass extends MyClass {
- function vmethod($b) {
- $b->x = $b->x + 31;
- return $b;
- }
-}
-
-$b = new Bar(3);
-$d = new MyClass();
-$c = new PhpClass();
-
-$cc = MyClass::get_self($c);
-$dd = MyClass::get_self($d);
-
-$bc = $cc->cmethod($b);
-$bd = $dd->cmethod($b);
-
-$cc->method($b);
-
-check::equal($bc->x, 34, "bc failed");
-check::equal($bd->x, 16, "bd failed");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/director_classic_runme.php b/Examples/test-suite/php5/director_classic_runme.php
deleted file mode 100644
index d2da1b1ba..000000000
--- a/Examples/test-suite/php5/director_classic_runme.php
+++ /dev/null
@@ -1,150 +0,0 @@
-<?php
-
-require "tests.php";
-require "director_classic.php";
-
-// No new functions
-check::functions(array(being_id,person_id,child_id,grandchild_id,caller_delcallback,caller_setcallback,caller_resetcallback,caller_call,caller_baseclass));
-// No new classes
-check::classes(array(Being,Person,Child,GrandChild,OrphanPerson,OrphanChild,Caller));
-// now new vars
-check::globals(array());
-
-class TargetLangPerson extends Person {
- function id() {
- $identifier = "TargetLangPerson";
- return $identifier;
- }
-}
-
-class TargetLangChild extends Child {
- function id() {
- $identifier = "TargetLangChild";
- return $identifier;
- }
-}
-
-class TargetLangGrandChild extends GrandChild {
- function id() {
- $identifier = "TargetLangGrandChild";
- return $identifier;
- }
-}
-
-# Semis - don't override id() in target language
-class TargetLangSemiPerson extends Person {
- # No id() override
-}
-
-class TargetLangSemiChild extends Child {
- # No id() override
-}
-
-class TargetLangSemiGrandChild extends GrandChild {
- # No id() override
-}
-
-# Orphans - don't override id() in C++
-class TargetLangOrphanPerson extends OrphanPerson {
- function id() {
- $identifier = "TargetLangOrphanPerson";
- return $identifier;
- }
-}
-
-class TargetLangOrphanChild extends OrphanChild {
- function id() {
- $identifier = "TargetLangOrphanChild";
- return $identifier;
- }
-}
-
-function mycheck($person, $expected) {
- $debug = 0;
- # Normal target language polymorphic call
- $ret = $person->id();
- if ($debug)
- print $ret . "\n";
- check::equal($ret, $expected, "#1 failed");
-
- # Polymorphic call from C++
- $caller = new Caller();
- $caller->setCallback($person);
- $ret = $caller->call();
- if ($debug)
- print $ret . "\n";
- check::equal($ret, $expected, "#2 failed");
-
- # Polymorphic call of object created in target language and passed to
- # C++ and back again
- $baseclass = $caller->baseClass();
- $ret = $baseclass->id();
- if ($debug)
- print $ret . "\n";
- # TODO: Currently we do not track the dynamic type of returned
- # objects, so in case it's possible that the dynamic type is not equal
- # to the static type, we skip this check.
- if (get_parent_class($person) === false)
- check::equal($ret, $expected, "#3 failed");
-
- $caller->resetCallback();
- if ($debug)
- print "----------------------------------------\n";
-}
-
-$person = new Person();
-mycheck($person, "Person");
-unset($person);
-
-$person = new Child();
-mycheck($person, "Child");
-unset($person);
-
-$person = new GrandChild();
-mycheck($person, "GrandChild");
-unset($person);
-
-$person = new TargetLangPerson();
-mycheck($person, "TargetLangPerson");
-unset($person);
-
-$person = new TargetLangChild();
-mycheck($person, "TargetLangChild");
-unset($person);
-
-$person = new TargetLangGrandChild();
-mycheck($person, "TargetLangGrandChild");
-unset($person);
-
-# Semis - don't override id() in target language
-$person = new TargetLangSemiPerson();
-mycheck($person, "Person");
-unset($person);
-
-$person = new TargetLangSemiChild();
-mycheck($person, "Child");
-unset($person);
-
-$person = new TargetLangSemiGrandChild();
-mycheck($person, "GrandChild");
-unset($person);
-
-# Orphans - don't override id() in C++
-$person = new OrphanPerson();
-mycheck($person, "Person");
-unset($person);
-
-$person = new OrphanChild();
-mycheck($person, "Child");
-unset($person);
-
-$person = new TargetLangOrphanPerson();
-mycheck($person, "TargetLangOrphanPerson");
-unset($person);
-
-$person = new TargetLangOrphanChild();
-mycheck($person, "TargetLangOrphanChild");
-unset($person);
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/director_default_runme.php b/Examples/test-suite/php5/director_default_runme.php
deleted file mode 100644
index f97fc7425..000000000
--- a/Examples/test-suite/php5/director_default_runme.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-
-require "tests.php";
-require "director_default.php";
-
-// No new functions
-check::functions(array(foo_msg,foo_getmsg,bar_msg,bar_getmsg,defaultsbase_defaultargs,defaultsderived_defaultargs));
-// No new classes
-check::classes(array(Foo,Bar,DefaultsBase,DefaultsDerived));
-// now new vars
-check::globals(array());
-
-$f = new Foo();
-$f = new Foo(1);
-
-$f = new Bar();
-$f = new Bar(1);
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/director_detect_runme.php b/Examples/test-suite/php5/director_detect_runme.php
deleted file mode 100644
index cc19c0302..000000000
--- a/Examples/test-suite/php5/director_detect_runme.php
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-
-require "tests.php";
-require "director_detect.php";
-
-// No new functions
-check::functions(array(foo_cloner,foo_get_value,foo_get_class,foo_just_do_it,bar_baseclass,bar_cloner,bar_get_value,bar_get_class,bar_just_do_it));
-// No new classes
-check::classes(array(A,Foo,Bar));
-// now new vars
-check::globals(array());
-
-class MyBar extends Bar {
- function __construct($val = 2) {
- parent::__construct();
- $this->val = $val;
- }
-
- function get_value() {
- $this->val = $this->val + 1;
- return $this->val;
- }
-
- function get_class() {
- $this->val = $this->val + 1;
- return new A();
- }
-
- function just_do_it() {
- $this->val = $this->val + 1;
- }
-
- /* clone is a reserved keyword */
- function clone_() {
- return new MyBar($this->val);
- }
-}
-
-$b = new MyBar();
-
-$f = $b->baseclass();
-
-$v = $f->get_value();
-$a = $f->get_class();
-$f->just_do_it();
-
-$c = $b->clone_();
-$vc = $c->get_value();
-
-check::equal($v, 3, "f: Bad virtual detection");
-check::equal($b->val, 5, "b: Bad virtual detection");
-check::equal($vc, 6, "c: Bad virtual detection");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/director_enum_runme.php b/Examples/test-suite/php5/director_enum_runme.php
deleted file mode 100644
index 8f6487a28..000000000
--- a/Examples/test-suite/php5/director_enum_runme.php
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php
-
-require "tests.php";
-require "director_enum.php";
-
-// No new functions
-check::functions(array(foo_say_hello,foo_say_hi,foo_say_bye,foo_say_hi_ref,foo_ping,foo_ping_ref,foo_ping_member_enum,a_f,a2_f));
-// No new classes
-check::classes(array(director_enum,Foo,A,B,A2,B2));
-// now new vars
-check::globals(array());
-
-class MyFoo extends Foo {
- function say_hi($val) {
- return $val;
- }
-}
-
-$b = new Foo();
-$a = new MyFoo();
-
-check::equal($a->say_hi(director_enum::hello), $b->say_hello(director_enum::hi), "say failed");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/director_exception_runme.php b/Examples/test-suite/php5/director_exception_runme.php
deleted file mode 100644
index 8b852c2ce..000000000
--- a/Examples/test-suite/php5/director_exception_runme.php
+++ /dev/null
@@ -1,127 +0,0 @@
-<?php
-
-require "tests.php";
-require "director_exception.php";
-
-// No new functions
-check::functions(array(foo_ping,foo_pong,launder,bar_ping,bar_pong,bar_pang,returnalltypes_return_int,returnalltypes_return_double,returnalltypes_return_const_char_star,returnalltypes_return_std_string,returnalltypes_return_bar,returnalltypes_call_int,returnalltypes_call_double,returnalltypes_call_const_char_star,returnalltypes_call_std_string,returnalltypes_call_bar,is_python_builtin));
-// No new classes
-check::classes(array(director_exception,Foo,Exception1,Exception2,Base,Bar,ReturnAllTypes));
-// now new vars
-check::globals(array());
-
-class MyException extends Exception {
- function __construct($a, $b) {
- $this->msg = $a . $b;
- }
-}
-
-class MyFoo extends Foo {
- function ping() {
- throw new Exception("MyFoo::ping() EXCEPTION");
- }
-}
-
-class MyFoo2 extends Foo {
- function ping() {
- return true;
- }
-}
-
-class MyFoo3 extends Foo {
- function ping() {
- throw new MyException("foo", "bar");
- }
-}
-
-# Check that the Exception raised by MyFoo.ping() is returned by
-# MyFoo.pong().
-$ok = 0;
-$a = new MyFoo();
-# TODO: Currently we do not track the dynamic type of returned
-# objects, so we skip the launder() call.
-#$b = director_exception::launder($a);
-$b = $a;
-try {
- $b->pong();
-} catch (Exception $e) {
- $ok = 1;
- check::equal($e->getMessage(), "MyFoo::ping() EXCEPTION", "Unexpected error message #1");
-}
-check::equal($ok, 1, "Got no exception while expected one #1");
-
-# Check that the director can return an exception which requires two
-# arguments to the constructor, without mangling it.
-$ok = 0;
-$a = new MyFoo3();
-#$b = director_exception::launder($a);
-$b = $a;
-try {
- $b->pong();
-} catch (Exception $e) {
- $ok = 1;
- check::equal($e->msg, "foobar", "Unexpected error message #2");
-}
-check::equal($ok, 1, "Got no exception while expected one #2");
-
-try {
- throw new Exception2();
-} catch (Exception2 $e2) {
-}
-
-try {
- throw new Exception1();
-} catch (Exception1 $e1) {
-}
-
-// Check that we can throw exceptions from director methods (this didn't used
-// to work in all cases, as the exception gets "set" in PHP and the method
-// then returns PHP NULL, which the directorout template may fail to convert.
-
-class Bad extends ReturnAllTypes {
- function return_int() { throw new Exception("bad int"); }
- function return_double() { throw new Exception("bad double"); }
- function return_const_char_star() { throw new Exception("bad const_char_star"); }
- function return_std_string() { throw new Exception("bad std_string"); }
- function return_Bar() { throw new Exception("bad Bar"); }
-}
-
-$bad = new Bad();
-
-try {
- $bad->call_int();
- check::fail("Exception wasn't propagated from Bad::return_int()");
-} catch (Exception $e) {
- check::equal($e->getMessage(), "bad int", "propagated exception incorrect");
-}
-
-try {
- $bad->call_double();
- check::fail("Exception wasn't propagated from Bad::return_double()");
-} catch (Exception $e) {
- check::equal($e->getMessage(), "bad double", "propagated exception incorrect");
-}
-
-try {
- $bad->call_const_char_star();
- check::fail("Exception wasn't propagated from Bad::return_const_char_star()");
-} catch (Exception $e) {
- check::equal($e->getMessage(), "bad const_char_star", "propagated exception incorrect");
-}
-
-try {
- $bad->call_std_string();
- check::fail("Exception wasn't propagated from Bad::return_std_string()");
-} catch (Exception $e) {
- check::equal($e->getMessage(), "bad std_string", "propagated exception incorrect");
-}
-
-try {
- $bad->call_Bar();
- check::fail("Exception wasn't propagated from Bad::return_Bar()");
-} catch (Exception $e) {
- check::equal($e->getMessage(), "bad Bar", "propagated exception incorrect");
-}
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/director_extend_runme.php b/Examples/test-suite/php5/director_extend_runme.php
deleted file mode 100644
index f283aefbe..000000000
--- a/Examples/test-suite/php5/director_extend_runme.php
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-
-require "tests.php";
-require "director_extend.php";
-
-// No new functions
-check::functions(array(spobject_getfoobar,spobject_dummy,spobject_exceptionmethod));
-// No new classes
-check::classes(array(SpObject));
-// now new vars
-check::globals(array());
-
-class MyObject extends SpObject{
- function getFoo() {
- return 123;
- }
-}
-
-$m = new MyObject();
-check::equal($m->dummy(), 666, "1st call");
-check::equal($m->dummy(), 666, "2st call"); // Locked system
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/director_finalizer_runme.php b/Examples/test-suite/php5/director_finalizer_runme.php
deleted file mode 100644
index 0fcddfd8b..000000000
--- a/Examples/test-suite/php5/director_finalizer_runme.php
+++ /dev/null
@@ -1,61 +0,0 @@
-<?php
-
-require "tests.php";
-require "director_finalizer.php";
-
-// No new functions
-check::functions(array(foo_orstatus,deletefoo,getstatus,launder,resetstatus));
-// No new classes
-check::classes(array(director_finalizer,Foo));
-// now new vars
-check::globals(array());
-
-class MyFoo extends Foo {
- function __destruct() {
- $this->orStatus(2);
- if (method_exists(parent, "__destruct")) {
- parent::__destruct();
- }
- }
-}
-
-resetStatus();
-
-$a = new MyFoo();
-unset($a);
-
-check::equal(getStatus(), 3, "getStatus() failed #1");
-
-resetStatus();
-
-$a = new MyFoo();
-launder($a);
-
-check::equal(getStatus(), 0, "getStatus() failed #2");
-
-unset($a);
-
-check::equal(getStatus(), 3, "getStatus() failed #3");
-
-resetStatus();
-
-$a = new MyFoo();
-$a->thisown = 0;
-deleteFoo($a);
-unset($a);
-
-check::equal(getStatus(), 3, "getStatus() failed #4");
-
-resetStatus();
-
-$a = new MyFoo();
-$a->thisown = 0;
-deleteFoo(launder($a));
-unset($a);
-
-check::equal(getStatus(), 3, "getStatus() failed #5");
-
-resetStatus();
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/director_frob_runme.php b/Examples/test-suite/php5/director_frob_runme.php
deleted file mode 100644
index 548b0b804..000000000
--- a/Examples/test-suite/php5/director_frob_runme.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-require "tests.php";
-require "director_frob.php";
-
-// No new functions
-check::functions(array(alpha_abs_method,bravo_abs_method,charlie_abs_method,ops_opint,ops_opintstarstarconst,ops_opintamp,ops_opintstar,ops_opconstintintstar,prims_ull,prims_callull,corecallbacks_on3dengineredrawn,corecallbacks_on3dengineredrawn2));
-// No new classes
-check::classes(array(Alpha,Bravo,Charlie,Delta,Ops,Prims,corePoint3d,coreCallbacks_On3dEngineRedrawnData,coreCallbacksOn3dEngineRedrawnData,coreCallbacks));
-// now new vars
-check::globals(array(corecallbacks_on3dengineredrawndata__eye,corecallbacks_on3dengineredrawndata__at,corecallbackson3dengineredrawndata__eye,corecallbackson3dengineredrawndata__at));
-
-$foo = new Bravo();
-$s = $foo->abs_method();
-
-check::equal($s, "Bravo::abs_method()", "s failed");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/director_nested_runme.php b/Examples/test-suite/php5/director_nested_runme.php
deleted file mode 100644
index 4965e94f7..000000000
--- a/Examples/test-suite/php5/director_nested_runme.php
+++ /dev/null
@@ -1,74 +0,0 @@
-<?php
-
-require "tests.php";
-require "director_nested.php";
-
-// No new functions
-check::functions(array(foo_int_advance,foo_int_do_advance,bar_step,bar_do_advance,bar_do_step,foobar_int_get_value,foobar_int_get_name,foobar_int_name,foobar_int_get_self,foobar_int_do_advance,foobar_int_do_step));
-// No new classes
-check::classes(array(Foo_int,Bar,FooBar_int));
-// now new vars
-check::globals(array());
-
-class A extends FooBar_int {
- function do_step() {
- return "A::do_step;";
- }
-
- function get_value() {
- return "A::get_value";
- }
-}
-
-$a = new A();
-check::equal($a->step(), "Bar::step;Foo::advance;Bar::do_advance;A::do_step;", "Bad A virtual resolution");
-
-class B extends FooBar_int {
- function do_advance() {
- return "B::do_advance;" . $this->do_step();
- }
-
- function do_step() {
- return "B::do_step;";
- }
-
- function get_value() {
- return 1;
- }
-}
-
-$b = new B();
-
-check::equal($b->step(), "Bar::step;Foo::advance;B::do_advance;B::do_step;", "Bad B virtual resolution");
-
-class C extends FooBar_int {
- function do_advance() {
- return "C::do_advance;" . parent::do_advance();
- }
-
- function do_step() {
- return "C::do_step;";
- }
-
- function get_value() {
- return 2;
- }
-
- function get_name() {
- return parent::get_name() . " hello";
- }
-}
-
-$cc = new C();
-# TODO: Currently we do not track the dynamic type of returned
-# objects, so we skip the get_self() call.
-#$c = Foobar_int::get_self($cc);
-$c = $cc;
-$c->advance();
-
-check::equal($c->get_name(), "FooBar::get_name hello", "get_name failed");
-
-check::equal($c->name(), "FooBar::get_name hello", "name failed");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/director_pass_by_value_runme.php b/Examples/test-suite/php5/director_pass_by_value_runme.php
deleted file mode 100644
index 8a8b84d67..000000000
--- a/Examples/test-suite/php5/director_pass_by_value_runme.php
+++ /dev/null
@@ -1,24 +0,0 @@
-<?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/php5/director_profile_runme.php b/Examples/test-suite/php5/director_profile_runme.php
deleted file mode 100644
index c72421341..000000000
--- a/Examples/test-suite/php5/director_profile_runme.php
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-
-require "tests.php";
-require "director_profile.php";
-
-// No new functions
-check::functions(array(b_fn,b_vfi,b_fi,b_fj,b_fk,b_fl,b_get_self,b_vfs,b_fs));
-// No new classes
-check::classes(array(A,B));
-// now new vars
-check::globals(array());
-
-class MyB extends B {
- function vfi($a) {
- return $a+3;
- }
-}
-
-$a = new A();
-$myb = new MyB();
-$b = B::get_self($myb);
-
-$i = 50000;
-$a = 1;
-
-while ($i) {
- $a = $b->fi($a); #1
- $a = $b->fi($a); #2
- $a = $b->fi($a); #3
- $a = $b->fi($a); #4
- $a = $b->fi($a); #5
- $a = $b->fi($a); #6
- $a = $b->fi($a); #7
- $a = $b->fi($a); #8
- $a = $b->fi($a); #9
- $a = $b->fi($a); #10
- $a = $b->fi($a); #1
- $a = $b->fi($a); #2
- $a = $b->fi($a); #3
- $a = $b->fi($a); #4
- $a = $b->fi($a); #5
- $a = $b->fi($a); #6
- $a = $b->fi($a); #7
- $a = $b->fi($a); #8
- $a = $b->fi($a); #9
- $a = $b->fi($a); #20
- $i -= 1;
-}
-
-print $a . "\n";
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/director_protected_runme.php b/Examples/test-suite/php5/director_protected_runme.php
deleted file mode 100644
index 18586ca62..000000000
--- a/Examples/test-suite/php5/director_protected_runme.php
+++ /dev/null
@@ -1,70 +0,0 @@
-<?php
-
-require "tests.php";
-require "director_protected.php";
-
-check::functions(array(foo_pong,foo_s,foo_q,foo_ping,foo_pang,foo_used,foo_cheer,bar_create,bar_callping,bar_callcheer,bar_cheer,bar_pong,bar_used,bar_ping,bar_pang,a_draw,b_draw));
-check::classes(array(Foo,Bar,PrivateFoo,A,B,AA,BB));
-check::globals(array(bar_a));
-
-class FooBar extends Bar {
- protected function ping() {
- return "FooBar::ping();";
- }
-}
-
-class FooBar2 extends Bar {
- function ping() {
- return "FooBar2::ping();";
- }
-
- function pang() {
- return "FooBar2::pang();";
- }
-}
-
-class FooBar3 extends Bar {
- function cheer() {
- return "FooBar3::cheer();";
- }
-}
-
-$b = new Bar();
-$f = $b->create();
-$fb = new FooBar();
-$fb2 = new FooBar2();
-$fb3 = new FooBar3();
-
-check::equal($fb->used(), "Foo::pang();Bar::pong();Foo::pong();FooBar::ping();", "bad FooBar::used");
-
-check::equal($fb2->used(), "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();", "bad FooBar2::used");
-
-check::equal($b->pong(), "Bar::pong();Foo::pong();Bar::ping();", "bad Bar::pong");
-
-check::equal($f->pong(), "Bar::pong();Foo::pong();Bar::ping();", "bad Foo::pong");
-
-check::equal($fb->pong(), "Bar::pong();Foo::pong();FooBar::ping();", "bad FooBar::pong");
-
-$method = new ReflectionMethod('Bar', 'ping');
-check::equal($method->isProtected(), true, "Foo::ping should be protected");
-
-$method = new ReflectionMethod('Foo', 'ping');
-check::equal($method->isProtected(), true, "Foo::ping should be protected");
-
-$method = new ReflectionMethod('FooBar', 'pang');
-check::equal($method->isProtected(), true, "FooBar::pang should be protected");
-
-$method = new ReflectionMethod('Bar', 'cheer');
-check::equal($method->isProtected(), true, "Bar::cheer should be protected");
-
-$method = new ReflectionMethod('Foo', 'cheer');
-check::equal($method->isProtected(), true, "Foo::cheer should be protected");
-
-check::equal($fb3->cheer(), "FooBar3::cheer();", "bad fb3::pong");
-check::equal($fb2->callping(), "FooBar2::ping();", "bad fb2::callping");
-check::equal($fb2->callcheer(), "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();", "bad fb2::callcheer");
-check::equal($fb3->callping(), "Bar::ping();", "bad fb3::callping");
-check::equal($fb3->callcheer(), "FooBar3::cheer();", "bad fb3::callcheer");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/director_stl_runme.php b/Examples/test-suite/php5/director_stl_runme.php
deleted file mode 100644
index 29addd261..000000000
--- a/Examples/test-suite/php5/director_stl_runme.php
+++ /dev/null
@@ -1,60 +0,0 @@
-<?php
-
-require "tests.php";
-require "director_stl.php";
-
-// No new functions
-check::functions(array(foo_bar,foo_ping,foo_pong,foo_tping,foo_tpong,foo_pident,foo_vident,foo_vsecond,foo_tpident,foo_tvident,foo_tvsecond,foo_vidents,foo_tvidents));
-// No new classes
-check::classes(array(Foo));
-// now new vars
-check::globals(array());
-
-class MyFoo extends Foo {
- function ping($s) {
- return "MyFoo::ping():" . $s;
- }
-
- function pident($arg) {
- return $arg;
- }
-
- function vident($v) {
- return $v;
- }
-
- function vidents($v) {
- return $v;
- }
-
- function vsecond($v1, $v2) {
- return $v2;
- }
-}
-
-$a = new MyFoo();
-
-$a->tping("hello");
-$a->tpong("hello");
-
-# TODO: automatic conversion between PHP arrays and std::pair or
-# std::vector is not yet implemented.
-/*$p = array(1, 2);
-$a->pident($p);
-$v = array(3, 4);
-$a->vident($v);
-
-$a->tpident($p);
-$a->tvident($v);
-
-$v1 = array(3, 4);
-$v2 = array(5, 6);
-
-$a->tvsecond($v1, $v2);
-
-$vs = array("hi", "hello");
-$vs;
-$a->tvidents($vs);*/
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/director_string_runme.php b/Examples/test-suite/php5/director_string_runme.php
deleted file mode 100644
index 5ac583f78..000000000
--- a/Examples/test-suite/php5/director_string_runme.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-
-require "tests.php";
-require "director_string.php";
-
-// No new functions
-check::functions(array(a_get_first,a_call_get_first,a_string_length,a_process_text,a_call_process_func,stringvector_size,stringvector_is_empty,stringvector_clear,stringvector_push,stringvector_pop,stringvector_capacity,stringvector_reserve));
-// No new classes
-check::classes(array(A,StringVector));
-// now new vars
-check::globals(array(a,a_call,a_m_strings,stringvector));
-
-class B extends A {
- function get_first() {
- return parent::get_first() . " world!";
- }
-
- function process_text($string) {
- parent::process_text($string);
- $this->smem = "hello";
- }
-}
-
-$b = new B("hello");
-
-$b->get(0);
-check::equal($b->get_first(),"hello world!", "get_first failed");
-
-$b->call_process_func();
-
-check::equal($b->smem, "hello", "smem failed");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/director_thread_runme.php b/Examples/test-suite/php5/director_thread_runme.php
deleted file mode 100644
index 809dec3e2..000000000
--- a/Examples/test-suite/php5/director_thread_runme.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-
-require "tests.php";
-require "director_thread.php";
-
-# Fails in a ZTS-build of PHP - see: https://github.com/swig/swig/pull/155
-exit(0);
-
-// No new functions
-check::functions(array(millisecondsleep,foo_stop,foo_run,foo_do_foo));
-// No new classes
-check::classes(array(director_thread,Foo));
-// now new vars
-check::globals(array(foo_val));
-
-class Derived extends Foo {
- function do_foo() {
- $this->val = $this->val - 1;
- }
-}
-
-$d = new Derived();
-$d->run();
-
-if ($d->val >= 0) {
- check::fail($d->val);
-}
-
-$d->stop();
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/director_unroll_runme.php b/Examples/test-suite/php5/director_unroll_runme.php
deleted file mode 100644
index 626b1f07d..000000000
--- a/Examples/test-suite/php5/director_unroll_runme.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-
-require "tests.php";
-require "director_unroll.php";
-
-// No new functions
-check::functions(array(foo_ping,foo_pong));
-// No new classes
-check::classes(array(Foo,Bar));
-// now new vars
-check::globals(array(bar));
-
-class MyFoo extends Foo {
- function ping() {
- return "MyFoo::ping()";
- }
-}
-
-$a = new MyFoo();
-
-$b = new Bar();
-
-$b->set($a);
-$c = $b->get();
-
-check::equal($a->this, $c->this, "this failed");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/enum_scope_template_runme.php b/Examples/test-suite/php5/enum_scope_template_runme.php
deleted file mode 100644
index 85ba467b7..000000000
--- a/Examples/test-suite/php5/enum_scope_template_runme.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-require "tests.php";
-require "enum_scope_template.php";
-
-check::classes(array("enum_scope_template", "TreeInt"));
-check::functions(array("chops","treeint_chops"));
-check::equal(0,TreeInt_Oak,"0==TreeInt_Oak");
-check::equal(1,TreeInt_Fir,"1==TreeInt_Fir");
-check::equal(2,TreeInt_Cedar,"2==TreeInt_Cedar");
-check::equal(TreeInt_Oak,chops(TreeInt_Oak),"TreeInt_Oak==chops(TreeInt_Oak)");
-check::equal(TreeInt_Fir,chops(TreeInt_Fir),"TreeInt_Fir==chops(TreeInt_Fir)");
-check::equal(TreeInt_Cedar,chops(TreeInt_Cedar),"TreeInt_Cedar==chops(TreeInt_Cedar)");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/evil_diamond_ns_runme.php b/Examples/test-suite/php5/evil_diamond_ns_runme.php
deleted file mode 100644
index fcce0f767..000000000
--- a/Examples/test-suite/php5/evil_diamond_ns_runme.php
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php
-
-require "tests.php";
-require "evil_diamond_ns.php";
-
-check::classes(array("evil_diamond_ns","foo","bar","baz","spam"));
-check::functions("test");
-check::is_a("bar","foo");
-check::is_a("baz","foo");
-check::is_a("spam","foo");
-check::is_a("spam","bar");
-//No multiple inheritance
-//check::is_a("spam","baz");
-$spam=new spam();
-$_spam=test($spam);
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/evil_diamond_prop_runme.php b/Examples/test-suite/php5/evil_diamond_prop_runme.php
deleted file mode 100644
index 02d9944d6..000000000
--- a/Examples/test-suite/php5/evil_diamond_prop_runme.php
+++ /dev/null
@@ -1,38 +0,0 @@
-<?php
-
-require "tests.php";
-require "evil_diamond_prop.php";
-
-check::classes(array("evil_diamond_prop","foo","bar","baz","spam"));
-check::functions("test");
-check::is_a("bar","foo");
-check::is_a("baz","foo");
-check::is_a("spam","foo");
-check::is_a("spam","bar");
-//No multiple inheritance introspection yet
-//check::is_a("spam","baz");
-
-$foo=new foo();
-check::is_a($foo,"foo");
-check::equal(1,$foo->_foo,"1==foo->_foo");
-
-$bar=new bar();
-check::is_a($bar,"bar");
-check::equal(1,$bar->_foo,"1==bar->_foo");
-check::equal(2,$bar->_bar,"2==bar->_bar");
-
-$baz=new baz();
-check::is_a($baz,"baz");
-check::equal(1,$baz->_foo,"1==baz->_foo");
-check::equal(3,$baz->_baz,"3==baz->_baz");
-
-$spam=new spam();
-check::is_a($spam,"spam");
-check::equal(1,$spam->_foo,"1==spam->_foo");
-check::equal(2,$spam->_bar,"2==spam->_bar");
-// multiple inheritance not supported in PHP
-check::equal(null,$spam->_baz,"null==spam->_baz");
-check::equal(4,$spam->_spam,"4==spam->_spam");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/evil_diamond_runme.php b/Examples/test-suite/php5/evil_diamond_runme.php
deleted file mode 100644
index a587ca359..000000000
--- a/Examples/test-suite/php5/evil_diamond_runme.php
+++ /dev/null
@@ -1,16 +0,0 @@
-<?php
-
-require "tests.php";
-require "evil_diamond.php";
-
-check::classes(array("evil_diamond","foo","bar","baz","spam"));
-check::functions("test");
-check::is_a("bar","foo");
-check::is_a("baz","foo");
-check::is_a("spam","foo");
-check::is_a("spam","bar");
-//No multiple inheritance
-//check::is_a("spam","baz");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/exception_order_runme.php b/Examples/test-suite/php5/exception_order_runme.php
deleted file mode 100644
index acb83561a..000000000
--- a/Examples/test-suite/php5/exception_order_runme.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?
-require "tests.php";
-require "exception_order.php";
-
-check::functions(array(a_foo,a_bar,a_foobar,a_barfoo,is_python_builtin));
-check::classes(array(A,E1,E2,E3,exception_order,ET_i,ET_d));
-check::globals(array(efoovar,foovar,cfoovar,a_sfoovar,a_foovar,a_efoovar));
-
-$a = new A();
-try {
- $a->foo();
-} catch (Exception $e) {
- check::equal($e->getMessage(), 'C++ E1 exception thrown', '');
-}
-
-try {
- $a->bar();
-} catch (Exception $e) {
- check::equal($e->getMessage(), 'C++ E2 exception thrown', '');
-}
-
-try {
- $a->foobar();
-} catch (Exception $e) {
- check::equal($e->getMessage(), 'postcatch unknown', '');
-}
-
-try {
- $a->barfoo(1);
-} catch (Exception $e) {
- check::equal($e->getMessage(), 'C++ E1 exception thrown', '');
-}
-
-try {
- $a->barfoo(2);
-} catch (Exception $e) {
- check::equal($e->getMessage(), 'C++ E2 * exception thrown', '');
-}
-?>
diff --git a/Examples/test-suite/php5/extend_template_ns_runme.php b/Examples/test-suite/php5/extend_template_ns_runme.php
deleted file mode 100644
index e6d3e9f73..000000000
--- a/Examples/test-suite/php5/extend_template_ns_runme.php
+++ /dev/null
@@ -1,12 +0,0 @@
-<?php
-
-require "tests.php";
-require "extend_template_ns.php";
-
-check::classes(array("extend_template_ns","Foo_One"));
-$foo=new Foo_One();
-check::equal(2,$foo->test1(2),"test1");
-check::equal(3,$foo->test2(3),"test2");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/extend_template_runme.php b/Examples/test-suite/php5/extend_template_runme.php
deleted file mode 100644
index 41bde4458..000000000
--- a/Examples/test-suite/php5/extend_template_runme.php
+++ /dev/null
@@ -1,12 +0,0 @@
-<?php
-
-require "tests.php";
-require "extend_template.php";
-
-check::classes(array("Foo_0"));
-$foo=new Foo_0();
-check::equal(2,$foo->test1(2),"test1");
-check::equal(3,$foo->test2(3),"test2");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/grouping_runme.php b/Examples/test-suite/php5/grouping_runme.php
deleted file mode 100644
index 51446f473..000000000
--- a/Examples/test-suite/php5/grouping_runme.php
+++ /dev/null
@@ -1,22 +0,0 @@
-<?php
-
-require "tests.php";
-require "grouping.php";
-
-check::functions(array("test1","test2","do_unary","negate"));
-check::equal(5,test1(5),"5==test1(5)");
-check::resource(test2(7),"_p_int","_p_int==test2(7)");
-check::globals(array(test3));
-
-//check::equal(37,test3_get(),'37==test3_get()');
-check::equal(37,check::get("test3"),'37==get(test3)');
-//test3_set(38);
-check::set(test3,38);
-//check::equal(38,test3_get(),'38==test3_get() after test3_set(37)');
-check::equal(38,check::get(test3),'38==get(test3) after set(test)');
-
-check::equal(-5,negate(5),"-5==negate(5)");
-check::equal(7,do_unary(-7,NEGATE),"7=do_unary(-7,NEGATE)");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/ignore_parameter_runme.php b/Examples/test-suite/php5/ignore_parameter_runme.php
deleted file mode 100644
index 1c8c76ad4..000000000
--- a/Examples/test-suite/php5/ignore_parameter_runme.php
+++ /dev/null
@@ -1,38 +0,0 @@
-<?php
-
-require "tests.php";
-require "ignore_parameter.php";
-
-// New functions
-check::functions(array(jaguar,lotus,tvr,ferrari,sportscars_daimler,sportscars_astonmartin,sportscars_bugatti,sportscars_lamborghini));
-// New classes
-check::classes(array(ignore_parameter,SportsCars,MiniCooper,MorrisMinor,FordAnglia,AustinAllegro));
-// No new vars
-check::globals(array());
-
-check::equal(jaguar(2,3.4),"hello",'jaguar(2,3.4)=="hello"');
-check::equal(lotus("eek",3.4),101,'lotus("eek",3.4)==101');
-check::equal(tvr("eek",2),8.8,'tvr("eek",2)==8.8');
-check::equal(ferrari(),101,'ferrari(2)==101');
-
-$sc=new sportscars();
-check::classname("sportscars",$sc);
-check::equal($sc->daimler(2,3.4),"hello",'$sc->daimler(2,3.4)=="hello"');
-check::equal($sc->astonmartin("eek",3.4),101,'$sc->mastonmartin("eek",3.4)==101');
-check::equal($sc->bugatti("eek",2),8.8,'$sc->bugatti("eek",2)==8.8');
-check::equal($sc->lamborghini(),101,'$sc->lamborghini(2)==101');
-
-$mc=new minicooper(2,3.4);
-check::classname("minicooper",$mc);
-
-$mm=new morrisminor("eek",3.4);
-check::classname("morrisminor",$mm);
-
-$fa=new fordanglia("eek",2);
-check::classname("fordanglia",$fa);
-
-$aa=new austinallegro();
-check::classname("austinallegro",$aa);
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/import_nomodule_runme.php b/Examples/test-suite/php5/import_nomodule_runme.php
deleted file mode 100644
index 41836ba0f..000000000
--- a/Examples/test-suite/php5/import_nomodule_runme.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-require "tests.php";
-require "import_nomodule.php";
-
-// No new functions
-check::functions(array(create_foo,delete_foo,test1,is_python_builtin));
-// No new classes
-check::classes(array(import_nomodule,Bar));
-// now new vars
-check::globals(array());
-
-$f = import_nomodule::create_Foo();
-import_nomodule::test1($f,42);
-import_nomodule::delete_Foo($f);
-
-$b = new Bar();
-import_nomodule::test1($b,37);
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/li_carrays_cpp_runme.php b/Examples/test-suite/php5/li_carrays_cpp_runme.php
deleted file mode 100644
index e0f9ffe92..000000000
--- a/Examples/test-suite/php5/li_carrays_cpp_runme.php
+++ /dev/null
@@ -1,22 +0,0 @@
-<?php
-require "tests.php";
-require "li_carrays_cpp.php";
-
-// Check functions.
-check::functions(array(new_intarray,delete_intarray,intarray_getitem,intarray_setitem,doublearray_getitem,doublearray_setitem,doublearray_cast,doublearray_frompointer,xyarray_getitem,xyarray_setitem,xyarray_cast,xyarray_frompointer,delete_abarray,abarray_getitem,abarray_setitem,shortarray_getitem,shortarray_setitem,shortarray_cast,shortarray_frompointer,sum_array));
-
-// Check classes.
-// NB An "li_carrays_cpp" class is created as a mock namespace.
-check::classes(array(li_carrays_cpp,doubleArray,AB,XY,XYArray,shortArray));
-
-// Check global variables.
-check::globals(array(xy_x,xy_y,globalxyarray,ab_a,ab_b,globalabarray));
-
-$d = new doubleArray(10);
-
-$d->setitem(0, 7);
-$d->setitem(5, $d->getitem(0) + 3);
-check::equal($d->getitem(0) + $d->getitem(5), 17., "7+10==17");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/li_carrays_runme.php b/Examples/test-suite/php5/li_carrays_runme.php
deleted file mode 100644
index 40e82f9ea..000000000
--- a/Examples/test-suite/php5/li_carrays_runme.php
+++ /dev/null
@@ -1,22 +0,0 @@
-<?php
-require "tests.php";
-require "li_carrays.php";
-
-// Check functions.
-check::functions(array(new_intarray,delete_intarray,intarray_getitem,intarray_setitem,doublearray_getitem,doublearray_setitem,doublearray_cast,doublearray_frompointer,xyarray_getitem,xyarray_setitem,xyarray_cast,xyarray_frompointer,delete_abarray,abarray_getitem,abarray_setitem,shortarray_getitem,shortarray_setitem,shortarray_cast,shortarray_frompointer,sum_array));
-
-// Check classes.
-// NB An "li_carrays" class is created as a mock namespace.
-check::classes(array(li_carrays,doubleArray,AB,XY,XYArray,shortArray));
-
-// Check global variables.
-check::globals(array(xy_x,xy_y,globalxyarray,ab_a,ab_b,globalabarray));
-
-$d = new doubleArray(10);
-
-$d->setitem(0, 7);
-$d->setitem(5, $d->getitem(0) + 3);
-check::equal($d->getitem(0) + $d->getitem(5), 17., "7+10==17");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/li_factory_runme.php b/Examples/test-suite/php5/li_factory_runme.php
deleted file mode 100644
index 6623e2a8c..000000000
--- a/Examples/test-suite/php5/li_factory_runme.php
+++ /dev/null
@@ -1,22 +0,0 @@
-<?php
-
-require "tests.php";
-require "li_factory.php";
-
-// No new functions
-check::functions(array(geometry_draw,geometry_create,geometry_clone_,point_draw,point_width,point_clone_,circle_draw,circle_radius,circle_clone_));
-// No new classes
-check::classes(array(Geometry,Point,Circle));
-// now new vars
-check::globals(array());
-
-$circle = Geometry::create(Geometry::CIRCLE);
-$r = $circle->radius();
-check::equal($r, 1.5, "r failed");
-
-$point = Geometry::create(Geometry::POINT);
-$w = $point->width();
-check::equal($w, 1.0, "w failed");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/li_std_string_runme.php b/Examples/test-suite/php5/li_std_string_runme.php
deleted file mode 100644
index ad62247e1..000000000
--- a/Examples/test-suite/php5/li_std_string_runme.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-
-require "tests.php";
-require "li_std_string.php";
-
-// Global variables
-//$s="initial string";
-//check::equal(GlobalString2_get() ,"global string 2", "GlobalString2 test 1");
-
-// Global variables
-$s = "initial string";
-check::equal(GlobalString2_get(), "global string 2", "GlobalString2 test 1");
-GlobalString2_set($s);
-check::equal(GlobalString2_get(), $s, "GlobalString2 test 2");
-check::equal(ConstGlobalString_get(), "const global string", "ConstGlobalString test");
-
-// Member variables
-$myStructure = new Structure();
-check::equal($myStructure->MemberString2, "member string 2", "MemberString2 test 1");
-$myStructure->MemberString2 = $s;
-check::equal($myStructure->MemberString2, $s, "MemberString2 test 2");
-check::equal($myStructure->ConstMemberString, "const member string", "ConstMemberString test");
-
-check::equal(Structure::StaticMemberString2(), "static member string 2", "StaticMemberString2 test 1");
-Structure::StaticMemberString2($s);
-check::equal(Structure::StaticMemberString2(), $s, "StaticMemberString2 test 2");
-// below broken ?
-//check::equal(Structure::ConstStaticMemberString(), "const static member string", "ConstStaticMemberString test");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/li_std_vector_member_var_runme.php b/Examples/test-suite/php5/li_std_vector_member_var_runme.php
deleted file mode 100644
index 238350352..000000000
--- a/Examples/test-suite/php5/li_std_vector_member_var_runme.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-
-require "tests.php";
-require "li_std_vector_member_var.php";
-
-$t = new Test();
-
-check::equal($t->x, 0, "Test::x != 0");
-check::equal($t->v->size(), 0, "Test::v.size() != 0");
-
-$t->f(1);
-check::equal($t->x, 1, "Test::x != 1");
-check::equal($t->v->size(), 1, "Test::v.size() != 1");
-
-$t->f(2);
-check::equal($t->x, 3, "Test::x != 3");
-check::equal($t->v->size(), 2, "Test::v.size() != 2");
-
-$t->f(3);
-check::equal($t->x, 6, "Test::x != 6");
-check::equal($t->v->size(), 3, "Test::v.size() != 3");
-
-$T = new T();
-$T->start_t = new S();
-$T->length = 7;
-check::equal($T->start_t->x, 4, "S::x != 4");
-check::equal($T->length, 7, "T::length != 7");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/newobject1_runme.php b/Examples/test-suite/php5/newobject1_runme.php
deleted file mode 100644
index 5853a72c0..000000000
--- a/Examples/test-suite/php5/newobject1_runme.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-require "tests.php";
-require "newobject1.php";
-
-// No new functions
-check::functions(array(foo_makefoo,foo_makemore,foo_foocount));
-// No new classes
-check::classes(array(Foo));
-// now new vars
-check::globals(array());
-
-$foo = Foo::makeFoo();
-check::equal(get_class($foo), "Foo", "static failed");
-$bar = $foo->makeMore();
-check::equal(get_class($bar), "Foo", "regular failed");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/overload_rename_runme.php b/Examples/test-suite/php5/overload_rename_runme.php
deleted file mode 100644
index dce4c6cb3..000000000
--- a/Examples/test-suite/php5/overload_rename_runme.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-require "tests.php";
-require "overload_rename.php";
-
-// No new functions
-check::functions(array());
-// No new classes
-check::classes(array(Foo));
-// now new vars
-check::globals(array());
-
-$f = new Foo(1.0);
-$f = new Foo(1.0,1.0);
-$f = Foo::Foo_int(1.0,1);
-$f = Foo::Foo_int(1.0,1,1.0);
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/overload_return_type_runme.php b/Examples/test-suite/php5/overload_return_type_runme.php
deleted file mode 100644
index 4fa19d22a..000000000
--- a/Examples/test-suite/php5/overload_return_type_runme.php
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php
-
-require "tests.php";
-require "overload_return_type.php";
-
-$b = new B;
-check::equal($b->foo(1), 0, "");
-check::classname("A", $b->foo("test"));
-
-check::equal(overload_return_type::foo(), 1, "overload_return_type::foo() should be 1");
-check::equal(overload_return_type::bar(), 1, "overload_return_type::bar() should be 1");
-
-?>
diff --git a/Examples/test-suite/php5/php_iterator_runme.php b/Examples/test-suite/php5/php_iterator_runme.php
deleted file mode 100644
index d69a5b385..000000000
--- a/Examples/test-suite/php5/php_iterator_runme.php
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-
-require "tests.php";
-require "php_iterator.php";
-
-check::functions(array(myiterator_rewind,myiterator_key,myiterator_current,myiterator_next,myiterator_valid));
-check::classes(array(MyIterator));
-// No new global variables.
-check::globals(array());
-
-$s = '';
-foreach (new MyIterator(1, 6) as $i) {
- $s .= $i;
-}
-check::equal($s, '12345', 'Simple iteration failed');
-
-$s = '';
-foreach (new MyIterator(2, 5) as $k => $v) {
- $s .= "($k=>$v)";
-}
-check::equal($s, '(0=>2)(1=>3)(2=>4)', 'Simple iteration failed');
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/pointer_reference_runme.php b/Examples/test-suite/php5/pointer_reference_runme.php
deleted file mode 100644
index 52946177e..000000000
--- a/Examples/test-suite/php5/pointer_reference_runme.php
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php
-
-require "tests.php";
-require "pointer_reference.php";
-
-$s = pointer_reference::get();
-check::equal($s->value, 10, "pointer_reference::get() failed");
-
-$ss = new Struct(20);
-pointer_reference::set($ss);
-$i = Struct::instance();
-check::equal($i->value, 20, "pointer_reference::set() failed");
-
-check::equal(pointer_reference::overloading(1), 111, "overload test 1 failed");
-check::equal(pointer_reference::overloading($ss), 222, "overload test 2 failed");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/prefix_runme.php b/Examples/test-suite/php5/prefix_runme.php
deleted file mode 100644
index ead064f5b..000000000
--- a/Examples/test-suite/php5/prefix_runme.php
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php
-
-require "tests.php";
-require "prefix.php";
-
-// No new functions
-check::functions(array(foo_get_self));
-// No new classes
-check::classes(array(ProjectFoo));
-// now new vars
-check::globals(array());
-
-$f = new ProjectFoo();
-// This resulted in "Fatal error: Class 'Foo' not found"
-$f->get_self();
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/preproc_constants_c_runme.php b/Examples/test-suite/php5/preproc_constants_c_runme.php
deleted file mode 100644
index 1ea01950e..000000000
--- a/Examples/test-suite/php5/preproc_constants_c_runme.php
+++ /dev/null
@@ -1,66 +0,0 @@
-<?php
-
-require "tests.php";
-require "preproc_constants_c.php";
-
-// Same as preproc_constants.i testcase, but bool types are always wrapped as int.
-check::equal(gettype(preproc_constants_c::CONST_INT1), "integer", "preproc_constants.CONST_INT1 has unexpected type");
-check::equal(gettype(preproc_constants_c::CONST_INT2), "integer", "preproc_constants.CONST_INT2 has unexpected type");
-check::equal(gettype(preproc_constants_c::CONST_UINT1), "integer", "preproc_constants.CONST_UINT1 has unexpected type");
-check::equal(gettype(preproc_constants_c::CONST_UINT2), "integer", "preproc_constants.CONST_UINT2 has unexpected type");
-check::equal(gettype(preproc_constants_c::CONST_UINT3), "integer", "preproc_constants.CONST_UINT3 has unexpected type");
-check::equal(gettype(preproc_constants_c::CONST_UINT4), "integer", "preproc_constants.CONST_UINT4 has unexpected type");
-check::equal(gettype(preproc_constants_c::CONST_LONG1), "integer", "preproc_constants.CONST_LONG1 has unexpected type");
-check::equal(gettype(preproc_constants_c::CONST_LONG2), "integer", "preproc_constants.CONST_LONG2 has unexpected type");
-check::equal(gettype(preproc_constants_c::CONST_LONG3), "integer", "preproc_constants.CONST_LONG3 has unexpected type");
-check::equal(gettype(preproc_constants_c::CONST_LONG4), "integer", "preproc_constants.CONST_LONG4 has unexpected type");
-# On some platforms these don't fit in a PHP integer and so get wrapped as a string constant.
-#check::equal(gettype(preproc_constants_c::CONST_LLONG1), "integer", "preproc_constants.CONST_LLONG1 has unexpected type");
-#check::equal(gettype(preproc_constants_c::CONST_LLONG2), "integer", "preproc_constants.CONST_LLONG2 has unexpected type");
-#check::equal(gettype(preproc_constants_c::CONST_LLONG3), "integer", "preproc_constants.CONST_LLONG3 has unexpected type");
-#check::equal(gettype(preproc_constants_c::CONST_LLONG4), "integer", "preproc_constants.CONST_LLONG4 has unexpected type");
-#check::equal(gettype(preproc_constants_c::CONST_ULLONG1), "integer", "preproc_constants.CONST_ULLONG1 has unexpected type");
-#check::equal(gettype(preproc_constants_c::CONST_ULLONG2), "integer", "preproc_constants.CONST_ULLONG2 has unexpected type");
-#check::equal(gettype(preproc_constants_c::CONST_ULLONG3), "integer", "preproc_constants.CONST_ULLONG3 has unexpected type");
-#check::equal(gettype(preproc_constants_c::CONST_ULLONG4), "integer", "preproc_constants.CONST_ULLONG4 has unexpected type");
-check::equal(gettype(preproc_constants_c::CONST_DOUBLE1), "double", "preproc_constants.CONST_DOUBLE1 has unexpected type");
-check::equal(gettype(preproc_constants_c::CONST_DOUBLE2), "double", "preproc_constants.CONST_DOUBLE2 has unexpected type");
-check::equal(gettype(preproc_constants_c::CONST_DOUBLE3), "double", "preproc_constants.CONST_DOUBLE3 has unexpected type");
-check::equal(gettype(preproc_constants_c::CONST_DOUBLE4), "double", "preproc_constants.CONST_DOUBLE4 has unexpected type");
-check::equal(gettype(preproc_constants_c::CONST_DOUBLE5), "double", "preproc_constants.CONST_DOUBLE5 has unexpected type");
-check::equal(gettype(preproc_constants_c::CONST_DOUBLE6), "double", "preproc_constants.CONST_DOUBLE6 has unexpected type");
-check::equal(gettype(preproc_constants_c::CONST_BOOL1), "integer", "preproc_constants.CONST_BOOL1 has unexpected type");
-check::equal(gettype(preproc_constants_c::CONST_BOOL2), "integer", "preproc_constants.CONST_BOOL2 has unexpected type");
-check::equal(gettype(preproc_constants_c::CONST_CHAR), "string", "preproc_constants.CONST_CHAR has unexpected type");
-check::equal(gettype(preproc_constants_c::CONST_STRING1), "string", "preproc_constants.CONST_STRING1 has unexpected type");
-check::equal(gettype(preproc_constants_c::CONST_STRING2), "string", "preproc_constants.CONST_STRING2 has unexpected type");
-
-check::equal(gettype(preproc_constants_c::INT_AND_BOOL), "integer", "preproc_constants.INT_AND_BOOL has unexpected type");
-check::equal(gettype(preproc_constants_c::INT_AND_CHAR), "integer", "preproc_constants.INT_AND_CHAR has unexpected type");
-check::equal(gettype(preproc_constants_c::INT_AND_INT), "integer", "preproc_constants.INT_AND_INT has unexpected type");
-check::equal(gettype(preproc_constants_c::INT_AND_UINT), "integer", "preproc_constants.INT_AND_UINT has unexpected type");
-check::equal(gettype(preproc_constants_c::INT_AND_LONG), "integer", "preproc_constants.INT_AND_LONG has unexpected type");
-check::equal(gettype(preproc_constants_c::INT_AND_ULONG), "integer", "preproc_constants.INT_AND_ULONG has unexpected type");
-# On some platforms these don't fit in a PHP integer and so get wrapped as a string constant.
-#check::equal(gettype(preproc_constants_c::INT_AND_LLONG), "integer", "preproc_constants.INT_AND_LLONG has unexpected type");
-#check::equal(gettype(preproc_constants_c::INT_AND_ULLONG), "integer", "preproc_constants.INT_AND_ULLONG has unexpected type");
-check::equal(gettype(preproc_constants_c::BOOL_AND_BOOL), "integer", "preproc_constants.BOOL_AND_BOOL has unexpected type");
-
-check::equal(gettype(preproc_constants_c::EXPR_MULTIPLY), "integer", "preproc_constants.EXPR_MULTIPLY has unexpected type");
-check::equal(gettype(preproc_constants_c::EXPR_DIVIDE), "integer", "preproc_constants.EXPR_DIVIDE has unexpected type");
-check::equal(gettype(preproc_constants_c::EXPR_PLUS), "integer", "preproc_constants.EXPR_PLUS has unexpected type");
-check::equal(gettype(preproc_constants_c::EXPR_MINUS), "integer", "preproc_constants.EXPR_MINUS has unexpected type");
-check::equal(gettype(preproc_constants_c::EXPR_LSHIFT), "integer", "preproc_constants.EXPR_LSHIFT has unexpected type");
-check::equal(gettype(preproc_constants_c::EXPR_RSHIFT), "integer", "preproc_constants.EXPR_RSHIFT has unexpected type");
-check::equal(gettype(preproc_constants_c::EXPR_LTE), "integer", "preproc_constants.EXPR_LTE has unexpected type");
-check::equal(gettype(preproc_constants_c::EXPR_GTE), "integer", "preproc_constants.EXPR_GTE has unexpected type");
-check::equal(gettype(preproc_constants_c::EXPR_INEQUALITY), "integer", "preproc_constants.EXPR_INEQUALITY has unexpected type");
-check::equal(gettype(preproc_constants_c::EXPR_EQUALITY), "integer", "preproc_constants.EXPR_EQUALITY has unexpected type");
-check::equal(gettype(preproc_constants_c::EXPR_AND), "integer", "preproc_constants.EXPR_AND has unexpected type");
-check::equal(gettype(preproc_constants_c::EXPR_XOR), "integer", "preproc_constants.EXPR_XOR has unexpected type");
-check::equal(gettype(preproc_constants_c::EXPR_OR), "integer", "preproc_constants.EXPR_OR has unexpected type");
-check::equal(gettype(preproc_constants_c::EXPR_LAND), "integer", "preproc_constants.EXPR_LAND has unexpected type");
-check::equal(gettype(preproc_constants_c::EXPR_LOR), "integer", "preproc_constants.EXPR_LOR has unexpected type");
-check::equal(gettype(preproc_constants_c::EXPR_CONDITIONAL), "double", "preproc_constants.EXPR_CONDITIONAL has unexpected type");
-
-?>
diff --git a/Examples/test-suite/php5/preproc_constants_runme.php b/Examples/test-suite/php5/preproc_constants_runme.php
deleted file mode 100644
index fb9ee4fa7..000000000
--- a/Examples/test-suite/php5/preproc_constants_runme.php
+++ /dev/null
@@ -1,74 +0,0 @@
-<?php
-
-require "tests.php";
-require "preproc_constants.php";
-
-check::equal(gettype(preproc_constants::CONST_INT1), "integer", "preproc_constants.CONST_INT1 has unexpected type");
-check::equal(gettype(preproc_constants::CONST_INT2), "integer", "preproc_constants.CONST_INT2 has unexpected type");
-check::equal(gettype(preproc_constants::CONST_UINT1), "integer", "preproc_constants.CONST_UINT1 has unexpected type");
-check::equal(gettype(preproc_constants::CONST_UINT2), "integer", "preproc_constants.CONST_UINT2 has unexpected type");
-check::equal(gettype(preproc_constants::CONST_UINT3), "integer", "preproc_constants.CONST_UINT3 has unexpected type");
-check::equal(gettype(preproc_constants::CONST_UINT4), "integer", "preproc_constants.CONST_UINT4 has unexpected type");
-check::equal(gettype(preproc_constants::CONST_LONG1), "integer", "preproc_constants.CONST_LONG1 has unexpected type");
-check::equal(gettype(preproc_constants::CONST_LONG2), "integer", "preproc_constants.CONST_LONG2 has unexpected type");
-check::equal(gettype(preproc_constants::CONST_LONG3), "integer", "preproc_constants.CONST_LONG3 has unexpected type");
-check::equal(gettype(preproc_constants::CONST_LONG4), "integer", "preproc_constants.CONST_LONG4 has unexpected type");
-# On some platforms these don't fit in a PHP integer and so get wrapped as a string constant.
-#check::equal(gettype(preproc_constants::CONST_LLONG1), "integer", "preproc_constants.CONST_LLONG1 has unexpected type");
-#check::equal(gettype(preproc_constants::CONST_LLONG2), "integer", "preproc_constants.CONST_LLONG2 has unexpected type");
-#check::equal(gettype(preproc_constants::CONST_LLONG3), "integer", "preproc_constants.CONST_LLONG3 has unexpected type");
-#check::equal(gettype(preproc_constants::CONST_LLONG4), "integer", "preproc_constants.CONST_LLONG4 has unexpected type");
-#check::equal(gettype(preproc_constants::CONST_ULLONG1), "integer", "preproc_constants.CONST_ULLONG1 has unexpected type");
-#check::equal(gettype(preproc_constants::CONST_ULLONG2), "integer", "preproc_constants.CONST_ULLONG2 has unexpected type");
-#check::equal(gettype(preproc_constants::CONST_ULLONG3), "integer", "preproc_constants.CONST_ULLONG3 has unexpected type");
-#check::equal(gettype(preproc_constants::CONST_ULLONG4), "integer", "preproc_constants.CONST_ULLONG4 has unexpected type");
-check::equal(gettype(preproc_constants::CONST_DOUBLE1), "double", "preproc_constants.CONST_DOUBLE1 has unexpected type");
-check::equal(gettype(preproc_constants::CONST_DOUBLE2), "double", "preproc_constants.CONST_DOUBLE2 has unexpected type");
-check::equal(gettype(preproc_constants::CONST_DOUBLE3), "double", "preproc_constants.CONST_DOUBLE3 has unexpected type");
-check::equal(gettype(preproc_constants::CONST_DOUBLE4), "double", "preproc_constants.CONST_DOUBLE4 has unexpected type");
-check::equal(gettype(preproc_constants::CONST_DOUBLE5), "double", "preproc_constants.CONST_DOUBLE5 has unexpected type");
-check::equal(gettype(preproc_constants::CONST_DOUBLE6), "double", "preproc_constants.CONST_DOUBLE6 has unexpected type");
-
-// SWIG wraps bool constants as integers for PHP5:
-check::equal(gettype(preproc_constants::CONST_BOOL1), "integer", "preproc_constants.CONST_BOOL1 has unexpected type");
-check::equal(gettype(preproc_constants::CONST_BOOL2), "integer", "preproc_constants.CONST_BOOL2 has unexpected type");
-
-check::equal(gettype(preproc_constants::CONST_CHAR), "string", "preproc_constants.CONST_CHAR has unexpected type");
-check::equal(gettype(preproc_constants::CONST_STRING1), "string", "preproc_constants.CONST_STRING1 has unexpected type");
-check::equal(gettype(preproc_constants::CONST_STRING2), "string", "preproc_constants.CONST_STRING2 has unexpected type");
-
-check::equal(gettype(preproc_constants::INT_AND_BOOL), "integer", "preproc_constants.INT_AND_BOOL has unexpected type");
-check::equal(gettype(preproc_constants::INT_AND_CHAR), "integer", "preproc_constants.INT_AND_CHAR has unexpected type");
-check::equal(gettype(preproc_constants::INT_AND_INT), "integer", "preproc_constants.INT_AND_INT has unexpected type");
-check::equal(gettype(preproc_constants::INT_AND_UINT), "integer", "preproc_constants.INT_AND_UINT has unexpected type");
-check::equal(gettype(preproc_constants::INT_AND_LONG), "integer", "preproc_constants.INT_AND_LONG has unexpected type");
-check::equal(gettype(preproc_constants::INT_AND_ULONG), "integer", "preproc_constants.INT_AND_ULONG has unexpected type");
-# On some platforms these don't fit in a PHP integer and so get wrapped as a string constant.
-#check::equal(gettype(preproc_constants::INT_AND_LLONG), "integer", "preproc_constants.INT_AND_LLONG has unexpected type");
-#check::equal(gettype(preproc_constants::INT_AND_ULLONG), "integer", "preproc_constants.INT_AND_ULLONG has unexpected type");
-check::equal(gettype(preproc_constants::BOOL_AND_BOOL), "integer", "preproc_constants.BOOL_AND_BOOL has unexpected type");
-
-check::equal(gettype(preproc_constants::EXPR_MULTIPLY), "integer", "preproc_constants.EXPR_MULTIPLY has unexpected type");
-check::equal(gettype(preproc_constants::EXPR_DIVIDE), "integer", "preproc_constants.EXPR_DIVIDE has unexpected type");
-check::equal(gettype(preproc_constants::EXPR_PLUS), "integer", "preproc_constants.EXPR_PLUS has unexpected type");
-check::equal(gettype(preproc_constants::EXPR_MINUS), "integer", "preproc_constants.EXPR_MINUS has unexpected type");
-check::equal(gettype(preproc_constants::EXPR_LSHIFT), "integer", "preproc_constants.EXPR_LSHIFT has unexpected type");
-check::equal(gettype(preproc_constants::EXPR_RSHIFT), "integer", "preproc_constants.EXPR_RSHIFT has unexpected type");
-
-// SWIG wraps bool constants as integers for PHP5:
-check::equal(gettype(preproc_constants::EXPR_LTE), "integer", "preproc_constants.EXPR_LTE has unexpected type");
-check::equal(gettype(preproc_constants::EXPR_GTE), "integer", "preproc_constants.EXPR_GTE has unexpected type");
-check::equal(gettype(preproc_constants::EXPR_INEQUALITY), "integer", "preproc_constants.EXPR_INEQUALITY has unexpected type");
-check::equal(gettype(preproc_constants::EXPR_EQUALITY), "integer", "preproc_constants.EXPR_EQUALITY has unexpected type");
-
-check::equal(gettype(preproc_constants::EXPR_AND), "integer", "preproc_constants.EXPR_AND has unexpected type");
-check::equal(gettype(preproc_constants::EXPR_XOR), "integer", "preproc_constants.EXPR_XOR has unexpected type");
-check::equal(gettype(preproc_constants::EXPR_OR), "integer", "preproc_constants.EXPR_OR has unexpected type");
-
-// SWIG wraps bool constants as integers for PHP5:
-check::equal(gettype(preproc_constants::EXPR_LAND), "integer", "preproc_constants.EXPR_LAND has unexpected type");
-check::equal(gettype(preproc_constants::EXPR_LOR), "integer", "preproc_constants.EXPR_LOR has unexpected type");
-
-check::equal(gettype(preproc_constants::EXPR_CONDITIONAL), "double", "preproc_constants.EXPR_CONDITIONAL has unexpected type");
-
-?>
diff --git a/Examples/test-suite/php5/primitive_ref_runme.php b/Examples/test-suite/php5/primitive_ref_runme.php
deleted file mode 100644
index 263a28074..000000000
--- a/Examples/test-suite/php5/primitive_ref_runme.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-
-require "tests.php";
-require "primitive_ref.php";
-
-# A large long long number is too big, so PHP makes treats it as a double, but SWIG opts to return it as a string.
-# The conversion to double can lose precision so this isn't an exact comparison.
-function long_long_equal($a,$b,$message) {
- if (! ($a===$b))
- if (! ((double)$a===$b))
- return check::fail($message . ": '$a'!=='$b'");
- return TRUE;
-}
-
-
-check::equal(ref_over(3), 3, "ref_over failed");
-
-check::equal(ref_int(3), 3, "ref_int failed");
-check::equal(ref_uint(3), 3, "ref_uint failed");
-check::equal(ref_short(3), 3, "ref_short failed");
-check::equal(ref_ushort(3), 3, "ref_ushort failed");
-check::equal(ref_long(3), 3, "ref_long failed");
-check::equal(ref_ulong(3), 3, "ref_ulong failed");
-check::equal(ref_schar(3), 3, "ref_schar failed");
-check::equal(ref_uchar(3), 3, "ref_uchar failed");
-check::equal(ref_bool(true), true, "ref_bool failed");
-check::equal(ref_float(3.5), 3.5, "ref_float failed");
-check::equal(ref_double(3.5), 3.5, "ref_double failed");
-check::equal(ref_char('x'), 'x', "ref_char failed");
-long_long_equal(ref_longlong(0x123456789ABCDEF0), 0x123456789ABCDEF0, "ref_longlong failed");
-long_long_equal(ref_ulonglong(0xF23456789ABCDEF0), 0xF23456789ABCDEF0, "ref_ulonglong failed");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/rename_scope_runme.php b/Examples/test-suite/php5/rename_scope_runme.php
deleted file mode 100644
index df620d796..000000000
--- a/Examples/test-suite/php5/rename_scope_runme.php
+++ /dev/null
@@ -1,16 +0,0 @@
-<?php
-
-require "tests.php";
-require "rename_scope.php";
-
-check::classes(array("rename_scope","Interface_UP","Interface_BP","Natural_UP","Natural_BP","Bucket"));
-
-check::classmethods("Interface_UP",array("__construct","__set","__isset","__get"));
-check::classmethods("Interface_BP",array("__construct","__set","__isset","__get"));
-check::classmethods("Natural_UP",array("__construct","__set","__isset","__get","rtest"));
-check::classmethods("Natural_BP",array("__construct","__set","__isset","__get","rtest"));
-check::classparent("Natural_UP","Interface_UP");
-check::classparent("Natural_BP","Interface_BP");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/skel.php b/Examples/test-suite/php5/skel.php
deleted file mode 100644
index 780a999ed..000000000
--- a/Examples/test-suite/php5/skel.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-// Sample test file
-
-require "tests.php";
-require "____.php";
-
-// No new functions
-check::functions(array());
-// No new classes
-check::classes(array());
-// now new vars
-check::globals(array());
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/smart_pointer_rename_runme.php b/Examples/test-suite/php5/smart_pointer_rename_runme.php
deleted file mode 100644
index 26692dde5..000000000
--- a/Examples/test-suite/php5/smart_pointer_rename_runme.php
+++ /dev/null
@@ -1,27 +0,0 @@
-<?php
-
-require "tests.php";
-require "smart_pointer_rename.php";
-
-check::classes(array("Foo","Bar"));
-check::classmethods("foo",array("ftest1","ftest2","__set","__isset","__get","__construct"));
-check::classmethods("bar",array("__deref__","test","ftest1","ftest2","__set","__isset","__get","__construct"));
-$foo=new foo();
-check::classname("foo",$foo);
-$bar=new bar($foo);
-check::classname("bar",$bar);
-
-# check foo's ftest1, ftest2
-check::equal(1,$foo->ftest1(1),"foo->ftest1");
-check::equal(2,$foo->ftest2(1,2),"foo->ftest2");
-
-# check bar's ftest1, ftest2, ftest
-check::equal(1,$bar->ftest1(1),"bar->ftest1");
-check::equal(2,$bar->ftest2(1,2),"bar->ftest2");
-check::equal(3,$bar->test(),"bar->test");
-
-# check deref returns foo
-check::classname("foo",$bar->__deref__());
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/swig_exception_runme.php b/Examples/test-suite/php5/swig_exception_runme.php
deleted file mode 100644
index 76641996e..000000000
--- a/Examples/test-suite/php5/swig_exception_runme.php
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-
-require("swig_exception.php");
-require("tests.php");
-
-$c = new Circle(10);
-$s = new Square(10);
-
-if (Shape::nshapes() != 2) {
- check::fail("Shape::nshapes() should be 2, actually ".Shape::nshapes());
-}
-
-# ----- Throw exception -----
-try {
- $c->throwException();
- check::fail("Exception wasn't thrown");
-} catch (Exception $e) {
- if ($e->getMessage() != "OK") {
- check::fail("Exception getMessage() should be \"OK\", actually \"".$e->getMessage()."\"");
- }
-}
-
-# ----- Delete everything -----
-
-$c = NULL;
-$s = NULL;
-$e = NULL;
-
-if (Shape::nshapes() != 0) {
- check::fail("Shape::nshapes() should be 0, actually ".Shape::nshapes());
-}
-
-?>
diff --git a/Examples/test-suite/php5/sym_runme.php b/Examples/test-suite/php5/sym_runme.php
deleted file mode 100644
index 483aaa980..000000000
--- a/Examples/test-suite/php5/sym_runme.php
+++ /dev/null
@@ -1,22 +0,0 @@
-<?php
-
-require "tests.php";
-require "sym.php";
-
-// No new functions
-check::functions(array());
-// No new classes
-check::classes(array(flim,flam));
-// now new vars
-check::globals(array());
-
-$flim=new flim();
-$flam=new flam();
-
-check::equal($flim->hulahoops(),"flim-jam","flim()->hulahoops==flim-jam");
-check::equal($flim->jar(),"flim-jar","flim()->jar==flim-jar");
-check::equal($flam->jam(),"flam-jam","flam()->jam==flam-jam");
-check::equal($flam->jar(),"flam-jar","flam()->jar==flam-jar");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/template_arg_typename_runme.php b/Examples/test-suite/php5/template_arg_typename_runme.php
deleted file mode 100644
index 7d60285e3..000000000
--- a/Examples/test-suite/php5/template_arg_typename_runme.php
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php
-
-require "tests.php";
-require "template_arg_typename.php";
-
-// No new functions
-check::functions(array());
-// No new classes
-check::classes(array(UnaryFunction_bool_bool,BoolUnaryFunction_bool));
-$ufbb=new unaryfunction_bool_bool();
-check::is_a($ufbb,"unaryfunction_bool_bool");
-
-unset($whatisthis);
-$bufb=new boolunaryfunction_bool($whatisthis);
-check::is_a($bufb,"boolunaryfunction_bool");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/template_construct_runme.php b/Examples/test-suite/php5/template_construct_runme.php
deleted file mode 100644
index 3a3986f7e..000000000
--- a/Examples/test-suite/php5/template_construct_runme.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-
-require "tests.php";
-require "template_construct.php";
-
-check::classes(array(Foo_int));
-$foo_int=new foo_int(3);
-check::is_a($foo_int,"foo_int","Made a foo_int");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/tests.php b/Examples/test-suite/php5/tests.php
deleted file mode 100644
index d3fd66868..000000000
--- a/Examples/test-suite/php5/tests.php
+++ /dev/null
@@ -1,237 +0,0 @@
-<?php
-
-// do we have true global vars or just GETSET functions?
-// Used to filter out get/set global functions to fake vars...
-define(GETSET,1);
-
-$_original_functions=get_defined_functions();
-$_original_globals=1;
-$_original_classes=get_declared_classes();
-$_original_globals=array_keys($GLOBALS);
-
-class check {
- function get_extra_classes($ref=FALSE) {
- static $extra;
- global $_original_classes;
- if ($ref===FALSE) $f=$_original_classes;
- if (! is_array($extra)) {
- $df=array_flip(get_declared_classes());
- foreach($_original_classes as $class) unset($df[$class]);
- $extra=array_keys($df);
- }
- return $extra;
- }
-
- function get_extra_functions($ref=FALSE,$gs=false) {
- static $extra;
- static $extrags; // for get/setters
- global $_original_functions;
- if ($ref===FALSE) $f=$_original_functions;
- if (! is_array($extra) || $gs) {
- $extra=array();
- $extrags=array();
- $df=get_defined_functions();
- $df=array_flip($df[internal]);
- foreach($_original_functions[internal] as $func) unset($df[$func]);
- // Now chop out any get/set accessors
- foreach(array_keys($df) as $func)
- if ((GETSET && preg_match('/_[gs]et$/', $func)) ||
- preg_match('/^new_/', $func) ||
- preg_match('/_(alter|get)_newobject$/', $func))
- $extrags[]=$func;
- else $extra[]=$func;
-// $extra=array_keys($df);
- }
- if ($gs) return $extrags;
- return $extra;
- }
-
- function get_extra_globals($ref=FALSE) {
- static $extra;
- global $_original_globals;
- if (! is_array($extra)) {
- if (GETSET) {
- $_extra=array();
- foreach(check::get_extra_functions(false,1) as $global) {
- if (preg_match('/^(.*)_[sg]et$/', $global, $match))
- $_extra[$match[1]] = 1;
- }
- $extra=array_keys($_extra);
- } else {
- if ($ref===FALSE) $ref=$_original_globals;
- if (! is_array($extra)) {
- $df=array_flip(array_keys($GLOBALS));
- foreach($_original_globals as $func) unset($df[$func]);
- // MASK xxxx_LOADED__ variables
- foreach(array_keys($df) as $func)
- if (preg_match('/_LOADED__$/', $func)) unset($df[$func]);
- $extra=array_keys($df);
- }
- }
- }
- return $extra;
- }
-
- function classname($string,$object) {
- if (!is_object($object))
- return check::fail("The second argument is a " . gettype($object) . ", not an object.");
- if (strtolower($string)!=strtolower($classname=get_class($object))) return check::fail("Object: \$object is of class %s not class %s",$classname,$string);
- return TRUE;
- }
-
- function classmethods($classname,$methods) {
- if (is_object($classname)) $classname=get_class($classname);
- $classmethods=array_flip(get_class_methods($classname));
- $missing=array();
- $extra=array();
- foreach($methods as $method) {
- if (! isset($classmethods[$method])) $missing[]=$method;
- else unset($classmethods[$method]);
- }
- $extra=array_keys($classmethods);
- if ($missing) $message[]="does not have these methods:\n ".join(",",$missing);
- if ($message) {
- return check::fail("Class %s %s\nFull class list:\n %s\n",$classname,join("\nbut ",$message),join("\n ",get_class_methods($classname)));
- }
- if ($extra) $message[]="Class ".$classname." has these extra methods:\n ".join(",",$extra);
- if ($message) return check::warn(join("\n ",$message));
- return TRUE;
- }
-
- function set($var,$value) {
- $func=$var."_set";
- if (GETSET) $func($value);
- else $_GLOBALS[$var]=$value;
- }
-
- function &get($var) {
- $func=$var."_get";
- if (GETSET) return $func();
- else return $_GLOBALS[$var];
- }
-
- function is_a($a,$b) {
- if (is_object($a)) $a=strtolower(get_class($a));
- if (is_object($b)) $a=strtolower(get_class($b));
- $parents=array();
- $c=$a;
- while($c!=$b && $c) {
- $parents[]=$c;
- $c=strtolower(get_parent_class($c));
- }
- if ($c!=$b) return check::fail("Class $a does not inherit from class $b\nHierachy:\n %s\n",join("\n ",$parents));
- return TRUE;
- }
-
- function classparent($a,$b) {
- if (is_object($a)) $a=get_class($a);
- if (is_object($b)) $a=get_class($b);
- $parent=get_parent_class($a);
-
- if ($parent!=$b) return check::fail("Class $a parent not actually $b but $parent");
- return TRUE;
- }
-
- function classes($classes) {
- if (! is_array($classes)) $classes=array($classes);
- $message=array();
- $missing=array();
- $extra=array_flip(check::get_extra_classes());
- foreach($classes as $class) {
- if (! class_exists($class)) $missing[]=$class;
- else unset($extra[$class]);
- }
- if ($missing) $message[]=sprintf("Classes missing: %s",join(",",$missing));
- if ($message) return check::fail(join("\n ",$message));
- if ($extra) $message[]=sprintf("These extra classes are defined: %s",join(",",array_keys($extra)));
- if ($message) return check::warn(join("\n ",$message));
- return TRUE;
- }
-
- function functions($functions) {
- if (! is_array($functions)) $functions=array($functions);
- $message=array();
- $missing=array();
- $extra=array_flip(check::get_extra_functions());
-
- foreach ($functions as $func) {
- if (! function_exists($func)) $missing[]=$func;
- else unset($extra[$func]);
- }
- if ($missing) $message[]=sprintf("Functions missing: %s",join(",",$missing));
- if ($message) return check::fail(join("\n ",$message));
- if ($extra) $message[]=sprintf("These extra functions are defined: %s",join(",",array_keys($extra)));
- if ($message) return check::warn(join("\n ",$message));
- return TRUE;
- }
-
- function globals($globals) {
- if (! is_array($globals)) $globals=array($globals);
- $message=array();
- $missing=array();
- $extra=array_flip(check::get_extra_globals());
- foreach ($globals as $glob) {
- if (GETSET) {
- if (! isset($extra[$glob])) $missing[]=$glob;
- else unset($extra[$glob]);
- } else {
- if (! isset($GLOBALS[$glob])) $missing[]=$glob;
- else unset($extra[$glob]);
- }
- }
- if ($missing) $message[]=sprintf("Globals missing: %s",join(",",$missing));
- if ($message) return check::fail(join("\n ",$message));
- if ($extra) $message[]=sprintf("These extra globals are defined: %s",join(",",array_keys($extra)));
- if ($message) return check::warn(join("\n ",$message));
- return TRUE;
-
- }
-
- function functionref($a,$type,$message) {
- if (! preg_match("/^_[a-f0-9]+$type$/i", $a))
- return check::fail($message);
- return TRUE;
- }
-
- function equal($a,$b,$message) {
- if (! ($a===$b)) return check::fail($message . ": '$a'!=='$b'");
- return TRUE;
- }
-
- function resource($a,$b,$message) {
- $resource=trim(check::var_dump($a));
- if (! preg_match("/^resource\([0-9]+\) of type \($b\)/i", $resource))
- return check::fail($message);
- return TRUE;
- }
-
- function isnull($a,$message) {
- $value=trim(check::var_dump($a));
- return check::equal($value,"NULL",$message);
- }
-
- function var_dump($arg) {
- ob_start();
- var_dump($arg);
- $result=ob_get_contents();
- ob_end_clean();
- return $result;
- }
-
- function fail($pattern) {
- $args=func_get_args();
- print("Failed on: ".call_user_func_array("sprintf",$args)."\n");
- exit(1);
- }
-
- function warn($pattern) {
- $args=func_get_args();
- print("Warning on: ".call_user_func_array("sprintf",$args)."\n");
- return FALSE;
- }
-
- function done() {
-# print $_SERVER[argv][0]." ok\n";
- }
-}
-?>
diff --git a/Examples/test-suite/php5/threads_exception_runme.php b/Examples/test-suite/php5/threads_exception_runme.php
deleted file mode 100644
index 9e4d04e10..000000000
--- a/Examples/test-suite/php5/threads_exception_runme.php
+++ /dev/null
@@ -1,43 +0,0 @@
-<?php
-
-require "tests.php";
-require "threads_exception.php";
-
-// Check functions
-check::functions(array(test_simple,test_message,test_hosed,test_unknown,test_multi,is_python_builtin));
-// Check classes.
-check::classes(array(Exc,Test,threads_exception));
-// Chek globals.
-check::globals(array(exc_code,exc_msg));
-
-$t = new Test();
-try {
- $t->unknown();
-} catch (Exception $e) {
- check::equal($e->getMessage(), 'C++ A * exception thrown', '');
-}
-
-try {
- $t->simple();
-} catch (Exception $e) {
- check::equal($e->getCode(), 37, '');
-}
-
-try {
- $t->message();
-} catch (Exception $e) {
- check::equal($e->getMessage(), 'I died.', '');
-}
-
-try {
- $t->hosed();
-} catch (Exception $e) {
- check::equal($e->getMessage(), 'C++ Exc exception thrown', '');
-}
-
-foreach (Array(1,2,3,4) as $i) {
- try {
- $t->multi($i);
- } catch (Exception $e) {
- }
-}
diff --git a/Examples/test-suite/php5/typedef_reference_runme.php b/Examples/test-suite/php5/typedef_reference_runme.php
deleted file mode 100644
index 88a70f8d3..000000000
--- a/Examples/test-suite/php5/typedef_reference_runme.php
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php
-
-require "tests.php";
-require "typedef_reference.php";
-
-check::functions(array(somefunc,otherfunc,new_intp,copy_intp,delete_intp,intp_assign,intp_value));
-$int2=copy_intp(2);
-check::equal(2,somefunc($int2)," test passing intp to somefunc");
-$int3=copy_intp(3);
-check::equal(3,otherfunc($int3)," test passing intp to otherfunc");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/typemap_ns_using_runme.php b/Examples/test-suite/php5/typemap_ns_using_runme.php
deleted file mode 100644
index 6a599f008..000000000
--- a/Examples/test-suite/php5/typemap_ns_using_runme.php
+++ /dev/null
@@ -1,9 +0,0 @@
-<?php
-
-require "tests.php";
-require "typemap_ns_using.php";
-if (! class_exists("_fooimpl")) die("_fooimpl class not found\n");
-if (! 3==spam(3)) die("spam function not working right\n");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/using1_runme.php b/Examples/test-suite/php5/using1_runme.php
deleted file mode 100644
index 51841bc78..000000000
--- a/Examples/test-suite/php5/using1_runme.php
+++ /dev/null
@@ -1,9 +0,0 @@
-<?php
-
-require "tests.php";
-require "using1.php";
-if (! class_exists("_fooimpl")) die("_fooimpl class not found\n");
-if (! 3==spam(3)) die("spam function not working right\n");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/using2_runme.php b/Examples/test-suite/php5/using2_runme.php
deleted file mode 100644
index 391a98f52..000000000
--- a/Examples/test-suite/php5/using2_runme.php
+++ /dev/null
@@ -1,9 +0,0 @@
-<?php
-
-require "tests.php";
-require "using2.php";
-if (! class_exists("_fooimpl")) die("_fooimpl class not found\n");
-if (! 3==spam(3)) die("spam function not working right\n");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/valuewrapper_base_runme.php b/Examples/test-suite/php5/valuewrapper_base_runme.php
deleted file mode 100644
index 6a1abdbd2..000000000
--- a/Examples/test-suite/php5/valuewrapper_base_runme.php
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php
-
-require "tests.php";
-require "valuewrapper_base.php";
-
-check::classes(array("valuewrapper_base","Base","Interface_BP"));
-check::functions("make_interface_bp");
-
-$ibp=valuewrapper_base::make_interface_bp();
-check::classname("interface_bp",$ibp);
-
-check::done();
-?>
diff --git a/Examples/test-suite/php5/virtual_vs_nonvirtual_base_runme.php b/Examples/test-suite/php5/virtual_vs_nonvirtual_base_runme.php
deleted file mode 100644
index 0d4aa3d5f..000000000
--- a/Examples/test-suite/php5/virtual_vs_nonvirtual_base_runme.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?
-
-require "tests.php";
-require "virtual_vs_nonvirtual_base.php";
-
-$fail = new SimpleClassFail();
-$work = new SimpleClassWork();
-
-check::equal($work->getInner()->get(), $fail->getInner()->get(), "should both be 10");
-
-?>
diff --git a/Examples/test-suite/php5/wrapmacro_runme.php b/Examples/test-suite/php5/wrapmacro_runme.php
deleted file mode 100644
index f32da990e..000000000
--- a/Examples/test-suite/php5/wrapmacro_runme.php
+++ /dev/null
@@ -1,12 +0,0 @@
-<?php
-
-require "tests.php";
-require "wrapmacro.php";
-
-check::functions(array('guint16_swap_le_be_constant', 'maximum'));
-
-check::equal(maximum(2.3, 2.4), 2.4, "maximum() doesn't work");
-check::equal(guint16_swap_le_be_constant(0x1234), 0x3412, "GUINT16_SWAP_LE_BE_CONSTANT() doesn't work");
-
-check::done();
-?>
diff --git a/Examples/test-suite/php_pragma.i b/Examples/test-suite/php_pragma.i
new file mode 100644
index 000000000..4d14f1357
--- /dev/null
+++ b/Examples/test-suite/php_pragma.i
@@ -0,0 +1,6 @@
+// Test pragma of php - pragma version.
+
+%module php_pragma
+
+%pragma(php) version= "1.5"
+
diff --git a/Examples/test-suite/preproc.i b/Examples/test-suite/preproc.i
index f236bfdff..215fdd0ef 100644
--- a/Examples/test-suite/preproc.i
+++ b/Examples/test-suite/preproc.i
@@ -16,8 +16,16 @@
//Suppress: warning: use of logical '&&' with constant operand [-Wconstant-logical-operand]
#pragma clang diagnostic ignored "-Wconstant-logical-operand"
#endif
+#if defined(_MSC_VER)
+ #pragma warning(disable: 4003) // not enough actual parameters for macro 'FOO2'
+#endif
%}
+#ifdef SWIGOCAML
+%warnfilter(SWIGWARN_PARSE_KEYWORD) method;
+%warnfilter(SWIGWARN_PARSE_KEYWORD) val;
+#endif
+
/* check __cplusplus case */
%header
%{
@@ -370,3 +378,75 @@ int methodX(int x);
int methodX(int x) { return x+100; }
%}
+// Comma in macro - https://github.com/swig/swig/issues/974 (for /* */)
+// and https://github.com/swig/swig/pull/1166 (for //)
+%inline %{
+#define swig__attribute__(x)
+#define TCX_PACKED(d) d swig__attribute__ ((__packed__))
+
+
+TCX_PACKED (typedef struct tcxMessageTestImpl
+{
+ int mHeader; /**< comment */
+}) tcxMessageTest;
+
+
+TCX_PACKED (typedef struct tcxMessageBugImpl
+{
+ int mBid; /**< Bid price and size, check PresentMap if available in message */
+}) tcxMessageBug;
+
+
+TCX_PACKED (typedef struct tcxMessageTestImpl2
+{
+ int mHeader; ///< comment
+}) tcxMessageTest2;
+
+
+TCX_PACKED (typedef struct tcxMessageBugImpl2
+{
+ int mBid; ///< Bid price and size, check PresentMap if available in message
+}) tcxMessageBug2;
+
+
+%}
+
+// Regression tests for https://github.com/swig/swig/pull/1111
+%{
+static int foo_func(int x) { return x; }
+static int foo_func2() { return 0; }
+static int bar_func() { return 0; }
+static int baz_func(int a, int b, int c) { return a + b - c; }
+%}
+%inline %{
+#define FOO(X) int foo_func(X);
+#define FOO2(X) int foo_func2(X);
+#define BAR() int bar_func();
+#define BAR2() int bar_func2()
+#define BAZ(A,B,C) baz_func(A+0,B,C)
+#define FOOVAR(...) foo_func(__VA_ARGS__)
+#define BARVAR(...) bar_func(__VA_ARGS__)
+#define BAZVAR(...) baz_func(__VA_ARGS__)
+// This has probably always worked, but make sure that the fix to accept
+// an empty X doesn't cause this case to be incorrectly expanded:
+const int FOO = 7;
+// BAR was incorrectly expanded here, causing:
+// Error: Syntax error in input(1).
+const int BAR = 6;
+// This has probably always worked, but make sure that the fix to accept
+// an empty X doesn't stop a non-empty X from working:
+FOO(int x)
+// FOO() didn't used to get expanded here, causing:
+// Syntax error in input(1).
+FOO2()
+// Check BAR2() still gets expanded here.
+BAR2() {
+ // Regression test - this used to fail with:
+ // Error: Macro 'BAZ' expects 3 arguments
+ BAZ(,2,3);
+ BARVAR();
+ FOOVAR(1);
+ BAZVAR(1,2,3);
+ return 0;
+}
+%}
diff --git a/Examples/test-suite/preproc_constants.i b/Examples/test-suite/preproc_constants.i
index 3a999ada3..3050baa06 100644
--- a/Examples/test-suite/preproc_constants.i
+++ b/Examples/test-suite/preproc_constants.i
@@ -86,11 +86,20 @@
#define EXPR_LAND 0xFF && 1
#define EXPR_LOR 0xFF || 1
#define EXPR_CONDITIONAL true ? 2 : 2.2
+#define EXPR_MIXED1 (0x80 + 11.1) - 1
+
+#define EXPR_WCHAR_MAX (0x7fffffff + L'\0')
+#define EXPR_WCHAR_MIN (-EXPR_WCHAR_MAX - 1)
#define EXPR_CHAR_COMPOUND_ADD 'A' + 12
#define EXPR_CHAR_COMPOUND_LSHIFT 'B' << 6
#define H_SUPPRESS_SCALING_MAGIC (('s'<<24) | ('u'<<16) | ('p'<<8) | 'p')
+// https://sourceforge.net/p/swig/bugs/1168/
+#define CHR(ch1,ch2,ch3,ch4) (((ch1)<<24)|((ch2)<<16)|((ch3)<<8)|(ch4))
+#define DEFAULT_LANG CHR('d','f','l','t')
+%constant DEFAULT_LANG_SIMPLIFIED = ('d')<<24;
+
/// constant assignment in enum
#if defined(SWIGCSHARP)
%csconstvalue("1<<2") kValue;
diff --git a/Examples/test-suite/preproc_gcc_output.h b/Examples/test-suite/preproc_gcc_output.h
new file mode 100644
index 000000000..cc5065d12
--- /dev/null
+++ b/Examples/test-suite/preproc_gcc_output.h
@@ -0,0 +1,13 @@
+# 1 "header1.h"
+# 1 "<built-in>"
+# 1 "<command-line>"
+# 1 "/usr/include/stdc-predef.h" 1 3 4
+# 1 "<command-line>" 2
+# 1 "header1.h"
+# 18 "header1.h"
+void header1_function_a(int a);
+# 1 "header2.h" 1
+# 13 "header2.h"
+void header2_function(int x);
+# 20 "header1.h" 2
+void header1_function_b(int b);
diff --git a/Examples/test-suite/preproc_gcc_output.i b/Examples/test-suite/preproc_gcc_output.i
new file mode 100644
index 000000000..b4db9e70a
--- /dev/null
+++ b/Examples/test-suite/preproc_gcc_output.i
@@ -0,0 +1,12 @@
+%module preproc_gcc_output
+// Testcase for Github issue #1475 using the output of gcc -E
+
+// The file below was generated using 'gcc -E header1.h'
+// where header1.h included header2.h
+%include "preproc_gcc_output.h"
+
+%{
+void header1_function_a(int a) {}
+void header2_function(int x) {}
+void header1_function_b(int b) {}
+%}
diff --git a/Examples/test-suite/primitive_types.i b/Examples/test-suite/primitive_types.i
index b9b973a2b..a71f62a4f 100644
--- a/Examples/test-suite/primitive_types.i
+++ b/Examples/test-suite/primitive_types.i
@@ -7,12 +7,6 @@
%rename(TestDir) TestDirector;
#endif
-%{
-#if defined(_MSC_VER)
- #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
-%}
-
// Ruby constant names
#pragma SWIG nowarn=SWIGWARN_RUBY_WRONG_NAME
@@ -259,14 +253,17 @@ macro(Param<char>, pfx, paramc)
macro(size_t, pfx, sizet)
%enddef
+%define catches_decl(type, pfx, name)
+ %catches(type) pfx##_##name(type x);
+%enddef
/* function passing by value */
%define val_decl(type, pfx, name)
- type pfx##_##name(type x) throw (type) { return x; }
+ type pfx##_##name(type x) { return x; }
%enddef
/* function passing by ref */
%define ref_decl(type, pfx, name)
- const type& pfx##_##name(const type& x) throw (type) { return x; }
+ const type& pfx##_##name(const type& x) { return x; }
%enddef
/* C++ constant declaration */
@@ -301,6 +298,11 @@ macro(size_t, pfx, sizet)
%test_prim_types(sct_decl, sct)
+%test_prim_types(catches_decl, val)
+%test_prim_types(catches_decl, ref)
+%test_prim_types(catches_decl, cct)
+%test_prim_types(catches_decl, var)
+
%inline {
%test_prim_types(val_decl, val)
%test_prim_types(ref_decl, ref)
@@ -452,12 +454,12 @@ macro(size_t, pfx, sizet)
var_decl(namet, var, namet)
- const char* val_namet(namet x) throw(namet)
+ const char* val_namet(namet x)
{
return x;
}
- const char* val_cnamet(const namet x) throw(namet)
+ const char* val_cnamet(const namet x)
{
return x;
}
@@ -465,7 +467,7 @@ macro(size_t, pfx, sizet)
#if 0
/* I have no idea how to define a typemap for
const namet&, where namet is a char[ANY] array */
- const namet& ref_namet(const namet& x) throw(namet)
+ const namet& ref_namet(const namet& x)
{
return x;
}
@@ -509,12 +511,12 @@ macro(size_t, pfx, sizet)
var_namet[0]='h';
}
- virtual const char* vval_namet(namet x) throw(namet)
+ virtual const char* vval_namet(namet x)
{
return x;
}
- virtual const char* vval_cnamet(const namet x) throw(namet)
+ virtual const char* vval_cnamet(const namet x)
{
return x;
}
@@ -522,7 +524,7 @@ macro(size_t, pfx, sizet)
#if 0
/* I have no idea how to define a typemap for
const namet&, where namet is a char[ANY] array */
- virtual const namet& vref_namet(const namet& x) throw(namet)
+ virtual const namet& vref_namet(const namet& x)
{
return x;
}
@@ -559,7 +561,7 @@ macro(size_t, pfx, sizet)
%test_prim_types_ovr(ovr_decl, ovr)
- virtual Test* vtest(Test* t) const throw (Test)
+ virtual Test* vtest(Test* t) const
{
return t;
}
@@ -628,6 +630,10 @@ macro(size_t, pfx, sizet)
float val_float(float x) {
return x;
}
+
+ float val_float_3(float f = 0e1f, float f2 = 020e0f, float f3 = 0.3e4f) {
+ return f + f2 + f3;
+ }
%}
diff --git a/Examples/test-suite/proxycode.i b/Examples/test-suite/proxycode.i
new file mode 100644
index 000000000..02dab9ade
--- /dev/null
+++ b/Examples/test-suite/proxycode.i
@@ -0,0 +1,141 @@
+%module proxycode
+
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Proxy4::Proxy4Nested;
+
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD)
+
+%{
+struct Proxy1 {};
+%}
+struct Proxy1 {
+%proxycode %{
+ public int proxycode1(int i) {
+ return i+1;
+ }
+%}
+};
+
+%proxycode %{
+ this should be ignored as it is not in scope of a class
+%}
+
+%extend Proxy2 {
+%proxycode %{
+ public int proxycode2a(int i) {
+ return i+2;
+ }
+%}
+}
+
+%extend Proxy2 {
+%proxycode %{
+ public int proxycode2b(int i) {
+ return i+2;
+ }
+%}
+}
+
+%inline %{
+struct Proxy2 {};
+struct Proxy3 {};
+struct Proxy4 {
+ struct Proxy4Nested {};
+};
+%}
+
+%extend Proxy3 {
+%proxycode %{
+ public int proxycode3(int i) {
+ return i+3;
+ }
+%}
+}
+
+%extend Proxy4 {
+%proxycode %{
+ public int proxycode4(int i) {
+ return i+4;
+ }
+%}
+}
+%extend Proxy4::Proxy4Nested {
+%proxycode %{
+ public int proxycode4nested(int i) {
+ return i+44;
+ }
+%}
+}
+
+%extend TemplateProxy {
+%proxycode %{
+ public T proxycode5(T i) {
+ return i;
+ }
+%}
+}
+
+%extend TemplateProxy<int> {
+%proxycode %{
+ public int proxycode5(int i, int j) {
+ return i+j+55;
+ }
+%}
+}
+
+%inline %{
+template <typename T> struct TemplateProxy {};
+%}
+
+%template(Proxy5a) TemplateProxy<short>;
+%template(Proxy5b) TemplateProxy<int>;
+
+%inline %{
+template <typename T> struct TypemapProxy {
+ T useT(T t1, T const& t2) {
+ return t1+t2;
+ }
+};
+%}
+
+%extend TypemapProxy {
+#if defined(SWIGJAVA)
+%proxycode %{
+ public $javaclassname proxyUseT(long t1, long t2) {
+ $typemap(jstype, unsigned int) tt1 = t1;
+ $typemap(jstype, unsigned int const&) tt2 = t2;
+ long ret = useT(tt1, tt2);
+ if (ret != t1+t2)
+ throw new RuntimeException("wrong sum");
+ return this;
+ }
+%}
+#elif defined(SWIGCSHARP)
+%proxycode %{
+ public $csclassname proxyUseT(uint t1, uint t2) {
+ $typemap(cstype, unsigned int) tt1 = t1;
+ $typemap(cstype, unsigned int const&) tt2 = t2;
+ uint ret = useT(tt1, tt2);
+ if (ret != t1+t2)
+ throw new System.Exception("wrong sum");
+ return this;
+ }
+%}
+#elif defined(SWIGD)
+%proxycode %{
+ public $dclassname proxyUseT(uint t1, uint t2) {
+ $typemap(dtype, unsigned int) tt1 = t1;
+ $typemap(dtype, unsigned int const&) tt2 = t2;
+ uint ret = useT(tt1, tt2);
+ if (ret != t1+t2)
+ throw new Exception("wrong sum");
+ return this;
+ }
+%}
+#else
+#error "missing test"
+#endif
+}
+
+%template(Proxy6) TypemapProxy<unsigned int>;
+
+#endif
diff --git a/Examples/test-suite/pure_virtual.i b/Examples/test-suite/pure_virtual.i
index 9e345e2a4..c1c7edc15 100644
--- a/Examples/test-suite/pure_virtual.i
+++ b/Examples/test-suite/pure_virtual.i
@@ -12,6 +12,10 @@
SWIGWARN_D_MULTIPLE_INHERITANCE,
SWIGWARN_PHP_MULTIPLE_INHERITANCE) E; /* C#, D, Java, PHP multiple inheritance */
+#ifdef SWIGOCAML
+%warnfilter(SWIGWARN_PARSE_KEYWORD) method;
+#endif
+
%nodefaultctor C;
%nodefaultdtor C;
%nodefaultctor E;
diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in
index 133b7056a..0bdbad51e 100644
--- a/Examples/test-suite/python/Makefile.in
+++ b/Examples/test-suite/python/Makefile.in
@@ -10,19 +10,9 @@ endif
LANGUAGE = python
PYTHON = $(PYBIN)
-PEP8 = @PEP8@
-PEP8_FLAGS = --ignore=E30,E402,E501,E731,W291,W391
-
-#*_runme.py for Python 2.x, *_runme3.py for Python 3.x
-PY2SCRIPTSUFFIX = _runme.py
-PY3SCRIPTSUFFIX = _runme3.py
-PY2TO3 = 2to3 -x import
-
-ifeq (,$(PY3))
- SCRIPTSUFFIX = $(PY2SCRIPTSUFFIX)
-else
- SCRIPTSUFFIX = $(PY3SCRIPTSUFFIX)
-endif
+SCRIPTSUFFIX = _runme.py
+PYCODESTYLE = @PYCODESTYLE@
+PYCODESTYLE_FLAGS = --ignore=E252,E30,E402,E501,E731,E741,W291,W391
srcdir = @srcdir@
top_srcdir = @top_srcdir@
@@ -45,6 +35,7 @@ CPP_TEST_CASES += \
li_factory \
li_implicit \
li_std_containers_int \
+ li_std_list \
li_std_map_member \
li_std_multimap \
li_std_pair_extra \
@@ -54,7 +45,7 @@ CPP_TEST_CASES += \
li_std_vectora \
li_std_vector_extra \
li_std_wstream \
- li_std_wstring \
+ li_std_wstring_inherit \
primitive_types \
python_abstractbase \
python_append \
@@ -64,38 +55,44 @@ CPP_TEST_CASES += \
python_docstring \
python_extranative \
python_moduleimport \
- python_nondynamic \
python_overload_simple_cast \
python_pickle \
+ python_pybuffer \
python_pythoncode \
python_richcompare \
python_strict_unicode \
+ python_threads \
simutry \
std_containers \
swigobject \
- template_matrix
+ template_matrix \
# li_std_carray
# director_profile
-# python_pybuf
+
+CPP11_TEST_CASES = \
+ cpp11_hash_tables \
+ cpp11_shared_ptr_const \
+ cpp11_shared_ptr_nullptr_in_containers \
+ cpp11_shared_ptr_overload \
+ cpp11_shared_ptr_template_upcast \
+ cpp11_shared_ptr_upcast \
+ cpp11_std_unordered_map \
+ cpp11_std_unordered_multimap \
+ cpp11_std_unordered_multiset \
+ cpp11_std_unordered_set \
C_TEST_CASES += \
+ ccomplextest \
file_test \
li_cstring \
li_cwstring \
python_nondynamic \
- python_varargs_typemap
-
-#
-# This test only works with modern C compilers
-#
-#C_TEST_CASES += \
-# complextest
+ python_varargs_typemap \
include $(srcdir)/../common.mk
# Overridden variables here
-SCRIPTDIR = .
LIBS = -L.
VALGRIND_OPT += --suppressions=pythonswig.supp
@@ -104,93 +101,52 @@ VALGRIND_OPT += --suppressions=pythonswig.supp
# Rules for the different types of tests
%.cpptest:
- +$(convert_testcase)
$(setup)
+$(swig_and_compile_cpp)
$(check_pep8)
$(run_testcase)
%.ctest:
- +$(convert_testcase)
$(setup)
+$(swig_and_compile_c)
$(check_pep8)
$(run_testcase)
%.multicpptest:
- +$(convert_testcase)
$(setup)
+$(swig_and_compile_multi_cpp)
$(check_pep8_multi_cpp)
$(run_testcase)
-
-# Runs the testcase. A testcase is only run if
-# a file is found which has _runme.py (or _runme3.py for Python 3) appended after the testcase name.
-
-py_runme = $(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)
-py2_runme = $(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX)
-py3_runme = $(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX)
-
-ifneq (,$(PEP8))
-check_pep8 = $(COMPILETOOL) $(PEP8) $(PEP8_FLAGS) $(SCRIPTPREFIX)$*.py
+# Python code style checking
+ifneq (,$(PYCODESTYLE))
+check_pep8 = $(COMPILETOOL) $(PYCODESTYLE) $(PYCODESTYLE_FLAGS) $(SCRIPTPREFIX)$*.py
check_pep8_multi_cpp = \
for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \
- $(COMPILETOOL) $(PEP8) $(PEP8_FLAGS) $$f.py; \
+ $(COMPILETOOL) $(PYCODESTYLE) $(PYCODESTYLE_FLAGS) $$f.py; \
done
endif
-run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=.:$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(py_runme)
-
+# Runs the testcase. A testcase is only run if
+# a file is found which has _runme.py appended after the testcase name.
run_testcase = \
- if [ -f $(SCRIPTDIR)/$(py_runme) ]; then \
- $(run_python);\
- fi
-
-# No copying/conversion needed for in-source-tree Python 2 scripts
-ifeq ($(SCRIPTDIR)|$(SCRIPTSUFFIX),$(srcdir)|$(PY2SCRIPTSUFFIX))
-convert_testcase =
-else
-
-convert_testcase = \
- if [ -f $(srcdir)/$(py2_runme) ]; then \
- $(MAKE) $(SCRIPTDIR)/$(py_runme); \
+ if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=.:$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
fi
-$(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX): $(srcdir)/$(SCRIPTPREFIX)%$(PY2SCRIPTSUFFIX)
- test x$< = x$@ || cp $< $@ || exit 1
- test x$(PY3) = x || $(PY2TO3) -w $@ >/dev/null 2>&1 || exit 1
-
-endif
-
# Clean: remove the generated .py file
-# We only remove the _runme3.py if it is generated by 2to3 from a _runme.py.
%.clean:
@rm -f $*.py
- @if test -f $(srcdir)/$(py2_runme); then rm -f $(SCRIPTDIR)/$(py3_runme) $(SCRIPTDIR)/$(py3_runme).bak; fi
- @if test "x$(SCRIPTDIR)" != "x$(srcdir)"; then rm -f $(SCRIPTDIR)/$(py2_runme); fi
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' python_clean
- rm -f hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py
rm -f clientdata_prop_a.py clientdata_prop_b.py import_stl_a.py import_stl_b.py
+ rm -f hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py
rm -f imports_a.py imports_b.py mod_a.py mod_b.py multi_import_a.py
rm -f multi_import_b.py packageoption_a.py packageoption_b.py packageoption_c.py
-
-cvsignore:
- @echo '*wrap* *.pyc *.so *.dll *.exp *.lib'
- @echo Makefile
- @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do echo $$i.py; done
- @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do if grep -q $${i}_runme.py CVS/Entries ; then echo $${i}_runme.py; fi; done
- @echo clientdata_prop_a.py
- @echo clientdata_prop_b.py
- @echo imports_a.py
- @echo imports_b.py
- @echo mod_a.py mod_b.py
- @echo hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py
- @echo template_typedef_import.py
+ rm -f template_typedef_cplx2.py
hugemod_runme = hugemod$(SCRIPTPREFIX)
diff --git a/Examples/test-suite/python/argcargvtest_runme.py b/Examples/test-suite/python/argcargvtest_runme.py
index 38843b932..eb57f79ea 100644
--- a/Examples/test-suite/python/argcargvtest_runme.py
+++ b/Examples/test-suite/python/argcargvtest_runme.py
@@ -1,21 +1,20 @@
from argcargvtest import *
-largs = ['hi', 'hola', 'hello']
+largs = ["hi", "hola", "hello"]
if mainc(largs) != 3:
raise RuntimeError("bad main typemap")
-targs = ('hi', 'hola')
-if mainv(targs, 1) != 'hola':
- print(mainv(targs, 1))
+targs = ("hi", "hola")
+if mainv(targs, 1) != "hola":
raise RuntimeError("bad main typemap")
-targs = ('hi', 'hola')
-if mainv(targs, 1) != 'hola':
+targs = ("hi", "hola")
+if mainv(targs, 1) != "hola":
raise RuntimeError("bad main typemap")
try:
error = 0
- mainv('hello', 1)
+ mainv("hello", 1)
error = 1
except TypeError:
pass
diff --git a/Examples/test-suite/python/array_member_runme.py b/Examples/test-suite/python/array_member_runme.py
index de6e0f3e7..2708a6f37 100644
--- a/Examples/test-suite/python/array_member_runme.py
+++ b/Examples/test-suite/python/array_member_runme.py
@@ -5,7 +5,7 @@ f.data = cvar.global_data
for i in range(0, 8):
if get_value(f.data, i) != get_value(cvar.global_data, i):
- raise RuntimeError, "Bad array assignment"
+ raise RuntimeError("Bad array assignment")
for i in range(0, 8):
@@ -15,4 +15,4 @@ cvar.global_data = f.data
for i in range(0, 8):
if get_value(f.data, i) != get_value(cvar.global_data, i):
- raise RuntimeError, "Bad array assignment"
+ raise RuntimeError("Bad array assignment")
diff --git a/Examples/test-suite/python/autodoc_runme.py b/Examples/test-suite/python/autodoc_runme.py
index af04c8c0e..7bc918644 100644
--- a/Examples/test-suite/python/autodoc_runme.py
+++ b/Examples/test-suite/python/autodoc_runme.py
@@ -1,367 +1,283 @@
from autodoc import *
+import _autodoc
+import comment_verifier
+import inspect
import sys
-
def check(got, expected, expected_builtin=None, skip=False):
- if not skip:
+ if is_python_builtin() and skip:
+ # Only skip for builtins
+ pass
+ else:
expect = expected
if is_python_builtin() and expected_builtin != None:
expect = expected_builtin
- if expect != got:
- raise RuntimeError(
- "\n" + "Expected: [" + str(expect) + "]\n" + "Got : [" + str(got) + "]")
-
-
-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)
+ comment_verifier.check(got, expect)
# skip builtin check - the autodoc is missing, but it probably should not be
skip = True
-check(A.__doc__, "Proxy of C++ A class.", "::A")
-check(A.funk.__doc__, "just a string.")
-check(A.func0.__doc__,
- "func0(self, arg2, hello) -> int",
- "func0(arg2, hello) -> int")
-check(A.func1.__doc__,
- "func1(A self, short arg2, Tuple hello) -> int",
- "func1(short arg2, Tuple hello) -> int")
-check(A.func2.__doc__,
- "\n"
- " func2(self, arg2, hello) -> int\n"
- "\n"
- " Parameters\n"
- " ----------\n"
- " arg2: short\n"
- " hello: int tuple[2]\n"
- "\n"
- " ",
- "\n"
- "func2(arg2, hello) -> int\n"
+check(inspect.getdoc(A), "Proxy of C++ A class.", "::A")
+check(inspect.getdoc(A.funk), "just a string.")
+check(inspect.getdoc(A.func0),
+ "func0(self, arg2, hello) -> int")
+check(inspect.getdoc(A.func1),
+ "func1(A self, short arg2, Tuple hello) -> int")
+check(inspect.getdoc(A.func2),
+ "func2(self, arg2, hello) -> int\n"
"\n"
"Parameters\n"
"----------\n"
"arg2: short\n"
- "hello: int tuple[2]\n"
- "\n"
- ""
- )
-check(A.func3.__doc__,
- "\n"
- " func3(A self, short arg2, Tuple hello) -> int\n"
- "\n"
- " Parameters\n"
- " ----------\n"
- " arg2: short\n"
- " hello: int tuple[2]\n"
- "\n"
- " ",
- "\n"
- "func3(short arg2, Tuple hello) -> int\n"
+ "hello: int tuple[2]")
+check(inspect.getdoc(A.func3),
+ "func3(A self, short arg2, Tuple hello) -> int\n"
"\n"
"Parameters\n"
"----------\n"
"arg2: short\n"
- "hello: int tuple[2]\n"
- "\n"
- ""
- )
+ "hello: int tuple[2]")
-check(A.func0default.__doc__,
- "\n"
- " func0default(self, e, arg3, hello, f=2) -> int\n"
- " func0default(self, e, arg3, hello) -> int\n"
- " ",
- "\n"
- "func0default(e, arg3, hello, f=2) -> int\n"
- "func0default(e, arg3, hello) -> int\n"
- ""
- )
-check(A.func1default.__doc__,
- "\n"
- " func1default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
- " func1default(A self, A e, short arg3, Tuple hello) -> int\n"
- " ",
- "\n"
- "func1default(A e, short arg3, Tuple hello, double f=2) -> int\n"
- "func1default(A e, short arg3, Tuple hello) -> int\n"
- ""
- )
-check(A.func2default.__doc__,
- "\n"
- " func2default(self, e, arg3, hello, f=2) -> int\n"
- "\n"
- " Parameters\n"
- " ----------\n"
- " e: A *\n"
- " arg3: short\n"
- " hello: int tuple[2]\n"
- " f: double\n"
- "\n"
- " func2default(self, e, arg3, hello) -> int\n"
- "\n"
- " Parameters\n"
- " ----------\n"
- " e: A *\n"
- " arg3: short\n"
- " hello: int tuple[2]\n"
- "\n"
- " ",
- "\n"
- "func2default(e, arg3, hello, f=2) -> int\n"
+check(inspect.getdoc(A.func0default),
+ "func0default(self, e, arg3, hello, f=2) -> int")
+check(inspect.getdoc(A.func1default),
+ "func1default(A self, A e, short arg3, Tuple hello, double f=2) -> int")
+check(inspect.getdoc(A.func2default),
+ "func2default(self, e, arg3, hello, f=2) -> int\n"
"\n"
"Parameters\n"
"----------\n"
"e: A *\n"
"arg3: short\n"
"hello: int tuple[2]\n"
- "f: double\n"
- "\n"
- "func2default(e, arg3, hello) -> int\n"
+ "f: double")
+check(inspect.getdoc(A.func3default),
+ "func3default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
"\n"
"Parameters\n"
"----------\n"
"e: A *\n"
"arg3: short\n"
"hello: int tuple[2]\n"
- "\n"
- ""
- )
-check(A.func3default.__doc__,
- "\n"
- " func3default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
- "\n"
- " Parameters\n"
- " ----------\n"
- " e: A *\n"
- " arg3: short\n"
- " hello: int tuple[2]\n"
- " f: double\n"
- "\n"
- " func3default(A self, A e, short arg3, Tuple hello) -> int\n"
- "\n"
- " Parameters\n"
- " ----------\n"
- " e: A *\n"
- " arg3: short\n"
- " hello: int tuple[2]\n"
- "\n"
- " ",
- "\n"
- "func3default(A e, short arg3, Tuple hello, double f=2) -> int\n"
+ "f: double")
+
+check(inspect.getdoc(A.func0static),
+ "func0static(e, arg2, hello, f=2) -> int")
+check(inspect.getdoc(_autodoc.A_func0static),
+ "A_func0static(e, arg2, hello, f=2) -> int")
+check(inspect.getdoc(A_func0static),
+ "A_func0static(e, arg2, hello, f=2) -> int")
+check(inspect.getdoc(A.func1static),
+ "func1static(A e, short arg2, Tuple hello, double f=2) -> int")
+check(inspect.getdoc(_autodoc.A_func1static),
+ "A_func1static(A e, short arg2, Tuple hello, double f=2) -> int")
+check(inspect.getdoc(A_func1static),
+ "A_func1static(A e, short arg2, Tuple hello, double f=2) -> int")
+check(inspect.getdoc(A.func2static),
+ "func2static(e, arg2, hello, f=2) -> int\n"
"\n"
"Parameters\n"
"----------\n"
"e: A *\n"
- "arg3: short\n"
+ "arg2: short\n"
"hello: int tuple[2]\n"
- "f: double\n"
- "\n"
- "func3default(A e, short arg3, Tuple hello) -> int\n"
+ "f: double")
+check(inspect.getdoc(_autodoc.A_func2static),
+ "A_func2static(e, arg2, hello, f=2) -> int\n"
"\n"
"Parameters\n"
"----------\n"
"e: A *\n"
- "arg3: short\n"
+ "arg2: short\n"
"hello: int tuple[2]\n"
- "\n"
- ""
- )
-
-check(A.func0static.__doc__,
- "\n"
- " func0static(e, arg2, hello, f=2) -> int\n"
- " func0static(e, arg2, hello) -> int\n"
- " ",
- "\n"
- "func0static(e, arg2, hello, f=2) -> int\n"
- "func0static(e, arg2, hello) -> int\n"
- ""
- )
-check(A.func1static.__doc__,
- "\n"
- " func1static(A e, short arg2, Tuple hello, double f=2) -> int\n"
- " func1static(A e, short arg2, Tuple hello) -> int\n"
- " ",
- "\n"
- "func1static(A e, short arg2, Tuple hello, double f=2) -> int\n"
- "func1static(A e, short arg2, Tuple hello) -> int\n"
- ""
- )
-check(A.func2static.__doc__,
- "\n"
- " func2static(e, arg2, hello, f=2) -> int\n"
- "\n"
- " Parameters\n"
- " ----------\n"
- " e: A *\n"
- " arg2: short\n"
- " hello: int tuple[2]\n"
- " f: double\n"
- "\n"
- " func2static(e, arg2, hello) -> int\n"
- "\n"
- " Parameters\n"
- " ----------\n"
- " e: A *\n"
- " arg2: short\n"
- " hello: int tuple[2]\n"
- "\n"
- " ",
- "\n"
- "func2static(e, arg2, hello, f=2) -> int\n"
+ "f: double")
+check(inspect.getdoc(A_func2static),
+ "A_func2static(e, arg2, hello, f=2) -> int\n"
"\n"
"Parameters\n"
"----------\n"
"e: A *\n"
"arg2: short\n"
"hello: int tuple[2]\n"
- "f: double\n"
- "\n"
- "func2static(e, arg2, hello) -> int\n"
+ "f: double")
+check(inspect.getdoc(A.func3static),
+ "func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
"\n"
"Parameters\n"
"----------\n"
"e: A *\n"
"arg2: short\n"
"hello: int tuple[2]\n"
- "\n"
- ""
- )
-check(A.func3static.__doc__,
- "\n"
- " func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
- "\n"
- " Parameters\n"
- " ----------\n"
- " e: A *\n"
- " arg2: short\n"
- " hello: int tuple[2]\n"
- " f: double\n"
- "\n"
- " func3static(A e, short arg2, Tuple hello) -> int\n"
- "\n"
- " Parameters\n"
- " ----------\n"
- " e: A *\n"
- " arg2: short\n"
- " hello: int tuple[2]\n"
- "\n"
- " ",
- "\n"
- "func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
+ "f: double")
+check(inspect.getdoc(_autodoc.A_func3static),
+ "A_func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
"\n"
"Parameters\n"
"----------\n"
"e: A *\n"
"arg2: short\n"
"hello: int tuple[2]\n"
- "f: double\n"
- "\n"
- "func3static(A e, short arg2, Tuple hello) -> int\n"
+ "f: double")
+check(inspect.getdoc(A_func3static),
+ "A_func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
"\n"
"Parameters\n"
"----------\n"
"e: A *\n"
"arg2: short\n"
"hello: int tuple[2]\n"
- "\n"
- ""
+ "f: double")
+
+check(inspect.getdoc(A.variable_a),
+ "variable_a"
+ )
+check(inspect.getdoc(A.variable_b),
+ "variable_b : int"
+ )
+check(inspect.getdoc(A.variable_c),
+ "variable_c"
+ )
+check(inspect.getdoc(A.variable_d),
+ "variable_d : int"
)
-if sys.version_info[0:2] > (2, 4):
- # Python 2.4 does not seem to work
- check(A.variable_a.__doc__,
- "A_variable_a_get(self) -> int",
- "A.variable_a"
- )
- check(A.variable_b.__doc__,
- "A_variable_b_get(A self) -> int",
- "A.variable_b"
- )
- check(A.variable_c.__doc__,
+# Check the low-level functions (not present when using -builtin except for the static ones)
+if not is_python_builtin():
+ check(inspect.getdoc(_autodoc.A_funk), "just a string.")
+ check(inspect.getdoc(_autodoc.A_func0),
+ "A_func0(self, arg2, hello) -> int")
+ check(inspect.getdoc(_autodoc.A_func1),
+ "A_func1(A self, short arg2, Tuple hello) -> int")
+ check(inspect.getdoc(_autodoc.A_func2),
+ "A_func2(self, arg2, hello) -> int\n"
+ "\n"
+ "Parameters\n"
+ "----------\n"
+ "arg2: short\n"
+ "hello: int tuple[2]")
+ check(inspect.getdoc(_autodoc.A_func3),
+ "A_func3(A self, short arg2, Tuple hello) -> int\n"
+ "\n"
+ "Parameters\n"
+ "----------\n"
+ "arg2: short\n"
+ "hello: int tuple[2]")
+ check(inspect.getdoc(_autodoc.A_func0default),
+ "A_func0default(self, e, arg3, hello, f=2) -> int")
+ check(inspect.getdoc(_autodoc.A_func1default),
+ "A_func1default(A self, A e, short arg3, Tuple hello, double f=2) -> int")
+ check(inspect.getdoc(_autodoc.A_func2default),
+ "A_func2default(self, e, arg3, hello, f=2) -> int\n"
+ "\n"
+ "Parameters\n"
+ "----------\n"
+ "e: A *\n"
+ "arg3: short\n"
+ "hello: int tuple[2]\n"
+ "f: double")
+ check(inspect.getdoc(_autodoc.A_func3default),
+ "A_func3default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
"\n"
- "A_variable_c_get(self) -> int\n"
+ "Parameters\n"
+ "----------\n"
+ "e: A *\n"
+ "arg3: short\n"
+ "hello: int tuple[2]\n"
+ "f: double")
+ check(inspect.getdoc(_autodoc.A_variable_a_set), "A_variable_a_set(self, variable_a)")
+ check(inspect.getdoc(_autodoc.A_variable_a_get), "A_variable_a_get(self) -> int" )
+ check(inspect.getdoc(_autodoc.A_variable_b_set), "A_variable_b_set(A self, int variable_b)")
+ check(inspect.getdoc(_autodoc.A_variable_b_get), "A_variable_b_get(A self) -> int")
+ check(inspect.getdoc(_autodoc.A_variable_c_set),
+ "A_variable_c_set(self, variable_c)\n"
"\n"
"Parameters\n"
"----------\n"
- "self: A *\n"
- "\n",
- "A.variable_c"
+ "variable_c: int"
)
- check(A.variable_d.__doc__,
+ check(inspect.getdoc(_autodoc.A_variable_c_get), "A_variable_c_get(self) -> int")
+ check(inspect.getdoc(_autodoc.A_variable_d_set),
+ "A_variable_d_set(A self, int variable_d)\n"
"\n"
- "A_variable_d_get(A self) -> int\n"
+ "Parameters\n"
+ "----------\n"
+ "variable_d: int"
+ )
+ check(inspect.getdoc(_autodoc.A_variable_d_get), "A_variable_d_get(A self) -> int")
+ check(inspect.getdoc(_autodoc.new_C), "new_C(a, b, h) -> C")
+ check(inspect.getdoc(_autodoc.delete_C), "delete_C(self)")
+ check(inspect.getdoc(_autodoc.new_D), "new_D(int a, int b, Hola h) -> D")
+ check(inspect.getdoc(_autodoc.delete_D), "delete_D(D self)")
+ check(inspect.getdoc(_autodoc.new_E),
+ "new_E(a, b, h) -> E\n"
"\n"
"Parameters\n"
"----------\n"
- "self: A *\n"
- "\n",
- "A.variable_d"
+ "a: special comment for parameter a\n"
+ "b: another special comment for parameter b\n"
+ "h: enum Hola"
)
+ check(inspect.getdoc(_autodoc.delete_E), "delete_E(self)")
+ check(inspect.getdoc(_autodoc.new_F),
+ "new_F(int a, int b, Hola h) -> F\n"
+ "\n"
+ "Parameters\n"
+ "----------\n"
+ "a: special comment for parameter a\n"
+ "b: another special comment for parameter b\n"
+ "h: enum Hola"
+ )
+ check(inspect.getdoc(_autodoc.delete_F), "delete_F(F self)")
+ check(inspect.getdoc(_autodoc.B_funk), "B_funk(B self, int c, int d) -> int")
+ check(inspect.getdoc(_autodoc.TInteger_inout), "TInteger_inout(TInteger self, TInteger t) -> TInteger")
-check(B.__doc__,
+check(inspect.getdoc(B),
"Proxy of C++ B class.",
"::B"
)
-check(C.__init__.__doc__, "__init__(self, a, b, h) -> C", None, skip)
-check(D.__init__.__doc__,
+check(inspect.getdoc(C.__init__), "__init__(self, a, b, h) -> C", None, skip)
+check(inspect.getdoc(D.__init__),
"__init__(D self, int a, int b, Hola h) -> D", None, skip)
-check(E.__init__.__doc__,
- "\n"
- " __init__(self, a, b, h) -> E\n"
+check(inspect.getdoc(E.__init__),
+ "__init__(self, a, b, h) -> E\n"
"\n"
- " Parameters\n"
- " ----------\n"
- " a: special comment for parameter a\n"
- " b: another special comment for parameter b\n"
- " h: enum Hola\n"
- "\n"
- " ", None, skip
+ "Parameters\n"
+ "----------\n"
+ "a: special comment for parameter a\n"
+ "b: another special comment for parameter b\n"
+ "h: enum Hola", None, skip
)
-check(F.__init__.__doc__,
- "\n"
- " __init__(F self, int a, int b, Hola h) -> F\n"
+check(inspect.getdoc(F.__init__),
+ "__init__(F self, int a, int b, Hola h) -> F\n"
"\n"
- " Parameters\n"
- " ----------\n"
- " a: special comment for parameter a\n"
- " b: another special comment for parameter b\n"
- " h: enum Hola\n"
- "\n"
- " ", None, skip
+ "Parameters\n"
+ "----------\n"
+ "a: special comment for parameter a\n"
+ "b: another special comment for parameter b\n"
+ "h: enum Hola", None, skip
)
-check(B.funk.__doc__,
- "funk(B self, int c, int d) -> int",
- "funk(int c, int d) -> int")
-check(funk.__doc__, "funk(A e, short arg2, int c, int d) -> int")
-check(funkdefaults.__doc__,
- "\n"
- " funkdefaults(A e, short arg2, int c, int d, double f=2) -> int\n"
- " funkdefaults(A e, short arg2, int c, int d) -> int\n"
- " ",
- "\n"
- "funkdefaults(A e, short arg2, int c, int d, double f=2) -> int\n"
- "funkdefaults(A e, short arg2, int c, int d) -> int\n"
- ""
- )
+check(inspect.getdoc(B.funk),
+ "funk(B self, int c, int d) -> int")
+check(inspect.getdoc(funk), "funk(A e, short arg2, int c, int d) -> int")
+check(inspect.getdoc(funkdefaults),
+ "funkdefaults(A e, short arg2, int c, int d, double f=2) -> int")
+
+check(inspect.getdoc(func_input), "func_input(int * INPUT) -> int")
+check(inspect.getdoc(func_output), "func_output() -> int")
+check(inspect.getdoc(func_inout), "func_inout(int * INOUT) -> int")
+check(inspect.getdoc(func_cb), "func_cb(int c, int d) -> int")
+check(inspect.getdoc(banana), "banana(S a, S b, int c, Integer d)")
+
+check(inspect.getdoc(TInteger), "Proxy of C++ T< int > class.", "::T< int >")
+check(inspect.getdoc(TInteger.__init__), "__init__(TInteger self) -> TInteger", None, skip)
+check(inspect.getdoc(TInteger.inout), "inout(TInteger self, TInteger t) -> TInteger")
+
+check(inspect.getdoc(process), "process(int _from, int _in, int var) -> int")
+check(inspect.getdoc(process2), "process2(int _from=0, int _in=1, int var=2) -> int")
+check(inspect.getdoc(process3), "process3(int _from, int _in, int var) -> int")
+check(inspect.getdoc(process4), "process4(int _from=0, int _in=1, int var=2) -> int")
+
+check(inspect.getdoc(process_complex_defval), "process_complex_defval(val=PROCESS_DEFAULT_VALUE, factor=some_type(-1)) -> int")
-check(func_input.__doc__, "func_input(int * INPUT) -> int")
-check(func_output.__doc__, "func_output() -> int")
-check(func_inout.__doc__, "func_inout(int * INOUT) -> int")
-check(func_cb.__doc__, "func_cb(int c, int d) -> int")
-check(banana.__doc__, "banana(S a, S b, int c, Integer d)")
+check(inspect.getdoc(a_structure.__init__), "__init__(a_structure self) -> a_structure", None, skip)
diff --git a/Examples/test-suite/python/callback_runme.py b/Examples/test-suite/python/callback_runme.py
index ef7baad4e..de8a372f6 100644
--- a/Examples/test-suite/python/callback_runme.py
+++ b/Examples/test-suite/python/callback_runme.py
@@ -13,6 +13,10 @@ if foobar(3, _callback.foo) != foo(3):
if foobar(3, foo) != foo(3):
raise RuntimeError
+# Needs some more work for -builtin
+# if foobar(3, A.bar) != A.bar(3):
+# raise RuntimeError
+
if foobar(3, A_bar) != A_bar(3):
raise RuntimeError
diff --git a/Examples/test-suite/python/ccomplextest_runme.py b/Examples/test-suite/python/ccomplextest_runme.py
new file mode 100644
index 000000000..63a663f50
--- /dev/null
+++ b/Examples/test-suite/python/ccomplextest_runme.py
@@ -0,0 +1,22 @@
+import ccomplextest
+
+a = complex(-1, 2)
+
+if ccomplextest.has_c99_complex():
+ if ccomplextest.Conj(a) != a.conjugate():
+ raise RuntimeError("bad complex mapping")
+
+ if ccomplextest.Conjf(a) != a.conjugate():
+ raise RuntimeError("bad complex mapping")
+
+ if ccomplextest.Conj2(a) != a.conjugate():
+ raise RuntimeError("bad complex mapping")
+
+ if ccomplextest.Conjf2(a) != a.conjugate():
+ raise RuntimeError("bad complex mapping")
+
+ if ccomplextest.Conj3(a) != a.conjugate():
+ raise RuntimeError("bad complex mapping")
+
+ if ccomplextest.Conjf3(a) != a.conjugate():
+ raise RuntimeError("bad complex mapping")
diff --git a/Examples/test-suite/python/char_binary_runme.py b/Examples/test-suite/python/char_binary_runme.py
index 34caa3208..39c0b2447 100644
--- a/Examples/test-suite/python/char_binary_runme.py
+++ b/Examples/test-suite/python/char_binary_runme.py
@@ -1,42 +1,39 @@
from char_binary import *
t = Test()
-if t.strlen('hile') != 4:
- print t.strlen('hile')
- raise RuntimeError, "bad multi-arg typemap"
-if t.ustrlen('hile') != 4:
- print t.ustrlen('hile')
- raise RuntimeError, "bad multi-arg typemap"
-
-if t.strlen('hil\0') != 4:
- raise RuntimeError, "bad multi-arg typemap"
-if t.ustrlen('hil\0') != 4:
- raise RuntimeError, "bad multi-arg typemap"
+if t.strlen("hile") != 4:
+ raise RuntimeError("bad multi-arg typemap {}".format(t.strlen("hile")))
+if t.ustrlen("hile") != 4:
+ raise RuntimeError("bad multi-arg typemap {}".format(t.ustrlen("hile")))
+
+if t.strlen("hil\0") != 4:
+ raise RuntimeError("bad multi-arg typemap")
+if t.ustrlen("hil\0") != 4:
+ raise RuntimeError("bad multi-arg typemap")
#
# creating a raw char*
#
pc = new_pchar(5)
-pchar_setitem(pc, 0, 'h')
-pchar_setitem(pc, 1, 'o')
-pchar_setitem(pc, 2, 'l')
-pchar_setitem(pc, 3, 'a')
+pchar_setitem(pc, 0, "h")
+pchar_setitem(pc, 1, "o")
+pchar_setitem(pc, 2, "l")
+pchar_setitem(pc, 3, "a")
pchar_setitem(pc, 4, 0)
if t.strlen(pc) != 4:
- raise RuntimeError, "bad multi-arg typemap"
+ raise RuntimeError("bad multi-arg typemap")
if t.ustrlen(pc) != 4:
- raise RuntimeError, "bad multi-arg typemap"
+ raise RuntimeError("bad multi-arg typemap")
cvar.var_pchar = pc
if cvar.var_pchar != "hola":
- print cvar.var_pchar
- raise RuntimeError, "bad pointer case"
+ raise RuntimeError("bad pointer case {}".format(cvar.var_pchar))
cvar.var_namet = pc
# if cvar.var_namet != "hola\0":
if cvar.var_namet != "hola":
- raise RuntimeError, "bad pointer case"
+ raise RuntimeError("bad pointer case")
delete_pchar(pc)
diff --git a/Examples/test-suite/python/comment_verifier.py b/Examples/test-suite/python/comment_verifier.py
new file mode 100644
index 000000000..653cb4940
--- /dev/null
+++ b/Examples/test-suite/python/comment_verifier.py
@@ -0,0 +1,26 @@
+def check(got, expected, expected_builtin=None):
+ if got is None: # Absence of comment is equivalent to empty comment.
+ got = ""
+
+ if got != expected:
+ import re
+ p = re.compile(r"^[+-]([^+-].*\S)?(\s+)$", re.M)
+
+ def make_trailing_spaces_visible(str):
+ def replace_trailing_spaces(match):
+ res = match.group(0)
+ spaces = match.group(2)
+ if spaces is not None:
+ res = res + "{+%d trailing spaces}" % len(spaces)
+ return res
+ return re.sub(p, replace_trailing_spaces, str)
+
+ from difflib import unified_diff
+ diff = unified_diff(expected.splitlines(True),
+ got.splitlines(True), "expected", "got")
+ lines = []
+ for line in diff:
+ line = make_trailing_spaces_visible(line.strip("\r\n"))
+ lines.append(line + "\n")
+
+ raise RuntimeError("Comments don't match:\n" + "".join(lines))
diff --git a/Examples/test-suite/python/complextest_runme.py b/Examples/test-suite/python/complextest_runme.py
index 7dd7f5a3b..1b9ad6629 100644
--- a/Examples/test-suite/python/complextest_runme.py
+++ b/Examples/test-suite/python/complextest_runme.py
@@ -3,15 +3,27 @@ import complextest
a = complex(-1, 2)
if complextest.Conj(a) != a.conjugate():
- raise RuntimeError, "bad complex mapping"
+ raise RuntimeError("bad complex mapping")
if complextest.Conjf(a) != a.conjugate():
- raise RuntimeError, "bad complex mapping"
+ raise RuntimeError("bad complex mapping")
+if complextest.Conj2(a) != a.conjugate():
+ raise RuntimeError("bad complex mapping")
+
+if complextest.Conjf2(a) != a.conjugate():
+ raise RuntimeError("bad complex mapping")
v = (complex(1, 2), complex(2, 3), complex(4, 3), 1)
-try:
- complextest.Copy_h(v)
-except:
- pass
+if len(complextest.CopyHalf(v)) != 2:
+ raise RuntimeError("CopyHalf failed")
+
+if len(complextest.CopyHalfRef(v)) != 2:
+ raise RuntimeError("CopyHalfRef failed")
+
+p = complextest.ComplexPair()
+p.z1 = complex(0, 1)
+p.z2 = complex(0, -1)
+if complextest.Conj(p.z2) != p.z1:
+ raise RuntimeError("bad complex mapping")
diff --git a/Examples/test-suite/python/constover_runme.py b/Examples/test-suite/python/constover_runme.py
index 2d28a55cc..0c03967f6 100644
--- a/Examples/test-suite/python/constover_runme.py
+++ b/Examples/test-suite/python/constover_runme.py
@@ -4,33 +4,26 @@ error = 0
p = constover.test("test")
if p != "test":
- print "test failed!"
- error = 1
+ raise RuntimeError("test failed!")
p = constover.test_pconst("test")
if p != "test_pconst":
- print "test_pconst failed!"
- error = 1
+ raise RuntimeError("test_pconst failed!")
f = constover.Foo()
p = f.test("test")
if p != "test":
- print "member-test failed!"
- error = 1
+ raise RuntimeError("member-test failed!")
p = f.test_pconst("test")
if p != "test_pconst":
- print "member-test_pconst failed!"
- error = 1
+ raise RuntimeError("member-test_pconst failed!")
p = f.test_constm("test")
if p != "test_constmethod":
- print "member-test_constm failed!"
- error = 1
+ raise RuntimeError("member-test_constm failed!")
p = f.test_pconstm("test")
if p != "test_pconstmethod":
- print "member-test_pconstm failed!"
- error = 1
+ raise RuntimeError("member-test_pconstm failed!")
-sys.exit(error)
diff --git a/Examples/test-suite/python/contract_runme.py b/Examples/test-suite/python/contract_runme.py
index cd75a51d2..b6bab3a09 100644
--- a/Examples/test-suite/python/contract_runme.py
+++ b/Examples/test-suite/python/contract_runme.py
@@ -2,141 +2,141 @@ import contract
contract.test_preassert(1, 2)
try:
- contract.test_preassert(-1)
- print "Failed! Preassertions are broken"
-except:
+ contract.test_preassert(-1, 3)
+ raise Exception("Failed! Preassertions are broken")
+except RuntimeError:
pass
contract.test_postassert(3)
try:
contract.test_postassert(-3)
- print "Failed! Postassertions are broken"
-except:
+ raise Exception("Failed! Postassertions are broken")
+except RuntimeError:
pass
contract.test_prepost(2, 3)
contract.test_prepost(5, -4)
try:
contract.test_prepost(-3, 4)
- print "Failed! Preassertions are broken"
-except:
+ raise Exception("Failed! Preassertions are broken")
+except RuntimeError:
pass
try:
contract.test_prepost(4, -10)
- print "Failed! Postassertions are broken"
+ raise Exception("Failed! Postassertions are broken")
-except:
+except RuntimeError:
pass
f = contract.Foo()
f.test_preassert(4, 5)
try:
f.test_preassert(-2, 3)
- print "Failed! Method preassertion."
-except:
+ raise Exception("Failed! Method preassertion.")
+except RuntimeError:
pass
f.test_postassert(4)
try:
f.test_postassert(-4)
- print "Failed! Method postassertion"
-except:
+ raise Exception("Failed! Method postassertion")
+except RuntimeError:
pass
f.test_prepost(3, 4)
f.test_prepost(4, -3)
try:
f.test_prepost(-4, 2)
- print "Failed! Method preassertion."
-except:
+ raise Exception("Failed! Method preassertion.")
+except RuntimeError:
pass
try:
f.test_prepost(4, -10)
- print "Failed! Method postassertion."
-except:
+ raise Exception("Failed! Method postassertion.")
+except RuntimeError:
pass
contract.Foo_stest_prepost(4, 0)
try:
contract.Foo_stest_prepost(-4, 2)
- print "Failed! Static method preassertion"
-except:
+ raise Exception("Failed! Static method preassertion")
+except RuntimeError:
pass
try:
contract.Foo_stest_prepost(4, -10)
- print "Failed! Static method posteassertion"
-except:
+ raise Exception("Failed! Static method posteassertion")
+except RuntimeError:
pass
b = contract.Bar()
try:
b.test_prepost(2, -4)
- print "Failed! Inherited preassertion."
-except:
+ raise Exception("Failed! Inherited preassertion.")
+except RuntimeError:
pass
d = contract.D()
try:
d.foo(-1, 1, 1, 1, 1)
- print "Failed! Inherited preassertion (D)."
-except:
+ raise Exception("Failed! Inherited preassertion (D).")
+except RuntimeError:
pass
try:
d.foo(1, -1, 1, 1, 1)
- print "Failed! Inherited preassertion (D)."
-except:
+ raise Exception("Failed! Inherited preassertion (D).")
+except RuntimeError:
pass
try:
d.foo(1, 1, -1, 1, 1)
- print "Failed! Inherited preassertion (D)."
-except:
+ raise Exception("Failed! Inherited preassertion (D).")
+except RuntimeError:
pass
try:
d.foo(1, 1, 1, -1, 1)
- print "Failed! Inherited preassertion (D)."
-except:
+ raise Exception("Failed! Inherited preassertion (D).")
+except RuntimeError:
pass
try:
d.foo(1, 1, 1, 1, -1)
- print "Failed! Inherited preassertion (D)."
-except:
+ raise Exception("Failed! Inherited preassertion (D).")
+except RuntimeError:
pass
try:
d.bar(-1, 1, 1, 1, 1)
- print "Failed! Inherited preassertion (D)."
-except:
+ raise Exception("Failed! Inherited preassertion (D).")
+except RuntimeError:
pass
try:
d.bar(1, -1, 1, 1, 1)
- print "Failed! Inherited preassertion (D)."
-except:
+ raise Exception("Failed! Inherited preassertion (D).")
+except RuntimeError:
pass
try:
d.bar(1, 1, -1, 1, 1)
- print "Failed! Inherited preassertion (D)."
-except:
+ raise Exception("Failed! Inherited preassertion (D).")
+except RuntimeError:
pass
try:
d.bar(1, 1, 1, -1, 1)
- print "Failed! Inherited preassertion (D)."
-except:
+ raise Exception("Failed! Inherited preassertion (D).")
+except RuntimeError:
pass
try:
d.bar(1, 1, 1, 1, -1)
- print "Failed! Inherited preassertion (D)."
-except:
+ raise Exception("Failed! Inherited preassertion (D).")
+except RuntimeError:
pass
# Namespace
my = contract.myClass(1)
try:
my = contract.myClass(0)
- print "Failed! constructor preassertion"
-except:
+ raise Exception("Failed! constructor preassertion")
+except RuntimeError:
pass
diff --git a/Examples/test-suite/python/cpp11_alternate_function_syntax_runme.py b/Examples/test-suite/python/cpp11_alternate_function_syntax_runme.py
index 363736a84..e46a4772f 100644
--- a/Examples/test-suite/python/cpp11_alternate_function_syntax_runme.py
+++ b/Examples/test-suite/python/cpp11_alternate_function_syntax_runme.py
@@ -4,11 +4,20 @@ a = cpp11_alternate_function_syntax.SomeStruct()
res = a.addNormal(4, 5)
if res != 9:
- raise RuntimeError, ("SomeStruct::addNormal(4,5) returns ",
- res, " should be 9.")
-
+ raise RuntimeError("SomeStruct::addNormal(4,5) returns ", res, " should be 9.")
res = a.addAlternate(4, 5)
if res != 9:
- raise RuntimeError, ("SomeStruct::addAlternate(4,5) returns ",
- res, " should be 9.")
+ raise RuntimeError("SomeStruct::addAlternate(4,5) returns ", res, " should be 9.")
+
+res = a.addAlternateConst(4, 5)
+if res != 9:
+ raise RuntimeError("SomeStruct::addAlternateConst(4,5) returns ", res, " should be 9.")
+
+res = a.addAlternateNoExcept(4, 5)
+if res != 9:
+ raise RuntimeError("SomeStruct::addAlternateNoExcept(4,5) returns ", res, " should be 9.")
+
+res = a.addAlternateConstNoExcept(4, 5)
+if res != 9:
+ raise RuntimeError("SomeStruct::addAlternateConstNoExcept(4,5) returns ", res, " should be 9.")
diff --git a/Examples/test-suite/python/cpp11_decltype_runme.py b/Examples/test-suite/python/cpp11_decltype_runme.py
index 1650d9004..a18f334dc 100644
--- a/Examples/test-suite/python/cpp11_decltype_runme.py
+++ b/Examples/test-suite/python/cpp11_decltype_runme.py
@@ -3,16 +3,16 @@ import cpp11_decltype
a = cpp11_decltype.A()
a.i = 5
if a.i != 5:
- raise RuntimeError, "Assignment to a.i failed."
+ raise RuntimeError("Assignment to a.i failed.")
a.j = 10
if a.j != 10:
- raise RuntimeError, "Assignment to a.j failed."
+ raise RuntimeError("Assignment to a.j failed.")
b = a.foo(5)
if b != 10:
- raise RuntimeError, "foo(5) should return 10."
+ raise RuntimeError("foo(5) should return 10.")
b = a.foo(6)
if b != 0:
- raise RuntimeError, "foo(6) should return 0."
+ raise RuntimeError("foo(6) should return 0.")
diff --git a/Examples/test-suite/python/cpp11_final_directors_runme.py b/Examples/test-suite/python/cpp11_final_directors_runme.py
new file mode 100644
index 000000000..2e5f8af96
--- /dev/null
+++ b/Examples/test-suite/python/cpp11_final_directors_runme.py
@@ -0,0 +1,11 @@
+import cpp11_final_directors
+
+class Derived2(cpp11_final_directors.Derived):
+
+ def meth(self):
+ return 3
+
+
+b = Derived2()
+if b.meth() != 3:
+ raise RuntimeError
diff --git a/Examples/test-suite/python/cpp11_hash_tables_runme.py b/Examples/test-suite/python/cpp11_hash_tables_runme.py
new file mode 100644
index 000000000..3e7be49d0
--- /dev/null
+++ b/Examples/test-suite/python/cpp11_hash_tables_runme.py
@@ -0,0 +1,60 @@
+import cpp11_hash_tables
+
+def swig_assert_equal(a, b):
+ if a != b:
+ raise RuntimeError(str(a) + " != " + str(b))
+
+for x in [cpp11_hash_tables.MapIntInt({1:7}),
+ cpp11_hash_tables.MultiMapIntInt({1:7}),
+ cpp11_hash_tables.UnorderedMapIntInt({1:7}),
+ cpp11_hash_tables.UnorderedMultiMapIntInt({1:7})
+ ]:
+
+ swig_assert_equal([(k, v) for k, v in x.items()], [(1, 7)])
+ swig_assert_equal(list(x.keys()), [1])
+ swig_assert_equal(list(x.values()), [7])
+ swig_assert_equal(list(x.items()), [(1, 7)])
+ swig_assert_equal([k for k in x], [1])
+ swig_assert_equal([i for i in x.keys()], [1])
+ swig_assert_equal([i for i in x.values()], [7])
+ swig_assert_equal([i for i in x.items()], [(1, 7)])
+
+ swig_assert_equal(x[1], 7)
+ swig_assert_equal(2 in x, False)
+ x[2] = 9
+ swig_assert_equal(x[2], 9)
+ del x[2]
+ swig_assert_equal(2 in x, False)
+ swig_assert_equal(x.empty(), False)
+ del x[1]
+ swig_assert_equal(x.empty(), True)
+ swig_assert_equal(1 in x, False)
+
+for x in [cpp11_hash_tables.MultiMapIntInt({1:7}),
+ cpp11_hash_tables.UnorderedMultiMapIntInt({1:7})]:
+ x[1] = 9
+ swig_assert_equal(sorted([v for k, v in x.items()]), [7, 9])
+ swig_assert_equal(len(x), 2)
+
+for x in [cpp11_hash_tables.SetInt([1]),
+ cpp11_hash_tables.MultiSetInt([1]),
+ cpp11_hash_tables.UnorderedSetInt([1]),
+ cpp11_hash_tables.UnorderedMultiSetInt([1])]:
+
+ swig_assert_equal([e for e in x], [1])
+ swig_assert_equal(x[0], 1)
+
+ swig_assert_equal(1 in x, True)
+ swig_assert_equal(2 in x, False)
+ x.append(2)
+ swig_assert_equal(2 in x, True)
+ x.erase(2)
+ swig_assert_equal(x.empty(), False)
+ x.erase(1)
+ swig_assert_equal(x.empty(), True)
+
+for x in [cpp11_hash_tables.MultiSetInt([1]),
+ cpp11_hash_tables.UnorderedMultiSetInt([1])]:
+ x.append(1)
+ swig_assert_equal(x.count(1), 2)
+ swig_assert_equal(len(x), 2)
diff --git a/Examples/test-suite/python/cpp11_null_pointer_constant_runme.py b/Examples/test-suite/python/cpp11_null_pointer_constant_runme.py
index 54a8fe0eb..c39760344 100644
--- a/Examples/test-suite/python/cpp11_null_pointer_constant_runme.py
+++ b/Examples/test-suite/python/cpp11_null_pointer_constant_runme.py
@@ -3,15 +3,15 @@ import cpp11_null_pointer_constant
a = cpp11_null_pointer_constant.A()
if a._myA != None:
- raise RuntimeError, (
+ raise RuntimeError(
"cpp11_null_pointer_constant: _myA should be None, but is ", a._myA)
b = cpp11_null_pointer_constant.A()
if a._myA != b._myA:
- raise RuntimeError, (
+ raise RuntimeError(
"cpp11_null_pointer_constant: a._myA should be the same as b._myA, but ", a._myA, "!=", b._myA)
a._myA = cpp11_null_pointer_constant.A()
if a._myA == None:
- raise RuntimeError, (
- "cpp11_null_pointer_constant: _myA should be object, but is None")
+ raise RuntimeError((
+ "cpp11_null_pointer_constant: _myA should be object, but is None"))
diff --git a/Examples/test-suite/python/cpp11_raw_string_literals_runme.py b/Examples/test-suite/python/cpp11_raw_string_literals_runme.py
index 29e53c6a7..90e450f8b 100644
--- a/Examples/test-suite/python/cpp11_raw_string_literals_runme.py
+++ b/Examples/test-suite/python/cpp11_raw_string_literals_runme.py
@@ -1,4 +1,5 @@
from cpp11_raw_string_literals import *
+import inspect
if cvar.L != 100:
raise RuntimeError
@@ -33,16 +34,42 @@ if cvar.aa != "Wide string":
raise RuntimeError
if cvar.bb != "UTF-8 string":
- raise RuntimeError, cvar.wide
+ raise RuntimeError(cvar.wide)
if cvar.xx != ")I'm an \"ascii\" \\ string.":
- raise RuntimeError, cvar.xx
+ raise RuntimeError(cvar.xx)
if cvar.ee != ")I'm an \"ascii\" \\ string.":
- raise RuntimeError, cvar.ee
+ raise RuntimeError(cvar.ee)
if cvar.ff != "I'm a \"raw wide\" \\ string.":
- raise RuntimeError, cvar.ff
+ raise RuntimeError(cvar.ff)
if cvar.gg != "I'm a \"raw UTF-8\" \\ string.":
- raise RuntimeError, cvar.gg
+ raise RuntimeError(cvar.gg)
+
+
+def check(got, expected):
+ expected_list = expected.split("\n")
+ got_list = got.split("\n")
+
+ if expected_list != got_list:
+ raise RuntimeError("\n" + "Expected: " + str(expected_list) + "\n" + "Got : " + str(got_list))
+
+# When getting docstrings, use inspect.getdoc(x) instead of x.__doc__ otherwise the different options
+# such as -O and -builtin may produce different initial indentation.
+check(inspect.getdoc(RawStringDoc.WW), "Single line documentation comment")
+check(inspect.getdoc(RawStringDoc.XX),
+"""Multi-line
+documentation
+comment""")
+check(inspect.getdoc(RawStringDoc.YY), """Single line "raw string" documentation comment""")
+check(inspect.getdoc(RawStringDoc.ZZ),
+"""Documentation comment
+
+as a "raw string"
+on multiple lines including a \ backslash""")
+
+check(mm, """)I'm an "ascii" \ string constant with multiple
+
+lines.""")
diff --git a/Examples/test-suite/python/cpp11_ref_qualifiers_runme.py b/Examples/test-suite/python/cpp11_ref_qualifiers_runme.py
new file mode 100644
index 000000000..d3aa98c47
--- /dev/null
+++ b/Examples/test-suite/python/cpp11_ref_qualifiers_runme.py
@@ -0,0 +1,45 @@
+import cpp11_ref_qualifiers
+
+h = cpp11_ref_qualifiers.Host()
+
+# Basic testing
+h.h1()
+h.h2()
+h.h6()
+h.h7()
+
+h.h()
+
+# %feature testing
+f = cpp11_ref_qualifiers.Features()
+if f.F1() != "F1":
+ raise RuntimeException("Fail")
+if f.F2() != "F2":
+ raise RuntimeException("Fail")
+if f.F3() != "F3":
+ raise RuntimeException("Fail")
+
+if f.C1(0) != "C1":
+ raise RuntimeException("Fail")
+if f.C2(0) != "C2":
+ raise RuntimeException("Fail")
+if f.C3(0) != "C3":
+ raise RuntimeException("Fail")
+
+# %rename testing
+r = cpp11_ref_qualifiers.Renames()
+r.RR1()
+r.RR2()
+r.RR3()
+
+r.SS1(0)
+r.SS2(0)
+r.SS3(0)
+
+# Conversion operators
+co = cpp11_ref_qualifiers.ConversionOperators()
+s = co.StringConvertCopy()
+s = co.StringConvertMove()
+
+co2 = cpp11_ref_qualifiers.ConversionOperators2()
+s = co2.StringConvertMove()
diff --git a/Examples/test-suite/python/cpp11_ref_qualifiers_rvalue_unignore_runme.py b/Examples/test-suite/python/cpp11_ref_qualifiers_rvalue_unignore_runme.py
new file mode 100644
index 000000000..6352c79c2
--- /dev/null
+++ b/Examples/test-suite/python/cpp11_ref_qualifiers_rvalue_unignore_runme.py
@@ -0,0 +1,4 @@
+import cpp11_ref_qualifiers_rvalue_unignore
+
+cpp11_ref_qualifiers_rvalue_unignore.RefQualifier().m1()
+cpp11_ref_qualifiers_rvalue_unignore.RefQualifier().m2()
diff --git a/Examples/test-suite/python/cpp11_result_of_runme.py b/Examples/test-suite/python/cpp11_result_of_runme.py
index 4469efd81..691d2a2d8 100644
--- a/Examples/test-suite/python/cpp11_result_of_runme.py
+++ b/Examples/test-suite/python/cpp11_result_of_runme.py
@@ -2,10 +2,10 @@ import cpp11_result_of
result = cpp11_result_of.test_result(cpp11_result_of.SQUARE, 3.0)
if result != 9.0:
- raise RuntimeError, "test_result(square, 3.0) is not 9.0. Got: " + str(
- result)
+ raise RuntimeError("test_result(square, 3.0) is not 9.0. Got: " + str(
+ result))
result = cpp11_result_of.test_result_alternative1(cpp11_result_of.SQUARE, 3.0)
if result != 9.0:
- raise RuntimeError, "test_result_alternative1(square, 3.0) is not 9.0. Got: " + str(
- result)
+ raise RuntimeError("test_result_alternative1(square, 3.0) is not 9.0. Got: " + str(
+ result))
diff --git a/Examples/test-suite/python/cpp11_rvalue_reference_runme.py b/Examples/test-suite/python/cpp11_rvalue_reference_runme.py
index c1cd3bf26..85d64a581 100644
--- a/Examples/test-suite/python/cpp11_rvalue_reference_runme.py
+++ b/Examples/test-suite/python/cpp11_rvalue_reference_runme.py
@@ -4,24 +4,24 @@ a = cpp11_rvalue_reference.A()
a.setAcopy(5)
if a.getAcopy() != 5:
- raise RunTimeError, ("int A::getAcopy() value is ",
+ raise RunTimeError("int A::getAcopy() value is ",
a.getAcopy(), " should be 5")
ptr = a.getAptr()
a.setAptr(ptr)
if a.getAcopy() != 5:
- raise RunTimeError, ("after A::setAptr(): int A::getAcopy() value is ", a.getAcopy(
+ raise RunTimeError("after A::setAptr(): int A::getAcopy() value is ", a.getAcopy(
), " should be 5")
a.setAref(ptr)
if a.getAcopy() != 5:
- raise RunTimeError, ("after A::setAref(): int A::getAcopy() value is ", a.getAcopy(
+ raise RunTimeError("after A::setAref(): int A::getAcopy() value is ", a.getAcopy(
), " should be 5")
rvalueref = a.getAmove()
a.setAmove(rvalueref)
if a.getAcopy() != 5:
- raise RunTimeError, ("after A::setAmove(): int A::getAcopy() value is ", a.getAcopy(
+ raise RunTimeError("after A::setAmove(): int A::getAcopy() value is ", a.getAcopy(
), " should be 5")
diff --git a/Examples/test-suite/python/cpp11_shared_ptr_overload_runme.py b/Examples/test-suite/python/cpp11_shared_ptr_overload_runme.py
new file mode 100644
index 000000000..6b179cb6d
--- /dev/null
+++ b/Examples/test-suite/python/cpp11_shared_ptr_overload_runme.py
@@ -0,0 +1,45 @@
+import cpp11_shared_ptr_overload
+from cpp11_shared_ptr_overload import MyType
+
+# ref
+ret = cpp11_shared_ptr_overload.UseA(MyType("123"))
+if ret != "123 ref": raise RuntimeError("UseA fail:" + ret)
+
+ret = cpp11_shared_ptr_overload.UseB(0, MyType("123"))
+if ret != "123 ref": raise RuntimeError("UseB fail:" + ret)
+
+ret = cpp11_shared_ptr_overload.UseC(0, MyType("123"), MyType("456"))
+if ret != "123 ref": raise RuntimeError("UseC fail:" + ret)
+
+# sharedptr
+ret = cpp11_shared_ptr_overload.UseX(MyType("123"))
+if ret != "123 sharedptr": raise RuntimeError("UseX fail:" + ret)
+
+ret = cpp11_shared_ptr_overload.UseY(0, MyType("123"))
+if ret != "123 sharedptr": raise RuntimeError("UseY fail:" + ret)
+
+ret = cpp11_shared_ptr_overload.UseZ(0, MyType("123"), MyType("456"))
+if ret != "123 sharedptr": raise RuntimeError("UseZ fail:" + ret)
+
+# Combo1-4
+ret = cpp11_shared_ptr_overload.Combo1(MyType("XXX"))
+if ret != "XXXCombo1": raise RuntimeError("Combo1 fail:" + ret)
+
+ret = cpp11_shared_ptr_overload.Combo2(MyType("XXX"))
+if ret != "XXXCombo2": raise RuntimeError("Combo2 fail:" + ret)
+
+ret = cpp11_shared_ptr_overload.Combo3(MyType("XXX"))
+if ret != "XXXCombo3": raise RuntimeError("Combo3 fail:" + ret)
+
+ret = cpp11_shared_ptr_overload.Combo4(MyType("XXX"))
+if ret != "XXXCombo4": raise RuntimeError("Combo4 fail:" + ret)
+
+# Combo5-7
+ret = cpp11_shared_ptr_overload.Combo5(MyType("XXX"))
+if ret != "XXXCombo5": raise RuntimeError("Combo5 fail:" + ret)
+
+ret = cpp11_shared_ptr_overload.Combo6(MyType("XXX"))
+if ret != "XXXCombo6": raise RuntimeError("Combo6 fail:" + ret)
+
+ret = cpp11_shared_ptr_overload.Combo7(MyType("XXX"))
+if ret != "XXXCombo7": raise RuntimeError("Combo7 fail:" + ret)
diff --git a/Examples/test-suite/python/cpp11_shared_ptr_template_upcast_runme.py b/Examples/test-suite/python/cpp11_shared_ptr_template_upcast_runme.py
new file mode 100644
index 000000000..08a95c2ce
--- /dev/null
+++ b/Examples/test-suite/python/cpp11_shared_ptr_template_upcast_runme.py
@@ -0,0 +1,5 @@
+from cpp11_shared_ptr_template_upcast import *
+
+pd = MakePrintableDerived(20)
+pd.GetResult()
+pd.GetFormatted()
diff --git a/Examples/test-suite/python/cpp11_shared_ptr_upcast_runme.py b/Examples/test-suite/python/cpp11_shared_ptr_upcast_runme.py
new file mode 100644
index 000000000..08546a45e
--- /dev/null
+++ b/Examples/test-suite/python/cpp11_shared_ptr_upcast_runme.py
@@ -0,0 +1,63 @@
+from cpp11_shared_ptr_upcast import *
+
+# This is a port from the Ruby equivalent test and some tests ported from
+# Examples/test-suite/ruby/cpp11_shared_ptr_upcast_runme.rb are not working and commented out with:
+# not working:
+
+def swig_assert_equal_simple(expected, got):
+ if expected != got:
+ raise RuntimeError("Expected: {}. Got: {}")
+
+# non-overloaded
+swig_assert_equal_simple(7, derived_num1(Derived(7)))
+swig_assert_equal_simple(7, derived_num2([Derived(7)]))
+swig_assert_equal_simple(7, derived_num3({0: Derived(7)}))
+
+swig_assert_equal_simple(-1, base_num1(Derived(7)))
+swig_assert_equal_simple(-1, base_num2([Derived(7)]))
+swig_assert_equal_simple(-1, base_num3({0: Derived(7)}))
+
+swig_assert_equal_simple(999, derived_num1(None))
+# not working: swig_assert_equal_simple(999, derived_num2([None]))
+# not working: swig_assert_equal_simple(999, derived_num3({0: None}))
+
+swig_assert_equal_simple(999, base_num1(None))
+# not working: swig_assert_equal_simple(999, base_num2([None]))
+# not working: swig_assert_equal_simple(999, base_num3({0: None}))
+
+# overloaded
+swig_assert_equal_simple(7, derived_num(Derived(7)))
+swig_assert_equal_simple(7, derived_num([Derived(7)]))
+swig_assert_equal_simple(7, derived_num({0: Derived(7)}))
+
+swig_assert_equal_simple(-1, base_num(Derived(7)))
+swig_assert_equal_simple(-1, base_num([Derived(7)]))
+swig_assert_equal_simple(-1, base_num({0: Derived(7)}))
+
+# ptr to shared_ptr
+swig_assert_equal_simple(7, derived2_num1(Derived2(7)))
+swig_assert_equal_simple(7, derived2_num2([Derived2(7)]))
+swig_assert_equal_simple(7, derived2_num3({0: Derived2(7)}))
+
+swig_assert_equal_simple(-1, base2_num1(Derived2(7)))
+
+# not working: try:
+# not working: # Upcast for pointers to shared_ptr in this generic framework has not been implemented
+# not working: swig_assert_equal_simple(-1, base2_num2([Derived2(7)]))
+# not working: raise RuntimeError, "Failed to catch TypeError"
+# not working: except TypeError:
+# not working: pass
+# not working: try:
+# not working: # Upcast for pointers to shared_ptr in this generic framework has not been implemented
+# not working: swig_assert_equal_simple(-1, base2_num3({0: Derived2(7)}))
+# not working: raise RuntimeError, "Failed to catch TypeError"
+# not working: except TypeError:
+# not working: pass
+
+swig_assert_equal_simple(888, derived2_num1(None))
+swig_assert_equal_simple(999, derived2_num2([None])) # although 888 would be more consistent
+swig_assert_equal_simple(999, derived2_num3({0: None})) # although 888 would be more consistent
+
+swig_assert_equal_simple(888, base2_num1(None))
+swig_assert_equal_simple(999, base2_num2([None])) # although 888 would be more consistent
+swig_assert_equal_simple(999, base2_num3({0: None})) # although 888 would be more consistent
diff --git a/Examples/test-suite/python/cpp11_li_std_array_runme.py b/Examples/test-suite/python/cpp11_std_array_runme.py
index 3b1ceb2f8..9e11a3e5b 100644
--- a/Examples/test-suite/python/cpp11_li_std_array_runme.py
+++ b/Examples/test-suite/python/cpp11_std_array_runme.py
@@ -1,9 +1,9 @@
-from cpp11_li_std_array import *
+from cpp11_std_array import *
import sys
def failed(a, b, msg):
- raise RuntimeError, msg + " " + str(list(a)) + " " + str(list(b))
+ raise RuntimeError(msg + " " + str(list(a)) + " " + str(list(b)))
def compare_sequences(a, b):
@@ -26,8 +26,8 @@ def steps_exception(swigarray, i, j, step):
a = swigarray[i::step]
else:
a = swigarray[i:j:step]
- raise RuntimeError, "swigarray[" + str(i) + ":" + str(j) + ":" + str(step) + "] missed steps exception for " + str(list(swigarray))
- except ValueError, e:
+ raise RuntimeError("swigarray[" + str(i) + ":" + str(j) + ":" + str(step) + "] missed steps exception for " + str(list(swigarray)))
+ except ValueError as e:
# print("exception: {}".format(e))
pass
@@ -43,16 +43,16 @@ def del_exception(swigarray, i, j, step):
del swigarray[i::step]
else:
del swigarray[i:j:step]
- raise RuntimeError, "swigarray[" + str(i) + ":" + str(j) + ":" + str(step) + "] missed del exception for " + str(list(swigarray))
- except ValueError, e:
+ raise RuntimeError("swigarray[" + str(i) + ":" + str(j) + ":" + str(step) + "] missed del exception for " + str(list(swigarray)))
+ except ValueError as e:
# print("exception: {}".format(e))
pass
def setslice_exception(swigarray, newval):
try:
swigarray[::] = newval
- raise RuntimeError, "swigarray[::] = " + str(newval) + " missed set exception for swigarray:" + str(list(swigarray))
- except TypeError, e:
+ raise RuntimeError("swigarray[::] = " + str(newval) + " missed set exception for swigarray:" + str(list(swigarray)))
+ except TypeError as e:
# print("exception: {}".format(e))
pass
diff --git a/Examples/test-suite/python/cpp11_uniform_initialization_runme.py b/Examples/test-suite/python/cpp11_uniform_initialization_runme.py
index ecb468ccb..b01557a6f 100644
--- a/Examples/test-suite/python/cpp11_uniform_initialization_runme.py
+++ b/Examples/test-suite/python/cpp11_uniform_initialization_runme.py
@@ -9,13 +9,13 @@ if var2.getX() != 2:
m = cpp11_uniform_initialization.MoreInit()
if m.charptr != None:
- raise RuntimeError, m.charptr
+ raise RuntimeError(m.charptr)
m.charptr = "hello sir"
if m.charptr != "hello sir":
- raise RuntimeError, m.charptr
+ raise RuntimeError(m.charptr)
if m.more1(m.vi) != 15:
- raise RuntimeError, m.vi
+ raise RuntimeError(m.vi)
if m.more1([-1, 1, 2]) != 2:
- raise RuntimeError, m.vi
+ raise RuntimeError(m.vi)
if m.more1() != 10:
raise RuntimeError
diff --git a/Examples/test-suite/python/cpp14_binary_integer_literals_runme.py b/Examples/test-suite/python/cpp14_binary_integer_literals_runme.py
new file mode 100644
index 000000000..8274ec6b5
--- /dev/null
+++ b/Examples/test-suite/python/cpp14_binary_integer_literals_runme.py
@@ -0,0 +1,16 @@
+from cpp14_binary_integer_literals import *
+
+if cvar.b1 != 1:
+ raise RuntimeError
+
+if cvar.b2 != 2:
+ raise RuntimeError
+
+if cvar.b3 != 3:
+ raise RuntimeError
+
+if cvar.b4 != 4:
+ raise RuntimeError
+
+if cvar.b5 != 5:
+ raise RuntimeError
diff --git a/Examples/test-suite/python/cpp17_hex_floating_literals_runme.py b/Examples/test-suite/python/cpp17_hex_floating_literals_runme.py
new file mode 100644
index 000000000..ed9f4d26b
--- /dev/null
+++ b/Examples/test-suite/python/cpp17_hex_floating_literals_runme.py
@@ -0,0 +1,28 @@
+from cpp17_hex_floating_literals import *
+
+if cvar.f1 != 0.:
+ raise RuntimeError
+
+if cvar.f2 != 0.:
+ raise RuntimeError
+
+if cvar.f3 != 0.:
+ raise RuntimeError
+
+if cvar.f4 != 7.5:
+ raise RuntimeError
+
+if cvar.f5 != 20.:
+ raise RuntimeError
+
+if cvar.f6 != 64.:
+ raise RuntimeError
+
+if cvar.f7 != 11452.:
+ raise RuntimeError
+
+if cvar.f8 != 149140.:
+ raise RuntimeError
+
+if cvar.f9 != 18253638.:
+ raise RuntimeError
diff --git a/Examples/test-suite/python/cpp17_nested_namespaces_runme.py b/Examples/test-suite/python/cpp17_nested_namespaces_runme.py
new file mode 100644
index 000000000..562216625
--- /dev/null
+++ b/Examples/test-suite/python/cpp17_nested_namespaces_runme.py
@@ -0,0 +1,18 @@
+from cpp17_nested_namespaces import *
+
+A1Struct().A1Method()
+B1Struct().B1Method()
+C1Struct().C1Method()
+createA1Struct().A1Method()
+createB1Struct().B1Method()
+createC1Struct().C1Method()
+
+B2Struct().B2Method()
+C2Struct().C2Method()
+createB2Struct().B2Method()
+createC2Struct().C2Method()
+
+B3Struct().B3Method()
+C3Struct().C3Method()
+createB3Struct().B3Method()
+createC3Struct().C3Method()
diff --git a/Examples/test-suite/python/cpp17_u8_char_literals_runme.py b/Examples/test-suite/python/cpp17_u8_char_literals_runme.py
new file mode 100644
index 000000000..e2f8897f3
--- /dev/null
+++ b/Examples/test-suite/python/cpp17_u8_char_literals_runme.py
@@ -0,0 +1,10 @@
+from cpp17_u8_char_literals import *
+
+if cvar.a != "a":
+ raise RuntimeError
+
+if cvar.u != "u":
+ raise RuntimeError
+
+if cvar.u8 != "8":
+ raise RuntimeError
diff --git a/Examples/test-suite/python/cpp_enum_runme.py b/Examples/test-suite/python/cpp_enum_runme.py
index 5f1e91c97..910d378e4 100644
--- a/Examples/test-suite/python/cpp_enum_runme.py
+++ b/Examples/test-suite/python/cpp_enum_runme.py
@@ -3,21 +3,17 @@ import cpp_enum
f = cpp_enum.Foo()
if f.hola != f.Hello:
- print f.hola
- raise RuntimeError
+ raise RuntimeError("f.hola: {}".format(f.hola))
f.hola = f.Hi
if f.hola != f.Hi:
- print f.hola
- raise RuntimeError
+ raise RuntimeError("f.hola: {}".format(f.hola))
f.hola = f.Hello
if f.hola != f.Hello:
- print f.hola
- raise RuntimeError
+ raise RuntimeError("f.hola: {}".format(f.hola))
cpp_enum.cvar.hi = cpp_enum.Hello
if cpp_enum.cvar.hi != cpp_enum.Hello:
- print cpp_enum.cvar.hi
- raise RuntimeError
+ raise RuntimeError("cpp_enum.cvar.hi: {}".format(cpp_enum.cvar.hi))
diff --git a/Examples/test-suite/python/cpp_parameters_runme.py b/Examples/test-suite/python/cpp_parameters_runme.py
new file mode 100644
index 000000000..99d14ad74
--- /dev/null
+++ b/Examples/test-suite/python/cpp_parameters_runme.py
@@ -0,0 +1,296 @@
+from cpp_parameters import *
+
+# Testing correct and incorrect parameter counts being passed (kwargs and non-kwargs)
+# Note that the implementation depends a lot on whether zero, one, two or more args are being wrapped
+
+def is_python_fastproxy():
+ """Return True if SWIG is generating Python code using -fastproxy."""
+ import cpp_parameters
+ # Note: _swig_new_instance_method is only generated when using -fastproxy
+ return hasattr(cpp_parameters, "_swig_new_instance_method")
+
+# Zero parameters expected
+x = Zero()
+try:
+ x = Zero(z=0)
+ raise RuntimeError("Missed throw")
+except TypeError:
+ pass
+try:
+ x = Zero(0)
+ raise RuntimeError("Missed throw")
+except TypeError:
+ pass
+
+try:
+ x.zero(z=0)
+ raise RuntimeError("Missed throw")
+except TypeError:
+ pass
+try:
+ x.zero(0)
+ raise RuntimeError("Missed throw")
+except TypeError:
+ pass
+
+try:
+ Zero.stat_zero(z=0)
+ raise RuntimeError("Missed throw")
+except TypeError:
+ pass
+try:
+ Zero.stat_zero(0)
+ raise RuntimeError("Missed throw")
+except TypeError:
+ pass
+
+try:
+ global_zero(z=0)
+ raise RuntimeError("Missed throw")
+except TypeError:
+ pass
+try:
+ global_zero(0)
+ raise RuntimeError("Missed throw")
+except TypeError:
+ pass
+
+# One mandatory parameter expected
+x = One(1)
+try:
+ x = One(a=1, z=0)
+ raise RuntimeError("Missed throw")
+except TypeError:
+ pass
+try:
+ x = One(1, 0)
+ raise RuntimeError("Missed throw")
+except TypeError:
+ pass
+
+try:
+ x.one(a=1, z=0)
+ raise RuntimeError("Missed throw")
+except TypeError:
+ pass
+try:
+ x.one(1, 0)
+ raise RuntimeError("Missed throw")
+except TypeError:
+ pass
+
+try:
+ One.stat_one(a=1, z=0)
+ raise RuntimeError("Missed throw")
+except TypeError:
+ pass
+try:
+ One.stat_one(1, 0)
+ raise RuntimeError("Missed throw")
+except TypeError:
+ pass
+
+try:
+ global_one(a=1, z=0)
+ raise RuntimeError("Missed throw")
+except TypeError:
+ pass
+try:
+ global_one(1, 0)
+ raise RuntimeError("Missed throw")
+except TypeError:
+ pass
+
+# Two mandatory parameters expected
+x = Two(1, 2)
+try:
+ x = Two(a=1, b=2, z=0)
+ raise RuntimeError("Missed throw")
+except TypeError:
+ pass
+try:
+ x = Two(1, 2, 0)
+ raise RuntimeError("Missed throw")
+except TypeError:
+ pass
+
+try:
+ x.two(a=1, b=2, z=0)
+ raise RuntimeError("Missed throw")
+except TypeError:
+ pass
+try:
+ x.two(1, 2, 0)
+ raise RuntimeError("Missed throw")
+except TypeError:
+ pass
+
+try:
+ Two.stat_two(a=1, b=2, z=0)
+ raise RuntimeError("Missed throw")
+except TypeError:
+ pass
+try:
+ Two.stat_two(1, 2, 0)
+ raise RuntimeError("Missed throw")
+except TypeError:
+ pass
+
+try:
+ global_two(a=1, b=2, z=0)
+ raise RuntimeError("Missed throw")
+except TypeError:
+ pass
+try:
+ global_two(1, 2, 0)
+ raise RuntimeError("Missed throw")
+except TypeError:
+ pass
+
+# Single optional parameter expected
+x = Single(1)
+try:
+ x = Single(a=1, z=0)
+ raise RuntimeError("Missed throw")
+except TypeError:
+ pass
+try:
+ x = Single(1, 0)
+ raise RuntimeError("Missed throw")
+except TypeError:
+ pass
+
+try:
+ x.single(a=1, z=0)
+ raise RuntimeError("Missed throw")
+except TypeError:
+ pass
+try:
+ x.single(1, 0)
+ raise RuntimeError("Missed throw")
+except TypeError:
+ pass
+
+try:
+ Single.stat_single(a=1, z=0)
+ raise RuntimeError("Missed throw")
+except TypeError:
+ pass
+try:
+ Single.stat_single(1, 0)
+ raise RuntimeError("Missed throw")
+except TypeError:
+ pass
+
+try:
+ global_single(a=1, z=0)
+ raise RuntimeError("Missed throw")
+except TypeError:
+ pass
+try:
+ global_single(1, 0)
+ raise RuntimeError("Missed throw")
+except TypeError:
+ pass
+
+# Test that -builtin option throws TypeError if kwargs are used even when they look like they should work, kwargs are not supported unless using -keyword.
+# Also same for -fastproxy option except that kwargs are supported by default for constructors. TODO: Fix inconsistency.
+
+if is_python_builtin() or is_python_fastproxy():
+ # One mandatory parameter in API
+ x = One(1)
+ if is_python_fastproxy():
+ x = One(a=1)
+ else:
+ try:
+ x = One(a=1)
+ raise RuntimeError("Missed throw")
+ except TypeError:
+ pass
+ try:
+ x.one(a=1)
+ raise RuntimeError("Missed throw")
+ except TypeError:
+ pass
+ try:
+ One.stat_one(a=1)
+ raise RuntimeError("Missed throw")
+ except TypeError:
+ pass
+ try:
+ global_one(a=1)
+ raise RuntimeError("Missed throw")
+ except TypeError:
+ pass
+
+ # Two mandatory parameters in API
+ x = Two(1, 2)
+ if is_python_fastproxy():
+ x = Two(a=1, b=2)
+ else:
+ try:
+ x = Two(a=1, b=2)
+ raise RuntimeError("Missed throw")
+ except TypeError:
+ pass
+ try:
+ x.two(a=1, b=2)
+ raise RuntimeError("Missed throw")
+ except TypeError:
+ pass
+ try:
+ Two.stat_two(a=1, b=2)
+ raise RuntimeError("Missed throw")
+ except TypeError:
+ pass
+ try:
+ global_two(a=1, b=2)
+ raise RuntimeError("Missed throw")
+ except TypeError:
+ pass
+
+ # Single optional parameter in API
+ x = Single(1)
+ if is_python_fastproxy():
+ x = Single(a=1)
+ else:
+ try:
+ x = Single(a=1)
+ raise RuntimeError("Missed throw")
+ except TypeError:
+ pass
+ try:
+ x.single(a=1)
+ raise RuntimeError("Missed throw")
+ except TypeError:
+ pass
+ try:
+ Single.stat_single(a=1)
+ raise RuntimeError("Missed throw")
+ except TypeError:
+ pass
+ try:
+ global_single(a=1)
+ raise RuntimeError("Missed throw")
+ except TypeError:
+ pass
+
+else:
+ # Non-builtin should work as expected
+ # One mandatory parameter in API
+ x = One(a=1)
+ x.one(a=1)
+ One.stat_one(a=1)
+ global_one(a=1)
+
+ # Two mandatory parameters in API
+ x = Two(a=1, b=2)
+ x.two(a=1, b=2)
+ Two.stat_two(a=1, b=2)
+ global_two(a=1, b=2)
+
+ # Single optional parameter in API
+ x = Single(a=1)
+ x.single(a=1)
+ Single.stat_single(a=1)
+ global_single(a=1)
diff --git a/Examples/test-suite/python/cpp_static_runme.py b/Examples/test-suite/python/cpp_static_runme.py
index ef31f88af..cd7398fbb 100644
--- a/Examples/test-suite/python/cpp_static_runme.py
+++ b/Examples/test-suite/python/cpp_static_runme.py
@@ -2,29 +2,27 @@
from cpp_static import *
-def is_new_style_class(cls):
- return hasattr(cls, "__class__")
-
-if is_new_style_class(StaticFunctionTest):
- StaticFunctionTest.static_func()
- StaticFunctionTest.static_func_2(1)
- StaticFunctionTest.static_func_3(1, 2)
-else:
- StaticFunctionTest().static_func()
- StaticFunctionTest().static_func_2(1)
- StaticFunctionTest().static_func_3(1, 2)
+StaticFunctionTest.static_func()
+StaticFunctionTest.static_func_2(1)
+StaticFunctionTest.static_func_3(1, 2)
if is_python_builtin():
if not StaticMemberTest.static_int == 99: raise RuntimeError("static_int not 99")
+ if not StaticMemberTest.grab_int() == 99: raise RuntimeError("static_int not 99")
StaticMemberTest.static_int = 10
if not StaticMemberTest.static_int == 10: raise RuntimeError("static_int not 10")
+ if not StaticMemberTest.grab_int() == 10: raise RuntimeError("static_int not 10")
if not StaticBase.statty == 11: raise RuntimeError("statty not 11")
+ if not StaticBase.grab_statty_base() == 11: raise RuntimeError("statty not 11")
if not StaticDerived.statty == 111: raise RuntimeError("statty not 111")
+ if not StaticDerived.grab_statty_derived() == 111: raise RuntimeError("statty not 111")
StaticBase.statty = 22
StaticDerived.statty = 222
if not StaticBase.statty == 22: raise RuntimeError("statty not 22")
+ if not StaticBase.grab_statty_base() == 22: raise RuntimeError("statty not 22")
if not StaticDerived.statty == 222: raise RuntimeError("statty not 222")
+ if not StaticDerived.grab_statty_derived() == 222: raise RuntimeError("statty not 222")
# Restore
StaticMemberTest.static_int = 99
@@ -32,12 +30,43 @@ if is_python_builtin():
StaticDerived.statty = 111
if not cvar.StaticMemberTest_static_int == 99: raise RuntimeError("cvar static_int not 99")
+if not StaticMemberTest.grab_int() == 99: raise RuntimeError("cvar static_int not 99")
cvar.StaticMemberTest_static_int = 10
if not cvar.StaticMemberTest_static_int == 10: raise RuntimeError("cvar static_int not 10")
+if not StaticMemberTest.grab_int() == 10: raise RuntimeError("cvar static_int not 10")
if not cvar.StaticBase_statty == 11: raise RuntimeError("cvar statty not 11")
+if not StaticBase.grab_statty_base() == 11: raise RuntimeError("cvar statty not 11")
if not cvar.StaticDerived_statty == 111: raise RuntimeError("cvar statty not 111")
+if not StaticDerived.grab_statty_derived() == 111: raise RuntimeError("cvar statty not 111")
cvar.StaticBase_statty = 22
cvar.StaticDerived_statty = 222
if not cvar.StaticBase_statty == 22: raise RuntimeError("cvar statty not 22")
+if not StaticBase.grab_statty_base() == 22: raise RuntimeError("cvar statty not 22")
if not cvar.StaticDerived_statty == 222: raise RuntimeError("cvar statty not 222")
+if not StaticDerived.grab_statty_derived() == 222: raise RuntimeError("cvar statty not 222")
+
+# Restore
+cvar.StaticMemberTest_static_int = 99
+cvar.StaticBase_statty = 11
+cvar.StaticDerived_statty = 111
+
+# Low-level layer testing
+if not is_python_builtin():
+ from cpp_static import _cpp_static
+ if not _cpp_static.StaticMemberTest_static_int_get() == 99: raise RuntimeError("low-level static_int not 99")
+ if not StaticMemberTest.grab_int() == 99: raise RuntimeError("low-level static_int not 99")
+ _cpp_static.StaticMemberTest_static_int_set(10)
+ if not _cpp_static.StaticMemberTest_static_int_get() == 10: raise RuntimeError("low-level static_int not 10")
+ if not StaticMemberTest.grab_int() == 10: raise RuntimeError("low-level static_int not 10")
+
+ if not _cpp_static.StaticBase_statty_get() == 11: raise RuntimeError("low-level statty not 11")
+ if not StaticBase.grab_statty_base() == 11: raise RuntimeError("low-level statty not 11")
+ if not _cpp_static.StaticDerived_statty_get() == 111: raise RuntimeError("low-level statty not 111")
+ if not StaticDerived.grab_statty_derived() == 111: raise RuntimeError("low-level statty not 111")
+ _cpp_static.StaticBase_statty_set(22)
+ _cpp_static.StaticDerived_statty_set(222)
+ if not _cpp_static.StaticBase_statty_get() == 22: raise RuntimeError("low-level statty not 22")
+ if not StaticBase.grab_statty_base() == 22: raise RuntimeError("low-level statty not 22")
+ if not _cpp_static.StaticDerived_statty_get() == 222: raise RuntimeError("low-level statty not 222")
+ if not StaticDerived.grab_statty_derived() == 222: raise RuntimeError("low-level statty not 222")
diff --git a/Examples/test-suite/python/default_args_c_runme.py b/Examples/test-suite/python/default_args_c_runme.py
index 5985fd75c..65ca9178f 100644
--- a/Examples/test-suite/python/default_args_c_runme.py
+++ b/Examples/test-suite/python/default_args_c_runme.py
@@ -4,3 +4,23 @@ if default_args_c.foo1() != 1:
raise RuntimeError("failed")
if default_args_c.foo43() != 43:
raise RuntimeError("failed")
+
+f = default_args_c.FooStruct()
+f.no_arg()
+f.one_req(None)
+f.one_opt()
+f.one_opt(None)
+f.two_arg(None)
+f.two_arg(None, None)
+
+default_args_c.StaticStruct.no_arg()
+default_args_c.StaticStruct.one_req(None)
+default_args_c.StaticStruct.one_opt()
+default_args_c.StaticStruct.one_opt(None)
+default_args_c.StaticStruct.two_arg(None)
+default_args_c.StaticStruct.two_arg(None, None)
+
+default_args_c.global_opts1()
+default_args_c.global_opts1(None)
+default_args_c.global_opts2(None)
+default_args_c.global_opts2(None, None)
diff --git a/Examples/test-suite/python/default_args_runme.py b/Examples/test-suite/python/default_args_runme.py
index 9d275e4a1..0ce47ab79 100644
--- a/Examples/test-suite/python/default_args_runme.py
+++ b/Examples/test-suite/python/default_args_runme.py
@@ -2,10 +2,6 @@
# the use of __main__ and the run function
-def is_new_style_class(cls):
- return hasattr(cls, "__class__")
-
-
def run(module_name):
default_args = __import__(module_name)
ec = default_args.EnumClass()
@@ -32,6 +28,8 @@ def run(module_name):
f.newname()
f.newname(1)
+ f.defaulted1()
+ f.defaulted2()
if f.double_if_void_ptr_is_null(2, None) != 4:
raise RuntimeError
@@ -99,10 +97,7 @@ def run(module_name):
if error:
raise RuntimeError("Foo::meth ignore is not working")
- if is_new_style_class(default_args.Klass):
- Klass_inc = default_args.Klass.inc
- else:
- Klass_inc = default_args.Klass_inc
+ Klass_inc = default_args.Klass.inc
if Klass_inc(100, default_args.Klass(22)).val != 122:
raise RuntimeError("Klass::inc failed")
@@ -113,15 +108,40 @@ def run(module_name):
if Klass_inc().val != 0:
raise RuntimeError("Klass::inc failed")
- default_args.trickyvalue1(10)
- default_args.trickyvalue1(10, 10)
- default_args.trickyvalue2(10)
- default_args.trickyvalue2(10, 10)
- default_args.trickyvalue3(10)
- default_args.trickyvalue3(10, 10)
+ tricky = default_args.TrickyInPython()
+ if tricky.value_m1(10) != -1:
+ raise RuntimeError("trickyvalue_m1 failed")
+ if tricky.value_m1(10, 10) != 10:
+ raise RuntimeError("trickyvalue_m1 failed")
+ if tricky.value_0xabcdef(10) != 0xabcdef:
+ raise RuntimeError("trickyvalue_0xabcdef failed")
+ if tricky.value_0644(10) != 420:
+ raise RuntimeError("trickyvalue_0644 failed")
+ if tricky.value_perm(10) != 420:
+ raise RuntimeError("trickyvalue_perm failed")
+ if tricky.value_m01(10) != -1:
+ raise RuntimeError("trickyvalue_m01 failed")
+ if not tricky.booltest2():
+ raise RuntimeError("booltest2 failed")
+
+ if tricky.max_32bit_int1() != 0x7FFFFFFF:
+ raise RuntimeError("max_32bit_int1 failed")
+ if tricky.min_32bit_int1() != -2147483648:
+ raise RuntimeError("min_32bit_int1 failed")
+ if tricky.max_32bit_int2() != 0x7FFFFFFF:
+ raise RuntimeError("max_32bit_int2 failed")
+
+ tricky.too_big_32bit_int1()
+ tricky.too_small_32bit_int1()
+ tricky.too_big_32bit_int2()
+ tricky.too_small_32bit_int2()
+
default_args.seek()
default_args.seek(10)
+ if not default_args.booltest():
+ raise RuntimeError("booltest failed")
+
if default_args.slightly_off_square(10) != 102:
raise RuntimeError
@@ -136,23 +156,23 @@ def run(module_name):
if default_args.CDA().cdefaultargs_test2() != 1:
raise RuntimeError
- if default_args.chartest1() != 'x':
+ if default_args.chartest1() != "x":
raise RuntimeError
- if default_args.chartest2() != '\0':
+ if default_args.chartest2() != "\0":
raise RuntimeError
- if default_args.chartest3() != '\1':
+ if default_args.chartest3() != "\1":
raise RuntimeError
- if default_args.chartest4() != '\n':
+ if default_args.chartest4() != "\n":
raise RuntimeError
- if default_args.chartest5() != 'B':
+ if default_args.chartest5() != "B":
raise RuntimeError
- if default_args.chartest6() != 'C':
+ if default_args.chartest6() != "C":
raise RuntimeError
if __name__ == "__main__":
- run('default_args')
+ run("default_args")
diff --git a/Examples/test-suite/python/default_constructor_runme.py b/Examples/test-suite/python/default_constructor_runme.py
index 1e877adda..2943dc960 100644
--- a/Examples/test-suite/python/default_constructor_runme.py
+++ b/Examples/test-suite/python/default_constructor_runme.py
@@ -16,24 +16,24 @@ dc.delete_AA(aa)
try:
b = dc.new_B()
- print "Whoa. new_BB created."
-except:
+ raise RuntimeError("Whoa. new_BB created.")
+except TypeError:
pass
del_b = dc.delete_B
try:
bb = dc.new_BB()
- print "Whoa. new_BB created."
-except:
+ raise RuntimeError("Whoa. new_BB created.")
+except AttributeError:
pass
del_bb = dc.delete_BB
try:
c = dc.new_C()
- print "Whoa. new_C created."
-except:
+ raise RuntimeError("Whoa. new_C created.")
+except AttributeError:
pass
del_c = dc.delete_C
@@ -43,24 +43,24 @@ dc.delete_CC(cc)
try:
d = dc.new_D()
- print "Whoa. new_D created"
-except:
+ raise RuntimeError("Whoa. new_D created")
+except AttributeError:
pass
del_d = dc.delete_D
try:
dd = dc.new_DD()
- print "Whoa. new_DD created"
-except:
+ raise RuntimeError("Whoa. new_DD created")
+except AttributeError:
pass
dd = dc.delete_DD
try:
ad = dc.new_AD()
- print "Whoa. new_AD created"
-except:
+ raise RuntimeError("Whoa. new_AD created")
+except AttributeError:
pass
del_ad = dc.delete_AD
@@ -73,8 +73,8 @@ dc.delete_EE(ee)
try:
eb = dc.new_EB()
- print "Whoa. new_EB created"
-except:
+ raise RuntimeError("Whoa. new_EB created")
+except AttributeError:
pass
del_eb = dc.delete_EB
@@ -83,7 +83,7 @@ f = dc.new_F()
try:
del_f = dc.delete_F
- print "Whoa. delete_F created"
+ raise RuntimeError("Whoa. delete_F created")
except AttributeError:
pass
@@ -93,7 +93,7 @@ g = dc.new_G()
try:
del_g = dc.delete_G
- print "Whoa. delete_G created"
+ raise RuntimeError("Whoa. delete_G created")
except AttributeError:
pass
diff --git a/Examples/test-suite/python/director_abstract_runme.py b/Examples/test-suite/python/director_abstract_runme.py
index 031c476d8..c8c4b36dc 100644
--- a/Examples/test-suite/python/director_abstract_runme.py
+++ b/Examples/test-suite/python/director_abstract_runme.py
@@ -1,10 +1,6 @@
import director_abstract
-def is_new_style_class(cls):
- return hasattr(cls, "__class__")
-
-
class MyFoo(director_abstract.Foo):
def __init__(self):
@@ -17,10 +13,10 @@ class MyFoo(director_abstract.Foo):
a = MyFoo()
if a.ping() != "MyFoo::ping()":
- raise RuntimeError, a.ping()
+ raise RuntimeError(a.ping())
if a.pong() != "Foo::pong();MyFoo::ping()":
- raise RuntimeError, a.pong()
+ raise RuntimeError(a.pong())
class MyExample1(director_abstract.Example1):
@@ -44,20 +40,12 @@ me1 = MyExample1()
if director_abstract.Example1_get_color(me1, 1, 2, 3) != 1:
raise RuntimeError
-if is_new_style_class(MyExample2):
- MyExample2_static = MyExample2
-else:
- MyExample2_static = MyExample2(0, 0)
me2 = MyExample2(1, 2)
-if MyExample2_static.get_color(me2, 1, 2, 3) != 2:
+if MyExample2.get_color(me2, 1, 2, 3) != 2:
raise RuntimeError
-if is_new_style_class(MyExample3):
- MyExample3_static = MyExample3
-else:
- MyExample3_static = MyExample3()
me3 = MyExample3()
-if MyExample3_static.get_color(me3, 1, 2, 3) != 3:
+if MyExample3.get_color(me3, 1, 2, 3) != 3:
raise RuntimeError
error = 1
diff --git a/Examples/test-suite/python/director_alternating_runme.py b/Examples/test-suite/python/director_alternating_runme.py
index a93ffec34..dc85351b5 100644
--- a/Examples/test-suite/python/director_alternating_runme.py
+++ b/Examples/test-suite/python/director_alternating_runme.py
@@ -2,4 +2,4 @@ from director_alternating import *
id = getBar().id()
if id != idFromGetBar():
- raise RuntimeError, "Got wrong id: " + str(id)
+ raise RuntimeError("Got wrong id: " + str(id))
diff --git a/Examples/test-suite/python/director_basic_runme.py b/Examples/test-suite/python/director_basic_runme.py
index 6564c95a2..79cd0e2eb 100644
--- a/Examples/test-suite/python/director_basic_runme.py
+++ b/Examples/test-suite/python/director_basic_runme.py
@@ -10,18 +10,18 @@ class PyFoo(director_basic.Foo):
a = PyFoo()
if a.ping() != "PyFoo::ping()":
- raise RuntimeError, a.ping()
+ raise RuntimeError(a.ping())
if a.pong() != "Foo::pong();PyFoo::ping()":
- raise RuntimeError, a.pong()
+ raise RuntimeError(a.pong())
b = director_basic.Foo()
if b.ping() != "Foo::ping()":
- raise RuntimeError, b.ping()
+ raise RuntimeError(b.ping())
if b.pong() != "Foo::pong();Foo::ping()":
- raise RuntimeError, b.pong()
+ raise RuntimeError(b.pong())
a = director_basic.A1(1)
diff --git a/Examples/test-suite/python/director_comparison_operators_runme.py b/Examples/test-suite/python/director_comparison_operators_runme.py
new file mode 100644
index 000000000..e9bf9438d
--- /dev/null
+++ b/Examples/test-suite/python/director_comparison_operators_runme.py
@@ -0,0 +1,11 @@
+import director_comparison_operators
+
+
+class PyFoo(director_comparison_operators.Foo):
+ pass
+
+
+a = PyFoo()
+
+if a.test() != "a=1,b=2":
+ raise RuntimeError(a.test())
diff --git a/Examples/test-suite/python/director_detect_runme.py b/Examples/test-suite/python/director_detect_runme.py
index 345051982..b9c73eb45 100644
--- a/Examples/test-suite/python/director_detect_runme.py
+++ b/Examples/test-suite/python/director_detect_runme.py
@@ -35,4 +35,4 @@ c = b.clone()
vc = c.get_value()
if (v != 3) or (b.val != 5) or (vc != 6):
- raise RuntimeError, "Bad virtual detection"
+ raise RuntimeError("Bad virtual detection")
diff --git a/Examples/test-suite/python/director_exception_runme.py b/Examples/test-suite/python/director_exception_runme.py
index 892c7e653..458983c6a 100644
--- a/Examples/test-suite/python/director_exception_runme.py
+++ b/Examples/test-suite/python/director_exception_runme.py
@@ -10,7 +10,7 @@ class MyException(Exception):
class MyFoo(Foo):
def ping(self):
- raise NotImplementedError, "MyFoo::ping() EXCEPTION"
+ raise NotImplementedError("MyFoo::ping() EXCEPTION")
class MyFoo2(Foo):
@@ -25,54 +25,62 @@ class MyFoo3(Foo):
def ping(self):
raise MyException("foo", "bar")
+class MyFoo4(Foo):
+
+ def ping(self, *args):
+ t = type("bad", "call") # throws TypeError message: type() takes 1 or 3 arguments
+ return "Foo4.ping"
+
+
# Check that the NotImplementedError raised by MyFoo.ping() is returned by
# MyFoo.pong().
-ok = 0
a = MyFoo()
b = launder(a)
try:
b.pong()
-except NotImplementedError, e:
- if str(e) == "MyFoo::ping() EXCEPTION":
- ok = 1
- else:
- print "Unexpected error message: %s" % str(e)
-except:
+ raise RuntimeError("Exception was not thrown")
+except NotImplementedError as e:
+ if not str(e) == "MyFoo::ping() EXCEPTION":
+ raise RuntimeError("Unexpected error message: %s" % str(e))
+except TypeError:
pass
-if not ok:
- raise RuntimeError
# Check that the director returns the appropriate TypeError if the return type
# is wrong.
-ok = 0
a = MyFoo2()
b = launder(a)
try:
b.pong()
-except TypeError, e:
- if str(e) == "SWIG director type mismatch in output value of type 'std::string'":
- ok = 1
- else:
- print "Unexpected error message: %s" % str(e)
-if not ok:
- raise RuntimeError
+ raise RuntimeError("Exception was not thrown")
+except TypeError as e:
+ # fastdispatch mode adds on Additional Information to the exception message - just check the main exception message exists
+ if not str(e).startswith("SWIG director type mismatch in output value of type 'std::string'"):
+ raise RuntimeError("Unexpected error message: %s" % str(e))
# Check that the director can return an exception which requires two arguments
# to the constructor, without mangling it.
-ok = 0
a = MyFoo3()
b = launder(a)
try:
b.pong()
-except MyException, e:
- if e.msg == 'foobar':
- ok = 1
- else:
- print "Unexpected error message: %s" % str(e)
-if not ok:
- raise RuntimeError
+ raise RuntimeError("Exception was not thrown")
+except MyException as e:
+ if e.msg != "foobar":
+ raise RuntimeError("Unexpected error message: %s" % str(e))
+
+
+# Check that the director returns the appropriate TypeError thrown in a director method
+a = MyFoo4()
+b = launder(a)
+try:
+ b.pong()
+ raise RuntimeError("Exception was not thrown")
+except TypeError as e:
+ if not str(e).startswith("type() takes 1 or 3 arguments"):
+ raise RuntimeError("Unexpected error message: %s" % str(e))
+
# This is expected to fail with -builtin option
# Throwing builtin classes as exceptions not supported
diff --git a/Examples/test-suite/python/director_extend_runme.py b/Examples/test-suite/python/director_extend_runme.py
index a5aad8245..870443d1f 100644
--- a/Examples/test-suite/python/director_extend_runme.py
+++ b/Examples/test-suite/python/director_extend_runme.py
@@ -17,6 +17,6 @@ class MyObject(SpObject):
m = MyObject()
if m.dummy() != 666:
- raise RuntimeError, "1st call"
+ raise RuntimeError("1st call")
if m.dummy() != 666: # Locked system
- raise RuntimeError, "2nd call"
+ raise RuntimeError("2nd call")
diff --git a/Examples/test-suite/python/director_frob_runme.py b/Examples/test-suite/python/director_frob_runme.py
index 0ef4ad900..6c8fcad06 100644
--- a/Examples/test-suite/python/director_frob_runme.py
+++ b/Examples/test-suite/python/director_frob_runme.py
@@ -4,4 +4,4 @@ foo = Bravo()
s = foo.abs_method()
if s != "Bravo::abs_method()":
- raise RuntimeError, s
+ raise RuntimeError(s)
diff --git a/Examples/test-suite/python/director_nested_runme.py b/Examples/test-suite/python/director_nested_runme.py
index f3d973630..b2c4b0d40 100644
--- a/Examples/test-suite/python/director_nested_runme.py
+++ b/Examples/test-suite/python/director_nested_runme.py
@@ -14,7 +14,7 @@ class A(FooBar_int):
a = A()
if a.step() != "Bar::step;Foo::advance;Bar::do_advance;A::do_step;":
- raise RuntimeError, "Bad A virtual resolution"
+ raise RuntimeError("Bad A virtual resolution")
class B(FooBar_int):
@@ -34,7 +34,7 @@ class B(FooBar_int):
b = B()
if b.step() != "Bar::step;Foo::advance;B::do_advance;B::do_step;":
- raise RuntimeError, "Bad B virtual resolution"
+ raise RuntimeError("Bad B virtual resolution")
class C(FooBar_int):
diff --git a/Examples/test-suite/python/director_profile_runme.py b/Examples/test-suite/python/director_profile_runme.py
index 035007c61..7c269c3f7 100644
--- a/Examples/test-suite/python/director_profile_runme.py
+++ b/Examples/test-suite/python/director_profile_runme.py
@@ -38,4 +38,4 @@ while i:
a = fi(a) # 20
i -= 1
-print a
+print("a: {}".format(a))
diff --git a/Examples/test-suite/python/director_protected_runme.py b/Examples/test-suite/python/director_protected_runme.py
index c3118a7c0..94eab69a6 100644
--- a/Examples/test-suite/python/director_protected_runme.py
+++ b/Examples/test-suite/python/director_protected_runme.py
@@ -35,7 +35,7 @@ try:
raise RuntimeError
pass
except:
- raise RuntimeError, "bad FooBar::used"
+ raise RuntimeError("bad FooBar::used")
try:
s = fb2.used()
@@ -43,7 +43,7 @@ try:
raise RuntimeError
pass
except:
- raise RuntimeError, "bad FooBar2::used"
+ raise RuntimeError("bad FooBar2::used")
try:
s = b.pong()
@@ -51,7 +51,7 @@ try:
raise RuntimeError
pass
except:
- raise RuntimeError, "bad Bar::pong"
+ raise RuntimeError("bad Bar::pong")
try:
s = f.pong()
@@ -59,7 +59,7 @@ try:
raise RuntimeError
pass
except:
- raise RuntimeError, " bad Foo::pong"
+ raise RuntimeError(" bad Foo::pong")
try:
s = fb.pong()
@@ -67,7 +67,7 @@ try:
raise RuntimeError
pass
except:
- raise RuntimeError, " bad FooBar::pong"
+ raise RuntimeError(" bad FooBar::pong")
protected = 1
try:
@@ -76,7 +76,7 @@ try:
except:
pass
if not protected:
- raise RuntimeError, "Foo::ping is protected"
+ raise RuntimeError("Foo::ping is protected")
protected = 1
try:
@@ -85,7 +85,7 @@ try:
except:
pass
if not protected:
- raise RuntimeError, "Foo::ping is protected"
+ raise RuntimeError("Foo::ping is protected")
protected = 1
@@ -95,7 +95,7 @@ try:
except:
pass
if not protected:
- raise RuntimeError, "FooBar::pang is protected"
+ raise RuntimeError("FooBar::pang is protected")
protected = 1
@@ -105,7 +105,7 @@ try:
except:
pass
if not protected:
- raise RuntimeError, "Bar::cheer is protected"
+ raise RuntimeError("Bar::cheer is protected")
protected = 1
try:
@@ -114,19 +114,19 @@ try:
except:
pass
if not protected:
- raise RuntimeError, "Foo::cheer is protected"
+ raise RuntimeError("Foo::cheer is protected")
if fb3.cheer() != "FooBar3::cheer();":
- raise RuntimeError, "bad fb3::cheer"
+ raise RuntimeError("bad fb3::cheer")
if fb2.callping() != "FooBar2::ping();":
- raise RuntimeError, "bad fb2.callping"
+ raise RuntimeError("bad fb2.callping")
if fb2.callcheer() != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();":
- raise RuntimeError, "bad fb2.callcheer"
+ raise RuntimeError("bad fb2.callcheer")
if fb3.callping() != "Bar::ping();":
- raise RuntimeError, "bad fb3.callping"
+ raise RuntimeError("bad fb3.callping")
if fb3.callcheer() != "FooBar3::cheer();":
- raise RuntimeError, "bad fb3.callcheer"
+ raise RuntimeError("bad fb3.callcheer")
diff --git a/Examples/test-suite/python/director_smartptr_runme.py b/Examples/test-suite/python/director_smartptr_runme.py
index c8bab9d7a..b4cbafe32 100644
--- a/Examples/test-suite/python/director_smartptr_runme.py
+++ b/Examples/test-suite/python/director_smartptr_runme.py
@@ -15,9 +15,23 @@ class director_smartptr_MyBarFoo(Foo):
def makeFoo(self):
return Foo()
+class director_smartptr_MyBarFooDerived(FooDerived):
+
+ def ping(self):
+ return "director_smartptr_MyBarFooDerived.ping()"
+
+ def pong(self):
+ return "director_smartptr_MyBarFooDerived.pong();" + self.ping()
+
+ def upcall(self, fooBarPtr):
+ return "overrideDerived;" + fooBarPtr.FooBarDo()
+
+ def makeFoo(self):
+ return Foo()
+
def check(got, expected):
if (got != expected):
- raise RuntimeError, "Failed, got: " + got + " expected: " + expected
+ raise RuntimeError("Failed, got: " + got + " expected: " + expected)
fooBar = FooBar()
@@ -35,3 +49,8 @@ myFoo2 = Foo().makeFoo()
check(myFoo2.pong(), "Foo::pong();Foo::ping()")
check(Foo.callPong(myFoo2), "Foo::pong();Foo::ping()")
check(myFoo2.upcall(FooBar()), "Bar::Foo2::Foo2Bar()")
+
+myBarFooDerived = director_smartptr_MyBarFooDerived()
+check(myBarFooDerived.ping(), "director_smartptr_MyBarFooDerived.ping()")
+check(FooDerived.callPong(myBarFooDerived), "director_smartptr_MyBarFooDerived.pong();director_smartptr_MyBarFooDerived.ping()")
+check(FooDerived.callUpcall(myBarFooDerived, fooBar), "overrideDerived;Bar::Foo2::Foo2Bar()")
diff --git a/Examples/test-suite/python/director_string_runme.py b/Examples/test-suite/python/director_string_runme.py
index dcd47d647..c6d4c8121 100644
--- a/Examples/test-suite/python/director_string_runme.py
+++ b/Examples/test-suite/python/director_string_runme.py
@@ -18,12 +18,10 @@ b = B("hello")
b.get(0)
if b.get_first() != "hello world!":
- print b.get_first()
- raise RuntimeError
+ raise RuntimeError("b.get_first(): {}".format(b.get_first()))
b.call_process_func()
if b.smem != "hello":
- print smem
- raise RuntimeError
+ raise RuntimeError("smem: {}".format(smem))
diff --git a/Examples/test-suite/python/director_thread_runme.py b/Examples/test-suite/python/director_thread_runme.py
index 4fcf3bfd1..21a8ce1b0 100644
--- a/Examples/test-suite/python/director_thread_runme.py
+++ b/Examples/test-suite/python/director_thread_runme.py
@@ -14,7 +14,6 @@ d = Derived()
d.run()
if d.val >= 0:
- print d.val
- raise RuntimeError
+ raise RuntimeError("d.val: {}".format(d.val))
d.stop()
diff --git a/Examples/test-suite/python/director_unroll_runme.py b/Examples/test-suite/python/director_unroll_runme.py
index 60bc05585..ea602d8e2 100644
--- a/Examples/test-suite/python/director_unroll_runme.py
+++ b/Examples/test-suite/python/director_unroll_runme.py
@@ -16,5 +16,4 @@ c = b.get()
if not (a.this == c.this):
- print a, c
- raise RuntimeError
+ raise RuntimeError("{} {}".format(a, c))
diff --git a/Examples/test-suite/python/director_wstring_runme.py b/Examples/test-suite/python/director_wstring_runme.py
index 242b27582..5facc1f1d 100644
--- a/Examples/test-suite/python/director_wstring_runme.py
+++ b/Examples/test-suite/python/director_wstring_runme.py
@@ -7,22 +7,20 @@ class B(A):
A.__init__(self, string)
def get_first(self):
- return A.get_first(self) + u" world!"
+ return A.get_first(self) + " world!"
- def process_text(self, string):
- self.smem = u"hello"
+ def process_text(self, s):
+ self.smem = s
-b = B(u"hello")
+b = B("hello")
b.get(0)
-if b.get_first() != u"hello world!":
- print b.get_first()
- raise RuntimeError
+if b.get_first() != "hello world!":
+ raise RuntimeError("b.get_first(): {}".format(b.get_first()))
b.call_process_func()
-if b.smem != u"hello":
- print smem
- raise RuntimeError
+if b.smem != "hello":
+ raise RuntimeError("smem: {}".format(smem))
diff --git a/Examples/test-suite/python/doxygen_alias_runme.py b/Examples/test-suite/python/doxygen_alias_runme.py
new file mode 100644
index 000000000..505261bcd
--- /dev/null
+++ b/Examples/test-suite/python/doxygen_alias_runme.py
@@ -0,0 +1,10 @@
+import doxygen_alias
+import inspect
+import comment_verifier
+
+comment_verifier.check(inspect.getdoc(doxygen_alias.make_something),
+ """\
+A function returning something.
+
+:rtype: :py:class:`Something`
+:return: A new object which may be None.""")
diff --git a/Examples/test-suite/python/doxygen_basic_notranslate_runme.py b/Examples/test-suite/python/doxygen_basic_notranslate_runme.py
new file mode 100644
index 000000000..1e654effc
--- /dev/null
+++ b/Examples/test-suite/python/doxygen_basic_notranslate_runme.py
@@ -0,0 +1,66 @@
+import doxygen_basic_notranslate
+import inspect
+import string
+import sys
+import comment_verifier
+
+comment_verifier.check(inspect.getdoc(doxygen_basic_notranslate.function),
+ r"""\brief
+Brief description.
+
+The comment text
+\author Some author
+\return Some number
+\sa function2"""
+)
+
+comment_verifier.check(inspect.getdoc(doxygen_basic_notranslate.function1),
+ r"""Single line comment """
+)
+comment_verifier.check(inspect.getdoc(doxygen_basic_notranslate.function2),
+ r"""A test of a very very very very very very very very very very very very very very very very
+very very very very very long comment string."""
+)
+
+comment_verifier.check(inspect.getdoc(doxygen_basic_notranslate.function3),
+ r"""*Overload 1:*
+
+A test for overloaded functions
+This is function \b one
+
+|
+
+*Overload 2:*
+
+A test for overloaded functions
+This is function \b two"""
+)
+
+comment_verifier.check(inspect.getdoc(doxygen_basic_notranslate.function4),
+ r"""A test of some mixed tag usage
+\if CONDITION
+This \a code fragment shows us something \.
+\par Minuses:
+\arg it's senseless
+\arg it's stupid
+\arg it's null
+
+\warning This may not work as expected
+
+\code
+int main() { while(true); }
+\endcode
+\endif"""
+)
+comment_verifier.check(inspect.getdoc(doxygen_basic_notranslate.function5),
+ r"""This is a post comment. """
+)
+comment_verifier.check(inspect.getdoc(doxygen_basic_notranslate.function6),
+ r"""Test for default args
+@param a Some parameter, default is 42"""
+)
+comment_verifier.check(inspect.getdoc(doxygen_basic_notranslate.function7),
+ r"""Test for a parameter with difficult type
+(mostly for python)
+@param a Very strange param"""
+)
diff --git a/Examples/test-suite/python/doxygen_basic_translate_runme.py b/Examples/test-suite/python/doxygen_basic_translate_runme.py
new file mode 100644
index 000000000..4cd500178
--- /dev/null
+++ b/Examples/test-suite/python/doxygen_basic_translate_runme.py
@@ -0,0 +1,94 @@
+import doxygen_basic_translate
+import inspect
+import string
+import sys
+import comment_verifier
+
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function),
+ """\
+Brief description.
+
+The comment text.
+
+Author: Some author
+
+:rtype: int
+:return: Some number
+
+See also: function2"""
+)
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function2),
+ """\
+A test of a very very very very very very very very very very very very very very very very
+very very very very very long comment string."""
+)
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function3),
+ """*Overload 1:*
+
+A test for overloaded functions
+This is function **one**
+
+|
+
+*Overload 2:*
+
+A test for overloaded functions
+This is function **two**"""
+)
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function4),
+ """\
+A test of some mixed tag usage
+If: CONDITION {
+This *code* fragment shows us something .
+Title: Minuses:
+* it\'s senseless
+* it\'s stupid
+* it\'s null
+
+Warning: This may not work as expected
+
+.. code-block:: c++
+
+ int main() { while(true); }
+
+ // Test blank line in code block
+}"""
+)
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function5),
+ """This is a post comment."""
+)
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function6),
+ """\
+Test for default args
+:type a: int, optional
+:param a: Some parameter, default is 42"""
+)
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function7),
+ """\
+Test for a parameter with difficult type
+(mostly for python)
+:type a: :py:class:`Shape`
+:param a: Very strange param"""
+)
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function8),
+ """\
+Test variadic function
+:param ...: extra args"""
+)
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function9),
+ """\
+Test unnamed argument
+:param baz: Description of baz"""
+)
+
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate.Atan2),
+ """\
+Multiple parameters test.
+
+:type y: float
+:param y: Vertical coordinate.
+:type x: float
+:param x: Horizontal coordinate.
+:rtype: float
+:return: Arc tangent of ``y/x``."""
+)
diff --git a/Examples/test-suite/python/doxygen_basic_translate_style2_runme.py b/Examples/test-suite/python/doxygen_basic_translate_style2_runme.py
new file mode 100644
index 000000000..a24f5defc
--- /dev/null
+++ b/Examples/test-suite/python/doxygen_basic_translate_style2_runme.py
@@ -0,0 +1,82 @@
+import doxygen_basic_translate_style2
+import inspect
+import string
+import sys
+import comment_verifier
+
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style2.function),
+ """\
+Brief description.
+
+The comment text.
+
+Author: Some author
+
+:rtype: int
+:return: Some number
+
+See also: function2"""
+)
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style2.function2),
+ """\
+A test of a very very very very very very very very very very very very very very very very
+very very very very very long comment string."""
+)
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style2.function3),
+ """*Overload 1:*
+A test for overloaded functions
+This is function **one**
+
+|
+
+*Overload 2:*
+A test for overloaded functions
+This is function **two**"""
+)
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style2.function4),
+ """\
+A test of some mixed tag usage
+If: CONDITION {
+This *code* fragment shows us something .
+Title: Minuses:
+* it\'s senseless
+* it\'s stupid
+* it\'s null
+
+Warning: This may not work as expected
+
+.. code-block:: c++
+
+ int main() { while(true); }
+
+ // Test blank line in code block
+}"""
+)
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style2.function5),
+ """This is a post comment."""
+)
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style2.function6),
+ """\
+Test for default args
+:type a: int, optional
+:param a: Some parameter, default is 42"""
+)
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style2.function7),
+ """\
+Test for a parameter with difficult type
+(mostly for python)
+:type a: :py:class:`Shape`
+:param a: Very strange param"""
+)
+
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style2.Atan2),
+ """\
+Multiple parameters test.
+
+:type y: float
+:param y: Vertical coordinate.
+:type x: float
+:param x: Horizontal coordinate.
+:rtype: float
+:return: Arc tangent of ``y/x``."""
+)
diff --git a/Examples/test-suite/python/doxygen_basic_translate_style3_runme.py b/Examples/test-suite/python/doxygen_basic_translate_style3_runme.py
new file mode 100644
index 000000000..687270351
--- /dev/null
+++ b/Examples/test-suite/python/doxygen_basic_translate_style3_runme.py
@@ -0,0 +1,82 @@
+import doxygen_basic_translate_style3
+import inspect
+import string
+import sys
+import comment_verifier
+
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style3.function),
+ """\
+Brief description.
+
+The comment text.
+
+Author: Some author
+
+:rtype: int
+:return: Some number
+
+See also: function2"""
+)
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style3.function2),
+ """\
+A test of a very very very very very very very very very very very very very very very very
+very very very very very long comment string."""
+)
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style3.function3),
+ """*Overload 1:*
+A test for overloaded functions
+This is function **one**
+
+|
+
+*Overload 2:*
+A test for overloaded functions
+This is function **two**"""
+)
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style3.function4),
+ """\
+A test of some mixed tag usage
+If: CONDITION {
+This *code* fragment shows us something .
+Title: Minuses:
+* it\'s senseless
+* it\'s stupid
+* it\'s null
+
+Warning: This may not work as expected
+
+.. code-block:: c++
+
+ int main() { while(true); }
+
+ int testBlankLine() {}
+}"""
+)
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style3.function5),
+ """This is a post comment."""
+)
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style3.function6),
+ """\
+Test for default args
+:type a: int, optional
+:param a: Some parameter, default is 42"""
+)
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style3.function7),
+ """\
+Test for a parameter with difficult type
+(mostly for python)
+:type a: :py:class:`Shape`
+:param a: Very strange param"""
+)
+
+comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style3.Atan2),
+ """\
+Multiple parameters test.
+
+:type y: float
+:param y: Vertical coordinate.
+:type x: float
+:param x: Horizontal coordinate.
+:rtype: float
+:return: Arc tangent of ``y/x``."""
+)
diff --git a/Examples/test-suite/python/doxygen_code_blocks_runme.py b/Examples/test-suite/python/doxygen_code_blocks_runme.py
new file mode 100644
index 000000000..46a0a3d84
--- /dev/null
+++ b/Examples/test-suite/python/doxygen_code_blocks_runme.py
@@ -0,0 +1,58 @@
+import doxygen_code_blocks
+import inspect
+import string
+import sys
+import comment_verifier
+
+comment_verifier.check(inspect.getdoc(doxygen_code_blocks.function),
+ """\
+Test for code blocks
+
+.. code-block:: c++
+
+ simple code block
+
+More advanced usage with C++ characters:
+
+.. code-block:: c++
+
+ std::vector<int> first; // empty vector of ints
+ std::vector<int> second (4,100); // four ints with value 100
+ std::vector<int> third (second.begin(),second.end()); // iterating through second
+ std::vector<int> fourth (third); // a copy of third
+ // the iterator constructor can also be used to construct from arrays:
+ int myints[] = {16,2,77,29};
+ std::vector<int> fifth (myints, myints + sizeof(myints) / sizeof(int) );
+
+ std::cout << "The contents of fifth are:";
+ for (std::vector<int>::iterator it = fifth.begin(); it != fifth.end(); ++it)
+ std::cout << ' ' << *it;
+ std::cout << '\\n';
+
+A code block for C:
+
+.. code-block:: c
+
+ printf("hello world");
+
+A code block for Java:
+
+.. code-block:: java
+
+ public class HelloWorld {
+ public static void main(String[] args) {
+ // Prints "Hello, World" to the terminal window.
+ System.out.println("Hello, World");
+ }
+ }
+
+A code block for python:
+
+.. code-block:: python
+
+ print('hello world')
+
+A python doctest example:
+
+>>> 1 + 1
+2""")
diff --git a/Examples/test-suite/python/doxygen_ignore_runme.py b/Examples/test-suite/python/doxygen_ignore_runme.py
new file mode 100644
index 000000000..9a7b2e5df
--- /dev/null
+++ b/Examples/test-suite/python/doxygen_ignore_runme.py
@@ -0,0 +1,17 @@
+import doxygen_ignore
+import inspect
+import comment_verifier
+
+comment_verifier.check(inspect.getdoc(doxygen_ignore.func),
+ """\
+A contrived example of ignoring too many commands in one comment.
+
+
+
+
+
+
+This is specific to **Python**.
+
+
+Command ignored, but anything here is still included.""")
diff --git a/Examples/test-suite/python/doxygen_misc_constructs_runme.py b/Examples/test-suite/python/doxygen_misc_constructs_runme.py
new file mode 100644
index 000000000..44f607fee
--- /dev/null
+++ b/Examples/test-suite/python/doxygen_misc_constructs_runme.py
@@ -0,0 +1,143 @@
+import doxygen_misc_constructs
+import inspect
+import string
+import sys
+import comment_verifier
+
+
+comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.getAddress),
+ r"""Returns address of file line.
+
+:type fileName: int
+:param fileName: name of the file, where the source line is located
+:type line: int
+:param line: line number
+:type isGetSize: boolean, optional
+:param isGetSize: if set, for every object location both address and size are returned
+
+Connection::getId() """)
+
+comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.CConnectionConfig),
+ r"""This class contains information for connection to winIDEA. Its methods
+return reference to self, so we can use it like this:
+
+CConnectionConfig config = new CConnectionConfig();
+config.discoveryPort(5534).dllPath("C:\\myWinIDEA\\connect.dll").id("main");
+
+
+All parameters are optional. Set only what is required, default values are
+used for unspecified parameters.
+
+
+
+advancedWinIDEALaunching.py Python example.""")
+
+comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.waitTime),
+ r"""Determines how long the ``isystem.connect`` should wait for running
+instances to respond. Only one of ``lfWaitXXX`` flags from IConnect::ELaunchFlags
+may be specified."""
+)
+
+comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.getConnection),
+ r"""This function returns connection id."""
+)
+
+
+comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.getFirstLetter),
+ r""
+)
+
+comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.ClassWithNestedEnum),
+ r"""Class description."""
+)
+
+comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.showList),
+ r"""An example of a list in a documentation comment.
+
+ - The first item of the list.
+ - The second list item, on
+ several indented lines,
+ showing that the indentation
+ is preserved.
+ - And the final list item after it.
+
+And this is not a list item any more."""
+)
+
+comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.isNoSpaceValidA),
+ r"""This comment without space after '*' is valid in Doxygen."""
+)
+
+comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.isNoSpaceValidB),
+ r""".This comment without space after '*' is valid in Doxygen."""
+)
+
+comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.isNoSpaceValidC),
+ r""
+)
+
+comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.backslashA),
+ r"""Backslash following``word`` is a valid doxygen command. Output contains
+'followingword' with 'word' in code font."""
+)
+
+comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.backslashB),
+ r"""Doxy command without trailing space is ignored - nothing appears
+on output. Standalone \ and '\' get to output.
+Standalone @ and '@' get to output.
+Commands "in quoted \b strings are treated as plain text".
+Commands not recognized by Doxygen are ignored.
+Backslashes in DOS paths d:and words
+following them do not appear on output, we must quote them with
+double quotes: "d:\xyz\qwe\myfile", "@something". Single quotes do not help:
+'d:'. Escaping works: d:\xyz\qwe\myfile. Unix
+paths of course have no such problems: /xyz/qwe/myfile
+Commands for escaped symbols:
+$ @ \ & ~ < > # % " . :: @text ::text"""
+)
+
+comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.backslashC),
+ r"""Backslash e at end of *line* froze SWIG
+*with* old comment parser.
+
+See also: MyClass::fun(char,
+ float)"""
+)
+
+
+comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.cycle),
+ r"""The next line contains expression:
+
+['retVal < 10', 'g_counter == 23 && g_mode & 3']
+
+
+Both words should be emphasized **isystem.connect**.
+But not the last period. For **example**, comma should not be emphasized.
+Similar **for**: double colon.
+
+Spaces at the start of line should be taken into account:
+:type id: int
+:param id: used as prefix in log
+ statements. The default value is empty string, which is OK if
+ there is only one app. instance. Example:
+
+ ctrl.setBP("func1");
+
+ If we set the id to ``main_``, we get:
+
+ main_ctrl.setBP("func1");
+
+
+:type fileName: string
+:param fileName: name of the log file"""
+);
+
+comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.doc_ends_with_quote),
+ r'''This doc comment ends with a quote: "and that's ok"'''
+);
+
+comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.doc_with_triple_quotes),
+ r'''This comment contains embedded triple-quoted string:
+
+ """How quaint"""'''
+);
diff --git a/Examples/test-suite/python/doxygen_parsing_runme.py b/Examples/test-suite/python/doxygen_parsing_runme.py
new file mode 100644
index 000000000..80e8892fa
--- /dev/null
+++ b/Examples/test-suite/python/doxygen_parsing_runme.py
@@ -0,0 +1,66 @@
+import doxygen_parsing
+import inspect
+import string
+import os
+import sys
+import comment_verifier
+
+comment_verifier.check(inspect.getdoc(doxygen_parsing.someFunction),
+ "The function comment")
+comment_verifier.check(inspect.getdoc(doxygen_parsing.SomeClass),
+ "The class comment")
+comment_verifier.check(inspect.getdoc(doxygen_parsing.SomeStruct),
+ "The struct comment")
+comment_verifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherClass),
+ "SomeAnotherClass description")
+
+# There doesn't seem to be any way to specify the doc string for __init__ when
+# using "-builtin" (see http://stackoverflow.com/q/11913492/15275), so skip
+# this test in this case.
+if not doxygen_parsing.is_python_builtin():
+ comment_verifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherClass.__init__),
+ r"""*Overload 1:*
+First overloaded constructor.
+
+|
+
+*Overload 2:*
+Second overloaded constructor.""")
+
+comment_verifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherClass.classMethod),
+ r"""The class method comment.
+
+SomeAnotherClass#classMethodExtended(int, int) a link text""")
+comment_verifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherClass.classMethodExtended),
+ r"""The class method with parameter
+
+:type a: int
+:param a: Parameter a
+:type b: int
+:param b: Parameter b"""
+)
+comment_verifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherClass.classMethodExtended2),
+ r"""The class method with parameter
+
+:type a: int
+:param a: Parameter a
+:type b: int
+:param b: Parameter b"""
+)
+comment_verifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherStruct.structMethod),
+ r"""The struct method comment""")
+comment_verifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherStruct.structMethodExtended),
+ r"""The struct method with parameter
+
+:type a: int
+:param a: Parameter a
+:type b: int
+:param b: Parameter b"""
+)
+comment_verifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherStruct.structMethodExtended2),
+ r"""The struct method with parameter
+
+:type a: int
+:param a: Parameter a
+:type b: int
+:param b: Parameter b""")
diff --git a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py
new file mode 100644
index 000000000..e884cf9ef
--- /dev/null
+++ b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py
@@ -0,0 +1,319 @@
+import doxygen_translate_all_tags
+import inspect
+import string
+import sys
+import comment_verifier
+
+
+comment_verifier.check(inspect.getdoc(doxygen_translate_all_tags.func01),
+r"""*Hello*
+
+
+
+
+
+* some list item
+
+This is attention!
+You were warned!
+
+Authors: lots of them
+Author: Zubr
+
+**boldword**
+
+Some brief description,
+extended to many lines.
+
+Not everything works right now...
+``codeword``
+
+
+
+
+
+'citationword'
+
+.. code-block:: c++
+
+ some test code
+
+Code immediately following text. Pydoc translation must add an
+empty line before:
+
+.. code-block:: c++
+
+ more test code""")
+
+comment_verifier.check(inspect.getdoc(doxygen_translate_all_tags.func02),
+r"""Conditional comment: SOMECONDITION
+Some conditional comment
+End of conditional comment.
+
+
+
+
+
+
+
+Copyright: some copyright
+
+1970 - 2012
+
+
+
+
+
+Deprecated: Now use another function
+
+This is very large
+and detailed description of some thing""")
+
+comment_verifier.check(inspect.getdoc(doxygen_translate_all_tags.func03),
+r"""Comment for **func03()**.
+
+
+
+
+
+
+
+
+
+*italicword*
+
+*emphazedWord*
+
+
+
+Example: someFile.txt
+Some details on using the example""")
+
+comment_verifier.check(inspect.getdoc(doxygen_translate_all_tags.func04),
+r""":raises: SuperError
+
+
+
+:math:`\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}`
+
+.. math::
+
+ \sqrt{(x_2-x_1)^2+(y_2-y_1)^2}
+
+.. math::
+
+ \sqrt{(x_2-x_1)^2+(y_2-y_1)^2}
+
+Math immediately following text. Pydoc translation must add an
+empty line before:
+
+.. math::
+
+ \sqrt{(x_2-x_1)^2+(y_2-y_1)^2}
+
+
+
+
+
+
+
+
+
+
+
+This will only appear in hmtl""")
+
+comment_verifier.check(inspect.getdoc(doxygen_translate_all_tags.func05),
+r"""If: ANOTHERCONDITION {
+ First part of comment
+ If: SECONDCONDITION {
+ Nested condition text
+ }Else if: THIRDCONDITION {
+ The third condition text
+ }Else: { The last text block
+ }
+}Else: { Second part of comment
+ If: CONDITION {
+ Second part extended
+ }
+}
+
+If not: SOMECONDITION {
+ This is printed if not
+}
+
+Image: testImage.bmp("Hello, world!")
+
+
+
+
+
+
+
+
+
+
+
+Some text
+describing invariant.""")
+
+comment_verifier.check(inspect.getdoc(doxygen_translate_all_tags.func06),
+r"""Comment for **func06()**.
+
+
+
+
+This will only appear in LATeX
+
+
+
+
+* Some unordered list
+* With lots of items
+* lots of lots of items
+
+
+
+
+someMember Some description follows with text after
+
+
+
+
+This will only appear in man""")
+
+comment_verifier.check(inspect.getdoc(doxygen_translate_all_tags.func07),
+r"""Comment for **func07()**.
+
+
+
+
+
+
+Notes: Here
+is the note!
+
+This is an overloaded member function, provided for convenience.
+It differs from the above function only in what argument(s) it accepts.
+
+``someword``
+
+
+
+
+
+Title: The paragraph title
+The paragraph text.
+Maybe even multiline
+
+
+
+:type a: int
+:param a: the first param
+:type b: int, in
+:param b: parameter with intent(in)
+:type c: int, out
+:param c: parameter with intent(out)
+:type d: int, in/out
+:param d: parameter with intent(in,out)""")
+
+comment_verifier.check(inspect.getdoc(doxygen_translate_all_tags.func08),
+r"""Text after anchor.
+
+
+
+
+
+
+'Anchor description'
+
+'someAnchor' not quoted text is not part of ref tag
+
+'someAnchor'
+
+
+
+
+
+
+
+
+
+Remarks: Some remark text
+
+Another remarks section
+
+:rtype: void
+:return: Whatever
+
+:rtype: void
+:return: it
+
+:rtype: void
+:return: may return""")
+
+comment_verifier.check(inspect.getdoc(doxygen_translate_all_tags.func09),
+r"""This will only appear in RTF
+
+
+See also: someOtherMethod
+
+
+
+See also: function
+
+Same as
+brief description
+
+
+
+Since: version 0.0.0.1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+:raises: superException
+
+:raises: RuntimeError""")
+
+comment_verifier.check(inspect.getdoc(doxygen_translate_all_tags.func10),
+r"""TODO: Some very important task
+
+:type b: float
+:param b: B is mentioned again...
+
+
+
+
+
+
+very long
+text with tags <sometag>
+
+
+
+Version: 0.0.0.2
+
+Warning: This is senseless!
+
+
+
+
+This will only appear in XML
+
+
+Here goes test of symbols:
+$ @ \ & ~ < > # % " . ::
+
+And here goes simple text""")
diff --git a/Examples/test-suite/python/doxygen_translate_links_runme.py b/Examples/test-suite/python/doxygen_translate_links_runme.py
new file mode 100644
index 000000000..89f276f6e
--- /dev/null
+++ b/Examples/test-suite/python/doxygen_translate_links_runme.py
@@ -0,0 +1,38 @@
+import doxygen_translate_links
+import inspect
+import string
+import sys
+import comment_verifier
+
+
+comment_verifier.check(inspect.getdoc(doxygen_translate_links.function),
+r"""Testing typenames converting in @ link
+
+superFunc(int,std::string)
+Test for std_string member
+
+
+superFunc(int,long,void*)
+Test for simple types
+
+
+superFunc(Shape::superType*)
+Test for custom types
+
+
+superFunc(int**[13])
+Test for complex types
+
+
+same works for 'See also:' links:
+
+See also: superFunc(int,std::string)
+See also: superFunc(int,long,void*)
+See also: superFunc(Shape::superType*)
+See also: superFunc(int**[13])
+
+some failing params:
+
+See also: superFunc()
+See also: superFunc()
+See also: superFunc()""")
diff --git a/Examples/test-suite/python/doxygen_translate_runme.py b/Examples/test-suite/python/doxygen_translate_runme.py
new file mode 100644
index 000000000..38dca2ef9
--- /dev/null
+++ b/Examples/test-suite/python/doxygen_translate_runme.py
@@ -0,0 +1,260 @@
+import doxygen_translate
+import inspect
+import string
+import sys
+import comment_verifier
+
+
+comment_verifier.check(inspect.getdoc(doxygen_translate.function),
+r"""*Hello*
+
+* some list item
+
+Authors: lots of them
+
+Author: Zubr
+
+**boldword**
+
+``codeword``
+
+'citationword'
+
+.. code-block:: c++
+
+ some test code
+
+Conditional comment: SOMECONDITION
+Some conditional comment
+End of conditional comment.
+
+Copyright: some copyright
+
+Deprecated: Now use another function
+
+*italicword*
+
+Example: someFile.txt
+Some details on using the example
+
+:raises: SuperError
+
+If: ANOTHERCONDITION {
+ First part of comment
+ If: SECONDCONDITION {
+ Nested condition text
+ }Else if: THIRDCONDITION {
+ The third condition text
+ }Else: { The last text block
+ }
+}Else: { Second part of comment
+ If: CONDITION {
+ Second part extended
+ }
+}
+
+If not: SOMECONDITION {
+ This is printed if not
+}
+
+Image: testImage.bmp("Hello, world!")
+
+
+
+* Some unordered list
+* With lots of items
+* lots of lots of items
+
+
+
+someMember Some description follows
+
+
+
+
+
+
+Notes: Here
+is the note!
+
+This is an overloaded member function, provided for convenience.
+It differs from the above function only in what argument(s) it accepts.
+
+``someword``
+
+
+
+Title: The paragraph title
+The paragraph text.
+Maybe even multiline
+
+:type a: int
+:param a: the first param
+
+Remarks: Some remark text
+
+Another remarks section
+
+:rtype: int
+:return: Whatever
+
+:rtype: int
+:return: it
+
+:rtype: int
+:return: may return
+
+See also: someOtherMethod
+
+See also: function
+
+Since: version 0.0.0.1
+
+:raises: superException
+
+:raises: RuntimeError
+
+TODO: Some very important task
+
+:type b: float
+:param b: B is mentioned again...
+
+very long
+text with tags <sometag>
+
+Version: 0.0.0.2
+
+Warning: This is senseless!
+
+Here goes test of symbols:
+$ @ \ & ~ < > # % " . ::
+
+And here goes simple text"""
+)
+
+
+
+comment_verifier.check(inspect.getdoc(doxygen_translate.htmlFunction),
+r"""Test for html tags. See Doxygen doc for list of tags recognized by Doxygen.
+
+This is link ("http://acme.com/index.html")
+**bold**
+Quote:
+Quotation block.
+ ("http://www.worldwildlife.org/who/index.html")
+
+
+center
+``this is code``
+
+
+Starts an item title.
+ Starts an item description.
+
+
+Starts a piece of text displayed in a typewriter font.
+
+Starts a section with a specific style (HTML only)
+
+**Starts a piece of text displayed in an italic font.**
+
+'Form' does not generate any output.
+
+--------------------------------------------------------------------
+
+# Heading 1
+
+## Heading 2
+
+### Heading 3
+
+*Starts a piece of text displayed in an italic font.*
+Input tag.
+Image: src="slika.png"
+Meta tag.
+Multicol is ignored by doxygen.
+
+
+
+* List item 1.
+* List item 2.
+
+
+
+Starts a new paragraph.
+
+Starts a preformatted fragment.
+
+Starts a section of text displayed in a smaller font.
+
+'Starts an inline text fragment with a specific style.'
+**Starts a section of bold text.**
+ Starts a piece of text displayed in subscript.
+ Starts a piece of text displayed in superscript.
+
+
+Animals
+| Column 1 | Column 2 |
+-----------------------
+| cow | dog |
+| cat | mouse |
+| horse | parrot |
+
+
+Starts a piece of text displayed in a typewriter font.
+
+Starts a piece of text displayed in a typewriter font.
+
+
+
+* List item 1.
+* List item 2.
+* List item 3.
+
+
+*Starts a piece of text displayed in an italic font.*
+
+
+<u>underlined \b bold text - doxy commands are ignored inside 'htmlonly' section </u>""")
+
+
+comment_verifier.check(inspect.getdoc(doxygen_translate.htmlTableFunction),
+r"""The meaning of flags:
+
+:type byFlags: int
+:param byFlags: bits marking required items:
+
+ | Size in bits| Items Required |
+ --------------------------------
+ | 1 - 8 | 1 |
+ | 9 - 16 | 2 |
+ | 17 - 32 | 4 |
+
+ Almost all combinations of above flags are supported by
+ ``htmlTable...`` functions.""")
+
+
+comment_verifier.check(inspect.getdoc(doxygen_translate.htmlEntitiesFunction),
+r"""All entities are treated as commands (C) TM (R)
+should work also<in text
+>
+&
+'
+"
+`
+'
+"
+"
+-
+--
+
+x
+-
+.
+~
+<=
+>=
+<--
+-->
+Not an html entity - ignored by Doxygen.
+Not an &text html entity - ampersand is replaced with entity.""")
diff --git a/Examples/test-suite/python/dynamic_cast_runme.py b/Examples/test-suite/python/dynamic_cast_runme.py
index 59e86d34c..ae080833b 100644
--- a/Examples/test-suite/python/dynamic_cast_runme.py
+++ b/Examples/test-suite/python/dynamic_cast_runme.py
@@ -8,4 +8,4 @@ y = b.blah()
a = dynamic_cast.do_test(y)
if a != "Bar::test":
- print "Failed!!"
+ raise RuntimeError("Failed!!")
diff --git a/Examples/test-suite/python/exception_order_runme.py b/Examples/test-suite/python/exception_order_runme.py
index c53521e3e..5c1529999 100644
--- a/Examples/test-suite/python/exception_order_runme.py
+++ b/Examples/test-suite/python/exception_order_runme.py
@@ -9,36 +9,35 @@ a = A()
try:
a.foo()
-except E1, e:
+except E1 as e:
pass
except:
- raise RuntimeError, "bad exception order"
+ raise RuntimeError("bad exception order")
try:
a.bar()
-except E2, e:
+except E2 as e:
pass
except:
- raise RuntimeError, "bad exception order"
+ raise RuntimeError("bad exception order")
try:
a.foobar()
-except RuntimeError, e:
+except RuntimeError as e:
if e.args[0] != "postcatch unknown":
- print "bad exception order",
- raise RuntimeError, e.args
+ raise RuntimeError("bad exception order {}".format(e.args))
try:
a.barfoo(1)
-except E1, e:
+except E1 as e:
pass
except:
- raise RuntimeError, "bad exception order"
+ raise RuntimeError("bad exception order")
try:
a.barfoo(2)
-except E2, e:
+except E2 as e:
pass
except:
- raise RuntimeError, "bad exception order"
+ raise RuntimeError("bad exception order")
diff --git a/Examples/test-suite/python/extend_template_method_runme.py b/Examples/test-suite/python/extend_template_method_runme.py
new file mode 100644
index 000000000..eb1a82d84
--- /dev/null
+++ b/Examples/test-suite/python/extend_template_method_runme.py
@@ -0,0 +1,45 @@
+from extend_template_method import *
+
+
+em = ExtendMe()
+
+ret_double = em.do_stuff_double(1, 1.1)
+if ret_double != 1.1:
+ raise RuntimeError("double failed " + ret_double)
+ret_string = em.do_stuff_string(1, "hello there")
+if ret_string != "hello there":
+ raise RuntimeError("string failed " + ret_string)
+
+ret_double = em.do_overloaded_stuff(1.1)
+if ret_double != 1.1:
+ raise RuntimeError("double failed " + ret_double)
+ret_string = em.do_overloaded_stuff("hello there")
+if ret_string != "hello there":
+ raise RuntimeError("string failed " + ret_string)
+
+if ExtendMe.static_method(123) != 123:
+ raise RuntimeError("static_method failed")
+
+em2 = ExtendMe(123)
+
+em = TemplateExtend()
+
+ret_double = em.do_template_stuff_double(1, 1.1)
+if ret_double != 1.1:
+ raise RuntimeError("double failed " + ret_double)
+ret_string = em.do_template_stuff_string(1, "hello there")
+if ret_string != "hello there":
+ raise RuntimeError("string failed " + ret_string)
+
+
+ret_double = em.do_template_overloaded_stuff(1.1)
+if ret_double != 1.1:
+ raise RuntimeError("double failed " + ret_double)
+ret_string = em.do_template_overloaded_stuff("hello there")
+if ret_string != "hello there":
+ raise RuntimeError("string failed " + ret_string)
+
+if TemplateExtend.static_template_method(123) != 123:
+ raise RuntimeError("static_template_method failed")
+
+em2 = TemplateExtend(123)
diff --git a/Examples/test-suite/python/funcptr_cpp_runme.py b/Examples/test-suite/python/funcptr_cpp_runme.py
index eb113d226..22c50b4e9 100644
--- a/Examples/test-suite/python/funcptr_cpp_runme.py
+++ b/Examples/test-suite/python/funcptr_cpp_runme.py
@@ -8,3 +8,6 @@ if call3(ADD_BY_REFERENCE, 14, 15) != 29:
raise RuntimeError
if call1(ADD_BY_VALUE_C, 2, 3) != 5:
raise RuntimeError
+
+if callconst1(ADD_BY_VALUE_C, 2, 3) != 5:
+ raise RuntimeError
diff --git a/Examples/test-suite/python/functors_runme.py b/Examples/test-suite/python/functors_runme.py
new file mode 100644
index 000000000..98945a047
--- /dev/null
+++ b/Examples/test-suite/python/functors_runme.py
@@ -0,0 +1,12 @@
+from functors import *
+
+a = Functor0(10)
+b = Functor1(10)
+c = Functor2(10)
+
+if a()!=-10:
+ raise RuntimeError("a failed")
+if b(1)!=11:
+ raise RuntimeError("b failed")
+if c(1, 2)!=13:
+ raise RuntimeError("c failed")
diff --git a/Examples/test-suite/python/fvirtual_runme.py b/Examples/test-suite/python/fvirtual_runme.py
index 99f5dc6b0..fe211b441 100644
--- a/Examples/test-suite/python/fvirtual_runme.py
+++ b/Examples/test-suite/python/fvirtual_runme.py
@@ -5,4 +5,4 @@ n = Node()
i = sw.addChild(n)
if i != 2:
- raise RuntimeError, "addChild"
+ raise RuntimeError("addChild")
diff --git a/Examples/test-suite/python/global_functions_runme.py b/Examples/test-suite/python/global_functions_runme.py
index f411261b6..4aab1b082 100644
--- a/Examples/test-suite/python/global_functions_runme.py
+++ b/Examples/test-suite/python/global_functions_runme.py
@@ -11,7 +11,7 @@ check(global_two(2, 2), 4)
fail = True
try:
global_void(1)
-except TypeError, e:
+except TypeError as e:
fail = False
if fail:
raise RuntimeError("argument count check failed")
@@ -19,7 +19,7 @@ if fail:
fail = True
try:
global_one()
-except TypeError, e:
+except TypeError as e:
fail = False
if fail:
raise RuntimeError("argument count check failed")
@@ -27,7 +27,7 @@ if fail:
fail = True
try:
global_one(2, 2)
-except TypeError, e:
+except TypeError as e:
fail = False
if fail:
@@ -36,7 +36,7 @@ if fail:
fail = True
try:
global_two(1)
-except TypeError, e:
+except TypeError as e:
fail = False
if fail:
@@ -45,7 +45,7 @@ if fail:
fail = True
try:
global_two(3, 3, 3)
-except TypeError, e:
+except TypeError as e:
fail = False
if fail:
diff --git a/Examples/test-suite/python/global_namespace_runme.py b/Examples/test-suite/python/global_namespace_runme.py
index ac12fe2dc..a47f41047 100644
--- a/Examples/test-suite/python/global_namespace_runme.py
+++ b/Examples/test-suite/python/global_namespace_runme.py
@@ -1,9 +1,6 @@
from global_namespace import *
-def is_new_style_class(cls):
- return hasattr(cls, "__class__")
-
k1 = Klass1()
k2 = Klass2()
k3 = Klass3()
@@ -12,12 +9,8 @@ k5 = Klass5()
k6 = Klass6()
k7 = Klass7()
-if is_new_style_class(KlassMethods):
- KlassMethods_static = KlassMethods
-else:
- KlassMethods_static = KlassMethods()
-KlassMethods_static.methodA(k1, k2, k3, k4, k5, k6, k7)
-KlassMethods_static.methodB(k1, k2, k3, k4, k5, k6, k7)
+KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7)
+KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7)
k1 = getKlass1A()
k2 = getKlass2A()
@@ -27,8 +20,8 @@ k5 = getKlass5A()
k6 = getKlass6A()
k7 = getKlass7A()
-KlassMethods_static.methodA(k1, k2, k3, k4, k5, k6, k7)
-KlassMethods_static.methodB(k1, k2, k3, k4, k5, k6, k7)
+KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7)
+KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7)
k1 = getKlass1B()
k2 = getKlass2B()
@@ -38,21 +31,11 @@ k5 = getKlass5B()
k6 = getKlass6B()
k7 = getKlass7B()
-KlassMethods_static.methodA(k1, k2, k3, k4, k5, k6, k7)
-KlassMethods_static.methodB(k1, k2, k3, k4, k5, k6, k7)
-
-if is_new_style_class(XYZMethods):
- XYZMethods_static = XYZMethods
-else:
- XYZMethods_static = XYZMethods()
-XYZMethods_static.methodA(
- XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7())
-XYZMethods_static.methodB(
- XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7())
-
-if is_new_style_class(TheEnumMethods):
- TheEnumMethods_static = TheEnumMethods
-else:
- TheEnumMethods_static = TheEnumMethods()
-TheEnumMethods_static.methodA(theenum1, theenum2, theenum3)
-TheEnumMethods_static.methodA(theenum1, theenum2, theenum3)
+KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7)
+KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7)
+
+XYZMethods.methodA(XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7())
+XYZMethods.methodB(XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7())
+
+TheEnumMethods.methodA(theenum1, theenum2, theenum3)
+TheEnumMethods.methodA(theenum1, theenum2, theenum3)
diff --git a/Examples/test-suite/python/global_vars_runme.py b/Examples/test-suite/python/global_vars_runme.py
index 3ef0b494f..015519ec8 100644
--- a/Examples/test-suite/python/global_vars_runme.py
+++ b/Examples/test-suite/python/global_vars_runme.py
@@ -20,7 +20,7 @@ if x != 9876:
fail = True
try:
global_vars.cvar.notexist = "something"
-except AttributeError, e:
+except AttributeError as e:
fail = False
if fail:
raise RuntimeError("AttributeError should have been thrown")
@@ -28,7 +28,7 @@ if fail:
fail = True
try:
g = global_vars.cvar.notexist
-except AttributeError, e:
+except AttributeError as e:
fail = False
if fail:
raise RuntimeError("AttributeError should have been thrown")
diff --git a/Examples/test-suite/python/ignore_parameter_runme.py b/Examples/test-suite/python/ignore_parameter_runme.py
new file mode 100644
index 000000000..2b5c21235
--- /dev/null
+++ b/Examples/test-suite/python/ignore_parameter_runme.py
@@ -0,0 +1,23 @@
+from ignore_parameter import *
+
+def check(a, b):
+ if a != b:
+ raise RuntimeError("'%s' != '%s'" % (a, b))
+
+check(jaguar(200, 0), "hello")
+check(lotus("foo", 1), 101)
+check(tvr("bar", 2), 8.8)
+check(ferrari(), 101)
+check(fiat(17), 17)
+
+car = SportsCars()
+check(car.daimler(200, 0), "hello")
+check(car.astonmartin("foo", 1), 101)
+check(car.bugatti("bar", 2), 8.8)
+check(car.lamborghini(), 101)
+check(car.maseratti(289), 289)
+
+MiniCooper(200, 0)
+MorrisMinor("baz", 0)
+FordAnglia("quux", 200)
+AustinAllegro()
diff --git a/Examples/test-suite/python/implicittest_runme.py b/Examples/test-suite/python/implicittest_runme.py
index 4646d08c0..625613a95 100644
--- a/Examples/test-suite/python/implicittest_runme.py
+++ b/Examples/test-suite/python/implicittest_runme.py
@@ -6,9 +6,6 @@ def check(a, b):
raise RuntimeError(str(a) + " does not equal " + str(b))
-def is_new_style_class(cls):
- return hasattr(cls, "__class__")
-
#### Class ####
# No implicit conversion
@@ -16,15 +13,7 @@ check(1, A(1).get())
check(2, A(1.0).get())
check(3, A(B()).get())
check(4, A("hello").get())
-try:
- check(3, A(None).get())
- raise RuntimeError
-except ValueError:
- # ValueError: invalid null reference in method 'new_A', argument 1 of type 'B const &'
- # Arguably A(char *) should be chosen, but there is a bug to do with None passed to methods overloaded by value,
- # references and pointers to different types, where pointers ought to be
- # given a slightly higher precedence.
- pass
+check(4, A(None).get())
check(1, get(1))
check(2, get(1.0))
@@ -45,17 +34,13 @@ check(2, A_int(1.0).get())
check(3, A_int(B()).get())
check(4, A_int("hello").get())
-if is_new_style_class(A_int):
- A_int_static = A_int
-else:
- A_int_static = A_int(0)
-check(1, A_int_static.sget(1))
-check(2, A_int_static.sget(1.0))
-check(3, A_int_static.sget(B()))
+check(1, A_int.sget(1))
+check(2, A_int.sget(1.0))
+check(3, A_int.sget(B()))
# explicit constructor:
try:
- check(4, A_int_static.sget("hello"))
+ check(4, A_int.sget("hello"))
raise RuntimeError
except TypeError:
pass
diff --git a/Examples/test-suite/python/import_stl_runme.py b/Examples/test-suite/python/import_stl_runme.py
index 69fe812b9..d0efbd083 100644
--- a/Examples/test-suite/python/import_stl_runme.py
+++ b/Examples/test-suite/python/import_stl_runme.py
@@ -3,4 +3,4 @@ import import_stl_a
v_new = import_stl_b.process_vector([1, 2, 3])
if v_new != (1, 2, 3, 4):
- raise RuntimeError, v_new
+ raise RuntimeError(v_new)
diff --git a/Examples/test-suite/python/inctest_runme.py b/Examples/test-suite/python/inctest_runme.py
index fa3492932..c2746560d 100644
--- a/Examples/test-suite/python/inctest_runme.py
+++ b/Examples/test-suite/python/inctest_runme.py
@@ -1,31 +1,21 @@
import inctest
-error = 0
try:
a = inctest.A()
except:
- print "didn't find A"
- print "therefore, I didn't include 'testdir/subdir1/hello.i'"
- error = 1
+ raise RuntimeError("didn't find A, therefore, I didn't include 'testdir/subdir1/hello.i'")
pass
try:
b = inctest.B()
except:
- print "didn't find B"
- print "therefore, I didn't include 'testdir/subdir2/hello.i'"
- error = 1
+ raise RuntimeError("didn't find B, therefore, I didn't include 'testdir/subdir2/hello.i'")
pass
-if error == 1:
- raise RuntimeError
-
# Check the import in subdirectory worked
if inctest.importtest1(5) != 15:
- print "import test 1 failed"
- raise RuntimeError
+ raise RuntimeError("import test 1 failed")
if inctest.importtest2("black") != "white":
- print "import test 2 failed"
- raise RuntimeError
+ raise RuntimeError("import test 2 failed")
diff --git a/Examples/test-suite/python/inherit_missing_runme.py b/Examples/test-suite/python/inherit_missing_runme.py
index 044c166fb..57a245e44 100644
--- a/Examples/test-suite/python/inherit_missing_runme.py
+++ b/Examples/test-suite/python/inherit_missing_runme.py
@@ -6,14 +6,14 @@ c = inherit_missing.Spam()
x = inherit_missing.do_blah(a)
if x != "Foo::blah":
- print "Whoa! Bad return", x
+ raise RuntimeError("Whoa! Bad return {}".format(x))
x = inherit_missing.do_blah(b)
if x != "Bar::blah":
- print "Whoa! Bad return", x
+ raise RuntimeError("Whoa! Bad return {}".format(x))
x = inherit_missing.do_blah(c)
if x != "Spam::blah":
- print "Whoa! Bad return", x
+ raise RuntimeError("Whoa! Bad return {}".format(x))
inherit_missing.delete_Foo(a)
diff --git a/Examples/test-suite/python/inplaceadd_runme.py b/Examples/test-suite/python/inplaceadd_runme.py
index 7f292cbb5..3d5a1fd40 100644
--- a/Examples/test-suite/python/inplaceadd_runme.py
+++ b/Examples/test-suite/python/inplaceadd_runme.py
@@ -3,8 +3,7 @@ a = inplaceadd.A(7)
a += 5
if a.val != 12:
- print a.val
- raise RuntimeError
+ raise RuntimeError("a.val: {}".format(a.val))
a -= 5
if a.val != 7:
diff --git a/Examples/test-suite/python/keyword_rename_runme.py b/Examples/test-suite/python/keyword_rename_runme.py
index 5646ce7d6..0bdd64b10 100644
--- a/Examples/test-suite/python/keyword_rename_runme.py
+++ b/Examples/test-suite/python/keyword_rename_runme.py
@@ -1,4 +1,6 @@
#!/usr/bin/env python
import keyword_rename
keyword_rename._in(1)
+keyword_rename._in(_except=1)
keyword_rename._except(1)
+keyword_rename._except(_in=1)
diff --git a/Examples/test-suite/python/kwargs_feature_runme.py b/Examples/test-suite/python/kwargs_feature_runme.py
index a2d4731ab..31d49d221 100644
--- a/Examples/test-suite/python/kwargs_feature_runme.py
+++ b/Examples/test-suite/python/kwargs_feature_runme.py
@@ -79,3 +79,46 @@ if rfoo(n=11, x=22) != -11:
if rfoo(x=11, n=22) != 11:
raise RuntimeError
+
+# Extended constructors
+e = Extending0()
+e = Extending1(one=1)
+e = Extending1(1)
+e = Extending2(1, "two")
+e = Extending2(1, two="two")
+e = Extending2(two="two", one=1)
+e = ExtendingOptArgs1()
+e = ExtendingOptArgs1(1)
+e = ExtendingOptArgs2(one=1)
+e = ExtendingOptArgs2()
+e = ExtendingOptArgs2(one=1)
+e = ExtendingOptArgs2(two="two")
+e = ExtendingOptArgs2(two="two", one=1)
+
+# Invalid kwargs test
+h = Hello()
+try:
+ h = Hello(nonexistent=10)
+ raise RuntimeError("missed exception")
+except TypeError as e:
+ pass
+
+f = Foo(1)
+f = Foo(a=1)
+try:
+ f = Foo(nonexistent=10)
+ raise RuntimeError("missed exception")
+except TypeError as e:
+ pass
+
+try:
+ f = Foo(a=1, nonexistent=10)
+ raise RuntimeError("missed exception")
+except TypeError as e:
+ pass
+
+try:
+ f = Foo(1, nonexistent=10)
+ raise RuntimeError("missed exception")
+except TypeError as e:
+ pass
diff --git a/Examples/test-suite/python/li_attribute_runme.py b/Examples/test-suite/python/li_attribute_runme.py
index 80e793618..d26bf0b68 100644
--- a/Examples/test-suite/python/li_attribute_runme.py
+++ b/Examples/test-suite/python/li_attribute_runme.py
@@ -8,12 +8,10 @@ if aa.a != 1:
raise RuntimeError
aa.a = 3
if aa.a != 3:
- print aa.a
- raise RuntimeError
+ raise RuntimeError("aa.a: {}".format(aa.a))
if aa.b != 2:
- print aa.b
- raise RuntimeError
+ raise RuntimeError("aa.b: {}".format(aa.b))
aa.b = 5
if aa.b != 5:
raise RuntimeError
@@ -47,6 +45,9 @@ myClass = li_attribute.MyClass()
myClass.Foo = myFoo
if myClass.Foo.x != 8:
raise RuntimeError
+myClass.Foo2 = myFoo
+if myClass.Foo2.x != 8:
+ raise RuntimeError
# class/struct attribute with get/set methods using return/pass by value
myClassVal = li_attribute.MyClassVal()
@@ -77,7 +78,7 @@ if myStringyClass.ReadOnlyString != "changed string":
try:
x = myFoo.does_not_exist
raise RuntimeError
-except AttributeError, e:
+except AttributeError as e:
if str(e).find("does_not_exist") == -1:
raise RuntimeError
diff --git a/Examples/test-suite/python/li_attribute_template_runme.py b/Examples/test-suite/python/li_attribute_template_runme.py
index d33b12309..f0a774995 100644
--- a/Examples/test-suite/python/li_attribute_template_runme.py
+++ b/Examples/test-suite/python/li_attribute_template_runme.py
@@ -7,8 +7,7 @@ chell = li_attribute_template.Cintint(1, 2, 3)
def rassert(what, master):
if what != master:
- print what
- raise RuntimeError
+ raise RuntimeError("what: {}".format(what))
# Testing primitive by value attribute
rassert(chell.a, 1)
diff --git a/Examples/test-suite/python/li_boost_shared_ptr_bits_runme.py b/Examples/test-suite/python/li_boost_shared_ptr_bits_runme.py
index 9b9c7d683..adf9ac4cf 100644
--- a/Examples/test-suite/python/li_boost_shared_ptr_bits_runme.py
+++ b/Examples/test-suite/python/li_boost_shared_ptr_bits_runme.py
@@ -1,10 +1,6 @@
from li_boost_shared_ptr_bits import *
-def is_new_style_class(cls):
- return hasattr(cls, "__class__")
-
-
def check(nd):
nd.i = 200
i = nd.i
@@ -35,7 +31,4 @@ if sum != 66:
raise "sum is wrong"
################################
-if is_new_style_class(HiddenDestructor):
- p = HiddenDestructor.create()
-else:
- p = HiddenDestructor_create()
+p = HiddenDestructor.create()
diff --git a/Examples/test-suite/python/li_boost_shared_ptr_director_runme.py b/Examples/test-suite/python/li_boost_shared_ptr_director_runme.py
new file mode 100644
index 000000000..52868eacc
--- /dev/null
+++ b/Examples/test-suite/python/li_boost_shared_ptr_director_runme.py
@@ -0,0 +1,80 @@
+from li_boost_shared_ptr_director import *
+
+class Derived(Base):
+ def __init__(self, flag):
+ self.return_none = flag
+ Base.__init__(self)
+
+ def ret_c_shared_ptr(self):
+ if self.return_none:
+ return None
+ else:
+ return C()
+
+ def ret_c_by_value(self):
+ return C()
+
+ def take_c_by_value(self,c):
+ return c.get_m()
+
+ def take_c_by_ref(self,c):
+ return c.get_m()
+
+ def take_c_by_pointer(self,c):
+ if c:
+ return c.get_m()
+ else:
+ return -2
+
+ def take_c_by_pointer_ref(self,c):
+ if c:
+ return c.get_m()
+ else:
+ return -3
+
+ def take_c_shared_ptr_by_value(self,c):
+ if c:
+ return c.get_m()
+ else:
+ return -4
+
+ def take_c_shared_ptr_by_ref(self,c):
+ if c:
+ return c.get_m()
+ else:
+ return -5
+
+ def take_c_shared_ptr_by_pointer(self,c):
+ if c:
+ return c.get_m()
+ else:
+ return -6
+
+ def take_c_shared_ptr_by_pointer_ref(self,c):
+ if c:
+ return c.get_m()
+ else:
+ return -7
+
+a = Derived(False)
+b = Derived(True)
+
+assert call_ret_c_shared_ptr(a) == 1
+assert call_ret_c_shared_ptr(b) == -1
+assert call_ret_c_by_value(a) == 1
+
+assert call_take_c_by_value(a) == 5
+assert call_take_c_by_ref(a) == 6
+assert call_take_c_by_pointer(a) == 7
+assert call_take_c_by_pointer_ref(a) == 8
+assert call_take_c_shared_ptr_by_value(a) == 9
+assert call_take_c_shared_ptr_by_ref(a) == 10
+assert call_take_c_shared_ptr_by_pointer(a) == 11
+assert call_take_c_shared_ptr_by_pointer_ref(a) == 12
+
+assert call_take_c_by_pointer_with_null(a) == -2
+assert call_take_c_by_pointer_ref_with_null(a) == -3
+assert call_take_c_shared_ptr_by_value_with_null(a) == -4
+assert call_take_c_shared_ptr_by_ref_with_null(a) == -5
+assert call_take_c_shared_ptr_by_pointer_with_null(a) == -6
+assert call_take_c_shared_ptr_by_pointer_ref_with_null(a) == -7
diff --git a/Examples/test-suite/python/li_boost_shared_ptr_runme.py b/Examples/test-suite/python/li_boost_shared_ptr_runme.py
index c960625ad..ecda7fdb1 100644
--- a/Examples/test-suite/python/li_boost_shared_ptr_runme.py
+++ b/Examples/test-suite/python/li_boost_shared_ptr_runme.py
@@ -10,7 +10,7 @@ class li_boost_shared_ptr_runme:
def main(self):
if (debug):
- print "Started"
+ print("Started")
li_boost_shared_ptr.cvar.debug_shared = debug
@@ -32,7 +32,7 @@ class li_boost_shared_ptr_runme:
"shared_ptr wrapper count=%s" % wrapper_count)
if (debug):
- print "Finished"
+ print("Finished")
def runtest(self):
# simple shared_ptr usage - created in C++
diff --git a/Examples/test-suite/python/li_cstring_runme.py b/Examples/test-suite/python/li_cstring_runme.py
index 55b51d1c7..d22fc261b 100644
--- a/Examples/test-suite/python/li_cstring_runme.py
+++ b/Examples/test-suite/python/li_cstring_runme.py
@@ -7,25 +7,23 @@ if count("ab\0ab\0ab\0", 0) != 3:
if test1() != "Hello World":
raise RuntimeError
-if test2() != " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_":
+if test2() != " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_":
raise RuntimeError
if test3("hello") != "hello-suffix":
- print test3("hello")
- raise RuntimeError
+ raise RuntimeError("test3(\"hello\")")
if test4("hello") != "hello-suffix":
- print test4("hello")
- raise RuntimeError
+ raise RuntimeError("test4(\"hello\")")
-if test5(4) != 'xxxx':
+if test5(4) != "xxxx":
raise RuntimeError
-if test6(10) != 'xxxxx':
+if test6(10) != "xxxxx":
raise RuntimeError
if test7() != "Hello world!":
raise RuntimeError
-if test8() != " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_":
+if test8() != " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_":
raise RuntimeError
diff --git a/Examples/test-suite/python/li_cwstring_runme.py b/Examples/test-suite/python/li_cwstring_runme.py
index aaa5b6e62..9216445c6 100644
--- a/Examples/test-suite/python/li_cwstring_runme.py
+++ b/Examples/test-suite/python/li_cwstring_runme.py
@@ -1,28 +1,28 @@
from li_cwstring import *
-if count(u"ab\0ab\0ab\0", 0) != 3:
+if count("ab\0ab\0ab\0", 0) != 3:
raise RuntimeError
-if test1() != u"Hello World":
+if test1() != "Hello World":
raise RuntimeError
-if test2() != u" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_":
+if test2() != " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_":
raise RuntimeError
-if test3("hello") != u"hello-suffix":
+if test3("hello") != "hello-suffix":
raise RuntimeError
-if test4("hello") != u"hello-suffix":
+if test4("hello") != "hello-suffix":
raise RuntimeError
-if test5(4) != u'xxxx':
+if test5(4) != "xxxx":
raise RuntimeError
-if test6(10) != u'xxxxx':
+if test6(10) != "xxxxx":
raise RuntimeError
-if test7() != u"Hello world!":
+if test7() != "Hello world!":
raise RuntimeError
-if test8() != u" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_":
+if test8() != " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_":
raise RuntimeError
diff --git a/Examples/test-suite/python/li_implicit_runme.py b/Examples/test-suite/python/li_implicit_runme.py
index d8dd0fdcc..5d5c6caa0 100644
--- a/Examples/test-suite/python/li_implicit_runme.py
+++ b/Examples/test-suite/python/li_implicit_runme.py
@@ -9,8 +9,8 @@ ad, get(ad)
ab, get(ab)
if get(ai) != get(1):
- raise RuntimeError, "bad implicit type"
+ raise RuntimeError("bad implicit type")
if get(ad) != get(2.0):
- raise RuntimeError, "bad implicit type"
+ raise RuntimeError("bad implicit type")
if get(ab) != get(b):
- raise RuntimeError, "bad implicit type"
+ raise RuntimeError("bad implicit type")
diff --git a/Examples/test-suite/python/li_std_containers_int_runme.py b/Examples/test-suite/python/li_std_containers_int_runme.py
index c7d262f60..f346de220 100644
--- a/Examples/test-suite/python/li_std_containers_int_runme.py
+++ b/Examples/test-suite/python/li_std_containers_int_runme.py
@@ -6,7 +6,7 @@ import sys
def failed(a, b, msg):
- raise RuntimeError, msg + " " + str(list(a)) + " " + str(list(b))
+ raise RuntimeError(msg + " " + str(list(a)) + " " + str(list(b)))
def compare_sequences(a, b):
@@ -26,7 +26,7 @@ def compare_containers(pythonlist, swigvector, swiglist):
def container_insert_step(i, j, step, newval):
- ps = range(6)
+ ps = list(range(6))
iv = vector_int(ps)
il = list_int(ps)
@@ -43,9 +43,9 @@ def container_insert_step(i, j, step, newval):
else:
ps[i:j:step] = newval
ps_error = None
- except ValueError, e:
+ except ValueError as e:
ps_error = e
- except IndexError, e:
+ except IndexError as e:
ps_error = e
# std::vector<int>
@@ -61,9 +61,9 @@ def container_insert_step(i, j, step, newval):
else:
iv[i:j:step] = newval
iv_error = None
- except ValueError, e:
+ except ValueError as e:
iv_error = e
- except IndexError, e:
+ except IndexError as e:
iv_error = e
# std::list<int>
@@ -79,27 +79,22 @@ def container_insert_step(i, j, step, newval):
else:
il[i:j:step] = newval
il_error = None
- except ValueError, e:
+ except ValueError as e:
il_error = e
- except IndexError, e:
+ except IndexError as e:
il_error = e
- # Python 2.6 contains bug fixes in extended slicing syntax:
- # http://docs.python.org/2/whatsnew/2.6.html
- skip_check = ps_error != None and(
- iv_error == il_error == None) and step > 0 and (sys.version_info[0:2] < (2, 6))
- if not(skip_check):
- if not((type(ps_error) == type(iv_error)) and (type(ps_error) == type(il_error))):
- raise RuntimeError, "ValueError exception not consistently thrown: " + \
- str(ps_error) + " " + str(iv_error) + " " + str(il_error)
+ if not((type(ps_error) == type(iv_error)) and (type(ps_error) == type(il_error))):
+ raise RuntimeError("ValueError exception not consistently thrown: " + \
+ str(ps_error) + " " + str(iv_error) + " " + str(il_error))
- compare_containers(ps, iv, il)
+ compare_containers(ps, iv, il)
# Check std::vector and std::list delete behaves same as Python list
# delete including exceptions
def container_delete_step(i, j, step):
- ps = range(6)
+ ps = list(range(6))
iv = vector_int(ps)
il = list_int(ps)
@@ -116,9 +111,9 @@ def container_delete_step(i, j, step):
else:
del ps[i:j:step]
ps_error = None
- except ValueError, e:
+ except ValueError as e:
ps_error = e
- except IndexError, e:
+ except IndexError as e:
ps_error = e
# std::vector<int>
@@ -134,9 +129,9 @@ def container_delete_step(i, j, step):
else:
del iv[i:j:step]
iv_error = None
- except ValueError, e:
+ except ValueError as e:
iv_error = e
- except IndexError, e:
+ except IndexError as e:
iv_error = e
# std::list<int>
@@ -152,14 +147,14 @@ def container_delete_step(i, j, step):
else:
del il[i:j:step]
il_error = None
- except ValueError, e:
+ except ValueError as e:
il_error = e
- except IndexError, e:
+ except IndexError as e:
il_error = e
if not((type(ps_error) == type(iv_error)) and (type(ps_error) == type(il_error))):
- raise RuntimeError, "ValueError exception not consistently thrown: " + \
- str(ps_error) + " " + str(iv_error) + " " + str(il_error)
+ raise RuntimeError("ValueError exception not consistently thrown: " + \
+ str(ps_error) + " " + str(iv_error) + " " + str(il_error))
compare_containers(ps, iv, il)
@@ -257,7 +252,7 @@ for start in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 10
for step in range(-7, 7):
container_delete_step(start, end, step)
-ps = range(6)
+ps = list(range(6))
iv = vector_int(ps)
il = list_int(ps)
del ps[:]
diff --git a/Examples/test-suite/python/li_std_containers_overload_runme.py b/Examples/test-suite/python/li_std_containers_overload_runme.py
new file mode 100644
index 000000000..dcb383511
--- /dev/null
+++ b/Examples/test-suite/python/li_std_containers_overload_runme.py
@@ -0,0 +1,29 @@
+from li_std_containers_overload import *
+
+def check(got, expected):
+ if got != expected:
+ raise RuntimeError("Failed check. '{}' != '{}'".format(got, expected))
+
+v = VectorX()
+check(VectorOverload(v), "vector<X>")
+
+v = VectorY()
+check(VectorOverload(v), "vector<Y>")
+
+v = VectorInt()
+check(VectorOverload(v), "vector<int>")
+
+v = VectorString()
+check(VectorOverload(v), "vector<string>")
+
+v = [X()]
+check(VectorOverload(v), "vector<X>")
+
+v = [Y()]
+check(VectorOverload(v), "vector<Y>")
+
+v = [1, 2, 3]
+check(VectorOverload(v), "vector<int>")
+
+v = ["aaa", "bbb", "ccc"]
+check(VectorOverload(v), "vector<string>")
diff --git a/Examples/test-suite/python/li_std_map_runme.py b/Examples/test-suite/python/li_std_map_runme.py
index af3e1d989..765527ea4 100644
--- a/Examples/test-suite/python/li_std_map_runme.py
+++ b/Examples/test-suite/python/li_std_map_runme.py
@@ -25,8 +25,7 @@ for k in m:
for k in m:
if pm[k].this != m[k].this:
- print pm[k], m[k]
- raise RuntimeError
+ raise RuntimeError("Not equal {} {}".format(pm[k], m[k]))
m = {}
@@ -50,3 +49,32 @@ mii[1] = 2
if mii[1] != 2:
raise RuntimeError
+
+if list(mii.keys()) != [1]:
+ raise RuntimeError("keys")
+if list(mii.values()) != [2]:
+ raise RuntimeError("values")
+if list(mii.items()) != [(1, 2)]:
+ raise RuntimeError("items")
+
+if [k for k in mii] != [1]:
+ raise RuntimeError("iteration")
+
+if [i for i in mii.keys()] != [1]:
+ raise RuntimeError("iterkeys")
+if [i for i in mii.values()] != [2]:
+ raise RuntimeError("itervalues")
+if [i for i in mii.items()] != [(1, 2)]:
+ raise RuntimeError("iteritems")
+
+
+slmap = li_std_map.StringLengthNumberMap()
+li_std_map.populate(slmap)
+
+keys = " ".join([k for k in list(slmap.keys())])
+if keys != "a aa zzz xxxx aaaaa":
+ raise RuntimeError("Keys are wrong or in wrong order: " + keys)
+
+values = " ".join([str(v) for v in list(slmap.values())])
+if values != "1 2 3 4 5":
+ raise RuntimeError("Values are wrong or in wrong order: " + values)
diff --git a/Examples/test-suite/python/li_std_pair_runme.py b/Examples/test-suite/python/li_std_pair_runme.py
new file mode 100644
index 000000000..4150e5cc8
--- /dev/null
+++ b/Examples/test-suite/python/li_std_pair_runme.py
@@ -0,0 +1,47 @@
+from li_std_pair import *
+
+def check(flag):
+ if not flag:
+ raise RuntimeError("Check failed")
+
+intPair = makeIntPair(7, 6)
+check(isinstance(intPair, tuple))
+check(len(intPair) == 2)
+check(intPair[0] == 7)
+check(intPair[1] == 6)
+
+intPairConstRef = makeIntPairConstRef(7, 6)
+check(isinstance(intPairConstRef, tuple))
+check(intPairConstRef[0] == 7)
+check(intPairConstRef[1] == 6)
+
+#
+# Each of these should return a reference to a wrapped
+# std::pair<int, int> object (i.e. an IntPair instance).
+#
+intPairPtr = makeIntPairPtr(7, 6)
+check(isinstance(intPairPtr, IntPair))
+check(intPairPtr[0] == 7)
+check(intPairPtr[1] == 6)
+
+intPairRef = makeIntPairRef(7, 6)
+check(isinstance(intPairRef, IntPair))
+check(intPairRef[0] == 7)
+check(intPairRef[1] == 6)
+#
+# Now test various input typemaps. Each of the wrapped C++ functions
+# (product1, product2 and product3) is expecting an argument of a
+# different type (see li_std_pair.i). Typemaps should be in place to
+# convert this tuple into the expected argument type.
+#
+check(product1(intPair) == 42)
+check(product2(intPair) == 42)
+# check(product3(intPair) == 42) # TODO, if desirable to match Ruby wrappers behaviour. Requires equivalent to typemap(in) std::pair* in Lib/ruby/std_pair.i and further fixes to stop recursive calls to swig::asptr which this testcase shows. Plus further changes for any type of sequence type (including other STL containers) to be accepted by all methods taking an STL container to match Ruby behaviour.
+
+#
+# Similarly, each of the input typemaps should know what to do
+# with an IntPair instance.
+#
+check(product1(intPairPtr) == 42)
+check(product2(intPairPtr) == 42)
+check(product3(intPairPtr) == 42)
diff --git a/Examples/test-suite/python/li_std_set_runme.py b/Examples/test-suite/python/li_std_set_runme.py
index ad3c6d881..34a1eb19c 100644
--- a/Examples/test-suite/python/li_std_set_runme.py
+++ b/Examples/test-suite/python/li_std_set_runme.py
@@ -14,11 +14,11 @@ if sum != "abc":
raise RuntimeError
i = s.__iter__()
-if i.next() != "a":
+if next(i) != "a":
raise RuntimeError
-if i.next() != "b":
+if next(i) != "b":
raise RuntimeError
-if i.next() != "c":
+if next(i) != "c":
raise RuntimeError
@@ -26,7 +26,7 @@ b = s.begin()
e = s.end()
sum = ""
while (b != e):
- sum = sum + b.next()
+ sum = sum + next(b)
if sum != "abc":
raise RuntimeError
@@ -34,7 +34,7 @@ b = s.rbegin()
e = s.rend()
sum = ""
while (b != e):
- sum = sum + b.next()
+ sum = sum + next(b)
if sum != "cba":
raise RuntimeError
@@ -47,23 +47,25 @@ si.append(2)
si.append(3)
i = si.__iter__()
-if i.next() != 1:
+if next(i) != 1:
raise RuntimeError
-if i.next() != 2:
+if next(i) != 2:
raise RuntimeError
-if i.next() != 3:
+if next(i) != 3:
raise RuntimeError
+if si[0] != 1:
+ raise RuntimeError
i = s.begin()
-i.next()
+next(i)
s.erase(i)
b = s.begin()
e = s.end()
sum = ""
while (b != e):
- sum = sum + b.next()
+ sum = sum + next(b)
if sum != "ac":
raise RuntimeError
@@ -88,5 +90,5 @@ sum = ()
for i in s:
sum = sum + (i,)
-if (len(sum) != 3 or (not 1 in sum) or (not 'hello' in sum) or (not (1, 2) in sum)):
+if (len(sum) != 3 or (not 1 in sum) or (not "hello" in sum) or (not (1, 2) in sum)):
raise RuntimeError
diff --git a/Examples/test-suite/python/li_std_stream_runme.py b/Examples/test-suite/python/li_std_stream_runme.py
index 08c308856..a4526f07b 100644
--- a/Examples/test-suite/python/li_std_stream_runme.py
+++ b/Examples/test-suite/python/li_std_stream_runme.py
@@ -9,5 +9,4 @@ o << a << " " << 2345 << " " << 1.435
if o.str() != "A class 2345 1.435":
- print "\"%s\"" % (o.str(),)
- raise RuntimeError
+ raise RuntimeError("str failed: \"%s\"".format(o.str()))
diff --git a/Examples/test-suite/python/li_std_string_extra_runme.py b/Examples/test-suite/python/li_std_string_extra_runme.py
index b65f0774a..96c64163d 100644
--- a/Examples/test-suite/python/li_std_string_extra_runme.py
+++ b/Examples/test-suite/python/li_std_string_extra_runme.py
@@ -4,64 +4,61 @@ x = "hello"
if li_std_string_extra.test_ccvalue(x) != x:
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping")
if li_std_string_extra.test_cvalue(x) != x:
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping")
if li_std_string_extra.test_value(x) != x:
- print x, li_std_string_extra.test_value(x)
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping {} {}".format(x, li_std_string_extra.test_value(x)))
if li_std_string_extra.test_const_reference(x) != x:
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping")
s = li_std_string_extra.string("he")
#s += "ll"
-# s.append('o')
+# s.append("o")
s = s + "llo"
if s != x:
- print s, x
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping {} {}".format(s, x))
if s[1:4] != x[1:4]:
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping")
if li_std_string_extra.test_value(s) != x:
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping")
if li_std_string_extra.test_const_reference(s) != x:
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping")
a = li_std_string_extra.A(s)
if li_std_string_extra.test_value(a) != x:
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping")
if li_std_string_extra.test_const_reference(a) != x:
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping")
b = li_std_string_extra.string(" world")
s = a + b
if a + b != "hello world":
- print a + b
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping {}".format(a + b))
if a + " world" != "hello world":
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping")
# This is expected to fail with -builtin option
# Reverse operators not supported in builtin types
if not li_std_string_extra.is_python_builtin():
if "hello" + b != "hello world":
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping")
c = "hello" + b
if c.find_last_of("l") != 9:
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping")
s = "hello world"
@@ -69,51 +66,73 @@ b = li_std_string_extra.B("hi")
b.name = li_std_string_extra.string("hello")
if b.name != "hello":
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping")
b.a = li_std_string_extra.A("hello")
if b.a != "hello":
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping")
if li_std_string_extra.test_value_basic1(x) != x:
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping")
if li_std_string_extra.test_value_basic2(x) != x:
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping")
if li_std_string_extra.test_value_basic3(x) != x:
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping")
+
+if li_std_string_extra.test_value_basic_overload(x) != x:
+ raise RuntimeError("bad overload string")
+
+if li_std_string_extra.test_value_basic_overload(123) != "int":
+ raise RuntimeError("bad overload int")
+
+try:
+ li_std_string_extra.test_value_basic_overload([x])
+ raise RuntimeError("should throw TypeError")
+except TypeError as e:
+ if str(e).find("Possible C/C++ prototypes are:") == -1:
+ raise RuntimeError("Incorrect error message text:\n{}".format(e))
+ pass
+
+try:
+ li_std_string_extra.test_value_basic_overload([123])
+ raise RuntimeError("should throw TypeError")
+except TypeError as e:
+ if str(e).find("Possible C/C++ prototypes are:") == -1:
+ raise RuntimeError("Incorrect error message text:\n{}".format(e))
+ pass
# Global variables
s = "initial string"
if li_std_string_extra.cvar.GlobalString2 != "global string 2":
- raise RuntimeError, "GlobalString2 test 1"
+ raise RuntimeError("GlobalString2 test 1")
li_std_string_extra.cvar.GlobalString2 = s
if li_std_string_extra.cvar.GlobalString2 != s:
- raise RuntimeError, "GlobalString2 test 2"
+ raise RuntimeError("GlobalString2 test 2")
if li_std_string_extra.cvar.ConstGlobalString != "const global string":
- raise RuntimeError, "ConstGlobalString test"
+ raise RuntimeError("ConstGlobalString test")
# Member variables
myStructure = li_std_string_extra.Structure()
if myStructure.MemberString2 != "member string 2":
- raise RuntimeError, "MemberString2 test 1"
+ raise RuntimeError("MemberString2 test 1")
myStructure.MemberString2 = s
if myStructure.MemberString2 != s:
- raise RuntimeError, "MemberString2 test 2"
+ raise RuntimeError("MemberString2 test 2")
if myStructure.ConstMemberString != "const member string":
- raise RuntimeError, "ConstMemberString test"
+ raise RuntimeError("ConstMemberString test")
if li_std_string_extra.cvar.Structure_StaticMemberString2 != "static member string 2":
- raise RuntimeError, "StaticMemberString2 test 1"
+ raise RuntimeError("StaticMemberString2 test 1")
li_std_string_extra.cvar.Structure_StaticMemberString2 = s
if li_std_string_extra.cvar.Structure_StaticMemberString2 != s:
- raise RuntimeError, "StaticMemberString2 test 2"
+ raise RuntimeError("StaticMemberString2 test 2")
if li_std_string_extra.cvar.Structure_ConstStaticMemberString != "const static member string":
- raise RuntimeError, "ConstStaticMemberString test"
+ raise RuntimeError("ConstStaticMemberString test")
if li_std_string_extra.test_reference_input("hello") != "hello":
diff --git a/Examples/test-suite/python/li_std_vector_back_reference_runme.py b/Examples/test-suite/python/li_std_vector_back_reference_runme.py
new file mode 100644
index 000000000..cec9e8cc4
--- /dev/null
+++ b/Examples/test-suite/python/li_std_vector_back_reference_runme.py
@@ -0,0 +1,10 @@
+from li_std_vector_back_reference import *
+
+def first_element():
+ v = VectorWheel((Wheel(11), Wheel(22)))
+ # v will be deleted after exit from this method
+ return v[0]
+
+size = first_element().size
+if size != 11:
+ raise RuntimeError("Back reference not working {}".format(size))
diff --git a/Examples/test-suite/python/li_std_vector_enum_runme.py b/Examples/test-suite/python/li_std_vector_enum_runme.py
index 318d1bff6..587f20b37 100644
--- a/Examples/test-suite/python/li_std_vector_enum_runme.py
+++ b/Examples/test-suite/python/li_std_vector_enum_runme.py
@@ -14,7 +14,7 @@ check(ev.nums[2], 30)
it = ev.nums.iterator()
v = it.value()
check(v, 10)
-it.next()
+next(it)
v = it.value()
check(v, 20)
diff --git a/Examples/test-suite/python/li_std_vector_extra_runme.py b/Examples/test-suite/python/li_std_vector_extra_runme.py
index d541de6db..40444552b 100644
--- a/Examples/test-suite/python/li_std_vector_extra_runme.py
+++ b/Examples/test-suite/python/li_std_vector_extra_runme.py
@@ -23,20 +23,20 @@ bv[2] = bool(4)
bv[3] = bool(0)
if bv[0] != bv[2]:
- raise RuntimeError, "bad std::vector<bool> mapping"
+ raise RuntimeError("bad std::vector<bool> mapping")
b = B(5)
va = VecA([b, None, b, b])
if va[0].f(1) != 6:
- raise RuntimeError, "bad std::vector<A*> mapping"
+ raise RuntimeError("bad std::vector<A*> mapping")
if vecAptr(va) != 6:
- raise RuntimeError, "bad std::vector<A*> mapping"
+ raise RuntimeError("bad std::vector<A*> mapping")
b.val = 7
if va[3].f(1) != 8:
- raise RuntimeError, "bad std::vector<A*> mapping"
+ raise RuntimeError("bad std::vector<A*> mapping")
ip = PtrInt()
@@ -47,7 +47,7 @@ ArrInt_setitem(ap, 2, 123)
vi = IntPtrVector((ip, ap, None))
if ArrInt_getitem(vi[0], 0) != ArrInt_getitem(vi[1], 2):
- raise RuntimeError, "bad std::vector<int*> mapping"
+ raise RuntimeError("bad std::vector<int*> mapping")
delete_ArrInt(ap)
@@ -57,42 +57,42 @@ a = halfs([10, 8, 4, 3])
v = IntVector()
v[0:2] = [1, 2]
if v[0] != 1 or v[1] != 2:
- raise RuntimeError, "bad setslice"
+ raise RuntimeError("bad setslice")
if v[0:-1][0] != 1:
- raise RuntimeError, "bad getslice"
+ raise RuntimeError("bad getslice")
if v[0:-2].size() != 0:
- raise RuntimeError, "bad getslice"
+ raise RuntimeError("bad getslice")
v[0:1] = [2]
if v[0] != 2:
- raise RuntimeError, "bad setslice"
+ raise RuntimeError("bad setslice")
v[1:] = [3]
if v[1] != 3:
- raise RuntimeError, "bad setslice"
+ raise RuntimeError("bad setslice")
v[2:] = [3]
if v[2] != 3:
- raise RuntimeError, "bad setslice"
+ raise RuntimeError("bad setslice")
if v[0:][0] != v[0]:
- raise RuntimeError, "bad getslice"
+ raise RuntimeError("bad getslice")
del v[:]
if v.size() != 0:
- raise RuntimeError, "bad getslice"
+ raise RuntimeError("bad getslice")
del v[:]
if v.size() != 0:
- raise RuntimeError, "bad getslice"
+ raise RuntimeError("bad getslice")
v = vecStr(["hello ", "world"])
-if v[0] != 'hello world':
- raise RuntimeError, "bad std::string+std::vector"
+if v[0] != "hello world":
+ raise RuntimeError("bad std::string+std::vector")
pv = pyvector([1, "hello", (1, 2)])
@@ -173,3 +173,11 @@ if extractConstShort(vcs[0]) != 111:
if extractConstShort(vcs[1]) != 222:
raise RuntimeError
+
+for p in vcs[0:1]:
+ if extractConstShort2(p) != 111:
+ raise RuntimeError
+
+for p in vcs[1:2]:
+ if extractConstShort2(p) != 222:
+ raise RuntimeError
diff --git a/Examples/test-suite/python/li_std_vector_ptr_runme.py b/Examples/test-suite/python/li_std_vector_ptr_runme.py
index baa92cfee..875d1c9c9 100644
--- a/Examples/test-suite/python/li_std_vector_ptr_runme.py
+++ b/Examples/test-suite/python/li_std_vector_ptr_runme.py
@@ -4,12 +4,20 @@ def check(val1, val2):
if val1 != val2:
raise RuntimeError("Values are not the same %s %s" % (val1, val2))
ip1 = makeIntPtr(11)
-ip2 = makeIntPtr(22)
+ip2 = makeIntPtr2(22)
vi = IntPtrVector((ip1, ip2))
check(getValueFromVector(vi, 0), 11)
check(getValueFromVector(vi, 1), 22)
+check(getIntValue(vi[0]), 11)
+check(getIntValue(vi[1]), 22)
+check(getIntValue2(vi[0]), 11)
+check(getIntValue2(vi[1]), 22)
+
+ipp = makeIntPtrPtr(vi[0])
+check(getIntValue3(ipp), 11) # Note: getIntValue3 takes int**
+
vA = APtrVector([makeA(33), makeA(34)])
check(getVectorValueA(vA, 0), 33)
diff --git a/Examples/test-suite/python/li_std_wstream_runme.py b/Examples/test-suite/python/li_std_wstream_runme.py
index 045645b61..0ecdddbf8 100644
--- a/Examples/test-suite/python/li_std_wstream_runme.py
+++ b/Examples/test-suite/python/li_std_wstream_runme.py
@@ -5,8 +5,7 @@ a = A()
o = wostringstream()
-o << a << u" " << 2345 << u" " << 1.435 << wends
+o << a << " " << 2345 << " " << 1.435 << wends
if o.str() != "A class 2345 1.435\0":
- print "\"%s\"" % (o.str(),)
- raise RuntimeError
+ raise RuntimeError("str failed: \"%s\"".format(o.str()))
diff --git a/Examples/test-suite/python/li_std_wstring_inherit_runme.py b/Examples/test-suite/python/li_std_wstring_inherit_runme.py
new file mode 100644
index 000000000..bd585890c
--- /dev/null
+++ b/Examples/test-suite/python/li_std_wstring_inherit_runme.py
@@ -0,0 +1,44 @@
+import li_std_wstring_inherit
+import sys
+
+x = "hello"
+
+s = li_std_wstring_inherit.wstring("he")
+s = s + "llo"
+
+if s != x:
+ raise RuntimeError("bad string mapping {} {}".format(s, x))
+
+if s[1:4] != x[1:4]:
+ raise RuntimeError("bad string mapping")
+
+a = li_std_wstring_inherit.A(s)
+b = li_std_wstring_inherit.wstring(" world")
+
+if a + b != "hello world":
+ raise RuntimeError("bad string mapping")
+
+if a + " world" != "hello world":
+ raise RuntimeError("bad string mapping")
+
+# This is expected to fail if -builtin is used
+# Reverse operators not supported in builtin types
+if not li_std_wstring_inherit.is_python_builtin():
+ if "hello" + b != "hello world":
+ raise RuntimeError("bad string mapping")
+
+ c = "hello" + b
+ if c.find_last_of("l") != 9:
+ raise RuntimeError("bad string mapping")
+
+b = li_std_wstring_inherit.B("hi")
+
+b.name = li_std_wstring_inherit.wstring("hello")
+if b.name != "hello":
+ raise RuntimeError("bad string mapping")
+
+
+b.a = li_std_wstring_inherit.A("hello")
+if b.a != "hello":
+ raise RuntimeError("bad string mapping")
+
diff --git a/Examples/test-suite/python/li_std_wstring_runme.py b/Examples/test-suite/python/li_std_wstring_runme.py
index e93196b80..ca8dc3184 100644
--- a/Examples/test-suite/python/li_std_wstring_runme.py
+++ b/Examples/test-suite/python/li_std_wstring_runme.py
@@ -1,83 +1,85 @@
import li_std_wstring
-
-x = u"h"
-
-if li_std_wstring.test_wcvalue(x) != x:
- print li_std_wstring.test_wcvalue(x)
- raise RuntimeError("bad string mapping")
-
-x = u"hello"
-if li_std_wstring.test_ccvalue(x) != x:
- raise RuntimeError("bad string mapping")
-
-if li_std_wstring.test_cvalue(x) != x:
- raise RuntimeError("bad string mapping")
-
-if li_std_wstring.test_wchar_overload(x) != x:
- raise RuntimeError("bad string mapping")
-
-if li_std_wstring.test_wchar_overload("not unicode") != "not unicode":
- raise RuntimeError("bad string mapping")
-
-if li_std_wstring.test_value(x) != x:
- print x, li_std_wstring.test_value(x)
- raise RuntimeError("bad string mapping")
-
-if li_std_wstring.test_const_reference(x) != x:
- raise RuntimeError("bad string mapping")
-
-
-s = li_std_wstring.wstring(u"he")
-s = s + u"llo"
-
-if s != x:
- print s, x
- raise RuntimeError("bad string mapping")
-
-if s[1:4] != x[1:4]:
- raise RuntimeError("bad string mapping")
-
-if li_std_wstring.test_value(s) != x:
- raise RuntimeError("bad string mapping")
-
-if li_std_wstring.test_const_reference(s) != x:
- raise RuntimeError("bad string mapping")
-
-a = li_std_wstring.A(s)
-
-if li_std_wstring.test_value(a) != x:
- raise RuntimeError("bad string mapping")
-
-if li_std_wstring.test_const_reference(a) != x:
- raise RuntimeError("bad string mapping")
-
-b = li_std_wstring.wstring(" world")
-
-if a + b != "hello world":
- raise RuntimeError("bad string mapping")
-
-if a + " world" != "hello world":
- raise RuntimeError("bad string mapping")
-
-# This is expected to fail if -builtin is used
-# Reverse operators not supported in builtin types
-if not li_std_wstring.is_python_builtin():
- if "hello" + b != "hello world":
+import sys
+
+def check_equal(a, b):
+ if a != b:
+ raise RuntimeError("failed {} {}".format(a, b))
+
+h = "h"
+check_equal(li_std_wstring.test_wcvalue(h), h)
+
+x = "abc"
+check_equal(li_std_wstring.test_ccvalue(x), x)
+check_equal(li_std_wstring.test_cvalue(x), x)
+
+check_equal(li_std_wstring.test_wchar_overload(x), x)
+check_equal(li_std_wstring.test_wchar_overload(), None)
+
+li_std_wstring.test_pointer(None)
+li_std_wstring.test_const_pointer(None)
+
+try:
+ li_std_wstring.test_value(None)
+ raise RuntimeError("NULL check failed")
+except TypeError as e:
+ pass
+
+try:
+ li_std_wstring.test_reference(None)
+ raise RuntimeError("NULL check failed")
+except ValueError as e:
+ if "invalid null reference" not in str(e):
+ raise RuntimeError("Missing text {}".format(e))
+try:
+ li_std_wstring.test_const_reference(None)
+ raise RuntimeError("NULL check failed")
+except ValueError as e:
+ if "invalid null reference" not in str(e):
+ raise RuntimeError("Missing text {}".format(e))
+
+x = "hello"
+check_equal(li_std_wstring.test_const_reference(x), x)
+
+s = "abc"
+if not li_std_wstring.test_equal_abc(s):
+ raise RuntimeError("Not equal {}".format(s))
+
+try:
+ li_std_wstring.test_throw
+except RuntimeError as e:
+ check_equal(e.message, "throwing test_throw")
+
+x = "abc\0def"
+check_equal(li_std_wstring.test_value(x), x)
+check_equal(li_std_wstring.test_ccvalue(x), "abc")
+check_equal(li_std_wstring.test_wchar_overload(x), "abc")
+
+ts = li_std_wstring.wchar_test_struct()
+ts.wchar_t_member = h
+check_equal(ts.wchar_t_member, h)
+ts.wchar_t_ptr_member = s
+check_equal(ts.wchar_t_ptr_member, s)
+
+################### Python specific
+
+# Byte strings only converted in Python 2
+if sys.version_info[0:2] < (3, 0):
+ x = b"hello there"
+ if li_std_wstring.test_value(x) != x:
raise RuntimeError("bad string mapping")
- c = "hello" + b
- if c.find_last_of("l") != 9:
- raise RuntimeError("bad string mapping")
-
-s = "hello world"
-
-b = li_std_wstring.B("hi")
-
-b.name = li_std_wstring.wstring(u"hello")
-if b.name != "hello":
- raise RuntimeError("bad string mapping")
-
-
-b.a = li_std_wstring.A("hello")
-if b.a != u"hello":
- raise RuntimeError("bad string mapping")
+# Invalid utf-8 in a byte string fails in all versions
+x = b"h\xe9llo"
+try:
+ li_std_wstring.test_value(x)
+ raise RuntimeError("TypeError not thrown")
+except TypeError:
+ pass
+
+# Check surrogateescape
+if sys.version_info[0:2] > (3, 1):
+ x = "h\udce9llo" # surrogate escaped representation of C char*: "h\xe9llo"
+ if li_std_wstring.non_utf8_c_str() != x:
+ raise RuntimeError("surrogateescape not working")
+ if li_std_wstring.size_wstring(x) != 5 and len(x) != 5:
+ raise RuntimeError("Unexpected length")
diff --git a/Examples/test-suite/python/member_pointer_const_runme.py b/Examples/test-suite/python/member_pointer_const_runme.py
new file mode 100644
index 000000000..ad6c2df99
--- /dev/null
+++ b/Examples/test-suite/python/member_pointer_const_runme.py
@@ -0,0 +1,51 @@
+# Example using pointers to member functions
+
+from member_pointer_const import *
+
+
+def check(what, expected, actual):
+ if expected != actual:
+ raise RuntimeError(
+ "Failed: ", what, " Expected: ", expected, " Actual: ", actual)
+
+# Get the pointers
+
+area_pt = areapt()
+perim_pt = perimeterpt()
+
+# Create some objects
+
+s = Square(10)
+
+# Do some calculations
+
+check("Square area ", 100.0, do_op(s, area_pt))
+check("Square perim", 40.0, do_op(s, perim_pt))
+
+memberPtr = cvar.areavar
+memberPtr = cvar.perimetervar
+
+# Try the variables
+check("Square area ", 100.0, do_op(s, cvar.areavar))
+check("Square perim", 40.0, do_op(s, cvar.perimetervar))
+
+# Modify one of the variables
+cvar.areavar = perim_pt
+
+check("Square perimeter", 40.0, do_op(s, cvar.areavar))
+
+# Try the constants
+
+memberPtr = AREAPT
+memberPtr = PERIMPT
+memberPtr = NULLPT
+
+check("Square area ", 100.0, do_op(s, AREAPT))
+check("Square perim", 40.0, do_op(s, PERIMPT))
+
+# Typedefs
+check("Square perim", 40.0, do_op_td(s, perim_pt));
+
+check("Add by value", 3, call1(ADD_BY_VALUE, 1, 2))
+#check("Add by pointer", 7, call2(ADD_BY_POINTER, 3, 4))
+#check("Add by reference", 11, call3(ADD_BY_REFERENCE, 5, 6))
diff --git a/Examples/test-suite/python/member_pointer_runme.py b/Examples/test-suite/python/member_pointer_runme.py
index 5ae7ab9a4..f6f165863 100644
--- a/Examples/test-suite/python/member_pointer_runme.py
+++ b/Examples/test-suite/python/member_pointer_runme.py
@@ -43,6 +43,9 @@ memberPtr = NULLPT
check("Square area ", 100.0, do_op(s, AREAPT))
check("Square perim", 40.0, do_op(s, PERIMPT))
+# Typedefs
+check("Square perim", 40.0, do_op_td(s, perim_pt));
+
check("Add by value", 3, call1(ADD_BY_VALUE, 1, 2))
check("Add by pointer", 7, call2(ADD_BY_POINTER, 3, 4))
check("Add by reference", 11, call3(ADD_BY_REFERENCE, 5, 6))
diff --git a/Examples/test-suite/python/minherit_runme.py b/Examples/test-suite/python/minherit_runme.py
index b7e7d019c..8638d2357 100644
--- a/Examples/test-suite/python/minherit_runme.py
+++ b/Examples/test-suite/python/minherit_runme.py
@@ -7,31 +7,31 @@ c = minherit.FooBar()
d = minherit.Spam()
if a.xget() != 1:
- raise RuntimeError, "Bad attribute value"
+ raise RuntimeError("Bad attribute value")
if b.yget() != 2:
- raise RuntimeError, "Bad attribute value"
+ raise RuntimeError("Bad attribute value")
if c.xget() != 1 or c.yget() != 2 or c.zget() != 3:
- raise RuntimeError, "Bad attribute value"
+ raise RuntimeError("Bad attribute value")
if d.xget() != 1 or d.yget() != 2 or d.zget() != 3 or d.wget() != 4:
- raise RuntimeError, "Bad attribute value"
+ raise RuntimeError("Bad attribute value")
if minherit.xget(a) != 1:
- raise RuntimeError, "Bad attribute value %d" % (minherit.xget(a))
+ raise RuntimeError("Bad attribute value %d" % (minherit.xget(a)))
if minherit.yget(b) != 2:
- raise RuntimeError, "Bad attribute value %d" % (minherit.yget(b))
+ raise RuntimeError("Bad attribute value %d" % (minherit.yget(b)))
if minherit.xget(c) != 1 or minherit.yget(c) != 2 or minherit.zget(c) != 3:
- raise RuntimeError, "Bad attribute value %d %d %d" % (
- minherit.xget(c), minherit.yget(c), minherit.zget(c))
+ raise RuntimeError("Bad attribute value %d %d %d" % (
+ minherit.xget(c), minherit.yget(c), minherit.zget(c)))
if minherit.xget(d) != 1 or minherit.yget(d) != 2 or minherit.zget(d) != 3 or minherit.wget(d) != 4:
- raise RuntimeError, "Bad attribute value %d %d %d %d" % (
- minherit.xget(d), minherit.yget(d), minherit.zget(d), minherit.wget(d))
+ raise RuntimeError("Bad attribute value %d %d %d %d" % (
+ minherit.xget(d), minherit.yget(d), minherit.zget(d), minherit.wget(d)))
# Cleanse all of the pointers and see what happens
@@ -41,27 +41,27 @@ cc = minherit.toFooBarPtr(c)
dd = minherit.toSpamPtr(d)
if aa.xget() != 1:
- raise RuntimeError, "Bad attribute value"
+ raise RuntimeError("Bad attribute value")
if bb.yget() != 2:
- raise RuntimeError, "Bad attribute value"
+ raise RuntimeError("Bad attribute value")
if cc.xget() != 1 or cc.yget() != 2 or cc.zget() != 3:
- raise RuntimeError, "Bad attribute value"
+ raise RuntimeError("Bad attribute value")
if dd.xget() != 1 or dd.yget() != 2 or dd.zget() != 3 or dd.wget() != 4:
- raise RuntimeError, "Bad attribute value"
+ raise RuntimeError("Bad attribute value")
if minherit.xget(aa) != 1:
- raise RuntimeError, "Bad attribute value %d" % (minherit.xget(aa))
+ raise RuntimeError("Bad attribute value %d" % (minherit.xget(aa)))
if minherit.yget(bb) != 2:
- raise RuntimeError, "Bad attribute value %d" % (minherit.yget(bb))
+ raise RuntimeError("Bad attribute value %d" % (minherit.yget(bb)))
if minherit.xget(cc) != 1 or minherit.yget(cc) != 2 or minherit.zget(cc) != 3:
- raise RuntimeError, "Bad attribute value %d %d %d" % (
- minherit.xget(cc), minherit.yget(cc), minherit.zget(cc))
+ raise RuntimeError("Bad attribute value %d %d %d" % (
+ minherit.xget(cc), minherit.yget(cc), minherit.zget(cc)))
if minherit.xget(dd) != 1 or minherit.yget(dd) != 2 or minherit.zget(dd) != 3 or minherit.wget(dd) != 4:
- raise RuntimeError, "Bad attribute value %d %d %d %d" % (
- minherit.xget(dd), minherit.yget(dd), minherit.zget(dd), minherit.wget(dd))
+ raise RuntimeError("Bad attribute value %d %d %d %d" % (
+ minherit.xget(dd), minherit.yget(dd), minherit.zget(dd), minherit.wget(dd)))
diff --git a/Examples/test-suite/python/namespace_class_runme.py b/Examples/test-suite/python/namespace_class_runme.py
index e0bd3ca09..9349f2430 100644
--- a/Examples/test-suite/python/namespace_class_runme.py
+++ b/Examples/test-suite/python/namespace_class_runme.py
@@ -1,9 +1,5 @@
from namespace_class import *
-
-def is_new_style_class(cls):
- return hasattr(cls, "__class__")
-
try:
p = Private1()
error = 1
@@ -11,7 +7,7 @@ except:
error = 0
if (error):
- raise RuntimeError, "Private1 is private"
+ raise RuntimeError("Private1 is private")
try:
p = Private2()
@@ -20,12 +16,9 @@ except:
error = 0
if (error):
- raise RuntimeError, "Private2 is private"
+ raise RuntimeError("Private2 is private")
-if is_new_style_class(EulerT3D):
- EulerT3D.toFrame(1, 1, 1)
-else:
- EulerT3D().toFrame(1, 1, 1)
+EulerT3D.toFrame(1, 1, 1)
b = BooT_i()
b = BooT_H()
@@ -40,7 +33,6 @@ f.moo(1)
f = FooT_H()
f.foo(Hi)
-if is_new_style_class(FooT_H):
- f_type = str(type(f))
- if f_type.find("'namespace_class.FooT_H'") == -1:
- raise RuntimeError("Incorrect type: " + f_type)
+f_type = str(type(f))
+if f_type.find("'namespace_class.FooT_H'") == -1:
+ raise RuntimeError("Incorrect type: " + f_type)
diff --git a/Examples/test-suite/python/nested_in_template_runme.py b/Examples/test-suite/python/nested_in_template_runme.py
new file mode 100644
index 000000000..69afd1604
--- /dev/null
+++ b/Examples/test-suite/python/nested_in_template_runme.py
@@ -0,0 +1,5 @@
+from nested_in_template import *
+
+cd = ConcreteDerived(88)
+if cd.m_value != 88:
+ raise RuntimeError("ConcreteDerived not created correctly")
diff --git a/Examples/test-suite/python/nested_runme.py b/Examples/test-suite/python/nested_runme.py
new file mode 100644
index 000000000..0e839e64b
--- /dev/null
+++ b/Examples/test-suite/python/nested_runme.py
@@ -0,0 +1,20 @@
+from nested import *
+
+def check(a, b):
+ if a != b:
+ raise RuntimeError("Problem: {} != {}".format(a, b))
+xx = x_t()
+yy = y_t()
+aa = a_t()
+bb = b_t()
+cc = c_t()
+dd = d_t()
+
+set_union_values(100, xx, yy, aa, bb, cc, dd)
+
+check(xx.duplicate_p.x, 100)
+check(yy.duplicate_p.y, 101)
+check(aa.duplicate_p.a, 102)
+check(bb.duplicate_p.b, 103)
+check(cc.duplicate_p.c, 104)
+check(dd.duplicate_p.d, 105)
diff --git a/Examples/test-suite/python/not_c_keywords_runme.py b/Examples/test-suite/python/not_c_keywords_runme.py
new file mode 100644
index 000000000..7f0772407
--- /dev/null
+++ b/Examples/test-suite/python/not_c_keywords_runme.py
@@ -0,0 +1,7 @@
+from not_c_keywords import *
+
+cs = ComplexStruct()
+cs.init()
+if cs.complex != 123:
+ raise RuntimeError("complex not correct")
+cs.complex = 456
diff --git a/Examples/test-suite/python/operator_overload_runme.py b/Examples/test-suite/python/operator_overload_runme.py
index cf4277f35..31c49058e 100644
--- a/Examples/test-suite/python/operator_overload_runme.py
+++ b/Examples/test-suite/python/operator_overload_runme.py
@@ -75,3 +75,10 @@ if not -a==a:
if not -b==Op(-5):
raise RuntimeError("-b==Op(-5)")
+# test functors
+if not b()==5:
+ raise RuntimeError("functor")
+if not b(1)==6:
+ raise RuntimeError("functor")
+if not b(1, 2)==8:
+ raise RuntimeError("functor")
diff --git a/Examples/test-suite/python/overload_complicated_runme.py b/Examples/test-suite/python/overload_complicated_runme.py
index 9c039a0a5..8794da12b 100644
--- a/Examples/test-suite/python/overload_complicated_runme.py
+++ b/Examples/test-suite/python/overload_complicated_runme.py
@@ -5,43 +5,43 @@ pInt = None
# Check the correct constructors are available
p = Pop(pInt)
-p = Pop(pInt, 0)
+p = Pop(pInt, False)
# Check overloaded in const only and pointers/references which target
# languages cannot disambiguate
-if p.hip(0) != 701:
- raise RuntimeError, "Test 1 failed"
+if p.hip(False) != 701:
+ raise RuntimeError("Test 1 failed")
if p.hip(pInt) != 702:
- raise RuntimeError, "Test 2 failed"
+ raise RuntimeError("Test 2 failed")
# Reverse the order for the above
if p.hop(pInt) != 805:
- raise RuntimeError, "Test 3 failed"
+ raise RuntimeError("Test 3 failed")
-if p.hop(0) != 801:
- raise RuntimeError, "Test 4 failed"
+if p.hop(False) != 801:
+ raise RuntimeError("Test 4 failed")
# Few more variations and order shuffled
-if p.pop(0) != 901:
- raise RuntimeError, "Test 5 failed"
+if p.pop(False) != 901:
+ raise RuntimeError("Test 5 failed")
-if p.pop(pInt) != 902:
- raise RuntimeError, "Test 6 failed"
+if p.pop(pInt) != 904:
+ raise RuntimeError("Test 6 failed")
if p.pop() != 905:
- raise RuntimeError, "Test 7 failed"
+ raise RuntimeError("Test 7 failed")
# Overload on const only
if p.bop(pInt) != 1001:
- raise RuntimeError, "Test 8 failed"
+ raise RuntimeError("Test 8 failed")
-if p.bip(pInt) != 2001:
- raise RuntimeError, "Test 9 failed"
+if p.bip(pInt) != 2002:
+ raise RuntimeError("Test 9 failed")
# Globals
-if muzak(0) != 3001:
- raise RuntimeError, "Test 10 failed"
+if muzak(False) != 3001:
+ raise RuntimeError("Test 10 failed")
if muzak(pInt) != 3002:
- raise RuntimeError, "Test 11 failed"
+ raise RuntimeError("Test 11 failed")
diff --git a/Examples/test-suite/python/overload_null_runme.py b/Examples/test-suite/python/overload_null_runme.py
new file mode 100644
index 000000000..a34524255
--- /dev/null
+++ b/Examples/test-suite/python/overload_null_runme.py
@@ -0,0 +1,44 @@
+from overload_null import *
+
+def check(a, b):
+ if a != b:
+ raise RuntimeError(str(a) + " does not equal " + str(b))
+
+o = Overload()
+x = X()
+
+check(1, o.byval1(x))
+check(2, o.byval1(None))
+
+check(3, o.byval2(None))
+check(4, o.byval2(x))
+
+check(5, o.byref1(x))
+check(6, o.byref1(None))
+
+check(7, o.byref2(None))
+check(8, o.byref2(x))
+
+check(9, o.byconstref1(x))
+check(10, o.byconstref1(None))
+
+check(11, o.byconstref2(None))
+check(12, o.byconstref2(x))
+
+# const pointer references
+check(13, o.byval1cpr(x))
+check(14, o.byval1cpr(None))
+
+check(15, o.byval2cpr(None))
+check(16, o.byval2cpr(x))
+
+# forward class declaration
+check(17, o.byval1forwardptr(x))
+check(18, o.byval1forwardptr(None))
+
+check(19, o.byval2forwardptr(None))
+check(20, o.byval2forwardptr(x))
+
+check(21, o.byval1forwardref(x))
+
+check(22, o.byval2forwardref(x))
diff --git a/Examples/test-suite/python/overload_simple_runme.py b/Examples/test-suite/python/overload_simple_runme.py
index 6d72ec081..8ad813b86 100644
--- a/Examples/test-suite/python/overload_simple_runme.py
+++ b/Examples/test-suite/python/overload_simple_runme.py
@@ -1,95 +1,95 @@
from overload_simple import *
if foo(3) != "foo:int":
- raise RuntimeError, "foo(int)"
+ raise RuntimeError("foo(int)")
if foo(3.0) != "foo:double":
- raise RuntimeError, "foo(double)"
+ raise RuntimeError("foo(double)")
if foo("hello") != "foo:char *":
- raise RuntimeError, "foo(char *)"
+ raise RuntimeError("foo(char *)")
f = Foo()
b = Bar()
if foo(f) != "foo:Foo *":
- raise RuntimeError, "foo(Foo *)"
+ raise RuntimeError("foo(Foo *)")
if foo(b) != "foo:Bar *":
- raise RuntimeError, "foo(Bar *)"
+ raise RuntimeError("foo(Bar *)")
v = malloc_void(32)
if foo(v) != "foo:void *":
- raise RuntimeError, "foo(void *)"
+ raise RuntimeError("foo(void *)")
s = Spam()
if s.foo(3) != "foo:int":
- raise RuntimeError, "Spam::foo(int)"
+ raise RuntimeError("Spam::foo(int)")
if s.foo(3.0) != "foo:double":
- raise RuntimeError, "Spam::foo(double)"
+ raise RuntimeError("Spam::foo(double)")
if s.foo("hello") != "foo:char *":
- raise RuntimeError, "Spam::foo(char *)"
+ raise RuntimeError("Spam::foo(char *)")
if s.foo(f) != "foo:Foo *":
- raise RuntimeError, "Spam::foo(Foo *)"
+ raise RuntimeError("Spam::foo(Foo *)")
if s.foo(b) != "foo:Bar *":
- raise RuntimeError, "Spam::foo(Bar *)"
+ raise RuntimeError("Spam::foo(Bar *)")
if s.foo(v) != "foo:void *":
- raise RuntimeError, "Spam::foo(void *)"
+ raise RuntimeError("Spam::foo(void *)")
if Spam_bar(3) != "bar:int":
- raise RuntimeError, "Spam::bar(int)"
+ raise RuntimeError("Spam::bar(int)")
if Spam_bar(3.0) != "bar:double":
- raise RuntimeError, "Spam::bar(double)"
+ raise RuntimeError("Spam::bar(double)")
if Spam_bar("hello") != "bar:char *":
- raise RuntimeError, "Spam::bar(char *)"
+ raise RuntimeError("Spam::bar(char *)")
if Spam_bar(f) != "bar:Foo *":
- raise RuntimeError, "Spam::bar(Foo *)"
+ raise RuntimeError("Spam::bar(Foo *)")
if Spam_bar(b) != "bar:Bar *":
- raise RuntimeError, "Spam::bar(Bar *)"
+ raise RuntimeError("Spam::bar(Bar *)")
if Spam_bar(v) != "bar:void *":
- raise RuntimeError, "Spam::bar(void *)"
+ raise RuntimeError("Spam::bar(void *)")
# Test constructors
s = Spam()
if s.type != "none":
- raise RuntimeError, "Spam()"
+ raise RuntimeError("Spam()")
s = Spam(3)
if s.type != "int":
- raise RuntimeError, "Spam(int)"
+ raise RuntimeError("Spam(int)")
s = Spam(3.4)
if s.type != "double":
- raise RuntimeError, "Spam(double)"
+ raise RuntimeError("Spam(double)")
s = Spam("hello")
if s.type != "char *":
- raise RuntimeError, "Spam(char *)"
+ raise RuntimeError("Spam(char *)")
s = Spam(f)
if s.type != "Foo *":
- raise RuntimeError, "Spam(Foo *)"
+ raise RuntimeError("Spam(Foo *)")
s = Spam(b)
if s.type != "Bar *":
- raise RuntimeError, "Spam(Bar *)"
+ raise RuntimeError("Spam(Bar *)")
s = Spam(v)
if s.type != "void *":
- raise RuntimeError, "Spam(void *)"
+ raise RuntimeError("Spam(void *)")
free_void(v)
diff --git a/Examples/test-suite/python/overload_subtype_runme.py b/Examples/test-suite/python/overload_subtype_runme.py
index 3f32a5583..b02e62ff3 100644
--- a/Examples/test-suite/python/overload_subtype_runme.py
+++ b/Examples/test-suite/python/overload_subtype_runme.py
@@ -4,7 +4,7 @@ f = Foo()
b = Bar()
if spam(f) != 1:
- raise RuntimeError, "foo"
+ raise RuntimeError("foo")
if spam(b) != 2:
- raise RuntimeError, "bar"
+ raise RuntimeError("bar")
diff --git a/Examples/test-suite/python/overload_template_fast_runme.py b/Examples/test-suite/python/overload_template_fast_runme.py
index 95349a9b1..e4eb33288 100644
--- a/Examples/test-suite/python/overload_template_fast_runme.py
+++ b/Examples/test-suite/python/overload_template_fast_runme.py
@@ -1,9 +1,5 @@
from overload_template_fast import *
-
-def is_new_style_class(cls):
- return hasattr(cls, "__class__")
-
f = foo()
a = maximum(3, 4)
@@ -11,74 +7,74 @@ b = maximum(3.4, 5.2)
# mix 1
if (mix1("hi") != 101):
- raise RuntimeError, ("mix1(const char*)")
+ raise RuntimeError(("mix1(const char*)"))
if (mix1(1.0, 1.0) != 102):
- raise RuntimeError, ("mix1(double, const double &)")
+ raise RuntimeError(("mix1(double, const double &)"))
if (mix1(1.0) != 103):
- raise RuntimeError, ("mix1(double)")
+ raise RuntimeError(("mix1(double)"))
# mix 2
if (mix2("hi") != 101):
- raise RuntimeError, ("mix2(const char*)")
+ raise RuntimeError(("mix2(const char*)"))
if (mix2(1.0, 1.0) != 102):
- raise RuntimeError, ("mix2(double, const double &)")
+ raise RuntimeError(("mix2(double, const double &)"))
if (mix2(1.0) != 103):
- raise RuntimeError, ("mix2(double)")
+ raise RuntimeError(("mix2(double)"))
# mix 3
if (mix3("hi") != 101):
- raise RuntimeError, ("mix3(const char*)")
+ raise RuntimeError(("mix3(const char*)"))
if (mix3(1.0, 1.0) != 102):
- raise RuntimeError, ("mix3(double, const double &)")
+ raise RuntimeError(("mix3(double, const double &)"))
if (mix3(1.0) != 103):
- raise RuntimeError, ("mix3(double)")
+ raise RuntimeError(("mix3(double)"))
# Combination 1
if (overtparams1(100) != 10):
- raise RuntimeError, ("overtparams1(int)")
+ raise RuntimeError(("overtparams1(int)"))
if (overtparams1(100.0, 100) != 20):
- raise RuntimeError, ("overtparams1(double, int)")
+ raise RuntimeError(("overtparams1(double, int)"))
# Combination 2
if (overtparams2(100.0, 100) != 40):
- raise RuntimeError, ("overtparams2(double, int)")
+ raise RuntimeError(("overtparams2(double, int)"))
# Combination 3
if (overloaded() != 60):
- raise RuntimeError, ("overloaded()")
+ raise RuntimeError(("overloaded()"))
if (overloaded(100.0, 100) != 70):
- raise RuntimeError, ("overloaded(double, int)")
+ raise RuntimeError(("overloaded(double, int)"))
# Combination 4
if (overloadedagain("hello") != 80):
- raise RuntimeError, ("overloadedagain(const char *)")
+ raise RuntimeError(("overloadedagain(const char *)"))
if (overloadedagain() != 90):
- raise RuntimeError, ("overloadedagain(double)")
+ raise RuntimeError(("overloadedagain(double)"))
# specializations
if (specialization(10) != 202):
- raise RuntimeError, ("specialization(int)")
+ raise RuntimeError(("specialization(int)"))
if (specialization(10.0) != 203):
- raise RuntimeError, ("specialization(double)")
+ raise RuntimeError(("specialization(double)"))
if (specialization(10, 10) != 204):
- raise RuntimeError, ("specialization(int, int)")
+ raise RuntimeError(("specialization(int, int)"))
if (specialization(10.0, 10.0) != 205):
- raise RuntimeError, ("specialization(double, double)")
+ raise RuntimeError(("specialization(double, double)"))
if (specialization("hi", "hi") != 201):
- raise RuntimeError, ("specialization(const char *, const char *)")
+ raise RuntimeError(("specialization(const char *, const char *)"))
# simple specialization
@@ -88,66 +84,63 @@ xyz_double()
# a bit of everything
if (overload("hi") != 0):
- raise RuntimeError, ("overload()")
+ raise RuntimeError(("overload()"))
if (overload(1) != 10):
- raise RuntimeError, ("overload(int t)")
+ raise RuntimeError(("overload(int t)"))
if (overload(1, 1) != 20):
- raise RuntimeError, ("overload(int t, const int &)")
+ raise RuntimeError(("overload(int t, const int &)"))
if (overload(1, "hello") != 30):
- raise RuntimeError, ("overload(int t, const char *)")
+ raise RuntimeError(("overload(int t, const char *)"))
k = Klass()
if (overload(k) != 10):
- raise RuntimeError, ("overload(Klass t)")
+ raise RuntimeError(("overload(Klass t)"))
if (overload(k, k) != 20):
- raise RuntimeError, ("overload(Klass t, const Klass &)")
+ raise RuntimeError(("overload(Klass t, const Klass &)"))
if (overload(k, "hello") != 30):
- raise RuntimeError, ("overload(Klass t, const char *)")
+ raise RuntimeError(("overload(Klass t, const char *)"))
if (overload(10.0, "hi") != 40):
- raise RuntimeError, ("overload(double t, const char *)")
+ raise RuntimeError(("overload(double t, const char *)"))
if (overload() != 50):
- raise RuntimeError, ("overload(const char *)")
+ raise RuntimeError(("overload(const char *)"))
# everything put in a namespace
if (nsoverload("hi") != 1000):
- raise RuntimeError, ("nsoverload()")
+ raise RuntimeError(("nsoverload()"))
if (nsoverload(1) != 1010):
- raise RuntimeError, ("nsoverload(int t)")
+ raise RuntimeError(("nsoverload(int t)"))
if (nsoverload(1, 1) != 1020):
- raise RuntimeError, ("nsoverload(int t, const int &)")
+ raise RuntimeError(("nsoverload(int t, const int &)"))
if (nsoverload(1, "hello") != 1030):
- raise RuntimeError, ("nsoverload(int t, const char *)")
+ raise RuntimeError(("nsoverload(int t, const char *)"))
if (nsoverload(k) != 1010):
- raise RuntimeError, ("nsoverload(Klass t)")
+ raise RuntimeError(("nsoverload(Klass t)"))
if (nsoverload(k, k) != 1020):
- raise RuntimeError, ("nsoverload(Klass t, const Klass &)")
+ raise RuntimeError(("nsoverload(Klass t, const Klass &)"))
if (nsoverload(k, "hello") != 1030):
- raise RuntimeError, ("nsoverload(Klass t, const char *)")
+ raise RuntimeError(("nsoverload(Klass t, const char *)"))
if (nsoverload(10.0, "hi") != 1040):
- raise RuntimeError, ("nsoverload(double t, const char *)")
+ raise RuntimeError(("nsoverload(double t, const char *)"))
if (nsoverload() != 1050):
- raise RuntimeError, ("nsoverload(const char *)")
+ raise RuntimeError(("nsoverload(const char *)"))
-if is_new_style_class(A):
- A.foo(1)
-else:
- A_foo(1)
+A.foo(1)
b = B()
b.foo(1)
diff --git a/Examples/test-suite/python/overload_template_runme.py b/Examples/test-suite/python/overload_template_runme.py
index 014ec71cb..a484d8f0e 100644
--- a/Examples/test-suite/python/overload_template_runme.py
+++ b/Examples/test-suite/python/overload_template_runme.py
@@ -6,74 +6,74 @@ b = maximum(3.4, 5.2)
# mix 1
if (mix1("hi") != 101):
- raise RuntimeError, ("mix1(const char*)")
+ raise RuntimeError(("mix1(const char*)"))
if (mix1(1.0, 1.0) != 102):
- raise RuntimeError, ("mix1(double, const double &)")
+ raise RuntimeError(("mix1(double, const double &)"))
if (mix1(1.0) != 103):
- raise RuntimeError, ("mix1(double)")
+ raise RuntimeError(("mix1(double)"))
# mix 2
if (mix2("hi") != 101):
- raise RuntimeError, ("mix2(const char*)")
+ raise RuntimeError(("mix2(const char*)"))
if (mix2(1.0, 1.0) != 102):
- raise RuntimeError, ("mix2(double, const double &)")
+ raise RuntimeError(("mix2(double, const double &)"))
if (mix2(1.0) != 103):
- raise RuntimeError, ("mix2(double)")
+ raise RuntimeError(("mix2(double)"))
# mix 3
if (mix3("hi") != 101):
- raise RuntimeError, ("mix3(const char*)")
+ raise RuntimeError(("mix3(const char*)"))
if (mix3(1.0, 1.0) != 102):
- raise RuntimeError, ("mix3(double, const double &)")
+ raise RuntimeError(("mix3(double, const double &)"))
if (mix3(1.0) != 103):
- raise RuntimeError, ("mix3(double)")
+ raise RuntimeError(("mix3(double)"))
# Combination 1
if (overtparams1(100) != 10):
- raise RuntimeError, ("overtparams1(int)")
+ raise RuntimeError(("overtparams1(int)"))
if (overtparams1(100.0, 100) != 20):
- raise RuntimeError, ("overtparams1(double, int)")
+ raise RuntimeError(("overtparams1(double, int)"))
# Combination 2
if (overtparams2(100.0, 100) != 40):
- raise RuntimeError, ("overtparams2(double, int)")
+ raise RuntimeError(("overtparams2(double, int)"))
# Combination 3
if (overloaded() != 60):
- raise RuntimeError, ("overloaded()")
+ raise RuntimeError(("overloaded()"))
if (overloaded(100.0, 100) != 70):
- raise RuntimeError, ("overloaded(double, int)")
+ raise RuntimeError(("overloaded(double, int)"))
# Combination 4
if (overloadedagain("hello") != 80):
- raise RuntimeError, ("overloadedagain(const char *)")
+ raise RuntimeError(("overloadedagain(const char *)"))
if (overloadedagain() != 90):
- raise RuntimeError, ("overloadedagain(double)")
+ raise RuntimeError(("overloadedagain(double)"))
# specializations
if (specialization(10) != 202):
- raise RuntimeError, ("specialization(int)")
+ raise RuntimeError(("specialization(int)"))
if (specialization(10.0) != 203):
- raise RuntimeError, ("specialization(double)")
+ raise RuntimeError(("specialization(double)"))
if (specialization(10, 10) != 204):
- raise RuntimeError, ("specialization(int, int)")
+ raise RuntimeError(("specialization(int, int)"))
if (specialization(10.0, 10.0) != 205):
- raise RuntimeError, ("specialization(double, double)")
+ raise RuntimeError(("specialization(double, double)"))
if (specialization("hi", "hi") != 201):
- raise RuntimeError, ("specialization(const char *, const char *)")
+ raise RuntimeError(("specialization(const char *, const char *)"))
# simple specialization
@@ -83,61 +83,61 @@ xyz_double()
# a bit of everything
if (overload("hi") != 0):
- raise RuntimeError, ("overload()")
+ raise RuntimeError(("overload()"))
if (overload(1) != 10):
- raise RuntimeError, ("overload(int t)")
+ raise RuntimeError(("overload(int t)"))
if (overload(1, 1) != 20):
- raise RuntimeError, ("overload(int t, const int &)")
+ raise RuntimeError(("overload(int t, const int &)"))
if (overload(1, "hello") != 30):
- raise RuntimeError, ("overload(int t, const char *)")
+ raise RuntimeError(("overload(int t, const char *)"))
k = Klass()
if (overload(k) != 10):
- raise RuntimeError, ("overload(Klass t)")
+ raise RuntimeError(("overload(Klass t)"))
if (overload(k, k) != 20):
- raise RuntimeError, ("overload(Klass t, const Klass &)")
+ raise RuntimeError(("overload(Klass t, const Klass &)"))
if (overload(k, "hello") != 30):
- raise RuntimeError, ("overload(Klass t, const char *)")
+ raise RuntimeError(("overload(Klass t, const char *)"))
if (overload(10.0, "hi") != 40):
- raise RuntimeError, ("overload(double t, const char *)")
+ raise RuntimeError(("overload(double t, const char *)"))
if (overload() != 50):
- raise RuntimeError, ("overload(const char *)")
+ raise RuntimeError(("overload(const char *)"))
# everything put in a namespace
if (nsoverload("hi") != 1000):
- raise RuntimeError, ("nsoverload()")
+ raise RuntimeError(("nsoverload()"))
if (nsoverload(1) != 1010):
- raise RuntimeError, ("nsoverload(int t)")
+ raise RuntimeError(("nsoverload(int t)"))
if (nsoverload(1, 1) != 1020):
- raise RuntimeError, ("nsoverload(int t, const int &)")
+ raise RuntimeError(("nsoverload(int t, const int &)"))
if (nsoverload(1, "hello") != 1030):
- raise RuntimeError, ("nsoverload(int t, const char *)")
+ raise RuntimeError(("nsoverload(int t, const char *)"))
if (nsoverload(k) != 1010):
- raise RuntimeError, ("nsoverload(Klass t)")
+ raise RuntimeError(("nsoverload(Klass t)"))
if (nsoverload(k, k) != 1020):
- raise RuntimeError, ("nsoverload(Klass t, const Klass &)")
+ raise RuntimeError(("nsoverload(Klass t, const Klass &)"))
if (nsoverload(k, "hello") != 1030):
- raise RuntimeError, ("nsoverload(Klass t, const char *)")
+ raise RuntimeError(("nsoverload(Klass t, const char *)"))
if (nsoverload(10.0, "hi") != 1040):
- raise RuntimeError, ("nsoverload(double t, const char *)")
+ raise RuntimeError(("nsoverload(double t, const char *)"))
if (nsoverload() != 1050):
- raise RuntimeError, ("nsoverload(const char *)")
+ raise RuntimeError(("nsoverload(const char *)"))
A_foo(1)
diff --git a/Examples/test-suite/python/pointer_reference_runme.py b/Examples/test-suite/python/pointer_reference_runme.py
index b9b47881d..f12648696 100644
--- a/Examples/test-suite/python/pointer_reference_runme.py
+++ b/Examples/test-suite/python/pointer_reference_runme.py
@@ -2,15 +2,15 @@ import pointer_reference
s = pointer_reference.get()
if s.value != 10:
- raise RuntimeError, "get test failed"
+ raise RuntimeError("get test failed")
ss = pointer_reference.Struct(20)
pointer_reference.set(ss)
if pointer_reference.cvar.Struct_instance.value != 20:
- raise RuntimeError, "set test failed"
+ raise RuntimeError("set test failed")
if pointer_reference.overloading(1) != 111:
- raise RuntimeError, "overload test 1 failed"
+ raise RuntimeError("overload test 1 failed")
if pointer_reference.overloading(ss) != 222:
- raise RuntimeError, "overload test 2 failed"
+ raise RuntimeError("overload test 2 failed")
diff --git a/Examples/test-suite/python/preproc_gcc_output_runme.py b/Examples/test-suite/python/preproc_gcc_output_runme.py
new file mode 100644
index 000000000..66ff7d21a
--- /dev/null
+++ b/Examples/test-suite/python/preproc_gcc_output_runme.py
@@ -0,0 +1,5 @@
+import preproc_gcc_output
+
+preproc_gcc_output.header1_function_a(99)
+preproc_gcc_output.header1_function_b(99)
+preproc_gcc_output.header2_function(99)
diff --git a/Examples/test-suite/python/preproc_runme.py b/Examples/test-suite/python/preproc_runme.py
index 99a6d0307..071362bc3 100644
--- a/Examples/test-suite/python/preproc_runme.py
+++ b/Examples/test-suite/python/preproc_runme.py
@@ -14,3 +14,6 @@ if 2 * preproc.one != preproc.two:
if preproc.methodX(99) != 199:
raise RuntimeError
+
+t1 = preproc.tcxMessageTest()
+t2 = preproc.tcxMessageBug()
diff --git a/Examples/test-suite/python/primitive_ref_runme.py b/Examples/test-suite/python/primitive_ref_runme.py
index f3a640389..2f1a5144c 100644
--- a/Examples/test-suite/python/primitive_ref_runme.py
+++ b/Examples/test-suite/python/primitive_ref_runme.py
@@ -33,7 +33,7 @@ if ref_double(3.5) != 3.5:
if ref_bool(True) != True:
raise RuntimeError
-if ref_char('x') != 'x':
+if ref_char("x") != "x":
raise RuntimeError
if ref_over(0) != 0:
diff --git a/Examples/test-suite/python/primitive_types_runme.py b/Examples/test-suite/python/primitive_types_runme.py
index b2060a028..7ed4b52d1 100644
--- a/Examples/test-suite/python/primitive_types_runme.py
+++ b/Examples/test-suite/python/primitive_types_runme.py
@@ -31,8 +31,7 @@ v_check()
def pyerror(name, val, cte):
- print "bad val/cte", name, val, cte
- raise RuntimeError
+ raise RuntimeError("bad val/cte {} {} {}".format(name, val, cte))
pass
if cvar.var_bool != cct_bool:
@@ -173,7 +172,7 @@ p = PyTest()
# internal call check
if t.c_check() != p.c_check():
- raise RuntimeError, "bad director"
+ raise RuntimeError("bad director")
p.var_bool = p.stc_bool
p.var_schar = p.stc_schar
@@ -227,86 +226,79 @@ t.var_paramc = sct_paramc
t.v_check()
# this value contains a '0' char!
-if def_namet != 'hola':
- print "bad namet", def_namet
- raise RuntimeError
+if def_namet != "hola":
+ raise RuntimeError("bad namet {}".format(def_namet))
t.var_namet = def_namet
if t.var_namet != def_namet:
- print "bad namet", t.var_namet, def_namet
- raise RuntimeError
+ raise RuntimeError("bad namet {} {}".format(t.var_namet, def_namet))
-t.var_namet = 'hola'
+t.var_namet = "hola"
-if t.var_namet != 'hola':
- print "bad namet", t.var_namet
- raise RuntimeError
+if t.var_namet != "hola":
+ raise RuntimeError("bad namet {}".format(t.var_namet))
-t.var_namet = 'hol'
+t.var_namet = "hol"
-if t.var_namet != 'hol':
- # if t.var_namet != 'hol\0\0':
- print "bad namet", t.var_namet
- raise RuntimeError
+if t.var_namet != "hol":
+ # if t.var_namet != "hol\0\0":
+ raise RuntimeError("bad namet {}".format(t.var_namet))
-cvar.var_char = '\0'
-if cvar.var_char != '\0':
- raise RuntimeError, "bad char '0' case"
+cvar.var_char = "\0"
+if cvar.var_char != "\0":
+ raise RuntimeError("bad char '0' case")
cvar.var_char = 0
-if cvar.var_char != '\0':
- raise RuntimeError, "bad char '0' case"
+if cvar.var_char != "\0":
+ raise RuntimeError("bad char '0' case")
-cvar.var_namet = '\0'
-# if cvar.var_namet != '\0\0\0\0\0':
-if cvar.var_namet != '':
- print 'hola', '', cvar.var_namet
- raise RuntimeError, "bad char '\0' case"
+cvar.var_namet = "\0"
+# if cvar.var_namet != "\0\0\0\0\0":
+if cvar.var_namet != "":
+ raise RuntimeError("bad char '\0' case hola {}".format(cvar.var_namet))
-cvar.var_namet = ''
-# if cvar.var_namet != '\0\0\0\0\0':
-if cvar.var_namet != '':
- raise RuntimeError, "bad char empty case"
+cvar.var_namet = ""
+# if cvar.var_namet != "\0\0\0\0\0":
+if cvar.var_namet != "":
+ raise RuntimeError("bad char empty case")
cvar.var_pchar = None
if cvar.var_pchar != None:
- raise RuntimeError, "bad None case"
+ raise RuntimeError("bad None case")
-cvar.var_pchar = ''
-if cvar.var_pchar != '':
- print '%c' % (cvar.var_pchar[0],)
- raise RuntimeError, "bad char empty case"
+cvar.var_pchar = ""
+if cvar.var_pchar != "":
+ raise RuntimeError("bad char empty case %c" % (cvar.var_pchar[0],))
cvar.var_pcharc = None
if cvar.var_pcharc != None:
- raise RuntimeError, "bad None case"
+ raise RuntimeError("bad None case")
-cvar.var_pcharc = ''
-if cvar.var_pcharc != '':
- raise RuntimeError, "bad char empty case"
+cvar.var_pcharc = ""
+if cvar.var_pcharc != "":
+ raise RuntimeError("bad char empty case")
#
# creating a raw char*
#
pc = new_pchar(5)
-pchar_setitem(pc, 0, 'h')
-pchar_setitem(pc, 1, 'o')
-pchar_setitem(pc, 2, 'l')
-pchar_setitem(pc, 3, 'a')
+pchar_setitem(pc, 0, "h")
+pchar_setitem(pc, 1, "o")
+pchar_setitem(pc, 2, "l")
+pchar_setitem(pc, 3, "a")
pchar_setitem(pc, 4, 0)
cvar.var_pchar = pc
if cvar.var_pchar != "hola":
- print cvar.var_pchar
- raise RuntimeError, "bad pointer case"
+ raise RuntimeError("bad pointer case {}".format(cvar.var_pchar))
cvar.var_namet = pc
# if cvar.var_namet != "hola\0":
if cvar.var_namet != "hola":
- raise RuntimeError, "bad pointer case"
+ raise RuntimeError("bad pointer case")
delete_pchar(pc)
@@ -325,20 +317,20 @@ except OverflowError:
error = 1
pass
if error:
- raise RuntimeError, "bad uchar typemap"
+ raise RuntimeError("bad uchar typemap")
try:
error = 0
a = t.var_char
- t.var_char = '23'
+ t.var_char = "23"
error = 1
except TypeError:
if a != t.var_char:
error = 1
pass
if error:
- raise RuntimeError, "bad char typemap"
+ raise RuntimeError("bad char typemap")
try:
error = 0
@@ -350,7 +342,7 @@ except OverflowError:
error = 1
pass
if error:
- raise RuntimeError, "bad ushort typemap"
+ raise RuntimeError("bad ushort typemap")
try:
error = 0
@@ -362,7 +354,7 @@ except OverflowError:
error = 1
pass
if error:
- raise RuntimeError, "bad uint typemap"
+ raise RuntimeError("bad uint typemap")
try:
error = 0
@@ -374,7 +366,7 @@ except OverflowError:
error = 1
pass
if error:
- raise RuntimeError, "bad sizet typemap"
+ raise RuntimeError("bad sizet typemap")
try:
error = 0
@@ -386,57 +378,57 @@ except OverflowError:
error = 1
pass
if error:
- raise RuntimeError, "bad ulong typemap"
+ raise RuntimeError("bad ulong typemap")
#
#
try:
error = 0
a = t.var_namet
- t.var_namet = '123456'
+ t.var_namet = "123456"
error = 1
except TypeError:
if a != t.var_namet:
error = 1
pass
if error:
- raise RuntimeError, "bad namet typemap"
+ raise RuntimeError("bad namet typemap")
#
#
#
t2 = p.vtest(t)
if t.var_namet != t2.var_namet:
- raise RuntimeError, "bad SWIGTYPE* typemap"
+ raise RuntimeError("bad SWIGTYPE* typemap")
-if cvar.fixsize != 'ho\0la\0\0\0':
- raise RuntimeError, "bad FIXSIZE typemap"
+if cvar.fixsize != "ho\0la\0\0\0":
+ raise RuntimeError("bad FIXSIZE typemap")
-cvar.fixsize = 'ho'
-if cvar.fixsize != 'ho\0\0\0\0\0\0':
- raise RuntimeError, "bad FIXSIZE typemap"
+cvar.fixsize = "ho"
+if cvar.fixsize != "ho\0\0\0\0\0\0":
+ raise RuntimeError("bad FIXSIZE typemap")
f = Foo(3)
f1 = fptr_val(f)
f2 = fptr_ref(f)
if f1._a != f2._a:
- raise RuntimeError, "bad const ptr& typemap"
+ raise RuntimeError("bad const ptr& typemap")
v = char_foo(1, 3)
if v != 3:
- raise RuntimeError, "bad int typemap"
+ raise RuntimeError("bad int typemap")
s = char_foo(1, "hello")
if s != "hello":
- raise RuntimeError, "bad char* typemap"
+ raise RuntimeError("bad char* typemap")
v = SetPos(1, 3)
if v != 4:
- raise RuntimeError, "bad int typemap"
+ raise RuntimeError("bad int typemap")
#
# Check the bounds for converting various types
@@ -481,53 +473,53 @@ maxullong = 2 * maxllong + 1
# Make sure Python 2's sys.maxint is the same as the maxlong we calculated
if sys.version_info[0] <= 2 and maxlong != sys.maxint:
- raise RuntimeError, "sys.maxint is not the maximum value of a signed long"
+ raise RuntimeError("sys.maxint is not the maximum value of a signed long")
def checkType(t, e, val, delta):
"""t = Test object, e = type name (e.g. ulong), val = max or min allowed value, delta = +1 for max, -1 for min"""
error = 0
# Set the extreme valid value for var_*
- setattr(t, 'var_' + e, val)
+ setattr(t, "var_" + e, val)
# Make sure it was set properly and works properly in the val_* and ref_* methods
- if getattr(t, 'var_' + e) != val or getattr(t, 'val_' + e)(val) != val or getattr(t, 'ref_' + e)(val) != val:
+ if getattr(t, "var_" + e) != val or getattr(t, "val_" + e)(val) != val or getattr(t, "ref_" + e)(val) != val:
error = 1
# Make sure setting a more extreme value fails without changing the value
try:
- a = getattr(t, 'var_' + e)
- setattr(t, 'var_' + e, val + delta)
+ a = getattr(t, "var_" + e)
+ setattr(t, "var_" + e, val + delta)
error = 1
except OverflowError:
- if a != getattr(t, 'var_' + e):
+ if a != getattr(t, "var_" + e):
error = 1
# Make sure the val_* and ref_* methods fail with a more extreme value
try:
- getattr(t, 'val_' + e)(val + delta)
+ getattr(t, "val_" + e)(val + delta)
error = 1
except OverflowError:
pass
try:
- getattr(t, 'ref_' + e)(val + delta)
+ getattr(t, "ref_" + e)(val + delta)
error = 1
except OverflowError:
pass
if error:
- raise RuntimeError, "bad " + e + " typemap"
+ raise RuntimeError("bad " + e + " typemap")
def checkFull(t, e, maxval, minval):
"""Check the maximum and minimum bounds for the type given by e"""
checkType(t, e, maxval, 1)
checkType(t, e, minval, -1)
-checkFull(t, 'llong', maxllong, minllong)
-checkFull(t, 'long', maxlong, minlong)
-checkFull(t, 'int', maxint, minint)
-checkFull(t, 'short', maxshort, minshort)
-checkFull(t, 'schar', maxchar, minchar)
-checkFull(t, 'ullong', maxullong, 0)
-checkFull(t, 'ulong', maxulong, 0)
-checkFull(t, 'uint', maxuint, 0)
-checkFull(t, 'ushort', maxushort, 0)
-checkFull(t, 'uchar', maxuchar, 0)
+checkFull(t, "llong", maxllong, minllong)
+checkFull(t, "long", maxlong, minlong)
+checkFull(t, "int", maxint, minint)
+checkFull(t, "short", maxshort, minshort)
+checkFull(t, "schar", maxchar, minchar)
+checkFull(t, "ullong", maxullong, 0)
+checkFull(t, "ulong", maxulong, 0)
+checkFull(t, "uint", maxuint, 0)
+checkFull(t, "ushort", maxushort, 0)
+checkFull(t, "uchar", maxuchar, 0)
def checkOverload(t, name, val, delta, prevval, limit):
"""
@@ -543,52 +535,47 @@ def checkOverload(t, name, val, delta, prevval, limit):
if val != prevval:
# Make sure the most extreme value of this type gives the name of this type
if t.ovr_str(val) != name:
- raise RuntimeError, "bad " + name + " typemap"
+ raise RuntimeError("bad " + name + " typemap")
# Make sure a more extreme value doesn't give the name of this type
try:
if t.ovr_str(val + delta) == name:
- raise RuntimeError, "bad " + name + " typemap"
+ raise RuntimeError("bad " + name + " typemap")
if val == limit:
- # Should raise NotImplementedError here since this is the largest integral type
- raise RuntimeError, "bad " + name + " typemap"
- except NotImplementedError:
- # NotImplementedError is expected only if this is the most extreme type
- if val != limit:
- raise RuntimeError, "bad " + name + " typemap"
+ # Should raise TypeError here since this is the largest integral type
+ raise RuntimeError("bad " + name + " typemap")
except TypeError:
- # TypeError is raised instead if swig is run with -O or -fastdispatch
if val != limit:
- raise RuntimeError, "bad " + name + " typemap"
+ raise RuntimeError("bad " + name + " typemap")
# Check that overloading works: uchar > schar > ushort > short > uint > int > ulong > long > ullong > llong
-checkOverload(t, 'uchar', maxuchar, +1, 0, maxullong)
-checkOverload(t, 'ushort', maxushort, +1, maxuchar, maxullong)
-checkOverload(t, 'uint', maxuint, +1, maxushort, maxullong)
-checkOverload(t, 'ulong', maxulong, +1, maxuint, maxullong)
-checkOverload(t, 'ullong', maxullong, +1, maxulong, maxullong)
-checkOverload(t, 'schar', minchar, -1, 0, minllong)
-checkOverload(t, 'short', minshort, -1, minchar, minllong)
-checkOverload(t, 'int', minint, -1, minshort, minllong)
-checkOverload(t, 'long', minlong, -1, minint, minllong)
-checkOverload(t, 'llong', minllong, -1, minlong, minllong)
+checkOverload(t, "uchar", maxuchar, +1, 0, maxullong)
+checkOverload(t, "ushort", maxushort, +1, maxuchar, maxullong)
+checkOverload(t, "uint", maxuint, +1, maxushort, maxullong)
+checkOverload(t, "ulong", maxulong, +1, maxuint, maxullong)
+checkOverload(t, "ullong", maxullong, +1, maxulong, maxullong)
+checkOverload(t, "schar", minchar, -1, 0, minllong)
+checkOverload(t, "short", minshort, -1, minchar, minllong)
+checkOverload(t, "int", minint, -1, minshort, minllong)
+checkOverload(t, "long", minlong, -1, minint, minllong)
+checkOverload(t, "llong", minllong, -1, minlong, minllong)
# Make sure that large ints can be converted to doubles properly
-if val_double(sys.maxint + 1) != float(sys.maxint + 1):
- raise RuntimeError, "bad double typemap"
-if val_double(-sys.maxint - 2) != float(-sys.maxint - 2):
- raise RuntimeError, "bad double typemap"
+if val_double(sys.maxsize + 1) != float(sys.maxsize + 1):
+ raise RuntimeError("bad double typemap")
+if val_double(-sys.maxsize - 2) != float(-sys.maxsize - 2):
+ raise RuntimeError("bad double typemap")
# Check the minimum and maximum values that fit in ptrdiff_t and size_t
def checkType(name, maxfunc, maxval, minfunc, minval, echofunc):
if maxfunc() != maxval:
- raise RuntimeError, "bad " + name + " typemap"
+ raise RuntimeError("bad " + name + " typemap")
if minfunc() != minval:
- raise RuntimeError, "bad " + name + " typemap"
+ raise RuntimeError("bad " + name + " typemap")
if echofunc(maxval) != maxval:
- raise RuntimeError, "bad " + name + " typemap"
+ raise RuntimeError("bad " + name + " typemap")
if echofunc(minval) != minval:
- raise RuntimeError, "bad " + name + " typemap"
+ raise RuntimeError("bad " + name + " typemap")
error = 0
try:
echofunc(maxval + 1)
@@ -596,14 +583,14 @@ def checkType(name, maxfunc, maxval, minfunc, minval, echofunc):
except OverflowError:
pass
if error == 1:
- raise RuntimeError, "bad " + name + " typemap"
+ raise RuntimeError("bad " + name + " typemap")
try:
echofunc(minval - 1)
error = 1
except OverflowError:
pass
if error == 1:
- raise RuntimeError, "bad " + name + " typemap"
+ raise RuntimeError("bad " + name + " typemap")
# sys.maxsize is the largest value supported by Py_ssize_t, which should be the same as ptrdiff_t
if sys.version_info[0:2] >= (2, 6):
diff --git a/Examples/test-suite/python/python_abstractbase_runme.py b/Examples/test-suite/python/python_abstractbase_runme.py
new file mode 100644
index 000000000..9f99dcb54
--- /dev/null
+++ b/Examples/test-suite/python/python_abstractbase_runme.py
@@ -0,0 +1,35 @@
+import sys
+
+# collections.abc requires Python 3.3+
+if sys.version_info[0:2] < (3, 3):
+ exit(0)
+
+from python_abstractbase import *
+import collections.abc
+
+# This is expected to fail with -builtin option
+# Builtin types can't inherit from pure-python abstract bases
+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)
+
+def check_issubclass(derived, base):
+ if not issubclass(derived, base):
+ raise RuntimeError("{} is not a subclass of {}".format(derived, base))
+
+check_issubclass(Mapii, collections.abc.MutableMapping)
+check_issubclass(Multimapii, collections.abc.MutableMapping)
+check_issubclass(IntSet, collections.abc.MutableSet)
+check_issubclass(IntMultiset, collections.abc.MutableSet)
+check_issubclass(IntVector, collections.abc.MutableSequence)
+check_issubclass(IntList, collections.abc.MutableSequence)
+
+mapii = Mapii()
+multimapii = Multimapii()
+intset = IntSet()
+intmultiset = IntMultiset()
+intvector = IntVector()
+intlist = IntList()
diff --git a/Examples/test-suite/python/python_abstractbase_runme3.py b/Examples/test-suite/python/python_abstractbase_runme3.py
deleted file mode 100644
index 4fdc79935..000000000
--- a/Examples/test-suite/python/python_abstractbase_runme3.py
+++ /dev/null
@@ -1,25 +0,0 @@
-from python_abstractbase import *
-from collections import *
-
-# This is expected to fail with -builtin option
-# Builtin types can't inherit from pure-python abstract bases
-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)
-assert issubclass(IntMultiset, MutableSet)
-assert issubclass(IntVector, MutableSequence)
-assert issubclass(IntList, MutableSequence)
-
-mapii = Mapii()
-multimapii = Multimapii()
-intset = IntSet()
-intmultiset = IntMultiset()
-intvector = IntVector()
-intlist = IntList()
diff --git a/Examples/test-suite/python/python_append_runme.py b/Examples/test-suite/python/python_append_runme.py
index 6675f3509..e5f6b07cf 100644
--- a/Examples/test-suite/python/python_append_runme.py
+++ b/Examples/test-suite/python/python_append_runme.py
@@ -1,19 +1,13 @@
from python_append import *
-def is_new_style_class(cls):
- return hasattr(cls, "__class__")
-
# test not relevant for -builtin
if is_python_builtin():
exit(0)
t = Test()
-t.func()
-if is_new_style_class(Test):
- t.static_func()
-else:
- Test_static_func()
+t.funk()
+t.static_func()
if grabpath() != os.path.dirname(mypath):
raise RuntimeError("grabpath failed")
@@ -27,3 +21,16 @@ if grabstaticpath() != None:
Test.static_func()
if grabstaticpath() != os.path.basename(mypath):
raise RuntimeError("grabstaticpath failed")
+
+# slots test
+fs = ForSlots()
+if fs.ValidVariable != 99:
+ raise RuntimeError("ValidVariable failed")
+fs.ValidVariable = 11
+if fs.ValidVariable != 11:
+ raise RuntimeError("ValidVariable failed")
+try:
+ fs.Invalid = 22
+ raise RuntimeError("It should not be possible to set a random variable name")
+except AttributeError:
+ pass
diff --git a/Examples/test-suite/python/python_builtin_runme.py b/Examples/test-suite/python/python_builtin_runme.py
index 7afab2a39..8a42a2607 100644
--- a/Examples/test-suite/python/python_builtin_runme.py
+++ b/Examples/test-suite/python/python_builtin_runme.py
@@ -32,7 +32,7 @@ if is_python_builtin():
passed = False
try:
h = hash(ExceptionHashFunction())
- except RuntimeError, e:
+ except RuntimeError as e:
passed = str(e).find("oops") != -1
pass
@@ -83,6 +83,7 @@ if is_python_builtin():
if MyClass.less_than_counts != 6:
raise RuntimeError("python:compare feature not working")
+# Test 6
sa = SimpleArray(5)
elements = [x for x in sa]
if elements != [0, 10, 20, 30, 40]:
@@ -96,3 +97,17 @@ subslice = sa[1:3]
elements = [x for x in subslice]
if elements != [10, 20]:
raise RuntimeError("slice not working")
+
+# Test 7 mapping to Python's pow
+x = ANumber(2)
+y = ANumber(4)
+z = x ** y
+if z.Value() != 16:
+ raise RuntimeError("x ** y wrong")
+z = pow(x, y)
+if z.Value() != 16:
+ raise RuntimeError("pow(x, y) wrong")
+z = ANumber(9)
+z = pow(x, y, z)
+if z.Value() != 7:
+ raise RuntimeError("pow(x, y, z) wrong")
diff --git a/Examples/test-suite/python/python_destructor_exception_runme.py b/Examples/test-suite/python/python_destructor_exception_runme.py
index ee71ab33b..47659531b 100644
--- a/Examples/test-suite/python/python_destructor_exception_runme.py
+++ b/Examples/test-suite/python/python_destructor_exception_runme.py
@@ -1,7 +1,11 @@
import python_destructor_exception
-from StringIO import StringIO
import sys
+if sys.version_info[0:2] < (3, 0):
+ import StringIO as io
+else:
+ import io
+
def error_function():
python_destructor_exception.ClassWithThrowingDestructor().GetBlah()
@@ -9,13 +13,13 @@ def runtest():
attributeErrorOccurred = False
try:
error_function()
- except AttributeError, e:
+ except AttributeError:
attributeErrorOccurred = True
return attributeErrorOccurred
def test1():
stderr_saved = sys.stderr
- buffer = StringIO()
+ buffer = io.StringIO()
attributeErrorOccurred = False
try:
# Suppress stderr while making this call to suppress the output shown by PyErr_WriteUnraisable
diff --git a/Examples/test-suite/python/python_docstring_runme.py b/Examples/test-suite/python/python_docstring_runme.py
index 0284ea0de..a601ecb54 100644
--- a/Examples/test-suite/python/python_docstring_runme.py
+++ b/Examples/test-suite/python/python_docstring_runme.py
@@ -9,7 +9,7 @@ def check(got, expected):
raise RuntimeError("\n" + "Expected: " + str(expected_list) + "\n" + "Got : " + str(got_list))
# When getting docstrings, use inspect.getdoc(x) instead of x.__doc__ otherwise the different options
-# such as -O, -builtin, -classic produce different initial indentation.
+# such as -O and -builtin may produce different initial indentation.
check(inspect.getdoc(DocStrings.docstring1),
" line 1\n"
diff --git a/Examples/test-suite/python/python_nondynamic_runme.py b/Examples/test-suite/python/python_nondynamic_runme.py
index 6a430961e..524f4d1c4 100644
--- a/Examples/test-suite/python/python_nondynamic_runme.py
+++ b/Examples/test-suite/python/python_nondynamic_runme.py
@@ -1,21 +1,41 @@
import python_nondynamic
+def is_python_modern():
+ """Return True if SWIG is generating Python code using -modern. Works only if %python_nondynamic has been used."""
+ return hasattr(python_nondynamic, "_swig_setattr_nondynamic_class_variable")
+
+def debug_print(s):
+ show_debug = False
+ if show_debug:
+ print(s)
+
aa = python_nondynamic.A()
aa.a = 1
aa.b = 2
+
+# Check values are really set
+if python_nondynamic.retrieve_A_a(aa) != 1: raise RuntimeError("a not set correctly")
+if python_nondynamic.retrieve_A_b(aa) != 2: raise RuntimeError("b not set correctly")
+
try:
aa.c = 2
- err = 0
-except:
- err = 1
-
-if not err:
- raise RuntimeError, "A is not static"
+ raise RuntimeError("A is not static")
+except AttributeError as e:
+ debug_print(e)
+ pass
+class PurePythonClass(object):
+ def __init__(self):
+ self.variables = dict()
+ def __set__(self, name, value):
+ self.variables[name] = value
+ pass
class B(python_nondynamic.A):
c = 4
+ cc = PurePythonClass()
+ cc.nnn = "new attrib"
def __init__(self):
python_nondynamic.A.__init__(self)
@@ -23,26 +43,62 @@ class B(python_nondynamic.A):
pass
bb = B()
+bb.a = 4
+bb.b = 5
+# Check values are really set
+if python_nondynamic.retrieve_A_a(bb) != 4: raise RuntimeError("a not set correctly")
+if python_nondynamic.retrieve_A_b(bb) != 5: raise RuntimeError("b not set correctly")
try:
bb.c = 3
- err = 0
-except:
- err = 1
-
-if not err:
- print "bb.c = %d" % bb.c
- print "B.c = %d" % B.c
- raise RuntimeError, "B.c class variable messes up nondynamic-ness of B"
+ raise RuntimeError("B.c class variable messes up nondynamic-ness of B bb.c={} B.c={}".format(bb.c, B.c))
+except AttributeError as e:
+ debug_print(e)
+ pass
try:
bb.d = 2
- err = 0
-except:
- err = 1
-
-if not err:
- raise RuntimeError, "B is not static"
+ raise RuntimeError("B is not static")
+except AttributeError as e:
+ debug_print(e)
+ pass
cc = python_nondynamic.C()
cc.d = 3
+
+# An inconsistency between builtin and (non-builtin/modern).
+# Class variables cannot be set on builtin types, like other Python builtins, eg list.classvar=111 fails
+if python_nondynamic.is_python_builtin():
+ try:
+ python_nondynamic.C.classvar = 111
+ raise RuntimeError("C should not allow static variables to be added when using builtin")
+ except AttributeError as e:
+ debug_print(e)
+ pass
+else:
+ python_nondynamic.C.classvar = 111
+
+if is_python_modern() and not python_nondynamic.is_python_builtin():
+ # Not working with builtin or non-modern :(
+ try:
+ B.a = 10
+ raise RuntimeError("B should not allow adding a class variable by setting it as an instance variable")
+ except AttributeError as e:
+ debug_print(e)
+ pass
+
+ try:
+ python_nondynamic.A.a = 10
+ raise RuntimeError("A should not allow adding a class variable by setting it as an instance variable")
+ except AttributeError as e:
+ debug_print(e)
+ pass
+
+if not python_nondynamic.is_python_builtin():
+ try:
+ bb.cc = 3
+ raise RuntimeError("B.cc class variable messes up nondynamic-ness of B bb.cc={} B.cc={}".format(bb.cc, B.cc))
+ except AttributeError as e:
+ debug_print(e)
+ pass
+
diff --git a/Examples/test-suite/python/python_overload_simple_cast_runme.py b/Examples/test-suite/python/python_overload_simple_cast_runme.py
index 79ef6cd2e..fc398ab29 100644
--- a/Examples/test-suite/python/python_overload_simple_cast_runme.py
+++ b/Examples/test-suite/python/python_overload_simple_cast_runme.py
@@ -30,136 +30,136 @@ except:
good = 1
if not good:
- raise RuntimeError, "fint(int)"
+ raise RuntimeError("fint(int)")
if fint(ad) != "fint:int":
- raise RuntimeError, "fint(int)"
+ raise RuntimeError("fint(int)")
if fdouble(ad) != "fdouble:double":
- raise RuntimeError, "fdouble(double)"
+ raise RuntimeError("fdouble(double)")
if fint(ai) != "fint:int":
- raise RuntimeError, "fint(int)"
+ raise RuntimeError("fint(int)")
if fint(5.0) != "fint:int":
- raise RuntimeError, "fint(int)"
+ raise RuntimeError("fint(int)")
if fint(3) != "fint:int":
- raise RuntimeError, "fint(int)"
+ raise RuntimeError("fint(int)")
if fint(3.0) != "fint:int":
- raise RuntimeError, "fint(int)"
+ raise RuntimeError("fint(int)")
if fdouble(ad) != "fdouble:double":
- raise RuntimeError, "fdouble(double)"
+ raise RuntimeError("fdouble(double)")
if fdouble(3) != "fdouble:double":
- raise RuntimeError, "fdouble(double)"
+ raise RuntimeError("fdouble(double)")
if fdouble(3.0) != "fdouble:double":
- raise RuntimeError, "fdouble(double)"
+ raise RuntimeError("fdouble(double)")
if fid(3, 3.0) != "fid:intdouble":
- raise RuntimeError, "fid:intdouble"
+ raise RuntimeError("fid:intdouble")
if fid(3.0, 3) != "fid:doubleint":
- raise RuntimeError, "fid:doubleint"
+ raise RuntimeError("fid:doubleint")
if fid(ad, ai) != "fid:doubleint":
- raise RuntimeError, "fid:doubleint"
+ raise RuntimeError("fid:doubleint")
if fid(ai, ad) != "fid:intdouble":
- raise RuntimeError, "fid:intdouble"
+ raise RuntimeError("fid:intdouble")
if foo(3) != "foo:int":
- raise RuntimeError, "foo(int)"
+ raise RuntimeError("foo(int)")
if foo(3.0) != "foo:double":
- raise RuntimeError, "foo(double)"
+ raise RuntimeError("foo(double)")
if foo("hello") != "foo:char *":
- raise RuntimeError, "foo(char *)"
+ raise RuntimeError("foo(char *)")
f = Foo()
b = Bar()
if foo(f) != "foo:Foo *":
- raise RuntimeError, "foo(Foo *)"
+ raise RuntimeError("foo(Foo *)")
if foo(b) != "foo:Bar *":
- raise RuntimeError, "foo(Bar *)"
+ raise RuntimeError("foo(Bar *)")
v = malloc_void(32)
if foo(v) != "foo:void *":
- raise RuntimeError, "foo(void *)"
+ raise RuntimeError("foo(void *)")
s = Spam()
if s.foo(3) != "foo:int":
- raise RuntimeError, "Spam::foo(int)"
+ raise RuntimeError("Spam::foo(int)")
if s.foo(3.0) != "foo:double":
- raise RuntimeError, "Spam::foo(double)"
+ raise RuntimeError("Spam::foo(double)")
if s.foo("hello") != "foo:char *":
- raise RuntimeError, "Spam::foo(char *)"
+ raise RuntimeError("Spam::foo(char *)")
if s.foo(f) != "foo:Foo *":
- raise RuntimeError, "Spam::foo(Foo *)"
+ raise RuntimeError("Spam::foo(Foo *)")
if s.foo(b) != "foo:Bar *":
- raise RuntimeError, "Spam::foo(Bar *)"
+ raise RuntimeError("Spam::foo(Bar *)")
if s.foo(v) != "foo:void *":
- raise RuntimeError, "Spam::foo(void *)"
+ raise RuntimeError("Spam::foo(void *)")
if Spam_bar(3) != "bar:int":
- raise RuntimeError, "Spam::bar(int)"
+ raise RuntimeError("Spam::bar(int)")
if Spam_bar(3.0) != "bar:double":
- raise RuntimeError, "Spam::bar(double)"
+ raise RuntimeError("Spam::bar(double)")
if Spam_bar("hello") != "bar:char *":
- raise RuntimeError, "Spam::bar(char *)"
+ raise RuntimeError("Spam::bar(char *)")
if Spam_bar(f) != "bar:Foo *":
- raise RuntimeError, "Spam::bar(Foo *)"
+ raise RuntimeError("Spam::bar(Foo *)")
if Spam_bar(b) != "bar:Bar *":
- raise RuntimeError, "Spam::bar(Bar *)"
+ raise RuntimeError("Spam::bar(Bar *)")
if Spam_bar(v) != "bar:void *":
- raise RuntimeError, "Spam::bar(void *)"
+ raise RuntimeError("Spam::bar(void *)")
# Test constructors
s = Spam()
if s.type != "none":
- raise RuntimeError, "Spam()"
+ raise RuntimeError("Spam()")
s = Spam(3)
if s.type != "int":
- raise RuntimeError, "Spam(int)"
+ raise RuntimeError("Spam(int)")
s = Spam(3.4)
if s.type != "double":
- raise RuntimeError, "Spam(double)"
+ raise RuntimeError("Spam(double)")
s = Spam("hello")
if s.type != "char *":
- raise RuntimeError, "Spam(char *)"
+ raise RuntimeError("Spam(char *)")
s = Spam(f)
if s.type != "Foo *":
- raise RuntimeError, "Spam(Foo *)"
+ raise RuntimeError("Spam(Foo *)")
s = Spam(b)
if s.type != "Bar *":
- raise RuntimeError, "Spam(Bar *)"
+ raise RuntimeError("Spam(Bar *)")
s = Spam(v)
if s.type != "void *":
- raise RuntimeError, "Spam(void *)"
+ raise RuntimeError("Spam(void *)")
# unsigned long long
@@ -168,13 +168,13 @@ ullmaxd = 9007199254740992.0
ullmin = 0
ullmind = 0.0
if ull(ullmin) != ullmin:
- raise runtimeerror, "ull(ullmin)"
+ raise RuntimeError("ull(ullmin)")
if ull(ullmax) != ullmax:
- raise runtimeerror, "ull(ullmax)"
+ raise RuntimeError("ull(ullmax)")
if ull(ullmind) != ullmind:
- raise RuntimeError, "ull(ullmind)"
+ raise RuntimeError("ull(ullmind)")
if ull(ullmaxd) != ullmaxd:
- raise RuntimeError, "ull(ullmaxd)"
+ raise RuntimeError("ull(ullmaxd)")
# long long
llmax = 9223372036854775807 # 0x7fffffffffffffff
@@ -183,13 +183,13 @@ llmin = -9223372036854775808
llmaxd = 9007199254740992.0
llmind = -9007199254740992.0
if ll(llmin) != llmin:
- raise runtimeerror, "ll(llmin)"
+ raise RuntimeError("ll(llmin)")
if ll(llmax) != llmax:
- raise runtimeerror, "ll(llmax)"
+ raise RuntimeError("ll(llmax)")
if ll(llmind) != llmind:
- raise RuntimeError, "ll(llmind)"
+ raise RuntimeError("ll(llmind)")
if ll(llmaxd) != llmaxd:
- raise RuntimeError, "ll(llmaxd)"
+ raise RuntimeError("ll(llmaxd)")
free_void(v)
diff --git a/Examples/test-suite/python/python_pickle_runme.py b/Examples/test-suite/python/python_pickle_runme.py
index cf2847919..cbe425fa2 100644
--- a/Examples/test-suite/python/python_pickle_runme.py
+++ b/Examples/test-suite/python/python_pickle_runme.py
@@ -3,17 +3,11 @@ import python_pickle
import pickle
import sys
-def is_new_style_class(cls):
- return hasattr(cls, "__class__")
-
def check(p):
msg = p.msg
if msg != "hi there":
raise RuntimeError("Bad, got: " + msg)
-if not is_new_style_class(python_pickle.PickleMe):
- sys.exit(0)
-
python_pickle.cvar.debug = False
p = python_pickle.PickleMe("hi there")
@@ -21,15 +15,15 @@ check(p)
r = p.__reduce__()
if python_pickle.cvar.debug:
- print "__reduce__ returned:", r
+ print("__reduce__ returned: {}".format(r))
pickle_string = pickle.dumps(p)
newp = pickle.loads(pickle_string)
check(newp)
# Not yet working... some crash and others are not producing a sensible "can't be pickled" error
#nfp = python_pickle.NotForPickling("no no")
-#print nfp.__reduce__()
+#print("{}".format(nfp.__reduce__()))
#pickle_string = pickle.dumps(nfp)
-#print pickle_string
+#print("{}".format(pickle_string))
#newp = pickle.loads(pickle_string)
-#print newp.msg
+#print("{}".format(newp.msg))
diff --git a/Examples/test-suite/python/python_pybuf_runme3.py b/Examples/test-suite/python/python_pybuf_runme3.py
deleted file mode 100644
index 4e57b69e8..000000000
--- a/Examples/test-suite/python/python_pybuf_runme3.py
+++ /dev/null
@@ -1,41 +0,0 @@
-# run:
-# python python_pybuf_runme3.py benchmark
-# for the benchmark, other wise the test case will be run
-import python_pybuf
-import sys
-if len(sys.argv) >= 2 and sys.argv[1] == "benchmark":
- # run the benchmark
- import time
- k = 1000000 # number of times to excute the functions
-
- t = time.time()
- a = bytearray(b'hello world')
- for i in range(k):
- pybuf.title1(a)
- print("Time used by bytearray:", time.time() - t)
-
- t = time.time()
- b = 'hello world'
- for i in range(k):
- pybuf.title2(b)
- print("Time used by string:", time.time() - t)
-else:
- # run the test case
- buf1 = bytearray(10)
- buf2 = bytearray(50)
-
- pybuf.func1(buf1)
- assert buf1 == b'a' * 10
-
- pybuf.func2(buf2)
- assert buf2.startswith(b"Hello world!\x00")
-
- count = pybuf.func3(buf2)
- assert count == 10 # number of alpha and number in 'Hello world!'
-
- length = pybuf.func4(buf2)
- assert length == 12
-
- buf3 = bytearray(b"hello")
- pybuf.title1(buf3)
- assert buf3 == b'Hello'
diff --git a/Examples/test-suite/python/python_pybuffer_runme.py b/Examples/test-suite/python/python_pybuffer_runme.py
new file mode 100644
index 000000000..65079200b
--- /dev/null
+++ b/Examples/test-suite/python/python_pybuffer_runme.py
@@ -0,0 +1,70 @@
+# run:
+# python python_pybuffer_runme.py benchmark
+# for the benchmark, other wise the test case will be run
+import python_pybuffer
+import sys
+
+def check(flag):
+ if not flag:
+ raise RuntimeError("Test failed")
+
+if len(sys.argv) >= 2 and sys.argv[1] == "benchmark":
+ # run the benchmark
+ import time
+ k = 1000000 # number of times to execute the functions
+
+ t = time.time()
+ a = bytearray(b"hello world")
+ for i in range(k):
+ python_pybuffer.title1(a)
+ print("Time used by bytearray: {}".format(time.time() - t))
+
+ t = time.time()
+ b = "hello world"
+ for i in range(k):
+ python_pybuffer.title2(b)
+ print("Time used by string: {}".format(time.time() - t))
+else:
+ # run the test case
+ buf1 = bytearray(10)
+ buf2 = bytearray(50)
+
+ python_pybuffer.func1(buf1)
+ check(buf1 == b"a" * 10)
+
+ python_pybuffer.func2(buf2)
+ check(buf2.startswith(b"Hello world!\x00"))
+
+ count = python_pybuffer.func3(buf2)
+ check(count == 10) # number of alpha and number in 'Hello world!'
+
+ length = python_pybuffer.func4(buf2)
+ check(length == 12)
+
+ buf3 = bytearray(b"hello")
+ python_pybuffer.title1(buf3)
+ check(buf3 == b"Hello")
+
+ try:
+ python_pybuffer.func1(1)
+ raise RuntimeError("should throw TypeError")
+ except TypeError as e:
+ check("(char *buf1, int len)" in str(e))
+
+ try:
+ python_pybuffer.func2(1)
+ raise RuntimeError("should throw TypeError")
+ except TypeError as e:
+ check("(char *buf2)" in str(e))
+
+ try:
+ python_pybuffer.func3(1)
+ raise RuntimeError("should throw TypeError")
+ except TypeError as e:
+ check("(const char *buf3, int len)" in str(e))
+
+ try:
+ python_pybuffer.func4(1)
+ raise RuntimeError("should throw TypeError")
+ except TypeError as e:
+ check("(const char *buf4)" in str(e))
diff --git a/Examples/test-suite/python/python_pythoncode_runme.py b/Examples/test-suite/python/python_pythoncode_runme.py
index da238780d..c27f4452d 100644
--- a/Examples/test-suite/python/python_pythoncode_runme.py
+++ b/Examples/test-suite/python/python_pythoncode_runme.py
@@ -3,3 +3,7 @@ import python_pythoncode
# No need to actually do anything, this is a regression test for a bug which
# caused an invalid python_pythoncode.py to be generated, so if we can import
# it the bug is still fixed.
+
+# A later test enhancement checking __new__ requires some code...
+f = python_pythoncode.get_foo()
+f = python_pythoncode.Foo()
diff --git a/Examples/test-suite/python/python_richcompare_runme.py b/Examples/test-suite/python/python_richcompare_runme.py
index a68da2f98..988a3f91f 100644
--- a/Examples/test-suite/python/python_richcompare_runme.py
+++ b/Examples/test-suite/python/python_richcompare_runme.py
@@ -1,4 +1,10 @@
import python_richcompare
+import sys
+
+def check_unorderable_types(exception):
+# if str(exception).find("unorderable types") == -1:
+# raise RuntimeError("A TypeError 'unorderable types' exception was expected"), None, sys.exc_info()[2]
+ pass # Exception message seems to vary from one version of Python to another
base1 = python_richcompare.BaseClass(1)
base2 = python_richcompare.BaseClass(2)
@@ -65,6 +71,18 @@ if (b1 == a1):
raise RuntimeError(
"Comparing equivalent instances of different subclasses, == returned True")
+# Check comparison to other objects
+#-------------------------------------------------------------------------------
+if (base1 == 42) :
+ raise RuntimeError("Comparing class to incompatible type, == returned True")
+if not (base1 != 42) :
+ raise RuntimeError("Comparing class to incompatible type, != returned False")
+
+if (a1 == 42) :
+ raise RuntimeError("Comparing class (with overloaded operator ==) to incompatible type, == returned True")
+if not (a1 != 42) :
+ raise RuntimeError("Comparing class (with overloaded operator ==) to incompatible type, != returned False")
+
# Check inequalities
#-------------------------------------------------------------------------
@@ -80,6 +98,40 @@ if not (a2 >= b2):
if not (a2 <= b2):
raise RuntimeError("operator<= failed")
+# Check inequalities to other objects
+#-------------------------------------------------------------------------------
+if sys.version_info[0:2] < (3, 0):
+ if (base1 < 42):
+ raise RuntimeError("Comparing class to incompatible type, < returned True")
+ if (base1 <= 42):
+ raise RuntimeError("Comparing class to incompatible type, <= returned True")
+ if not (base1 > 42):
+ raise RuntimeError("Comparing class to incompatible type, > returned False")
+ if not (base1 >= 42):
+ raise RuntimeError("Comparing class to incompatible type, >= returned False")
+else:
+ # Python 3 throws: TypeError: unorderable types
+ try:
+ res = base1 < 42
+ raise RuntimeError("Failed to throw")
+ except TypeError as e:
+ check_unorderable_types(e)
+ try:
+ res = base1 <= 42
+ raise RuntimeError("Failed to throw")
+ except TypeError as e:
+ check_unorderable_types(e)
+ try:
+ res = base1 > 42
+ raise RuntimeError("Failed to throw")
+ except TypeError as e:
+ check_unorderable_types(e)
+ try:
+ res = base1 >= 42
+ raise RuntimeError("Failed to throw")
+ except TypeError as e:
+ check_unorderable_types(e)
+
# Check inequalities used for ordering
#-------------------------------------------------------------------------
diff --git a/Examples/test-suite/python/python_strict_unicode_runme.py b/Examples/test-suite/python/python_strict_unicode_runme.py
index 642e127fa..79c768de1 100644
--- a/Examples/test-suite/python/python_strict_unicode_runme.py
+++ b/Examples/test-suite/python/python_strict_unicode_runme.py
@@ -1,16 +1,20 @@
import python_strict_unicode
-from sys import version_info
+import sys
-test_bytes = 'hello \x01world\x99'
-BYTES = 'BYTES'
-test_unicode = u'h\udce9llo w\u00f6rld'
+test_bytes = b"hello \x01world\x99"
+BYTES = b"BYTES"
-# Python < 2.6 rejects the b prefix for byte string literals as a SyntaxError,
-# so instead create Python3 bytes objects by encoding unicode strings as
-# latin-1, which maps code points 0-255 directly to the corresponding bytes.
-if version_info[0] >= 3:
- test_bytes = test_bytes.encode('latin-1')
- BYTES = BYTES.encode('latin-1')
+if sys.version_info[0:2] < (3, 0):
+ # Python 3.0-3.2 results in a SyntaxError when using u"" string literals, so we use a
+ # convoluted unicode string construction using unicode() and unichr().
+ # Conventional Python 2 syntax shown in comments.
+ test_unicode = unicode("h" + unichr(0xdce9) + "llo w" + unichr(0x00f6) + "rld") # u"h\udce9llo w\u00f6rld"
+ UNICODE = unicode("UNICODE")
+ type_unicode_string = type(UNICODE)
+else:
+ test_unicode = "h\udce9llo w\u00f6rld"
+ UNICODE = "UNICODE"
+ type_unicode_string = type(UNICODE)
# Test that byte string inputs and outputs work as expected
bdbl = python_strict_unicode.double_str(test_bytes)
@@ -28,12 +32,12 @@ if type(bout) != type(BYTES):
udbl = python_strict_unicode.double_wstr(test_unicode)
if udbl != test_unicode + test_unicode:
raise RuntimeError("Failed to double wide string")
-if type(udbl) != type(u''):
+if type(udbl) != type_unicode_string:
raise RuntimeError("Wrong type output for wide string")
uout = python_strict_unicode.same_wstr(test_unicode)
if uout != test_unicode:
raise RuntimeError("Failed to copy wchar_t*")
-if type(uout) != type(u''):
+if type(uout) != type_unicode_string:
raise RuntimeError("Wrong type output for wchar_t*")
# Test that overloading is handled properly
@@ -43,9 +47,9 @@ if bovr != BYTES:
if type(bovr) != type(BYTES):
raise RuntimeError("Wrong type output from overload")
uovr = python_strict_unicode.overload(test_unicode)
-if uovr != u'UNICODE':
+if uovr != UNICODE:
raise RuntimeError("Failed to return unicode from overload")
-if type(uovr) != type(u''):
+if type(uovr) != type_unicode_string:
raise RuntimeERror("Wrong type output from overload")
# Test that bytes aren't accepted as wide strings and unicode isn't accepted as narrow strings
diff --git a/Examples/test-suite/python/reference_global_vars_runme.py b/Examples/test-suite/python/reference_global_vars_runme.py
index 6c2d181ac..6f86527b7 100644
--- a/Examples/test-suite/python/reference_global_vars_runme.py
+++ b/Examples/test-suite/python/reference_global_vars_runme.py
@@ -13,8 +13,8 @@ cvar.var_bool = createref_bool(True)
if value_bool(cvar.var_bool) != True:
raise RuntimeError
-cvar.var_char = createref_char('w')
-if value_char(cvar.var_char) != 'w':
+cvar.var_char = createref_char("w")
+if value_char(cvar.var_char) != "w":
raise RuntimeError
cvar.var_unsigned_char = createref_unsigned_char(10)
diff --git a/Examples/test-suite/python/return_const_value_runme.py b/Examples/test-suite/python/return_const_value_runme.py
index 947102840..809eed97a 100644
--- a/Examples/test-suite/python/return_const_value_runme.py
+++ b/Examples/test-suite/python/return_const_value_runme.py
@@ -3,10 +3,8 @@ import sys
p = return_const_value.Foo_ptr_getPtr()
if (p.getVal() != 17):
- print "Runtime test1 faild. p.getVal()=", p.getVal()
- sys.exit(1)
+ raise RuntimeError("Runtime test1 failed. p.getVal()={}".format(p.getVal()))
p = return_const_value.Foo_ptr_getConstPtr()
if (p.getVal() != 17):
- print "Runtime test2 faild. p.getVal()=", p.getVal()
- sys.exit(1)
+ raise RuntimeError("Runtime test2 failed. p.getVal()={}".format(p.getVal()))
diff --git a/Examples/test-suite/python/smart_pointer_member_runme.py b/Examples/test-suite/python/smart_pointer_member_runme.py
index ce91da2bd..9758b0ba4 100644
--- a/Examples/test-suite/python/smart_pointer_member_runme.py
+++ b/Examples/test-suite/python/smart_pointer_member_runme.py
@@ -1,9 +1,6 @@
from smart_pointer_member import *
-def is_new_style_class(cls):
- return hasattr(cls, "__class__")
-
f = Foo()
f.y = 1
@@ -14,9 +11,7 @@ b = Bar(f)
b.y = 2
if f.y != 2:
- print f.y
- print b.y
- raise RuntimeError
+ raise RuntimeError("Failed {} {}".format(f.y, b.y))
if b.x != f.x:
raise RuntimeError
@@ -24,6 +19,5 @@ if b.x != f.x:
if b.z != f.z:
raise RuntimeError
-if is_new_style_class(Bar): # feature not supported in old style classes
- if Foo.z == Bar.z:
- raise RuntimeError
+if Foo.z == Bar.z:
+ raise RuntimeError
diff --git a/Examples/test-suite/python/smart_pointer_not_runme.py b/Examples/test-suite/python/smart_pointer_not_runme.py
index 69704c4ef..8cd9f11f3 100644
--- a/Examples/test-suite/python/smart_pointer_not_runme.py
+++ b/Examples/test-suite/python/smart_pointer_not_runme.py
@@ -7,36 +7,36 @@ g = Grok(f)
try:
x = b.x
- print "Error! b.x"
-except:
+ raise RuntimeError("Error! b.x")
+except AttributeError:
pass
try:
x = s.x
- print "Error! s.x"
-except:
+ raise RuntimeError("Error! s.x")
+except AttributeError:
pass
try:
x = g.x
- print "Error! g.x"
-except:
+ raise RuntimeError("Error! g.x")
+except AttributeError:
pass
try:
x = b.getx()
- print "Error! b.getx()"
-except:
+ raise RuntimeError("Error! b.getx()")
+except AttributeError:
pass
try:
x = s.getx()
- print "Error! s.getx()"
-except:
+ raise RuntimeError("Error! s.getx()")
+except AttributeError:
pass
try:
x = g.getx()
- print "Error! g.getx()"
-except:
+ raise RuntimeError("Error! g.getx()")
+except AttributeError:
pass
diff --git a/Examples/test-suite/python/std_containers_runme.py b/Examples/test-suite/python/std_containers_runme.py
index d4625daa0..820c8f454 100644
--- a/Examples/test-suite/python/std_containers_runme.py
+++ b/Examples/test-suite/python/std_containers_runme.py
@@ -7,34 +7,33 @@ cube = (((1, 2), (3, 4)), ((5, 6), (7, 8)))
icube = std_containers.cident(cube)
for i in range(0, len(cube)):
if cube[i] != icube[i]:
- raise RuntimeError, "bad cident"
+ raise RuntimeError("bad cident")
p = (1, 2)
if p != std_containers.pident(p):
- raise RuntimeError, "bad pident"
+ raise RuntimeError("bad pident")
v = (1, 2, 3, 4, 5, 6)
iv = std_containers.vident(v)
for i in range(0, len(v)):
if v[i] != iv[i]:
- raise RuntimeError, "bad vident"
+ raise RuntimeError("bad vident")
iv = std_containers.videntu(v)
for i in range(0, len(v)):
if v[i] != iv[i]:
- raise RuntimeError, "bad videntu"
+ raise RuntimeError("bad videntu")
vu = std_containers.vector_ui(v)
if vu[2] != std_containers.videntu(vu)[2]:
- raise RuntimeError, "bad videntu"
+ raise RuntimeError("bad videntu")
if v[0:3][1] != vu[0:3][1]:
- print v[0:3][1], vu[0:3][1]
- raise RuntimeError, "bad getslice"
+ raise RuntimeError("bad getslice {} {}".format(v[0:3][1], vu[0:3][1]))
m = ((1, 2, 3), (2, 3), (3, 4))
@@ -43,32 +42,41 @@ im = std_containers.midenti(m)
for i in range(0, len(m)):
for j in range(0, len(m[i])):
if m[i][j] != im[i][j]:
- raise RuntimeError, "bad getslice"
+ raise RuntimeError("bad getslice")
m = ((True, False, True), (True, True), (True, True))
im = std_containers.midentb(m)
for i in range(0, len(m)):
for j in range(0, len(m[i])):
if m[i][j] != im[i][j]:
- raise RuntimeError, "bad getslice"
+ raise RuntimeError("bad getslice")
mi = std_containers.imatrix(m)
mc = std_containers.cmatrix(m)
if mi[0][1] != mc[0][1]:
- raise RuntimeError, "bad matrix"
+ raise RuntimeError("bad matrix")
map = {}
-map['hello'] = 1
-map['hi'] = 2
-map['3'] = 2
+map["hello"] = 1
+map["hi"] = 2
+map["3"] = 2
imap = std_containers.mapident(map)
for k in map:
if map[k] != imap[k]:
- raise RuntimeError, "bad map"
-
+ raise RuntimeError("bad map")
+
+# Test __contains__ (required for 'x in y' to work)
+if not imap.__contains__("hello"):
+ raise RuntimeError("hello imap.__contains__")
+if "hello" not in imap:
+ raise RuntimeError("hello not in imap")
+if imap.__contains__("oops"):
+ raise RuntimeError("oops imap.__contains__")
+if "oops" in imap:
+ raise RuntimeError("oops in imap")
mapc = {}
c1 = std_containers.C()
@@ -114,3 +122,14 @@ for i in s:
if i != j:
raise RuntimeError
j = j + 1
+
+# Test __contains__ (required for 'x in y' to work)
+if not s.__contains__(3):
+ raise RuntimeError("3 s.__contains__")
+if 3 not in s:
+ raise RuntimeError("3 not in s")
+if s.__contains__(-1):
+ raise RuntimeError("-1 s.__contains__")
+if -1 in s:
+ raise RuntimeError("-1 in s")
+
diff --git a/Examples/test-suite/python/struct_value_runme.py b/Examples/test-suite/python/struct_value_runme.py
index aa3ece38c..9fe5c815c 100644
--- a/Examples/test-suite/python/struct_value_runme.py
+++ b/Examples/test-suite/python/struct_value_runme.py
@@ -17,7 +17,7 @@ b.added = 123
if b.added != 123:
raise RuntimeError("Wrong attribute value")
-if not b.__dict__.has_key("added"):
+if "added" not in b.__dict__:
raise RuntimeError("Missing added attribute in __dict__")
@@ -28,7 +28,7 @@ class PyBar(struct_value.Bar):
struct_value.Bar.__init__(self)
pybar = PyBar()
-if not pybar.__dict__.has_key("extra"):
+if "extra" not in pybar.__dict__:
raise RuntimeError("Missing extra attribute in __dict__")
if pybar.extra != "hi":
raise RuntimeError("Incorrect attribute value for extra")
diff --git a/Examples/test-suite/python/swigobject_runme.py b/Examples/test-suite/python/swigobject_runme.py
index 346b05d40..e28e187c9 100644
--- a/Examples/test-suite/python/swigobject_runme.py
+++ b/Examples/test-suite/python/swigobject_runme.py
@@ -1,5 +1,5 @@
-
from swigobject import *
+import sys
a = A()
@@ -11,25 +11,33 @@ if a1.this != a2.this:
raise RuntimeError
-lthis = long(a.this)
+if sys.version_info[0:2] < (3, 0):
+ lthis = long(a.this)
+else:
+ lthis = int(a.this)
+
# match pointer value, but deal with leading zeros on 8/16 bit systems and
# different C++ compilers interpretation of %p
xstr1 = "%016X" % (lthis,)
-xstr1 = str.lstrip(xstr1, '0')
+xstr1 = str.lstrip(xstr1, "0")
xstr2 = pointer_str(a)
xstr2 = str.replace(xstr2, "0x", "")
xstr2 = str.replace(xstr2, "0X", "")
-xstr2 = str.lstrip(xstr2, '0')
+xstr2 = str.lstrip(xstr2, "0")
xstr2 = str.upper(xstr2)
if xstr1 != xstr2:
- print xstr1, xstr2
- raise RuntimeError
+ raise RuntimeError("Not equal failed {} {}".format(xstr1, xstr2))
s = str(a.this)
r = repr(a.this)
v1 = v_ptr(a)
v2 = v_ptr(a)
-if long(v1) != long(v2):
- raise RuntimeError
+
+if sys.version_info[0:2] < (3, 0):
+ if long(v1) != long(v2):
+ raise RuntimeError
+else:
+ if int(v1) != int(v2):
+ raise RuntimeError
diff --git a/Examples/test-suite/python/template_class_reuse_name_runme.py b/Examples/test-suite/python/template_class_reuse_name_runme.py
new file mode 100644
index 000000000..3ce427508
--- /dev/null
+++ b/Examples/test-suite/python/template_class_reuse_name_runme.py
@@ -0,0 +1,42 @@
+from template_class_reuse_name import *
+
+Bool1().tt()
+Bool1False().ff()
+
+Bool2().tt()
+Bool2False().ff()
+
+Bool3().tt()
+Bool3False().ff()
+
+Bool4().tt()
+Bool4False().ff()
+
+
+BoolForward1().tt()
+BoolForward1False().ff()
+
+BoolForward2().tt()
+BoolForward2False().ff()
+
+BoolForward3().tt()
+BoolForward3False().ff()
+
+BoolForward4().tt()
+BoolForward4False().ff()
+
+
+IntBool1().tt()
+IntBool1False().ff()
+
+IntBool2().tt()
+IntBool2False().ff()
+
+IntBool3().tt()
+IntBool3False().ff()
+
+IntBool4().tt()
+IntBool4False().ff()
+
+Duplicate2_0().n()
+Duplicate3().n()
diff --git a/Examples/test-suite/python/template_classes_runme.py b/Examples/test-suite/python/template_classes_runme.py
index 38b2d7a62..1bd133975 100644
--- a/Examples/test-suite/python/template_classes_runme.py
+++ b/Examples/test-suite/python/template_classes_runme.py
@@ -13,7 +13,7 @@ RectangleInt.static_onearg(1)
fail = True
try:
rectangle.setPoint()
-except TypeError, e:
+except TypeError as e:
fail = False
if fail:
raise RuntimeError("argument count check failed")
@@ -22,7 +22,7 @@ if fail:
fail = True
try:
rectangle.getPoint(0)
-except TypeError, e:
+except TypeError as e:
fail = False
if fail:
raise RuntimeError("argument count check failed")
@@ -30,7 +30,7 @@ if fail:
fail = True
try:
RectangleInt.static_noargs(0)
-except TypeError, e:
+except TypeError as e:
fail = False
if fail:
raise RuntimeError("argument count check failed")
@@ -38,7 +38,7 @@ if fail:
fail = True
try:
RectangleInt.static_onearg()
-except TypeError, e:
+except TypeError as e:
fail = False
if fail:
raise RuntimeError("argument count check failed")
diff --git a/Examples/test-suite/python/template_default_arg_runme.py b/Examples/test-suite/python/template_default_arg_runme.py
index 91b1e0e8c..e9ef00f99 100644
--- a/Examples/test-suite/python/template_default_arg_runme.py
+++ b/Examples/test-suite/python/template_default_arg_runme.py
@@ -7,25 +7,25 @@ helloInt.foo(template_default_arg.Hello_int.hi)
x = template_default_arg.X_int()
if (x.meth(20.0, 200) != 200):
- raise RuntimeError, ("X_int test 1 failed")
+ raise RuntimeError(("X_int test 1 failed"))
if (x.meth(20) != 20):
- raise RuntimeError, ("X_int test 2 failed")
+ raise RuntimeError(("X_int test 2 failed"))
if (x.meth() != 0):
- raise RuntimeError, ("X_int test 3 failed")
+ raise RuntimeError(("X_int test 3 failed"))
y = template_default_arg.Y_unsigned()
if (y.meth(20.0, 200) != 200):
- raise RuntimeError, ("Y_unsigned test 1 failed")
+ raise RuntimeError(("Y_unsigned test 1 failed"))
if (y.meth(20) != 20):
- raise RuntimeError, ("Y_unsigned test 2 failed")
+ raise RuntimeError(("Y_unsigned test 2 failed"))
if (y.meth() != 0):
- raise RuntimeError, ("Y_unsigned test 3 failed")
+ raise RuntimeError(("Y_unsigned test 3 failed"))
x = template_default_arg.X_longlong()
x = template_default_arg.X_longlong(20.0)
-x = template_default_arg.X_longlong(20.0, 200L)
+x = template_default_arg.X_longlong(20.0, 200)
x = template_default_arg.X_int()
@@ -54,40 +54,40 @@ fzc = x.meth(fz)
# plain function: int ott(Foo<int>)
if (template_default_arg.ott(template_default_arg.Foo_int()) != 30):
- raise RuntimeError, ("ott test 1 failed")
+ raise RuntimeError(("ott test 1 failed"))
# %template(ott) ott<int, int>
if (template_default_arg.ott() != 10):
- raise RuntimeError, ("ott test 2 failed")
+ raise RuntimeError(("ott test 2 failed"))
if (template_default_arg.ott(1) != 10):
- raise RuntimeError, ("ott test 3 failed")
+ raise RuntimeError(("ott test 3 failed"))
if (template_default_arg.ott(1, 1) != 10):
- raise RuntimeError, ("ott test 4 failed")
+ raise RuntimeError(("ott test 4 failed"))
if (template_default_arg.ott("hi") != 20):
- raise RuntimeError, ("ott test 5 failed")
+ raise RuntimeError(("ott test 5 failed"))
if (template_default_arg.ott("hi", 1) != 20):
- raise RuntimeError, ("ott test 6 failed")
+ raise RuntimeError(("ott test 6 failed"))
if (template_default_arg.ott("hi", 1, 1) != 20):
- raise RuntimeError, ("ott test 7 failed")
+ raise RuntimeError(("ott test 7 failed"))
# %template(ott) ott<const char *>
if (template_default_arg.ottstring(template_default_arg.Hello_int(), "hi") != 40):
- raise RuntimeError, ("ott test 8 failed")
+ raise RuntimeError(("ott test 8 failed"))
if (template_default_arg.ottstring(template_default_arg.Hello_int()) != 40):
- raise RuntimeError, ("ott test 9 failed")
+ raise RuntimeError(("ott test 9 failed"))
# %template(ott) ott<int>
if (template_default_arg.ottint(template_default_arg.Hello_int(), 1) != 50):
- raise RuntimeError, ("ott test 10 failed")
+ raise RuntimeError(("ott test 10 failed"))
if (template_default_arg.ottint(template_default_arg.Hello_int()) != 50):
- raise RuntimeError, ("ott test 11 failed")
+ raise RuntimeError(("ott test 11 failed"))
# %template(ott) ott<double>
if (template_default_arg.ott(template_default_arg.Hello_int(), 1.0) != 60):
- raise RuntimeError, ("ott test 12 failed")
+ raise RuntimeError(("ott test 12 failed"))
if (template_default_arg.ott(template_default_arg.Hello_int()) != 60):
- raise RuntimeError, ("ott test 13 failed")
+ raise RuntimeError(("ott test 13 failed"))
diff --git a/Examples/test-suite/python/template_default_cache_runme.py b/Examples/test-suite/python/template_default_cache_runme.py
new file mode 100644
index 000000000..ffe155acf
--- /dev/null
+++ b/Examples/test-suite/python/template_default_cache_runme.py
@@ -0,0 +1,9 @@
+import template_default_cache
+
+ap = template_default_cache.get_mp_a();
+bp = template_default_cache.get_mp_b();
+
+if not isinstance(ap, template_default_cache.AModelPtr):
+ raise RuntimeError("get_mp_a fail")
+if not isinstance(bp, template_default_cache.BModelPtr):
+ raise RuntimeError("get_mp_b fail")
diff --git a/Examples/test-suite/python/template_typedef_cplx2_runme.py b/Examples/test-suite/python/template_typedef_cplx2_runme.py
index 3043d4285..23f19efb9 100644
--- a/Examples/test-suite/python/template_typedef_cplx2_runme.py
+++ b/Examples/test-suite/python/template_typedef_cplx2_runme.py
@@ -8,25 +8,21 @@ try:
d = make_Identity_double()
a = d.this
except:
- print d, "is not an instance"
- raise RuntimeError
+ raise RuntimeError("{} is not an instance".format(d))
-s = '%s' % d
-if str.find(s, 'ArithUnaryFunction') == -1:
- print d, "is not an ArithUnaryFunction"
- raise RuntimeError
+s = "%s" % d
+if str.find(s, "ArithUnaryFunction") == -1:
+ raise RuntimeError("{} is not an ArithUnaryFunction".format(d))
try:
e = make_Multiplies_double_double_double_double(d, d)
a = e.this
except:
- print e, "is not an instance"
- raise RuntimeError
+ raise RuntimeError("{} is not an instance".format(e))
-s = '%s' % e
-if str.find(s, 'ArithUnaryFunction') == -1:
- print e, "is not an ArithUnaryFunction"
- raise RuntimeError
+s = "%s" % e
+if str.find(s, "ArithUnaryFunction") == -1:
+ raise RuntimeError("{} is not an ArithUnaryFunction".format(e))
#
@@ -37,25 +33,21 @@ try:
c = make_Identity_complex()
a = c.this
except:
- print c, "is not an instance"
- raise RuntimeError
+ raise RuntimeError("{} is not an instance".format(c))
-s = '%s' % c
-if str.find(s, 'ArithUnaryFunction') == -1:
- print c, "is not an ArithUnaryFunction"
- raise RuntimeError
+s = "%s" % c
+if str.find(s, "ArithUnaryFunction") == -1:
+ raise RuntimeError("{} is not an ArithUnaryFunction".format(c))
try:
f = make_Multiplies_complex_complex_complex_complex(c, c)
a = f.this
except:
- print f, "is not an instance"
- raise RuntimeError
+ raise RuntimeError("{} is not an instance".format(f))
-s = '%s' % f
-if str.find(s, 'ArithUnaryFunction') == -1:
- print f, "is not an ArithUnaryFunction"
- raise RuntimeError
+s = "%s" % f
+if str.find(s, "ArithUnaryFunction") == -1:
+ raise RuntimeError("{} is not an ArithUnaryFunction".format(f))
#
# Mix case
@@ -65,29 +57,24 @@ try:
g = make_Multiplies_double_double_complex_complex(d, c)
a = g.this
except:
- print g, "is not an instance"
- raise RuntimeError
+ raise RuntimeError("{} is not an instance".format(g))
-s = '%s' % g
-if str.find(s, 'ArithUnaryFunction') == -1:
- print g, "is not an ArithUnaryFunction"
- raise RuntimeError
+s = "%s" % g
+if str.find(s, "ArithUnaryFunction") == -1:
+ raise RuntimeError("{} is not an ArithUnaryFunction".format(g))
try:
h = make_Multiplies_complex_complex_double_double(c, d)
a = h.this
except:
- print h, "is not an instance"
- raise RuntimeError
+ raise RuntimeError("{} is not an instance".format(h))
-s = '%s' % h
-if str.find(s, 'ArithUnaryFunction') == -1:
- print h, "is not an ArithUnaryFunction"
- raise RuntimeError
+s = "%s" % h
+if str.find(s, "ArithUnaryFunction") == -1:
+ raise RuntimeError("{} is not an ArithUnaryFunction".format(h))
try:
a = g.get_value()
except:
- print g, "has not get_value() method"
- raise RuntimeError
+ raise RuntimeError("{}, has not get_value() method".format(g))
diff --git a/Examples/test-suite/python/template_typedef_cplx_runme.py b/Examples/test-suite/python/template_typedef_cplx_runme.py
index afb97d070..69d5642d6 100644
--- a/Examples/test-suite/python/template_typedef_cplx_runme.py
+++ b/Examples/test-suite/python/template_typedef_cplx_runme.py
@@ -8,25 +8,21 @@ try:
d = make_Identity_double()
a = d.this
except:
- print d, "is not an instance"
- raise RuntimeError
+ raise RuntimeError("{} is not an instance".format(d))
-s = '%s' % d
-if str.find(s, 'ArithUnaryFunction') == -1:
- print d, "is not an ArithUnaryFunction"
- raise RuntimeError
+s = "%s" % d
+if str.find(s, "ArithUnaryFunction") == -1:
+ raise RuntimeError("{} is not an ArithUnaryFunction".format(d))
try:
e = make_Multiplies_double_double_double_double(d, d)
a = e.this
except:
- print e, "is not an instance"
- raise RuntimeError
+ raise RuntimeError("{} is not an instance".format(e))
-s = '%s' % e
-if str.find(s, 'ArithUnaryFunction') == -1:
- print e, "is not an ArithUnaryFunction"
- raise RuntimeError
+s = "%s" % e
+if str.find(s, "ArithUnaryFunction") == -1:
+ raise RuntimeError("{} is not an ArithUnaryFunction".format(e))
#
@@ -37,25 +33,21 @@ try:
c = make_Identity_complex()
a = c.this
except:
- print c, "is not an instance"
- raise RuntimeError
+ raise RuntimeError("{} is not an instance".format(c))
-s = '%s' % c
-if str.find(s, 'ArithUnaryFunction') == -1:
- print c, "is not an ArithUnaryFunction"
- raise RuntimeError
+s = "%s" % c
+if str.find(s, "ArithUnaryFunction") == -1:
+ raise RuntimeError("{} is not an ArithUnaryFunction".format(c))
try:
f = make_Multiplies_complex_complex_complex_complex(c, c)
a = f.this
except:
- print f, "is not an instance"
- raise RuntimeError
+ raise RuntimeError("{} is not an instance".format(f))
-s = '%s' % f
-if str.find(s, 'ArithUnaryFunction') == -1:
- print f, "is not an ArithUnaryFunction"
- raise RuntimeError
+s = "%s" % f
+if str.find(s, "ArithUnaryFunction") == -1:
+ raise RuntimeError("{} is not an ArithUnaryFunction".format(f))
#
# Mix case
@@ -65,23 +57,19 @@ try:
g = make_Multiplies_double_double_complex_complex(d, c)
a = g.this
except:
- print g, "is not an instance"
- raise RuntimeError
+ raise RuntimeError("{} is not an instance".format(g))
-s = '%s' % g
-if str.find(s, 'ArithUnaryFunction') == -1:
- print g, "is not an ArithUnaryFunction"
- raise RuntimeError
+s = "%s" % g
+if str.find(s, "ArithUnaryFunction") == -1:
+ raise RuntimeError("{} is not an ArithUnaryFunction".format(g))
try:
h = make_Multiplies_complex_complex_double_double(c, d)
a = h.this
except:
- print h, "is not an instance"
- raise RuntimeError
+ raise RuntimeError("{} is not an instance".format(h))
-s = '%s' % h
-if str.find(s, 'ArithUnaryFunction') == -1:
- print h, "is not an ArithUnaryFunction"
- raise RuntimeError
+s = "%s" % h
+if str.find(s, "ArithUnaryFunction") == -1:
+ raise RuntimeError("{} is not an ArithUnaryFunction".format(h))
diff --git a/Examples/test-suite/python/template_typedef_runme.py b/Examples/test-suite/python/template_typedef_runme.py
index 16695bada..5723e4f59 100644
--- a/Examples/test-suite/python/template_typedef_runme.py
+++ b/Examples/test-suite/python/template_typedef_runme.py
@@ -14,22 +14,19 @@ try:
e = make_Multiplies_float_float_float_float(d, d)
a = e.this
except:
- print e, "is not an instance"
- raise RuntimeError
+ raise RuntimeError("{} is not an instance".format(e))
try:
f = make_Multiplies_reald_reald_reald_reald(c, c)
a = f.this
except:
- print f, "is not an instance"
- raise RuntimeError
+ raise RuntimeError("{} is not an instance".format(f))
try:
g = make_Multiplies_float_float_reald_reald(d, c)
a = g.this
except:
- print g, "is not an instance"
- raise RuntimeError
+ raise RuntimeError("{} is not an instance".format(g))
# the old large format
diff --git a/Examples/test-suite/python/template_typemaps_typedef2_runme.py b/Examples/test-suite/python/template_typemaps_typedef2_runme.py
index 258f44366..da26a9f76 100644
--- a/Examples/test-suite/python/template_typemaps_typedef2_runme.py
+++ b/Examples/test-suite/python/template_typemaps_typedef2_runme.py
@@ -5,7 +5,7 @@ m1 = MultimapIntA()
dummy_pair = m1.make_dummy_pair()
val = m1.typemap_test(dummy_pair).val
if val != 1234:
- raise RuntimeError, "typemaps not working"
+ raise RuntimeError("typemaps not working")
m2 = MultimapAInt()
@@ -13,24 +13,24 @@ m2 = MultimapAInt()
#dummy_pair = m2.make_dummy_pair()
#val = m2.typemap_test(dummy_pair)
-# print val
+# print("{}".format(val))
# if val != 4321:
# raise RuntimeError, "typemaps not working"
if typedef_test1(dummy_pair).val != 1234:
- raise RuntimeError, "typedef_test1 not working"
+ raise RuntimeError("typedef_test1 not working")
if typedef_test2(dummy_pair).val != 1234:
- raise RuntimeError, "typedef_test2 not working"
+ raise RuntimeError("typedef_test2 not working")
if typedef_test3(dummy_pair).val != 1234:
- raise RuntimeError, "typedef_test3 not working"
+ raise RuntimeError("typedef_test3 not working")
if typedef_test4(dummy_pair).val != 1234:
- raise RuntimeError, "typedef_test4 not working"
+ raise RuntimeError("typedef_test4 not working")
if typedef_test5(dummy_pair).val != 1234:
- raise RuntimeError, "typedef_test5 not working"
+ raise RuntimeError("typedef_test5 not working")
if typedef_test6(dummy_pair).val != 1234:
- raise RuntimeError, "typedef_test6 not working"
+ raise RuntimeError("typedef_test6 not working")
diff --git a/Examples/test-suite/python/template_typemaps_typedef_runme.py b/Examples/test-suite/python/template_typemaps_typedef_runme.py
index 1ca3f835c..a5209b71f 100644
--- a/Examples/test-suite/python/template_typemaps_typedef_runme.py
+++ b/Examples/test-suite/python/template_typemaps_typedef_runme.py
@@ -5,7 +5,7 @@ m1 = MultimapIntA()
dummy_pair = m1.make_dummy_pair()
val = m1.typemap_test(dummy_pair).val
if val != 1234:
- raise RuntimeError, "typemaps not working"
+ raise RuntimeError("typemaps not working")
m2 = MultimapAInt()
@@ -13,24 +13,24 @@ m2 = MultimapAInt()
#dummy_pair = m2.make_dummy_pair()
#val = m2.typemap_test(dummy_pair)
-# print val
+# print("{}".format(val))
# if val != 4321:
# raise RuntimeError, "typemaps not working"
if typedef_test1(dummy_pair).val != 1234:
- raise RuntimeError, "typedef_test1 not working"
+ raise RuntimeError("typedef_test1 not working")
if typedef_test2(dummy_pair).val != 1234:
- raise RuntimeError, "typedef_test2 not working"
+ raise RuntimeError("typedef_test2 not working")
if typedef_test3(dummy_pair).val != 1234:
- raise RuntimeError, "typedef_test3 not working"
+ raise RuntimeError("typedef_test3 not working")
if typedef_test4(dummy_pair).val != 1234:
- raise RuntimeError, "typedef_test4 not working"
+ raise RuntimeError("typedef_test4 not working")
if typedef_test5(dummy_pair).val != 1234:
- raise RuntimeError, "typedef_test5 not working"
+ raise RuntimeError("typedef_test5 not working")
if typedef_test6(dummy_pair).val != 1234:
- raise RuntimeError, "typedef_test6 not working"
+ raise RuntimeError("typedef_test6 not working")
diff --git a/Examples/test-suite/python/template_using_directive_typedef_runme.py b/Examples/test-suite/python/template_using_directive_typedef_runme.py
new file mode 100644
index 000000000..363a3b754
--- /dev/null
+++ b/Examples/test-suite/python/template_using_directive_typedef_runme.py
@@ -0,0 +1,15 @@
+import template_using_directive_typedef
+
+vo = template_using_directive_typedef.Vector_Obj();
+
+h = template_using_directive_typedef.Holder();
+h.holder_use1(vo, vo, vo);
+h.holder_use2(vo, vo, vo);
+h.holder_use3(vo, vo, vo);
+
+template_using_directive_typedef.tns_holder_use(vo, vo);
+template_using_directive_typedef.tns_use(vo, vo, vo);
+template_using_directive_typedef.global_holder_use(vo);
+template_using_directive_typedef.global_use(vo, vo, vo);
+template_using_directive_typedef.ns1_holder_use(vo);
+template_using_directive_typedef.ns2_holder_use(vo, vo, vo, vo);
diff --git a/Examples/test-suite/python/threads_exception_runme.py b/Examples/test-suite/python/threads_exception_runme.py
index 056bd849b..e3f6299e7 100644
--- a/Examples/test-suite/python/threads_exception_runme.py
+++ b/Examples/test-suite/python/threads_exception_runme.py
@@ -3,18 +3,18 @@ import threads_exception
t = threads_exception.Test()
try:
t.unknown()
-except RuntimeError, e:
+except RuntimeError as e:
pass
try:
t.simple()
-except RuntimeError, e:
+except RuntimeError as e:
if e.args[0] != 37:
raise RuntimeError
try:
t.message()
-except RuntimeError, e:
+except RuntimeError as e:
if e.args[0] != "I died.":
raise RuntimeError
@@ -23,18 +23,18 @@ except RuntimeError, e:
if not threads_exception.is_python_builtin():
try:
t.hosed()
- except threads_exception.Exc, e:
+ except threads_exception.Exc as e:
code = e.code
if code != 42:
- raise RuntimeError, "bad... code: %d" % code
+ raise RuntimeError("bad... code: %d" % code)
msg = e.msg
if msg != "Hosed":
- raise RuntimeError, "bad... msg: '%s' len: %d" % (msg, len(msg))
+ raise RuntimeError("bad... msg: '%s' len: %d" % (msg, len(msg)))
for i in range(1, 4):
try:
t.multi(i)
- except RuntimeError, e:
+ except RuntimeError as e:
pass
- except threads_exception.Exc, e:
+ except threads_exception.Exc as e:
pass
diff --git a/Examples/test-suite/python/typedef_classforward_same_name_runme.py b/Examples/test-suite/python/typedef_classforward_same_name_runme.py
new file mode 100644
index 000000000..61f45fbee
--- /dev/null
+++ b/Examples/test-suite/python/typedef_classforward_same_name_runme.py
@@ -0,0 +1,11 @@
+from typedef_classforward_same_name import *
+
+foo = Foo()
+foo.x = 5
+if extractFoo(foo) != 5:
+ raise RuntimeError("unexpected value")
+
+boo = Boo()
+boo.x = 5
+if extractBoo(boo) != 5:
+ raise RuntimeError("unexpected value")
diff --git a/Examples/test-suite/python/typedef_funcptr_runme.py b/Examples/test-suite/python/typedef_funcptr_runme.py
new file mode 100644
index 000000000..a186963f7
--- /dev/null
+++ b/Examples/test-suite/python/typedef_funcptr_runme.py
@@ -0,0 +1,20 @@
+import typedef_funcptr
+
+a = 100
+b = 10
+
+if typedef_funcptr.do_op(a,b,typedef_funcptr.addf) != 110:
+ raise RuntimeError("addf failed")
+if typedef_funcptr.do_op(a,b,typedef_funcptr.subf) != 90:
+ raise RuntimeError("subf failed")
+
+if typedef_funcptr.do_op_typedef_int(a,b,typedef_funcptr.addf) != 110:
+ raise RuntimeError("addf failed")
+if typedef_funcptr.do_op_typedef_int(a,b,typedef_funcptr.subf) != 90:
+ raise RuntimeError("subf failed")
+
+if typedef_funcptr.do_op_typedef_Integer(a,b,typedef_funcptr.addf) != 110:
+ raise RuntimeError("addf failed")
+if typedef_funcptr.do_op_typedef_Integer(a,b,typedef_funcptr.subf) != 90:
+ raise RuntimeError("subf failed")
+
diff --git a/Examples/test-suite/python/typedef_inherit_runme.py b/Examples/test-suite/python/typedef_inherit_runme.py
index 6b7f2d872..3c552ec65 100644
--- a/Examples/test-suite/python/typedef_inherit_runme.py
+++ b/Examples/test-suite/python/typedef_inherit_runme.py
@@ -5,19 +5,19 @@ b = typedef_inherit.Bar()
x = typedef_inherit.do_blah(a)
if x != "Foo::blah":
- print "Whoa! Bad return", x
+ raise RuntimeError("Whoa! Bad return {}".format(x))
x = typedef_inherit.do_blah(b)
if x != "Bar::blah":
- print "Whoa! Bad return", x
+ raise RuntimeError("Whoa! Bad return {}".format(x))
c = typedef_inherit.Spam()
d = typedef_inherit.Grok()
x = typedef_inherit.do_blah2(c)
if x != "Spam::blah":
- print "Whoa! Bad return", x
+ raise RuntimeError("Whoa! Bad return {}".format(x))
x = typedef_inherit.do_blah2(d)
if x != "Grok::blah":
- print "Whoa! Bad return", x
+ raise RuntimeError("Whoa! Bad return {}".format(x))
diff --git a/Examples/test-suite/python/typedef_scope_runme.py b/Examples/test-suite/python/typedef_scope_runme.py
index edd3e9f3a..0294c4a07 100644
--- a/Examples/test-suite/python/typedef_scope_runme.py
+++ b/Examples/test-suite/python/typedef_scope_runme.py
@@ -3,8 +3,8 @@ import typedef_scope
b = typedef_scope.Bar()
x = b.test1(42, "hello")
if x != 42:
- print "Failed!!"
+ raise RuntimeError("Failed!!")
x = b.test2(42, "hello")
if x != "hello":
- print "Failed!!"
+ raise RuntimeError("Failed!!")
diff --git a/Examples/test-suite/python/typemap_arrays_runme.py b/Examples/test-suite/python/typemap_arrays_runme.py
index ea0f08d6b..7bc45f908 100644
--- a/Examples/test-suite/python/typemap_arrays_runme.py
+++ b/Examples/test-suite/python/typemap_arrays_runme.py
@@ -1,4 +1,4 @@
from typemap_arrays import *
if sumA(None) != 60:
- raise RuntimeError, "Sum is wrong"
+ raise RuntimeError("Sum is wrong")
diff --git a/Examples/test-suite/python/typemap_template_typedef_runme.py b/Examples/test-suite/python/typemap_template_typedef_runme.py
new file mode 100644
index 000000000..a2458367e
--- /dev/null
+++ b/Examples/test-suite/python/typemap_template_typedef_runme.py
@@ -0,0 +1,32 @@
+from typemap_template_typedef import *
+
+def check(got, expected):
+ if got != expected:
+ raise RuntimeError("got: " + str(got) + " expected: " + str(expected))
+
+x = XXXInt()
+
+check(x.aa1(0), 0)
+check(x.aa2(0), 55)
+check(x.aa3(0), 0)
+check(aa1(0), 0)
+check(aa2(0), 0)
+
+check(x.bb1(0), 0)
+check(x.bb2(0), 66)
+check(x.bb3(0), 0)
+check(bb1(0), 0)
+check(bb2(0), 0)
+
+check(x.cc1(0), 0)
+check(x.cc2(0), 77)
+check(x.cc3(0), 77)
+check(cc1(0), 0)
+check(cc2(0), 0)
+
+check(x.dd1(0), 0)
+check(x.dd2(0), 88)
+check(x.dd3(0), 0)
+check(dd1(0), 0)
+check(dd2(0), 0)
+
diff --git a/Examples/test-suite/python/typename_runme.py b/Examples/test-suite/python/typename_runme.py
index aac936fde..a4f76fc36 100644
--- a/Examples/test-suite/python/typename_runme.py
+++ b/Examples/test-suite/python/typename_runme.py
@@ -4,8 +4,8 @@ f = typename.Foo()
b = typename.Bar()
x = typename.twoFoo(f)
-if not isinstance(x, types.FloatType):
- raise RuntimeError, "Wrong return type (FloatType) !"
+if not isinstance(x, float):
+ raise RuntimeError("Wrong return type (FloatType) !")
y = typename.twoBar(b)
-if not isinstance(y, types.IntType):
- raise RuntimeError, "Wrong return type (IntType)!"
+if not isinstance(y, int):
+ raise RuntimeError("Wrong return type (IntType)!")
diff --git a/Examples/test-suite/python/unicode_strings_runme.py b/Examples/test-suite/python/unicode_strings_runme.py
index fa9c51437..57bd7abca 100644
--- a/Examples/test-suite/python/unicode_strings_runme.py
+++ b/Examples/test-suite/python/unicode_strings_runme.py
@@ -2,16 +2,12 @@ import sys
import unicode_strings
-# The 'u' string prefix isn't valid in Python 3.0 - 3.2 and is redundant
-# in 3.3+. Since this file is run through 2to3 before testing, though,
-# mark this as a unicode string in 2.x so it'll become a str in 3.x.
-test_string = u'h\udce9llo w\u00f6rld'
-
if sys.version_info[0:2] >= (3, 1):
+ test_string = "h\udce9llo w\u00f6rld"
if unicode_strings.non_utf8_c_str() != test_string:
- raise ValueError('Test comparison mismatch')
+ raise ValueError("Test comparison mismatch")
if unicode_strings.non_utf8_std_string() != test_string:
- raise ValueError('Test comparison mismatch')
+ raise ValueError("Test comparison mismatch")
def check(s1, s2):
if s1 != s2:
@@ -19,9 +15,24 @@ def check(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):
+ # Python 3.0-3.2 results in a SyntaxError when using u"" string literals, so we use a
+ # convoluted unicode string construction using unicode() and unichr().
+ # Conventional Python 2 syntax shown in comments.
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")
+ check(unicode_strings.charstring(str(unicode("hello2"))), "hello2") # u"hello2"
+ check(unicode_strings.charstring(unicode("hello3")), "hello3") # u"hello3"
+ check(unicode_strings.charstring(str("hello4")), "hello4")
+ unicode_strings.charstring(unicode("hell" + unichr(0xb0) + "5")) # u"hell\xb05"
+ unicode_strings.charstring(unicode("hell" + unichr(0x00f6) +"6")) # u"hell\u00f66"
+ low_surrogate_string = unichr(0xdcff) # u"\udcff"
+ unicode_strings.instring(low_surrogate_string)
+else:
+ low_surrogate_string = "\udcff"
+ try:
+ unicode_strings.instring(low_surrogate_string)
+ raise RuntimeError("Exception should have been thrown")
+ except TypeError as e:
+ # Python 3 will fail the PyUnicode_AsUTF8String conversion resulting in a TypeError.
+ # The real error is actually:
+ # UnicodeEncodeError: 'utf-8' codec can't encode character '\udcff' in position 0: surrogates not allowed
+ pass
diff --git a/Examples/test-suite/python/unions_runme.py b/Examples/test-suite/python/unions_runme.py
index 387a048c8..5a3ee3b5c 100644
--- a/Examples/test-suite/python/unions_runme.py
+++ b/Examples/test-suite/python/unions_runme.py
@@ -3,7 +3,6 @@
# union embedded within a struct can be set and read correctly.
import unions
-import sys
import string
# Create new instances of SmallStruct and BigStruct for later use
@@ -23,28 +22,23 @@ eut.number = 1
eut.uni.small = small
Jill1 = eut.uni.small.jill
if (Jill1 != 200):
- print "Runtime test1 failed. eut.uni.small.jill=", Jill1
- sys.exit(1)
+ raise RuntimeError("Runtime test1 failed. eut.uni.small.jill={}".format(Jill1))
Num1 = eut.number
if (Num1 != 1):
- print "Runtime test2 failed. eut.number=", Num1
- sys.exit(1)
+ raise RuntimeError("Runtime test2 failed. eut.number=".format(Num1))
# Secondly check the BigStruct in EmbeddedUnionTest
eut.number = 2
eut.uni.big = big
Jack1 = eut.uni.big.jack
if (Jack1 != 300):
- print "Runtime test3 failed. eut.uni.big.jack=", Jack1
- sys.exit(1)
+ raise RuntimeError("Runtime test3 failed. eut.uni.big.jack={}".format(Jack1))
Jill2 = eut.uni.big.smallstruct.jill
if (Jill2 != 200):
- print "Runtime test4 failed. eut.uni.big.smallstruct.jill=", Jill2
- sys.exit(1)
+ raise RuntimeError("Runtime test4 failed. eut.uni.big.smallstruct.jill={}".format(Jill2))
Num2 = eut.number
if (Num2 != 2):
- print "Runtime test5 failed. eut.number=", Num2
- sys.exit(1)
+ raise RuntimeError("Runtime test5 failed. eut.number={}".format(Num2))
diff --git a/Examples/test-suite/python/using_composition_runme.py b/Examples/test-suite/python/using_composition_runme.py
index c4f339095..67f72bc2f 100644
--- a/Examples/test-suite/python/using_composition_runme.py
+++ b/Examples/test-suite/python/using_composition_runme.py
@@ -2,32 +2,32 @@ from using_composition import *
f = FooBar()
if f.blah(3) != 3:
- raise RuntimeError, "FooBar::blah(int)"
+ raise RuntimeError("FooBar::blah(int)")
if f.blah(3.5) != 3.5:
- raise RuntimeError, "FooBar::blah(double)"
+ raise RuntimeError("FooBar::blah(double)")
if f.blah("hello") != "hello":
- raise RuntimeError, "FooBar::blah(char *)"
+ raise RuntimeError("FooBar::blah(char *)")
f = FooBar2()
if f.blah(3) != 3:
- raise RuntimeError, "FooBar2::blah(int)"
+ raise RuntimeError("FooBar2::blah(int)")
if f.blah(3.5) != 3.5:
- raise RuntimeError, "FooBar2::blah(double)"
+ raise RuntimeError("FooBar2::blah(double)")
if f.blah("hello") != "hello":
- raise RuntimeError, "FooBar2::blah(char *)"
+ raise RuntimeError("FooBar2::blah(char *)")
f = FooBar3()
if f.blah(3) != 3:
- raise RuntimeError, "FooBar3::blah(int)"
+ raise RuntimeError("FooBar3::blah(int)")
if f.blah(3.5) != 3.5:
- raise RuntimeError, "FooBar3::blah(double)"
+ raise RuntimeError("FooBar3::blah(double)")
if f.blah("hello") != "hello":
- raise RuntimeError, "FooBar3::blah(char *)"
+ raise RuntimeError("FooBar3::blah(char *)")
diff --git a/Examples/test-suite/python/using_extend_runme.py b/Examples/test-suite/python/using_extend_runme.py
index 038a1686a..7e0912926 100644
--- a/Examples/test-suite/python/using_extend_runme.py
+++ b/Examples/test-suite/python/using_extend_runme.py
@@ -2,20 +2,20 @@ from using_extend import *
f = FooBar()
if f.blah(3) != 3:
- raise RuntimeError, "blah(int)"
+ raise RuntimeError("blah(int)")
if f.blah(3.5) != 3.5:
- raise RuntimeError, "blah(double)"
+ raise RuntimeError("blah(double)")
if f.blah("hello") != "hello":
- raise RuntimeError, "blah(char *)"
+ raise RuntimeError("blah(char *)")
if f.blah(3, 4) != 7:
- raise RuntimeError, "blah(int,int)"
+ raise RuntimeError("blah(int,int)")
if f.blah(3.5, 7.5) != (3.5 + 7.5):
- raise RuntimeError, "blah(double,double)"
+ raise RuntimeError("blah(double,double)")
if f.duh(3) != 3:
- raise RuntimeError, "duh(int)"
+ raise RuntimeError("duh(int)")
diff --git a/Examples/test-suite/python/using_inherit_runme.py b/Examples/test-suite/python/using_inherit_runme.py
index 4fd595968..ccdeece8d 100644
--- a/Examples/test-suite/python/using_inherit_runme.py
+++ b/Examples/test-suite/python/using_inherit_runme.py
@@ -2,47 +2,47 @@ from using_inherit import *
b = Bar()
if b.test(3) != 3:
- raise RuntimeError, "Bar::test(int)"
+ raise RuntimeError("Bar::test(int)")
if b.test(3.5) != 3.5:
- raise RuntimeError, "Bar::test(double)"
+ raise RuntimeError("Bar::test(double)")
b = Bar2()
if b.test(3) != 6:
- raise RuntimeError, "Bar2::test(int)"
+ raise RuntimeError("Bar2::test(int)")
if b.test(3.5) != 7.0:
- raise RuntimeError, "Bar2::test(double)"
+ raise RuntimeError("Bar2::test(double)")
b = Bar3()
if b.test(3) != 6:
- raise RuntimeError, "Bar3::test(int)"
+ raise RuntimeError("Bar3::test(int)")
if b.test(3.5) != 7.0:
- raise RuntimeError, "Bar3::test(double)"
+ raise RuntimeError("Bar3::test(double)")
b = Bar4()
if b.test(3) != 6:
- raise RuntimeError, "Bar4::test(int)"
+ raise RuntimeError("Bar4::test(int)")
if b.test(3.5) != 7.0:
- raise RuntimeError, "Bar4::test(double)"
+ raise RuntimeError("Bar4::test(double)")
b = Fred1()
if b.test(3) != 3:
- raise RuntimeError, "Fred1::test(int)"
+ raise RuntimeError("Fred1::test(int)")
if b.test(3.5) != 7.0:
- raise RuntimeError, "Fred1::test(double)"
+ raise RuntimeError("Fred1::test(double)")
b = Fred2()
if b.test(3) != 3:
- raise RuntimeError, "Fred2::test(int)"
+ raise RuntimeError("Fred2::test(int)")
if b.test(3.5) != 7.0:
- raise RuntimeError, "Fred2::test(double)"
+ raise RuntimeError("Fred2::test(double)")
diff --git a/Examples/test-suite/python/using_private_runme.py b/Examples/test-suite/python/using_private_runme.py
index 00c9a8d25..9e0a15f12 100644
--- a/Examples/test-suite/python/using_private_runme.py
+++ b/Examples/test-suite/python/using_private_runme.py
@@ -4,10 +4,10 @@ f = FooBar()
f.x = 3
if f.blah(4) != 4:
- raise RuntimeError, "blah(int)"
+ raise RuntimeError("blah(int)")
if f.defaulted() != -1:
- raise RuntimeError, "defaulted()"
+ raise RuntimeError("defaulted()")
if f.defaulted(222) != 222:
- raise RuntimeError, "defaulted(222)"
+ raise RuntimeError("defaulted(222)")
diff --git a/Examples/test-suite/python/using_protected_runme.py b/Examples/test-suite/python/using_protected_runme.py
index 525a1cde4..dd477237e 100644
--- a/Examples/test-suite/python/using_protected_runme.py
+++ b/Examples/test-suite/python/using_protected_runme.py
@@ -4,4 +4,4 @@ f = FooBar()
f.x = 3
if f.blah(4) != 4:
- raise RuntimeError, "blah(int)"
+ raise RuntimeError("blah(int)")
diff --git a/Examples/test-suite/python/varargs_overload_runme.py b/Examples/test-suite/python/varargs_overload_runme.py
index 37958620c..ffa763450 100644
--- a/Examples/test-suite/python/varargs_overload_runme.py
+++ b/Examples/test-suite/python/varargs_overload_runme.py
@@ -1,30 +1,62 @@
import varargs_overload
if varargs_overload.vararg_over1("Hello") != "Hello":
- raise RuntimeError, "Failed"
+ raise RuntimeError("Failed")
if varargs_overload.vararg_over1(2) != "2":
- raise RuntimeError, "Failed"
+ raise RuntimeError("Failed")
if varargs_overload.vararg_over2("Hello") != "Hello":
- raise RuntimeError, "Failed"
+ raise RuntimeError("Failed")
if varargs_overload.vararg_over2(2, 2.2) != "2 2.2":
- raise RuntimeError, "Failed"
+ raise RuntimeError("Failed")
if varargs_overload.vararg_over3("Hello") != "Hello":
- raise RuntimeError, "Failed"
+ raise RuntimeError("Failed")
if varargs_overload.vararg_over3(2, 2.2, "hey") != "2 2.2 hey":
- raise RuntimeError, "Failed"
+ raise RuntimeError("Failed")
if varargs_overload.vararg_over4("Hello") != "Hello":
- raise RuntimeError, "Failed"
+ raise RuntimeError("Failed")
if varargs_overload.vararg_over4(123) != "123":
- raise RuntimeError, "Failed"
+ raise RuntimeError("Failed")
if varargs_overload.vararg_over4("Hello", 123) != "Hello":
- raise RuntimeError, "Failed"
+ raise RuntimeError("Failed")
+
+
+# Same as above but non-vararg function declared first
+
+if varargs_overload.vararg_over6("Hello") != "Hello":
+ raise RuntimeError("Failed")
+
+if varargs_overload.vararg_over6(2) != "2":
+ raise RuntimeError("Failed")
+
+
+if varargs_overload.vararg_over7("Hello") != "Hello":
+ raise RuntimeError("Failed")
+
+if varargs_overload.vararg_over7(2, 2.2) != "2 2.2":
+ raise RuntimeError("Failed")
+
+
+if varargs_overload.vararg_over8("Hello") != "Hello":
+ raise RuntimeError("Failed")
+
+if varargs_overload.vararg_over8(2, 2.2, "hey") != "2 2.2 hey":
+ raise RuntimeError("Failed")
+
+if varargs_overload.vararg_over9("Hello") != "Hello":
+ raise RuntimeError("Failed")
+
+if varargs_overload.vararg_over9(123) != "123":
+ raise RuntimeError("Failed")
+
+if varargs_overload.vararg_over9("Hello", 123) != "Hello":
+ raise RuntimeError("Failed")
diff --git a/Examples/test-suite/python/varargs_runme.py b/Examples/test-suite/python/varargs_runme.py
index 7105ba8d7..8f90d5cde 100644
--- a/Examples/test-suite/python/varargs_runme.py
+++ b/Examples/test-suite/python/varargs_runme.py
@@ -1,36 +1,34 @@
import varargs
if varargs.test("Hello") != "Hello":
- raise RuntimeError, "Failed"
+ raise RuntimeError("Failed")
f = varargs.Foo("Greetings")
if f.str != "Greetings":
- raise RuntimeError, "Failed"
+ raise RuntimeError("Failed")
if f.test("Hello") != "Hello":
- raise RuntimeError, "Failed"
+ raise RuntimeError("Failed")
if varargs.test_def("Hello", 1) != "Hello":
- raise RuntimeError, "Failed"
+ raise RuntimeError("Failed")
if varargs.test_def("Hello") != "Hello":
- raise RuntimeError, "Failed"
+ raise RuntimeError("Failed")
###
if varargs.test_plenty("Hello") != "Hello":
- raise RuntimeError, "Failed"
+ raise RuntimeError("Failed")
if varargs.test_plenty("Hello", 1) != "Hello":
- raise RuntimeError, "Failed"
+ raise RuntimeError("Failed")
if varargs.test_plenty("Hello", 1, 2) != "Hello":
- raise RuntimeError, "Failed"
+ raise RuntimeError("Failed")
try:
varargs.test_plenty("Hello", 1, 2, 3)
raise RuntimeError
-except NotImplementedError:
- pass
except TypeError:
pass
diff --git a/Examples/test-suite/python/virtual_derivation_runme.py b/Examples/test-suite/python/virtual_derivation_runme.py
index 68546c6eb..21014bd02 100644
--- a/Examples/test-suite/python/virtual_derivation_runme.py
+++ b/Examples/test-suite/python/virtual_derivation_runme.py
@@ -4,4 +4,4 @@ from virtual_derivation import *
#
b = B(3)
if b.get_a() != b.get_b():
- raise RuntimeError, "something is really wrong"
+ raise RuntimeError("something is really wrong")
diff --git a/Examples/test-suite/python_append.i b/Examples/test-suite/python_append.i
index 2a71b5784..883097ec6 100644
--- a/Examples/test-suite/python_append.i
+++ b/Examples/test-suite/python_append.i
@@ -17,11 +17,11 @@ def clearstaticpath():
staticfuncpath = None
%}
-%pythonappend Test::func %{
+%pythonappend Test::funk %{
funcpath = os.path.dirname(funcpath)
%}
-%pythonprepend Test::func %{
+%pythonprepend Test::funk %{
global funcpath
funcpath = mypath
%}
@@ -42,13 +42,31 @@ import os.path
%}
%inline %{
-
class Test {
public:
static void static_func() {};
- void func() {};
+ void funk() {};
+};
+%}
+
+// Github issue #1674
+%extend ForSlots {
+ %pythoncode %{
+ __slots__ = ["this"]
+ %}
+}
+// While __slots__ does not contain 'ValidVariable' in the list, it is still possible
+// to set 'ValidVariable'. A little odd, but the whole attribute setting is bypassed
+// for setting C/C++ member variables.
+// Not sure how to test the equivalent for -builtin.
+%inline %{
+struct ForSlots {
+ int ValidVariable;
+ ForSlots() : ValidVariable(99) {}
};
+%}
+%inline %{
#ifdef SWIGPYTHON_BUILTIN
bool is_python_builtin() { return true; }
#else
diff --git a/Examples/test-suite/python_builtin.i b/Examples/test-suite/python_builtin.i
index d4e245dc4..994c625e8 100644
--- a/Examples/test-suite/python_builtin.i
+++ b/Examples/test-suite/python_builtin.i
@@ -2,10 +2,12 @@
%module python_builtin
+// throw is invalid in C++17 and later, only SWIG to use it
+#define TESTCASE_THROW1(T1) throw(T1)
+#define TESTCASE_THROW2(T1, T2) throw(T1, T2)
%{
-#if defined(_MSC_VER)
- #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
+#define TESTCASE_THROW1(T1)
+#define TESTCASE_THROW2(T1, T2)
%}
%inline %{
@@ -192,13 +194,13 @@ void Dealloc2Destroyer(PyObject *v) {
return size;
}
- int __getitem__(Py_ssize_t n) throw (std::out_of_range) {
+ int __getitem__(Py_ssize_t n) TESTCASE_THROW1(std::out_of_range) {
if (n >= (int)size)
throw std::out_of_range("Index too large");
return numbers[n];
}
- SimpleArray __getitem__(PySliceObject *slice) throw (std::out_of_range, std::invalid_argument) {
+ SimpleArray __getitem__(PySliceObject *slice) TESTCASE_THROW2(std::out_of_range, std::invalid_argument) {
if (!PySlice_Check(slice))
throw std::invalid_argument("Slice object expected");
Py_ssize_t i, j, step;
@@ -223,3 +225,23 @@ void Dealloc2Destroyer(PyObject *v) {
}
};
%}
+
+// Test 7 mapping to Python's pow
+%pybinoperator(__pow__, ANumber::power, ternaryfunc, nb_power);
+
+%inline %{
+class ANumber {
+ int num;
+public:
+ ANumber(int d = 0) : num(d) {}
+ ANumber __pow__(const ANumber &other, const ANumber *x = 0) const {
+ int val = (int)pow(num, other.num);
+ val = x ? val % x->num : val;
+ return ANumber(val);
+ }
+ int Value() const {
+ return num;
+ }
+};
+%}
+
diff --git a/Examples/test-suite/python_nondynamic.i b/Examples/test-suite/python_nondynamic.i
index 54a3f28ca..b08cec9e6 100644
--- a/Examples/test-suite/python_nondynamic.i
+++ b/Examples/test-suite/python_nondynamic.i
@@ -29,8 +29,6 @@
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252158
- and works for modern (-modern) and plain python.
-
*/
@@ -54,5 +52,14 @@
int b;
};
+ int retrieve_A_a(const struct A* self) { return self->a; }
+ int retrieve_A_b(const struct A* self) { return self->b; }
+%}
+%inline %{
+#ifdef SWIGPYTHON_BUILTIN
+int is_python_builtin() { return 1; }
+#else
+int is_python_builtin() { return 0; }
+#endif
%}
diff --git a/Examples/test-suite/python_pybuf.i b/Examples/test-suite/python_pybuffer.i
index 8e1302582..bff72bfa2 100644
--- a/Examples/test-suite/python_pybuf.i
+++ b/Examples/test-suite/python_pybuffer.i
@@ -1,6 +1,6 @@
-%module python_pybuf
-%include<pybuffer.i>
-%include<cstring.i>
+%module python_pybuffer
+%include <pybuffer.i>
+%include <cstring.i>
/*functions for the test case*/
%pybuffer_mutable_binary(char *buf1, int len);
%pybuffer_mutable_string(char *buf2);
@@ -28,7 +28,7 @@
++count;
return count;
}
- int func4(const char *buf4)
+ size_t func4(const char *buf4)
{
return strlen(buf4);
}
diff --git a/Examples/test-suite/python_pythoncode.i b/Examples/test-suite/python_pythoncode.i
index 70474d44c..017f076c4 100644
--- a/Examples/test-suite/python_pythoncode.i
+++ b/Examples/test-suite/python_pythoncode.i
@@ -29,3 +29,33 @@ struct TYPE2 {
struct TYPE { };
struct TYPE2 { };
%}
+
+
+// Overriding __new__ test: https://github.com/swig/swig/pull/1357
+%inline %{
+class Foo {
+ public:
+ virtual ~Foo() {}
+ Foo() {}
+};
+
+Foo* get_foo() {return new Foo();}
+%}
+
+%pythoncode %{
+ print_debug = False
+%}
+
+%extend Foo {
+ // Note that %pythoncode is not available with -builtin
+ %pythoncode %{
+ def __new__(cls, *args, **kwargs):
+ if print_debug:
+ print('in Foo.__new__()')
+ return super(Foo, cls).__new__(cls)
+
+ def __init__(self):
+ if print_debug:
+ print('in Foo.__init__()')
+ %}
+};
diff --git a/Examples/test-suite/python_varargs_typemap.i b/Examples/test-suite/python_varargs_typemap.i
index f05fb98eb..d809bf1fa 100644
--- a/Examples/test-suite/python_varargs_typemap.i
+++ b/Examples/test-suite/python_varargs_typemap.i
@@ -23,8 +23,11 @@
SWIG_fail;
}
pystr = PyUnicode_AsUTF8String(pyobj);
+ if (!pystr) {
+ SWIG_fail;
+ }
str = strdup(PyBytes_AsString(pystr));
- Py_XDECREF(pystr);
+ Py_DECREF(pystr);
%#else
if (!PyString_Check(pyobj)) {
PyErr_SetString(PyExc_ValueError, "Expected a string");
diff --git a/Examples/test-suite/r/Makefile.in b/Examples/test-suite/r/Makefile.in
index d75d4c042..98835b958 100644
--- a/Examples/test-suite/r/Makefile.in
+++ b/Examples/test-suite/r/Makefile.in
@@ -18,9 +18,20 @@ C_TEST_CASES += \
CPP_TEST_CASES += \
r_double_delete \
+ r_memory_leak \
r_overload_array \
r_sexp \
- r_overload_comma
+ r_overload_comma \
+ r_use_isnull
+
+# These tests are failing because enums currently cannot handle
+# arithmetic expressions
+
+FAILING_CPP_TESTS = \
+ preproc_constants
+
+FAILING_C_TESTS = \
+ preproc_constants_c
include $(srcdir)/../common.mk
@@ -53,7 +64,7 @@ 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) || (cat $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)out ; false); \
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PATH=.:"$$PATH" $(RUNTOOL) $(RUNR) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) || (cat ./$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)out ; false); \
else \
$(RUNTOOL) $(RUNR) ./$(SCRIPTPREFIX)$*$(WRAPSUFFIX) || (cat ./$(SCRIPTPREFIX)$*$(WRAPSUFFIX)out ; false); \
fi
@@ -61,7 +72,7 @@ run_testcase = \
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) || (cat $(SCRIPTDIR)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX)out ; false); \
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PATH=.:"$$PATH" $(RUNTOOL) $(RUNR) $(SCRIPTDIR)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX) || (cat ./$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX)out ; false); \
else \
$(RUNTOOL) $(RUNR) ./$(SCRIPTPREFIX)$${f}$(WRAPSUFFIX) || (cat ./$(SCRIPTPREFIX)$${f}$(WRAPSUFFIX)out ; false); \
fi; \
diff --git a/Examples/test-suite/r/abstract_access_runme.R b/Examples/test-suite/r/abstract_access_runme.R
new file mode 100644
index 000000000..f6fb4099d
--- /dev/null
+++ b/Examples/test-suite/r/abstract_access_runme.R
@@ -0,0 +1,74 @@
+clargs <- commandArgs(trailing=TRUE)
+source(file.path(clargs[1], "unittest.R"))
+
+dyn.load(paste("abstract_access", .Platform$dynlib.ext, sep=""))
+source("abstract_access.R")
+
+dd <- D()
+unittest(1, dd$z())
+unittest(1, dd$do_x())
+
+## Original version allowed dd$z <- 2
+tryCatch({
+ dd$z <- 2
+ # force an error if the previous line doesn't raise an exception
+ stop("Test Failure A")
+}, error = function(e) {
+ if (e$message == "Test Failure A") {
+ # Raise the error again to cause a failed test
+ stop(e)
+ }
+ message("Correct - no dollar assignment method found")
+}
+)
+
+tryCatch({
+ dd[["z"]] <- 2
+ # force an error if the previous line doesn't raise an exception
+ stop("Test Failure B")
+}, error = function(e) {
+ if (e$message == "Test Failure B") {
+ # Raise the error again to cause a failed test
+ stop(e)
+ }
+ message("Correct - no dollar assignment method found")
+}
+)
+
+## The methods are attached to the parent class - see if we can get
+## them
+tryCatch({
+ m1 <- getMethod('$', "_p_A")
+}, error = function(e) {
+ stop("No $ method found - there should be one")
+}
+)
+
+## These methods should not be present
+## They correspond to the tests that are expected
+## to fail above.
+tryCatch({
+ m2 <- getMethod('$<-', "_p_A")
+ # force an error if the previous line doesn't raise an exception
+ stop("Test Failure C")
+}, error = function(e) {
+ if (e$message == "Test Failure C") {
+ # Raise the error again to cause a failed test
+ stop(e)
+ }
+ message("Correct - no dollar assignment method found")
+}
+)
+
+tryCatch({
+ m3 <- getMethod('[[<-', "_p_A")
+ # force an error if the previous line doesn't raise an exception
+ stop("Test Failure D")
+}, error = function(e) {
+ if (e$message == "Test Failure D") {
+ # Raise the error again to cause a failed test
+ stop(e)
+ }
+ message("Correct - no list assignment method found")
+}
+)
diff --git a/Examples/test-suite/r/enum_thorough_runme.R b/Examples/test-suite/r/enum_thorough_runme.R
new file mode 100644
index 000000000..a0f1270b7
--- /dev/null
+++ b/Examples/test-suite/r/enum_thorough_runme.R
@@ -0,0 +1,452 @@
+clargs <- commandArgs(trailing=TRUE)
+source(file.path(clargs[1], "unittest.R"))
+
+dyn.load(paste("enum_thorough", .Platform$dynlib.ext, sep=""))
+source("enum_thorough.R")
+cacheMetaData(1)
+
+## Anonymous enums are not wrapped by the R module
+##
+
+# Colours - string interface, various function signatures
+unittest('red', colourTest1('red'))
+unittest('blue', colourTest1('blue'))
+unittest('green', colourTest1('green'))
+
+
+unittest('red', colourTest2('red'))
+unittest('blue', colourTest2('blue'))
+unittest('green', colourTest2('green'))
+
+unittest('red', colourTest3('red'))
+unittest('blue', colourTest3('blue'))
+unittest('green', colourTest3('green'))
+
+unittest('red', colourTest4('red'))
+unittest('blue', colourTest4('blue'))
+unittest('green', colourTest4('green'))
+
+## Colours - underlying integers
+unittest(-1, enumToInteger('red', '_colour'))
+unittest(0, enumToInteger('blue', '_colour'))
+unittest(10, enumToInteger('green', '_colour'))
+
+########
+## enum variable, wrapped as a function
+## Is initialization to 0 a "standard"
+myColour()
+
+## Test setting and retrieving
+myColour('green')
+unittest('green', myColour())
+
+########
+## SpeedClass
+
+s <- SpeedClass()
+v <- "medium"
+unittest(v, s$speedTest1(v))
+unittest(v, s$speedTest2(v))
+unittest(v, s$speedTest3(v))
+unittest(v, s$speedTest4(v))
+unittest(v, s$speedTest5(v))
+unittest(v, s$speedTest6(v))
+unittest(v, s$speedTest7(v))
+unittest(v, s$speedTest8(v))
+
+## speedTest methods not in the class
+
+unittest(v, speedTest1(v))
+unittest(v, speedTest2(v))
+unittest(v, speedTest3(v))
+unittest(v, speedTest4(v))
+# enum reference
+unittest(v, speedTest5(v))
+
+## member access
+s <- SpeedClass()
+unittest("slow", s$mySpeedtd1)
+# check integer value
+unittest(10, enumToInteger(s$mySpeedtd1, "_SpeedClass__speed"))
+# set and check
+s$mySpeedtd1 <- "lightning"
+unittest("lightning", s$mySpeedtd1)
+unittest(31, enumToInteger(s$mySpeedtd1, "_SpeedClass__speed"))
+
+## Named anon - not wrapped nicely, but can be retrieved:
+
+
+unittest("NamedAnon2", namedanon_NamedAnon2_get())
+unittest(0, enumToInteger(namedanon_NamedAnon1_get(), "_namedanon"))
+unittest(1, enumToInteger(namedanon_NamedAnon2_get(), "_namedanon"))
+
+## Twonames
+v <- "TwoNames1"
+unittest(v, twonamesTest1(v))
+unittest(v, twonamesTest2(v))
+unittest(v, twonamesTest3(v))
+unittest(33, enumToInteger("TwoNames3", "_twonamestag"))
+
+tt <- TwoNamesStruct()
+v <- "TwoNamesStruct1"
+unittest(v, tt$twonamesTest1(v))
+unittest(v, tt$twonamesTest2(v))
+unittest(v, tt$twonamesTest3(v))
+## Try the wrong name
+unittest(TRUE, is.na(tt$twonamesTest3("TwoNames1")))
+
+## Namedanonspace
+## can get the values
+
+v <- namedanonspace_NamedAnonSpace2_get()
+unittest(v, namedanonspaceTest1(v))
+unittest(v, namedanonspaceTest2(v))
+unittest(v, namedanonspaceTest3(v))
+unittest(v, namedanonspaceTest4(v))
+
+## scientists
+
+tt <- TemplateClassInt()
+
+g <- "galileo"
+unittest(g, tt$scientistsTest1(g))
+unittest(g, tt$scientistsTest2(g))
+unittest(g, tt$scientistsTest3(g))
+unittest(g, tt$scientistsTest4(g))
+unittest(g, tt$scientistsTest5(g))
+unittest(g, tt$scientistsTest6(g))
+unittest(g, tt$scientistsTest7(g))
+unittest(g, tt$scientistsTest8(g))
+unittest(g, tt$scientistsTest9(g))
+
+## This one is commented out in csharp too
+## unittest(g, tt$scientistsTestA(g))
+unittest(g, tt$scientistsTestB(g))
+## This one is commented out in csharp too
+## unittest(g, tt$scientistsTestC(g))
+unittest(g, tt$scientistsTestD(g))
+unittest(g, tt$scientistsTestE(g))
+unittest(g, tt$scientistsTestF(g))
+unittest(g, tt$scientistsTestG(g))
+unittest(g, tt$scientistsTestH(g))
+unittest(g, tt$scientistsTestI(g))
+# enum reference
+unittest(g, tt$scientistsTestJ(g))
+
+
+unittest(g, scientistsTest1(g))
+unittest(g, scientistsTest2(g))
+unittest(g, scientistsTest3(g))
+unittest(g, scientistsTest4(g))
+unittest(g, scientistsTest5(g))
+unittest(g, scientistsTest6(g))
+unittest(g, scientistsTest7(g))
+## enum reference
+unittest(g, scientistsTest8(g))
+
+tt <- TClassInt()
+b <- "bell"
+unittest(b, tt$scientistsNameTest1(b))
+unittest(b, tt$scientistsNameTest2(b))
+unittest(b, tt$scientistsNameTest3(b))
+unittest(b, tt$scientistsNameTest4(b))
+unittest(b, tt$scientistsNameTest5(b))
+unittest(b, tt$scientistsNameTest6(b))
+unittest(b, tt$scientistsNameTest7(b))
+unittest(b, tt$scientistsNameTest8(b))
+unittest(b, tt$scientistsNameTest9(b))
+
+## This one is commented out in csharp too
+## unittest(b, tt$scientistsNameTestA(b))
+unittest(b, tt$scientistsNameTestB(b))
+## This one is commented out in csharp too
+## unittest(b, tt$scientistsNameTestC(b))
+unittest(b, tt$scientistsNameTestD(b))
+unittest(b, tt$scientistsNameTestE(b))
+unittest(b, tt$scientistsNameTestF(b))
+unittest(b, tt$scientistsNameTestG(b))
+unittest(b, tt$scientistsNameTestH(b))
+unittest(b, tt$scientistsNameTestI(b))
+
+
+unittest(b, tt$scientistsNameSpaceTest1(b))
+unittest(b, tt$scientistsNameSpaceTest2(b))
+unittest(b, tt$scientistsNameSpaceTest3(b))
+unittest(b, tt$scientistsNameSpaceTest4(b))
+unittest(b, tt$scientistsNameSpaceTest5(b))
+unittest(b, tt$scientistsNameSpaceTest6(b))
+unittest(b, tt$scientistsNameSpaceTest7(b))
+
+unittest(g, tt$scientistsOtherTest1(g))
+unittest(g, tt$scientistsOtherTest2(g))
+unittest(g, tt$scientistsOtherTest3(g))
+unittest(g, tt$scientistsOtherTest4(g))
+unittest(g, tt$scientistsOtherTest5(g))
+unittest(g, tt$scientistsOtherTest6(g))
+unittest(g, tt$scientistsOtherTest7(g))
+
+## Global
+unittest(b, scientistsNameTest1(b))
+unittest(b, scientistsNameTest2(b))
+unittest(b, scientistsNameTest3(b))
+unittest(b, scientistsNameTest4(b))
+unittest(b, scientistsNameTest5(b))
+unittest(b, scientistsNameTest6(b))
+unittest(b, scientistsNameTest7(b))
+
+unittest(b, scientistsNameSpaceTest1(b))
+unittest(b, scientistsNameSpaceTest2(b))
+unittest(b, scientistsNameSpaceTest3(b))
+unittest(b, scientistsNameSpaceTest4(b))
+unittest(b, scientistsNameSpaceTest5(b))
+unittest(b, scientistsNameSpaceTest6(b))
+unittest(b, scientistsNameSpaceTest7(b))
+
+unittest(b, scientistsNameSpaceTest8(b))
+unittest(b, scientistsNameSpaceTest9(b))
+unittest(b, scientistsNameSpaceTestA(b))
+unittest(b, scientistsNameSpaceTestB(b))
+unittest(b, scientistsNameSpaceTestC(b))
+unittest(b, scientistsNameSpaceTestD(b))
+unittest(b, scientistsNameSpaceTestE(b))
+unittest(b, scientistsNameSpaceTestF(b))
+unittest(b, scientistsNameSpaceTestG(b))
+unittest(b, scientistsNameSpaceTestH(b))
+unittest(b, scientistsNameSpaceTestI(b))
+unittest(b, scientistsNameSpaceTestJ(b))
+unittest(b, scientistsNameSpaceTestK(b))
+unittest(b, scientistsNameSpaceTestL(b))
+
+## rename test
+v <- "eek"
+unittest(v, renameTest1(v))
+unittest(v, renameTest2(v))
+
+## NewName
+N <- NewNameStruct()
+## Only half works:
+unittest("kerboom", NewNameStruct_bang_get())
+## Can't put in "bang" in the call
+## confirm with:
+## get(".__E___OldNameStruct__enumeration")
+
+## TreeClass
+
+T <- TreesClass()
+p <- "pine"
+
+unittest(p, T$treesTest1(p))
+unittest(p, T$treesTest2(p))
+unittest(p, T$treesTest3(p))
+unittest(p, T$treesTest4(p))
+unittest(p, T$treesTest5(p))
+unittest(p, T$treesTest6(p))
+unittest(p, T$treesTest7(p))
+unittest(p, T$treesTest8(p))
+unittest(p, T$treesTest9(p))
+unittest(p, T$treesTestA(p))
+unittest(p, T$treesTestB(p))
+unittest(p, T$treesTestC(p))
+unittest(p, T$treesTestD(p))
+unittest(p, T$treesTestE(p))
+unittest(p, T$treesTestF(p))
+unittest(p, T$treesTestG(p))
+unittest(p, T$treesTestH(p))
+unittest(p, T$treesTestI(p))
+unittest(p, T$treesTestJ(p))
+unittest(p, T$treesTestK(p))
+unittest(p, T$treesTestL(p))
+unittest(p, T$treesTestM(p))
+unittest(p, T$treesTestN(p))
+unittest(p, T$treesTestO(p))
+
+unittest(p, treesTest1(p))
+unittest(p, treesTest2(p))
+unittest(p, treesTest3(p))
+unittest(p, treesTest4(p))
+unittest(p, treesTest5(p))
+unittest(p, treesTest6(p))
+unittest(p, treesTest7(p))
+unittest(p, treesTest8(p))
+unittest(p, treesTest9(p))
+unittest(p, treesTestA(p))
+unittest(p, treesTestB(p))
+unittest(p, treesTestC(p))
+unittest(p, treesTestD(p))
+unittest(p, treesTestE(p))
+unittest(p, treesTestF(p))
+unittest(p, treesTestG(p))
+unittest(p, treesTestH(p))
+unittest(p, treesTestI(p))
+unittest(p, treesTestJ(p))
+unittest(p, treesTestK(p))
+unittest(p, treesTestL(p))
+unittest(p, treesTestM(p))
+unittest(p, treesTestO(p))
+unittest(p, treesTestP(p))
+unittest(p, treesTestQ(p))
+unittest(p, treesTestR(p))
+
+## Hair
+h <- HairStruct()
+g <- "ginger"
+unittest(g, h$hairTest1(g))
+unittest(g, h$hairTest2(g))
+unittest(g, h$hairTest3(g))
+unittest(g, h$hairTest4(g))
+unittest(g, h$hairTest5(g))
+unittest(g, h$hairTest6(g))
+unittest(g, h$hairTest7(g))
+unittest(g, h$hairTest8(g))
+unittest(g, h$hairTest9(g))
+unittest(g, h$hairTestA(g))
+unittest(g, h$hairTestB(g))
+
+r <- "red"
+unittest(r, h$colourTest1(r))
+unittest(r, h$colourTest2(r))
+
+nmA <- "NamedAnon1"
+unittest(nmA, h$namedanonTest1(nmA))
+unittest("NamedAnonSpace2", h$namedanonspaceTest1("NamedAnonSpace2"))
+
+f <- "fir"
+
+unittest(f, h$treesGlobalTest1(f))
+unittest(f, h$treesGlobalTest2(f))
+unittest(f, h$treesGlobalTest3(f))
+unittest(f, h$treesGlobalTest4(f))
+
+b <- "blonde"
+unittest(b, hairTest1(b))
+unittest(b, hairTest2(b))
+unittest(b, hairTest3(b))
+unittest(b, hairTest4(b))
+unittest(b, hairTest5(b))
+unittest(b, hairTest6(b))
+unittest(b, hairTest7(b))
+unittest(b, hairTest8(b))
+unittest(b, hairTest9(b))
+unittest(b, hairTestA(b))
+unittest(b, hairTestB(b))
+## enum reference
+unittest(b, hairTestC(b))
+unittest(b, hairTestA1(b))
+unittest(b, hairTestA2(b))
+unittest(b, hairTestA3(b))
+unittest(b, hairTestA4(b))
+unittest(b, hairTestA5(b))
+unittest(b, hairTestA6(b))
+unittest(b, hairTestA7(b))
+unittest(b, hairTestA8(b))
+unittest(b, hairTestA9(b))
+unittest(b, hairTestAA(b))
+unittest(b, hairTestAB(b))
+## enum reference
+unittest(b, hairTestAC(b))
+
+unittest(b, hairTestB1(b))
+unittest(b, hairTestB2(b))
+unittest(b, hairTestB3(b))
+unittest(b, hairTestB4(b))
+unittest(b, hairTestB5(b))
+unittest(b, hairTestB6(b))
+unittest(b, hairTestB7(b))
+unittest(b, hairTestB8(b))
+unittest(b, hairTestB9(b))
+unittest(b, hairTestBA(b))
+unittest(b, hairTestBB(b))
+## enum reference
+unittest(b, hairTestBC(b))
+
+f <- FirStruct()
+b <- "blonde"
+
+unittest(b, f$hairTestFir1(b))
+unittest(b, f$hairTestFir2(b))
+unittest(b, f$hairTestFir3(b))
+unittest(b, f$hairTestFir4(b))
+unittest(b, f$hairTestFir5(b))
+unittest(b, f$hairTestFir6(b))
+unittest(b, f$hairTestFir7(b))
+unittest(b, f$hairTestFir8(b))
+unittest(b, f$hairTestFir9(b))
+unittest(b, f$hairTestFirA(b))
+
+## Unnamed enum instance doesn't work
+## Wrapper set/get exists, but there's
+## no mapping between strings and integers
+GlobalInstance(1)
+unittest(1, GlobalInstance())
+
+ii <- Instances()
+ii$MemberInstance <- 1
+unittest(1, ii$MemberInstance)
+
+ii <- IgnoreTest()
+
+## Testing integer values
+unittest(0, enumToInteger(IgnoreTest_ignoreA_zero_get(), "_IgnoreTest__IgnoreA"))
+unittest(3, enumToInteger(IgnoreTest_ignoreA_three_get(), "_IgnoreTest__IgnoreA"))
+unittest(10, enumToInteger(IgnoreTest_ignoreA_ten_get(), "_IgnoreTest__IgnoreA"))
+
+unittest(11, enumToInteger(IgnoreTest_ignoreA_eleven_get(), "_IgnoreTest__IgnoreA"))
+unittest(14, enumToInteger(IgnoreTest_ignoreA_fourteen_get(), "_IgnoreTest__IgnoreA"))
+unittest(20, enumToInteger(IgnoreTest_ignoreA_twenty_get(), "_IgnoreTest__IgnoreA"))
+unittest(30, enumToInteger(IgnoreTest_ignoreA_thirty_get(), "_IgnoreTest__IgnoreA"))
+unittest(32, enumToInteger(IgnoreTest_ignoreA_thirty_two_get(), "_IgnoreTest__IgnoreA"))
+unittest(33, enumToInteger(IgnoreTest_ignoreA_thirty_three_get(), "_IgnoreTest__IgnoreA"))
+
+unittest(11, enumToInteger(IgnoreTest_ignoreB_eleven_get(), "_IgnoreTest__IgnoreB"))
+unittest(12, enumToInteger(IgnoreTest_ignoreB_twelve_get(), "_IgnoreTest__IgnoreB"))
+unittest(31, enumToInteger(IgnoreTest_ignoreB_thirty_one_get(), "_IgnoreTest__IgnoreB"))
+unittest(32, enumToInteger(IgnoreTest_ignoreB_thirty_two_get(), "_IgnoreTest__IgnoreB"))
+unittest(41, enumToInteger(IgnoreTest_ignoreB_forty_one_get(), "_IgnoreTest__IgnoreB"))
+unittest(42, enumToInteger(IgnoreTest_ignoreB_forty_two_get(), "_IgnoreTest__IgnoreB"))
+
+unittest(10, enumToInteger(IgnoreTest_ignoreC_ten_get(), "_IgnoreTest__IgnoreC"))
+unittest(12, enumToInteger(IgnoreTest_ignoreC_twelve_get(), "_IgnoreTest__IgnoreC"))
+unittest(30, enumToInteger(IgnoreTest_ignoreC_thirty_get(), "_IgnoreTest__IgnoreC"))
+unittest(32, enumToInteger(IgnoreTest_ignoreC_thirty_two_get(), "_IgnoreTest__IgnoreC"))
+unittest(40, enumToInteger(IgnoreTest_ignoreC_forty_get(), "_IgnoreTest__IgnoreC"))
+unittest(42, enumToInteger(IgnoreTest_ignoreC_forty_two_get(), "_IgnoreTest__IgnoreC"))
+
+unittest(21, enumToInteger(IgnoreTest_ignoreD_twenty_one_get(), "_IgnoreTest__IgnoreD"))
+unittest(22, enumToInteger(IgnoreTest_ignoreD_twenty_two_get(), "_IgnoreTest__IgnoreD"))
+
+unittest(0, enumToInteger(IgnoreTest_ignoreE_zero_get(), "_IgnoreTest__IgnoreE"))
+unittest(21, enumToInteger(IgnoreTest_ignoreE_twenty_one_get(), "_IgnoreTest__IgnoreE"))
+unittest(22, enumToInteger(IgnoreTest_ignoreE_twenty_two_get(), "_IgnoreTest__IgnoreE"))
+
+## confirm that an ignore directive is followed:
+unittest(TRUE, is.na(ignoreCTest("ignoreC_eleven")))
+
+
+## repeat test
+unittest(1, enumToInteger(repeatTest("one"), "_RepeatSpace__repeat"))
+unittest(1, enumToInteger(repeatTest("initial"), "_RepeatSpace__repeat"))
+unittest(2, enumToInteger(repeatTest("two"), "_RepeatSpace__repeat"))
+unittest(3, enumToInteger(repeatTest("three"), "_RepeatSpace__repeat"))
+unittest(3, enumToInteger(repeatTest("llast"), "_RepeatSpace__repeat"))
+unittest(3, enumToInteger(repeatTest("end"), "_RepeatSpace__repeat"))
+
+## Macro test - nothing in csharp
+## Note - this enum is set up with both entries the same
+## This means that mapping back from the integer value to the
+## string value isn't unique, so asking for "ABCD2" will return
+## a string of "ABCD"
+unittest("ABCD", enumWithMacroTest("ABCD"))
+
+## Different types
+unittest(10, enumToInteger(differentTypesTest("typeint"), "_DifferentSpace__DifferentTypes"))
+unittest(0, enumToInteger(differentTypesTest("typeboolfalse"), "_DifferentSpace__DifferentTypes"))
+unittest(1, enumToInteger(differentTypesTest("typebooltrue"), "_DifferentSpace__DifferentTypes"))
+unittest(2, enumToInteger(differentTypesTest("typebooltwo"), "_DifferentSpace__DifferentTypes"))
+unittest(utf8ToInt('C'), enumToInteger(differentTypesTest("typechar"), "_DifferentSpace__DifferentTypes"))
+unittest(utf8ToInt('D'), enumToInteger(differentTypesTest("typedefaultint"), "_DifferentSpace__DifferentTypes"))
+unittest(utf8ToInt('A') + 1, enumToInteger(differentTypesTest("typecharcompound"), "_DifferentSpace__DifferentTypes"))
+
+
+## Global different types
+## Test uses an anonymous type so the string mapping
+## framework doesn't exist.
diff --git a/Examples/test-suite/r/overload_null_runme.R b/Examples/test-suite/r/overload_null_runme.R
new file mode 100644
index 000000000..d187a1fbb
--- /dev/null
+++ b/Examples/test-suite/r/overload_null_runme.R
@@ -0,0 +1,49 @@
+clargs <- commandArgs(trailing=TRUE)
+source(file.path(clargs[1], "unittest.R"))
+
+dyn.load(paste("overload_null", .Platform$dynlib.ext, sep=""))
+source("overload_null.R")
+cacheMetaData(1)
+
+o <- Overload()
+x <- X()
+
+unittest(1, o$byval1(x))
+unittest(2, o$byval1(NULL))
+
+unittest(3, o$byval2(NULL))
+unittest(4, o$byval2(x))
+
+unittest(5, o$byref1(x))
+unittest(6, o$byref1(NULL))
+
+unittest(7, o$byref2(NULL))
+unittest(8, o$byref2(x))
+
+unittest(9, o$byconstref1(x))
+unittest(10, o$byconstref1(NULL))
+
+unittest(11, o$byconstref2(NULL))
+unittest(12, o$byconstref2(x))
+
+# const pointer references
+# No SWIGTYPE *const& typemaps for R yet
+#unittest(13, o$byval1cpr(x))
+#unittest(14, o$byval1cpr(NULL))
+
+#unittest(15, o$byval2cpr(NULL))
+#unittest(16, o$byval2cpr(x))
+
+# forward class declaration
+unittest(17, o$byval1forwardptr(x))
+unittest(18, o$byval1forwardptr(NULL))
+
+unittest(19, o$byval2forwardptr(NULL))
+unittest(20, o$byval2forwardptr(x))
+
+unittest(21, o$byval1forwardref(x))
+
+unittest(22, o$byval2forwardref(x))
+
+q(save="no")
+
diff --git a/Examples/test-suite/r/r_memory_leak_runme.R b/Examples/test-suite/r/r_memory_leak_runme.R
new file mode 100644
index 000000000..ef6533aef
--- /dev/null
+++ b/Examples/test-suite/r/r_memory_leak_runme.R
@@ -0,0 +1,26 @@
+clargs <- commandArgs(trailing=TRUE)
+source(file.path(clargs[1], "unittest.R"))
+
+dyn.load(paste("r_memory_leak", .Platform$dynlib.ext, sep=""))
+source("r_memory_leak.R")
+cacheMetaData(1)
+
+a <- Foo();
+unittest(Foo_get_count(), 1);
+b <- Foo();
+unittest(Foo_get_count(), 2);
+
+# Normal behaviour
+invisible(trigger_internal_swig_exception("no problem", a));
+unittest(Foo_get_count(), 2);
+# SWIG exception introduced
+result <- tryCatch({
+ trigger_internal_swig_exception("null", b);
+}, warning = function(w) {
+ # print(" Hum... We received a warning, but this should be an error");
+ unittest(1,0);
+}, error = function(e) {
+ # print(" Gotcha!");
+ unittest(1,1);
+})
+unittest(Foo_get_count(), 2);
diff --git a/Examples/test-suite/r/r_use_isnull_runme.R b/Examples/test-suite/r/r_use_isnull_runme.R
new file mode 100644
index 000000000..0dbf8762f
--- /dev/null
+++ b/Examples/test-suite/r/r_use_isnull_runme.R
@@ -0,0 +1,11 @@
+clargs <- commandArgs(trailing=TRUE)
+source(file.path(clargs[1], "unittest.R"))
+
+dyn.load(paste("r_use_isnull", .Platform$dynlib.ext, sep=""))
+source("r_use_isnull.R")
+cacheMetaData(1)
+
+tp <- pointerTest()
+circ1 <- tp$getCircle(1)
+circ1
+unittest(is.null(circ1), TRUE)
diff --git a/Examples/test-suite/r_memory_leak.i b/Examples/test-suite/r_memory_leak.i
new file mode 100644
index 000000000..a240097e3
--- /dev/null
+++ b/Examples/test-suite/r_memory_leak.i
@@ -0,0 +1,40 @@
+%module r_memory_leak
+
+%include <std_string.i>
+
+%typemap(in) Foo* foo
+{
+ $1 = new Foo;
+}
+%typemap(freearg) Foo* foo
+{
+ printf(" \" Object deleted\"\n");
+ delete $1;
+}
+%typemap(out) Foo* verify_no_memory_leak
+{
+ if ($1 == NULL)
+ SWIG_exception_fail(SWIG_RuntimeError, "Let's see how the bindings manage this exception!");
+}
+%typemap(scoerceout) Foo*
+ %{ if (!is.null($result) && !is.logical($result)) {$result <- new("$R_class", ref=$result) ;}; %}
+
+%inline %{
+ #include <string>
+
+ class Foo {
+ static unsigned count;
+ public:
+ Foo() { ++count; }
+ ~Foo() { --count; }
+ static unsigned get_count() { return count; }
+ };
+
+ unsigned Foo::count = 0;
+
+ static Foo* trigger_internal_swig_exception(const std::string& message, Foo* foo)
+ {
+ return (message == "null") ? NULL : foo;
+ };
+
+%}
diff --git a/Examples/test-suite/r_use_isnull.i b/Examples/test-suite/r_use_isnull.i
new file mode 100644
index 000000000..03b4c15a7
--- /dev/null
+++ b/Examples/test-suite/r_use_isnull.i
@@ -0,0 +1,34 @@
+%module r_use_isnull
+
+%inline %{
+// C++ code
+class circle {
+public:
+circle(double radius)
+{
+m_radius = radius;
+}
+double getArea() const
+{
+return (3.14 * m_radius * m_radius);
+}
+
+private:
+double m_radius;
+};
+
+class pointerTest {
+public:
+pointerTest() : m_circle(2) {}
+const circle * getCircle(int index) const {
+if (index == 0)
+return & m_circle;
+else
+return 0;
+}
+
+private:
+ circle m_circle;
+
+};
+ %}
diff --git a/Examples/test-suite/redefined_not.i b/Examples/test-suite/redefined_not.i
index db9d3a248..fde5994fb 100644
--- a/Examples/test-suite/redefined_not.i
+++ b/Examples/test-suite/redefined_not.i
@@ -1,6 +1,6 @@
%module redefined_not
-// These should not emit an Identifer redefined warning
+// These should not emit an Identifier redefined warning
%inline %{
typedef unsigned int my_size_t;
namespace Std {
diff --git a/Examples/test-suite/register_par.i b/Examples/test-suite/register_par.i
index 030be4556..643841455 100644
--- a/Examples/test-suite/register_par.i
+++ b/Examples/test-suite/register_par.i
@@ -1,6 +1,10 @@
%module register_par
+%{
+struct swig_tree;
+%}
+
// bug # 924413
%inline {
- void clear_tree_flags(register struct tree *tp, register int i) {}
+ void clear_tree_flags(register struct swig_tree *tp, register int i) {}
}
diff --git a/Examples/test-suite/rename.h b/Examples/test-suite/rename.h
index c8199eeeb..3f10c5856 100644
--- a/Examples/test-suite/rename.h
+++ b/Examples/test-suite/rename.h
@@ -27,7 +27,6 @@ namespace Space {
void templateXYZ(XYZ<T> i) {}
operator T() { return m_t; }
operator NotXYZ<T>() const { return m_notxyz; }
- operator XYZ<T>() const { XYZ<T> xyz = XYZ<T>(); return xyz; }
};
}
@@ -48,10 +47,7 @@ class ABC {
public:
void method(ABC a) const {}
void method(Klass k) const {}
-#if !defined(__clang__)
- // Workaround for: warning: conversion function converting 'Space::ABC' to itself will never be used
- operator ABC() const { ABC a; return a; }
-#endif
+ operator ABC*() const { return new ABC(); }
operator Klass() const { Klass k; return k; }
};
}
diff --git a/Examples/test-suite/rename1.i b/Examples/test-suite/rename1.i
index 38af2b3bd..92e6b3494 100644
--- a/Examples/test-suite/rename1.i
+++ b/Examples/test-suite/rename1.i
@@ -35,14 +35,9 @@
%rename(opNotXYZ3) Space::XYZ<Space::Klass>::operator NotXYZ<Space::Klass>() const;
%rename(opNotXYZ4) Space::XYZ<Space::Enu>::operator NotXYZ<Space::Enu>() const;
-%rename(opXYZ1) Space::XYZ::operator XYZ<T>() const;
-%rename(opXYZ2) Space::XYZ<int>::operator XYZ<int>() const;
-%rename(opXYZ3) Space::XYZ<Space::Klass>::operator XYZ<Space::Klass>() const;
-%rename(opXYZ4) Space::XYZ<Space::Enu>::operator XYZ<Space::Enu>() const;
-
%rename(methodABC) Space::ABC::method(ABC a) const;
-%rename(opABC) Space::ABC::operator ABC() const;
+%rename(opABC) Space::ABC::operator ABC*() const;
%rename(methodKlass) Space::ABC::method(Klass k) const;
%rename(opKlass) Space::ABC::operator Klass() const;
diff --git a/Examples/test-suite/rename2.i b/Examples/test-suite/rename2.i
index 6a9c22ecf..93b82ddc6 100644
--- a/Examples/test-suite/rename2.i
+++ b/Examples/test-suite/rename2.i
@@ -43,7 +43,7 @@ namespace Space {
%rename(methodABC) ABC::method(ABC a) const;
-%rename(opABC) ABC::operator ABC() const;
+%rename(opABC) ABC::operator ABC*() const;
%rename(methodKlass) ABC::method(Klass k) const;
%rename(opKlass) ABC::operator Klass() const;
}
diff --git a/Examples/test-suite/rename3.i b/Examples/test-suite/rename3.i
index b39979fdd..5b613d769 100644
--- a/Examples/test-suite/rename3.i
+++ b/Examples/test-suite/rename3.i
@@ -52,7 +52,7 @@ namespace Space {
%extend ABC {
%rename(methodABC) method(ABC a) const;
- %rename(opABC) operator ABC() const;
+ %rename(opABC) operator ABC*() const;
%rename(methodKlass) method(Klass k) const;
%rename(opKlass) operator Klass() const;
}
diff --git a/Examples/test-suite/rename4.i b/Examples/test-suite/rename4.i
index 9ddff362f..75f01ca5b 100644
--- a/Examples/test-suite/rename4.i
+++ b/Examples/test-suite/rename4.i
@@ -29,21 +29,18 @@ namespace Space {
%rename(tMethodXYZ2) templateXYZ(XYZ<int>);
%rename(opT2) operator int();
%rename(opNotXYZ2) operator NotXYZ<int>() const;
-%rename(opXYZ2) operator XYZ<int>() const;
%rename(tMethod3) templateT(Space::Klass i);
%rename(tMethodNotXYZ3) templateNotXYZ(NotXYZ<Space::Klass>);
%rename(tMethodXYZ3) templateXYZ(XYZ<Space::Klass>);
%rename(opT3) operator Space::Klass();
%rename(opNotXYZ3) operator NotXYZ<Space::Klass>() const;
-%rename(opXYZ3) operator XYZ<Space::Klass>() const;
%rename(tMethod4) templateT(Space::Enu i);
%rename(tMethodNotXYZ4) templateNotXYZ(NotXYZ<Space::Enu>);
%rename(tMethodXYZ4) templateXYZ(XYZ<Space::Enu>);
%rename(opT4) operator Space::Enu();
%rename(opNotXYZ4) operator NotXYZ<Space::Enu>() const;
-%rename(opXYZ4) operator XYZ<Space::Enu>() const;
namespace Space {
using namespace AnotherSpace;
@@ -60,7 +57,6 @@ namespace Space {
%rename(tMethodXYZ1) templateXYZ(XYZ<T>);
%rename(opT1) operator T();
%rename(opNotXYZ1) operator NotXYZ<T>() const;
- %rename(opXYZ1) operator XYZ<T>() const;
NotXYZ<int> *m_int;
T m_t;
@@ -74,7 +70,6 @@ namespace Space {
void templateXYZ(XYZ<T> i) {}
operator T() { return m_t; }
operator NotXYZ<T>() const { return m_notxyz; }
- operator XYZ<T>() const { XYZ<T> xyz; return xyz; }
};
}
@@ -93,16 +88,13 @@ class ABC {
public:
%rename(methodABC) method(ABC a) const;
- %rename(opABC) operator ABC() const;
+ %rename(opABC) operator ABC*() const;
%rename(methodKlass) method(Klass k) const;
%rename(opKlass) operator Klass() const;
void method(ABC a) const {}
void method(Klass k) const {}
-#if !defined(__clang__)
- // Workaround for: warning: conversion function converting 'Space::ABC' to itself will never be used
- operator ABC() const { ABC a; return a; }
-#endif
+ operator ABC*() const { return new ABC(); }
operator Klass() const { Klass k; return k; }
};
}
diff --git a/Examples/test-suite/restrict_cplusplus.i b/Examples/test-suite/restrict_cplusplus.i
index 62abffa52..53c5782a1 100644
--- a/Examples/test-suite/restrict_cplusplus.i
+++ b/Examples/test-suite/restrict_cplusplus.i
@@ -1,7 +1,8 @@
%module restrict_cplusplus
%{
-// For PHP 5.3 / gcc-4.4
+// Workaround PHP's headers which do:
+// #define restrict __restrict__
#ifdef restrict
#undef restrict
#endif
diff --git a/Examples/test-suite/ruby/Makefile.in b/Examples/test-suite/ruby/Makefile.in
index d94ac7061..2c59029ec 100644
--- a/Examples/test-suite/ruby/Makefile.in
+++ b/Examples/test-suite/ruby/Makefile.in
@@ -14,23 +14,42 @@ CPP_TEST_CASES = \
li_cstring \
li_factory \
li_std_functors \
+ li_std_list \
li_std_multimap \
li_std_pair_lang_object \
li_std_queue \
li_std_set \
li_std_stack \
+ li_std_wstring_inherit \
primitive_types \
+ ruby_alias_method \
+ ruby_global_immutable_vars_cpp \
ruby_keywords \
ruby_minherit_shared_ptr \
ruby_naming \
+ ruby_rdata \
ruby_track_objects \
ruby_track_objects_directors \
- std_containers
-# ruby_li_std_speed
-# stl_new
+ std_containers \
+# ruby_li_std_speed \
+# stl_new \
+
+CPP11_TEST_CASES = \
+ cpp11_hash_tables \
+ cpp11_shared_ptr_const \
+ cpp11_shared_ptr_nullptr_in_containers \
+ cpp11_shared_ptr_overload \
+ cpp11_shared_ptr_upcast \
+ cpp11_std_unordered_map \
+ cpp11_std_unordered_multimap \
+ cpp11_std_unordered_multiset \
+ cpp11_std_unordered_set \
C_TEST_CASES += \
li_cstring \
+ ruby_alias_global_function \
+ ruby_alias_module_function \
+ ruby_global_immutable_vars \
ruby_manual_proxy \
include $(srcdir)/../common.mk
@@ -39,6 +58,9 @@ include $(srcdir)/../common.mk
SWIGOPT += -w801 -noautorename -features autodoc=4
# Custom tests - tests with additional commandline options
+ruby_alias_global_function.ctest: SWIGOPT += -globalmodule
+ruby_global_immutable_vars.ctest: SWIGOPT += -globalmodule
+ruby_global_immutable_vars_cpp.cpptest: SWIGOPT += -globalmodule
ruby_naming.cpptest: SWIGOPT += -autorename
# Rules for the different types of tests
diff --git a/Examples/test-suite/ruby/cpp11_hash_tables_runme.rb b/Examples/test-suite/ruby/cpp11_hash_tables_runme.rb
new file mode 100644
index 000000000..203b0ce06
--- /dev/null
+++ b/Examples/test-suite/ruby/cpp11_hash_tables_runme.rb
@@ -0,0 +1,61 @@
+require 'swig_assert'
+require 'cpp11_hash_tables'
+
+[Cpp11_hash_tables::MapIntInt.new({1=>7}),
+ Cpp11_hash_tables::MultiMapIntInt.new({1=>7}),
+ Cpp11_hash_tables::UnorderedMapIntInt.new({1=>7}),
+ Cpp11_hash_tables::UnorderedMultiMapIntInt.new({1=>7})].each{|x|
+
+ swig_assert_equal("x.find_all{|e,k| e == 1}", "[[1,7]]", binding)
+
+ swig_assert_equal("x[1]", "7", binding)
+ swig_assert_equal("x[2]", "nil", binding)
+ x[2] = 9
+ swig_assert_equal("x[2]", "9", binding)
+ x.delete(2)
+ swig_assert_equal("x[2]", "nil", binding)
+ swig_assert_equal("x.empty?", "false", binding)
+ x.delete(1)
+ swig_assert_equal("x.empty?", "true", binding)
+ swig_assert_equal("x.include?(1)", "false", binding)
+}
+
+[Cpp11_hash_tables::MultiMapIntInt.new({1=>7}),
+ Cpp11_hash_tables::UnorderedMultiMapIntInt.new({1=>7})].each{|x|
+ x[1] = 9
+ swig_assert_equal("x[1].sort", "[7,9]", binding)
+}
+
+[Cpp11_hash_tables::SetInt.new([1]),
+ Cpp11_hash_tables::MultiSetInt.new([1]),
+ Cpp11_hash_tables::UnorderedSetInt.new([1]),
+ Cpp11_hash_tables::UnorderedMultiSetInt.new([1])].each{|x|
+
+ swig_assert_equal("x.find_all{|e| e == 1}", "[1]", binding)
+
+ swig_assert_equal("x.include?(1)", "true", binding)
+ swig_assert_equal("x.include?(2)", "false", binding)
+ x << 2
+ swig_assert_equal("x.include?(2)", "true", binding)
+ x.erase(2)
+ swig_assert_equal("x.empty?", "false", binding)
+ x.erase(1)
+ swig_assert_equal("x.empty?", "true", binding)
+}
+
+[Cpp11_hash_tables::MultiSetInt.new([1]),
+ Cpp11_hash_tables::UnorderedMultiSetInt.new([1])].each{|x|
+ x << 1
+ swig_assert_equal("x.count(1)", "2", binding)
+}
+
+[Cpp11_hash_tables::MapIntInt,
+ Cpp11_hash_tables::MultiMapIntInt,
+ Cpp11_hash_tables::UnorderedMapIntInt,
+ Cpp11_hash_tables::UnorderedMultiMapIntInt,
+ Cpp11_hash_tables::SetInt,
+ Cpp11_hash_tables::MultiSetInt,
+ Cpp11_hash_tables::UnorderedSetInt,
+ Cpp11_hash_tables::UnorderedMultiSetInt].each{|k|
+ swig_assert("k.include?(Enumerable)", binding)
+}
diff --git a/Examples/test-suite/ruby/cpp11_shared_ptr_const_runme.rb b/Examples/test-suite/ruby/cpp11_shared_ptr_const_runme.rb
new file mode 100644
index 000000000..149aa0898
--- /dev/null
+++ b/Examples/test-suite/ruby/cpp11_shared_ptr_const_runme.rb
@@ -0,0 +1,9 @@
+require "swig_assert"
+require "cpp11_shared_ptr_const"
+
+include Cpp11_shared_ptr_const
+
+swig_assert_equal_simple(1, foo( Foo.new(1) ).get_m )
+swig_assert_equal_simple(7, const_foo( Foo.new(7) ).get_m )
+swig_assert_equal_simple(7, foo_vec( Foo.new(7) )[0].get_m )
+swig_assert_equal_simple(8, const_foo_vec( Foo.new(8) )[0].get_m )
diff --git a/Examples/test-suite/ruby/cpp11_shared_ptr_nullptr_in_containers_runme.rb b/Examples/test-suite/ruby/cpp11_shared_ptr_nullptr_in_containers_runme.rb
new file mode 100644
index 000000000..9d8b3c050
--- /dev/null
+++ b/Examples/test-suite/ruby/cpp11_shared_ptr_nullptr_in_containers_runme.rb
@@ -0,0 +1,16 @@
+require "cpp11_shared_ptr_nullptr_in_containers"
+
+include Cpp11_shared_ptr_nullptr_in_containers
+
+a = ret_vec_c_shared_ptr()
+raise unless a[0].get_m == 0
+raise unless a[1] == nil
+raise unless a[2].get_m == 2
+
+a = ret_arg_vec([C.new(7), nil, C.new(9)])
+raise unless a[0].get_m == 7
+raise unless a[1] == nil
+raise unless a[2].get_m == 9
+
+raise unless is_last_null([C.new(7), C.new(8), nil])
+raise if is_last_null([C.new(7), C.new(8)])
diff --git a/Examples/test-suite/ruby/cpp11_shared_ptr_upcast_runme.rb b/Examples/test-suite/ruby/cpp11_shared_ptr_upcast_runme.rb
new file mode 100644
index 000000000..000b9b6a9
--- /dev/null
+++ b/Examples/test-suite/ruby/cpp11_shared_ptr_upcast_runme.rb
@@ -0,0 +1,60 @@
+require 'swig_assert'
+require 'cpp11_shared_ptr_upcast'
+
+
+include Cpp11_shared_ptr_upcast
+
+# non-overloaded
+swig_assert_equal_simple( 7, derived_num1(Derived.new(7)) )
+swig_assert_equal_simple( 7, derived_num2([Derived.new(7)]) )
+swig_assert_equal_simple( 7, derived_num3({0 => Derived.new(7)}) )
+
+swig_assert_equal_simple(-1, base_num1(Derived.new(7)) )
+swig_assert_equal_simple(-1, base_num2([Derived.new(7)]) )
+swig_assert_equal_simple(-1, base_num3({0 => Derived.new(7)}) )
+
+swig_assert_equal_simple( 999, derived_num1(nil) )
+swig_assert_equal_simple( 999, derived_num2([nil]) )
+swig_assert_equal_simple( 999, derived_num3({0 => nil}) )
+
+swig_assert_equal_simple( 999, base_num1(nil) )
+swig_assert_equal_simple( 999, base_num2([nil]) )
+swig_assert_equal_simple( 999, base_num3({0 => nil}) )
+
+# overloaded
+swig_assert_equal_simple( 7, derived_num(Derived.new(7)) )
+swig_assert_equal_simple( 7, derived_num([Derived.new(7)]) )
+swig_assert_equal_simple( 7, derived_num({0 => Derived.new(7)}) )
+
+swig_assert_equal_simple(-1, base_num(Derived.new(7)) )
+swig_assert_equal_simple(-1, base_num([Derived.new(7)]) )
+swig_assert_equal_simple(-1, base_num({0 => Derived.new(7)}) )
+
+# ptr to shared_ptr
+swig_assert_equal_simple( 7, derived2_num1(Derived2.new(7)) )
+swig_assert_equal_simple( 7, derived2_num2([Derived2.new(7)]) )
+swig_assert_equal_simple( 7, derived2_num3({0 => Derived2.new(7)}) )
+
+swig_assert_equal_simple( -1, base2_num1(Derived2.new(7)) )
+
+begin
+ # Upcast for pointers to shared_ptr in this generic framework has not been implemented
+ swig_assert_equal_simple( -1, base2_num2([Derived2.new(7)]) )
+ raise RuntimeError, "Failed to catch TypeError"
+rescue TypeError
+end
+begin
+ # Upcast for pointers to shared_ptr in this generic framework has not been implemented
+ swig_assert_equal_simple( -1, base2_num3({0 => Derived2.new(7)}) )
+ raise RuntimeError, "Failed to catch TypeError"
+rescue TypeError
+end
+
+swig_assert_equal_simple( 888, derived2_num1(nil) )
+swig_assert_equal_simple( 999, derived2_num2([nil]) ) # although 888 would be more consistent
+swig_assert_equal_simple( 999, derived2_num3({0 => nil}) ) # although 888 would be more consistent
+
+swig_assert_equal_simple( 888, base2_num1(nil) )
+swig_assert_equal_simple( 999, base2_num2([nil]) ) # although 888 would be more consistent
+swig_assert_equal_simple( 999, base2_num3({0 => nil}) ) # although 888 would be more consistent
+
diff --git a/Examples/test-suite/ruby/cpp11_li_std_array_runme.rb b/Examples/test-suite/ruby/cpp11_std_array_runme.rb
index 770f37c0f..13c5efb84 100644
--- a/Examples/test-suite/ruby/cpp11_li_std_array_runme.rb
+++ b/Examples/test-suite/ruby/cpp11_std_array_runme.rb
@@ -9,9 +9,9 @@
require 'swig_assert'
-require 'cpp11_li_std_array'
+require 'cpp11_std_array'
-include Cpp11_li_std_array
+include Cpp11_std_array
def failed(a, b, msg)
diff --git a/Examples/test-suite/ruby/director_smartptr_runme.rb b/Examples/test-suite/ruby/director_smartptr_runme.rb
index 8b4bd3d6d..46ef8b1b5 100644
--- a/Examples/test-suite/ruby/director_smartptr_runme.rb
+++ b/Examples/test-suite/ruby/director_smartptr_runme.rb
@@ -30,6 +30,25 @@ class Director_smartptr_MyBarFoo < Foo
end
end
+class Director_smartptr_MyBarFooDerived < FooDerived
+
+ def ping()
+ return "director_smartptr_MyBarFooDerived.ping()"
+ end
+
+ def pong()
+ return "director_smartptr_MyBarFooDerived.pong();" + ping()
+ end
+
+ def upcall(fooBarPtr)
+ return "overrideDerived;" + fooBarPtr.FooBarDo()
+ end
+
+ def makeFoo()
+ return Foo.new()
+ end
+end
+
def check(got, expected)
if (got != expected)
raise RuntimeError, "Failed, got: #{got} expected: #{expected}"
@@ -52,3 +71,8 @@ myFoo2 = Foo.new().makeFoo()
check(myFoo2.pong(), "Foo::pong();Foo::ping()")
check(Foo.callPong(myFoo2), "Foo::pong();Foo::ping()")
check(myFoo2.upcall(FooBar.new()), "Bar::Foo2::Foo2Bar()")
+
+myBarFooDerived = Director_smartptr_MyBarFooDerived.new()
+check(myBarFooDerived.ping(), "director_smartptr_MyBarFooDerived.ping()")
+check(FooDerived.callPong(myBarFooDerived), "director_smartptr_MyBarFooDerived.pong();director_smartptr_MyBarFooDerived.ping()")
+check(FooDerived.callUpcall(myBarFooDerived, fooBar), "overrideDerived;Bar::Foo2::Foo2Bar()")
diff --git a/Examples/test-suite/ruby/global_immutable_vars_cpp_runme.rb b/Examples/test-suite/ruby/global_immutable_vars_cpp_runme.rb
new file mode 100644
index 000000000..7897f7da5
--- /dev/null
+++ b/Examples/test-suite/ruby/global_immutable_vars_cpp_runme.rb
@@ -0,0 +1,48 @@
+#!/usr/bin/env ruby
+#
+# C++ version of global_immutable_vars_runme.rb
+#
+
+require 'swig_assert'
+
+require 'global_immutable_vars_cpp'
+
+# first check if all variables can be read
+swig_assert_each_line( <<EOF )
+Global_immutable_vars_cpp::default_mutable_var == 40
+Global_immutable_vars_cpp::global_immutable_var == 41
+Global_immutable_vars_cpp::specific_mutable_var == 42
+Global_immutable_vars_cpp::global_mutable_var == 43
+Global_immutable_vars_cpp::specific_immutable_var == 44
+EOF
+
+# check that all mutable variables can be modified
+swig_assert_each_line( <<EOF )
+Global_immutable_vars_cpp::default_mutable_var = 80
+Global_immutable_vars_cpp::default_mutable_var == 80
+Global_immutable_vars_cpp::specific_mutable_var = 82
+Global_immutable_vars_cpp::specific_mutable_var == 82
+Global_immutable_vars_cpp::global_mutable_var = 83
+Global_immutable_vars_cpp::global_mutable_var == 83
+EOF
+
+# now check that immutable variables cannot be modified
+had_exception = false
+begin
+ Global_immutable_vars_cpp::global_immutable_var = 81
+rescue NoMethodError => e
+ had_exception = true
+end
+swig_assert(had_exception, nil,
+ "Global_immutable_vars_cpp::global_immutable_var is writable (expected to be immutable)")
+
+had_exception = false
+begin
+ Global_immutable_vars_cpp::specific_immutable_var = 81
+rescue NoMethodError => e
+ had_exception = true
+end
+swig_assert(had_exception, nil,
+ "Global_immutable_vars_cpp::specific_immutable_var is writable (expected to be immutable)")
+
+swig_assert(Global_immutable_vars_cpp::check_values(80, 41, 82, 83, 44) == 1, nil, "Check values failed")
diff --git a/Examples/test-suite/ruby/global_immutable_vars_runme.rb b/Examples/test-suite/ruby/global_immutable_vars_runme.rb
new file mode 100644
index 000000000..ffbea270f
--- /dev/null
+++ b/Examples/test-suite/ruby/global_immutable_vars_runme.rb
@@ -0,0 +1,52 @@
+#!/usr/bin/env ruby
+#
+# Here the proper generation of mutable and immutable variables is tested
+# in the target language.
+# Immutable variables do not have "<var>=" methods generated by SWIG,
+# therefore trying to assign these variables shall throw a NoMethodError
+# exception.
+#
+
+require 'swig_assert'
+
+require 'global_immutable_vars'
+
+# first check if all variables can be read
+swig_assert_each_line( <<EOF )
+Global_immutable_vars::default_mutable_var == 40
+Global_immutable_vars::global_immutable_var == 41
+Global_immutable_vars::specific_mutable_var == 42
+Global_immutable_vars::global_mutable_var == 43
+Global_immutable_vars::specific_immutable_var == 44
+EOF
+
+# check that all mutable variables can be modified
+swig_assert_each_line( <<EOF )
+Global_immutable_vars::default_mutable_var = 80
+Global_immutable_vars::default_mutable_var == 80
+Global_immutable_vars::specific_mutable_var = 82
+Global_immutable_vars::specific_mutable_var == 82
+Global_immutable_vars::global_mutable_var = 83
+Global_immutable_vars::global_mutable_var == 83
+EOF
+
+# now check that immutable variables cannot be modified
+had_exception = false
+begin
+ Global_immutable_vars::global_immutable_var = 81
+rescue NoMethodError => e
+ had_exception = true
+end
+swig_assert(had_exception, nil,
+ "Global_immutable_vars::global_immutable_var is writable (expected to be immutable)")
+
+had_exception = false
+begin
+ Global_immutable_vars::specific_immutable_var = 81
+rescue NoMethodError => e
+ had_exception = true
+end
+swig_assert(had_exception, nil,
+ "Global_immutable_vars::specific_immutable_var is writable (expected to be immutable)")
+
+swig_assert(Global_immutable_vars::check_values(80, 41, 82, 83, 44) == 1, nil, "Check values failed")
diff --git a/Examples/test-suite/ruby/li_boost_shared_ptr_director_runme.rb b/Examples/test-suite/ruby/li_boost_shared_ptr_director_runme.rb
new file mode 100644
index 000000000..55c1cbebd
--- /dev/null
+++ b/Examples/test-suite/ruby/li_boost_shared_ptr_director_runme.rb
@@ -0,0 +1,103 @@
+require 'li_boost_shared_ptr_director'
+
+include Li_boost_shared_ptr_director
+
+class Derived < Base
+
+ def initialize(flag)
+ @return_none = flag
+ super()
+ end
+
+ def ret_c_shared_ptr
+ if @return_none
+ nil
+ else
+ C.new
+ end
+ end
+
+ def ret_c_by_value
+ C.new
+ end
+
+ def take_c_by_value(c)
+ c.get_m
+ end
+
+ def take_c_by_ref(c)
+ c.get_m
+ end
+
+ def take_c_by_pointer(c)
+ if c
+ c.get_m
+ else
+ -2
+ end
+ end
+
+ def take_c_by_pointer_ref(c)
+ if c
+ c.get_m
+ else
+ -3
+ end
+ end
+
+ def take_c_shared_ptr_by_value(c)
+ if c
+ c.get_m
+ else
+ -4
+ end
+ end
+
+ def take_c_shared_ptr_by_ref(c)
+ if c
+ c.get_m
+ else
+ -5
+ end
+ end
+
+ def take_c_shared_ptr_by_pointer(c)
+ if c
+ c.get_m
+ else
+ -6
+ end
+ end
+
+ def take_c_shared_ptr_by_pointer_ref(c)
+ if c
+ c.get_m
+ else
+ -7
+ end
+ end
+
+end
+
+a = Derived.new(false)
+b = Derived.new(true)
+
+raise unless call_ret_c_shared_ptr(a) == 1
+raise unless call_ret_c_shared_ptr(b) == -1
+raise unless call_ret_c_by_value(a) == 1
+
+raise unless call_take_c_by_value(a) == 5
+raise unless call_take_c_by_ref(a) == 6
+raise unless call_take_c_by_pointer(a) == 7
+raise unless call_take_c_by_pointer_ref(a) == 8
+raise unless call_take_c_shared_ptr_by_value(a) == 9
+raise unless call_take_c_shared_ptr_by_ref(a) == 10
+raise unless call_take_c_shared_ptr_by_pointer(a) == 11
+raise unless call_take_c_shared_ptr_by_pointer_ref(a) == 12
+
+raise unless call_take_c_by_pointer_with_null(a) == -2
+raise unless call_take_c_by_pointer_ref_with_null(a) == -3
+raise unless call_take_c_shared_ptr_by_value_with_null(a) == -4
+raise unless call_take_c_shared_ptr_by_ref_with_null(a) == -5
+raise unless call_take_c_shared_ptr_by_pointer_with_null(a) == -6
+raise unless call_take_c_shared_ptr_by_pointer_ref_with_null(a) == -7
diff --git a/Examples/test-suite/ruby/li_std_auto_ptr_runme.rb b/Examples/test-suite/ruby/li_std_auto_ptr_runme.rb
new file mode 100644
index 000000000..cec48a58c
--- /dev/null
+++ b/Examples/test-suite/ruby/li_std_auto_ptr_runme.rb
@@ -0,0 +1,27 @@
+#!/usr/bin/env ruby
+
+require 'swig_assert'
+
+require 'li_std_auto_ptr'
+
+def gc_check(expected_count)
+# GC.start(full_mark: true, immediate_sweep: true)
+ GC.start
+# GC is not reliably run, skip check
+# swig_assert_equal_simple(expected_count, Li_std_auto_ptr::Klass::getTotal_count())
+end
+
+k1 = Li_std_auto_ptr::makeKlassAutoPtr("first")
+k2 = Li_std_auto_ptr::makeKlassAutoPtr("second")
+swig_assert_equal_simple(2, Li_std_auto_ptr::Klass::getTotal_count())
+
+gc_check(2)
+k1 = nil
+gc_check(1)
+
+swig_assert_equal_simple(k2.getLabel(), "second")
+gc_check(1)
+
+k2 = nil
+gc_check(0)
+
diff --git a/Examples/test-suite/ruby/li_std_containers_overload_runme.rb b/Examples/test-suite/ruby/li_std_containers_overload_runme.rb
new file mode 100644
index 000000000..913b6113a
--- /dev/null
+++ b/Examples/test-suite/ruby/li_std_containers_overload_runme.rb
@@ -0,0 +1,44 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'li_std_containers_overload'
+
+include Li_std_containers_overload
+
+def check(got, expected)
+ if (got != expected)
+ raise RuntimeError, "Failed check. '#{got}' != '#{expected}'"
+ end
+end
+
+v = VectorX.new()
+check(VectorOverload(v), "vector<X>")
+
+v = VectorY.new()
+check(VectorOverload(v), "vector<Y>")
+
+v = VectorInt.new()
+check(VectorOverload(v), "vector<int>")
+
+v = VectorString.new()
+check(VectorOverload(v), "vector<string>")
+
+v = [X.new()]
+check(VectorOverload(v), "vector<X>")
+
+v = [Y.new()]
+check(VectorOverload(v), "vector<Y>")
+
+v = [1, 2, 3]
+check(VectorOverload(v), "vector<int>")
+
+v = ["aaa", "bbb", "ccc"]
+check(VectorOverload(v), "vector<string>")
diff --git a/Examples/test-suite/ruby/li_std_list_runme.rb b/Examples/test-suite/ruby/li_std_list_runme.rb
new file mode 100644
index 000000000..b1182e2e3
--- /dev/null
+++ b/Examples/test-suite/ruby/li_std_list_runme.rb
@@ -0,0 +1,8 @@
+require 'swig_assert'
+
+require 'li_std_list'
+
+include Li_std_list
+
+x = DoubleList.new([1,2,3])
+swig_assert_equal("[1.0]", "x.find_all{|e| e == 1 }", binding)
diff --git a/Examples/test-suite/ruby/li_std_wstring_inherit_runme.rb b/Examples/test-suite/ruby/li_std_wstring_inherit_runme.rb
new file mode 100644
index 000000000..b5a90d834
--- /dev/null
+++ b/Examples/test-suite/ruby/li_std_wstring_inherit_runme.rb
@@ -0,0 +1,12 @@
+# -*- coding: utf-8 -*-
+require 'swig_assert'
+require 'li_std_wstring_inherit'
+x = "abc"
+swig_assert_equal("Li_std_wstring_inherit.test_value(Li_std_wstring_inherit::Wstring.new(x))", "x", binding)
+
+
+x = "y"
+swig_assert_equal("Li_std_wstring_inherit.test_value(x)", "x", binding)
+a = Li_std_wstring_inherit::A.new(x)
+swig_assert_equal("Li_std_wstring_inherit.test_value(a)", "x", binding)
+
diff --git a/Examples/test-suite/ruby/li_std_wstring_runme.rb b/Examples/test-suite/ruby/li_std_wstring_runme.rb
new file mode 100644
index 000000000..170f80ebf
--- /dev/null
+++ b/Examples/test-suite/ruby/li_std_wstring_runme.rb
@@ -0,0 +1,59 @@
+# -*- coding: utf-8 -*-
+require 'swig_assert'
+require 'li_std_wstring'
+
+h = "h"
+swig_assert_equal("Li_std_wstring.test_wcvalue(h)", "h", binding)
+
+x = "abc"
+swig_assert_equal("Li_std_wstring.test_ccvalue(x)", "x", binding)
+swig_assert_equal("Li_std_wstring.test_cvalue(x)", "x", binding)
+
+swig_assert_equal("Li_std_wstring.test_wchar_overload(x)", "x", binding)
+swig_assert_equal("Li_std_wstring.test_wchar_overload()", "nil", binding)
+
+Li_std_wstring.test_pointer(nil)
+Li_std_wstring.test_const_pointer(nil)
+
+begin
+ Li_std_wstring.test_value(nil)
+ raise RuntimeError, "NULL check failed"
+rescue TypeError => e
+end
+
+begin
+ Li_std_wstring.test_reference(nil)
+ raise RuntimeError, "NULL check failed"
+rescue ArgumentError => e
+ swig_assert_simple(e.message.include? "invalid null reference")
+end
+begin
+ Li_std_wstring.test_const_reference(nil)
+ raise RuntimeError, "NULL check failed"
+rescue ArgumentError => e
+ swig_assert_simple(e.message.include? "invalid null reference")
+end
+
+x = "hello"
+swig_assert_equal("Li_std_wstring.test_const_reference(x)", "x", binding)
+
+s = "abc"
+swig_assert("Li_std_wstring.test_equal_abc(s)", binding)
+
+begin
+ Li_std_wstring.test_throw
+rescue RuntimeError => e
+ swig_assert_equal("e.message", "'throwing test_throw'", binding)
+end
+
+x = "abc\0def"
+swig_assert_equal("Li_std_wstring.test_value(x)", "x", binding)
+swig_assert_equal("Li_std_wstring.test_ccvalue(x)", '"abc"', binding)
+swig_assert_equal("Li_std_wstring.test_wchar_overload(x)", '"abc"', binding)
+
+ts = Li_std_wstring::Wchar_test_struct.new
+ts.wchar_t_member = h
+swig_assert_equal("ts.wchar_t_member", "h", binding)
+ts.wchar_t_ptr_member = s
+swig_assert_equal("ts.wchar_t_ptr_member", "s", binding)
+
diff --git a/Examples/test-suite/ruby/newobject1_runme.rb b/Examples/test-suite/ruby/newobject1_runme.rb
index f5dc12fb5..be1949377 100644
--- a/Examples/test-suite/ruby/newobject1_runme.rb
+++ b/Examples/test-suite/ruby/newobject1_runme.rb
@@ -8,7 +8,7 @@
#
# Ruby's GC is somewhat broken in that it will mark some more stack space
# leading to the collection of local objects to be delayed.
-# Thus, upon invokation, it sometimes you can wait up to several
+# Thus, upon invocation, it sometimes you can wait up to several
# instructions to kick in.
# See: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/7449
#
diff --git a/Examples/test-suite/ruby/newobject2_runme.rb b/Examples/test-suite/ruby/newobject2_runme.rb
index 99bc24374..b7ebea097 100644
--- a/Examples/test-suite/ruby/newobject2_runme.rb
+++ b/Examples/test-suite/ruby/newobject2_runme.rb
@@ -2,7 +2,7 @@
#
# Ruby's GC is somewhat broken in that it will mark some more stack space
# leading to the collection of local objects to be delayed.
-# Thus, upon invokation, it sometimes you can wait up to several
+# Thus, upon invocation, it sometimes you can wait up to several
# instructions to kick in.
# See: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/7449
#
@@ -18,10 +18,12 @@ require 'newobject2'
include Newobject2
GC.track_class = Foo
+GC.disable
GC.stats if $VERBOSE
100.times { foo1 = makeFoo }
GC.stats if $VERBOSE
swig_assert( 'fooCount == 100', nil, "but is #{fooCount}" )
+GC.enable
GC.start
swig_assert( 'fooCount <= 1', nil, "but is #{fooCount}" )
diff --git a/Examples/test-suite/ruby/overload_null_runme.rb b/Examples/test-suite/ruby/overload_null_runme.rb
new file mode 100644
index 000000000..eabea5e40
--- /dev/null
+++ b/Examples/test-suite/ruby/overload_null_runme.rb
@@ -0,0 +1,52 @@
+#!/usr/bin/env ruby
+#
+# Put script description here.
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+require 'overload_null'
+
+include Overload_null
+
+o = Overload.new
+x = X.new
+
+swig_assert(1 == o.byval1(x))
+swig_assert(2 == o.byval1(nil))
+
+swig_assert(3 == o.byval2(nil))
+swig_assert(4 == o.byval2(x))
+
+swig_assert(5 == o.byref1(x))
+swig_assert(6 == o.byref1(nil))
+
+swig_assert(7 == o.byref2(nil))
+swig_assert(8 == o.byref2(x))
+
+swig_assert(9 == o.byconstref1(x))
+swig_assert(10 == o.byconstref1(nil))
+
+swig_assert(11 == o.byconstref2(nil))
+swig_assert(12 == o.byconstref2(x))
+
+# const pointer references
+swig_assert(13 == o.byval1cpr(x))
+swig_assert(14 == o.byval1cpr(nil))
+
+swig_assert(15 == o.byval2cpr(nil))
+swig_assert(16 == o.byval2cpr(x))
+
+# forward class declaration
+swig_assert(17 == o.byval1forwardptr(x))
+swig_assert(18 == o.byval1forwardptr(nil))
+
+swig_assert(19 == o.byval2forwardptr(nil))
+swig_assert(20 == o.byval2forwardptr(x))
+
+swig_assert(21 == o.byval1forwardref(x))
+
+swig_assert(22 == o.byval2forwardref(x))
diff --git a/Examples/test-suite/ruby/ruby_alias_global_function_runme.rb b/Examples/test-suite/ruby/ruby_alias_global_function_runme.rb
new file mode 100644
index 000000000..14e38e4cf
--- /dev/null
+++ b/Examples/test-suite/ruby/ruby_alias_global_function_runme.rb
@@ -0,0 +1,20 @@
+#!/usr/bin/env ruby
+#
+# Runtime tests for ruby_alias_global_function.i
+#
+
+require 'swig_assert'
+require 'ruby_alias_global_function'
+
+expected_name = get_my_name
+
+swig_assert(fullname == expected_name, msg: "nickname not working as expected")
+swig_assert(nickname == expected_name, msg: "fullname not working as expected")
+
+if method(:nickname).respond_to?(:original_name)
+ swig_assert_equal_simple(method(:nickname).original_name, :get_my_name)
+ swig_assert_equal_simple(method(:fullname).original_name, :get_my_name)
+else
+ swig_assert(method(:nickname) == method(:get_my_name), msg: "nickname is not an alias of get_my_name")
+ swig_assert(method(:fullname) == method(:get_my_name), msg: "fullname is not an alias of get_my_name")
+end
diff --git a/Examples/test-suite/ruby/ruby_alias_method_runme.rb b/Examples/test-suite/ruby/ruby_alias_method_runme.rb
new file mode 100644
index 000000000..c19101e63
--- /dev/null
+++ b/Examples/test-suite/ruby/ruby_alias_method_runme.rb
@@ -0,0 +1,24 @@
+#!/usr/bin/env ruby
+#
+# Runtime tests for ruby_alias_method.i
+#
+
+require 'swig_assert'
+require 'ruby_alias_method'
+
+include Ruby_alias_method
+
+expected_name = "Chester Tester"
+syn = Synonym.new(expected_name)
+
+swig_assert(syn.getMyName() == expected_name, msg: "getMyName not working as expected")
+swig_assert(syn.nickname() == expected_name, msg: "nickname not working as expected")
+swig_assert(syn.fullname() == expected_name, msg: "fullname not working as expected")
+
+if syn.method(:nickname).respond_to?(:original_name)
+ swig_assert_equal_simple(syn.method(:nickname).original_name, :getMyName)
+ swig_assert_equal_simple(syn.method(:fullname).original_name, :getMyName)
+else
+ swig_assert(syn.method(:nickname) == syn.method(:getMyName))
+ swig_assert(syn.method(:fullname) == syn.method(:getMyName))
+end
diff --git a/Examples/test-suite/ruby/ruby_alias_module_function_runme.rb b/Examples/test-suite/ruby/ruby_alias_module_function_runme.rb
new file mode 100644
index 000000000..1f4205f1f
--- /dev/null
+++ b/Examples/test-suite/ruby/ruby_alias_module_function_runme.rb
@@ -0,0 +1,26 @@
+#!/usr/bin/env ruby
+#
+# Runtime tests for ruby_alias_module_function.i
+#
+
+require 'swig_assert'
+require 'ruby_alias_module_function'
+
+include Ruby_alias_module_function
+
+expected_name = Ruby_alias_module_function.get_my_name
+
+swig_assert(Ruby_alias_module_function.nickname == expected_name, msg: "nickname returned a different result than get_my_name")
+swig_assert(Ruby_alias_module_function.fullname == expected_name, msg: "fullname returned a different result than get_my_name")
+
+nickname_method = Ruby_alias_module_function.method(:nickname)
+fullname_method = Ruby_alias_module_function.method(:fullname)
+
+if nickname_method.respond_to?(:original_name)
+ swig_assert_equal_simple(nickname_method.original_name, :get_my_name)
+ swig_assert_equal_simple(fullname_method.original_name, :get_my_name)
+else
+ original_method = Ruby_alias_module_function.method(:get_my_name)
+ swig_assert(nickname_method == original_method, msg: "nickname is not an alias of get_my_name")
+ swig_assert(fullname_method == original_method, msg: "fullname is not an alias of get_my_name")
+end
diff --git a/Examples/test-suite/ruby/ruby_global_immutable_vars_cpp_runme.rb b/Examples/test-suite/ruby/ruby_global_immutable_vars_cpp_runme.rb
new file mode 100644
index 000000000..5523b59f4
--- /dev/null
+++ b/Examples/test-suite/ruby/ruby_global_immutable_vars_cpp_runme.rb
@@ -0,0 +1,48 @@
+#!/usr/bin/env ruby
+#
+# C++ version of ruby_global_immutable_vars_runme.rb.
+#
+
+require 'swig_assert'
+
+require 'ruby_global_immutable_vars_cpp'
+
+# first check if all variables can be read
+swig_assert_each_line( <<EOF )
+$default_mutable_var == 40
+$global_immutable_var == 41
+$specific_mutable_var == 42
+$global_mutable_var == 43
+$specific_immutable_var == 44
+EOF
+
+# check that all mutable variables can be modified
+swig_assert_each_line( <<EOF )
+$default_mutable_var = 80
+$default_mutable_var == 80
+$specific_mutable_var = 82
+$specific_mutable_var == 82
+$global_mutable_var = 83
+$global_mutable_var == 83
+EOF
+
+# now check that immutable variables cannot be modified
+had_exception = false
+begin
+ $global_immutable_var = 81
+rescue NameError => e
+ had_exception = true
+end
+swig_assert(had_exception, nil,
+ "$global_immutable_var is writable (expected to be immutable)")
+
+had_exception = false
+begin
+ $specific_immutable_var = 81
+rescue NameError => e
+ had_exception = true
+end
+swig_assert(had_exception, nil,
+ "$specific_immutable_var is writable (expected to be immutable)")
+
+swig_assert(check_values(80, 41, 82, 83, 44) == 1, nil, "Check values failed")
diff --git a/Examples/test-suite/ruby/ruby_global_immutable_vars_runme.rb b/Examples/test-suite/ruby/ruby_global_immutable_vars_runme.rb
new file mode 100644
index 000000000..45a8506ba
--- /dev/null
+++ b/Examples/test-suite/ruby/ruby_global_immutable_vars_runme.rb
@@ -0,0 +1,52 @@
+#!/usr/bin/env ruby
+#
+# This test program is similar to global_immutable_vars_runme.rb
+# with the difference that the global variables to check are also
+# Ruby global variables (SWIG Ruby option "-globalmodule").
+#
+# Immutable global variables shall throw a NameError exception.
+#
+
+require 'swig_assert'
+
+require 'ruby_global_immutable_vars'
+
+# first check if all variables can be read
+swig_assert_each_line( <<EOF )
+$default_mutable_var == 40
+$global_immutable_var == 41
+$specific_mutable_var == 42
+$global_mutable_var == 43
+$specific_immutable_var == 44
+EOF
+
+# check that all mutable variables can be modified
+swig_assert_each_line( <<EOF )
+$default_mutable_var = 80
+$default_mutable_var == 80
+$specific_mutable_var = 82
+$specific_mutable_var == 82
+$global_mutable_var = 83
+$global_mutable_var == 83
+EOF
+
+# now check that immutable variables cannot be modified
+had_exception = false
+begin
+ $global_immutable_var = 81
+rescue NameError => e
+ had_exception = true
+end
+swig_assert(had_exception, nil,
+ "$global_immutable_var is writable (expected to be immutable)")
+
+had_exception = false
+begin
+ $specific_immutable_var = 81
+rescue NameError => e
+ had_exception = true
+end
+swig_assert(had_exception, nil,
+ "$specific_immutable_var is writable (expected to be immutable)")
+
+swig_assert(check_values(80, 41, 82, 83, 44) == 1, nil, "Check values failed")
diff --git a/Examples/test-suite/ruby/ruby_rdata_runme.rb b/Examples/test-suite/ruby/ruby_rdata_runme.rb
new file mode 100644
index 000000000..b7f293077
--- /dev/null
+++ b/Examples/test-suite/ruby/ruby_rdata_runme.rb
@@ -0,0 +1,7 @@
+require 'swig_assert'
+require 'ruby_rdata'
+
+include Ruby_rdata
+
+swig_assert_equal_simple(1, take_proc_or_cpp_obj_and_ret_1(Proc.new{}))
+swig_assert_equal_simple(1, take_proc_or_cpp_obj_and_ret_1(C.new))
diff --git a/Examples/test-suite/ruby/std_containers_runme.rb b/Examples/test-suite/ruby/std_containers_runme.rb
index 73d443218..65a8b5b86 100644
--- a/Examples/test-suite/ruby/std_containers_runme.rb
+++ b/Examples/test-suite/ruby/std_containers_runme.rb
@@ -13,6 +13,8 @@ require 'swig_assert'
require 'std_containers'
include Std_containers
+swig_assert_equal("[true, false]", "videntb([true, false])")
+
swig_assert_each_line(<<'EOF', binding)
cube = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]
diff --git a/Examples/test-suite/ruby/swig_assert.rb b/Examples/test-suite/ruby/swig_assert.rb
index 69a1a0207..cbdfc036d 100644
--- a/Examples/test-suite/ruby/swig_assert.rb
+++ b/Examples/test-suite/ruby/swig_assert.rb
@@ -1,12 +1,7 @@
#!/usr/bin/env ruby
#
-# A simple function to create useful asserts
+# Useful assert functions
#
-#
-#
-#
-#
-
#
# Exception raised when some swig binding test fails
@@ -16,6 +11,21 @@ end
#
+# Simple assertions. Strings are not needed as arguments.
+#
+def swig_assert_equal_simple(a, b)
+ unless a == b
+ raise SwigRubyError.new("\n#{a} expected but was \n#{b}")
+ end
+end
+
+def swig_assert_simple(a)
+ unless a
+ raise SwigRubyError.new("assertion failed.")
+ end
+end
+
+#
# Asserts whether a and b are equal.
#
# scope - optional Binding where to run the code
diff --git a/Examples/test-suite/ruby_alias_global_function.i b/Examples/test-suite/ruby_alias_global_function.i
new file mode 100644
index 000000000..bddb24959
--- /dev/null
+++ b/Examples/test-suite/ruby_alias_global_function.i
@@ -0,0 +1,11 @@
+%module ruby_alias_global_function
+
+%alias get_my_name "nickname,fullname";
+
+%inline %{
+
+const char *get_my_name(){
+ return "Chester Tester";
+}
+
+%}
diff --git a/Examples/test-suite/ruby_alias_method.i b/Examples/test-suite/ruby_alias_method.i
new file mode 100644
index 000000000..9ddcfce5e
--- /dev/null
+++ b/Examples/test-suite/ruby_alias_method.i
@@ -0,0 +1,26 @@
+%module ruby_alias_method
+%include <std_string.i>
+
+%alias Synonym::getMyName "nickname,fullname"
+
+%inline %{
+
+class Synonym {
+private:
+ std::string myName;
+
+public:
+ Synonym(std::string myName);
+
+ std::string getMyName();
+};
+
+Synonym::Synonym(std::string myName){
+ this->myName = myName;
+};
+
+std::string Synonym::getMyName(){
+ return this->myName;
+};
+
+%}
diff --git a/Examples/test-suite/ruby_alias_module_function.i b/Examples/test-suite/ruby_alias_module_function.i
new file mode 100644
index 000000000..900de5f1d
--- /dev/null
+++ b/Examples/test-suite/ruby_alias_module_function.i
@@ -0,0 +1,11 @@
+%module ruby_alias_module_function
+
+%alias get_my_name "nickname,fullname";
+
+%inline %{
+
+const char *get_my_name(){
+ return "Chester Tester";
+}
+
+%}
diff --git a/Examples/test-suite/ruby_global_immutable_vars.i b/Examples/test-suite/ruby_global_immutable_vars.i
new file mode 100644
index 000000000..6f067d269
--- /dev/null
+++ b/Examples/test-suite/ruby_global_immutable_vars.i
@@ -0,0 +1,34 @@
+%module ruby_global_immutable_vars
+
+// This copy of global_immutable_vars.i shall be compiled with the
+// SWIG Ruby option "-globalmodule" in order to check the code path
+// for registering global methods (in contrast to module methods).
+
+%inline %{
+ int default_mutable_var = 40;
+%}
+
+%immutable;
+%feature("immutable", "0") specific_mutable_var;
+
+%inline %{
+ int global_immutable_var = 41;
+ int specific_mutable_var = 42;
+%}
+
+%mutable;
+%immutable specific_immutable_var;
+%inline %{
+ int global_mutable_var = 43;
+ int specific_immutable_var = 44;
+
+ int check_values(int default_mutable, int global_immutable, int specific_mutable, int global_mutable, int specific_immutable) {
+ return
+ default_mutable == default_mutable_var &&
+ global_immutable == global_immutable_var &&
+ specific_mutable == specific_mutable_var &&
+ global_mutable == global_mutable_var &&
+ specific_immutable == specific_immutable_var;
+ }
+%}
+
diff --git a/Examples/test-suite/ruby_global_immutable_vars_cpp.i b/Examples/test-suite/ruby_global_immutable_vars_cpp.i
new file mode 100644
index 000000000..511390e20
--- /dev/null
+++ b/Examples/test-suite/ruby_global_immutable_vars_cpp.i
@@ -0,0 +1,32 @@
+%module ruby_global_immutable_vars_cpp
+
+// C++ version of ruby_global_immutable_vars.i
+
+%inline %{
+ int default_mutable_var = 40;
+%}
+
+%immutable;
+%feature("immutable", "0") specific_mutable_var;
+
+%inline %{
+ int global_immutable_var = 41;
+ int specific_mutable_var = 42;
+%}
+
+%mutable;
+%immutable specific_immutable_var;
+%inline %{
+ int global_mutable_var = 43;
+ int specific_immutable_var = 44;
+
+ int check_values(int default_mutable, int global_immutable, int specific_mutable, int global_mutable, int specific_immutable) {
+ return
+ default_mutable == default_mutable_var &&
+ global_immutable == global_immutable_var &&
+ specific_mutable == specific_mutable_var &&
+ global_mutable == global_mutable_var &&
+ specific_immutable == specific_immutable_var;
+ }
+%}
+
diff --git a/Examples/test-suite/ruby_rdata.i b/Examples/test-suite/ruby_rdata.i
new file mode 100644
index 000000000..06af06f36
--- /dev/null
+++ b/Examples/test-suite/ruby_rdata.i
@@ -0,0 +1,20 @@
+%module ruby_rdata
+
+%{
+
+ class C {};
+
+ int take_proc_or_cpp_obj_and_ret_1(VALUE obj) {
+ return 1;
+ }
+
+ int take_proc_or_cpp_obj_and_ret_1(C c) {
+ return 1;
+ }
+
+%}
+
+class C {};
+
+int take_proc_or_cpp_obj_and_ret_1(VALUE);
+int take_proc_or_cpp_obj_and_ret_1(C);
diff --git a/Examples/test-suite/schemerunme/reference_global_vars.scm b/Examples/test-suite/schemerunme/reference_global_vars.scm
index 4b3370cfc..29d0904b8 100644
--- a/Examples/test-suite/schemerunme/reference_global_vars.scm
+++ b/Examples/test-suite/schemerunme/reference_global_vars.scm
@@ -56,4 +56,12 @@
(if (!= (TestClass-num-get (value-TestClass (var-TestClass))) 20)
(begin (display "Runtime test 13 failed.\n") (exit 1)))
+; Test garbage collection on guile >= 2.0.12
+(if (or (and (string=? (major-version) "2")
+ (string=? (minor-version) "0")
+ (string>=? (micro-version) "12"))
+ (and (string>=? (major-version) "2")
+ (string>=? (minor-version) "1")))
+ (gc))
+
(exit 0)
diff --git a/Examples/test-suite/scilab/Makefile.in b/Examples/test-suite/scilab/Makefile.in
index 483ed2439..f873b8687 100644
--- a/Examples/test-suite/scilab/Makefile.in
+++ b/Examples/test-suite/scilab/Makefile.in
@@ -29,7 +29,7 @@ CPP_STD_TEST_CASES += \
include $(srcdir)/../common.mk
-# Overriden variables
+# Overridden variables
SRCDIR = ../$(srcdir)/
# Local variables
diff --git a/Examples/test-suite/scilab/li_std_container_typemaps_runme.sci b/Examples/test-suite/scilab/li_std_container_typemaps_runme.sci
index e4832efe6..af87d54bf 100644
--- a/Examples/test-suite/scilab/li_std_container_typemaps_runme.sci
+++ b/Examples/test-suite/scilab/li_std_container_typemaps_runme.sci
@@ -6,7 +6,7 @@ function checkerror(ierr, cmd)
if ierr <> 0 then swigtesterror("error " + string(ierr) + " in """ + cmd + """"); end
endfunction
-// test container of pointers returned from fonction (expected a list)
+// test container of pointers returned from function (expected a list)
function [classAPtr_list, classAPtr1, classAPtr2] = testCreateContainerPtr(container, value1, value2)
classAPtr1 = new_ClassA(value1);
classAPtr2 = new_ClassA(value2);
@@ -57,7 +57,7 @@ endfunction
// computed on the container
function testContainerType(container, value_type, value1, value2, ..
expected_returned_container, expected_accumulate_value)
- // test container of basic type returned from fonction
+ // test container of basic type returned from function
func = msprintf("ret_%s_%s", value_type, container);
if value_type == "string" then
cmd = msprintf("c = %s(''%s'', ''%s'');", func, value1, value2);
diff --git a/Examples/test-suite/scilab/li_std_deque_runme.sci b/Examples/test-suite/scilab/li_std_deque_runme.sci
index c0680846b..0903db4ae 100644
--- a/Examples/test-suite/scilab/li_std_deque_runme.sci
+++ b/Examples/test-suite/scilab/li_std_deque_runme.sci
@@ -25,7 +25,7 @@ IntDeque_push_back(intDeque, 6);
avg = average(intDeque);
checkequal(avg, 4.0, "average(intDeque)");
-// half shoud return a deque with elements half of the input elements
+// half should return a deque with elements half of the input elements
RealDeque_clear(realDeque);
RealDeque_push_front(realDeque, 2.0);
RealDeque_push_front(realDeque, 4.0);
diff --git a/Examples/test-suite/scilab/null_pointer_runme.sci b/Examples/test-suite/scilab/null_pointer_runme.sci
index 2c693d259..dab59acf8 100644
--- a/Examples/test-suite/scilab/null_pointer_runme.sci
+++ b/Examples/test-suite/scilab/null_pointer_runme.sci
@@ -2,6 +2,6 @@ exec("swigtest.start", -1);
p = getnull();
checkequal(SWIG_this(p), 0, "SWIG_this(p)");
-checkequal(func(p), %T, "func(p)");
+checkequal(funk(p), %T, "funk(p)");
exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/overload_null_runme.sci b/Examples/test-suite/scilab/overload_null_runme.sci
new file mode 100644
index 000000000..e3939ac5c
--- /dev/null
+++ b/Examples/test-suite/scilab/overload_null_runme.sci
@@ -0,0 +1,45 @@
+exec("swigtest.start", -1);
+
+NULL = SWIG_ptr(0);
+
+o = new_Overload();
+x = new_X();
+
+checkequal(1, Overload_byval1(o, x), "test 1");
+checkequal(2, Overload_byval1(o, NULL), "test 2");
+
+checkequal(3, Overload_byval2(o, NULL), "test 3");
+checkequal(4, Overload_byval2(o, x), "test 4");
+
+checkequal(5, Overload_byref1(o, x), "test 5");
+checkequal(6, Overload_byref1(o, NULL), "test 6");
+
+checkequal(7, Overload_byref2(o, NULL), "test 7");
+checkequal(8, Overload_byref2(o, x), "test 8");
+
+checkequal(9, Overload_byconstref1(o, x), "test 9");
+checkequal(10, Overload_byconstref1(o, NULL), "test 10");
+
+checkequal(11, Overload_byconstref2(o, NULL), "test 11");
+checkequal(12, Overload_byconstref2(o, x), "test 12");
+
+// const pointer references
+checkequal(13, Overload_byval1cpr(o, x), "test 13");
+checkequal(14, Overload_byval1cpr(o, NULL), "test 14");
+
+checkequal(15, Overload_byval2cpr(o, NULL), "test 15");
+checkequal(16, Overload_byval2cpr(o, x), "test 16");
+
+// forward class declaration
+checkequal(17, Overload_byval1forwardptr(o, x), "test 17");
+checkequal(18, Overload_byval1forwardptr(o, NULL), "test 18");
+
+checkequal(19, Overload_byval2forwardptr(o, NULL), "test 19");
+checkequal(20, Overload_byval2forwardptr(o, x), "test 20");
+
+checkequal(21, Overload_byval1forwardref(o, x), "test 21");
+
+checkequal(22, Overload_byval2forwardref(o, x), "test 22");
+
+exec("swigtest.quit", -1);
+
diff --git a/Examples/test-suite/scilab/scilab_li_matrix_runme.sci b/Examples/test-suite/scilab/scilab_li_matrix_runme.sci
index 41924d6f9..55184cc20 100644
--- a/Examples/test-suite/scilab/scilab_li_matrix_runme.sci
+++ b/Examples/test-suite/scilab/scilab_li_matrix_runme.sci
@@ -2,7 +2,7 @@
exec("swigtest.start", -1);
-// test matrix passed as output argument from fonction
+// test matrix passed as output argument from function
function test_outMatrix(func, valueType, expectedOutMatrix)
funcName = msprintf("out%s%s", valueType, func);
cmd = msprintf("outMatrix = %s();", funcName);
@@ -13,7 +13,7 @@ function test_outMatrix(func, valueType, expectedOutMatrix)
checkequal(outMatrix, expectedOutMatrix, funcName);
endfunction
-// test matrix passed as input argument of fonction
+// test matrix passed as input argument of function
function test_inMatrix(func, valueType, inMatrix, expectedInValue)
funcName = msprintf("in%s%s", valueType, func);
cmd = msprintf("inValue = %s(inMatrix);", funcName);
@@ -24,7 +24,7 @@ function test_inMatrix(func, valueType, inMatrix, expectedInValue)
checkequal(inValue, expectedInValue, funcName);
endfunction
-// test matrixes passed as input and output arguments of fonction
+// test matrixes passed as input and output arguments of function
function test_inoutMatrix(func, valueType, inoutMatrix, expectedInoutMatrix)
funcName = msprintf("inout%s%s", valueType, func);
cmd = msprintf("inoutMatrix = %s(inoutMatrix);", funcName);
diff --git a/Examples/test-suite/scilab/throw_exception_runme.sci b/Examples/test-suite/scilab/throw_exception_runme.sci
index 2eada4be2..535a2f4b9 100644
--- a/Examples/test-suite/scilab/throw_exception_runme.sci
+++ b/Examples/test-suite/scilab/throw_exception_runme.sci
@@ -8,15 +8,15 @@ endfunction
foo = new_Foo();
-checkException('Foo_test_int(foo)', 'Exception (int) occured: 37');
+checkException('Foo_test_int(foo)', 'Exception (int) occurred: 37');
-checkException('Foo_test_msg(foo)', 'Exception (char const *) occured: Dead');
+checkException('Foo_test_msg(foo)', 'Exception (char const *) occurred: Dead');
-checkException('Foo_test_multi(foo, 1)', 'Exception (int) occured: 37');
+checkException('Foo_test_multi(foo, 1)', 'Exception (int) occurred: 37');
-checkException('Foo_test_multi(foo, 2)', 'Exception (char const *) occured: Dead');
+checkException('Foo_test_multi(foo, 2)', 'Exception (char const *) occurred: Dead');
-checkException('Foo_test_cls(foo)', 'Exception (CError) occured.');
+checkException('Foo_test_cls(foo)', 'Exception (CError) occurred.');
delete_Foo(foo);
diff --git a/Examples/test-suite/scilab/varargs_overload_runme.sci b/Examples/test-suite/scilab/varargs_overload_runme.sci
index 7603b667c..7426e8165 100644
--- a/Examples/test-suite/scilab/varargs_overload_runme.sci
+++ b/Examples/test-suite/scilab/varargs_overload_runme.sci
@@ -4,7 +4,7 @@ checkequal(vararg_over1("Hello"), "Hello", "vararg_over1(""Hello"")");
checkequal(vararg_over1(2), "2", "vararg_over1(2)");
-checkequal(vararg_over2("Hello"), "Hello", "vararg_over1(""Hello"")");
+checkequal(vararg_over2("Hello"), "Hello", "vararg_over2(""Hello"")");
checkequal(vararg_over2(2, 2.2), "2 2.2", "vararg_over2(2, 2.2)")
@@ -18,4 +18,24 @@ checkequal(vararg_over4(123), "123", "vararg_over4(123)");
checkequal(vararg_over4("Hello", 123), "Hello", "vararg_over4(""Hello"", 123)");
+
+// Same as above but non-vararg function declared first
+
+checkequal(vararg_over6("Hello"), "Hello", "vararg_over6(""Hello"")");
+
+checkequal(vararg_over6(2), "2", "vararg_over6(2)");
+
+checkequal(vararg_over7("Hello"), "Hello", "vararg_over7(""Hello"")");
+
+checkequal(vararg_over7(2, 2.2), "2 2.2", "vararg_over7(2, 2.2)")
+
+checkequal(vararg_over8("Hello"), "Hello", "vararg_over8(""Hello"")");
+
+checkequal(vararg_over8(2, 2.2, "hey"), "2 2.2 hey", "vararg_over8(2, 2.2, ""hey"")");
+
+checkequal(vararg_over9("Hello"), "Hello", "vararg_over9(""Hello"")");
+
+checkequal(vararg_over9(123), "123", "vararg_over9(123)");
+
+checkequal(vararg_over9("Hello", 123), "Hello", "vararg_over9(""Hello"", 123)");
exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/simutry.i b/Examples/test-suite/simutry.i
index addea14db..ad45da425 100644
--- a/Examples/test-suite/simutry.i
+++ b/Examples/test-suite/simutry.i
@@ -23,7 +23,7 @@ namespace simuPOP
{
}
- virtual int func() const
+ virtual int funk() const
{ return m_pop.m_a; }
};
@@ -32,7 +32,7 @@ namespace simuPOP
struct DerivedOperator: public Operator<Pop>
{
DerivedOperator(int a):Operator<Pop>(a){}
- virtual int func() const
+ virtual int funk() const
{ return 2*this->m_pop.m_a; }
};
@@ -90,7 +90,7 @@ namespace simuPOP
void test( const std::vector< Operator<pop>*>& para)
{
for( size_t i =0; i < para.size(); ++i)
- para[i]->func();
+ para[i]->funk();
}
}
}
diff --git a/Examples/test-suite/smart_pointer_namespace2.i b/Examples/test-suite/smart_pointer_namespace2.i
index 882799862..e78364c25 100644
--- a/Examples/test-suite/smart_pointer_namespace2.i
+++ b/Examples/test-suite/smart_pointer_namespace2.i
@@ -49,11 +49,6 @@ namespace one
};
}
-%define PTR_DEF(o)
-typedef one::Ptr<o> o ## _ptr;
-%template(o ## _ptr) one::Ptr<o>;
-%enddef
-
namespace one
{
class Obj1
@@ -63,7 +58,8 @@ namespace one
void donothing() {}
};
- PTR_DEF(Obj1)
+ typedef one::Ptr<Obj1> Obj1_ptr;
+ %template(Obj1_ptr) one::Ptr<Obj1>;
}
namespace two
@@ -75,6 +71,9 @@ namespace two
void donothing() {}
};
- PTR_DEF(Obj2)
+ typedef one::Ptr<Obj2> Obj2_ptr;
}
+using two::Obj2;
+%template(Obj2_ptr) one::Ptr<Obj2>;
+
diff --git a/Examples/test-suite/smart_pointer_overload.i b/Examples/test-suite/smart_pointer_overload.i
index 0d2cc595d..08248d295 100644
--- a/Examples/test-suite/smart_pointer_overload.i
+++ b/Examples/test-suite/smart_pointer_overload.i
@@ -4,8 +4,6 @@
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) test;
#endif
-#ifndef SWIG_NO_OVERLOAD
-
%inline %{
struct Foo {
int x;
@@ -24,5 +22,3 @@ public:
};
%}
-#endif
-
diff --git a/Examples/test-suite/static_const_member_2.i b/Examples/test-suite/static_const_member_2.i
index 0b6d38d21..0b38b394b 100644
--- a/Examples/test-suite/static_const_member_2.i
+++ b/Examples/test-suite/static_const_member_2.i
@@ -4,6 +4,10 @@
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) oss::modules::CavityPackFlags::backward_field;
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) oss::modules::Test::current_profile;
+#ifdef SWIGOCAML
+%warnfilter(SWIGWARN_PARSE_KEYWORD) val;
+#endif
+
%inline %{
namespace oss
{
diff --git a/Examples/test-suite/std_containers.i b/Examples/test-suite/std_containers.i
index ae69b6418..80409a1f0 100644
--- a/Examples/test-suite/std_containers.i
+++ b/Examples/test-suite/std_containers.i
@@ -115,6 +115,10 @@
return v;
}
+ std::vector<bool> videntb(const std::vector<bool>& v)
+ {
+ return v;
+ }
int get_elem(const std::vector<int>& v, int index)
{
diff --git a/Examples/test-suite/stl_no_default_constructor.i b/Examples/test-suite/stl_no_default_constructor.i
new file mode 100644
index 000000000..32aff2b46
--- /dev/null
+++ b/Examples/test-suite/stl_no_default_constructor.i
@@ -0,0 +1,19 @@
+%module stl_no_default_constructor
+
+%include <stl.i>
+
+%inline %{
+struct NoDefaultCtor {
+ int value;
+ NoDefaultCtor(int i) : value(i) {}
+};
+%}
+
+#if defined(SWIGCSHARP) || defined(SWIGJAVA) || defined(SWIGD)
+%template(VectorNoDefaultCtor) std::vector<NoDefaultCtor>;
+#endif
+
+#if defined(SWIGJAVA) || defined(SWIGJAVA)
+%include <std_list.i>
+%template(ListNoDefaultCtor) std::list<NoDefaultCtor>;
+#endif
diff --git a/Examples/test-suite/string_simple.i b/Examples/test-suite/string_simple.i
index c319aa1ef..537daa570 100644
--- a/Examples/test-suite/string_simple.i
+++ b/Examples/test-suite/string_simple.i
@@ -1,10 +1,10 @@
%module string_simple
-%newobject copy_string;
+%newobject copy_str;
%inline %{
#include <string.h>
-const char* copy_string(const char* str) {
+const char* copy_str(const char* str) {
size_t len = strlen(str);
char* newstring = (char*) malloc(len + 1);
strcpy(newstring, str);
diff --git a/Examples/test-suite/tcl/null_pointer_runme.tcl b/Examples/test-suite/tcl/null_pointer_runme.tcl
index be99c7166..7ed87c153 100644
--- a/Examples/test-suite/tcl/null_pointer_runme.tcl
+++ b/Examples/test-suite/tcl/null_pointer_runme.tcl
@@ -3,7 +3,7 @@ if [ catch { load ./null_pointer[info sharedlibextension] null_pointer} err_msg
}
set a [A]
-if {[func $a] != 0} {
+if {[funk $a] != 0} {
puts stderr "null_pointer test 1 failed"
exit 1
}
diff --git a/Examples/test-suite/tcl/overload_null_runme.tcl b/Examples/test-suite/tcl/overload_null_runme.tcl
new file mode 100644
index 000000000..3716612ab
--- /dev/null
+++ b/Examples/test-suite/tcl/overload_null_runme.tcl
@@ -0,0 +1,52 @@
+
+if [ catch { load ./overload_null[info sharedlibextension] overload_null} err_msg ] {
+ puts stderr "Could not load shared object:\n$err_msg"
+}
+
+proc check {what expected actual} {
+ if {$expected != $actual } {
+ error "Failed: $what Expected: $expected , Actual: $actual"
+ }
+}
+
+set o [Overload]
+set x [X]
+
+check "test1 " 1 [$o byval1 $x]
+check "test2 " 2 [$o byval1 "NULL"]
+
+check "testX" 1 [$o byval1 $x]
+check "testX" 2 [$o byval1 "NULL"]
+
+check "testX" 3 [$o byval2 "NULL"]
+check "testX" 4 [$o byval2 $x]
+
+check "testX" 5 [$o byref1 $x]
+check "testX" 6 [$o byref1 "NULL"]
+
+check "testX" 7 [$o byref2 "NULL"]
+check "testX" 8 [$o byref2 $x]
+
+check "testX" 9 [$o byconstref1 $x]
+check "testX" 10 [$o byconstref1 "NULL"]
+
+check "testX" 11 [$o byconstref2 "NULL"]
+check "testX" 12 [$o byconstref2 $x]
+
+# const pointer references
+check "testX" 13 [$o byval1cpr $x]
+check "testX" 14 [$o byval1cpr "NULL"]
+
+check "testX" 15 [$o byval2cpr "NULL"]
+check "testX" 16 [$o byval2cpr $x]
+
+# forward class declaration
+check "testX" 17 [$o byval1forwardptr $x]
+check "testX" 18 [$o byval1forwardptr "NULL"]
+
+check "testX" 19 [$o byval2forwardptr "NULL"]
+check "testX" 20 [$o byval2forwardptr $x]
+
+check "testX" 21 [$o byval1forwardref $x]
+
+check "testX" 22 [$o byval2forwardref $x]
diff --git a/Examples/test-suite/template_class_reuse_name.i b/Examples/test-suite/template_class_reuse_name.i
new file mode 100644
index 000000000..818816d0e
--- /dev/null
+++ b/Examples/test-suite/template_class_reuse_name.i
@@ -0,0 +1,132 @@
+%module template_class_reuse_name
+
+// One parameter templates
+%inline %{
+namespace Space {
+ template <bool B> struct Bool1 { void tt(){}; void ff(){}; };
+ template <bool B = true> struct Bool2 { void tt(){}; void ff(){}; };
+ template <bool B> struct Bool3 {};
+ template <> struct Bool3<true> { void tt(){}; };
+ template <> struct Bool3<false> { void ff(){}; };
+ template <bool B = true> struct Bool4 { void tt(){}; };
+ template <> struct Bool4<false> { void ff(){}; };
+}
+%}
+
+// Instantiated names are the same as C++ template name
+%template(Bool1) Space::Bool1<true>;
+%template(Bool2) Space::Bool2<true>;
+%template(Bool3) Space::Bool3<true>;
+%template(Bool4) Space::Bool4<true>;
+
+// Instantiated names are not the same as C++ template name
+%template(Bool1False) Space::Bool1<false>;
+%template(Bool2False) Space::Bool2<false>;
+%template(Bool3False) Space::Bool3<false>;
+%template(Bool4False) Space::Bool4<false>;
+
+
+// Forward declared templates
+%inline %{
+namespace Space {
+ template <bool B> struct BoolForward1;
+ template <bool B> struct BoolForward2;
+ template <bool B> struct BoolForward3;
+ template <bool B> struct BoolForward4;
+
+ template <bool B> struct BoolForward1 { void tt(){}; void ff(){}; };
+ template <bool B = true> struct BoolForward2 { void tt(){}; void ff(){}; };
+ template <bool B> struct BoolForward3 {};
+ template <> struct BoolForward3<true> { void tt(){}; };
+ template <> struct BoolForward3<false> { void ff(){}; };
+ template <bool B = true> struct BoolForward4 { void tt(){}; };
+ template <> struct BoolForward4<false> { void ff(){}; };
+}
+%}
+
+// Instantiated names are the same as C++ template name
+%template(BoolForward1) Space::BoolForward1<true>;
+%template(BoolForward2) Space::BoolForward2<true>;
+%template(BoolForward3) Space::BoolForward3<true>;
+%template(BoolForward4) Space::BoolForward4<true>;
+
+// Instantiated names are not the same as C++ template name
+%template(BoolForward1False) Space::BoolForward1<false>;
+%template(BoolForward2False) Space::BoolForward2<false>;
+%template(BoolForward3False) Space::BoolForward3<false>;
+%template(BoolForward4False) Space::BoolForward4<false>;
+
+
+// Two parameter templates
+%inline %{
+namespace Space {
+ template <int I, bool B> struct IntBool1 { void tt(){}; void ff(){}; };
+ template <int I, bool B = true> struct IntBool2 { void tt(){}; void ff(){}; };
+ template <int I, bool B> struct IntBool3 {};
+ template <int I> struct IntBool3<I, true> { void tt(){}; };
+ template <int I> struct IntBool3<I, false> { void ff(){}; };
+ template <int I, bool B = true> struct IntBool4 { void tt(){}; };
+ template <int I> struct IntBool4<I, false> { void ff(){}; };
+}
+%}
+
+// Instantiated names are the same as C++ template name
+%template(IntBool1) Space::IntBool1<0, true>;
+%template(IntBool2) Space::IntBool2<0, true>;
+%template(IntBool3) Space::IntBool3<0, true>;
+%template(IntBool4) Space::IntBool4<0, true>;
+
+// Instantiated names are not the same as C++ template name
+%template(IntBool1False) Space::IntBool1<0, false>;
+%template(IntBool2False) Space::IntBool2<0, false>;
+%template(IntBool3False) Space::IntBool3<0, false>;
+%template(IntBool4False) Space::IntBool4<0, false>;
+
+
+%{
+namespace Space {
+ template <bool B> struct Duplicate1 { void ff(){}; };
+}
+%}
+
+%warnfilter(SWIGWARN_PARSE_REDEFINED) Space::Duplicate1;
+namespace Space {
+ template <bool B> struct Duplicate1 { void ff(){}; };
+ template <bool B> struct Duplicate1 { void ff(){}; };
+}
+
+
+%warnfilter(SWIGWARN_PARSE_REDEFINED) Space::Duplicate2;
+%inline %{
+namespace Space {
+ template <int I> struct Duplicate2 { void n(){}; };
+}
+%}
+%template(Duplicate2_0) Space::Duplicate2<0>;
+%template(Duplicate2_0) Space::Duplicate2<0>;
+
+
+%warnfilter(SWIGWARN_PARSE_REDEFINED) Space::Duplicate3;
+%inline %{
+namespace Space {
+ template <int I> struct Duplicate3 { void n(){}; };
+}
+%}
+%template(Duplicate3) Space::Duplicate3<0>;
+%template(Duplicate3) Space::Duplicate3<0>;
+
+
+%{
+namespace Space {
+ template <bool B> struct Duplicate4 { void ff(){}; };
+}
+%}
+
+%warnfilter(SWIGWARN_PARSE_REDEFINED) Space::Duplicate4;
+namespace Space {
+ template <bool B> struct Duplicate4 { void ff(){}; };
+ template <bool B> struct Duplicate4 { void ff(){}; };
+}
+%template(Duplicate4) Space::Duplicate4<0>;
+%template(Duplicate4) Space::Duplicate4<0>;
+
diff --git a/Examples/test-suite/template_default_cache.i b/Examples/test-suite/template_default_cache.i
new file mode 100644
index 000000000..70bccd595
--- /dev/null
+++ b/Examples/test-suite/template_default_cache.i
@@ -0,0 +1,35 @@
+%module template_default_cache;
+
+%inline %{
+ namespace d {
+ template< typename T > class d {};
+ }
+%}
+
+%ignore ns_a::iface1::Model;
+
+%inline %{
+namespace ns_a {
+ namespace iface1 {
+ class Model {};
+ typedef d::d<Model> ModelPtr;
+ }
+ using iface1::ModelPtr;
+}
+%}
+
+%inline %{
+namespace ns_b {
+ namespace iface1 {
+ class Model {
+ public:
+ ns_a::ModelPtr foo() { return ns_a::ModelPtr(); };
+ };
+ typedef d::d<Model> ModelPtr;
+ ns_a::ModelPtr get_mp_a() { return ns_a::ModelPtr(); }
+ ModelPtr get_mp_b() { return ModelPtr(); }
+ }
+ }
+%}
+%template(AModelPtr) d::d<ns_a::iface1::Model>;
+%template(BModelPtr) d::d<ns_b::iface1::Model>;
diff --git a/Examples/test-suite/template_default_class_parms.i b/Examples/test-suite/template_default_class_parms.i
index d07a1309f..02e993f32 100644
--- a/Examples/test-suite/template_default_class_parms.i
+++ b/Examples/test-suite/template_default_class_parms.i
@@ -1,5 +1,9 @@
%module template_default_class_parms
+#ifdef SWIGOCAML
+%warnfilter(SWIGWARN_PARSE_KEYWORD) method;
+#endif
+
%inline %{
namespace Space {
struct SomeType {};
diff --git a/Examples/test-suite/template_default_class_parms_typedef.i b/Examples/test-suite/template_default_class_parms_typedef.i
index 0767498bf..748b23cbb 100644
--- a/Examples/test-suite/template_default_class_parms_typedef.i
+++ b/Examples/test-suite/template_default_class_parms_typedef.i
@@ -4,6 +4,10 @@
%feature("python:nondynamic");
+#ifdef SWIGOCAML
+%warnfilter(SWIGWARN_PARSE_KEYWORD) method;
+#endif
+
%inline %{
namespace Space {
struct SomeType {};
diff --git a/Examples/test-suite/template_empty_inherit.i b/Examples/test-suite/template_empty_inherit.i
new file mode 100644
index 000000000..5677b8b1a
--- /dev/null
+++ b/Examples/test-suite/template_empty_inherit.i
@@ -0,0 +1,34 @@
+%module template_empty_inherit
+
+%rename(FunctorOperator) operator();
+
+%inline %{
+template<class Arg, typename Result> struct Functor {
+ virtual Result operator()(Arg x) const = 0;
+ virtual ~Functor() {}
+};
+%}
+
+// Bug fix - %ignore was resulting in this warning:
+// Warning 401: Base class 'Functor< int,int >' has no name as it is an empty template instantiated with '%template()'. Ignored.
+%ignore Functor<int, int>;
+%template() Functor<int, int>;
+
+%inline %{
+#include <algorithm>
+#include <iterator>
+struct SquareFunctor : Functor<int, int> {
+ int operator()(int v) const { return v*v; }
+};
+%}
+
+%include <std_vector.i>
+%template(VectorInt) std::vector<int>;
+
+%inline %{
+std::vector<int> squares(const std::vector<int>& vi) {
+ std::vector<int> result;
+ std::transform(vi.begin(), vi.end(), std::back_inserter(result), SquareFunctor());
+ return result;
+}
+%}
diff --git a/Examples/test-suite/template_nested_typemaps.i b/Examples/test-suite/template_nested_typemaps.i
index 54f5bc503..577a88e14 100644
--- a/Examples/test-suite/template_nested_typemaps.i
+++ b/Examples/test-suite/template_nested_typemaps.i
@@ -1,25 +1,30 @@
-#pragma SWIG nowarn=SWIGWARN_PARSE_NESTED_TEMPLATE
-
%module template_nested_typemaps
-// Testing that the typemaps invoked within a class via %template are picked up by appropriate methods
+#pragma SWIG nowarn=SWIGWARN_PARSE_NAMED_NESTED_CLASS
-template <typename T> struct Typemap {
- %typemap(in) T {
- $1 = -99;
- }
-};
-template <> struct Typemap<short> { // Note explicit specialization
- %typemap(in) short {
- $1 = -77;
- }
-};
+// Testing that the typemaps invoked within a class via %template are picked up by appropriate methods
+// Only for languages that support nested classes
%inline %{
int globalInt1(int s) { return s; }
short globalShort1(short s) { return s; }
template <typename T> struct Breeze {
+ template <typename TMT> struct Typemap {
+#ifdef SWIG
+ %typemap(in) TMT {
+ $1 = -99;
+ }
+#endif
+ };
+ template <typename TMT> struct TypemapShort {
+#ifdef SWIG
+ %typemap(in) short {
+ $1 = -77;
+ }
+#endif
+ };
+
int methodInt1(int s) { return s; }
#if defined(SWIG)
%template() Typemap<int>;
@@ -29,7 +34,7 @@ template <typename T> struct Breeze {
short methodShort1(short s) { return s; }
#if defined(SWIG)
- %template(TypemapShort) Typemap<short>; // should issue warning SWIGWARN_PARSE_NESTED_TEMPLATE
+ %template() TypemapShort<short>;
#endif
short methodShort2(short s) { return s; } // should pick up the typemap within Typemap<short>
};
diff --git a/Examples/test-suite/template_opaque.i b/Examples/test-suite/template_opaque.i
index b910e47e3..7aafd62e8 100644
--- a/Examples/test-suite/template_opaque.i
+++ b/Examples/test-suite/template_opaque.i
@@ -36,7 +36,4 @@ namespace A {
}
}
-#ifndef SWIGCSHARP
-// C# vector typemaps only ready for simple cases right now
%template(OpaqueVectorType) std::vector<A::OpaqueType>;
-#endif
diff --git a/Examples/test-suite/template_parameters_global_scope.i b/Examples/test-suite/template_parameters_global_scope.i
new file mode 100644
index 000000000..a828187b5
--- /dev/null
+++ b/Examples/test-suite/template_parameters_global_scope.i
@@ -0,0 +1,133 @@
+%module template_parameters_global_scope
+
+%inline %{
+namespace Alloc {
+ template<typename T> struct Rebind {
+ typedef int Integer;
+ };
+}
+%}
+
+%inline %{
+struct Bucket_ {};
+typedef Bucket_ TDBucket;
+typedef ::Bucket_ TDGlobalBucket;
+%}
+
+// Check 1: %template no unary scope operator
+%template(RebindBucket) Alloc::Rebind< Bucket_ >;
+
+%inline %{
+Alloc::Rebind< Bucket_ >::Integer Bucket1() { return 1; }
+Alloc::Rebind< ::Bucket_ >::Integer Bucket2() { return 2; }
+Alloc::Rebind< TDBucket >::Integer Bucket3() { return 3; }
+Alloc::Rebind< ::TDBucket >::Integer Bucket4() { return 4; }
+Alloc::Rebind< TDGlobalBucket >::Integer Bucket5() { return 5; }
+Alloc::Rebind< ::TDGlobalBucket >::Integer Bucket6() { return 6; }
+%}
+
+// Check 2: %template with unary scope operator
+%inline %{
+struct Spade {};
+typedef Spade TDSpade;
+typedef ::Spade TDGlobalSpade;
+%}
+%template(RebindSpade) Alloc::Rebind< ::Spade >;
+
+%inline %{
+Alloc::Rebind< Spade >::Integer Spade1() { return 1; }
+Alloc::Rebind< ::Spade >::Integer Spade2() { return 2; }
+Alloc::Rebind< TDSpade >::Integer Spade3() { return 3; }
+Alloc::Rebind< ::TDSpade >::Integer Spade4() { return 4; }
+Alloc::Rebind< TDGlobalSpade >::Integer Spade5() { return 5; }
+Alloc::Rebind< ::TDGlobalSpade >::Integer Spade6() { return 6; }
+%}
+
+// Check 3: %template typedef no unary scope operator
+%inline %{
+struct Ball {};
+typedef Ball TDBall;
+typedef ::Ball TDGlobalBall;
+%}
+%template(RebindBall) Alloc::Rebind< TDBall >;
+
+%inline %{
+Alloc::Rebind< Ball >::Integer Ball1() { return 1; }
+Alloc::Rebind< ::Ball >::Integer Ball2() { return 2; }
+Alloc::Rebind< TDBall >::Integer Ball3() { return 3; }
+Alloc::Rebind< ::TDBall >::Integer Ball4() { return 4; }
+Alloc::Rebind< TDGlobalBall >::Integer Ball5() { return 5; }
+Alloc::Rebind< ::TDGlobalBall >::Integer Ball6() { return 6; }
+%}
+
+// Check 4: %template typedef with unary scope operator
+%inline %{
+struct Bat {};
+typedef Bat TDBat;
+typedef ::Bat TDGlobalBat;
+%}
+%template(RebindBat) Alloc::Rebind< ::TDBat >;
+
+%inline %{
+Alloc::Rebind< Bat >::Integer Bat1() { return 1; }
+Alloc::Rebind< ::Bat >::Integer Bat2() { return 2; }
+Alloc::Rebind< TDBat >::Integer Bat3() { return 3; }
+Alloc::Rebind< ::TDBat >::Integer Bat4() { return 4; }
+Alloc::Rebind< TDGlobalBat >::Integer Bat5() { return 5; }
+Alloc::Rebind< ::TDGlobalBat >::Integer Bat6() { return 6; }
+%}
+
+// Check 5: %template double typedef no unary scope operator
+%inline %{
+struct Chair {};
+typedef Chair TDChair;
+typedef ::Chair TDGlobalChair;
+%}
+%template(RebindChair) Alloc::Rebind< TDGlobalChair >;
+
+%inline %{
+Alloc::Rebind< Chair >::Integer Chair1() { return 1; }
+Alloc::Rebind< ::Chair >::Integer Chair2() { return 2; }
+Alloc::Rebind< TDChair >::Integer Chair3() { return 3; }
+Alloc::Rebind< ::TDChair >::Integer Chair4() { return 4; }
+Alloc::Rebind< TDGlobalChair >::Integer Chair5() { return 5; }
+Alloc::Rebind< ::TDGlobalChair >::Integer Chair6() { return 6; }
+%}
+
+// Check 6: %template double typedef with unary scope operator
+%inline %{
+struct Table {};
+typedef Table TDTable;
+typedef ::Table TDGlobalTable;
+%}
+%template(RebindTable) Alloc::Rebind< ::TDGlobalTable >;
+
+%inline %{
+Alloc::Rebind< Table >::Integer Table1() { return 1; }
+Alloc::Rebind< ::Table >::Integer Table2() { return 2; }
+Alloc::Rebind< TDTable >::Integer Table3() { return 3; }
+Alloc::Rebind< ::TDTable >::Integer Table4() { return 4; }
+Alloc::Rebind< TDGlobalTable >::Integer Table5() { return 5; }
+Alloc::Rebind< ::TDGlobalTable >::Integer Table6() { return 6; }
+%}
+
+#if 0
+%inline %{
+namespace Alloc {
+ template<typename T=::Spade/*, typename T2=TDSpade, typename T3=::TDSpade, typename T4=TDGlobalSpade, typename T5=::TDGlobalSpade*/> struct Rejig {
+ typedef int Integer;
+ };
+}
+%}
+
+%template(RejigSpade) Alloc::Rejig<::Spade>;
+
+%inline %{
+Alloc::Rejig<>::Integer rejig1() { return 1; }
+Alloc::Rejig< ::Spade >::Integer rejig2() { return 2; }
+Alloc::Rejig< ::TDSpade >::Integer rejig3() { return 3; }
+Alloc::Rejig< ::TDSpade >::Integer rejig4() { return 4; }
+Alloc::Rejig< TDGlobalSpade >::Integer rejig5() { return 5; }
+Alloc::Rejig< ::TDGlobalSpade >::Integer rejig6() { return 6; }
+%}
+#endif
diff --git a/Examples/test-suite/template_partial_specialization.i b/Examples/test-suite/template_partial_specialization.i
index 8781fbbda..9727b52f8 100644
--- a/Examples/test-suite/template_partial_specialization.i
+++ b/Examples/test-suite/template_partial_specialization.i
@@ -12,10 +12,10 @@ namespace One {
template <> struct OneParm<int * const &> { void g() {} };
template <> struct OneParm<int **> { void h() {} };
- template <> struct OneParm<float> { void i() {} };
- template <> struct OneParm<float *> { void j() {} };
- template <> struct OneParm<float **> { void k() {} };
- template <> struct OneParm<float ***> { void l() {} };
+ template <> struct OneParm<float> { void j() {} };
+ template <> struct OneParm<float *> { void k() {} };
+ template <> struct OneParm<float **> { void m() {} };
+ template <> struct OneParm<float ***> { void n() {} };
}
%}
@@ -32,17 +32,17 @@ namespace One {
%template(H) One::OneParm<int **>;
// %template scope explicit specializations
-namespace ONE {
- %template(I) One::OneParm<float>;
- %template(J) ::One::OneParm<float *>;
+namespace One {
+ %template(J) One::OneParm<float>;
+ %template(K) ::One::OneParm<float *>;
}
-%template(K) ::One::OneParm<float **>;
+%template(M) ::One::OneParm<float **>;
namespace One {
- %template(L) OneParm<float ***>;
+ %template(N) OneParm<float ***>;
}
// %template scope partial specializations
-namespace ONE {
+namespace One {
%template(BB) One::OneParm<bool *>;
%template(BBB) ::One::OneParm<char *>;
}
diff --git a/Examples/test-suite/template_partial_specialization_typedef.i b/Examples/test-suite/template_partial_specialization_typedef.i
index 6fdbf99aa..6f8a11591 100644
--- a/Examples/test-suite/template_partial_specialization_typedef.i
+++ b/Examples/test-suite/template_partial_specialization_typedef.i
@@ -39,10 +39,10 @@ namespace One {
template <> struct OneParm<int * const &> { void g() {} };
template <> struct OneParm<int **> { void h() {} };
- template <> struct OneParm<float> { void i() {} };
- template <> struct OneParm<float *> { void j() {} };
- template <> struct OneParm<float **> { void k() {} };
- template <> struct OneParm<float ***> { void l() {} };
+ template <> struct OneParm<float> { void j() {} };
+ template <> struct OneParm<float *> { void k() {} };
+ template <> struct OneParm<float **> { void m() {} };
+ template <> struct OneParm<float ***> { void n() {} };
}
%}
@@ -59,17 +59,17 @@ namespace One {
%template(H) One::OneParm<TypeDef::IntPtrPtr>;
// %template scope explicit specializations
-namespace ONE {
- %template(I) One::OneParm<TypeDef::Float>;
- %template(J) ::One::OneParm<TypeDef::FloatPtr>;
+namespace One {
+ %template(J) One::OneParm<TypeDef::Float>;
+ %template(K) ::One::OneParm<TypeDef::FloatPtr>;
}
-%template(K) ::One::OneParm<TypeDef::FloatPtrPtr>;
+%template(M) ::One::OneParm<TypeDef::FloatPtrPtr>;
namespace One {
- %template(L) OneParm<TypeDef::FloatPtrPtrPtr>;
+ %template(N) OneParm<TypeDef::FloatPtrPtrPtr>;
}
// %template scope partial specializations
-namespace ONE {
+namespace One {
%template(BB) One::OneParm<TypeDef::BoolPtr>;
%template(BBB) ::One::OneParm<TypeDef::CharPtr>;
}
diff --git a/Examples/test-suite/template_typedef_class_template.i b/Examples/test-suite/template_typedef_class_template.i
index fc8151ff0..e391c6a3a 100644
--- a/Examples/test-suite/template_typedef_class_template.i
+++ b/Examples/test-suite/template_typedef_class_template.i
@@ -1,5 +1,9 @@
%module template_typedef_class_template
+#ifdef SWIGOCAML
+%warnfilter(SWIGWARN_PARSE_KEYWORD) val;
+#endif
+
%inline %{
namespace Standard {
template <class T, class U > struct Pair {
diff --git a/Examples/test-suite/template_typedef_cplx5.i b/Examples/test-suite/template_typedef_cplx5.i
index 84b09fd78..566696992 100644
--- a/Examples/test-suite/template_typedef_cplx5.i
+++ b/Examples/test-suite/template_typedef_cplx5.i
@@ -7,7 +7,7 @@
%inline %{
- // This typedef triggers an inifinite recursion
+ // This typedef triggers an infinite recursion
// in the next test1() nd test2() function declarations
typedef std::complex<double> complex;
diff --git a/Examples/test-suite/template_typemaps.i b/Examples/test-suite/template_typemaps.i
index d01945460..38a9c66de 100644
--- a/Examples/test-suite/template_typemaps.i
+++ b/Examples/test-suite/template_typemaps.i
@@ -25,6 +25,10 @@
%typemap(out) Integer2 { /* do nothing */ }
#endif
+#ifdef SWIGOCAML
+%warnfilter(SWIGWARN_PARSE_KEYWORD) val;
+#endif
+
%{
typedef int Integer1;
%}
diff --git a/Examples/test-suite/template_typemaps_typedef.i b/Examples/test-suite/template_typemaps_typedef.i
index 022fe884f..44c485dfb 100644
--- a/Examples/test-suite/template_typemaps_typedef.i
+++ b/Examples/test-suite/template_typemaps_typedef.i
@@ -2,6 +2,10 @@
// Similar to template_typedef_class_template
// Testing typemaps of a typedef of a nested class in a template and where the template uses default parameters
+#ifdef SWIGOCAML
+%warnfilter(SWIGWARN_PARSE_KEYWORD) val;
+#endif
+
%inline %{
namespace Standard {
template <class T, class U > struct Pair {
diff --git a/Examples/test-suite/template_typemaps_typedef2.i b/Examples/test-suite/template_typemaps_typedef2.i
index 64055c4ea..443fa3627 100644
--- a/Examples/test-suite/template_typemaps_typedef2.i
+++ b/Examples/test-suite/template_typemaps_typedef2.i
@@ -4,6 +4,10 @@
// Similar to template_typedef_class_template
// Testing typemaps of a typedef of a nested class in a template and where the template uses default parameters
+#ifdef SWIGOCAML
+%warnfilter(SWIGWARN_PARSE_KEYWORD) val;
+#endif
+
%inline %{
namespace Standard {
template <class T, class U > struct Pair {
diff --git a/Examples/test-suite/template_using_directive_typedef.i b/Examples/test-suite/template_using_directive_typedef.i
new file mode 100644
index 000000000..1c8bcb9dd
--- /dev/null
+++ b/Examples/test-suite/template_using_directive_typedef.i
@@ -0,0 +1,44 @@
+%module template_using_directive_typedef
+
+%inline %{
+namespace space {
+ template<typename T> class Vector {};
+ class VectorClass {};
+}
+struct Obj {};
+%}
+
+%template(Vector_Obj) space::Vector<Obj>;
+
+%inline %{
+namespace tns {
+ using space::Vector; // template using directives were not being added into the typedef table
+ using space::VectorClass;
+ typedef Vector<Obj> NSVec;
+}
+%}
+
+%inline %{
+namespace tns {
+ struct Holder {
+// using Vec = Vector<Obj>;
+ typedef Vector<Obj> Vec;
+ typedef VectorClass VecClass;
+ Vec items;
+ void holder_use1(space::Vector<Obj>, tns::NSVec, tns::Vector<Obj>) {}
+ void holder_use2(space::Vector<Obj>, NSVec, Vector<Obj>) {}
+ void holder_use3(tns::Holder::Vec, Holder::Vec, Vec) {}
+ };
+ void tns_holder_use(tns::Holder::Vec, Holder::Vec) {}
+ void tns_use(space::Vector<Obj>, NSVec, tns::NSVec) {}
+}
+void global_holder_use(tns::Holder::Vec) {}
+void global_use(space::Vector<Obj>, tns::NSVec, tns::Vector<Obj>) {}
+namespace ns1 {
+ void ns1_holder_use(tns::Holder::Vec) {}
+}
+namespace ns2 {
+ using namespace tns;
+ void ns2_holder_use(tns::Holder::Vec, Holder::Vec, NSVec, Vector<Obj>) {}
+}
+%}
diff --git a/Examples/test-suite/template_virtual.i b/Examples/test-suite/template_virtual.i
index 8c844f946..c760e1833 100644
--- a/Examples/test-suite/template_virtual.i
+++ b/Examples/test-suite/template_virtual.i
@@ -1,7 +1,7 @@
%module template_virtual
// Submitted by Marcelo Matus
-// assertion emmitted with templates + derivation + pure virtual member
+// assertion emitted with templates + derivation + pure virtual member
// allocate.cxx:47: int Allocate::is_abstract_inherit(Node*, Node*):
// Assertion `dn' failed.
diff --git a/Examples/test-suite/threads_exception.i b/Examples/test-suite/threads_exception.i
index caa79c78e..4708633db 100644
--- a/Examples/test-suite/threads_exception.i
+++ b/Examples/test-suite/threads_exception.i
@@ -4,6 +4,14 @@
%module(threads="1") threads_exception
+// throw is invalid in C++17 and later, only SWIG to use it
+#define TESTCASE_THROW1(T1) throw(T1)
+#define TESTCASE_THROW3(T1, T2, T3) throw(T1, T2, T3)
+%{
+#define TESTCASE_THROW1(T1)
+#define TESTCASE_THROW3(T1, T2, T3)
+%}
+
%{
struct A {};
%}
@@ -11,10 +19,6 @@ struct A {};
%inline %{
#include <string>
-#if defined(_MSC_VER)
- #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
-
class Exc {
public:
Exc(int c, const char *m) {
@@ -28,24 +32,24 @@ public:
class Test {
public:
- int simple() throw(int) {
+ int simple() TESTCASE_THROW1(int) {
throw(37);
return 1;
}
- int message() throw(const char *) {
+ int message() TESTCASE_THROW1(const char *) {
throw("I died.");
return 1;
}
- int hosed() throw(Exc) {
+ int hosed() TESTCASE_THROW1(Exc) {
throw(Exc(42,"Hosed"));
return 1;
}
- int unknown() throw(A*) {
+ int unknown() TESTCASE_THROW1(A*) {
static A a;
throw &a;
return 1;
}
- int multi(int x) throw(int, const char *, Exc) {
+ int multi(int x) TESTCASE_THROW3(int, const char *, Exc) {
if (x == 1) throw(37);
if (x == 2) throw("Bleah!");
if (x == 3) throw(Exc(42,"No-go-diggy-die"));
diff --git a/Examples/test-suite/throw_exception.i b/Examples/test-suite/throw_exception.i
index 396c633a6..ed9288290 100644
--- a/Examples/test-suite/throw_exception.i
+++ b/Examples/test-suite/throw_exception.i
@@ -1,9 +1,11 @@
%module throw_exception
+// throw is invalid in C++17 and later, only SWIG to use it
+#define TESTCASE_THROW1(T1) throw(T1)
+#define TESTCASE_THROW3(T1, T2, T3) throw(T1, T2, T3)
%{
-#if defined(_MSC_VER)
- #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
+#define TESTCASE_THROW1(T1)
+#define TESTCASE_THROW3(T1, T2, T3)
%}
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Namespace::enum1;
@@ -30,45 +32,45 @@ namespace Namespace {
}
class Foo {
public:
- void test_int() throw(int) {
+ void test_int() TESTCASE_THROW1(int) {
throw 37;
}
- void test_msg() throw(const char *) {
+ void test_msg() TESTCASE_THROW1(const char *) {
throw "Dead";
}
- void test_cls() throw(CError) {
+ void test_cls() TESTCASE_THROW1(CError) {
throw CError();
}
- void test_cls_ptr() throw(CError *) {
+ void test_cls_ptr() TESTCASE_THROW1(CError *) {
static CError StaticError;
throw &StaticError;
}
- void test_cls_ref() throw(CError &) {
+ void test_cls_ref() TESTCASE_THROW1(CError &) {
static CError StaticError;
throw StaticError;
}
- void test_cls_td() throw(Namespace::ErrorTypedef) {
+ void test_cls_td() TESTCASE_THROW1(Namespace::ErrorTypedef) {
throw CError();
}
- void test_cls_ptr_td() throw(Namespace::ErrorPtr) {
+ void test_cls_ptr_td() TESTCASE_THROW1(Namespace::ErrorPtr) {
static CError StaticError;
throw &StaticError;
}
- void test_cls_ref_td() throw(Namespace::ErrorRef) {
+ void test_cls_ref_td() TESTCASE_THROW1(Namespace::ErrorRef) {
static CError StaticError;
throw StaticError;
}
- void test_array() throw(Namespace::IntArray) {
+ void test_array() TESTCASE_THROW1(Namespace::IntArray) {
static Namespace::IntArray array;
for (int i=0; i<10; i++) {
array[i] = i;
}
throw array;
}
- void test_enum() throw(Namespace::EnumTest) {
+ void test_enum() TESTCASE_THROW1(Namespace::EnumTest) {
throw Namespace::enum2;
}
- void test_multi(int x) throw(int, const char *, CError) {
+ void test_multi(int x) TESTCASE_THROW3(int, const char *, CError) {
if (x == 1) throw 37;
if (x == 2) throw "Dead";
if (x == 3) throw CError();
diff --git a/Examples/test-suite/typedef_classforward_same_name.i b/Examples/test-suite/typedef_classforward_same_name.i
new file mode 100644
index 000000000..ad2e456f8
--- /dev/null
+++ b/Examples/test-suite/typedef_classforward_same_name.i
@@ -0,0 +1,15 @@
+%module typedef_classforward_same_name
+
+%inline %{
+typedef struct Foo Foo;
+struct Foo {
+ int x;
+};
+int extractFoo(Foo* foo) { return foo->x; }
+
+struct Boo {
+ int x;
+};
+typedef struct Boo Boo;
+int extractBoo(Boo* boo) { return boo->x; }
+%}
diff --git a/Examples/test-suite/typedef_funcptr.i b/Examples/test-suite/typedef_funcptr.i
index f8cdd14b3..45ea99ef2 100644
--- a/Examples/test-suite/typedef_funcptr.i
+++ b/Examples/test-suite/typedef_funcptr.i
@@ -21,6 +21,16 @@ extern "C"
Integer do_op(Integer x, Integer y, Integer (*op)(Integer, Integer)) {
return (*op)(x,y);
}
+
+typedef int (*FnPtr_int_td)(int, int);
+int do_op_typedef_int(int x, int y, FnPtr_int_td op) {
+ return (*op)(x,y);
+}
+
+typedef Integer (*FnPtr_Integer_td)(Integer, Integer);
+Integer do_op_typedef_Integer(Integer x, Integer y, FnPtr_Integer_td op) {
+ return (*op)(x,y);
+}
%}
%constant int addf(int x, int y);
diff --git a/Examples/test-suite/typemap_delete.i b/Examples/test-suite/typemap_delete.i
index eb6abe73c..fa62803cb 100644
--- a/Examples/test-suite/typemap_delete.i
+++ b/Examples/test-suite/typemap_delete.i
@@ -1,5 +1,9 @@
%module typemap_delete
+#ifdef SWIGOCAML
+%warnfilter(SWIGWARN_PARSE_KEYWORD) val;
+#endif
+
%typemap(in) Rect* (Rect temp) {
$1 = 0;
will_not_compile
diff --git a/Examples/test-suite/typemap_template.i b/Examples/test-suite/typemap_template.i
index 7ef77c79d..9f283105b 100644
--- a/Examples/test-suite/typemap_template.i
+++ b/Examples/test-suite/typemap_template.i
@@ -27,7 +27,7 @@ template<typename T> struct TemplateTest1 {
%template(TTint) TemplateTest1< int >;
%inline %{
- void extratest(const TemplateTest1< YY > &t,
+ void extratest(const TemplateTest1< YY > &t,
const TemplateTest1< ZZ > &tt,
const TemplateTest1< int > &ttt)
{}
@@ -38,3 +38,27 @@ template<typename T> struct TemplateTest1 {
%inline %{
void wasbug(TemplateTest1< int >::Double wbug) {}
%}
+
+/* Test bug where the %apply directive was ignored inside anonymous template
+ * instantiations */
+
+template<class T>
+struct Foo {
+ %typemap(in) Foo<T> ""
+ %apply Foo<T> { const Foo<T> & }
+};
+
+%{
+template<class T> struct Foo {};
+%}
+
+%template(Foo_int) Foo<int>;
+%template() Foo<double>;
+
+%inline %{
+ void this_works(Foo<int> f) {}
+ void this_also_works(const Foo<int>& f) {}
+ void this_also_also_works(Foo<double> f) {}
+ void this_used_to_fail(const Foo<double>& f) {}
+%}
+
diff --git a/Examples/test-suite/typemap_template_parms.i b/Examples/test-suite/typemap_template_parms.i
new file mode 100644
index 000000000..90231e827
--- /dev/null
+++ b/Examples/test-suite/typemap_template_parms.i
@@ -0,0 +1,41 @@
+%module typemap_template_parms
+
+%typemap(ret) int "_this_will_not_compile_int_$symname"
+
+%extend X {
+%typemap(ret) T lake "/* ret lake X<T> */"
+%typemap(ret) T X<T>::rake "/* ret rake X<T> */"
+
+// Overrides below: %typemap(ret) T take
+%typemap(ret) T X<T>::take "/* ret take X<T> */"
+}
+
+%inline %{
+template<typename T> struct X {
+#if defined(SWIG)
+%typemap(ret) T bake "/* ret bake X<T> */"
+%typemap(ret) T X<T>::make "/* ret make X<T> */"
+%typemap(ret) T take "_rake_T_this_will_not_compile_"
+#endif
+ T bake() { return T(); }
+ T make() { return T(); }
+ T lake() { return T(); }
+ T rake() { return T(); }
+ T take() { return T(); }
+};
+%}
+
+%template(Xint) X<int>;
+
+
+// The function name and parameter name are both 'labels'
+%inline %{
+template <typename T>
+void labels(T labels) {}
+void voido(int vooo) {}
+%}
+
+// TODO: R has a problem with parameter names clashing with the function name
+#if !defined(SWIGR)
+%template(ShortLabels) labels<short>;
+#endif
diff --git a/Examples/test-suite/typemap_template_typedef.i b/Examples/test-suite/typemap_template_typedef.i
new file mode 100644
index 000000000..6605ec711
--- /dev/null
+++ b/Examples/test-suite/typemap_template_typedef.i
@@ -0,0 +1,66 @@
+%module typemap_template_typedef
+//%module("templatereduce") typemap_template_typedef
+
+%typemap(in) int TMAP55 %{ $1 = 55; /* int TMAP55 typemap */ %}
+%typemap(in) int TMAP66 %{ $1 = 66; /* int TMAP66 typemap */ %}
+%typemap(in) int TMAP77 %{ $1 = 77; /* int TMAP77 typemap */ %}
+%typemap(in) int TMAP88 %{ $1 = 88; /* int TMAP88 typemap */ %}
+
+%apply int TMAP77 { XXX<int>::Long cc }
+
+%inline %{
+typedef int MyInteger;
+
+template<typename T> struct XXX {
+#ifdef SWIG
+// In swig-3.0.12 'Long aa' was actually stored as 'long aa' in typemap table instead of 'XXX<int>::Long aa'
+%apply int TMAP55 { Long aa }
+%apply int TMAP66 { XXX<int>::Long bb }
+%apply int TMAP88 { XXX<MyInteger>::Long dd }
+#endif
+ typedef long Long;
+ long aa1(long aa) { return aa; }
+ long aa2(Long aa) { return aa; }
+ long bb1(long bb) { return bb; }
+ long bb2(Long bb) { return bb; }
+ long cc1(long cc) { return cc; }
+ long cc2(Long cc) { return cc; }
+ long dd1(long dd) { return dd; }
+ long dd2(Long dd) { return dd; }
+#ifdef SWIG
+%clear Long aa;
+%clear XXX<int>::Long bb;
+%clear XXX<MyInteger>::Long dd;
+#endif
+ long aa3(Long aa) { return aa; }
+ long bb3(Long bb) { return bb; }
+ long cc3(Long cc) { return cc; }
+ long dd3(Long dd) { return dd; }
+};
+%}
+
+%template(XXXInt) XXX<MyInteger>;
+
+%clear XXX<int>::Long cc;
+
+%inline %{
+ long aa1(XXX<int>::Long aa) { return aa; }
+ long aa2(long aa) { return aa; }
+ long bb1(XXX<int>::Long bb) { return bb; }
+ long bb2(long bb) { return bb; }
+ long cc1(XXX<int>::Long cc) { return cc; }
+ long cc2(long cc) { return cc; }
+ long dd1(XXX<MyInteger>::Long dd) { return dd; }
+ long dd2(long dd) { return dd; }
+%}
+
+%inline %{
+typedef MyInteger MY_INTEGER;
+template<typename T1, typename T2 = MY_INTEGER> struct YYY {
+ void meff(T1 t1, T2 t2) {}
+};
+%}
+%template(YYYIntInt) YYY<MY_INTEGER>;
+%inline %{
+ void whyohwhy(YYY<MY_INTEGER> yy) {}
+%}
diff --git a/Examples/test-suite/unicode_strings.i b/Examples/test-suite/unicode_strings.i
index 9be3748e6..e7266266e 100644
--- a/Examples/test-suite/unicode_strings.i
+++ b/Examples/test-suite/unicode_strings.i
@@ -20,4 +20,6 @@ char *charstring(char *s) {
return s;
}
+void instring(const char *s) {
+}
%}
diff --git a/Examples/test-suite/using_pointers.i b/Examples/test-suite/using_pointers.i
index b2d6abe4d..1a3824afa 100644
--- a/Examples/test-suite/using_pointers.i
+++ b/Examples/test-suite/using_pointers.i
@@ -4,10 +4,10 @@
%csmethodmodifiers x "public new"
#endif
+// throw is invalid in C++17 and later, only SWIG to use it
+#define TESTCASE_THROW2(T1, T2) throw(T1, T2)
%{
-#if defined(_MSC_VER)
- #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
+#define TESTCASE_THROW2(T1, T2)
%}
%inline %{
@@ -16,7 +16,7 @@
int x;
virtual ~Foo() { }
virtual Foo* blah() { return this; }
- virtual Foo* exception_spec(int what_to_throw) throw (int, const char *) {
+ virtual Foo* exception_spec(int what_to_throw) TESTCASE_THROW2(int, const char *) {
int num = 10;
const char *str = "exception message";
if (what_to_throw == 1) throw num;
diff --git a/Examples/test-suite/valuewrapper_opaque.i b/Examples/test-suite/valuewrapper_opaque.i
index 52da89391..bc7ba8683 100644
--- a/Examples/test-suite/valuewrapper_opaque.i
+++ b/Examples/test-suite/valuewrapper_opaque.i
@@ -4,6 +4,10 @@
* Opaque types
*/
+#ifdef SWIGOCAML
+%warnfilter(SWIGWARN_PARSE_KEYWORD) method;
+#endif
+
%feature("valuewrapper") C;
class C;
diff --git a/Examples/test-suite/varargs_overload.i b/Examples/test-suite/varargs_overload.i
index 9a24e15a8..eb9dcaab9 100644
--- a/Examples/test-suite/varargs_overload.i
+++ b/Examples/test-suite/varargs_overload.i
@@ -44,3 +44,47 @@ const char *vararg_over4(int i) {
return buffer;
}
%}
+
+
+// Same as above but non-vararg function declared first
+
+%inline %{
+const char *vararg_over6(int i) {
+ static char buffer[256];
+ sprintf(buffer, "%d", i);
+ return buffer;
+}
+const char *vararg_over6(const char *fmt, ...) {
+ return fmt;
+}
+
+const char *vararg_over7(int i, double j) {
+ static char buffer[256];
+ sprintf(buffer, "%d %g", i, j);
+ return buffer;
+}
+const char *vararg_over7(const char *fmt, ...) {
+ return fmt;
+}
+
+const char *vararg_over8(int i, double j, const char *s) {
+ static char buffer[256];
+ sprintf(buffer, "%d %g %s", i, j, s);
+ return buffer;
+}
+const char *vararg_over8(const char *fmt, ...) {
+ return fmt;
+}
+%}
+
+%varargs(int mode = 0) vararg_over9;
+%inline %{
+const char *vararg_over9(int i) {
+ static char buffer[256];
+ sprintf(buffer, "%d", i);
+ return buffer;
+}
+const char *vararg_over9(const char *fmt, ...) {
+ return fmt;
+}
+%}
diff --git a/Examples/test-suite/virtual_derivation.i b/Examples/test-suite/virtual_derivation.i
index a199646d4..59b7fcea1 100644
--- a/Examples/test-suite/virtual_derivation.i
+++ b/Examples/test-suite/virtual_derivation.i
@@ -58,6 +58,7 @@
class IndexReader{
public:
virtual void norms() = 0;
+ virtual ~IndexReader() {}
};
class MultiReader : public IndexReader {
diff --git a/Examples/test-suite/virtual_poly.i b/Examples/test-suite/virtual_poly.i
index 5f2f1d201..8b500539e 100644
--- a/Examples/test-suite/virtual_poly.i
+++ b/Examples/test-suite/virtual_poly.i
@@ -13,6 +13,10 @@
#endif
%}
+#ifdef SWIGOCAML
+%warnfilter(SWIGWARN_PARSE_KEYWORD) method;
+#endif
+
//
// Check this example with directors wherever possible.
//