diff --git a/.gitignore b/.gitignore
index a1b9d5e94..400ce4469 100644
--- a/.gitignore
+++ b/.gitignore
@@ -67,6 +67,7 @@ CCache/config.h
CCache/config.log
CCache/config.status
Examples/Makefile
+Examples/d/example.mk
Examples/guile/Makefile
Examples/test-suite/*/Makefile
Examples/xml/Makefile
@@ -121,16 +122,29 @@ Examples/test-suite/pike/*/
Examples/test-suite/python/*/
Examples/test-suite/r/*/
Examples/test-suite/ruby/*/
+Examples/test-suite/scilab/*/
Examples/test-suite/tcl/*/
Examples/test-suite/uffi/*/
*_wrap.c
*_wrap.cxx
*-gypcopy.cxx
+# Scratch directories
+Examples/scratch
+
+# Out of source tree build directories
+*build*/
+
+########## Language specific files ##########
+
# C# generated files
*_runme.exe.mdb
*_runme.exe
+# Go generated files
+*.[5689]
+*_gc.c
+
# Javascript generated files
*.gyp
@@ -144,12 +158,6 @@ Examples/test-suite/octave/*.oct
*/__pycache__/
/__pycache__/
-# Go generated files
-*.[5689]
-*_gc.c
+# Scilab generated files
+loader.sce
-# Scratch directories
-Examples/scratch
-
-# Out of source tree build directories
-*build*/
diff --git a/.travis.yml b/.travis.yml
index 65008f623..8d814e7f8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -50,12 +50,21 @@ matrix:
env: SWIGLANG=python SWIG_FEATURES=-builtin
- compiler: gcc
env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3
+ - compiler: gcc
+ env: SWIGLANG=python SWIG_FEATURES=-classic
- compiler: gcc
env: SWIGLANG=ruby
+ - compiler: gcc
+ env: SWIGLANG=scilab
- compiler: gcc
env: SWIGLANG=tcl
allow_failures:
- # None
+ # Occasional gcc internal compiler error
+ - compiler: gcc
+ env: SWIGLANG=octave SWIGJOBS=-j3 VER=3.8
+ # Not quite working yet
+ - compiler: gcc
+ env: SWIGLANG=python SWIG_FEATURES=-classic
before_install:
- date -u
- uname -a
@@ -77,40 +86,13 @@ before_install:
- if test "$SWIGLANG" = "python"; then git clone https://github.com/jcrocholl/pep8.git && pushd pep8 && git checkout tags/1.5.7 && python ./setup.py build && sudo python ./setup.py install && popd; fi
- if test "$SWIGLANG" = "python" -a "$PY3" -a -z "$VER"; then sudo apt-get install -qq python3-dev; fi
- if test "$SWIGLANG" = "python" -a "$VER"; then sudo add-apt-repository -y ppa:fkrull/deadsnakes && sudo apt-get -qq update && sudo apt-get -qq install python${VER}-dev && export CONFIGOPTS="--with-python${PY3}=python${VER}"; fi
+ - if test "$SWIGLANG" = "scilab"; then sudo apt-get -qq install scilab; fi
- if test "$SWIGLANG" = "tcl"; then sudo apt-get -qq install tcl8.4-dev; fi
- # Stricter compile flags for examples. Various headers and SWIG generated code prevents full use of -pedantic.
- - declare -A CFLAGS_EXAMPLES && CFLAGS_EXAMPLES=(
- ["csharp"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
- ["d"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
- ["go"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
- ["guile"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
- ["java"]="-Werror -std=gnu89 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
- ["javascript"]="-Werror -std=gnu89 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
- ["lua"]="-Werror -std=gnu89 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
- ["octave"]="-Werror -std=gnu89 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
- ["perl5"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
- ["php"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
- ["python"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
- ["ruby"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
- ["tcl"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
- )
- - declare -A CXXFLAGS_EXAMPLES && CXXFLAGS_EXAMPLES=(
- ["csharp"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
- ["d"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
- ["go"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
- ["guile"]="-Werror -std=c++98 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
- ["java"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
- ["javascript"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
- ["lua"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
- ["octave"]="-Werror -std=c++98 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
- ["perl5"]="-Werror -std=c++98 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
- ["php"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
- ["python"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
- ["ruby"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
- ["tcl"]="-Werror -std=c++98 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
- )
- $CC --version
- $CXX --version
+ # Stricter compile flags for examples. Various headers and SWIG generated code prevents full use of -pedantic.
+ - export cflags=$(./testflags.py --language $SWIGLANG --cflags) && echo $cflags
+ - export cxxflags=$(./testflags.py --language $SWIGLANG --cxxflags) && echo $cxxflags
script:
- echo 'Configuring...' && echo -en 'travis_fold:start:script.1\\r'
- ./autogen.sh && mkdir -p build/build && cd build/build && ../../configure $CONFIGOPTS
@@ -123,11 +105,12 @@ script:
- if test -z "$SWIGLANG"; then sudo make -s install && swig -version && ccache-swig -V; fi
- echo -en 'travis_fold:end:script.2\\r'
- if test -n "$SWIGLANG"; then make -s check-$SWIGLANG-version; fi
- - if test -n "$SWIGLANG"; then make -k $SWIGJOBS check-$SWIGLANG-examples CFLAGS="${CFLAGS_EXAMPLES[$SWIGLANG]}" CXXFLAGS="${CXXFLAGS_EXAMPLES[$SWIGLANG]}"; fi
- - if test -n "$SWIGLANG"; then make -k $SWIGJOBS check-$SWIGLANG-test-suite; fi
+ - if test -n "$SWIGLANG"; then make $SWIGJOBS check-$SWIGLANG-examples CFLAGS="$cflags" CXXFLAGS="$cxxflags"; fi
+ - if test -n "$SWIGLANG"; then make $SWIGJOBS check-$SWIGLANG-test-suite CFLAGS="$cflags" CXXFLAGS="$cxxflags"; fi
- echo 'Cleaning...' && echo -en 'travis_fold:start:script.3\\r'
- make check-maintainer-clean && ../../configure $CONFIGOPTS
- echo -en 'travis_fold:end:script.3\\r'
branches:
only:
- master
+ - error-declaration-after-statement
diff --git a/ANNOUNCE b/ANNOUNCE
index 95261b2bd..96b1904ac 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,8 +1,8 @@
-*** ANNOUNCE: SWIG 3.0.3 (in progress) ***
+*** ANNOUNCE: SWIG 3.0.6 (in progress) ***
http://www.swig.org
-We're pleased to announce SWIG-3.0.3, the latest SWIG release.
+We're pleased to announce SWIG-3.0.6, the latest SWIG release.
What is SWIG?
=============
@@ -11,21 +11,22 @@ SWIG is a software development tool that reads C/C++ header files and
generates the wrapper code needed to make C and C++ code accessible
from other programming languages including Perl, Python, Tcl, Ruby,
PHP, C#, Go, Java, Javascript, Lua, Scheme (Guile, MzScheme, CHICKEN),
-D, Ocaml, Pike, Modula-3, Octave, R, Common Lisp (CLISP, Allegro CL,
-CFFI, UFFI). SWIG can also export its parse tree in the form of XML
-and Lisp s-expressions. Major applications of SWIG include generation
-of scripting language extension modules, rapid prototyping, testing,
-and user interface development for large C/C++ systems.
+D, Ocaml, Pike, Modula-3, Octave, R, Scilab, Common Lisp (CLISP,
+Allegro CL, CFFI, UFFI). SWIG can also export its parse tree in
+the form of XML and Lisp s-expressions. Major applications of SWIG
+include generation of scripting language extension modules, rapid
+prototyping, testing, and user interface development for large
+C/C++ systems.
Availability
============
The release is available for download on Sourceforge at
- http://prdownloads.sourceforge.net/swig/swig-3.0.3.tar.gz
+ http://prdownloads.sourceforge.net/swig/swig-3.0.6.tar.gz
A Windows version is also available at
- http://prdownloads.sourceforge.net/swig/swigwin-3.0.3.zip
+ http://prdownloads.sourceforge.net/swig/swigwin-3.0.6.zip
Please report problems with this release to the swig-devel mailing list,
details at http://www.swig.org/mail.html.
diff --git a/CHANGES b/CHANGES
index 33b2b5942..8bea8c1c2 100644
--- a/CHANGES
+++ b/CHANGES
@@ -3,6 +3,211 @@ SWIG (Simplified Wrapper and Interface Generator)
See the CHANGES.current file for changes in the current version.
See the RELEASENOTES file for a summary of changes in each release.
+Version 3.0.5 (31 Jan 2015)
+===========================
+
+2015-01-30: wsfulton
+ [Python] Fix Python -classic and property setting. Setting properties on classic classes
+ was broken in swig-3.0.3 by attempting to use __setattr__. This regression is fixed now
+ by using __dict__ again when using -classic.
+ Fixes patch #232.
+
+2015-01-27: smarchetto
+ [Scilab] Support for the Scilab language has been added
+
+2015-01-23: olly
+ [PHP] When wrapping a returned resource as an object, check if all
+ cases wrap it in the same class, and if so eliminate the pointless
+ switch statement wrapper we previously generated.
+
+2015-01-22: wsfulton
+ [Octave] Merge patch #297 for SF bug #1277 - Octave shared_ptr support
+
+2015-01-15: wsfulton
+ [Python] Merge patch #250 - Fixes for using %constant and objects (non-primitive types)
+
+2015-01-15: wsfulton
+ [C# Go] Merge patch #308 and fix #307 - C++11 strongly typed enum support
+ in directors
+
+2015-01-15: wsfulton
+ [Python] Second fix for #294 #296 - Regression introduced in SWIG-3.0.3 when
+ wrapping functions with default arguments, this time when using kwargs.
+
+Version 3.0.4 (14 Jan 2015)
+===========================
+
+2015-01-12: olly
+ [PHP] Fix segfault in director upcall check when using PHP built with
+ ZTS enabled. Fixes #155, reported by Pierre Labastie.
+
+2015-01-12: vadz
+ [Python] Fix #294 #296 - Regression introduced in SWIG-3.0.3 when
+ wrapping functions with default arguments. Invalid or missing default
+ arguments were sometimes being generated into the python layer.
+
+2015-01-08: olly
+ Allow C++11 "explicit constexpr". Fixes github issue #284 reported
+ by Pawel Tomulik. Also handle "constexpr explicit" and "constexpr
+ static".
+
+2015-01-08: olly
+ When reporting an error for a construct which hasn't been
+ terminated when the end of the file is reached, report it at the
+ start line rather than "EOF" as then tools like editors and IDEs
+ will take you to a generally more useful place for fixing the
+ problem.
+
+2015-01-08: olly
+ Improve error messages for a few cases which previously gave the
+ one of the cryptic catch-all errors "Syntax error in input".
+
+2015-01-08: olly
+ Provide -cppext as a general command line option for setting the
+ extension used for generated C++ files (previously it was specific
+ to the PHP backend). Deprecate the equivalent -suffix option
+ provided by the Ocaml backend, but continue to support that for
+ now.
+
+Version 3.0.3 (30 Dec 2014)
+===========================
+
+2014-12-27: wsfulton
+ Fix #280 - abort using all default template parameters within other template
+ parameters.
+
+2014-12-27: talby
+ [Perl] Issue #282 perl5 archlib vs archlibexp
+ [Perl] tidy "warning: duplicate 'extern' declaration specifier" when building generated code
+ under clang
+
+2014-12-18: wsfulton
+ Add support for %constant and structs/classes - issue #272
+
+2014-12-09: wsfulton
+ Fix #245 - regression (since swig-3.0.0) in templated constructors.
+ Templated constructors could not be instantiated - they were incorrectly ignored with a warning 504:
+ "Function: xyz must have a return type. Ignored."
+
+2014-12-07: wsfulton
+ Add support for C++11 strongly typed enumerations.
+
+2014-11-21: wsfulton
+ [Java C#] Fix multiply defined error when using %rename of enum items when using the "simple enum"
+ wrappers.
+
+2014-10-28: vadz
+ [Python] Patch #201 The generated .py file no longer uses *args for all Python parameters.
+ Instead, the parameters are named using the C++ parameter names.
+
+2014-10-24: timotheecour
+ [D] Patch #204 Use core.atomic.atomicOp to mutate shared variables
+
+2014-10-21: wsfulton
+ Fix issue #242 - Use of the "kwargs" feature no longer automatically turns on the
+ "compactdefaultargs" feature if the target language does not support kwargs.
+ Only Java and Python support kwargs, so this affects all the other languages.
+
+ *** POTENTIAL INCOMPATIBILITY ***
+
+2014-10-10: diorcety
+ [Python] Patch #232 Fix property access using directors
+
+2014-10-06: wsfulton
+ [Python] Fixes when using -builtin and std::vector/std::list wrappers to allow deletion
+ of single elements, such as 'del vec[0]'.
+
+2014-09-30: oliverb
+ [Javascript] Merge patch #216 by Richie765 - Added support for many versions of v8 javascript.
+
+2014-09-30: oliverb
+ [Javascript] Merge patch #195 by zittix - Fixed JSClassRef declaration not using the static one.
+
+2014-09-30: ianlancetaylor
+ [Go] In configure script, require Go 1.1 or later.
+
+2014-09-30: wsfulton
+ [Python] Patch #207 - Fix No module error with -relativeimport when using single
+ header file import.
+
+2014-09-27: wsfulton
+ Patch #208 - Initialise newly created array when using array_functions in the
+ carrays.i library (C++ usage).
+
+2014-09-27: wsfulton
+ [Ruby] Patch #187 - Fix crash on shutdown of the Ruby interpreter if more than one
+ module was loaded at a time when data is being shared between modules.
+
+2014-09-27: wsfulton
+ [Java] Patch #168 - Fix leak in Java director string handling after the Java
+ upcall when called from a native thread.
+
+2014-09-25: ianlancetaylor
+ [Go] Adjust generated code to work with upcoming Go 1.4
+ release.
+
+2014-09-23: wsfulton
+ [Python] Add patch from Thomas Maslach to fix crash in wrappers when using -threads in
+ the STL iterators (SwigPyIterator destructor).
+
+2014-09-17: wsfulton
+ [C#] Merge patch #229 from contre - Add bool array types to arrays_csharp.i
+
+2014-09-12: olly
+ [PHP] Add support for specifying any PHP interfaces a wrapped class
+ implements, e.g.: %typemap("phpinterfaces") MyIterator "Iterator";
+
+2014-09-11: olly
+ [PHP] Fix throwing a PHP exception through C++ from a subclassed
+ director method - PHP NULL gets returned by the subclassed method
+ in this case, so the directorout typemap needs to allow that (at
+ least if an exception is active).
+
+2014-09-09: ianlancetaylor
+ [Go] Add goargout typemap.
+
+2014-09-09: olly
+ [PHP] Fix segmentation faults with directors in PHP >= 5.4, and
+ reenable runme tests for director_basic testcase. Fix from
+ pavel-charvat in issue#164.
+
+2014-09-05: ianlancetaylor
+ [Go] Add imtype, goin, goout, godirectorin, and
+ godirectorout typemaps, to support writing Go code to
+ convert between types.
+
+2014-09-02: olly
+ [Python] Fix regression in indentation of python code produced with
+ -modern, introduced by changes in #188. Reported by fabiencastan
+ in #218.
+
+2014-09-01: olly
+ Issue an error for unknown SWIG preprocessor directives, rather
+ than quietly ignoring them. Reported by jrhelsey in issue#217.
+
+ *** POTENTIAL INCOMPATIBILITY ***
+
+2014-08-15: talby
+ [Perl] Include guard fix for nested modules from Anthony Heading (SF Patch #350).
+
+2014-08-04: wsfulton
+ [C#] Merge patch #200 from gpetrou - Changed CSharp license header to include auto-generated
+ tag so that StyleCop ignores the files.
+
+2014-08-04: wsfulton
+ [Java] Merge patch #198 from Yuval Kashtan - Support for java.nio.ByteBuffer mapping to
+ unsigned char * in various.i in NIOBUFFER typemaps.
+
+2014-07-14: ianlancetaylor
+ [Go] Change struct definition to use void *, not uint8, so
+ that the type is recorded as possibly containing
+ pointers. This ensures that the 1.3 garbage collector
+ does not collect pointers passed to C++ code.
+
+2014-07-01: wsfulton
+ Fix SF Bug #1375 - Expansion of the $parentclassname special variable incorrectly contains
+ brackets in the expanded name.
+
Version 3.0.2 (4 Jun 2014)
==========================
@@ -40,7 +245,7 @@ Version 3.0.1 (27 May 2014)
symbol comprising the outer structure name and unnamed variable instance name.
2014-05-15: kwwette
- Add #166 - 'make check' now works out of source. This required te examples to build
+ Add #166 - 'make check' now works out of source. This required the examples to build
out of source. The main languages have been tested - C#, Go, Guile, Java, Javascript,
Lua, Octave, Perl, PHP, Python, Ruby and Tcl.
@@ -4308,7 +4513,7 @@ Version 1.3.32 (November 15, 2007)
%attributeref(Class, AttributeType, AttributeName, AccessorMethod)
10/16/2007: olly
- [Tcl] Fix several ocurrences of "warning: deprecated conversion
+ [Tcl] Fix several occurrences of "warning: deprecated conversion
from string constant to 'char*'" from GCC 4.2 in generated C/C++
code.
diff --git a/CHANGES.current b/CHANGES.current
index 941e575a7..4679e8d63 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -2,126 +2,16 @@ Below are the changes for the current release.
See the CHANGES file for changes in older releases.
See the RELEASENOTES file for a summary of changes in each release.
-Version 3.0.3 (in progress)
+Version 3.0.6 (in progress)
===========================
-2014-12-09: wsfulton
- Fix #245 - regression (since swig-3.0.0) in templated constructors.
- Templated constructors could not be instantiated - they were incorrectly ignored with a warning 504:
- "Function: xyz must have a return type. Ignored."
+2015-02-09: wsfulton
+ [Guile] Fix generated code for static const char member variables when
+ defined and declared inline.
-2014-12-07: wsfulton
- Add support for C++11 strongly typed enumerations.
+2015-02-05: ianlancetaylor
+ [Go] Ignore Go specific type maps (goin, goout, etc.) if they are empty.
-2014-11-21: wsfulton
- [Java C#] Fix multiply defined error when using %rename of enum items when using the "simple enum" wrappers.
-
-2014-10-28: vadz
- [Python] Patch #201 The generated .py file no longer uses *args for all Python parameters.
- Instead, the parameters are named using the C++ parameter names.
-
-2014-10-24: timotheecour
- [D] Patch #204 Use core.atomic.atomicOp to mutate shared variables
-
-2014-10-21: wsfulton
- Fix issue #242 - Use of the "kwargs" feature no longer automatically turns on the
- "compactdefaultargs" feature if the target language does not support kwargs.
- Only Java and Python support kwargs, so this affects all the other languages.
-
- *** POTENTIAL INCOMPATIBILITY ***
-
-2014-10-10: diorcety
- [Python] Patch #232 Fix property access using directors
-
-2014-10-06: wsfulton
- [Python] Fixes when using -builtin and std::vector/std::list wrappers to allow deletion
- of single elements, such as 'del vec[0]'.
-
-2014-09-30: oliverb
- [Javascript] Merge patch #216 by Richie765 - Added support for many versions of v8 javascript.
-
-2014-09-30: oliverb
- [Javascript] Merge patch #195 by zittix - Fixed JSClassRef declaration not using the static one.
-
-2014-09-30: ianlancetaylor
- [Go] In configure script, require Go 1.1 or later.
-
-2014-09-30: wsfulton
- [Python] Patch #207 - Fix No module error with -relativeimport when using single
- header file import.
-
-2014-09-27: wsfulton
- Patch #208 - Initialise newly created array when using array_functions in the
- carrays.i library (C++ usage).
-
-2014-09-27: wsfulton
- [Ruby] Patch #187 - Fix crash on shutdown of the Ruby interpreter if more than one
- module was loaded at a time when data is being shared between modules.
-
-2014-09-27: wsfulton
- [Java] Patch #168 - Fix leak in Java director string handling after the Java
- upcall when called from a native thread.
-
-2014-09-25: ianlancetaylor
- [Go] Adjust generated code to work with upcoming Go 1.4
- release.
-
-2014-09-23: wsfulton
- [Python] Add patch from Thomas Maslach to fix crash in wrappers when using -threads in
- the STL iterators (SwigPyIterator destructor).
-
-2014-09-17: wsfulton
- [C#] Merge patch #229 from contre - Add bool array types to arrays_csharp.i
-
-2014-09-12: olly
- [PHP] Add support for specifying any PHP interfaces a wrapped class
- implements, e.g.: %typemap("phpinterfaces") MyIterator "Iterator";
-
-2014-09-11: olly
- [PHP] Fix throwing a PHP exception through C++ from a subclassed
- director method - PHP NULL gets returned by the subclassed method
- in this case, so the directorout typemap needs to allow that (at
- least if an exception is active).
-
-2014-09-09: ianlancetaylor
- [Go] Add goargout typemap.
-
-2014-09-09: olly
- [PHP] Fix segmentation faults with directors in PHP >= 5.4, and
- reenable runme tests for director_basic testcase. Fix from
- pavel-charvat in issue#164.
-
-2014-09-05: ianlancetaylor
- [Go] Add imtype, goin, goout, godirectorin, and
- godirectorout typemaps, to support writing Go code to
- convert between types.
-
-2014-09-02: olly
- [Python] Fix regression in indentation of python code produced with
- -modern, introduced by changes in #188. Reported by fabiencastan
- in #218.
-
-2014-09-01: olly
- Issue an error for unknown SWIG preprocessor directives, rather
- than quietly ignoring them. Reported by jrhelsey in issue#217.
-
-2014-08-15: talby
- [Perl] Include guard fix for nested modules from Anthony Heading (SF Patch #350).
-
-2014-08-04: wsfulton
- [C#] Merge patch #200 from gpetrou - Changed CSharp license header to include auto-generated
- tag so that StyleCop ignores the files.
-
-2014-08-04: wsfulton
- [Java] Merge patch #198 from Yuval Kashtan - Support for java.nio.ByteBuffer mapping to
- unsigned char * in various.i in NIOBUFFER typemaps.
-
-2014-07-14: ianlancetaylor
- [Go] Change struct definition to use void *, not uint8, so
- that the type is recorded as possibly containing
- pointers. This ensures that the 1.3 garbage collector
- does not collect pointers passed to C++ code.
-
-2014-07-01: wsfulton
- Fix SF Bug #1375 - Expansion of the $parentclassname special variable incorrectly contains
- brackets in the expanded name.
+2015-02-05: ianlancetaylor
+ [Go] Generated Go code no longer calls _swig_goallocate or
+ _swig_makegostring, as they will no longer work as of Go 1.5.
diff --git a/COPYRIGHT b/COPYRIGHT
index 6fbf6c0b0..baf15a5db 100644
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -11,58 +11,63 @@ Portions also copyrighted by:
Information-technology Promotion Agency, Japan
Active SWIG Developers:
- William Fulton (wsf@fultondesigns.co.uk) (SWIG core, Java, C#, Windows, Cygwin)
- Olly Betts (olly@survex.com) (PHP)
- Joseph Wang (joequant@gmail.com) (R)
- Xavier Delacour (xavier.delacour@gmail.com) (Octave)
- David Nadlinger (code@klickverbot.at) (D)
- Oliver Buchtala (oliver.buchtala@gmail.com) (Javascript)
- Neha Narang (narangneha03@gmail.com) (Javascript)
+ William Fulton (wsf@fultondesigns.co.uk) (SWIG core, Java, C#, Windows, Cygwin)
+ Olly Betts (olly@survex.com) (PHP)
+ Joseph Wang (joequant@gmail.com) (R)
+ Xavier Delacour (xavier.delacour@gmail.com) (Octave)
+ David Nadlinger (code@klickverbot.at) (D)
+ Oliver Buchtala (oliver.buchtala@gmail.com) (Javascript)
+ Neha Narang (narangneha03@gmail.com) (Javascript)
+ Simon Marchetto (simon.marchetto@scilab-enterprises.com) (Scilab)
Past SWIG developers and major contributors include:
- Dave Beazley (dave-swig@dabeaz.com) (SWIG core, Python, Tcl, Perl)
- Dmitry Kabak (userdima@gmail.com) (Doxygen)
- Henning Thielemann (swig@henning-thielemann.de) (Modula3)
- Matthias Köppe (mkoeppe@mail.math.uni-magdeburg.de) (Guile, MzScheme)
- Luigi Ballabio (luigi.ballabio@fastwebnet.it) (STL wrapping)
- Mikel Bancroft (mikel@franz.com) (Allegro CL)
- Surendra Singhi (efuzzyone@netscape.net) (CLISP, CFFI)
- Marcelo Matus (mmatus@acms.arizona.edu) (SWIG core, Python, UTL[python,perl,tcl,ruby])
- Art Yerkes (ayerkes@speakeasy.net) (Ocaml)
- Lyle Johnson (lyle@users.sourceforge.net) (Ruby)
- Charlie Savage (cfis@interserv.com) (Ruby)
- Thien-Thi Nguyen (ttn@glug.org) (build/test/misc)
- Richard Palmer (richard@magicality.org) (PHP)
- Sam Liddicott - Ananova Ltd (saml@liddicott.com) (PHP)
- Tim Hockin - Sun Microsystems (thockin@sun.com) (PHP)
- Kevin Ruland (PHP)
- Shibukawa Yoshiki (Japanese Translation)
- Jason Stewart (jason@openinformatics.com) (Perl5)
- Loic Dachary (Perl5)
- David Fletcher (Perl5)
- Gary Holt (Perl5)
- Masaki Fukushima (Ruby)
- Scott Michel (scottm@cs.ucla.edu) (Java directors)
- Tiger Feng (songyanf@cs.uchicago.edu) (SWIG core)
- Mark Rose (mrose@stm.lbl.gov) (Directors)
- Jonah Beckford (beckford@usermail.com) (CHICKEN)
- Ahmon Dancy (dancy@franz.com) (Allegro CL)
- Dirk Gerrits (Allegro CL)
- Neil Cawse (C#)
- Harco de Hilster (Java)
- Alexey Dyachenko (dyachenko@fromru.com) (Tcl)
- Bob Techentin (Tcl)
- Martin Froehlich (Guile)
- Marcio Luis Teixeira (Guile)
- Duncan Temple Lang (R)
- Miklos Vajna (PHP directors)
- Mark Gossage (mark@gossage.cjb.net) (Lua)
- Raman Gopalan (ramangopalan@gmail.com) (eLua)
- Gonzalo Garramuno (ggarra@advancedsl.com.ar) (Ruby, Ruby's UTL)
- John Lenz (Guile, MzScheme updates, Chicken module, runtime system)
- Ian Lance Taylor (Go)
- Vadim Zeitlin (PCRE)
- Stefan Zager (szager@gmail.com) (Python)
+ Dave Beazley (dave-swig@dabeaz.com) (SWIG core, Python, Tcl, Perl)
+ Henning Thielemann (swig@henning-thielemann.de) (Modula3)
+ Matthias Köppe (mkoeppe@mail.math.uni-magdeburg.de) (Guile, MzScheme)
+ Luigi Ballabio (luigi.ballabio@fastwebnet.it) (STL wrapping)
+ Mikel Bancroft (mikel@franz.com) (Allegro CL)
+ Surendra Singhi (efuzzyone@netscape.net) (CLISP, CFFI)
+ Marcelo Matus (mmatus@acms.arizona.edu) (SWIG core, Python, UTL[python,perl,tcl,ruby])
+ Art Yerkes (ayerkes@speakeasy.net) (Ocaml)
+ Lyle Johnson (lyle@users.sourceforge.net) (Ruby)
+ Charlie Savage (cfis@interserv.com) (Ruby)
+ Thien-Thi Nguyen (ttn@glug.org) (build/test/misc)
+ Richard Palmer (richard@magicality.org) (PHP)
+ Sam Liddicott - Ananova Ltd (saml@liddicott.com) (PHP)
+ Tim Hockin - Sun Microsystems (thockin@sun.com) (PHP)
+ Kevin Ruland (PHP)
+ Shibukawa Yoshiki (Japanese Translation)
+ Jason Stewart (jason@openinformatics.com) (Perl5)
+ Loic Dachary (Perl5)
+ David Fletcher (Perl5)
+ Gary Holt (Perl5)
+ Masaki Fukushima (Ruby)
+ Scott Michel (scottm@cs.ucla.edu) (Java directors)
+ Tiger Feng (songyanf@cs.uchicago.edu) (SWIG core)
+ Mark Rose (mrose@stm.lbl.gov) (Directors)
+ Jonah Beckford (beckford@usermail.com) (CHICKEN)
+ Ahmon Dancy (dancy@franz.com) (Allegro CL)
+ Dirk Gerrits (Allegro CL)
+ Neil Cawse (C#)
+ Harco de Hilster (Java)
+ Alexey Dyachenko (dyachenko@fromru.com) (Tcl)
+ Bob Techentin (Tcl)
+ Martin Froehlich (Guile)
+ Marcio Luis Teixeira (Guile)
+ Duncan Temple Lang (R)
+ Miklos Vajna (PHP directors)
+ Mark Gossage (mark@gossage.cjb.net) (Lua)
+ Raman Gopalan (ramangopalan@gmail.com) (eLua)
+ Gonzalo Garramuno (ggarra@advancedsl.com.ar) (Ruby, Ruby's UTL)
+ John Lenz (Guile, MzScheme updates, Chicken module, runtime system)
+ Baozeng Ding (Scilab)
+ Ian Lance Taylor (Go)
+ Dmitry Kabak (userdima@gmail.com) (Doxygen)
+ Vadim Zeitlin (PCRE, Python, Doxygen)
+ Stefan Zager (szager@gmail.com) (Python)
+ Vincent Couvert (Scilab)
+ Sylvestre Ledru (Scilab)
+ Wolfgang Frisch (Scilab)
Past contributors include:
James Michael DuPont, Clark McGrew, Dustin Mitchell, Ian Cooke, Catalin Dumitrescu, Baran
diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html
index 60d05f981..ae00a6617 100644
--- a/Doc/Manual/Contents.html
+++ b/Doc/Manual/Contents.html
@@ -841,6 +841,7 @@
@@ -91,7 +91,7 @@ Also, this chapter is not meant to be a hand-holding tutorial. As a starting po
you should probably look at one of SWIG's existing modules.
-
40.2 Prerequisites
+
41.2 Prerequisites
@@ -121,7 +121,7 @@ obvious, but almost all SWIG directives as well as the low-level generation of
wrapper code are driven by C++ datatypes.
-
40.3 The Big Picture
+
41.3 The Big Picture
@@ -158,7 +158,7 @@ role in making the system work. For example, both typemaps and declaration anno
based on pattern matching and interact heavily with the underlying type system.
-
40.4 Execution Model
+
41.4 Execution Model
@@ -203,7 +203,7 @@ latter stage of compilation.
The next few sections briefly describe some of these stages.
-
40.4.1 Preprocessing
+
41.4.1 Preprocessing
@@ -284,7 +284,7 @@ been expanded as well as everything else that goes into the low-level
construction of the wrapper code.
-
40.4.2 Parsing
+
41.4.2 Parsing
@@ -385,7 +385,7 @@ returning a foo and taking types a and b as
arguments).
@@ -659,7 +659,7 @@ that matches the name of the target language. For example, python:fooperl:foo.
-
40.4.5 Symbol Tables
+
41.4.5 Symbol Tables
@@ -750,7 +750,7 @@ example.i:5. Previous declaration is foo_i(int )
-
40.4.6 The %feature directive
+
41.4.6 The %feature directive
@@ -806,7 +806,7 @@ For example, the exception code above is simply
stored without any modifications.
-
40.4.7 Code Generation
+
41.4.7 Code Generation
@@ -928,7 +928,7 @@ public :
The role of these functions is described shortly.
-
40.4.8 SWIG and XML
+
41.4.8 SWIG and XML
@@ -941,7 +941,7 @@ internal data structures, it may be useful to keep XML in the back of
your mind as a model.
-
40.5 Primitive Data Structures
+
41.5 Primitive Data Structures
@@ -987,7 +987,7 @@ typedef Hash Typetab;
-
40.5.1 Strings
+
41.5.1 Strings
@@ -1128,7 +1128,7 @@ Returns the number of replacements made (if any).
-
40.5.2 Hashes
+
41.5.2 Hashes
@@ -1205,7 +1205,7 @@ Returns the list of hash table keys.
-
40.5.3 Lists
+
41.5.3 Lists
@@ -1294,7 +1294,7 @@ If t is not a standard object, it is assumed to be a char *
and is used to create a String object.
-
40.5.4 Common operations
+
41.5.4 Common operations
The following operations are applicable to all datatypes.
@@ -1349,7 +1349,7 @@ objects and report errors.
Gets the line number associated with x.
-
40.5.5 Iterating over Lists and Hashes
+
41.5.5 Iterating over Lists and Hashes
To iterate over the elements of a list or a hash table, the following functions are used:
@@ -1394,7 +1394,7 @@ for (j = First(j); j.item; j= Next(j)) {
-
40.5.6 I/O
+
41.5.6 I/O
Special I/O functions are used for all internal I/O. These operations
@@ -1528,7 +1528,7 @@ Printf(f, "%s\n", s);
Similarly, the preprocessor and parser all operate on string-files.
-
40.6 Navigating and manipulating parse trees
+
41.6 Navigating and manipulating parse trees
Parse trees are built as collections of hash tables. Each node is a hash table in which
@@ -1662,7 +1662,7 @@ Deletes a node from the parse tree. Deletion reconnects siblings and properly u
the parent so that sibling nodes are unaffected.
-
40.7 Working with attributes
+
41.7 Working with attributes
@@ -1779,7 +1779,7 @@ the attribute is optional. Swig_restore() must always be called after
function.
-
40.8 Type system
+
41.8 Type system
@@ -1788,7 +1788,7 @@ pointers, references, and pointers to members. A detailed discussion of
type theory is impossible here. However, let's cover the highlights.
-
40.8.1 String encoding of types
+
41.8.1 String encoding of types
@@ -1889,7 +1889,7 @@ make the final type, the two parts are just joined together using
string concatenation.
-
40.8.2 Type construction
+
41.8.2 Type construction
@@ -2058,7 +2058,7 @@ Returns the prefix of a type. For example, if ty is
ty is unmodified.
-
40.8.3 Type tests
+
41.8.3 Type tests
@@ -2145,7 +2145,7 @@ Checks if ty is a varargs type.
Checks if ty is a templatized type.
-
40.8.4 Typedef and inheritance
+
41.8.4 Typedef and inheritance
@@ -2247,7 +2247,7 @@ Fully reduces ty according to typedef rules. Resulting datatype
will consist only of primitive typenames.
-
@@ -2346,7 +2346,7 @@ SWIG, but is most commonly associated with type-descriptor objects
that appear in wrappers (e.g., SWIGTYPE_p_double).
-
40.9 Parameters
+
41.9 Parameters
@@ -2445,7 +2445,7 @@ included. Used to emit prototypes.
Returns the number of required (non-optional) arguments in p.
-
40.10 Writing a Language Module
+
41.10 Writing a Language Module
@@ -2460,7 +2460,7 @@ describes the creation of a minimal Python module. You should be able to extra
this to other languages.
-
40.10.1 Execution model
+
41.10.1 Execution model
@@ -2470,7 +2470,7 @@ the parsing of command line options, all aspects of code generation are controll
different methods of the Language that must be defined by your module.
-
40.10.2 Starting out
+
41.10.2 Starting out
@@ -2578,7 +2578,7 @@ that activates your module. For example, swig -python foo.i. The
messages from your new module should appear.
-
40.10.3 Command line options
+
41.10.3 Command line options
@@ -2637,7 +2637,7 @@ to mark the option as valid. If you forget to do this, SWIG will terminate wit
unrecognized command line option error.
-
40.10.4 Configuration and preprocessing
+
41.10.4 Configuration and preprocessing
@@ -2686,7 +2686,7 @@ an implementation file python.cxx and a configuration file
python.swg.
-
40.10.5 Entry point to code generation
+
41.10.5 Entry point to code generation
@@ -2744,7 +2744,7 @@ int Python::top(Node *n) {
-
@@ -3046,7 +3046,7 @@ but without the typemaps, there is still work to do.
-
40.10.8 Configuration files
+
41.10.8 Configuration files
@@ -3190,7 +3190,7 @@ politely displays the ignoring language message.
-
40.10.9 Runtime support
+
41.10.9 Runtime support
@@ -3199,7 +3199,7 @@ Discuss the kinds of functions typically needed for SWIG runtime support (e.g.
the SWIG files that implement those functions.
-
40.10.10 Standard library files
+
41.10.10 Standard library files
@@ -3218,7 +3218,7 @@ The following are the minimum that are usually supported:
Please copy these and modify for any new language.
-
40.10.11 User examples
+
41.10.11 User examples
@@ -3247,7 +3247,7 @@ during this process, see the section on .
-
40.10.12 Test driven development and the test-suite
+
41.10.12 Test driven development and the test-suite
@@ -3306,7 +3306,7 @@ It is therefore essential that the runtime tests are written in a manner that di
but error/exception out with an error message on stderr on failure.
-
40.10.12.1 Running the test-suite
+
41.10.12.1 Running the test-suite
@@ -3498,7 +3498,7 @@ It can be run in the same way as the other language test-suites, replacing [lang
The test cases used and the way it works is described in Examples/test-suite/errors/Makefile.in.
-
40.10.13 Documentation
+
41.10.13 Documentation
@@ -3530,7 +3530,7 @@ Some topics that you'll want to be sure to address include:
if available.
-
40.10.14 Prerequisites for adding a new language module to the SWIG distribution
+
41.10.14 Prerequisites for adding a new language module to the SWIG distribution
@@ -3587,7 +3587,7 @@ should be added should there be an area not already covered by
the existing tests.
-
40.10.15 Coding style guidelines
+
41.10.15 Coding style guidelines
@@ -3611,7 +3611,7 @@ The generated C/C++ code should also follow this style as close as possible. How
should be avoided as unlike the SWIG developers, users will never have consistent tab settings.
-
40.11 Debugging Options
+
41.11 Debugging Options
@@ -3638,7 +3638,7 @@ There are various command line options which can aid debugging a SWIG interface
The complete list of command line options for SWIG are available by running swig -help.
Additional Commandline Options
@@ -69,7 +70,22 @@ checking and runtime library are not used with Go. This should be
borne in mind when reading the rest of the SWIG documentation.
-
+The examples in the 2nd link are shipped with the SWIG distribution under the Examples/go directory.
+
+
+
+
23.3 Running SWIG with Go
@@ -78,7 +94,7 @@ default SWIG will generate code for the gc compilers. To generate
code for gccgo, you should also use the -gccgo option.
-
23.2.1 Additional Commandline Options
+
23.3.1 Additional Commandline Options
@@ -152,7 +168,7 @@ swig -go -help
-
23.2.2 Go Output Files
+
23.3.2 Go Output Files
When generating Go code, SWIG will generate the following
@@ -228,7 +244,7 @@ this:
% go tool 6l main.6
-
23.3 A tour of basic C/C++ wrapping
+
23.4 A tour of basic C/C++ wrapping
@@ -238,7 +254,7 @@ modifications have to occur. This section briefly covers the
essential aspects of this wrapping.
-
23.3.1 Go Package Name
+
23.4.1 Go Package Name
@@ -248,7 +264,7 @@ directive. You may override this by using SWIG's -package
command line option.
-
23.3.2 Go Names
+
23.4.2 Go Names
@@ -280,7 +296,7 @@ followed by that name, and the destructor will be
named Delete followed by that name.
-
23.3.3 Go Constants
+
23.4.3 Go Constants
@@ -288,7 +304,7 @@ C/C++ constants created via #define or the %constant
directive become Go constants, declared with a const
declaration.
-
23.3.4 Go Enumerations
+
23.4.4 Go Enumerations
@@ -298,7 +314,7 @@ usual). The values of the enumeration will become variables in Go;
code should avoid modifying those variables.
-
23.3.5 Go Classes
+
23.4.5 Go Classes
@@ -376,21 +392,24 @@ returns a go interface. If the returned pointer can be null, you can check
for this by calling the Swigcptr() method.
-
23.3.5.1 Go Class Memory Management
+
23.4.5.1 Go Class Memory Management
Calling NewClassName for some C++ class ClassName
will allocate memory using the C++ memory allocator. This memory will
-not be automatically freed by Go's garbage collector. When you are
-done with the C++ object you must free it using DeleteClassName.
+not be automatically freed by Go's garbage collector as the object ownership is
+not tracked. When you are done with the C++ object you must free it manually
+using DeleteClassName.
A common technique is to store the C++ object into a Go object, and
-use the Go function runtime.SetFinalizer to free the C++
-object when the Go object is freed. For example, if the SWIG package
-is imported as "wrap":
+use the Go function runtime.SetFinalizer to free the C++ object when
+the Go object is freed. It is strongly recommended to read the
+runtime.SetFinalizer
+documentation before using this technique to understand its limitations.
+For example, if the SWIG package is imported as "wrap":
@@ -421,7 +440,7 @@ Doing the reverse will require an explicit type assertion, which will
be checked dynamically.
-
23.3.6 Go Templates
+
23.4.6 Go Templates
@@ -429,7 +448,7 @@ In order to use C++ templates in Go, you must tell SWIG to create
wrappers for a particular template instantation. To do this, use
the %template directive.
-
23.3.7 Go Director Classes
+
23.4.7 Go Director Classes
@@ -472,7 +491,7 @@ method defined in Go. The Go code may of course call other methods on
itself, and those methods may be defined either in Go or in C++.
-
23.3.8 Default Go primitive type mappings
+
23.4.8 Default Go primitive type mappings
@@ -579,7 +598,7 @@ that typemap, or add new values, to control how C/C++ types are mapped
into Go types.
-
23.3.9 Output arguments
+
23.4.9 Output arguments
Because of limitations in the way output arguments are processed in swig,
@@ -632,7 +651,7 @@ void f(char *output);
-
23.3.10 Adding additional go code
+
23.4.10 Adding additional go code
Often the APIs generated by swig are not very natural in go, especially if
@@ -727,7 +746,7 @@ func bar() {
-
23.3.11 Go typemaps
+
23.4.11 Go typemaps
@@ -776,7 +795,8 @@ gotype is best converted to C/C++ using Go code.
Go code to convert from gotype to imtype when calling a C/C++
function. SWIG will then internally convert imtype to a C/C++ type
-and pass it down. If this is not defined no conversion is done.
+and pass it down. If this is not defined, or is the empty string, no
+conversion is done.
@@ -803,7 +823,8 @@ to the desired type.
goout
Go code to convert a value returned from a C/C++ function from imtype
-to gotype. If this is not defined no conversion is done.
+to gotype. If this is not defined, or is the empty string, no
+conversion is done.
@@ -824,7 +845,7 @@ be done.
Go code to adjust an argument value when returning from a function.
This is called after the real C/C++ function has run. The value will
be in imtype. This is only useful for a pointer type of some sort.
-If this is not defined nothing will be done.
+If this is not defined, or is the empty string, nothing will be done.
@@ -842,7 +863,8 @@ to the desired type.
godirectorin
Go code to convert a value used to call a director method from imtype
-to gotype. If this is not defined no conversion is done.
+to gotype. If this is not defined, or is the empty string, no
+conversion is done.
@@ -850,7 +872,8 @@ to gotype. If this is not defined no conversion is done.
godirectorout
Go code to convert a value returned from a director method from gotype
-to imtype. If this is not defined no conversion is done.
+to imtype. If this is not defined, or is the empty string, no
+conversion is done.
diff --git a/Doc/Manual/Introduction.html b/Doc/Manual/Introduction.html
index 19d59a4df..9cc4277c9 100644
--- a/Doc/Manual/Introduction.html
+++ b/Doc/Manual/Introduction.html
@@ -334,8 +334,7 @@ major features include:
-Currently, the only major C++ feature not supported is nested classes--a limitation
-that should be removed in a future release, but has some workarounds for the moment.
+Most of C++11 is also supported. Details are in the C++11 section.
diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html
index 6f11b4aa1..623adb68a 100644
--- a/Doc/Manual/Php.html
+++ b/Doc/Manual/Php.html
@@ -142,6 +142,7 @@ least work for Linux though):
34.1.2 Using PHP Extensions
+
To test the extension from a PHP script, you first need to tell PHP to
load it. To do this, add a line like this to the [PHP] section of
@@ -773,6 +774,7 @@ Ko::threats();
34.2.6.5 Specifying Implemented Interfaces
+
PHP supports the concept of abstract interfaces which a class can implement.
Since SWIG 3.0.3, you can tell SWIG that a wrapped class (for example
diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html
index 745570ca4..e188fc0be 100644
--- a/Doc/Manual/Preprocessor.html
+++ b/Doc/Manual/Preprocessor.html
@@ -120,7 +120,7 @@ SWIG_JAVASCRIPT_JSC Defined when using Javascript for JavascriptCore
SWIG_JAVASCRIPT_V8 Defined when using Javascript for v8 or node.js
SWIGLUA Defined when using Lua
SWIGMODULA3 Defined when using Modula-3
-SWIGMZSCHEME Defined when using Mzscheme
+SWIGMZSCHEME Defined when using Mzscheme
SWIGOCAML Defined when using Ocaml
SWIGOCTAVE Defined when using Octave
SWIGPERL Defined when using Perl
@@ -129,6 +129,7 @@ SWIGPIKE Defined when using Pike
SWIGPYTHON Defined when using Python
SWIGR Defined when using R
SWIGRUBY Defined when using Ruby
+SWIGSCILAB Defined when using Scilab
SWIGSEXP Defined when using S-expressions
SWIGTCL Defined when using Tcl
SWIGXML Defined when using XML
diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html
index 234117464..8dae4bbf0 100644
--- a/Doc/Manual/Python.html
+++ b/Doc/Manual/Python.html
@@ -2169,15 +2169,15 @@ for Python 2.2):
import _example
class Foo(object):
- def __init__(self):
- self.this = _example.new_Foo()
- self.thisown = 1
- def __del__(self):
- if self.thisown:
- _example.delete_Foo(self.this)
- def spam(self,arg1):
- return _example.Foo_spam(self.this,arg1)
- x = property(_example.Foo_x_get, _example.Foo_x_set)
+ def __init__(self):
+ self.this = _example.new_Foo()
+ self.thisown = 1
+ def __del__(self):
+ if self.thisown:
+ _example.delete_Foo(self.this)
+ def spam(self,arg1):
+ return _example.Foo_spam(self.this,arg1)
+ x = property(_example.Foo_x_get, _example.Foo_x_set)
@@ -2219,9 +2219,9 @@ like in a proxy class:
@@ -2841,6 +2841,7 @@ the methods one() and two() (but not three()):
class Foo {
public:
Foo(int foo);
+ virtual ~Foo();
virtual void one();
virtual void two();
};
@@ -2861,11 +2862,12 @@ then at the python side you can define
import mymodule
class MyFoo(mymodule.Foo):
- def __init__(self, foo):
- mymodule.Foo(self, foo)
+ def __init__(self, foo):
+ mymodule.Foo.__init__(self, foo)
+# super().__init__(foo) # Alternative construction for Python3
- def one(self):
- print "one from python"
+ def one(self):
+ print "one from python"
@@ -3368,6 +3370,18 @@ print("Loading", "Whizz", "Bang", sep=' ... ')
+
When using %pythoncode and %pythonbegin you generally
+want to make sure that the block is delimited by %{ and %}.
+If you delimit it with { and } then any lines with a
+leading # will be handled by SWIG as preprocessor directives, when
+you probably meant them as Python comments. Prior to SWIG 3.0.3, invalid
+preprocessor directives were silently ignored, so generally using the wrong
+delimiters resulted in such comments not appearing in the generated output
+(though a comment starting with a valid preprocessor directive could cause
+problems, for example: # error handling). SWIG 3.0.3 and later report
+an error for invalid preprocessor directives, so you may have to update
+existing interface files to delimit blocks of Python code correctly.
+
Sometimes you may want to replace or modify the wrapper function
that SWIG creates in the proxy .py file. The Python module
in SWIG provides some features that enable you to do this. First, to
diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html
index c4e0074f3..e78447b92 100644
--- a/Doc/Manual/Ruby.html
+++ b/Doc/Manual/Ruby.html
@@ -147,7 +147,7 @@
38.1 Preliminaries
-
SWIG 1.3 is known to work with Ruby versions 1.6 and later.
+
SWIG 3.0 is known to work with Ruby versions 1.8 and later.
Given the choice, you should use the latest stable version of Ruby. You
should also determine if your system supports shared libraries and
dynamic loading. SWIG will work with or without dynamic loading, but
@@ -191,7 +191,7 @@ header file. This file is usually contained in a directory such as
@@ -2823,7 +2829,7 @@ not support optional arguments, such as Java and C#, effectively ignore
the value specified by this typemap as all arguments must be given.
@@ -5351,7 +5357,7 @@ used for callbacks, for example.
To solve the problem, SWIG can now generate code with director
functions containing the optional macros SWIG_INIT_STACK and
SWIG_RELEASE_STACK. These macros will try to force Ruby to
-reinitiliaze the beginning of the stack the first time a
+reinitialize the beginning of the stack the first time a
director
function is called. This will lead Ruby to measure and not
collect any VALUE objects defined from that point on.
diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html
index e70280a08..4c33aeab8 100644
--- a/Doc/Manual/SWIG.html
+++ b/Doc/Manual/SWIG.html
@@ -138,6 +138,7 @@ can be obtained by typing swig -help or swig
-xml Generate XML wrappers
-c++ Enable C++ parsing
+-cppext ext Change file extension of C++ generated files to ext (default is cxx, except for PHP which uses cpp)
-Dsymbol Define a preprocessor symbol
-Fstandard Display error/warning messages in commonly used format
-Fmicrosoft Display error/warning messages in Microsoft format
@@ -146,7 +147,7 @@ can be obtained by typing swig -help or swig
-lfile Include a SWIG library file.
-module name Set the name of the SWIG module
-o outfile Name of output file
--outcurrentdir Set default output dir to current dir instead of input file's path
+-outcurrentdir Set default output dir to current dir instead of input file's path
-outdir dir Set language specific files output directory
-pcreversion Display PCRE version information
-swiglib Show location of SWIG library
diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html
index 62c0e8d1e..eeca0291c 100644
--- a/Doc/Manual/SWIGPlus.html
+++ b/Doc/Manual/SWIGPlus.html
@@ -3614,18 +3614,52 @@ and the second will take two integer arguments.
-Needless to say, SWIG's template support provides plenty of
-opportunities to break the universe. That said, an important final
-point is that SWIG does not perform extensive error checking of
-templates! Specifically, SWIG does not perform type checking nor
-does it check to see if the actual contents of the template
-declaration make any sense. Since the C++ compiler will hopefully
-check this when it compiles the resulting wrapper file, there is no
-practical reason for SWIG to duplicate this functionality (besides,
-none of the SWIG developers are masochistic enough to want to
-implement this right now).
+Needless to say, SWIG's template support provides plenty of opportunities to
+break the universe. That said, an important final point is that SWIG does
+not perform extensive error checking of templates! Specifically, SWIG does
+not perform type checking nor does it check to see if the actual contents of the
+template declaration make any sense. Since the C++ compiler checks this when it
+compiles the resulting wrapper file, there is no practical reason for SWIG to
+duplicate this functionality.
+
+
+As SWIG's template support does not perform type checking %template
+can be used as early as after a template declaration. You can, and rarely have
+to, use %template before the template parameters have been declared.
+For example:
+
+
+
+
+template <class T> class OuterTemplateClass {};
+
+// The nested class OuterClass::InnerClass inherits from the template class
+// OuterTemplateClass<OuterClass::InnerStruct> and thus the template needs
+// to be expanded with %template before the OuterClass declaration.
+%template(OuterTemplateClass_OuterClass__InnerStruct)
+ OuterTemplateClass<OuterClass::InnerStruct>
+
+
+// Don't forget to use %feature("flatnested") for OuterClass::InnerStruct and
+// OuterClass::InnerClass if the target language doesn't support nested classes.
+class OuterClass {
+ public:
+ // Forward declarations:
+ struct InnerStruct;
+ class InnerClass;
+};
+
+struct OuterClass::InnerStruct {};
+
+// Expanding the template at this point with %template is too late as the
+// OuterClass::InnerClass declaration is processed inside OuterClass.
+
+class OuterClass::InnerClass : public OuterTemplateClass<InnerStruct> {};
+
+
+
Compatibility Note: The first implementation of template support relied heavily on
macro expansion in the preprocessor. Templates have been more tightly integrated into
@@ -5000,6 +5034,12 @@ class Bar {
+
+If a nested class, within an outer class, has to be used as a template parameter within the outer class, then the template will
+have to be instantiated with %template before the beginning of the outer class.
+An example can be found in the
+Templates section.
+
+Scilab is a scientific software package for numerical computations providing a powerful open computing environment for engineering and scientific applications that is mostly compatible with MATLAB. More information can be found at www.scilab.org.
+
+
+
+This chapter explains how to use SWIG for Scilab. After this introduction, you should be able to generate with SWIG a Scilab external module from a C/C++ library.
+
+
+
+
39.1 Preliminaries
+
+
+
+SWIG for Scilab supports Linux. Other operating sytems haven't been tested.
+
+
+
+Scilab is supported from version 5.3.3 onwards.
+The forthcoming version 6, as of January 2015, is also supported.
+
+
+
+SWIG for Scilab supports C language. C++ is partially supported. See A basic tour of C/C++ wrapping for further details.
+
+
+
+
39.2 Running SWIG
+
+
+
+Let's see how to use SWIG for Scilab on a small example.
+
+In this example we bind from C a function and a global variable into Scilab. The SWIG interface (stored in a file named example.i), is the following:
+
+Note: a code in an %inline section is both parsed and wrapped by SWIG, and inserted as is in the wrapper source file.
+
+
+
+
39.2.1 Generating the module
+
+
+
+The module is generated using the swig executable and its -scilab option.
+
+
+
+$ swig -scilab example.i
+
+
+
+This command generates two files:
+
+
+
example_wrap.c: a C source file containing the wrapping code and also here the wrapped code (the fact() and Foo definitions)
+
loader.sce: a Scilab script used to load the module into Scilab
+
+
+
+Note: if the following error is returned:
+
+
+
+:1: Error: Unable to find 'swig.swg'
+:3: Error: Unable to find 'scilab.swg'
+
+
+
+it may be because the SWIG library is not found. Check the SWIG_LIB environment variable or your SWIG installation.
+
+
+
+Note: SWIG for Scilab can work in two modes related to the way the module is built, see the Building modes section for details.
+This example uses the builder mode.
+
+
+
+
+The swig executable has several other command line options you can use. See Scilab command line options for further details.
+
+
+
+
39.2.2 Building the module
+
+
+
+To be loaded in Scilab, the wrapper has to be built into a dynamic module (or shared library).
+
+
+
+The commands to compile and link the wrapper (with gcc) into the shared library libexample.so are:
+
+Note: we supposed in this example that the path to the Scilab include directory is /usr/local/include/scilab (which is the case in a Debian environment), this should be changed for another environment.
+
+
+
39.2.3 Loading the module
+
+
+
+Loading a module is done by running the loader script in Scilab:
+
+
+
+--> exec loader.sce
+
+
+
+Scilab should output the following messages:
+
+
+
+Shared archive loaded.
+Link done.
+
+
+
+which means that Scilab has successfully loaded the shared library. The module functions and other symbols are now available in Scilab.
+
+
+
39.2.4 Using the module
+
+
+
+In Scilab, the function fact() is simply called as following:
+
+
+
+--> fact(5)
+ans =
+
+ 120.
+
+
+
For the Foo global variable, the accessors need to be used:
+
+
+Note: for conciseness, we assume in the subsequent Scilab code examples that the modules have been beforehand built and loaded in Scilab.
+
+
+
39.2.5 Scilab command line options
+
+
+
+The following table lists the Scilab specific command line options in addition to the generic SWIG options:
+
+
+
+
+
+
-builder
+
Generate the Scilab builder script
+
+
+
+
-buildercflags <cflags>
+
Add <cflags> to the builder compiler flags
+
+
+
+
-builderldflags <ldflags>
+
Add <ldlags> to the builder linker flags
+
+
+
+
-buildersources <files>
+
Add the (comma separated) files <files> to the builder sources
+
+
+
+
-builderverbositylevel <level>
+
Set the build verbosity level to <level> (default 0: off, 2: high)
+
+
+
+
-builderflagscript <file>
+
Use the Scilab script <file> to configure the compiler and linker flags
+
+
+
+
-gatewayxml <gateway_id>
+
Generate the gateway XML with the given <gateway_id>
+
+
+
+
+
+These options can be displayed with:
+
+
+
+$ swig -scilab -help
+
+
+
+
39.3 A basic tour of C/C++ wrapping
+
+
+
39.3.1 Overview
+
+
+
+SWIG for Scilab provides only a low-level C interface for Scilab (see Scripting Languages for the general approach to wrapping).
+This means that functions, structs, classes, variables, etc... are interfaced through C functions. These C functions are mapped as Scilab functions.
+There are a few exceptions, such as constants and enumerations, which can be wrapped directly as Scilab variables.
+
+
+
39.3.2 Identifiers
+
+
+
+In Scilab 5.x, identifier names are composed of 24 characters maximum (this limitation should disappear from Scilab 6.0 onwards).
+ Thus long function or variable names may be truncated and this can cause ambiguities.
+
+
This happens especially when wrapping structs/classes, for which the wrapped function name is composed of the struct/class name and field names.
+In these cases, the %rename directive can be used to choose a different Scilab name.
+
+
+
39.3.3 Functions
+
+
+
+Functions are wrapped as new Scilab built-in functions. For example:
+
+
+
+%module example
+
+%inline %{
+int fact(int n) {
+ if (n > 1)
+ return n * fact(n - 1);
+ else
+ return 1;
+}
+%}
+
+
+
+creates a built-in function fact(n) in Scilab:
+
+
+
+--> fact(4)
+ans =
+
+ 24.
+
+
+
39.3.3.1 Argument passing
+
+
+
+In the above example, the function parameter is a primitive type and is marshalled by value.
+So this function is wrapped without any additional customization.
+Argument values are converted between C types and Scilab types through type mappings.
+There are several default type mappings for primitive and complex types, described later in the Scilab typemaps section.
+
+
+
+When a parameter is not passed by value, such as a pointer or reference, SWIG does not know if it is an input, output (or both) parameter.
+The INPUT, OUTPUT, INOUT typemaps defined in the typemaps.i library can be used to specify this.
+
+
+
+Let's see this on two simple functions: sub() which has an output parameter, and inc(), which as input/output parameter:
+
+
+
+%module example
+
+%include <typemaps.i>
+
+extern void sub(int *INPUT, int *INPUT, int *OUTPUT);
+extern void inc(int *INOUT, int *INPUT);
+
+%{
+void sub(int *x, int *y, int *result) {
+ *result = *x - *y;
+}
+void inc(int *x, int *delta) {
+ *x = *x + *delta;
+}
+%}
+
+
+
+In Scilab, parameters are passed by value. The output (and inout) parameters are returned as the result of the functions:
+
+
+
+--> sub(5, 3)
+ ans =
+
+ 2.
+
+--> inc(4, 3)
+ ans =
+
+ 7.
+
+
+
39.3.3.2 Multiple output arguments
+
+
+
+A C function can have several output parameters. They can all be returned as results of the wrapped function as Scilab supports multiple return values from a function
+when using the typemaps.i library.
+If the C function itself returns a result, this is returned first before the parameter outputs.
+
+
+
+The example below shows this for a C function returning 2 values and a result:
+
+
+
+%module example
+
+%include <typemaps.i>
+
+int divide(int n, int d, int *OUTPUT, int *OUTPUT);
+
+%{
+int divide(int n, int d, int q*, int *r) {
+ if (d != 0) {
+ *q = n / d;
+ *r = n % d;
+ return 1;
+ }
+ else return 0;
+}
+%}
+
+
+
+
+
+--> [ret, q, r] = divide(20, 6)
+ r =
+
+ 2.
+ q =
+
+ 3.
+ ret =
+
+ 1.
+
+
+
+
39.3.4 Global variables
+
+
+
+Global variables are manipulated through generated accessor functions.
+For example, for a given Foo global variable, SWIG actually generates two functions: Foo_get() to get the value of Foo, and Foo_set() to set the value.
+These functions are used as following:
+
+It works for variables of primitive type, but also for non-primitive types: arrays, and structs/classes which are described later.
+For now, an example with two global primitive arrays x and y is shown:
+
+
+
+%module example
+
+%inline %{
+int x[10];
+double y[7];
+
+void initArrays()
+{
+ int i;
+ for (i = 0; i < 10; i++)
+ x[i] = 1;
+ for (i = 0; i < 7; i++)
+ y[i] = 1.0f;
+}
+%}
+
+--> exec loader.sce;
+--> ICONST_get();
+ ans =
+
+ 42.
+
+--> FCONST_get();
+ ans =
+
+ 2.1828
+
+--> CCONST_get();
+ ans =
+
+ x
+
+--> CCONST2_get();
+ ans =
+
+--> SCONST_get();
+ ans =
+
+ Hello World
+
+--> SCONST2_get();
+ ans =
+
+ "Hello World"
+
+--> EXPR_get();
+ ans =
+
+ 48.5484
+
+--> iconst_get();
+ ans =
+
+ 37.
+
+--> fconst_get();
+ ans =
+
+ 3.14
+
+
+
+There is another mode in which constants are wrapped as Scilab variables.
+The variables are easier to use than functions, but the drawback is that variables are not constant and so can be modified.
+
+
+
+This mode can be enabled/disabled at any time in the interface file with %scilabconst(), which
+works like all the other %feature directives.
+Use the argument value "1" to enable and "0" to disable this mode.
+For example in this mode the previous constants:
+
+are mapped to Scilab variables, with the same name:
+
+
+
+--> exec loader.sce;
+--> ICONST
+ ans =
+
+ 42
+
+--> FCONST
+ ans =
+
+ 2.1828
+
+--> CCONST
+ ans =
+
+ x
+
+--> CCONST2
+ ans =
+
+--> SCONST
+ ans =
+
+ Hello World
+
+--> SCONST2
+ ans =
+
+ "Hello World"
+
+--> EXPR
+ ans =
+
+ 48.5484
+
+--> iconst
+ ans =
+
+ 37
+
+--> fconst
+ ans =
+
+ 3.14
+
+
+
39.3.5.2 Enumerations
+
+
+
+The wrapping of enums is the same as for constants.
+By default, enums are wrapped as getter functions.
+For example, with the following enumeration:
+
+
+
%module example
+typedef enum { RED, BLUE, GREEN } color;
+
+
+
+a getter function will be generated for each value of the enumeration:
+
+
+
+--> exec loader.sce;
+--> RED_get()
+ ans =
+
+ 0.
+
+--> BLUE_get()
+ ans =
+
+ 1.
+
+--> GREEN_get()
+ ans =
+
+ 2.
+
+
+
+The %scilabconst() feature is also available for enumerations:
+
+
+
%module example
+%scilabconst(1) color;
+typedef enum { RED, BLUE, GREEN } color;
+
+
+
+
+
+--> exec loader.sce;
+--> RED
+ ans =
+
+ 0.
+
+--> BLUE
+ ans =
+
+ 1.
+
+--> GREEN
+ ans =
+
+ 2.
+
+
+
+
39.3.6 Pointers
+
+
+
+C/C++ pointers are fully supported by SWIG. They are mapped to the Scilab pointer type ("pointer", type ID: 128).
+
+
+
+Given a wrapping of some of the C file functions:
+
+The user of a pointer is responsible for freeing it or, like in the example, closing any resources associated with it (just as is required in a C program).
+
+
+
39.3.6.1 Utility functions
+
+
+
+Most of time pointer manipulation is not needed in a scripting language such as Scilab.
+However, in some cases it can be useful, such as for testing or debugging.
+
+
+
+SWIG comes with two pointer utility functions:
+
+
+
SWIG_this(): returns the address value of a pointer
+
SWIG_ptr(): creates a pointer from an address value
+
+
+
Following illustrates their use on the last example:
+
+
+--> f = fopen("junk", "w");
+--> fputs("Hello", f);
+--> addr = SWIG_this(f)
+ ans =
+
+ 8219088.
+
+--> p = SWIG_ptr(addr);
+--> fputs(" World", p);
+--> fclose(f);
+
+
+
39.3.6.2 Null pointers
+
+
+
By default, Scilab does not provide a way to test or create null pointers.
+But it is possible to have a null pointer by using the previous functions SWIG_this() and SWIG_ptr(), like this:
+
+
+
+--> p = SWIG_ptr(0);
+--> SWIG_this(p) == 0
+ ans =
+
+ T
+
+
+
+
39.3.7 Structures
+
+
+
+Structs exist in Scilab, but C structs are not (at least in this version of SWIG) mapped to Scilab structs.
+A C structure is wrapped through low-level accessor functions, i.e. functions that give access to the member variables of this structure.
+In Scilab, a structure is manipulated through a pointer which is passed as an argument to the accessor functions.
+
+
+
+Let's see it on an example of a struct with two members:
+
+
+
+%module example
+
+%inline %{
+
+typedef struct {
+ int x;
+ int arr[4];
+} Foo;
+
+%}
+
+
+
+Several functions are generated:
+
+
+
a constructor function new_Foo() which returns a pointer to a newly created struct Foo.
+
two member getter functions Foo_x_get(), Foo_arr_get(), to get the values of x and y for the struct pointer (provided as the first parameter to these functions)
+
two member setter functions Foo_x_set(), Foo_arr_set(), to set the values of x and y for the struct pointer (provided as the first parameter to these functions).
+
a destructor function delete_Foo() to release the struct pointer.
+Classes do not exist in Scilab. The classes are wrapped the same way as structs.
+Low-level accessor functions are generated for class members.
+Also, constructor and destructor functions are generated to create and destroy an instance of the class.
+
+Inheritance is supported. SWIG knows the inheritance relationship between classes.
+
+
+
+A function is only generated for the class in which it is actually declared.
+But if one of its parameters is a class, any instance of a derived class is accepted as the argument.
+
+
+
+This mechanism also applies for accessor functions: they are generated only in the class in which they are defined.
+But any instance of a derived class can be used as the argument to these accessor functions.
+
+
+
+For example, let's take a base class Shape and two derived classes Circle and Square:
+
+To set the location of the Circle, we have to use the function set_location() of the parent Shape.
+But we can use either use the get_perimeter() function of the parent class or the derived class:
+
+
+
+--> c = new_Circle(3);
+
+--> Shape_set_location(c, 2, 3);
+--> Shape_x_get(c)
+ ans =
+
+ 2.
+
+--> Circle_get_perimeter(c)
+ ans =
+
+ 18.84
+
+--> Shape_get_perimeter(c)
+ ans =
+
+ 18.84
+
+
+
39.3.10 Pointers, references, values, and arrays
+
+
+
+In C++ objects can be passed by value, pointer, reference, or by an array:
+
+Similar behaviour occurs for return values. For example, if you had functions like this:
+
+
+Foo *spam5();
+Foo &spam6();
+Foo spam7();
+
+
+All these functions will return a pointer to an instance of Foo.
+As the function spam7 returns a value, new instance of Foo has to be allocated, and a pointer on this instance is returned.
+
+
+
39.3.11 C++ templates
+
+
+
+As in other languages, function and class templates are supported in SWIG Scilab.
+
+
+
+You have to tell SWIG to create wrappers for a particular
+template instantiation. The %template directive is used for this purpose.
+For example:
+
+
+
+%module example
+
+template<class T1, class T2, class T3>
+struct triplet {
+ T1 first;
+ T2 second;
+ T3 third;
+ triplet(const T1& a, const T2& b, const T3& c) {
+ third = a; second = b; third = c;
+ }
+};
+
+%template(IntTriplet) triplet<int,int,int>;
+
+
+
+Then in Scilab:
+
+
+
+
+--> t = new_IntTriplet(3, 4, 1);
+
+--> IntTriplet_first_get(t)
+ ans =
+
+ 3.
+
+--> IntTriplet_second_get(t)
+ ans =
+
+ 4.
+
+--> IntTriplet_third_get(t)
+ ans =
+
+ 1.
+
+--> delete_IntTriplet(t);
+
+
+
+
+More details on template support can be found in the templates documentation.
+
+
+
39.3.12 C++ operators
+
+
+
+C++ operators are partially supported.
+Operator overloading exists in Scilab, but a C++ operator is not (in this version) wrapped by SWIG as a Scilab operator, but as a function.
+It is not automatic, you have to rename each operator (with the instruction %rename) with the suitable wrapper name.
+
+
+
+Let's see it with an example of class with two operators + and double():
+
+SWIG is aware of C++ namespaces, but does not use it for wrappers.
+The module is not broken into submodules, nor do namespace appear in functions names.
+All the namespaces are all flattened in the module.
+For example with one namespace Foo:
+
+Scilab does not natively support exceptions, but has errors.
+When an exception is thrown, SWIG catches it, and sets a Scilab error. An error message is displayed in Scilab.
+For example:
+
+
+
+%module example
+
+%inline %{
+void throw_exception() throw(char const *) {
+ throw "Bye world !";
+}
+%}
+
+Scilab has a try-catch mechanism (and a similar instruction execstr()) to handle exceptions.
+It can be used with the lasterror() function as following:
+
+
+
+--> execstr('throw_exception()', 'errcatch');
+ ans =
+
+ 999.
+
+--> lasterror()
+ ans =
+
+ SWIG/Scilab: Exception (char const *) occured: Bye world !
+
+
+
+If the function has a throw exception specification, SWIG can automatically map the exception type and set an appropriate Scilab error message.
+It works for a few primitive types, and also for STL exceptions (the library std_except.i has to be included to get the STL exception support):
+
+
+
+%module example
+
+%include <std_except.i>
+
+%inline %{
+void throw_int() throw(int) {
+ throw 12;
+}
+
+void throw_stl_invalid_arg(int i) throw(std::invalid_argument) {
+ if (i < 0)
+ throw std::invalid_argument("argument is negative.");
+}
+%}
+
+More complex or custom exception types require specific exception typemaps to be implemented in order to specifically handle a thrown type.
+See the SWIG C++ documentation for more details.
+
+
+
39.3.15 C++ STL
+
+
+
+The Standard Template Library (STL) is partially supported. See STL for more details.
+
+
+
39.4 Type mappings and libraries
+
+
+
39.4.1 Default primitive type mappings
+
+
+
+The following table provides the equivalent Scilab type for C/C++ primitive types.
+
+
+
+
+
+
C/C++ type
+
Scilab type
+
+
bool
boolean
+
char
string
+
signed char
double or int8
+
unsigned char
double or uint8
+
short
double or int16
+
unsigned short
double or uint16
+
int
double or int32
+
unsigned int
double or uint32
+
long
double or int32
+
unsigned long
double or uint32
+
signed long long
not supported in Scilab 5.x
+
unsigned long long
not supported in Scilab 5.x
+
float
double
+
double
double
+
char * or char[]
string
+
+
+
+
+Notes:
+
+
+
In Scilab the double type is far more used than any integer type.
+This is why integer values (int32, uint32, ...) are automatically converted to Scilab double values when marshalled from C into Scilab.
+Additionally on input to a C function, Scilab double values are converted into the related integer type.
+
+
+When an integer is expected, if the input is a double, the value must be an integer, i.e. it must not have any decimal part, otherwise a SWIG value error occurs.
+
+
+In SWIG for Scilab 5.x, the long long type is not supported, since Scilab 5.x does not have a 64-bit integer type.
+The default behaviour is for SWIG to generate code that will give a runtime error if long long type arguments are used from Scilab.
+
+
+
+
+
39.4.2 Default type mappings for non-primitive types
+
+
+
+The default mapped type for C/C++ non-primitive types is the Scilab pointer, for example for C structs, C++ classes, etc...
+
+
+
+
39.4.3 Arrays
+
+
+
+Typemaps are available by default for arrays. Primitive type arrays are automatically converted to/from Scilab matrices.
+Typemaps are also provided to handle members of a struct or class that are arrays.
+
+
+
+In input, the matrix is usually one-dimensional (it can be either a row or column vector). But it can also be a two-dimensional matrix.
+Warning: in Scilab, the values are column-major ordered, unlike in C, which is row-major ordered.
+
+
+
+The type mappings used for arrays is the same for primitive types, described earlier.
+This means that, if needed, a Scilab double vector is converted in input into the related C integer array
+and this C integer array is automatically converted on output into a Scilab double vector.
+Note that unlike scalars, no control is done for arrays when a double is converted into an integer.
+
+
+
+The following example illustrates all this:
+
+
+%module example
+
+%#include <stdio.h>
+
+%inline %{
+
+void printArray(int values[], int len) {
+ int i = 0;
+ for (i = 0; i < len; i++) {
+ printf("%s %d %s", i==0?"[":"", values[i], i==len-1?"]\n":"");
+ }
+}
+%}
+
+There are no specific typemaps for pointer-to-pointers, they are are mapped as pointers in Scilab.
+
+
+
+Pointer-to-pointers are sometimes used to implement matrices in C. The following is a an example of this:
+
+
+
+
+%module example
+%inline %{
+
+// Returns the matrix [1 2; 3 4];
+double **create_matrix() {
+ double **M;
+ int i;
+ M = (double **) malloc(2 * sizeof(double *));
+ for (i = 0; i < 2; i++) {
+ M[i] = (double *) malloc(2 * sizeof(double));
+ M[i][0] = 2 * i + 1;
+ M[i][1] = 2 * i + 2;
+ }
+ return M;
+}
+
+// Gets the item M(i,j) value
+double get_matrix(double **M, int i, int j) {
+ return M[i][j];
+}
+
+// Sets the item M(i,j) value to be val
+void set_matrix(double **M, int i, int j, double val) {
+ M[i][j] = val;
+}
+
+// Prints a matrix (2,2) to console
+void print_matrix(double **M, int nbRows, int nbCols) {
+ int i, j;
+ for (i = 0; i < 2; i++) {
+ for (j = 0; j < 2; j++) {
+ printf("%3g ", M[i][j]);
+ }
+ printf("\n");
+ }
+}
+
+%}
+
+The remarks made earlier for arrays also apply here:
+
+
+
The values of matrices in Scilab are column-major orderered,
+
There is no control while converting double values to integers, double values are truncated without any checking or warning.
+
+
+
39.4.6 STL
+
+
+
+The STL library wraps some containers defined in the STL (Standard Template Library), so that they can be manipulated in Scilab.
+This library also provides the appropriate typemaps to use the containers in functions and variables.
+
+
+
+The list of wrapped sequence containers are:
+
+
+
std::vector
+
std::list
+
std::deque
+
+
+
+And associative containers are:
+
+
+
std::set
+
std::multiset
+
+
+
+Typemaps are available for the following container types:
+
+
+
+
double
+
float
+
int
+
string
+
bool
+
pointer
+
+
+
+Containers of other item types are not supported. Using them does not break compilation, but provokes a runtime error.
+Containers of enum are not supported yet.
+
+
+
+In order to use the STL, the library must first be included in the SWIG interface file:
+
+
+
+%include <stl.i>
+
+
+
Then for each container used, the appropriate template must be instantiated, in the std namespace:
+
+Additionally, the module initialization function has to be executed first in Scilab, so that all the types are known to Scilab.
+See the Module initialization section for more details.
+
+
+
+
+Because in Scilab matrices exist for basic types only, a sequence container of pointers is mapped to a Scilab list.
+For other item types (double, int, string...) the sequence container is mapped to a Scilab matrix.
+
+
+
+The first example below shows how to create a vector (of int) in Scilab, add some values to the vector and pass it as an argument of a function.
+It also shows, thanks to the typemaps, that we can also pass a Scilab matrix of values directly into the function:
+
+--> example_Init();
+
+--> v = new_IntVector();
+
+--> for i = 1:4
+--> IntVector_push_back(v, i);
+--> end;
+
+--> average(v)
+ ans =
+
+ 2.5
+
+--> average([0 1 2 3])
+ ans =
+
+ 2.5
+
+--> delete_IntVector();
+
+
+
+
+In the second example, a set of struct (Person) is wrapped.
+A function performs a search in this set, and returns a subset. As one can see, the result in Scilab is a list of pointers:
+
+
+
+%module example
+
+%include <stl.i>
+
+%{
+#include <string>
+%}
+
+%inline %{
+
+struct Person {
+ Person(std::string _name, int _age) : name(_name), age(_age) {};
+ std::string name;
+ int age;
+};
+typedef Person * PersonPtr;
+
+%}
+
+namespace std {
+ %template(PersonPtrSet) set<PersonPtr>;
+}
+
+%inline %{
+
+std::set<PersonPtr> findPersonsByAge(std::set<PersonPtr> persons, int minAge, int maxAge) {
+ std::set<PersonPtr> foundPersons;
+ for (std::set<PersonPtr>::iterator it = persons.begin(); it != persons.end(); it++) {
+ if (((*it)->age >= minAge) && ((*it)->age <= maxAge)) {
+ foundPersons.insert(*it);
+ }
+ }
+ return foundPersons;
+}
+
+%}
+
+
+
+
+
+--> example_Init();
+
+--> joe = new_Person("Joe", 25);
+--> susan = new_Person("Susan", 32);
+--> bill = new_Person("Bill", 50);
+
+--> p = new_PersonPtrSet();
+--> PersonPtrSet_insert(p, susan);
+--> PersonPtrSet_insert(p, joe);
+--> PersonPtrSet_insert(p, bill);
+
+--> l = findPersonsByAge(p, 20, 40);
+
+--> size(l)
+ ans =
+
+ 2.
+
+--> Person_name_get(l(1))
+ans =
+
+ Susan
+
+--> Person_name_get(l(2))
+ ans =
+
+ Joe
+
+--> delete_PersonPtrSet(p);
+
+
+
39.5 Module initialization
+
+
+
+The wrapped module contains an initialization function to:
+
+
+
initialize the SWIG runtime, which is necessary when working with the STL
+
initialize in Scilab the module constants and enumerations declared with %scilabconst()
+
+
+
+This initialization function should be executed at the start of a script, before the wrapped library has to be used.
+
+
+
+The function has the name of the module suffixed by _Init.
+For example, to initialize the module example:
+
+
+
+--> example_Init();
+
+
+
39.6 Building modes
+
+
+
+The mechanism to load an external module in Scilab is called Dynamic Link and works with dynamic modules (or shared libraries, .so files).
+
+
+
+To produce a dynamic module, when generating the wrapper, there are two possibilities, or build modes:
+
+
+
the nobuilder mode, this is the default mode in SWIG. The user is responsible of the build.
+
the builder mode. In this mode, Scilab is responsible of building.
+
+
+
39.6.1 No-builder mode
+
+
+
+In this mode, used by default, SWIG generates the wrapper sources, which have to be manually compiled and linked.
+A loader script loader.sce is also produced, this one is executed further in Scilab to load the module.
+
+
+
+This mode is the best option to use when you have to integrate the module build into a larger build process.
+
+
+
+
39.6.2 Builder mode
+
+
+
+In this mode, in addition to the wrapper sources, SWIG produces a builder Scilab script (builder.sce), which is executed in Scilab to build the module.
+In a few words, the Scilab ilib_build() command is used, which produces the shared library file, and the loader script loader.sce (and also a cleaner script cleaner.sce).
+
+
+
+An advantage of this mode is that it hides all the complexity of the build and other platform issues.
+Also it allows the module to conform to a Scilab external module convention which is that an external module should be simply built by calling a builder script.
+
+
+
+The builder mode is activated with the -builder SWIG option.
+In this mode, the following SWIG options may be used to setup the build:
+
+
+
+
-buildersources: to add sources to the build (several files must be separated by a comma)
+
-buildercflags: to add flags to the builder compiler flags, for example to set library dependencies include paths
+
-builderldflags: to add flags to the linker flags, for example to set library dependency names and paths
+
+
+
+Let's give an example how to build a module example, composed of two sources, and using a library dependency:
+
+
+
the sources are baa1.c and baa2.c (and are stored in in the current directory)
+
the library is libfoo in /opt/foo (headers stored in /opt/foo/include, and shared library in /opt/foo/lib)
+ilib_build(lib_name,table,files,libs) is used to create shared libraries, and to generate a loader file used to dynamically load the shared library into Scilab.
+
+
+
+
ilib_name: a character string, the generic name of the library without path and extension.
@@ -83,7 +83,7 @@ Tcl 8.0 or a later release. Earlier releases of SWIG supported Tcl 7.x, but
this is no longer supported.
-
39.1 Preliminaries
+
40.1 Preliminaries
@@ -109,7 +109,7 @@ build a Tcl extension module. To finish building the module, you
need to compile this file and link it with the rest of your program.
-
39.1.1 Getting the right header files
+
40.1.1 Getting the right header files
@@ -127,7 +127,7 @@ this is the case, you should probably make a symbolic link so that tcl.h
-
39.1.2 Compiling a dynamic module
+
40.1.2 Compiling a dynamic module
@@ -163,7 +163,7 @@ The name of the module is specified using the %module directive or the
-module command line option.
-
39.1.3 Static linking
+
40.1.3 Static linking
@@ -229,7 +229,7 @@ minimal in most situations (and quite frankly not worth the extra
hassle in the opinion of this author).
-
39.1.4 Using your module
+
40.1.4 Using your module
@@ -357,7 +357,7 @@ to the default system configuration (this requires root access and you will need
the man pages).
-
39.1.5 Compilation of C++ extensions
+
40.1.5 Compilation of C++ extensions
@@ -440,7 +440,7 @@ erratic program behavior. If working with lots of software components, you
might want to investigate using a more formal standard such as COM.
-
39.1.6 Compiling for 64-bit platforms
+
40.1.6 Compiling for 64-bit platforms
@@ -467,7 +467,7 @@ also introduce problems on platforms that support more than one
linking standard (e.g., -o32 and -n32 on Irix).
-
39.1.7 Setting a package prefix
+
40.1.7 Setting a package prefix
@@ -486,7 +486,7 @@ option will append the prefix to the name when creating a command and
call it "Foo_bar".
-
39.1.8 Using namespaces
+
40.1.8 Using namespaces
@@ -508,7 +508,7 @@ When the -namespace option is used, objects in the module
are always accessed with the namespace name such as Foo::bar.
-
39.2 Building Tcl/Tk Extensions under Windows 95/NT
+
40.2 Building Tcl/Tk Extensions under Windows 95/NT
@@ -519,7 +519,7 @@ covers the process of using SWIG with Microsoft Visual C++.
although the procedure may be similar with other compilers.
-
39.2.1 Running SWIG from Developer Studio
+
40.2.1 Running SWIG from Developer Studio
@@ -577,7 +577,7 @@ MSDOS > tclsh80
%
-
39.2.2 Using NMAKE
+
40.2.2 Using NMAKE
@@ -640,7 +640,7 @@ to get you started. With a little practice, you'll be making lots of
Tcl extensions.
-
39.3 A tour of basic C/C++ wrapping
+
40.3 A tour of basic C/C++ wrapping
@@ -651,7 +651,7 @@ classes. This section briefly covers the essential aspects of this
wrapping.
-
39.3.1 Modules
+
40.3.1 Modules
@@ -685,7 +685,7 @@ To fix this, supply an extra argument to load like this:
-
@@ -874,7 +874,7 @@ When an identifier name is given, it is used to perform an implicit hash-table l
conversion. This allows the global statement to be omitted.
-
39.3.5 Pointers
+
40.3.5 Pointers
@@ -970,7 +970,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return
None if the conversion can't be performed.
-
39.3.6 Structures
+
40.3.6 Structures
@@ -1252,7 +1252,7 @@ Note: Tcl only destroys the underlying object if it has ownership. See the
memory management section that appears shortly.
-
39.3.7 C++ classes
+
40.3.7 C++ classes
@@ -1319,7 +1319,7 @@ In Tcl, the static member is accessed as follows:
-
39.3.8 C++ inheritance
+
40.3.8 C++ inheritance
@@ -1368,7 +1368,7 @@ For instance:
It is safe to use multiple inheritance with SWIG.
-
39.3.9 Pointers, references, values, and arrays
+
40.3.9 Pointers, references, values, and arrays
@@ -1422,7 +1422,7 @@ to hold the result and a pointer is returned (Tcl will release this memory
when the return value is garbage collected).
-
39.3.10 C++ overloaded functions
+
40.3.10 C++ overloaded functions
@@ -1545,7 +1545,7 @@ first declaration takes precedence.
Please refer to the "SWIG and C++" chapter for more information about overloading.
-
39.3.11 C++ operators
+
40.3.11 C++ operators
@@ -1647,7 +1647,7 @@ There are ways to make this operator appear as part of the class using the %
Keep reading.
-
39.3.12 C++ namespaces
+
40.3.12 C++ namespaces
@@ -1711,7 +1711,7 @@ utilizes thousands of small deeply nested namespaces each with
identical symbol names, well, then you get what you deserve.
@@ -2435,7 +2435,7 @@ Since SWIG's exception handling is user-definable, you are not limited to C++ ex
See the chapter on "Customization Features" for more examples.
-
39.7 Typemaps
+
40.7 Typemaps
@@ -2452,7 +2452,7 @@ Typemaps are only used if you want to change some aspect of the primitive
C-Tcl interface.
-
39.7.1 What is a typemap?
+
40.7.1 What is a typemap?
@@ -2569,7 +2569,7 @@ parameter is omitted):
-
39.7.2 Tcl typemaps
+
40.7.2 Tcl typemaps
@@ -2707,7 +2707,7 @@ Initialize an argument to a value before any conversions occur.
Examples of these methods will appear shortly.
-
39.7.3 Typemap variables
+
40.7.3 Typemap variables
@@ -2778,7 +2778,7 @@ properly assigned.
The Tcl name of the wrapper function being created.
-
39.7.4 Converting a Tcl list to a char **
+
40.7.4 Converting a Tcl list to a char **
@@ -2840,7 +2840,7 @@ argv[2] = Larry
3
-
39.7.5 Returning values in arguments
+
40.7.5 Returning values in arguments
@@ -2882,7 +2882,7 @@ result, a Tcl function using these typemaps will work like this :
%
-
39.7.6 Useful functions
+
40.7.6 Useful functions
@@ -2958,7 +2958,7 @@ int Tcl_IsShared(Tcl_Obj *obj);
-
39.7.7 Standard typemaps
+
40.7.7 Standard typemaps
@@ -3043,7 +3043,7 @@ work)
-
39.7.8 Pointer handling
+
40.7.8 Pointer handling
@@ -3119,7 +3119,7 @@ For example:
-
39.8 Turning a SWIG module into a Tcl Package.
+
40.8 Turning a SWIG module into a Tcl Package.
@@ -3191,7 +3191,7 @@ As a final note, most SWIG examples do not yet use the
to use the load command instead.
-
39.9 Building new kinds of Tcl interfaces (in Tcl)
+
40.9 Building new kinds of Tcl interfaces (in Tcl)
@@ -3290,7 +3290,7 @@ danger of blowing something up (although it is easily accomplished
with an out of bounds array access).
-
39.9.1 Proxy classes
+
40.9.1 Proxy classes
@@ -3411,7 +3411,7 @@ short, but clever Tcl script can be combined with SWIG to do many
interesting things.
-
39.10 Tcl/Tk Stubs
+
40.10 Tcl/Tk Stubs
diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html
index 99b89c425..fda162615 100644
--- a/Doc/Manual/Warnings.html
+++ b/Doc/Manual/Warnings.html
@@ -349,9 +349,9 @@ These can be overridden using command line options, for example:
$ swig -python -Fstandard example.i
-example.i:4: Syntax error in input.
+example.i:4: Syntax error in input(1).
$ swig -python -Fmicrosoft example.i
-example.i(4) : Syntax error in input.
+example.i(4) : Syntax error in input(1).
15.9 Warning number reference
diff --git a/Doc/Manual/chapters b/Doc/Manual/chapters
index 32cf0b2dd..4e513beac 100644
--- a/Doc/Manual/chapters
+++ b/Doc/Manual/chapters
@@ -36,6 +36,7 @@ Pike.html
Python.html
R.html
Ruby.html
+Scilab.html
Tcl.html
Extending.html
Doxygen.html
diff --git a/Examples/Makefile.in b/Examples/Makefile.in
index ea4c65654..6fccda22e 100644
--- a/Examples/Makefile.in
+++ b/Examples/Makefile.in
@@ -485,11 +485,10 @@ guile: $(SRCDIR_SRCS)
$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ISRCS) $(SRCDIR_SRCS)
$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(GUILE_LIBS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO)
-guile_cpp: $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO)
-$(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO): $(SRCDIR_SRCS)
+guile_cpp: $(SRCDIR_SRCS)
$(SWIG) -c++ -guile -Linkage passive $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS)
- $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(GUILE_LIBS) $(LIBS) $(CPP_DLLIBS) -o $@
+ $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(GUILE_LIBS) $(LIBS) $(CPP_DLLIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO)
guile_externalhdr:
$(SWIG) -guile -external-runtime $(TARGET)
@@ -596,7 +595,7 @@ java_cpp: $(SRCDIR_SRCS)
# ----------------------------------------------------------------
java_compile: $(SRCDIR_SRCS)
- $(COMPILETOOL) $(JAVAC) $(JAVACFLAGS) $(addprefix $(SRCDIR),$(JAVASRCS))
+ $(COMPILETOOL) $(JAVAC) $(addprefix $(SRCDIR),$(JAVASRCS))
# -----------------------------------------------------------------
# Run java example
@@ -633,9 +632,6 @@ java_clean:
ROOT_DIR = @ROOT_DIR@
JSINCLUDES = @JSCOREINC@ @JSV8INC@
JSDYNAMICLINKING = @JSCOREDYNAMICLINKING@ @JSV8DYNAMICLINKING@
-JSSO =@JSSO@
-JSLDSHARED = @JSLDSHARED@
-JSCXXSHARED = @JSCXXSHARED@
NODEJS = @NODEJS@
NODEGYP = @NODEGYP@
@@ -731,7 +727,7 @@ javascript_clean:
rm -rf build
rm -f *_wrap* $(RUNME)
rm -f core @EXTRA_CLEAN@
- rm -f *.@OBJEXT@ *@JSSO@ *.$(SO)
+ rm -f *.@OBJEXT@ *@SO@
rm -f binding.gyp example-gypcopy.cxx
cd $(ROOT_DIR)/Tools/javascript && $(MAKE) -s clean
@@ -1096,7 +1092,7 @@ ruby_version:
# -----------------------------------------------------------------
ruby_clean:
- rm -f *_wrap* *~ .~* myruby@EXEEXT@ *.pm
+ rm -f *_wrap* *~ .~* myruby@EXEEXT@
rm -f core @EXTRA_CLEAN@
rm -f *.@OBJEXT@ *$(RUBY_SO)
@@ -1668,7 +1664,6 @@ endif
# ----------------------------------------------------------------
# Build a R dynamically loadable module (C++)
# ----------------------------------------------------------------
-
r_cpp: $(SRCDIR_CXXSRCS)
$(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACEPATH)
ifneq ($(SRCDIR_CXXSRCS),)
@@ -1700,6 +1695,57 @@ r_clean:
rm -f *.@OBJEXT@ *@SO@ NAMESPACE
rm -f $(RRSRC) $(RUNME).Rout .RData
+##################################################################
+##### SCILAB ######
+##################################################################
+
+SCILAB = @SCILAB@
+SCILAB_INC= @SCILABINCLUDE@
+SCILAB_OPT = @SCILABOPT@
+SCILAB_LIBPREFIX = lib
+
+# ----------------------------------------------------------------
+# Build a C dynamically loadable module
+# ----------------------------------------------------------------
+
+scilab:
+ $(SWIG) -scilab $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
+ $(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SCILAB_INC) $(INCLUDES) $(ISRCS) $(SRCDIR_SRCS) $(SRCDIR_CSRCS)
+ $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(IOBJS) $(OBJS) $(LIBS) -o $(SCILAB_LIBPREFIX)$(TARGET)$(SO)
+
+# ----------------------------------------------------------------
+# Build a C++ dynamically loadable module
+# ----------------------------------------------------------------
+
+scilab_cpp:
+ $(SWIG) -c++ -scilab $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
+ $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(SCILAB_INC) $(INCLUDES) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS)
+ $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(IOBJS) $(OBJS) $(LIBS) $(CPP_DLLIBS) -o $(SCILAB_LIBPREFIX)$(TARGET)$(SO)
+
+# -----------------------------------------------------------------
+# Running a Scilab example
+# -----------------------------------------------------------------
+
+scilab_run:
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(SCILAB) $(SCILAB_OPT) -f $(SRCDIR)$(RUNME).sci $(RUNPIPE)
+
+# -----------------------------------------------------------------
+# Scilab version
+# -----------------------------------------------------------------
+
+scilab_version:
+ echo `$(SCILAB) -version | head -1`
+
+# -----------------------------------------------------------------
+# Cleaning the scilab examples
+# -----------------------------------------------------------------
+
+scilab_clean:
+ rm -f *_wrap* *~ .~*
+ rm -f core @EXTRA_CLEAN@
+ rm -f *.@OBJEXT@ *@SO@
+ rm -f *.sce
+
##################################################################
##### Go ######
##################################################################
diff --git a/Examples/d/example.mk.in b/Examples/d/example.mk.in
index 33e1a801e..a1d9a85fc 100644
--- a/Examples/d/example.mk.in
+++ b/Examples/d/example.mk.in
@@ -29,9 +29,15 @@ EXTRA_CXXFLAGS =
EXTRA_LDFLAGS =
TARGET = example_wrap
SWIGOPT = -outcurrentdir
-DSRCS = *.d
DFLAGS = -ofrunme
+ifeq (,$(SRCDIR))
+DSRCS = *.d
+else
+DSRCS = *.d $(addprefix ../$(SRCDIR)$(VERSION_DIR),runme.d)
+endif
+
+
check: build
$(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' d_run
@@ -44,7 +50,10 @@ build:
else \
$(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' SRCS='' d; \
fi
- $(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' DSRCS='../$(SRCDIR)$(VERSION_DIR)runme.d $(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
+ $(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
clean:
- $(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' d_clean
+ if [ -d $(VERSION_DIR) ]; then \
+ $(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' d_clean; \
+ fi
+ test -f $(VERSION_DIR)runme.d || rm -rf $(VERSION_DIR) # Only delete dir if out of source
diff --git a/Examples/scilab/check.list b/Examples/scilab/check.list
new file mode 100644
index 000000000..0bcf457c2
--- /dev/null
+++ b/Examples/scilab/check.list
@@ -0,0 +1,16 @@
+# see top-level Makefile.in
+class
+constants
+contract
+enum
+funcptr
+matrix
+matrix2
+pointer
+simple
+std_list
+std_vector
+struct
+template
+variables
+
diff --git a/Examples/scilab/class/Makefile b/Examples/scilab/class/Makefile
new file mode 100644
index 000000000..b0545d804
--- /dev/null
+++ b/Examples/scilab/class/Makefile
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab_cpp
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_clean
diff --git a/Examples/scilab/class/example.cxx b/Examples/scilab/class/example.cxx
new file mode 100644
index 000000000..046304519
--- /dev/null
+++ b/Examples/scilab/class/example.cxx
@@ -0,0 +1,28 @@
+/* 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;
+
+double Circle::area() {
+ return M_PI*radius*radius;
+}
+
+double Circle::perimeter() {
+ return 2*M_PI*radius;
+}
+
+double Square::area() {
+ return width*width;
+}
+
+double Square::perimeter() {
+ return 4*width;
+}
diff --git a/Examples/scilab/class/example.h b/Examples/scilab/class/example.h
new file mode 100644
index 000000000..0dff185b2
--- /dev/null
+++ b/Examples/scilab/class/example.h
@@ -0,0 +1,34 @@
+/* File : example.h */
+
+class Shape {
+public:
+ Shape() {
+ nshapes++;
+ }
+ virtual ~Shape() {
+ nshapes--;
+ }
+ double x, y;
+ void move(double dx, double dy);
+ virtual double area() = 0;
+ virtual double perimeter() = 0;
+ static int nshapes;
+};
+
+class Circle : public Shape {
+private:
+ double radius;
+public:
+ Circle(double r) : radius(r) { }
+ virtual double area();
+ virtual double perimeter();
+};
+
+class Square : public Shape {
+private:
+ double width;
+public:
+ Square(double w) : width(w) { }
+ virtual double area();
+ virtual double perimeter();
+};
diff --git a/Examples/scilab/class/example.i b/Examples/scilab/class/example.i
new file mode 100644
index 000000000..fbdf7249f
--- /dev/null
+++ b/Examples/scilab/class/example.i
@@ -0,0 +1,9 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+%include "example.h"
diff --git a/Examples/scilab/class/runme.sci b/Examples/scilab/class/runme.sci
new file mode 100644
index 000000000..236e54110
--- /dev/null
+++ b/Examples/scilab/class/runme.sci
@@ -0,0 +1,52 @@
+lines(0);
+ilib_verbose(0);
+ierr = exec('loader.sce', 'errcatch');
+if ierr <> 0 then
+ disp(lasterror());
+ exit(ierr);
+end
+
+// ----- Object creation -----
+
+printf("Creating some objects:\n");
+c = new_Circle(10)
+s = new_Square(10)
+
+// ----- Access a static member -----
+
+printf("\nA total of %i shapes were created\n", Shape_nshapes_get());
+
+// ----- 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);
+
+printf("\nHere is their current position:\n");
+printf(" Circle = (%f, %f)\n", Shape_x_get(c), Shape_y_get(c));
+printf(" Square = (%f, %f)\n", Shape_x_get(s), Shape_y_get(s));
+
+// ----- Call some methods -----
+
+printf("\nHere are some properties of the shapes:\n");
+function print_shape(o)
+ printf(" area = %f\n", Shape_area(o));
+ printf(" perimeter = %f\n", Shape_perimeter(o));
+endfunction
+print_shape(c);
+print_shape(s);
+
+printf("\nGuess I will clean up now\n");
+
+// Note: this invokes the virtual destructor
+delete_Circle(c);
+delete_Square(s);
+
+printf("%i shapes remain\n", Shape_nshapes_get());
+printf("Goodbye\n");
+
+exit
diff --git a/Examples/scilab/constants/Makefile b/Examples/scilab/constants/Makefile
new file mode 100644
index 000000000..56e51e6f5
--- /dev/null
+++ b/Examples/scilab/constants/Makefile
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS =
+TARGET = example
+INTERFACE = example.i
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_clean
diff --git a/Examples/scilab/constants/example.i b/Examples/scilab/constants/example.i
new file mode 100644
index 000000000..1172a4edc
--- /dev/null
+++ b/Examples/scilab/constants/example.i
@@ -0,0 +1,30 @@
+/* File : example.i */
+%module example
+
+/* Wraps enums and constants as Scilab variables (instead of functions) */
+%scilabconst(1);
+
+/* 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 directives also produce constants */
+
+%constant int iconst = 37;
+%constant double fconst = 3.14;
+
+
diff --git a/Examples/scilab/constants/runme.sci b/Examples/scilab/constants/runme.sci
new file mode 100644
index 000000000..cfb28b6b4
--- /dev/null
+++ b/Examples/scilab/constants/runme.sci
@@ -0,0 +1,18 @@
+lines(0);
+ilib_verbose(0);
+ierr = exec('loader.sce', 'errcatch');
+if ierr <> 0 then
+ disp(lasterror());
+ exit(ierr);
+end
+example_Init();
+
+printf("\nTest constants\n");
+printf("ICONST = %i (should be 42)\n", ICONST);
+printf("FCONST = %5.4f (should be 2.1828)\n", FCONST);
+printf("SCONST = ''%s'' (should be ''Hello World'')\n", SCONST);
+printf("EXPR = %5.4f (should be 48.5484)\n", EXPR);
+printf("iconst = %i (should be 37)\n", iconst);
+printf("fconst = %3.2f (should be 3.14)\n", fconst);
+
+exit
diff --git a/Examples/scilab/contract/Makefile b/Examples/scilab/contract/Makefile
new file mode 100644
index 000000000..208a88bfe
--- /dev/null
+++ b/Examples/scilab/contract/Makefile
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_clean
diff --git a/Examples/scilab/contract/example.c b/Examples/scilab/contract/example.c
new file mode 100644
index 000000000..1a644543f
--- /dev/null
+++ b/Examples/scilab/contract/example.c
@@ -0,0 +1,23 @@
+/* File : example.c */
+
+/* A global variable */
+double Foo = 3.0;
+
+/* 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 fact(int n) {
+ if (n <= 0) return 1;
+ return n*fact(n-1);
+}
+
+
diff --git a/Examples/scilab/contract/example.i b/Examples/scilab/contract/example.i
new file mode 100644
index 000000000..8fd1a80af
--- /dev/null
+++ b/Examples/scilab/contract/example.i
@@ -0,0 +1,21 @@
+/* File : example.i */
+%module example
+
+%contract gcd(int x, int y) {
+require:
+ x >= 0;
+ y >= 0;
+}
+
+%contract fact(int n) {
+require:
+ n >= 0;
+ensure:
+ fact >= 1;
+}
+
+%inline %{
+extern int gcd(int x, int y);
+extern int fact(int n);
+extern double Foo;
+%}
diff --git a/Examples/scilab/contract/runme.sci b/Examples/scilab/contract/runme.sci
new file mode 100644
index 000000000..718424b29
--- /dev/null
+++ b/Examples/scilab/contract/runme.sci
@@ -0,0 +1,46 @@
+lines(0);
+ilib_verbose(0);
+ierr = exec('loader.sce', 'errcatch');
+if ierr <> 0 then
+ disp(lasterror());
+ exit(ierr);
+end
+
+
+// Call our gcd() function
+x = 42;
+y = 105;
+g = gcd(x, y);
+printf("The gcd of %d and %d is %d\n", x, y, g);
+
+// Call our fact() function
+x = 5;
+g = fact(x);
+printf("The fact of %d is %d\n", x, g);
+
+// Manipulate the Foo global variable
+
+// Output its current value
+printf("Foo = %f\n", Foo_get());
+
+// Change its value
+Foo_set(3.1415926);
+
+// See if the change took effect
+printf("Foo = %f\n", Foo_get());
+
+// Check error messages when violating contract
+ierr = execstr('gcd(-42, 105)', 'errcatch');
+if ierr <> 20003 then
+ error("gcd(-42, 105) must provoke a RunTimeError")
+end
+
+ierr = execstr('fact(-4)', 'errcatch');
+if ierr <> 20003 then
+ error("fact(-4) must provoke a RunTimeError")
+end
+
+exit
+
+
+
diff --git a/Examples/scilab/enum/Makefile b/Examples/scilab/enum/Makefile
new file mode 100644
index 000000000..b0545d804
--- /dev/null
+++ b/Examples/scilab/enum/Makefile
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab_cpp
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_clean
diff --git a/Examples/scilab/enum/example.cxx b/Examples/scilab/enum/example.cxx
new file mode 100644
index 000000000..6785e57ac
--- /dev/null
+++ b/Examples/scilab/enum/example.cxx
@@ -0,0 +1,37 @@
+/* File : example.c */
+
+#include "example.h"
+#include
+
+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/scilab/enum/example.h b/Examples/scilab/enum/example.h
new file mode 100644
index 000000000..525d62afc
--- /dev/null
+++ b/Examples/scilab/enum/example.h
@@ -0,0 +1,13 @@
+/* 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/scilab/enum/example.i b/Examples/scilab/enum/example.i
new file mode 100644
index 000000000..a9c71c5ab
--- /dev/null
+++ b/Examples/scilab/enum/example.i
@@ -0,0 +1,10 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+%include "example.h"
+
+
diff --git a/Examples/scilab/enum/runme.sci b/Examples/scilab/enum/runme.sci
new file mode 100644
index 000000000..0895fc340
--- /dev/null
+++ b/Examples/scilab/enum/runme.sci
@@ -0,0 +1,36 @@
+lines(0);
+ilib_verbose(0);
+ierr = exec('loader.sce', 'errcatch');
+if ierr <> 0 then
+ disp(lasterror());
+ exit(ierr);
+end
+example_Init();
+
+printf("\nTest enums\n");
+printf("*** color ***\n");
+printf(" RED_get() = %i\n", RED_get());
+printf(" BLUE_get() = %i\n", BLUE_get());
+printf(" GREEN_get() = %i\n", GREEN_get());
+
+printf("\n*** Foo::speed ***\n")
+printf(" Foo_IMPULSE = %i\n", Foo_IMPULSE_get());
+printf(" Foo_WARP = %i\n", Foo_WARP_get());
+printf(" Foo_LUDICROUS = %i\n", Foo_LUDICROUS_get());
+
+printf("\nTest enums as argument of functions\n");
+
+enum_test(RED_get(), Foo_IMPULSE_get());
+enum_test(BLUE_get(), Foo_WARP_get());
+enum_test(GREEN_get(), Foo_LUDICROUS_get());
+enum_test(1234, 5678);
+
+printf("\nTest enums as argument of class methods\n");
+
+f = new_Foo();
+Foo_enum_test(f, Foo_IMPULSE_get());
+Foo_enum_test(f, Foo_WARP_get());
+Foo_enum_test(f, Foo_LUDICROUS_get());
+delete_Foo(f);
+
+exit
diff --git a/Examples/scilab/funcptr/Makefile b/Examples/scilab/funcptr/Makefile
new file mode 100644
index 000000000..208a88bfe
--- /dev/null
+++ b/Examples/scilab/funcptr/Makefile
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_clean
diff --git a/Examples/scilab/funcptr/example.c b/Examples/scilab/funcptr/example.c
new file mode 100644
index 000000000..5c4a3dabf
--- /dev/null
+++ b/Examples/scilab/funcptr/example.c
@@ -0,0 +1,19 @@
+/* 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;
+}
+
+int (*funcvar)(int,int) = add;
diff --git a/Examples/scilab/funcptr/example.h b/Examples/scilab/funcptr/example.h
new file mode 100644
index 000000000..9936e24fc
--- /dev/null
+++ b/Examples/scilab/funcptr/example.h
@@ -0,0 +1,9 @@
+/* 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);
+
+extern int (*funcvar)(int,int);
+
diff --git a/Examples/scilab/funcptr/example.i b/Examples/scilab/funcptr/example.i
new file mode 100644
index 000000000..e8af50e6f
--- /dev/null
+++ b/Examples/scilab/funcptr/example.i
@@ -0,0 +1,11 @@
+/* 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));
+
+extern int (*funcvar)(int,int);
+
diff --git a/Examples/scilab/funcptr/runme.sci b/Examples/scilab/funcptr/runme.sci
new file mode 100644
index 000000000..d3cbed394
--- /dev/null
+++ b/Examples/scilab/funcptr/runme.sci
@@ -0,0 +1,22 @@
+lines(0);
+ilib_verbose(0);
+ierr = exec('loader.sce', 'errcatch');
+if ierr <> 0 then
+ disp(lasterror());
+ exit(ierr);
+end
+
+a = 37
+b = 42
+
+// Now call our C function with a bunch of callbacks
+
+printf("Trying some C callback functions\n");
+printf(" a = %i\n", a);
+printf(" b = %i\n", b);
+printf(" ADD(a,b) = %i\n", do_op(a,b,funcvar_get()));
+
+exit
+
+
+
diff --git a/Examples/scilab/matrix/Makefile b/Examples/scilab/matrix/Makefile
new file mode 100644
index 000000000..208a88bfe
--- /dev/null
+++ b/Examples/scilab/matrix/Makefile
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_clean
diff --git a/Examples/scilab/matrix/example.c b/Examples/scilab/matrix/example.c
new file mode 100644
index 000000000..6ce10098b
--- /dev/null
+++ b/Examples/scilab/matrix/example.c
@@ -0,0 +1,61 @@
+/* FILE : matrix.c : some simple 4x4 matrix operations */
+#include
+#include
+
+double **new_matrix() {
+
+ int i;
+ double **M;
+
+ M = (double **) malloc(4*sizeof(double *));
+ M[0] = (double *) malloc(16*sizeof(double));
+
+ for (i = 0; i < 4; i++) {
+ M[i] = M[0] + 4*i;
+ }
+ return M;
+}
+
+void destroy_matrix(double **M) {
+
+ free(M[0]);
+ free(M);
+
+}
+
+void print_matrix(double **M) {
+
+ int i,j;
+
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 4; j++) {
+ printf("%10g ", M[i][j]);
+ }
+ printf("\n");
+ }
+
+}
+
+void mat_mult(double **m1, double **m2, double **m3) {
+
+ int i,j,k;
+ double temp[4][4];
+
+ for (i = 0; i < 4; i++)
+ for (j = 0; j < 4; j++) {
+ temp[i][j] = 0;
+ for (k = 0; k < 4; k++)
+ temp[i][j] += m1[i][k]*m2[k][j];
+ }
+
+ for (i = 0; i < 4; i++)
+ for (j = 0; j < 4; j++)
+ m3[i][j] = temp[i][j];
+}
+
+
+
+
+
+
+
diff --git a/Examples/scilab/matrix/example.i b/Examples/scilab/matrix/example.i
new file mode 100644
index 000000000..c930e92f5
--- /dev/null
+++ b/Examples/scilab/matrix/example.i
@@ -0,0 +1,36 @@
+%module example
+// FILE : matrix.i
+
+%{
+
+void set_m(double **M, int i, int j, double val) {
+ M[i][j] = val;
+}
+
+double get_m(double **M, int i, int j) {
+ return M[i][j];
+}
+%}
+
+%inline {
+/*** Matrix Operations ***/
+
+extern double **new_matrix();
+/* Creates a new matrix and returns a pointer to it */
+
+extern void destroy_matrix(double **M);
+/* Destroys the matrix M */
+
+extern void print_matrix(double **M);
+/* Prints out the matrix M */
+
+extern void set_m(double **M, int i, int j, double val);
+/* Sets M[i][j] = val*/
+
+extern double get_m(double **M, int i, int j);
+/* Returns M[i][j] */
+
+extern void mat_mult(double **a, double **b, double **c);
+/* Multiplies matrix a by b and places the result in c*/
+
+}
diff --git a/Examples/scilab/matrix/runme.sci b/Examples/scilab/matrix/runme.sci
new file mode 100644
index 000000000..26943b184
--- /dev/null
+++ b/Examples/scilab/matrix/runme.sci
@@ -0,0 +1,43 @@
+lines(0);
+ilib_verbose(0);
+ierr = exec('loader.sce', 'errcatch');
+if ierr <> 0 then
+ disp(lasterror());
+ exit(ierr);
+end
+
+// create a new matrix
+x = new_matrix();
+for i = 0 : 3;
+ for j = 0 : 3;
+ set_m(x, i, j, i+j);
+ end;
+end;
+
+// print the matrix
+print_matrix(x);
+
+// another matrix
+y = new_matrix();
+ for i = 0 : 3;
+ for j = 0 : 3;
+ set_m(y, i, j, i-j);
+ end;
+ end;
+
+// print the matrix
+print_matrix(y);
+
+// mat_mult the two matrix, and the result is stored in a new matrix
+z = new_matrix();
+
+mat_mult(x, y, z);
+
+print_matrix(z);
+
+//destroy the matrix
+destroy_matrix(x);
+destroy_matrix(y);
+destroy_matrix(z);
+
+exit
diff --git a/Examples/scilab/matrix2/Makefile b/Examples/scilab/matrix2/Makefile
new file mode 100644
index 000000000..208a88bfe
--- /dev/null
+++ b/Examples/scilab/matrix2/Makefile
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_clean
diff --git a/Examples/scilab/matrix2/example.c b/Examples/scilab/matrix2/example.c
new file mode 100644
index 000000000..476067df9
--- /dev/null
+++ b/Examples/scilab/matrix2/example.c
@@ -0,0 +1,118 @@
+#include
+#include
+#include
+
+
+// Double matrix functions
+
+double sumDoubleMatrix(double *inputMatrix, int nbRow, int nbCol)
+{
+ int i;
+ double total = 0.0;
+ for (i=0; i myMatrix=[ 103 3 1 12;0 0 2043 1];
+ * --> sumitems(myMatrix);
+ * 32
+ */
+ double B[] = {1,3,4,9,2,8,3,2}; /* Declare the matrix */
+ int rowB = 2, colB = 4;
+ printf("sumitems: %6.2f\n",sumitems(B, rowB, colB));
+
+
+/**
+ * --> myOtherMatrix=generateValues();
+ * --> size(myOtherMatrix);
+ */
+ int numberRow, numberCol, i;
+ double * matrix=getValues(&numberRow, &numberCol);
+ printf("Matrix of size [%d,%d]",numberRow, numberCol);
+ for(i=0; i < numberRow*numberCol; i++)
+ {
+ printf("A[%d] = %5.2f\n",i,matrix[i]);
+ }
+}
diff --git a/Examples/scilab/matrix2/runme.sci b/Examples/scilab/matrix2/runme.sci
new file mode 100644
index 000000000..0af7df4e7
--- /dev/null
+++ b/Examples/scilab/matrix2/runme.sci
@@ -0,0 +1,51 @@
+lines(0);
+ilib_verbose(0);
+ierr = exec('loader.sce', 'errcatch');
+if ierr <> 0 then
+ disp(lasterror());
+ exit(ierr);
+end
+
+// Test lib double matrix functions
+disp("Call lib function getDoubleMatrix()");
+doubleMatrix = getDoubleMatrix();
+disp(doubleMatrix);
+
+disp("Call lib function sumDoubleMatrix()");
+s = sumDoubleMatrix(doubleMatrix);
+disp(s);
+
+disp("Call lib function squareDoubleMatrix()");
+sqrd = squareDoubleMatrix(doubleMatrix);
+disp(sqrd);
+
+
+// Test lib integer matrix functions
+
+disp("Call lib function getIntegerMatrix()");
+integerMatrix = getIntegerMatrix();
+disp(integerMatrix);
+
+disp("Call lib function sumIntegerMatrix()");
+s = sumIntegerMatrix(integerMatrix);
+disp(s);
+
+disp("Call lib function squareIntegerMatrix()");
+sqri = squareIntegerMatrix(integerMatrix);
+disp(sqri);
+
+
+// Test lib string matrix functions
+
+disp("Call lib function getStringVector()");
+stringVector = getStringVector();
+disp(stringVector);
+
+disp("Call lib function concatStringVector()");
+stringVector2 = concatStringVector(stringVector);
+disp(stringVector2);
+
+exit
+
+
+
diff --git a/Examples/scilab/pointer/Makefile b/Examples/scilab/pointer/Makefile
new file mode 100644
index 000000000..92308c312
--- /dev/null
+++ b/Examples/scilab/pointer/Makefile
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_clean
diff --git a/Examples/scilab/pointer/example.c b/Examples/scilab/pointer/example.c
new file mode 100644
index 000000000..b877d9a5b
--- /dev/null
+++ b/Examples/scilab/pointer/example.c
@@ -0,0 +1,16 @@
+/* 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/scilab/pointer/example.i b/Examples/scilab/pointer/example.i
new file mode 100644
index 000000000..a8ac79499
--- /dev/null
+++ b/Examples/scilab/pointer/example.i
@@ -0,0 +1,30 @@
+/* File : example.i */
+%module example
+
+%{
+extern void add(int *, int *, int *);
+extern void sub(int *, int *, int *);
+extern int divide(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/scilab/pointer/runme.sci b/Examples/scilab/pointer/runme.sci
new file mode 100644
index 000000000..3400ab3e5
--- /dev/null
+++ b/Examples/scilab/pointer/runme.sci
@@ -0,0 +1,47 @@
+lines(0);
+ilib_verbose(0);
+ierr = exec('loader.sce', 'errcatch');
+if ierr <> 0 then
+ disp(lasterror());
+ exit(ierr);
+end
+
+// First create some objects using the pointer library.
+printf("Testing the pointer library\n")
+a = new_intp();
+b = new_intp();
+c = new_intp(); // Memory for result
+
+intp_assign(a, 37);
+intp_assign(b, 42);
+
+printf(" a = %d\n", intp_value(a));
+printf(" b = %d\n", intp_value(b));
+printf(" c = %d\n", intp_value(c));
+
+// Call the add() function with some pointers
+add(a, b, c);
+
+// Now get the result
+r = intp_value(c);
+printf(" 37 + 42 = %d\n", r);
+
+// Clean up the pointers
+delete_intp(a);
+delete_intp(b);
+delete_intp(c);
+
+// Now try the typemap library
+// This should be much easier. Now how it is no longer
+// necessary to manufacture pointers.
+printf("Trying the typemap library\n");
+r = sub(37, 42);
+printf(" 37 - 42 = %d\n", r);
+
+// Now try the version with multiple return values
+printf("Testing multiple return values\n");
+[q, r] = divide(42, 37);
+printf(" 42/37 = %d remainder %d\n", q, r);
+
+exit
+
diff --git a/Examples/scilab/simple/Makefile b/Examples/scilab/simple/Makefile
new file mode 100644
index 000000000..208a88bfe
--- /dev/null
+++ b/Examples/scilab/simple/Makefile
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_clean
diff --git a/Examples/scilab/simple/example.c b/Examples/scilab/simple/example.c
new file mode 100644
index 000000000..1c2af789c
--- /dev/null
+++ b/Examples/scilab/simple/example.c
@@ -0,0 +1,18 @@
+/* File : example.c */
+
+/* A global variable */
+double Foo = 3.0;
+
+/* 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/scilab/simple/example.i b/Examples/scilab/simple/example.i
new file mode 100644
index 000000000..24093b9bf
--- /dev/null
+++ b/Examples/scilab/simple/example.i
@@ -0,0 +1,7 @@
+/* File : example.i */
+%module example
+
+%inline %{
+extern int gcd(int x, int y);
+extern double Foo;
+%}
diff --git a/Examples/scilab/simple/runme.sci b/Examples/scilab/simple/runme.sci
new file mode 100644
index 000000000..ed8b0f6c3
--- /dev/null
+++ b/Examples/scilab/simple/runme.sci
@@ -0,0 +1,29 @@
+lines(0);
+ilib_verbose(0);
+ierr = exec('loader.sce', 'errcatch');
+if ierr <> 0 then
+ disp(lasterror());
+ exit(ierr);
+end
+
+// Call our gcd() function
+
+x = 42;
+y = 105;
+g = gcd(x,y);
+printf("The gcd of %d and %d is %d\n",x,y,g);
+
+// Manipulate the Foo global variable
+
+// Get its default value (see in example.c)
+defaultValue = Foo_get()
+if defaultValue <> 3 then pause; end
+
+// Change its value
+Foo_set(3.1415926)
+
+// See if the change took effect
+if Foo_get() <> 3.1415926 then pause,end
+
+exit
+
diff --git a/Examples/scilab/std_list/Makefile b/Examples/scilab/std_list/Makefile
new file mode 100644
index 000000000..b0545d804
--- /dev/null
+++ b/Examples/scilab/std_list/Makefile
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab_cpp
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_clean
diff --git a/Examples/scilab/std_list/example.cxx b/Examples/scilab/std_list/example.cxx
new file mode 100644
index 000000000..e58d6a38b
--- /dev/null
+++ b/Examples/scilab/std_list/example.cxx
@@ -0,0 +1,61 @@
+/* File : example.cpp */
+
+#include "example.h"
+
+#include
+#include
+#include
+#include
+#include
+
+
+template
+std::list concat_list(const std::list list, const std::list other_list)
+{
+ std::list out_list(list);
+ out_list.insert(out_list.end(), other_list.begin(), other_list.end());
+ return out_list;
+}
+
+// int lists
+
+std::list create_integer_list(const int rangemin, const int rangemax)
+{
+ std::list out_list;
+ for (int i = rangemin; i <= rangemax; i++)
+ {
+ out_list.push_back(i);
+ }
+ return out_list;
+}
+
+int sum_integer_list(const std::list& list)
+{
+ return std::accumulate(list.begin(), list.end(), 0);
+}
+
+std::list concat_integer_list(const std::list list, const std::list other_list)
+{
+ return concat_list(list, other_list);
+}
+
+// string lists
+
+std::list create_string_list(const char* svalue)
+{
+ std::list out_list;
+ std::string str(svalue);
+
+ std::istringstream iss(str);
+ std::copy(std::istream_iterator(iss),
+ std::istream_iterator(),
+ std::inserter >(out_list, out_list.begin()));
+
+ return out_list;
+}
+
+std::list concat_string_list(const std::list list, const std::list other_list)
+{
+ return concat_list(list, other_list);
+}
+
diff --git a/Examples/scilab/std_list/example.h b/Examples/scilab/std_list/example.h
new file mode 100644
index 000000000..769627e08
--- /dev/null
+++ b/Examples/scilab/std_list/example.h
@@ -0,0 +1,14 @@
+/* File : example.h */
+
+#include
+#include
+
+
+// integer lists
+std::list create_integer_list(const int size, const int value);
+int sum_integer_list(const std::list& list);
+std::list concat_integer_list(const std::list list, const std::list other_list);
+
+// string lists
+std::list create_string_list(const char* value);
+std::list concat_string_list(const std::list list, const std::list other_list);
diff --git a/Examples/scilab/std_list/example.i b/Examples/scilab/std_list/example.i
new file mode 100644
index 000000000..dbe2a73e4
--- /dev/null
+++ b/Examples/scilab/std_list/example.i
@@ -0,0 +1,19 @@
+/* File : example.i */
+
+%module example
+
+%{
+#include "example.h"
+%}
+
+%include stl.i
+%include std_list.i
+
+/* instantiate the required template specializations */
+namespace std
+{
+ %template(IntList) list;
+ %template(StringList) list;
+}
+
+%include "example.h"
diff --git a/Examples/scilab/std_list/runme.sci b/Examples/scilab/std_list/runme.sci
new file mode 100644
index 000000000..e4c04b029
--- /dev/null
+++ b/Examples/scilab/std_list/runme.sci
@@ -0,0 +1,39 @@
+lines(0);
+ilib_verbose(0);
+ierr = exec('loader.sce', 'errcatch');
+if ierr <> 0 then
+ disp(lasterror());
+ exit(ierr);
+end
+example_Init();
+
+// This example shows how to use C++ fonctions with STL lists arguments
+// Here, STL lists are converted from/to Scilab matrices (SWIG_SCILAB_EXTRA_NATIVE_CONTAINERS is not defined)
+
+// integer lists
+
+disp("Example of passing matrices of int as list arguments of C++ functions.");
+disp("get a list of int {1...4} from create_integer_list():");
+is = create_integer_list(1, 4);
+disp(is);
+disp("get the sum of this list elements with sum_integer_list():")
+sum = sum_integer_list(is);
+disp(is);
+is2 = create_integer_list(3, 6);
+disp("concat this list with the list of int {3...6} with concat_integer_list():");
+is3 = concat_integer_list(is, is2);
+disp(is3);
+
+// string lists
+
+disp("Example of passing matrices of string as list arguments of C++ functions.");
+disp("get a list of string {''aa'', ''bb'', ''cc'', ''dd''} with create_string_list():");
+ss = create_string_list("aa bb cc dd");
+disp(ss);
+ss2 = create_string_list("cc dd ee ff");
+disp("concat this list with the list of string {''cc'', ''dd'', ''ee'', ''ff''} with concat_string_list():");
+ss3 = concat_string_list(ss, ss2);
+disp(ss3);
+
+exit
+
diff --git a/Examples/scilab/std_vector/Makefile b/Examples/scilab/std_vector/Makefile
new file mode 100644
index 000000000..f73144d78
--- /dev/null
+++ b/Examples/scilab/std_vector/Makefile
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab_cpp
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_clean
diff --git a/Examples/scilab/std_vector/example.h b/Examples/scilab/std_vector/example.h
new file mode 100644
index 000000000..4f0dac70d
--- /dev/null
+++ b/Examples/scilab/std_vector/example.h
@@ -0,0 +1,25 @@
+/* File : example.h */
+
+#include
+#include
+#include
+#include
+
+double average(std::vector v) {
+ return std::accumulate(v.begin(),v.end(),0.0)/v.size();
+}
+
+std::vector half(const std::vector& v) {
+ std::vector w(v);
+ for (unsigned int i=0; i& v) {
+ // would you believe this is the same as the above?
+ std::transform(v.begin(),v.end(),v.begin(),
+ std::bind2nd(std::divides(),2.0));
+}
+
+
diff --git a/Examples/scilab/std_vector/example.i b/Examples/scilab/std_vector/example.i
new file mode 100644
index 000000000..1ba9e927e
--- /dev/null
+++ b/Examples/scilab/std_vector/example.i
@@ -0,0 +1,19 @@
+/* File : example.i */
+%module example
+
+%warnfilter(SWIGWARN_SCILAB_TRUNCATED_NAME) std::vector::get_allocator;
+
+%{
+#include "example.h"
+%}
+
+%include stl.i
+/* instantiate the required template specializations */
+namespace std {
+ %template(IntVector) vector;
+ %template(DoubleVector) vector;
+}
+
+/* Let's just grab the original header file here */
+%include "example.h"
+
diff --git a/Examples/scilab/std_vector/runme.sci b/Examples/scilab/std_vector/runme.sci
new file mode 100644
index 000000000..3e569454c
--- /dev/null
+++ b/Examples/scilab/std_vector/runme.sci
@@ -0,0 +1,37 @@
+lines(0);
+ilib_verbose(0);
+ierr = exec('loader.sce', 'errcatch');
+if ierr <> 0 then
+ disp(lasterror());
+ exit(ierr);
+end
+example_Init();
+
+
+disp(mean([1,2,3,4]));
+
+// ... or a wrapped std::vector
+
+v = new_IntVector();
+for i = 1:4
+ IntVector_push_back(v, i);
+end;
+disp(average(v));
+
+
+// half will return a Scilab matrix.
+// Call it with a Scilab matrix...
+
+disp(half([1.0, 1.5, 2.0, 2.5, 3.0]));
+
+
+// ... or a wrapped std::vector
+
+v = new_DoubleVector();
+for i = 1:4
+ DoubleVector_push_back(v, i);
+end;
+disp(half(v));
+
+exit
+
diff --git a/Examples/scilab/struct/Makefile b/Examples/scilab/struct/Makefile
new file mode 100644
index 000000000..7a030a33c
--- /dev/null
+++ b/Examples/scilab/struct/Makefile
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS =
+TARGET = example
+INTERFACE = example.i
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_clean
diff --git a/Examples/scilab/struct/example.i b/Examples/scilab/struct/example.i
new file mode 100644
index 000000000..af2cd3f4a
--- /dev/null
+++ b/Examples/scilab/struct/example.i
@@ -0,0 +1,11 @@
+%module example
+
+%rename(Bar) Foo;
+
+%inline %{
+typedef struct {
+ int x;
+} Foo;
+
+%}
+
diff --git a/Examples/scilab/struct/runme.sci b/Examples/scilab/struct/runme.sci
new file mode 100644
index 000000000..4d47ef0dc
--- /dev/null
+++ b/Examples/scilab/struct/runme.sci
@@ -0,0 +1,18 @@
+lines(0);
+ilib_verbose(0);
+ierr = exec('loader.sce', 'errcatch');
+if ierr <> 0 then
+ disp(lasterror());
+ exit(ierr);
+end
+
+// Test use of a struct (Bar)
+
+a = new_Bar();
+
+Bar_x_set(a, 100);
+printf("a.x = %d (Should be 100)\n", Bar_x_get(a));
+
+delete_Bar(a);
+
+exit
diff --git a/Examples/scilab/template/Makefile b/Examples/scilab/template/Makefile
new file mode 100644
index 000000000..f73144d78
--- /dev/null
+++ b/Examples/scilab/template/Makefile
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab_cpp
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_clean
diff --git a/Examples/scilab/template/example.h b/Examples/scilab/template/example.h
new file mode 100644
index 000000000..7401df650
--- /dev/null
+++ b/Examples/scilab/template/example.h
@@ -0,0 +1,32 @@
+/* File : example.h */
+
+// Some template definitions
+
+template T max(T a, T b) { return a>b ? a : b; }
+
+template class vector {
+ T *v;
+ int sz;
+ public:
+ vector(int _sz) {
+ v = new T[_sz];
+ sz = _sz;
+ }
+ T &get(int index) {
+ return v[index];
+ }
+ void set(int index, T &val) {
+ v[index] = val;
+ }
+#ifdef SWIG
+ %extend {
+ T getitem(int index) {
+ return $self->get(index);
+ }
+ void setitem(int index, T val) {
+ $self->set(index,val);
+ }
+ }
+#endif
+};
+
diff --git a/Examples/scilab/template/example.i b/Examples/scilab/template/example.i
new file mode 100644
index 000000000..8f94c4da1
--- /dev/null
+++ b/Examples/scilab/template/example.i
@@ -0,0 +1,17 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+%include "example.h"
+
+/* Now instantiate some specific template declarations */
+
+%template(maxint) max;
+%template(maxdouble) max;
+%template(vecint) vector;
+%template(vecdouble) vector;
+
diff --git a/Examples/scilab/template/runme.sci b/Examples/scilab/template/runme.sci
new file mode 100644
index 000000000..35ca9d1c2
--- /dev/null
+++ b/Examples/scilab/template/runme.sci
@@ -0,0 +1,45 @@
+lines(0);
+ilib_verbose(0);
+ierr = exec('loader.sce', 'errcatch');
+if ierr <> 0 then
+ disp(lasterror());
+ exit(ierr);
+end
+example_Init();
+
+// Call some templated functions
+printf("maxint(3, 7) = %i\n", maxint(3, 7));
+printf("maxdouble(3.14, 2.18) = %3.2f\n", maxdouble(3.14, 2.18));
+
+// Create some class
+
+iv = new_vecint(100);
+dv = new_vecdouble(1000);
+
+for i = 0:100
+ vecint_setitem(iv, i, 2*i);
+end
+
+for i = 0:100
+ vecdouble_setitem(dv, i, 1.0/(i+1));
+end
+
+isum = 0
+for i = 0:100
+ isum = isum + vecint_getitem(iv, i);
+end
+
+printf("isum = %i\n", isum);
+
+dsum = 0
+for i = 0:100
+ dsum = dsum + vecdouble_getitem(dv, i);
+end
+
+printf("dsum = %3.2f\n", dsum);
+
+delete_vecint(iv);
+delete_vecdouble(dv);
+
+exit
+
diff --git a/Examples/scilab/variables/Makefile b/Examples/scilab/variables/Makefile
new file mode 100644
index 000000000..208a88bfe
--- /dev/null
+++ b/Examples/scilab/variables/Makefile
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_clean
diff --git a/Examples/scilab/variables/example.c b/Examples/scilab/variables/example.c
new file mode 100644
index 000000000..9f88d90a4
--- /dev/null
+++ b/Examples/scilab/variables/example.c
@@ -0,0 +1,95 @@
+/* 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
+#include
+#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[256] = "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 = %s\n", name);
+ printf("ptptr = %p (%d, %d)\n", (void *)ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
+ 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/scilab/variables/example.h b/Examples/scilab/variables/example.h
new file mode 100644
index 000000000..0f7e89594
--- /dev/null
+++ b/Examples/scilab/variables/example.h
@@ -0,0 +1,6 @@
+/* File: example.h */
+
+typedef struct {
+ int x,y;
+} Point;
+
diff --git a/Examples/scilab/variables/example.i b/Examples/scilab/variables/example.i
new file mode 100644
index 000000000..97ba1f0e6
--- /dev/null
+++ b/Examples/scilab/variables/example.i
@@ -0,0 +1,52 @@
+/* File : example.i */
+%module example
+%{
+#include "example.h"
+%}
+
+#pragma SWIG nowarn=SWIGWARN_TYPEMAP_SWIGTYPELEAK
+
+/* Some global variable declarations */
+%inline %{
+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[256];
+
+extern Point *ptptr;
+extern Point pt;
+%}
+
+
+/* Some read-only variables */
+
+%immutable;
+
+%inline %{
+extern int status;
+extern char path[256];
+%}
+
+%mutable;
+
+/* Some helper functions to make it easier to test */
+%inline %{
+extern void print_vars();
+extern int *new_int(int value);
+extern int value_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/scilab/variables/runme.sci b/Examples/scilab/variables/runme.sci
new file mode 100644
index 000000000..98d76cfa0
--- /dev/null
+++ b/Examples/scilab/variables/runme.sci
@@ -0,0 +1,73 @@
+lines(0);
+ilib_verbose(0);
+ierr = exec('loader.sce', 'errcatch');
+if ierr <> 0 then
+ disp(lasterror());
+ exit(ierr);
+end
+
+// Try to set the values of some global variables
+ivar_set(42);
+svar_set(-31000);
+lvar_set(65537);
+uivar_set(uint32(123456));
+usvar_set(uint16(61000));
+ulvar_set(654321);
+scvar_set(int8(-13));
+ucvar_set(uint8(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("Bill");
+
+// Now print out the values of the variables
+printf("Variables (values printed from Scilab)\n");
+printf("ivar = %i\n", ivar_get());
+printf("svar = %i\n", svar_get());
+printf("lvar = %i\n", lvar_get());
+printf("uivar = %i\n", uivar_get());
+printf("usvar = %i\n", usvar_get());
+printf("ulvar = %i\n", ulvar_get());
+printf("scvar = %i\n", scvar_get());
+printf("ucvar = %i\n", ucvar_get());
+printf("fvar = %f\n", fvar_get());
+printf("dvar = %f\n", dvar_get());
+printf("cvar = %s\n", cvar_get());
+printf("strvar = %s\n", strvar_get());
+printf("cstrvar = %s\n", cstrvar_get());
+printf("iptrvar = %i\n", value_int(iptrvar_get()));
+printf("name = %s\n", name_get());
+printf("ptptr = %s\n", Point_print(ptptr_get()));
+printf("pt = %s\n", Point_print(pt_get()));
+printf("status = %d\n", status_get());
+
+printf("\nVariables (values printed from C)\n");
+print_vars()
+
+// Immutable variables
+printf("\nNow I''m going to try and modify some read only variables\n");
+printf(" Tring to set ''path''\n");
+try
+ path_set("Whoa!");
+ printf("Hey, what''s going on?!?! This shouldn''t work\n");
+catch
+ printf("Good.\n");
+end
+printf(" Trying to set ''status''\n");
+try
+ status_set(0);
+ printf("Hey, what''s going on?!?! This shouldn''t work\n");
+catch
+ printf("Good.\n");
+end
+
+// Structure
+printf("\nI''m going to try and update a structure variable.\n");
+pt_set(ptptr_get());
+printf("The new value is %s\n", Point_print(pt_get()));
+
+exit
+
diff --git a/Examples/test-suite/allprotected.i b/Examples/test-suite/allprotected.i
index bd4dfe5c7..086cfb245 100644
--- a/Examples/test-suite/allprotected.i
+++ b/Examples/test-suite/allprotected.i
@@ -8,6 +8,11 @@
%include "std_string.i"
+#ifdef SWIGSCILAB
+%rename(ProcBase) ProtectedBase;
+%rename(PubBase) PublicBase;
+#endif
+
%feature("director") PublicBase;
%feature("director") ProtectedBase;
diff --git a/Examples/test-suite/apply_signed_char.i b/Examples/test-suite/apply_signed_char.i
index c0fa00cfe..d3116f024 100644
--- a/Examples/test-suite/apply_signed_char.i
+++ b/Examples/test-suite/apply_signed_char.i
@@ -4,6 +4,10 @@
%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) DirectorTest;
+#if defined(SWIGSCILAB)
+%rename(DirTest) DirectorTest;
+#endif
+
%apply signed char {char, const char};
%apply const signed char & {const char &};
diff --git a/Examples/test-suite/apply_strings.i b/Examples/test-suite/apply_strings.i
index 54a91f83a..62b578bf2 100644
--- a/Examples/test-suite/apply_strings.i
+++ b/Examples/test-suite/apply_strings.i
@@ -1,5 +1,5 @@
-/* Test %apply for char *, signed char *, unsigned char *
- This won't work in all situations, so does not necessarily have to be implemented. See
+/* Test %apply for char *, signed char *, unsigned char *
+ This won't work in all situations, so does not necessarily have to be implemented. See
http://groups.google.com.ai/group/comp.lang.c++.moderated/browse_thread/thread/ad5873ce25d49324/0ae94552452366be?lnk=raot */
%module(directors="1") apply_strings
@@ -7,6 +7,11 @@
%warnfilter(SWIGWARN_TYPEMAP_VARIN_UNDEF) DigitsGlobalB;
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK) DigitsGlobalC;
+#if defined(SWIGSCILAB)
+%rename(TNum) TNumber;
+%rename(DirTest) DirectorTest;
+#endif
+
%apply char * {UCharPtr};
%apply char * {SCharPtr};
%apply const char * {CUCharPtr};
@@ -53,12 +58,12 @@ typedef struct {
TAscii DigitsMemberA[20];
TAscii *DigitsMemberB;
} TNumber;
-
+
TAscii DigitsGlobalA[20];
TAscii DigitsGlobalB[] = {(unsigned char)'A', (unsigned char)'B', 0};
TAscii *DigitsGlobalC;
-%}
+%}
// Director test
%feature("director");
diff --git a/Examples/test-suite/array_member.i b/Examples/test-suite/array_member.i
index d8e2f873c..845eeb72c 100644
--- a/Examples/test-suite/array_member.i
+++ b/Examples/test-suite/array_member.i
@@ -1,5 +1,9 @@
%module array_member
+#if defined(SWIGSCILAB)
+%rename(RayPkt) RayPacketData;
+#endif
+
%inline %{
typedef struct Foo {
diff --git a/Examples/test-suite/array_typedef_memberin.i b/Examples/test-suite/array_typedef_memberin.i
index ed49543a3..d9f768ed8 100644
--- a/Examples/test-suite/array_typedef_memberin.i
+++ b/Examples/test-suite/array_typedef_memberin.i
@@ -1,4 +1,9 @@
%module array_typedef_memberin
+
+#if defined(SWIGSCILAB)
+%rename(ExDetail) ExampleDetail;
+#endif
+
%inline %{
typedef short Eight[8];
typedef const short ConstEight[8];
diff --git a/Examples/test-suite/arrays.i b/Examples/test-suite/arrays.i
index decce7415..07162aa90 100644
--- a/Examples/test-suite/arrays.i
+++ b/Examples/test-suite/arrays.i
@@ -7,6 +7,10 @@ This test case tests that various types of arrays are working.
#include
%}
+#if defined(SWIGSCILAB)
+%rename(ArrSt) ArrayStruct;
+#endif
+
%inline %{
#define ARRAY_LEN 2
diff --git a/Examples/test-suite/bloody_hell.i b/Examples/test-suite/bloody_hell.i
index e580f0dd4..ff296a24c 100644
--- a/Examples/test-suite/bloody_hell.i
+++ b/Examples/test-suite/bloody_hell.i
@@ -2,16 +2,20 @@
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) kMaxIOCTLSpaceParmsSize;
-#define kMaxIOCTLSpaceParmsSize 128
+#ifdef SWIGSCILAB
+%rename(Parms) sm_channel_ix_dump_parms;
+#endif
+
+#define kMaxIOCTLSpaceParmsSize 128
%{
-#define kMaxIOCTLSpaceParmsSize 128
+#define kMaxIOCTLSpaceParmsSize 128
%}
%inline %{
-typedef struct sm_channel_ix_dump_parms {
- unsigned data[(kMaxIOCTLSpaceParmsSize - ((4*sizeof(int)) + (2*sizeof(unsigned))))/sizeof(unsigned)];
-} SM_CHANNEL_IX_DUMP_PARMS;
+typedef struct sm_channel_ix_dump_parms {
+ unsigned data[(kMaxIOCTLSpaceParmsSize - ((4*sizeof(int)) + (2*sizeof(unsigned))))/sizeof(unsigned)];
+} SM_CHANNEL_IX_DUMP_PARMS;
%}
diff --git a/Examples/test-suite/bools.i b/Examples/test-suite/bools.i
index 7b94fcf88..2ef3d93a6 100644
--- a/Examples/test-suite/bools.i
+++ b/Examples/test-suite/bools.i
@@ -1,5 +1,10 @@
// bool typemaps check
%module bools
+
+#if defined(SWIGSCILAB)
+%rename(BoolSt) BoolStructure;
+#endif
+
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); /* memory leak when setting a ptr/ref variable */
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) constbool; /* Ruby, wrong class name */
diff --git a/Examples/test-suite/callback.i b/Examples/test-suite/callback.i
index c4d50d3fe..8e28dad06 100644
--- a/Examples/test-suite/callback.i
+++ b/Examples/test-suite/callback.i
@@ -57,6 +57,22 @@
return pf(a);
}
+#if defined(__SUNPRO_CC)
+// workaround for: Error: Could not find a match for foobar_T(int, extern "C" int(*)(int)).
+ extern "C" {
+ typedef int (*foobar_int_int)(int a);
+ typedef double (*foobar_double_double)(double a);
+ };
+ template
+ int foobar_T(int a, foobar_int_int pf) {
+ return pf(a);
+ }
+ template
+ double foobar_T(double a, foobar_double_double pf) {
+ return pf(a);
+ }
+#endif
+
template
const T& ident(const T& x) {
return x;
diff --git a/Examples/test-suite/char_strings.i b/Examples/test-suite/char_strings.i
index cc59815b2..9a87df4e3 100644
--- a/Examples/test-suite/char_strings.i
+++ b/Examples/test-suite/char_strings.i
@@ -9,13 +9,9 @@ below.
%warnfilter(SWIGWARN_TYPEMAP_VARIN_UNDEF) global_char_array1; // Unable to set variable of type char[]
%warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) global_const_char; // Setting a const char * variable may leak memory.
-#ifdef SWIG_ALLEGRO_CL
%{
#include
-%}
-#endif
-%{
#define OTHERLAND_MSG "Little message from the safe world."
#define CPLUSPLUS_MSG "A message from the deep dark world of C++, where anything is possible."
static char *global_str = NULL;
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index e37580f7c..87b66f47a 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -143,6 +143,7 @@ CPP_TEST_CASES += \
class_scope_weird \
compactdefaultargs \
const_const_2 \
+ constant_directive \
constant_pointers \
constover \
constructor_copy \
@@ -298,6 +299,7 @@ CPP_TEST_CASES += \
nested_directors \
nested_comment \
nested_scope \
+ nested_template_base \
nested_workaround \
newobject1 \
null_pointer \
@@ -306,6 +308,7 @@ CPP_TEST_CASES += \
operator_pointer_ref \
operbool \
ordering \
+ overload_arrays \
overload_bool \
overload_copy \
overload_extend \
@@ -514,6 +517,7 @@ CPP11_TEST_CASES = \
cpp11_decltype \
cpp11_default_delete \
cpp11_delegating_constructors \
+ cpp11_director_enums \
cpp11_explicit_conversion_operators \
cpp11_final_override \
cpp11_function_objects \
diff --git a/Examples/test-suite/constant_directive.i b/Examples/test-suite/constant_directive.i
new file mode 100644
index 000000000..8204720d6
--- /dev/null
+++ b/Examples/test-suite/constant_directive.i
@@ -0,0 +1,28 @@
+%module constant_directive
+
+// %constant and struct
+%{
+ struct Type1 {
+ Type1(int val = 0) : val(val) {}
+ int val;
+ };
+ static Type1 TYPE1_CONSTANT1(1);
+ static Type1 TYPE1_CONST2(2);
+ static Type1 TYPE1_CONST3(3);
+%}
+
+struct Type1 {
+ Type1(int val = 0) : val(val) {}
+ int val;
+};
+
+%inline %{
+Type1 getType1Instance() { return Type1(111); }
+%}
+
+%constant Type1 TYPE1_CONSTANT1;
+%constant Type1 TYPE1_CONSTANT2 = TYPE1_CONST2;
+%constant Type1 *TYPE1_CONSTANT3 = &TYPE1_CONST3;
+
+%constant int TYPE_INT = 0;
+
diff --git a/Examples/test-suite/constant_pointers.i b/Examples/test-suite/constant_pointers.i
index 388970c4d..9094e9dea 100644
--- a/Examples/test-suite/constant_pointers.i
+++ b/Examples/test-suite/constant_pointers.i
@@ -4,6 +4,11 @@ This testcase primarily test constant pointers, eg int* const. Only a getter is
%module constant_pointers
+#if defined(SWIGSCILAB)
+%rename(MbrVar) MemberVariablesTest;
+%rename(RetVal) ReturnValuesTest;
+#endif
+
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); /* memory leak when setting a ptr/ref variable */
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG); /* Setting a pointer/reference variable may leak memory. */
diff --git a/Examples/test-suite/constructor_copy.i b/Examples/test-suite/constructor_copy.i
index 8e92e7840..7dcd05e8b 100644
--- a/Examples/test-suite/constructor_copy.i
+++ b/Examples/test-suite/constructor_copy.i
@@ -5,13 +5,13 @@
%nocopyctor Bar;
%inline %{
-
+
struct Foo1 {
int x;
Foo1(int _x = 2) : x(_x)
{
- }
+ }
};
struct Foo2 {
@@ -25,7 +25,7 @@ struct Foo3 {
struct Foo4 {
Foo4() { }
-
+
protected:
Foo4(const Foo4& ) { }
};
@@ -33,7 +33,7 @@ protected:
struct Foo4a {
Foo4a() { }
-
+
private:
Foo4a(const Foo4a& ) { }
};
@@ -53,7 +53,7 @@ struct Foo8 {
};
template
-class Bar
+class Bar
{
public:
int x;
@@ -73,7 +73,7 @@ public:
%include "std_vector.i"
-#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGR) || defined(SWIGOCTAVE) || defined(SWIGRUBY) || defined(SWIGJAVASCRIPT)
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGR) || defined(SWIGOCTAVE) || defined(SWIGRUBY) || defined(SWIGJAVASCRIPT) || defined(SWIGSCILAB)
#define SWIG_GOOD_VECTOR
%ignore std::vector::vector(size_type);
%ignore std::vector::resize(size_type);
@@ -126,7 +126,7 @@ public:
template
struct ModelUtils_T {};
- }
+ }
}
%}
@@ -144,13 +144,13 @@ namespace Space1 {
class TotalReturnSwap {
public:
TotalReturnSwap() {}
- };
+ };
template
class TotalReturnSwap_T {
public:
TotalReturnSwap_T() {}
- };
+ };
}
}
diff --git a/Examples/test-suite/constructor_exception.i b/Examples/test-suite/constructor_exception.i
index 4c867c144..e3cdc47af 100644
--- a/Examples/test-suite/constructor_exception.i
+++ b/Examples/test-suite/constructor_exception.i
@@ -1,14 +1,14 @@
%module constructor_exception
%inline %{
-class Error {
+class MyError {
};
class SomeClass {
public:
SomeClass(int x) {
if (x < 0) {
- throw Error();
+ throw MyError();
}
}
};
@@ -17,7 +17,7 @@ class Test {
SomeClass o;
public:
Test(int x) try : o(x) { }
- catch (Error &) {
+ catch (MyError &) {
}
catch (int) {
}
diff --git a/Examples/test-suite/conversion_ns_template.i b/Examples/test-suite/conversion_ns_template.i
index 0814f2a18..bddda5e7b 100644
--- a/Examples/test-suite/conversion_ns_template.i
+++ b/Examples/test-suite/conversion_ns_template.i
@@ -20,9 +20,13 @@
Bar(){ }
Bar(int){ }
+#if !defined(__SUNPRO_CC)
operator int() { return 0; }
+#endif
operator int&() { static int num = 0; return num; }
+#if !defined(__SUNPRO_CC)
operator Foo() { return Foo(); }
+#endif
operator Foo&() { return *(new Foo()); }
};
}
diff --git a/Examples/test-suite/cpp11_constexpr.i b/Examples/test-suite/cpp11_constexpr.i
index 412b8132a..d91107cc6 100644
--- a/Examples/test-suite/cpp11_constexpr.i
+++ b/Examples/test-suite/cpp11_constexpr.i
@@ -18,6 +18,12 @@ struct ConstExpressions {
static const int LLL = 300;
constexpr int MMM() { return 400; }
constexpr const 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;
+ // Regression tests for https://github.com/swig/swig/issues/284 :
+ explicit constexpr ConstExpressions(int) { }
+ constexpr explicit ConstExpressions(double) { }
};
%}
diff --git a/Examples/test-suite/cpp11_director_enums.i b/Examples/test-suite/cpp11_director_enums.i
new file mode 100644
index 000000000..420b3c8c9
--- /dev/null
+++ b/Examples/test-suite/cpp11_director_enums.i
@@ -0,0 +1,14 @@
+%module(directors="1") cpp11_director_enums
+
+%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) Cpp11DirectorEnumsCallback::g;
+
+%director Cpp11DirectorEnumsCallback;
+
+%inline %{
+enum class Color { Red, Green, Blue=10 };
+struct Cpp11DirectorEnumsCallback {
+ virtual Color f(Color c) = 0;
+ virtual const Color & g(const Color &c) = 0;
+ virtual ~Cpp11DirectorEnumsCallback() {}
+};
+%}
diff --git a/Examples/test-suite/csharp_exceptions.i b/Examples/test-suite/csharp_exceptions.i
index 0f11e7d69..e5b4d495b 100644
--- a/Examples/test-suite/csharp_exceptions.i
+++ b/Examples/test-suite/csharp_exceptions.i
@@ -198,7 +198,7 @@ enum UnmanagedExceptions {
UnmanagedSystemException,
UnmanagedArgumentException,
UnmanagedArgumentNullException,
- UnmanagedArgumentOutOfRangeException,
+ UnmanagedArgumentOutOfRangeException
};
void check_exception(UnmanagedExceptions e) {
diff --git a/Examples/test-suite/csharp_typemaps.i b/Examples/test-suite/csharp_typemaps.i
index 32e735ca7..dc5b40c02 100644
--- a/Examples/test-suite/csharp_typemaps.i
+++ b/Examples/test-suite/csharp_typemaps.i
@@ -77,17 +77,17 @@ public:
Number quadruple(Number n) {
n.Value *= 4;
return n;
-};
+}
Number times8(const Number& num) {
Number n(num);
n.Value *= 8;
return n;
-};
+}
Number times12(const Number* num) {
Number n(*num);
n.Value *= 12;
return n;
-};
+}
%}
// Test $csinput expansion
diff --git a/Examples/test-suite/default_args.i b/Examples/test-suite/default_args.i
index 839d28e3e..bcb8766a8 100644
--- a/Examples/test-suite/default_args.i
+++ b/Examples/test-suite/default_args.i
@@ -13,6 +13,27 @@
%inline %{
#include
+ // 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) {}
+
+ 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) {}
+ void seek4(unsigned long offset = 0UL) {}
+ void seek5(unsigned long offset = 0U) {}
+ void seek6(unsigned long offset = 02U) {}
+ void seek7(unsigned long offset = 00U) {}
+ void seek8(unsigned long offset = 1U) {}
+ void seek9(long offset = 1L) {}
+ void seekA(long long offset = 1LL) {}
+ void seekB(unsigned long long offset = 1ULL) {}
+
// Anonymous arguments
int anonymous(int = 7771);
int anonymous(int x) { return x; }
@@ -29,6 +50,12 @@
bool blah(speed s = FAST, flavor f = SWEET) { return (s == FAST && f == SWEET); };
};
+ // using base class enum in a derived class
+ class DerivedEnumClass : public EnumClass {
+ public:
+ void accelerate(speed s = SLOW) { }
+ };
+
// casts
const char * casts1(const char *m = (const char *) NULL) {
char *ret = NULL;
@@ -199,6 +226,7 @@ namespace Space {
struct Klass {
int val;
Klass(int val = -1) : val(val) {}
+ static Klass inc(int n = 1, const Klass& k = Klass()) { return Klass(k.val + n); }
};
Klass constructorcall(const Klass& k = Klass()) { return k; }
diff --git a/Examples/test-suite/director_frob.i b/Examples/test-suite/director_frob.i
index cf555eb66..f1d502dc2 100644
--- a/Examples/test-suite/director_frob.i
+++ b/Examples/test-suite/director_frob.i
@@ -1,6 +1,12 @@
%module(directors="1") director_frob;
#pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR
+#ifdef SWIGSCILAB
+%rename(cb) coreCallbacks;
+%rename(On3dEngRedrawn) coreCallbacksOn3dEngineRedrawnData;
+%rename (_On3dEngRedrawn) coreCallbacks_On3dEngineRedrawnData;
+#endif
+
%header %{
#include
%}
@@ -17,7 +23,7 @@
virtual ~Alpha() { };
virtual const char* abs_method() = 0;
};
-
+
struct Bravo : Alpha
{
const char* abs_method()
@@ -26,14 +32,14 @@
}
};
- struct Charlie : Bravo
+ struct Charlie : Bravo
{
const char* abs_method()
{
return "Charlie::abs_method()";
}
};
-
+
struct Delta : Charlie
{
};
@@ -50,7 +56,9 @@
public:
Ops() : num(0) {}
virtual ~Ops() {}
+#if !defined(__SUNPRO_CC)
virtual operator int() { return 0; }
+#endif
virtual operator int **() const {
return (int **) 0;
}
diff --git a/Examples/test-suite/director_overload2.i b/Examples/test-suite/director_overload2.i
index 0f3238149..e467c18ce 100644
--- a/Examples/test-suite/director_overload2.i
+++ b/Examples/test-suite/director_overload2.i
@@ -12,10 +12,14 @@ struct OverloadBase {
};
struct OverloadDerived1 : OverloadBase {
virtual void nnn(int vvv) {}
-// virtual void nnn() {}
+#if defined(__SUNPRO_CC)
+ virtual void nnn() {}
+#endif
};
struct OverloadDerived2 : OverloadBase {
-// virtual void nnn(int vvv) {}
+#if defined(__SUNPRO_CC)
+ virtual void nnn(int vvv) {}
+#endif
virtual void nnn() {}
};
%}
diff --git a/Examples/test-suite/director_property.i b/Examples/test-suite/director_property.i
index 3363c3c4f..da37ca4ae 100644
--- a/Examples/test-suite/director_property.i
+++ b/Examples/test-suite/director_property.i
@@ -7,13 +7,13 @@
class Foo {
private:
- std::string a;
+ std::string a_;
public:
virtual ~Foo() {}
virtual std::string ping() { return "Foo::ping()"; }
virtual std::string pong() { return "Foo::pong();" + ping(); }
- virtual std::string getA() { return this->a; }
- virtual void setA(std::string a) { this->a = a; }
+ virtual std::string getA() { return this->a_; }
+ virtual void setA(std::string a) { this->a_ = a; }
static Foo* get_self(Foo *slf) {return slf;}
diff --git a/Examples/test-suite/enum_forward.i b/Examples/test-suite/enum_forward.i
index c82e17be7..784f4fb02 100644
--- a/Examples/test-suite/enum_forward.i
+++ b/Examples/test-suite/enum_forward.i
@@ -8,7 +8,20 @@ enum ForwardEnum2 { CCC, DDD };
%}
%inline %{
+#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
+/* ISO C forbids forward references to ‘enum’ types [-Werror=pedantic] */
+#pragma GCC diagnostic ignored "-Wpedantic"
+#endif
+
+#if !defined(__SUNPRO_C)
enum ForwardEnum1;
+enum ForwardEnum2;
+enum ForwardEnum2;
+enum ForwardEnum3;
+#endif
+%}
+
+%inline %{
enum ForwardEnum1 get_enum1() { return AAA; }
enum ForwardEnum1 test_function1(enum ForwardEnum1 e) {
return e;
@@ -16,22 +29,25 @@ enum ForwardEnum1 test_function1(enum ForwardEnum1 e) {
%}
%inline %{
-enum ForwardEnum2;
-enum ForwardEnum2;
enum ForwardEnum2 get_enum2() { return CCC; }
enum ForwardEnum2 test_function2(enum ForwardEnum2 e) {
return e;
}
-enum ForwardEnum2;
%}
%inline %{
-enum ForwardEnum3;
enum ForwardEnum3 { EEE, FFF };
enum ForwardEnum3 get_enum3() { return EEE; }
enum ForwardEnum3 test_function3(enum ForwardEnum3 e) {
return e;
}
-enum ForwardEnum3;
%}
+
+%inline %{
+#if !defined(__SUNPRO_C)
+enum ForwardEnum2;
+enum ForwardEnum3;
+#endif
+%}
+
#endif
diff --git a/Examples/test-suite/enum_macro.i b/Examples/test-suite/enum_macro.i
index b18e02a84..c058cdf72 100644
--- a/Examples/test-suite/enum_macro.i
+++ b/Examples/test-suite/enum_macro.i
@@ -1,6 +1,13 @@
%module enum_macro
%inline %{
+
+#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
+/* comma at end of enumerator list [-Werror=pedantic] */
+#pragma GCC diagnostic ignored "-Wpedantic"
+#endif
+
+
enum Greeks1
{
#define GREEK1 -1
diff --git a/Examples/test-suite/enum_missing.i b/Examples/test-suite/enum_missing.i
index de71952e7..8a436ba36 100644
--- a/Examples/test-suite/enum_missing.i
+++ b/Examples/test-suite/enum_missing.i
@@ -14,10 +14,10 @@ enum AVPixelFormat2 {
%}
%inline %{
-typedef struct AVCodecContext {
+typedef struct AVCodecCtx {
enum AVPixelFormat pix_fmt;
enum AVPixelFormat2 pix_fmt2;
-} AVCodecContext;
+} AVCodecCtx;
enum AVPixelFormat global_fmt;
enum AVPixelFormat2 global_fmt2;
@@ -29,7 +29,7 @@ enum AVPixelFormat * use_pixel_format_ptr(enum AVPixelFormat *px) {
return px;
}
-const enum AVPixelFormat2 use_pixel_format2(const enum AVPixelFormat2 px) {
+enum AVPixelFormat2 use_pixel_format2(const enum AVPixelFormat2 px) {
return px;
}
const enum AVPixelFormat2 * use_pixel_format_ptr2(const enum AVPixelFormat2 *px) {
diff --git a/Examples/test-suite/errors/.gitignore b/Examples/test-suite/errors/.gitignore
new file mode 100644
index 000000000..22ca11947
--- /dev/null
+++ b/Examples/test-suite/errors/.gitignore
@@ -0,0 +1,4 @@
+*.newerr
+cpp_recursive_typedef.py
+cpp_shared_ptr.py
+xxx.py
diff --git a/Examples/test-suite/errors/c_extra_rblock.stderr b/Examples/test-suite/errors/c_extra_rblock.stderr
index 82877023a..be14eee4c 100644
--- a/Examples/test-suite/errors/c_extra_rblock.stderr
+++ b/Examples/test-suite/errors/c_extra_rblock.stderr
@@ -1 +1 @@
-c_extra_rblock.i:5: Error: Syntax error in input(1).
+c_extra_rblock.i:5: Error: Syntax error. Extraneous '%}'
diff --git a/Examples/test-suite/errors/c_missing_semi.stderr b/Examples/test-suite/errors/c_missing_semi.stderr
index 791b959ca..18befaa1b 100644
--- a/Examples/test-suite/errors/c_missing_semi.stderr
+++ b/Examples/test-suite/errors/c_missing_semi.stderr
@@ -1 +1 @@
-c_missing_semi.i:3: Error: Syntax error in input(1).
+c_missing_semi.i:3: Error: Syntax error - possibly a missing semicolon.
diff --git a/Examples/test-suite/errors/cpp_extra_brackets.stderr b/Examples/test-suite/errors/cpp_extra_brackets.stderr
index 12bb1f327..f1fabc78d 100644
--- a/Examples/test-suite/errors/cpp_extra_brackets.stderr
+++ b/Examples/test-suite/errors/cpp_extra_brackets.stderr
@@ -1 +1 @@
-cpp_extra_brackets.i:5: Error: Syntax error in input(3).
+cpp_extra_brackets.i:5: Error: Unexpected ')'.
diff --git a/Examples/test-suite/errors/doxygen_unknown_command.stderr b/Examples/test-suite/errors/doxygen_unknown_command.stderr
index 263d9cca2..40055ee8b 100644
--- a/Examples/test-suite/errors/doxygen_unknown_command.stderr
+++ b/Examples/test-suite/errors/doxygen_unknown_command.stderr
@@ -1 +1 @@
-doxygen_unknown_command.i:4: Warning 720: Doxygen parser warning: unknown command "unknown".
+doxygen_unknown_command.i:4: Warning 740: Doxygen parser warning: unknown command "unknown".
diff --git a/Examples/test-suite/errors/pp_missing_enddef.stderr b/Examples/test-suite/errors/pp_missing_enddef.stderr
index bb4ea3c75..c461699e6 100644
--- a/Examples/test-suite/errors/pp_missing_enddef.stderr
+++ b/Examples/test-suite/errors/pp_missing_enddef.stderr
@@ -1 +1 @@
-pp_missing_enddef.i:EOF: Error: Missing %enddef for macro starting on line 3
+pp_missing_enddef.i:3: Error: Missing %enddef for macro starting here
diff --git a/Examples/test-suite/errors/pp_missing_endif.stderr b/Examples/test-suite/errors/pp_missing_endif.stderr
index 0bbfad7f2..4db4021aa 100644
--- a/Examples/test-suite/errors/pp_missing_endif.stderr
+++ b/Examples/test-suite/errors/pp_missing_endif.stderr
@@ -1 +1 @@
-pp_missing_endif.i:EOF: Error: Missing #endif for conditional starting on line 3
+pp_missing_endif.i:3: Error: Missing #endif for conditional starting here
diff --git a/Examples/test-suite/errors/pp_missing_endoffile.i b/Examples/test-suite/errors/pp_missing_endoffile.i
new file mode 100644
index 000000000..2074495a8
--- /dev/null
+++ b/Examples/test-suite/errors/pp_missing_endoffile.i
@@ -0,0 +1,7 @@
+%module xxx
+/* %beginfile and %endoffile are internal directives inserted when %include is
+ * used. Users should never use them directly, but test coverage for this
+ * error message still seems useful to have.
+ */
+%includefile "dummy.i" %beginfile
+
diff --git a/Examples/test-suite/errors/pp_missing_endoffile.stderr b/Examples/test-suite/errors/pp_missing_endoffile.stderr
new file mode 100644
index 000000000..7269f2e92
--- /dev/null
+++ b/Examples/test-suite/errors/pp_missing_endoffile.stderr
@@ -0,0 +1 @@
+pp_missing_endoffile.i:6: Error: Missing %endoffile for file inclusion block starting here
diff --git a/Examples/test-suite/errors/pp_missing_rblock.stderr b/Examples/test-suite/errors/pp_missing_rblock.stderr
index 8f4a54c0a..f00457d73 100644
--- a/Examples/test-suite/errors/pp_missing_rblock.stderr
+++ b/Examples/test-suite/errors/pp_missing_rblock.stderr
@@ -1 +1 @@
-pp_missing_rblock.i:EOF: Error: Unterminated %{ ... %} block starting on line 3
+pp_missing_rblock.i:3: Error: Unterminated %{ ... %} block
diff --git a/Examples/test-suite/errors/pp_unknowndirective.i b/Examples/test-suite/errors/pp_unknowndirective.i
new file mode 100644
index 000000000..659a997d3
--- /dev/null
+++ b/Examples/test-suite/errors/pp_unknowndirective.i
@@ -0,0 +1,7 @@
+%module xxx
+
+/* This used to give the rather cryptic "Syntax error in input(1)." prior to
+ * SWIG 3.0.4. This testcase checks that the improved message is actually
+ * issued.
+ */
+%remane("typo") tyop;
diff --git a/Examples/test-suite/errors/pp_unknowndirective.stderr b/Examples/test-suite/errors/pp_unknowndirective.stderr
new file mode 100644
index 000000000..d0d5e249f
--- /dev/null
+++ b/Examples/test-suite/errors/pp_unknowndirective.stderr
@@ -0,0 +1 @@
+pp_unknowndirective.i:7: Error: Unknown directive '%remane'.
diff --git a/Examples/test-suite/errors/pp_unknowndirective2.i b/Examples/test-suite/errors/pp_unknowndirective2.i
new file mode 100644
index 000000000..889e6c5b2
--- /dev/null
+++ b/Examples/test-suite/errors/pp_unknowndirective2.i
@@ -0,0 +1,11 @@
+%module xxx
+
+#ifdef FOO
+long long i;
+/* Check we get an error for an unknown directive (this should be #elif).
+ * Unknown directives were silently ignored by SWIG < 3.0.3. */
+#elsif defined(BAR)
+long i;
+#else
+int i;
+#endif
diff --git a/Examples/test-suite/errors/pp_unknowndirective2.stderr b/Examples/test-suite/errors/pp_unknowndirective2.stderr
new file mode 100644
index 000000000..70afa670c
--- /dev/null
+++ b/Examples/test-suite/errors/pp_unknowndirective2.stderr
@@ -0,0 +1 @@
+pp_unknowndirective2.i:7: Error: Unknown SWIG preprocessor directive: elsif (if this is a block of target language code, delimit it with %{ and %})
diff --git a/Examples/test-suite/errors/pp_unterm_char.stderr b/Examples/test-suite/errors/pp_unterm_char.stderr
index 4386e933d..147e3859d 100644
--- a/Examples/test-suite/errors/pp_unterm_char.stderr
+++ b/Examples/test-suite/errors/pp_unterm_char.stderr
@@ -1 +1 @@
-pp_unterm_char.i:EOF: Error: Unterminated character constant starting at line 4
+pp_unterm_char.i:4: Error: Unterminated character constant
diff --git a/Examples/test-suite/errors/pp_unterm_comment.stderr b/Examples/test-suite/errors/pp_unterm_comment.stderr
index 4ff34230c..ab1edac14 100644
--- a/Examples/test-suite/errors/pp_unterm_comment.stderr
+++ b/Examples/test-suite/errors/pp_unterm_comment.stderr
@@ -1 +1 @@
-pp_unterm_comment.i:EOF: Error: Unterminated comment starting on line 3
+pp_unterm_comment.i:3: Error: Unterminated comment
diff --git a/Examples/test-suite/errors/pp_unterm_string.stderr b/Examples/test-suite/errors/pp_unterm_string.stderr
index 16b4034f3..14e110ebb 100644
--- a/Examples/test-suite/errors/pp_unterm_string.stderr
+++ b/Examples/test-suite/errors/pp_unterm_string.stderr
@@ -1 +1 @@
-pp_unterm_string.i:EOF: Error: Unterminated string constant starting at line 4
+pp_unterm_string.i:4: Error: Unterminated string constant
diff --git a/Examples/test-suite/errors/pp_unterminated_block.i b/Examples/test-suite/errors/pp_unterminated_block.i
new file mode 100644
index 000000000..99f5f0bc2
--- /dev/null
+++ b/Examples/test-suite/errors/pp_unterminated_block.i
@@ -0,0 +1,5 @@
+%module xxx
+
+%{
+int foo(int x);
+
diff --git a/Examples/test-suite/errors/pp_unterminated_block.stderr b/Examples/test-suite/errors/pp_unterminated_block.stderr
new file mode 100644
index 000000000..03c16a45f
--- /dev/null
+++ b/Examples/test-suite/errors/pp_unterminated_block.stderr
@@ -0,0 +1 @@
+pp_unterminated_block.i:3: Error: Unterminated %{ ... %} block
diff --git a/Examples/test-suite/extend_special_variables.i b/Examples/test-suite/extend_special_variables.i
index 9a453597a..1f218a8b9 100644
--- a/Examples/test-suite/extend_special_variables.i
+++ b/Examples/test-suite/extend_special_variables.i
@@ -28,7 +28,10 @@ namespace Space {
%extend Space::ExtendTemplate
{
- void extending() { $parentclassname tmp; }
+ void extending() {
+ $parentclassname tmp;
+ (void)tmp;
+ }
}
%template(ExtendTemplateInt) Space::ExtendTemplate;
diff --git a/Examples/test-suite/go/contract_runme.go b/Examples/test-suite/go/contract_runme.go
index d86110be2..b20a1a64f 100644
--- a/Examples/test-suite/go/contract_runme.go
+++ b/Examples/test-suite/go/contract_runme.go
@@ -196,13 +196,13 @@ func main() {
}()
//Namespace
- my := contract.NewMyClass(1)
+ contract.NewMyClass(1)
func() {
defer func() {
if recover() == nil {
panic("Failed! constructor preassertion")
}
}()
- my = contract.NewMyClass(0)
+ contract.NewMyClass(0)
}()
}
diff --git a/Examples/test-suite/java/constant_directive_runme.java b/Examples/test-suite/java/constant_directive_runme.java
new file mode 100644
index 000000000..b5135a499
--- /dev/null
+++ b/Examples/test-suite/java/constant_directive_runme.java
@@ -0,0 +1,22 @@
+import constant_directive.*;
+
+public class constant_directive_runme {
+
+ static {
+ try {
+ System.loadLibrary("constant_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[]) {
+ if (constant_directive.TYPE1_CONSTANT1.getVal() != 1)
+ throw new RuntimeException("fail");
+ if (constant_directive.TYPE1_CONSTANT2.getVal() != 2)
+ throw new RuntimeException("fail");
+ if (constant_directive.TYPE1_CONSTANT3.getVal() != 3)
+ throw new RuntimeException("fail");
+ }
+}
diff --git a/Examples/test-suite/java/nested_template_base_runme.java b/Examples/test-suite/java/nested_template_base_runme.java
new file mode 100644
index 000000000..8404afe04
--- /dev/null
+++ b/Examples/test-suite/java/nested_template_base_runme.java
@@ -0,0 +1,27 @@
+import nested_template_base.*;
+
+public class nested_template_base_runme {
+
+ static {
+ try {
+ System.loadLibrary("nested_template_base");
+ } 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[]) {
+ OuterC.InnerS ois = new OuterC.InnerS(123);
+ OuterC.InnerC oic = new OuterC.InnerC();
+
+ // Check base method is available
+ if (oic.outer(ois).getVal() != 123)
+ throw new RuntimeException("Wrong value calling outer");
+
+ // Check non-derived class using base class
+ if (oic.innerc().outer(ois).getVal() != 123)
+ throw new RuntimeException("Wrong value calling innerc");
+
+ }
+}
diff --git a/Examples/test-suite/java/preproc_line_file_runme.java b/Examples/test-suite/java/preproc_line_file_runme.java
index 7726b613b..e38ce0efd 100644
--- a/Examples/test-suite/java/preproc_line_file_runme.java
+++ b/Examples/test-suite/java/preproc_line_file_runme.java
@@ -63,7 +63,7 @@ public class preproc_line_file_runme {
if (SillyMacroClass.LINE_NUM != 56)
throw new RuntimeException("preproc failure");
- if (SillyMultipleMacroStruct.LINE_NUM != 81)
+ if (SillyMulMacroStruc.LINE_NUM != 81)
throw new RuntimeException("preproc failure");
if (preproc_line_file.INLINE_LINE != 87)
diff --git a/Examples/test-suite/java/smart_pointer_const_overload_runme.java b/Examples/test-suite/java/smart_pointer_const_overload_runme.java
index bb4ae2c8f..9c10dedb2 100644
--- a/Examples/test-suite/java/smart_pointer_const_overload_runme.java
+++ b/Examples/test-suite/java/smart_pointer_const_overload_runme.java
@@ -41,7 +41,7 @@ public class smart_pointer_const_overload_runme {
Assert(f.getAccess() == MUTABLE_ACCESS);
// Test static method
- b.stat();
+ b.statMethod();
Assert(f.getAccess() == CONST_ACCESS);
diff --git a/Examples/test-suite/java/template_default_class_parms_runme.java b/Examples/test-suite/java/template_default_class_parms_runme.java
index 406915b82..0a6571fa8 100644
--- a/Examples/test-suite/java/template_default_class_parms_runme.java
+++ b/Examples/test-suite/java/template_default_class_parms_runme.java
@@ -45,6 +45,11 @@ public class template_default_class_parms_runme {
foo.setTType(a);
a = foo.method(a);
}
+
+ {
+ MapDefaults md = new MapDefaults();
+ md.test_func(10, 20, new DefaultNodeType());
+ }
}
}
diff --git a/Examples/test-suite/javascript/Makefile.in b/Examples/test-suite/javascript/Makefile.in
index b0fd82c25..83b15f822 100644
--- a/Examples/test-suite/javascript/Makefile.in
+++ b/Examples/test-suite/javascript/Makefile.in
@@ -6,6 +6,8 @@ LANGUAGE = javascript
NODEGYP = @NODEGYP@
NODEJS = @NODEJS@
SCRIPTSUFFIX = _runme.js
+OBJEXT = @OBJEXT@
+SO = @SO@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
@@ -116,10 +118,10 @@ endif
%.clean:
@rm -rf $*
- @rm -f $*_wrap.* $*.so $*.o
+ @rm -f $*_wrap.* $*$(SO) $*.$(OBJEXT)
clean:
- for ext in _wrap.cxx _wrap.o .so; do \
+ for ext in _wrap.cxx _wrap.$(OBJEXT) $(SO); do \
rm -f clientdata_prop_a$${ext} clientdata_prop_b$${ext}; \
rm -f imports_a$${ext} imports_b$${ext}; \
rm -f import_stl_a$${ext} import_stl_b$${ext}; \
diff --git a/Examples/test-suite/kwargs_feature.i b/Examples/test-suite/kwargs_feature.i
index a935b25f3..a8d1c38d8 100644
--- a/Examples/test-suite/kwargs_feature.i
+++ b/Examples/test-suite/kwargs_feature.i
@@ -79,9 +79,9 @@
static const size_type hello = 3;
};
- int rfoo( const size_type& x = Hello::hello, const Hello& y = Hello() )
+ int rfoo( int n = 0, const size_type& x = Hello::hello, const Hello& y = Hello() )
{
- return x;
+ return n - x;
}
%}
%{
diff --git a/Examples/test-suite/li_attribute_template.i b/Examples/test-suite/li_attribute_template.i
index 3d4c108ef..28551c2cf 100644
--- a/Examples/test-suite/li_attribute_template.i
+++ b/Examples/test-suite/li_attribute_template.i
@@ -27,38 +27,38 @@
struct C
{
C(int a, int b, int c) :
- _a(a), _b(b), _c(c), _d(a), _e(b),
+ a(a), b(b), c(c), d(a), _e(b),
_f(a,b), _g(b,c)
{
/*
- _f.first = _a;
- _f.second = _b;
+ _f.first = a;
+ _f.second = b;
- _g.first = _b;
- _g.second = _c;
+ _g.first = b;
+ _g.second = c;
*/
}
int get_value() const
{
- return _a;
+ return a;
}
void set_value(int aa)
{
- _a = aa;
+ a = aa;
}
/* only one ref method */
int& get_ref()
{
- return _b;
+ return b;
}
- Foo get_class_value() const { return _d; }
- void set_class_value( Foo foo) { _d = foo; }
+ Foo get_class_value() const { return d; }
+ void set_class_value( Foo foo) { d = foo; }
const Foo& get_class_ref() const { return _e; }
void set_class_ref( const Foo& foo ) { _e = foo; }
@@ -73,10 +73,10 @@
void set_string(std::string other) { str = other; }
private:
- int _a;
- int _b;
- int _c;
- Foo _d;
+ int a;
+ int b;
+ int c;
+ Foo d;
Foo _e;
pair _f;
pair _g;
diff --git a/Examples/test-suite/li_boost_shared_ptr.i b/Examples/test-suite/li_boost_shared_ptr.i
index 3d474ec00..25ca6039b 100644
--- a/Examples/test-suite/li_boost_shared_ptr.i
+++ b/Examples/test-suite/li_boost_shared_ptr.i
@@ -1,7 +1,7 @@
// This tests shared_ptr is working okay. It also checks that there are no memory leaks in the
// class that shared_ptr is pointing via a counting mechanism in the constructors and destructor of Klass.
// In order to test that there are no leaks of the shared_ptr class itself (as it is created on the heap)
-// the runtime tests can be run for a long time to monitor memory leaks using memory monitor tools
+// the runtime tests can be run for a long time to monitor memory leaks using memory monitor tools
// like 'top'. There is a wrapper for shared_ptr in shared_ptr_wrapper.h which enables one to
// count the instances of shared_ptr. Uncomment the SHARED_PTR_WRAPPER macro to turn this on.
//
@@ -11,6 +11,16 @@
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK);
+#if defined(SWIGSCILAB)
+%rename(MbrVar) MemberVariables;
+%rename(MbrVal) MemberVariables::MemberValue;
+%rename(MbrPtr) MemberVariables::MemberPointer;
+%rename(MbrRef) MemberVariables::MemberReference;
+%rename(SmartMbrVal) MemberVariables::SmartMemberValue;
+%rename(SmartMbrPtr) MemberVariables::SmartMemberPointer;
+%rename(SmartMbrRef) MemberVariables::SmartMemberReference;
+#endif
+
%inline %{
#include "boost/shared_ptr.hpp"
#include "swig_examples_lock.h"
@@ -34,7 +44,7 @@
# define SWIG_SHARED_PTR_NAMESPACE SwigBoost
#endif
-#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD)
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGOCTAVE)
#define SHARED_PTR_WRAPPERS_IMPLEMENTED
#endif
@@ -93,7 +103,7 @@ struct Klass {
static int getTotal_count() { return total_count; }
private:
- // lock increment and decrement as a destructor could be called at the same time as a
+ // lock increment and decrement as a destructor could be called at the same time as a
// new object is being created - C# / Java, at least, have finalizers run in a separate thread
static SwigExamples::CriticalSection critical_section;
static void increment() { SwigExamples::Lock lock(critical_section); total_count++; if (debug_shared) cout << " ++xxxxx Klass::increment tot: " << total_count << endl;}
@@ -104,15 +114,15 @@ private:
};
SwigExamples::CriticalSection Space::Klass::critical_section;
-struct IgnoredMultipleInheritBase {
+struct IgnoredMultipleInheritBase {
IgnoredMultipleInheritBase() : d(0.0), e(0.0) {}
- virtual ~IgnoredMultipleInheritBase() {}
- double d;
+ virtual ~IgnoredMultipleInheritBase() {}
+ double d;
double e;
- virtual void AVirtualMethod() {}
+ virtual void AVirtualMethod() {}
};
-// For most compilers, this use of multiple inheritance results in different derived and base class
+// For most compilers, this use of multiple inheritance results in different derived and base class
// pointer values ... for some more challenging tests :)
struct KlassDerived : IgnoredMultipleInheritBase, Klass {
KlassDerived() : Klass() {}
@@ -254,7 +264,7 @@ long use_count(const SwigBoost::shared_ptr& sptr) {
long use_count(const SwigBoost::shared_ptr& sptr) {
return sptr.use_count();
}
-const SwigBoost::shared_ptr& ref_1() {
+const SwigBoost::shared_ptr& ref_1() {
static SwigBoost::shared_ptr sptr;
return sptr;
}
@@ -334,7 +344,11 @@ template struct Base {
};
%}
+#if !defined(SWIGSCILAB)
%template(BaseIntDouble) Base;
+#else
+%template(BaseIDbl) Base;
+#endif
%inline %{
template struct Pair : Base {
@@ -356,9 +370,9 @@ SwigBoost::shared_ptr< Pair > pair_id1(SwigBoost::shared_ptr< Pair<
%inline %{
namespace SwigBoost {
const int NOT_COUNTING = -123456;
- int shared_ptr_wrapper_count() {
+ int shared_ptr_wrapper_count() {
#ifdef SHARED_PTR_WRAPPER
- return SwigBoost::SharedPtrWrapper::getTotalCount();
+ return SwigBoost::SharedPtrWrapper::getTotalCount();
#else
return NOT_COUNTING;
#endif
diff --git a/Examples/test-suite/li_std_auto_ptr.i b/Examples/test-suite/li_std_auto_ptr.i
index 627572d5c..5fdc5fa35 100644
--- a/Examples/test-suite/li_std_auto_ptr.i
+++ b/Examples/test-suite/li_std_auto_ptr.i
@@ -1,7 +1,7 @@
%module li_std_auto_ptr
%{
-#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
+#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" // auto_ptr deprecation
#endif
%}
diff --git a/Examples/test-suite/li_std_combinations.i b/Examples/test-suite/li_std_combinations.i
index 57f945bcd..e28950835 100644
--- a/Examples/test-suite/li_std_combinations.i
+++ b/Examples/test-suite/li_std_combinations.i
@@ -9,15 +9,23 @@
%template(PairIntString) std::pair;
%template(VectorPairIntString) std::vector< std::pair >;
-%template(PairIntVectorString) std::pair< int, std::vector >;
-
%template(VectorVectorString) std::vector< std::vector >;
+
+#if !defined(SWIGSCILAB)
+%template(PairIntVectorString) std::pair< int, std::vector >;
%template(PairIntPairIntString) std::pair< int, std::pair >;
+#else
+%template(PairIntVecStr) std::pair< int, std::vector >;
+%template(PairIntPairIntStr) std::pair< int, std::pair >;
+#endif
+
#if defined(SWIGCSHARP) || defined(SWIGD)
// Checks macro containing a type with a comma
SWIG_STD_VECTOR_ENHANCED(std::pair< double, std::string >)
#endif
+
%template(PairDoubleString) std::pair< double, std::string >;
%template(VectorPairDoubleString) std::vector< std::pair >;
+
diff --git a/Examples/test-suite/li_std_container_typemaps.i b/Examples/test-suite/li_std_container_typemaps.i
new file mode 100644
index 000000000..9da32ef8d
--- /dev/null
+++ b/Examples/test-suite/li_std_container_typemaps.i
@@ -0,0 +1,132 @@
+%module li_std_container_typemaps
+
+%include stl.i
+%include std_list.i
+%include std_deque.i
+%include std_set.i
+%include std_multiset.i
+
+%{
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+
+using namespace std;
+%}
+
+%inline %{
+class ClassA
+{
+public:
+ ClassA() : a(0) {}
+ ClassA(int _a) : a(_a) {}
+ ClassA(const ClassA& c) : a(c.a) {}
+ int a;
+};
+
+typedef ClassA* ClassAPtr;
+
+enum _Color { RED=1, GREEN=10, YELLOW=11, BLUE=100, MAGENTA=101, CYAN=111 };
+typedef enum _Color Color;
+
+namespace std {
+ template T binaryOperation(T x, T y) {
+ return static_cast(x + y);
+ }
+
+ template<> bool binaryOperation(bool x, bool y) {
+ return x | y;
+ }
+
+ template<> ClassAPtr binaryOperation(ClassAPtr x, ClassAPtr y) {
+ if (x)
+ y->a += x->a;
+ return y;
+ }
+
+ template
+ struct sequence_container {
+ typedef typename SeqCont::value_type value_type;
+
+ static SeqCont ret_container(const value_type value1, const value_type value2) {
+ SeqCont s;
+ s.insert(s.end(), value1);
+ s.insert(s.end(), value2);
+ return s;
+ }
+
+ static value_type val_container(const SeqCont container) {
+ return std::accumulate(container.begin(), container.end(), value_type(),
+ binaryOperation);
+ }
+
+ static value_type ref_container(const SeqCont& container) {
+ return std::accumulate(container.begin(), container.end(), value_type(),
+ binaryOperation);
+ }
+ };
+
+ template
+ Container ret_container(const T value1, const T value2) {
+ return sequence_container::ret_container(value1, value2);
+ }
+ template
+ T val_container(const Container container) {
+ return sequence_container::val_container(container);
+ }
+ template
+ T ref_container(const Container& container) {
+ return sequence_container::ref_container(container);
+ }
+}
+%}
+
+%define %instantiate_containers_templates(TYPE...)
+namespace std
+{
+ %template(TYPE ## _vector) std::vector;
+ %template(TYPE ## _list) std::list;
+ %template(TYPE ## _deque) std::deque;
+ %template(TYPE ## _set) std::set;
+ %template(TYPE ## _multiset) std::multiset;
+}
+%enddef
+
+%define %instantiate_containers_functions(TYPE...)
+namespace std
+{
+ %template(ret_ ## TYPE ## _vector) ret_container >;
+ %template(val_ ## TYPE ## _vector) val_container >;
+ %template(ref_ ## TYPE ## _vector) ref_container >;
+ %template(ret_ ## TYPE ## _list) ret_container >;
+ %template(val_ ## TYPE ## _list) val_container >;
+ %template(ref_ ## TYPE ## _list) ref_container >;
+ %template(ret_ ## TYPE ## _deque) ret_container >;
+ %template(val_ ## TYPE ## _deque) val_container >;
+ %template(ref_ ## TYPE ## _deque) ref_container >;
+ %template(ret_ ## TYPE ## _set) ret_container >;
+ %template(val_ ## TYPE ## _set) val_container >;
+ %template(ref_ ## TYPE ## _set) ref_container >;
+ %template(ret_ ## TYPE ## _multiset) ret_container >;
+ %template(val_ ## TYPE ## _multiset) val_container >;
+ %template(ref_ ## TYPE ## _multiset) ref_container >;
+}
+%enddef
+
+%define %instantiate_containers_templates_and_functions(TYPE...)
+ %instantiate_containers_templates(TYPE);
+ %instantiate_containers_functions(TYPE);
+%enddef
+
+%instantiate_containers_templates_and_functions(int);
+%instantiate_containers_templates_and_functions(double);
+%instantiate_containers_templates_and_functions(float);
+%instantiate_containers_templates_and_functions(bool);
+%instantiate_containers_templates_and_functions(string);
+%instantiate_containers_templates_and_functions(ClassAPtr);
diff --git a/Examples/test-suite/li_std_string.i b/Examples/test-suite/li_std_string.i
index 2d0b7503d..a1a55ed85 100644
--- a/Examples/test-suite/li_std_string.i
+++ b/Examples/test-suite/li_std_string.i
@@ -83,6 +83,16 @@ void test_const_pointer_throw() throw(const std::string *) {
std::string *Structure::StaticMemberString2 };
*/
+#ifdef SWIGSCILAB
+%rename(St) MemberString;
+%rename(Str) MemberString;
+%rename(Str2) MemberString2;
+%rename(StaticStr) StaticMemberString;
+%rename(StaticStr2) StaticMemberString2;
+%rename(ConstStr) ConstMemberString;
+%rename(ConstStaticStr) ConstStaticMemberString;
+#endif
+
%inline %{
std::string GlobalString;
std::string GlobalString2 = "global string 2";
diff --git a/Examples/test-suite/li_std_vector_extra.i b/Examples/test-suite/li_std_vector_extra.i
index 114de3f11..531898a0e 100644
--- a/Examples/test-suite/li_std_vector_extra.i
+++ b/Examples/test-suite/li_std_vector_extra.i
@@ -12,6 +12,17 @@
#include
#include
#include
+
+
+#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 {
diff --git a/Examples/test-suite/li_stdint.i b/Examples/test-suite/li_stdint.i
index 518679934..91017aa29 100644
--- a/Examples/test-suite/li_stdint.i
+++ b/Examples/test-suite/li_stdint.i
@@ -3,7 +3,7 @@
%include
%inline %{
- struct StdInts {
+ struct StdI {
int8_t int8_member;
int16_t int16_member;
int32_t int32_member;
@@ -23,7 +23,7 @@
uint32_t uint32_td(int32_t i) { return i; }
uint64_t uint64_td(int64_t i) { return i; }
- struct StdIntFasts {
+ struct StdIf {
int_fast8_t int_fast8_member;
int_fast16_t int_fast16_member;
int_fast32_t int_fast32_member;
@@ -43,7 +43,7 @@
uint_fast32_t uint_fast32_td(int_fast32_t i) { return i; }
uint_fast64_t uint_fast64_td(int_fast64_t i) { return i; }
- struct StdIntLeasts {
+ struct StdIl {
int_least8_t int_least8_member;
int_least16_t int_least16_member;
int_least32_t int_least32_member;
diff --git a/Examples/test-suite/li_swigtype_inout.i b/Examples/test-suite/li_swigtype_inout.i
index 9d7e9a4c6..136c9fa9e 100644
--- a/Examples/test-suite/li_swigtype_inout.i
+++ b/Examples/test-suite/li_swigtype_inout.i
@@ -13,28 +13,28 @@
#include
struct XXX {
XXX(int v) : value(v) {
- if (debug) std::cout << "Default Constructor " << value << " " << this << std::endl;
+ if (debugging) std::cout << "Default Constructor " << value << " " << this << std::endl;
count++;
}
XXX(const XXX &other) {
value = other.value;
- if (debug) std::cout << "Copy Constructor " << value << " " << this << std::endl;
+ if (debugging) std::cout << "Copy Constructor " << value << " " << this << std::endl;
count++;
}
XXX& operator=(const XXX &other) {
value = other.value;
- if (debug) std::cout << "Assignment operator " << value << " " << this << std::endl;
+ if (debugging) std::cout << "Assignment operator " << value << " " << this << std::endl;
return *this;
}
~XXX() {
- if (debug) std::cout << "Destructor " << value << " " << this << std::endl;
+ if (debugging) std::cout << "Destructor " << value << " " << this << std::endl;
count--;
}
void showInfo() {
- if (debug) std::cout << "Info " << value << " " << this << std::endl;
+ if (debugging) std::cout << "Info " << value << " " << this << std::endl;
}
int value;
- static const bool debug = false;
+ static const bool debugging = false;
static int count;
};
int XXX::count = 0;
diff --git a/Examples/test-suite/nested.i b/Examples/test-suite/nested.i
index 004cb4814..1d4710128 100644
--- a/Examples/test-suite/nested.i
+++ b/Examples/test-suite/nested.i
@@ -1,4 +1,4 @@
-/*
+/*
This testcase tests that nested structs/unions work. Named structs/unions declared within
a struct produced redefinition errors in SWIG 1.3.6 as reported by SF bug #447488.
Also tests reported error when a #define placed in a deeply embedded struct/union.
@@ -6,6 +6,13 @@ Also tests reported error when a #define placed in a deeply embedded struct/unio
%module nested
+
+#if defined(SWIGSCILAB)
+%rename(OutStNamed) OuterStructNamed;
+%rename(InStNamed) OuterStructNamed::InnerStructNamed;
+%rename(InUnNamed) OuterStructNamed::Inner_union_named;
+#endif
+
%inline %{
struct TestStruct {
@@ -22,6 +29,13 @@ struct OuterStructNamed {
} inner_union_named;
};
+%}
+
+
+#if !defined(SWIGSCILAB)
+
+%inline %{
+
struct OuterStructUnnamed {
struct {
double xx;
@@ -32,7 +46,6 @@ struct OuterStructUnnamed {
} inner_union_unnamed;
};
-
typedef struct OuterStruct {
union {
@@ -52,3 +65,41 @@ typedef struct OuterStruct {
} OuterStruct;
%}
+
+#else
+
+%inline %{
+
+struct OutStUnnamed {
+ struct {
+ double xx;
+ } inSt;
+ union {
+ double yy;
+ int zz;
+ } inUn;
+};
+
+typedef struct OutSt {
+ union {
+
+ struct nst_st {
+ union in_un {
+#define BAD_STYLE 1
+ int red;
+ struct TestStruct green;
+ } InUn;
+
+ struct in_st {
+ int blue;
+ } InSt;
+ } NstdSt;
+
+ } EmbedUn;
+} OutSt;
+
+%}
+
+#endif
+
+
diff --git a/Examples/test-suite/nested_class.i b/Examples/test-suite/nested_class.i
index ccb7ecac1..ebfc65f3d 100644
--- a/Examples/test-suite/nested_class.i
+++ b/Examples/test-suite/nested_class.i
@@ -1,5 +1,33 @@
%module nested_class
+
+#if defined(SWIGSCILAB)
+%rename(Out) Outer;
+%rename(InSt1) InnerStruct1;
+%rename(InCls1) InnerClass1;
+%rename(InCls2) InnerClass2;
+%rename(InClas3Inst) InnerClass3Instance;
+%rename(InSt3Inst) InnerStruct3Instance;
+%rename(InCls4Type) InnerClass4Typedef;
+%rename(InSt4Type) InnerStruct4Typedef;
+%rename(InCls5Type) InnerClass5Typedef;
+%rename(InSt5Type) InnerStruct5Typedef;
+%rename(InMul) InnerMultiple;
+%rename(InMulDrv) InnerMultipleDerived;
+%rename(MulInst1) MultipleInstance1;
+%rename(MulInst2) MultipleInstance2;
+%rename(MulInst3) MultipleInstance3;
+%rename(MulInst4) MultipleInstance4;
+%rename(MulDrvInst1) MultipleDerivedInstance1;
+%rename(MulDrvInst2) MultipleDerivedInstance2;
+%rename(MulDrvInst3) MultipleDerivedInstance3;
+%rename(MulDrvInst4) MultipleDerivedInstance4;
+%rename(MulInstAnnDrv1) MultipleInstanceAnonDerived1;
+%rename(MulInstAnnDrv2) MultipleInstanceAnonDerived2;
+%rename(MulInstAnnDrv3) MultipleInstanceAnonDerived3;
+%rename(MulInstAnnDrv4) MultipleInstanceAnonDerived4;
+#endif
+
#pragma SWIG nowarn=SWIGWARN_PARSE_UNNAMED_NESTED_CLASS
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerStruct1;
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerClass1;
@@ -21,6 +49,12 @@
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer2::IgnoreMe;
%inline %{
+
+#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
+/* ISO C++ prohibits anonymous structs [-Werror=pedantic] */
+#pragma GCC diagnostic ignored "-Wpedantic"
+#endif
+
struct Outer {
typedef int Integer;
///////////////////////////////////////////
@@ -49,6 +83,9 @@ struct Outer {
struct {
Integer b;
};
+#else
+ Integer a;
+ Integer b;
#endif
union {
@@ -164,6 +201,9 @@ struct Outer {
public:
Integer yy;
};
+#else
+ Integer xx;
+ Integer yy;
#endif
///////////////////////////////////////////
diff --git a/Examples/test-suite/nested_extend_c.i b/Examples/test-suite/nested_extend_c.i
index 64727b9ea..8fde075a4 100644
--- a/Examples/test-suite/nested_extend_c.i
+++ b/Examples/test-suite/nested_extend_c.i
@@ -95,7 +95,7 @@ typedef struct {
} bar;
} FOO;
-struct {
+static struct {
int i;
} THING;
%}
diff --git a/Examples/test-suite/nested_scope.i b/Examples/test-suite/nested_scope.i
index b1515f77f..bd66eec73 100644
--- a/Examples/test-suite/nested_scope.i
+++ b/Examples/test-suite/nested_scope.i
@@ -26,39 +26,42 @@ namespace ns {
#endif
};
}
-#ifndef __clang__
class Outer1 {
struct Nested1;
public:
struct Nested2;
- template class Abstract;
+#ifdef __clang__
+ struct Nested2 {
+ int data;
+ };
+#endif
+ template class AbstractClass;
class Real;
};
+#ifndef __clang__
struct Outer1::Nested2 {
int data;
};
+#endif
- class Class {
+ class Klass {
public:
- template class Abstract;
+ template class AbstractClass;
class Real;
};
- template class Class::Abstract {
+ template class Klass::AbstractClass {
public:
virtual void Method() = 0;
+ virtual ~AbstractClass() {}
};
-#endif
%}
-#ifndef __clang__
- %template(abstract_int) Class::Abstract ;
-#endif
+
+%template(abstract_int) Klass::AbstractClass ;
+
%inline %{
-#ifndef __clang__
- class Class::Real : public Abstract {
+ class Klass::Real : public AbstractClass {
public:
virtual void Method() {}
};
-#endif
-
%}
diff --git a/Examples/test-suite/nested_template_base.i b/Examples/test-suite/nested_template_base.i
new file mode 100644
index 000000000..0b0272224
--- /dev/null
+++ b/Examples/test-suite/nested_template_base.i
@@ -0,0 +1,38 @@
+%module nested_template_base
+
+%inline %{
+ template class OuterT {
+ public:
+ T outer(T t) { return t; }
+ };
+%}
+
+// The %template goes after OuterT and before OuterC as OuterC::InnerC's base is handled inside OuterC
+%template(OuterTInnerS) OuterT;
+
+#if !defined(SWIGCSHARP) && !defined(SWIGJAVA)
+%feature("flatnested") OuterC::InnerS;
+%feature("flatnested") OuterC::InnerC;
+#endif
+
+
+%inline %{
+ class OuterC {
+ public:
+ struct InnerS;
+ class InnerC;
+ };
+
+ struct OuterC::InnerS {
+ int val;
+ InnerS(int val = 0) : val(val) {}
+ };
+
+
+ class OuterC::InnerC : public OuterT {
+ public:
+ OuterT& innerc() {
+ return *this;
+ }
+ };
+%}
diff --git a/Examples/test-suite/octave/li_boost_shared_ptr_runme.m b/Examples/test-suite/octave/li_boost_shared_ptr_runme.m
new file mode 100644
index 000000000..a9f4a82c0
--- /dev/null
+++ b/Examples/test-suite/octave/li_boost_shared_ptr_runme.m
@@ -0,0 +1,566 @@
+1;
+li_boost_shared_ptr;
+
+function verifyValue(expected, got)
+ if (expected ~= got)
+ error("verify value failed.");% Expected: ", expected, " Got: ", got)
+ end
+endfunction
+
+function verifyCount(expected, k)
+ got = use_count(k);
+ if (expected ~= got)
+ error("verify use_count failed. Expected: %d Got: %d ", expected, got);
+ end
+endfunction
+
+function runtest()
+ li_boost_shared_ptr; # KTTODO this needs to be here at present. Global module failure?
+ # simple shared_ptr usage - created in C++
+ k = Klass("me oh my");
+ val = k.getValue();
+ verifyValue("me oh my", val)
+ verifyCount(1, k)
+
+ # simple shared_ptr usage - not created in C++
+ k = factorycreate();
+ val = k.getValue();
+ verifyValue("factorycreate", val)
+ verifyCount(1, k)
+
+ # pass by shared_ptr
+ k = Klass("me oh my");
+ kret = smartpointertest(k);
+ val = kret.getValue();
+ verifyValue("me oh my smartpointertest", val)
+ verifyCount(2, k)
+ verifyCount(2, kret)
+
+ # pass by shared_ptr pointer
+ k = Klass("me oh my");
+ kret = smartpointerpointertest(k);
+ val = kret.getValue();
+ verifyValue("me oh my smartpointerpointertest", val)
+ verifyCount(2, k)
+ verifyCount(2, kret)
+
+ # pass by shared_ptr reference
+ k = Klass("me oh my");
+ kret = smartpointerreftest(k);
+ val = kret.getValue();
+ verifyValue("me oh my smartpointerreftest", val)
+ verifyCount(2, k)
+ verifyCount(2, kret)
+
+ # pass by shared_ptr pointer reference
+ k = Klass("me oh my");
+ kret = smartpointerpointerreftest(k);
+ val = kret.getValue();
+ verifyValue("me oh my smartpointerpointerreftest", val)
+ verifyCount(2, k)
+ verifyCount(2, kret)
+
+ # const pass by shared_ptr
+ k = Klass("me oh my");
+ kret = constsmartpointertest(k);
+ val = kret.getValue();
+ verifyValue("me oh my", val)
+ verifyCount(2, k)
+ verifyCount(2, kret)
+
+ # const pass by shared_ptr pointer
+ k = Klass("me oh my");
+ kret = constsmartpointerpointertest(k);
+ val = kret.getValue();
+ verifyValue("me oh my", val)
+ verifyCount(2, k)
+ verifyCount(2, kret)
+
+ # const pass by shared_ptr reference
+ k = Klass("me oh my");
+ kret = constsmartpointerreftest(k);
+ val = kret.getValue();
+ verifyValue("me oh my", val)
+ verifyCount(2, k)
+ verifyCount(2, kret)
+
+ # pass by value
+ k = Klass("me oh my");
+ kret = valuetest(k);
+ val = kret.getValue();
+ verifyValue("me oh my valuetest", val)
+ verifyCount(1, k)
+ verifyCount(1, kret)
+
+ # pass by pointer
+ k = Klass("me oh my");
+ kret = pointertest(k);
+ val = kret.getValue();
+ verifyValue("me oh my pointertest", val)
+ verifyCount(1, k)
+ verifyCount(1, kret)
+
+ # pass by reference
+ k = Klass("me oh my");
+ kret = reftest(k);
+ val = kret.getValue();
+ verifyValue("me oh my reftest", val)
+ verifyCount(1, k)
+ verifyCount(1, kret)
+
+ # pass by pointer reference
+ k = Klass("me oh my");
+ kret = pointerreftest(k);
+ val = kret.getValue();
+ verifyValue("me oh my pointerreftest", val)
+ verifyCount(1, k)
+ verifyCount(1, kret)
+
+ # null tests
+ #KTODO None not defined
+ # k = None;
+
+ # if (smartpointertest(k) ~= None)
+ # error("return was not null")
+ # end
+
+ # if (smartpointerpointertest(k) ~= None)
+ # error("return was not null")
+ # end
+
+ # if (smartpointerreftest(k) ~= None)
+ # error("return was not null")
+ # end
+
+ # if (smartpointerpointerreftest(k) ~= None)
+ # error("return was not null")
+ # end
+
+ # if (nullsmartpointerpointertest(None) ~= "null pointer")
+ # error("not null smartpointer pointer")
+ # end
+
+ # # try:
+ # # valuetest(k)
+ # # error("Failed to catch null pointer")
+ # # except ValueError:
+ # # pass
+
+ # if (pointertest(k) ~= None)
+ # error("return was not null")
+ # end
+
+ # # try:
+ # # reftest(k)
+ # # error("Failed to catch null pointer")
+ # # except ValueError:
+ # # pass
+
+ # $owner
+ k = pointerownertest();
+ val = k.getValue();
+ verifyValue("pointerownertest", val)
+ verifyCount(1, k)
+ k = smartpointerpointerownertest();
+ val = k.getValue();
+ verifyValue("smartpointerpointerownertest", val)
+ verifyCount(1, k)
+
+ # //////////////////////////////// Derived class ////////////////////////////////////////
+ # derived pass by shared_ptr
+ k = KlassDerived("me oh my");
+ kret = derivedsmartptrtest(k);
+ val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrtest-Derived", val)
+ verifyCount(2, k)
+ verifyCount(2, kret)
+
+ # derived pass by shared_ptr pointer
+ k = KlassDerived("me oh my");
+ kret = derivedsmartptrpointertest(k);
+ val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrpointertest-Derived", val)
+ verifyCount(2, k)
+ verifyCount(2, kret)
+
+ # derived pass by shared_ptr ref
+ k = KlassDerived("me oh my");
+ kret = derivedsmartptrreftest(k);
+ val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrreftest-Derived", val)
+ verifyCount(2, k)
+ verifyCount(2, kret)
+
+ # derived pass by shared_ptr pointer ref
+ k = KlassDerived("me oh my");
+ kret = derivedsmartptrpointerreftest(k);
+ val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrpointerreftest-Derived", val)
+ verifyCount(2, k)
+ verifyCount(2, kret)
+
+ # derived pass by pointer
+ k = KlassDerived("me oh my");
+ kret = derivedpointertest(k);
+ val = kret.getValue();
+ verifyValue("me oh my derivedpointertest-Derived", val)
+ verifyCount(1, k)
+ verifyCount(1, kret)
+
+ # derived pass by ref
+ k = KlassDerived("me oh my");
+ kret = derivedreftest(k);
+ val = kret.getValue();
+ verifyValue("me oh my derivedreftest-Derived", val)
+ verifyCount(1, k)
+ verifyCount(1, kret)
+
+ # //////////////////////////////// Derived and base class mixed ////////////////////////////////////////
+ # pass by shared_ptr (mixed)
+ k = KlassDerived("me oh my");
+ kret = smartpointertest(k);
+ val = kret.getValue();
+ verifyValue("me oh my smartpointertest-Derived", val)
+ verifyCount(2, k)
+ verifyCount(2, kret)
+
+ # pass by shared_ptr pointer (mixed)
+ k = KlassDerived("me oh my");
+ kret = smartpointerpointertest(k);
+ val = kret.getValue();
+ verifyValue("me oh my smartpointerpointertest-Derived", val)
+ verifyCount(2, k)
+ verifyCount(2, kret)
+
+ # pass by shared_ptr reference (mixed)
+ k = KlassDerived("me oh my");
+ kret = smartpointerreftest(k);
+ val = kret.getValue();
+ verifyValue("me oh my smartpointerreftest-Derived", val)
+ verifyCount(2, k)
+ verifyCount(2, kret)
+
+ # pass by shared_ptr pointer reference (mixed)
+ k = KlassDerived("me oh my");
+ kret = smartpointerpointerreftest(k);
+ val = kret.getValue();
+ verifyValue("me oh my smartpointerpointerreftest-Derived", val)
+ verifyCount(2, k)
+ verifyCount(2, kret)
+
+ # pass by value (mixed)
+ k = KlassDerived("me oh my");
+ kret = valuetest(k);
+ val = kret.getValue();
+ verifyValue("me oh my valuetest", val) # note slicing
+ verifyCount(1, k)
+ verifyCount(1, kret)
+
+ # pass by pointer (mixed)
+ k = KlassDerived("me oh my");
+ kret = pointertest(k);
+ val = kret.getValue();
+ verifyValue("me oh my pointertest-Derived", val)
+ verifyCount(1, k)
+ verifyCount(1, kret)
+ # pass by ref (mixed)
+ k = KlassDerived("me oh my");
+ kret = reftest(k);
+ val = kret.getValue();
+ verifyValue("me oh my reftest-Derived", val)
+ verifyCount(1, k)
+ verifyCount(1, kret)
+
+ # //////////////////////////////// Overloading tests ////////////////////////////////////////
+ # Base class
+ k = Klass("me oh my");
+ verifyValue(overload_rawbyval(k), "rawbyval")
+ verifyValue(overload_rawbyref(k), "rawbyref")
+ verifyValue(overload_rawbyptr(k), "rawbyptr")
+ verifyValue(overload_rawbyptrref(k), "rawbyptrref")
+
+ verifyValue(overload_smartbyval(k), "smartbyval")
+ verifyValue(overload_smartbyref(k), "smartbyref")
+ verifyValue(overload_smartbyptr(k), "smartbyptr")
+ verifyValue(overload_smartbyptrref(k), "smartbyptrref")
+
+ # Derived class
+ k = KlassDerived("me oh my");
+ verifyValue(overload_rawbyval(k), "rawbyval")
+ verifyValue(overload_rawbyref(k), "rawbyref")
+ verifyValue(overload_rawbyptr(k), "rawbyptr")
+ verifyValue(overload_rawbyptrref(k), "rawbyptrref")
+
+ verifyValue(overload_smartbyval(k), "smartbyval")
+ verifyValue(overload_smartbyref(k), "smartbyref")
+ verifyValue(overload_smartbyptr(k), "smartbyptr")
+ verifyValue(overload_smartbyptrref(k), "smartbyptrref")
+
+ # 3rd derived class
+ k = Klass3rdDerived("me oh my");
+ val = k.getValue();
+ verifyValue("me oh my-3rdDerived", val)
+ verifyCount(1, k)
+
+ val = test3rdupcast(k);
+ verifyValue("me oh my-3rdDerived", val)
+ verifyCount(1, k)
+
+ # //////////////////////////////// Member variables ////////////////////////////////////////
+ # smart pointer by value
+ m = MemberVariables();
+ k = Klass("smart member value");
+ m.SmartMemberValue = k;
+ val = k.getValue();
+ verifyValue("smart member value", val)
+ verifyCount(2, k)
+
+ kmember = m.SmartMemberValue;
+ val = kmember.getValue();
+ verifyValue("smart member value", val)
+ verifyCount(3, kmember)
+ verifyCount(3, k)
+
+ clear m
+ verifyCount(2, kmember)
+ verifyCount(2, k)
+
+ # smart pointer by pointer
+ m = MemberVariables();
+ k = Klass("smart member pointer");
+ m.SmartMemberPointer = k;
+ val = k.getValue();
+ verifyValue("smart member pointer", val)
+ verifyCount(1, k)
+
+ kmember = m.SmartMemberPointer;
+ val = kmember.getValue();
+ verifyValue("smart member pointer", val)
+ verifyCount(2, kmember)
+ verifyCount(2, k)
+
+ clear m
+ verifyCount(2, kmember)
+ verifyCount(2, k)
+
+ # smart pointer by reference
+ m = MemberVariables();
+ k = Klass("smart member reference");
+ m.SmartMemberReference = k;
+ val = k.getValue();
+ verifyValue("smart member reference", val)
+ verifyCount(2, k)
+
+ kmember = m.SmartMemberReference;
+ val = kmember.getValue();
+ verifyValue("smart member reference", val)
+ verifyCount(3, kmember)
+ verifyCount(3, k)
+
+ # The C++ reference refers to SmartMemberValue...
+ kmemberVal = m.SmartMemberValue;
+ val = kmember.getValue();
+ verifyValue("smart member reference", val)
+ verifyCount(4, kmemberVal)
+ verifyCount(4, kmember)
+ verifyCount(4, k)
+
+ clear m
+ verifyCount(3, kmemberVal)
+ verifyCount(3, kmember)
+ verifyCount(3, k)
+
+ # plain by value
+ m = MemberVariables();
+ k = Klass("plain member value");
+ m.MemberValue = k;
+ val = k.getValue();
+ verifyValue("plain member value", val)
+ verifyCount(1, k)
+
+ kmember = m.MemberValue;
+ val = kmember.getValue();
+ verifyValue("plain member value", val)
+ verifyCount(1, kmember)
+ verifyCount(1, k)
+
+ clear m
+ verifyCount(1, kmember)
+ verifyCount(1, k)
+
+ # plain by pointer
+ m = MemberVariables();
+ k = Klass("plain member pointer");
+ m.MemberPointer = k;
+ val = k.getValue();
+ verifyValue("plain member pointer", val)
+ verifyCount(1, k)
+
+ kmember = m.MemberPointer;
+ val = kmember.getValue();
+ verifyValue("plain member pointer", val)
+ verifyCount(1, kmember)
+ verifyCount(1, k)
+
+ clear m
+ verifyCount(1, kmember)
+ verifyCount(1, k)
+
+ # plain by reference
+ m = MemberVariables();
+ k = Klass("plain member reference");
+ m.MemberReference = k;
+ val = k.getValue();
+ verifyValue("plain member reference", val)
+ verifyCount(1, k)
+
+ kmember = m.MemberReference;
+ val = kmember.getValue();
+ verifyValue("plain member reference", val)
+ verifyCount(1, kmember)
+ verifyCount(1, k)
+
+ clear m
+ verifyCount(1, kmember)
+ verifyCount(1, k)
+
+ # null member variables
+ m = MemberVariables();
+
+ # shared_ptr by value
+ k = m.SmartMemberValue;
+ #KTODO None not defined
+ # if (k ~= None)
+ # error("expected null")
+ # end
+
+ # m.SmartMemberValue = None
+ # k = m.SmartMemberValue
+ # if (k ~= None)
+ # error("expected null")
+ # end
+ # verifyCount(0, k)
+
+ # # plain by value
+ # # try:
+ # # m.MemberValue = None
+ # # error("Failed to catch null pointer")
+ # # except ValueError:
+ # # pass
+
+ # # ////////////////////////////////// Global variables ////////////////////////////////////////
+ # # smart pointer
+ # kglobal = cvar.GlobalSmartValue
+ # if (kglobal ~= None)
+ # error("expected null")
+ # end
+
+ k = Klass("smart global value");
+ cvar.GlobalSmartValue = k;
+ verifyCount(2, k)
+
+ kglobal = cvar.GlobalSmartValue;
+ val = kglobal.getValue();
+ verifyValue("smart global value", val)
+ verifyCount(3, kglobal)
+ verifyCount(3, k)
+ verifyValue("smart global value", cvar.GlobalSmartValue.getValue())
+ #KTTODO cvar.GlobalSmartValue = None
+
+ # plain value
+ k = Klass("global value");
+ cvar.GlobalValue = k;
+ verifyCount(1, k)
+
+ kglobal = cvar.GlobalValue;
+ val = kglobal.getValue();
+ verifyValue("global value", val)
+ verifyCount(1, kglobal)
+ verifyCount(1, k)
+ verifyValue("global value", cvar.GlobalValue.getValue())
+
+ # try:
+ # cvar.GlobalValue = None
+ # error("Failed to catch null pointer")
+ # except ValueError:
+ # pass
+
+ # plain pointer
+ kglobal = cvar.GlobalPointer;
+ #KTODO if (kglobal ~= None)
+ #KTODO error("expected null")
+ #KTODO end
+
+ k = Klass("global pointer");
+ cvar.GlobalPointer = k;
+ verifyCount(1, k)
+
+ kglobal = cvar.GlobalPointer;
+ val = kglobal.getValue();
+ verifyValue("global pointer", val)
+ verifyCount(1, kglobal)
+ verifyCount(1, k)
+ #KTODO cvar.GlobalPointer = None
+
+ # plain reference
+ kglobal;
+ k = Klass("global reference");
+ cvar.GlobalReference = k;
+ verifyCount(1, k)
+
+ kglobal = cvar.GlobalReference;
+ val = kglobal.getValue();
+ verifyValue("global reference", val)
+ verifyCount(1, kglobal)
+ verifyCount(1, k)
+
+ # try:
+ # cvar.GlobalReference = None
+ # error("Failed to catch null pointer")
+ # except ValueError:
+ # pass
+
+ # ////////////////////////////////// Templates ////////////////////////////////////////
+ pid = PairIntDouble(10, 20.2);
+ if (pid.baseVal1 ~= 20 || pid.baseVal2 ~= 40.4)
+ error("Base values wrong")
+ end
+ if (pid.val1 ~= 10 || pid.val2 ~= 20.2)
+ error("Derived Values wrong")
+ end
+
+endfunction
+
+debug = false;%true;
+
+ if (debug)
+ fprintf( "Started\n" )
+ end
+
+ cvar.debug_shared = debug;
+
+ # Change loop count to run for a long time to monitor memory
+ loopCount = 1; #5000
+ for i=0:loopCount
+ runtest()
+ end
+
+ # Expect 1 instance - the one global variable (GlobalValue)
+ #KTTODO next fails, possibly because we commented GlobalSmartValue=None
+ #if (Klass.getTotal_count() ~= 1)
+ # error("Klass.total_count=%d", Klass.getTotal_count())
+ #end
+
+ wrapper_count = shared_ptr_wrapper_count() ;
+ #KTTODO next fails as NOT_COUNTING not in octave name space, so we hard-wire it here
+ #if (wrapper_count ~= NOT_COUNTING)
+ if (wrapper_count ~= -123456)
+ # Expect 1 instance - the one global variable (GlobalSmartValue)
+ if (wrapper_count ~= 1)
+ error("shared_ptr wrapper count=%s", wrapper_count)
+ end
+ end
+
+ if (debug)
+ fprintf( "Finished\n" )
+ end
diff --git a/Examples/test-suite/operator_overload.i b/Examples/test-suite/operator_overload.i
index 061e7024c..90f767a84 100644
--- a/Examples/test-suite/operator_overload.i
+++ b/Examples/test-suite/operator_overload.i
@@ -73,12 +73,6 @@ see bottom for a set of possible tests
%rename(OrOperator) operator ||;
#endif
-#ifdef SWIG_ALLEGRO_CL
-%{
-#include
-%}
-#endif
-
#ifdef SWIGD
// Due to the way operator overloading is implemented in D1 and D2, the prefix
// increment/decrement operators (D1) resp. the postfix ones (D2) are ignored.
@@ -89,6 +83,7 @@ see bottom for a set of possible tests
%rename(DoubleCast) operator double();
%inline %{
+#include
#if defined(_MSC_VER)
#include /* for named logical operator, eg 'operator or' */
diff --git a/Examples/test-suite/overload_arrays.i b/Examples/test-suite/overload_arrays.i
new file mode 100644
index 000000000..42c08390a
--- /dev/null
+++ b/Examples/test-suite/overload_arrays.i
@@ -0,0 +1,148 @@
+// Tests of overloaded functions of arrays
+// Based on overload_simple testcase
+%module overload_arrays
+
+#ifdef SWIGCHICKEN
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) fbool;
+#endif
+
+#ifdef SWIGLUA
+// lua only has one numeric type, so most of the overloads shadow each other creating warnings
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) foo;
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) bar;
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) Spam;
+#endif
+
+#ifdef SWIGGO
+%warnfilter(SWIGWARN_PARSE_KEYWORD) type; // 'type' is a Go keyword, renamed as 'Xtype'
+%rename(Foos) Foo;
+#endif
+
+
+
+#ifndef SWIG_NO_OVERLOAD
+%immutable Spam::type;
+
+%inline %{
+
+#define SIZE 3
+
+struct Foo {
+};
+
+class Bar {
+public:
+ Bar(int i = 0) { num = i; }
+
+ static int foo(int a=0, int b=0) {return 0;}
+
+ int num;
+};
+
+char *foo() {
+ return (char *) "foo:";
+}
+char *foo(int[SIZE]) {
+ return (char*) "foo:int[SIZE]";
+}
+
+char *foo(double[SIZE]) {
+ return (char*) "foo:double[SIZE]";
+}
+
+char *foo(char *[SIZE]) {
+ return (char*) "foo:char *[SIZE]";
+}
+
+char *foo(Foo *[SIZE]) {
+ return (char*) "foo:Foo *[SIZE]";
+}
+char *foo(Bar *[SIZE]) {
+ return (char *) "foo:Bar *[SIZE]";
+}
+char *foo(void *[SIZE]) {
+ return (char *) "foo:void *[SIZE]";
+}
+char *foo(Foo *[SIZE], int[SIZE]) {
+ return (char *) "foo:Foo *[SIZE],int[SIZE]";
+}
+char *foo(double[SIZE], Bar *[SIZE]) {
+ return (char *) "foo:double[SIZE],Bar *[SIZE]";
+}
+
+char *blah(double[SIZE]) {
+ return (char *) "blah:double[SIZE]";
+}
+
+char *blah(char *[SIZE]) {
+ return (char *) "blah:char *[SIZE]";
+}
+
+class Spam {
+public:
+ Spam() { type = "none"; }
+ Spam(int[SIZE]) { type = "int[SIZE]"; }
+ Spam(double[SIZE]) { type = "double[SIZE]"; }
+ Spam(char *[SIZE]) { type = "char *[SIZE]"; }
+ Spam(Foo *[SIZE]) { type = "Foo *[SIZE]"; }
+ Spam(Bar *[SIZE]) { type = "Bar *[SIZE]"; }
+ Spam(void *[SIZE]) { type = "void *[SIZE]"; }
+ const char *type;
+
+char *foo(int[SIZE]) {
+ return (char*) "foo:int[SIZE]";
+}
+char *foo(double[SIZE]) {
+ return (char*) "foo:double[SIZE]";
+}
+char *foo(char *[SIZE]) {
+ return (char*) "foo:char *[SIZE]";
+}
+char *foo(Foo *[SIZE]) {
+ return (char*) "foo:Foo *[SIZE]";
+}
+char *foo(Bar *[SIZE]) {
+ return (char *) "foo:Bar *[SIZE]";
+}
+char *foo(void *[SIZE]) {
+ return (char *) "foo:void *[SIZE]";
+}
+
+static char *bar(int[SIZE]) {
+ return (char*) "bar:int[SIZE]";
+}
+static char *bar(double[SIZE]) {
+ return (char*) "bar:double[SIZE]";
+}
+static char *bar(char *[SIZE]) {
+ return (char*) "bar:char *[SIZE]";
+}
+static char *bar(Foo *[SIZE]) {
+ return (char*) "bar:Foo *[SIZE]";
+}
+static char *bar(Bar *[SIZE]) {
+ return (char *) "bar:Bar *[SIZE]";
+}
+static char *bar(void *[SIZE]) {
+ return (char *) "bar:void *[SIZE]";
+}
+};
+
+%}
+
+#endif
+
+
+%inline {
+ class ClassA
+ {
+ public:
+ ClassA() {}
+ int method1( ) {return 0;}
+ int method1( int arg1[SIZE] ) {return arg1[0];}
+ protected:
+ int method1( int arg1[SIZE], int arg2[SIZE] ) {return arg1[0] + arg2[0];}
+
+ };
+}
+
diff --git a/Examples/test-suite/php/director_exception_runme.php b/Examples/test-suite/php/director_exception_runme.php
index cb823214b..8b852c2ce 100644
--- a/Examples/test-suite/php/director_exception_runme.php
+++ b/Examples/test-suite/php/director_exception_runme.php
@@ -4,7 +4,7 @@ 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));
+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
diff --git a/Examples/test-suite/php/director_thread_runme.php b/Examples/test-suite/php/director_thread_runme.php
index 8df25d969..809dec3e2 100644
--- a/Examples/test-suite/php/director_thread_runme.php
+++ b/Examples/test-suite/php/director_thread_runme.php
@@ -3,6 +3,9 @@
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
diff --git a/Examples/test-suite/php/exception_order_runme.php b/Examples/test-suite/php/exception_order_runme.php
index a83598170..acb83561a 100644
--- a/Examples/test-suite/php/exception_order_runme.php
+++ b/Examples/test-suite/php/exception_order_runme.php
@@ -2,7 +2,7 @@
require "tests.php";
require "exception_order.php";
-check::functions(array(a_foo,a_bar,a_foobar,a_barfoo));
+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));
diff --git a/Examples/test-suite/php/import_nomodule_runme.php b/Examples/test-suite/php/import_nomodule_runme.php
index 84191fba9..41836ba0f 100644
--- a/Examples/test-suite/php/import_nomodule_runme.php
+++ b/Examples/test-suite/php/import_nomodule_runme.php
@@ -3,7 +3,7 @@ require "tests.php";
require "import_nomodule.php";
// No new functions
-check::functions(array(create_foo,delete_foo,test1));
+check::functions(array(create_foo,delete_foo,test1,is_python_builtin));
// No new classes
check::classes(array(import_nomodule,Bar));
// now new vars
diff --git a/Examples/test-suite/php/threads_exception_runme.php b/Examples/test-suite/php/threads_exception_runme.php
index 31148a1e1..9e4d04e10 100644
--- a/Examples/test-suite/php/threads_exception_runme.php
+++ b/Examples/test-suite/php/threads_exception_runme.php
@@ -4,9 +4,9 @@ require "tests.php";
require "threads_exception.php";
// Check functions
-check::functions(array(test_simple,test_message,test_hosed,test_unknown,test_multi));
+check::functions(array(test_simple,test_message,test_hosed,test_unknown,test_multi,is_python_builtin));
// Check classes.
-check::classes(array(Exc,Test));
+check::classes(array(Exc,Test,threads_exception));
// Chek globals.
check::globals(array(exc_code,exc_msg));
diff --git a/Examples/test-suite/preproc.i b/Examples/test-suite/preproc.i
index e052bff28..f236bfdff 100644
--- a/Examples/test-suite/preproc.i
+++ b/Examples/test-suite/preproc.i
@@ -11,6 +11,13 @@
#pragma SWIG nowarn=890 /* lots of Go name conflicts */
#pragma SWIG nowarn=206 /* Unexpected tokens after #endif directive. */
+%{
+#if defined(__clang__)
+//Suppress: warning: use of logical '&&' with constant operand [-Wconstant-logical-operand]
+#pragma clang diagnostic ignored "-Wconstant-logical-operand"
+#endif
+%}
+
/* check __cplusplus case */
%header
%{
@@ -225,8 +232,8 @@ This testcase tests operators for defines
#define A7 13 & 14
#define A8 15 | 16
#define A9 17 ^ 18
-#define A10 19 && 20
-#define A11 21 || 21
+#define A10 1 && 0
+#define A11 1 || 0
#define A12 ~22
#define A13 !23
@@ -346,3 +353,20 @@ int method(struct TypeNameTraits tnt) {
return tnt.val;
}
%}
+
+/* Null directive */
+# /* comment 1 */
+# // comment 2
+# /** comment 3 */
+# /* comment 4 */ /*comment 5*/
+# /** comment 6
+#
+# more comment 6 */
+#
+#
+#
+int methodX(int x);
+%{
+int methodX(int x) { return x+100; }
+%}
+
diff --git a/Examples/test-suite/preproc_constants.i b/Examples/test-suite/preproc_constants.i
index ef5c35e12..db71bd2d7 100644
--- a/Examples/test-suite/preproc_constants.i
+++ b/Examples/test-suite/preproc_constants.i
@@ -1,5 +1,12 @@
%module preproc_constants
+%{
+#if defined(__clang__)
+//Suppress: warning: use of logical '&&' with constant operand [-Wconstant-logical-operand]
+#pragma clang diagnostic ignored "-Wconstant-logical-operand"
+#endif
+%}
+
// Note: C types are slightly different to C++ types as (a && b) is int in C and bool in C++
// Simple constants
@@ -102,3 +109,4 @@ enum MyEnum {
enum MyEnum {
kValue = BIT(2)
};
+
diff --git a/Examples/test-suite/preproc_line_file.i b/Examples/test-suite/preproc_line_file.i
index b221b7728..cd30b1dc1 100644
--- a/Examples/test-suite/preproc_line_file.i
+++ b/Examples/test-suite/preproc_line_file.i
@@ -2,7 +2,7 @@
// Test __LINE__ and __FILE__ (don't change line numbering in here else runtime tests will need modifying)
#define MYLINE __LINE__
-#define MYLINE_ADJUSTED __LINE__ + 100
+#define MYLINE_ADJUSTED __LINE__ + 100
#define MYFILE __FILE__
#define MYFILE_ADJUSTED __FILE__ ".bak"
@@ -78,7 +78,7 @@ struct NAME { \
int num; \
};
#endif
-KLASS(SillyMultipleMacroStruct)
+KLASS(SillyMulMacroStruc)
%}
%inline %{
diff --git a/Examples/test-suite/primitive_types.i b/Examples/test-suite/primitive_types.i
index 5e3ce3eed..82a673536 100644
--- a/Examples/test-suite/primitive_types.i
+++ b/Examples/test-suite/primitive_types.i
@@ -1,6 +1,11 @@
// Massive primitive datatype test.
%module(directors="1") primitive_types
+#if defined(SWIGSCILAB)
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) ovr_val;
+%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)
@@ -322,10 +327,19 @@ macro(size_t, pfx, sizet)
if (a.str() != b.str()) {
std::cout << "failing in pfx""_""name : "
<< a.str() << " : " << b.str() << std::endl;
- // return 0;
}
}
%enddef
+/* check variables (arrays can't be compared so compare as strings) */
+%define var_array_check(type, pfx, name)
+ std::ostringstream a; std::ostringstream b;
+ a << pfx##_##name;
+ b << def_##name;
+ if (a.str() != b.str()) {
+ std::cout << "failing in pfx""_""name : "
+ << a.str() << " : " << b.str() << std::endl;
+ }
+%enddef
/* check a function call */
%define call_check(type, pfx, name)
@@ -337,7 +351,6 @@ macro(size_t, pfx, sizet)
if (a.str() != b.str()) {
std::cout << "failing in pfx""_""name : "
<< a.str() << " : " << b.str() << std::endl;
- // return 0;
}
}
%enddef
@@ -456,7 +469,7 @@ macro(size_t, pfx, sizet)
{
%test_prim_types_stc(var_check, stc)
%test_prim_types(var_check, var)
- var_check(namet, var, namet);
+ var_array_check(namet, var, namet);
return 1;
}
@@ -540,7 +553,7 @@ macro(size_t, pfx, sizet)
{
%test_prim_types(var_check, cct)
%test_prim_types(var_check, var)
- var_check(namet, var, namet);
+ var_array_check(namet, var, namet);
return 1;
}
diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in
index c79a786da..82a0e9db1 100644
--- a/Examples/test-suite/python/Makefile.in
+++ b/Examples/test-suite/python/Makefile.in
@@ -11,6 +11,7 @@ endif
LANGUAGE = python
PYTHON = $(PYBIN)
PEP8 = @PEP8@
+PEP8_FLAGS = --ignore=E402,E501,E30,W291,W391
#*_runme.py for Python 2.x, *_runme3.py for Python 3.x
PY2SCRIPTSUFFIX = _runme.py
@@ -126,13 +127,13 @@ py3_runme = $(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX)
check_pep8 = \
if [ -n "$(PEP8)" ]; then \
- $(PEP8) --ignore=E501,E30,W291,W391 $(SCRIPTPREFIX)$*.py;\
+ $(PEP8) $(PEP8_FLAGS) $(SCRIPTPREFIX)$*.py;\
fi
check_pep8_multi_cpp = \
if [ -n "$(PEP8)" ]; then \
for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \
- $(PEP8) --ignore=E501,E30,W291,W391 $$f.py; \
+ $(PEP8) $(PEP8_FLAGS) $$f.py; \
done \
fi
diff --git a/Examples/test-suite/python/autodoc_runme.py b/Examples/test-suite/python/autodoc_runme.py
index 8c3ca56fa..6ad4bae0c 100644
--- a/Examples/test-suite/python/autodoc_runme.py
+++ b/Examples/test-suite/python/autodoc_runme.py
@@ -2,6 +2,13 @@ from autodoc import *
from commentVerifier import check
import sys
+def is_new_style_class(cls):
+ return hasattr(cls, "__class__")
+
+if not is_new_style_class(A):
+ # Missing static methods make this hard to test... skip if -classic is used!
+ sys.exit(0)
+
check(A.__doc__, "Proxy of C++ A class")
check(A.funk.__doc__, "just a string")
check(A.func0.__doc__, "func0(self, arg2, hello) -> int")
diff --git a/Examples/test-suite/python/constant_directive_runme.py b/Examples/test-suite/python/constant_directive_runme.py
new file mode 100644
index 000000000..48f85ce8a
--- /dev/null
+++ b/Examples/test-suite/python/constant_directive_runme.py
@@ -0,0 +1,15 @@
+import constant_directive
+
+if not isinstance(constant_directive.TYPE1_CONSTANT1,constant_directive.Type1):
+ raise RuntimeError("Failure: TYPE1_CONSTANT1 type: {}".format(type(constant_directive.TYPE1_CONSTANT1)))
+if not isinstance(constant_directive.getType1Instance(),constant_directive.Type1):
+ raise RuntimeError("Failure: getType1Instance() type: {}".format(type(constant_directive.getType1Instance())))
+
+if constant_directive.TYPE1_CONSTANT1.val != 1:
+ raise RuntimeError("constant_directive.TYPE1_CONSTANT1.val is %r (should be 1)" % constant_directive.TYPE1_CONSTANT1.val)
+
+if constant_directive.TYPE1_CONSTANT2.val != 2:
+ raise RuntimeError("constant_directive.TYPE1_CONSTANT2.val is %r (should be 2)" % constant_directive.TYPE1_CONSTANT2.val)
+
+if constant_directive.TYPE1_CONSTANT3.val != 3:
+ raise RuntimeError("constant_directive.TYPE1_CONSTANT3.val is %r (should be 3)" % constant_directive.TYPE1_CONSTANT3.val)
diff --git a/Examples/test-suite/python/cpp_static_runme.py b/Examples/test-suite/python/cpp_static_runme.py
index ef8623359..eef921780 100644
--- a/Examples/test-suite/python/cpp_static_runme.py
+++ b/Examples/test-suite/python/cpp_static_runme.py
@@ -1,7 +1,16 @@
#!/usr/bin/evn python
from cpp_static import *
-StaticFunctionTest.static_func()
-StaticFunctionTest.static_func_2(1)
-StaticFunctionTest.static_func_3(1,2)
+
+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)
StaticMemberTest.static_int = 10
assert StaticMemberTest.static_int == 10
diff --git a/Examples/test-suite/python/default_args_runme.py b/Examples/test-suite/python/default_args_runme.py
index ad5e03d11..25bef14ca 100644
--- a/Examples/test-suite/python/default_args_runme.py
+++ b/Examples/test-suite/python/default_args_runme.py
@@ -1,67 +1,98 @@
-import default_args
+# Note that this test is also used by python_default_args_runme.py hence the use of __main__ and the run function
-ec = default_args.EnumClass()
-if not ec.blah():
- raise RuntimeError,"EnumClass::blah() default arguments don't work"
+def is_new_style_class(cls):
+ return hasattr(cls, "__class__")
-if default_args.Statics_staticMethod() != 60:
- raise RuntimeError
-
-if default_args.cfunc1(1) != 2:
- raise RuntimeError
+def run(module_name):
+ default_args = __import__(module_name)
+ ec = default_args.EnumClass()
+ if not ec.blah():
+ raise RuntimeError("EnumClass::blah() default arguments don't work")
-if default_args.cfunc2(1) != 3:
- raise RuntimeError
+ de = default_args.DerivedEnumClass()
+ de.accelerate()
+ de.accelerate(default_args.EnumClass.SLOW)
-if default_args.cfunc3(1) != 4:
- raise RuntimeError
+ if default_args.Statics_staticMethod() != 60:
+ raise RuntimeError
+
+ if default_args.cfunc1(1) != 2:
+ raise RuntimeError
+
+ if default_args.cfunc2(1) != 3:
+ raise RuntimeError
+
+ if default_args.cfunc3(1) != 4:
+ raise RuntimeError
-f = default_args.Foo()
+ f = default_args.Foo()
-f.newname()
-f.newname(1)
+ f.newname()
+ f.newname(1)
-try:
- f = default_args.Foo(1)
- error = 1
-except:
- error = 0
-if error: raise RuntimeError,"Foo::Foo ignore is not working"
+ try:
+ f = default_args.Foo(1)
+ error = 1
+ except:
+ error = 0
+ if error: raise RuntimeError("Foo::Foo ignore is not working")
-try:
- f = default_args.Foo(1,2)
- error = 1
-except:
- error = 0
-if error: raise RuntimeError,"Foo::Foo ignore is not working"
+ try:
+ f = default_args.Foo(1,2)
+ error = 1
+ except:
+ error = 0
+ if error: raise RuntimeError("Foo::Foo ignore is not working")
-try:
- f = default_args.Foo(1,2,3)
- error = 1
-except:
- error = 0
-if error: raise RuntimeError,"Foo::Foo ignore is not working"
+ try:
+ f = default_args.Foo(1,2,3)
+ error = 1
+ except:
+ error = 0
+ if error: raise RuntimeError("Foo::Foo ignore is not working")
-try:
- m = f.meth(1)
- error = 1
-except:
- error = 0
-if error: raise RuntimeError,"Foo::meth ignore is not working"
+ try:
+ m = f.meth(1)
+ error = 1
+ except:
+ error = 0
+ if error: raise RuntimeError("Foo::meth ignore is not working")
-try:
- m = f.meth(1,2)
- error = 1
-except:
- error = 0
-if error: raise RuntimeError,"Foo::meth ignore is not working"
+ try:
+ m = f.meth(1,2)
+ error = 1
+ except:
+ error = 0
+ if error: raise RuntimeError("Foo::meth ignore is not working")
-try:
- m = f.meth(1,2,3)
- error = 1
-except:
- error = 0
-if error: raise RuntimeError,"Foo::meth ignore is not working"
+ try:
+ m = f.meth(1,2,3)
+ error = 1
+ except:
+ error = 0
+ 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
+
+ if Klass_inc(100, default_args.Klass(22)).val != 122:
+ raise RuntimeError("Klass::inc failed")
+
+ if Klass_inc(100).val != 99:
+ raise RuntimeError("Klass::inc failed")
+
+ 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)
+ default_args.seek(); default_args.seek(10)
+
+if __name__=="__main__":
+ run('default_args')
diff --git a/Examples/test-suite/python/director_abstract_runme.py b/Examples/test-suite/python/director_abstract_runme.py
index 7d92d10ff..886cda0ae 100644
--- a/Examples/test-suite/python/director_abstract_runme.py
+++ b/Examples/test-suite/python/director_abstract_runme.py
@@ -1,5 +1,8 @@
import director_abstract
+def is_new_style_class(cls):
+ return hasattr(cls, "__class__")
+
class MyFoo(director_abstract.Foo):
def __init__(self):
director_abstract.Foo.__init__(self)
@@ -32,12 +35,20 @@ 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.get_color(me2, 1,2,3) != 2:
+if MyExample2_static.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.get_color(me3, 1,2,3) != 3:
+if MyExample3_static.get_color(me3, 1,2,3) != 3:
raise RuntimeError
error = 1
diff --git a/Examples/test-suite/python/global_namespace_runme.py b/Examples/test-suite/python/global_namespace_runme.py
index b64e75ca1..8e42e0653 100644
--- a/Examples/test-suite/python/global_namespace_runme.py
+++ b/Examples/test-suite/python/global_namespace_runme.py
@@ -1,5 +1,8 @@
from global_namespace import *
+def is_new_style_class(cls):
+ return hasattr(cls, "__class__")
+
k1 = Klass1()
k2 = Klass2()
k3 = Klass3()
@@ -8,8 +11,12 @@ k5 = Klass5()
k6 = Klass6()
k7 = Klass7()
-KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7)
-KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7)
+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)
k1 = getKlass1A()
k2 = getKlass2A()
@@ -19,8 +26,8 @@ k5 = getKlass5A()
k6 = getKlass6A()
k7 = getKlass7A()
-KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7)
-KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7)
+KlassMethods_static.methodA(k1, k2, k3, k4, k5, k6, k7)
+KlassMethods_static.methodB(k1, k2, k3, k4, k5, k6, k7)
k1 = getKlass1B()
k2 = getKlass2B()
@@ -30,11 +37,19 @@ k5 = getKlass5B()
k6 = getKlass6B()
k7 = getKlass7B()
-KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7)
-KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7)
+KlassMethods_static.methodA(k1, k2, k3, k4, k5, k6, k7)
+KlassMethods_static.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())
+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())
-TheEnumMethods.methodA(theenum1, theenum2, theenum3)
-TheEnumMethods.methodA(theenum1, theenum2, theenum3)
+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)
diff --git a/Examples/test-suite/python/implicittest_runme.py b/Examples/test-suite/python/implicittest_runme.py
index a9957bc7e..4cad1bb5d 100644
--- a/Examples/test-suite/python/implicittest_runme.py
+++ b/Examples/test-suite/python/implicittest_runme.py
@@ -4,6 +4,9 @@ def check(a, b):
if 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
@@ -39,13 +42,17 @@ check(2, A_int(1.0).get())
check(3, A_int(B()).get())
check(4, A_int("hello").get())
-check(1, A_int.sget(1))
-check(2, A_int.sget(1.0))
-check(3, A_int.sget(B()))
+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()))
# explicit constructor:
try:
- check(4, A_int.sget("hello"))
+ check(4, A_int_static.sget("hello"))
raise RuntimeError
except TypeError:
pass
diff --git a/Examples/test-suite/python/kwargs_feature_runme.py b/Examples/test-suite/python/kwargs_feature_runme.py
index 7792e2e06..37457c976 100644
--- a/Examples/test-suite/python/kwargs_feature_runme.py
+++ b/Examples/test-suite/python/kwargs_feature_runme.py
@@ -51,7 +51,7 @@ if foo_fn(b=2) != 3:
raise RuntimeError
-#Funtions with keywords
+#Functions with keywords
if foo_kw(_from=2) != 4:
raise RuntimeError
@@ -65,3 +65,17 @@ if foo_mm(min=2) != 4:
if foo_mm(max=3) != 4:
raise RuntimeError
+#Default args with references
+
+if rfoo(n=123) != 120:
+ raise RuntimeError
+
+if rfoo(x=10) != -10:
+ raise RuntimeError
+
+if rfoo(n=11, x=22) != -11:
+ raise RuntimeError
+
+if rfoo(x=11, n=22) != 11:
+ raise RuntimeError
+
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 931317615..a05432925 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,5 +1,8 @@
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
@@ -30,5 +33,8 @@ if sum != 66:
raise "sum is wrong"
################################
-p = HiddenDestructor.create()
+if is_new_style_class(HiddenDestructor):
+ p = HiddenDestructor.create()
+else:
+ p = HiddenDestructor_create()
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 f967def14..0e025d546 100644
--- a/Examples/test-suite/python/li_boost_shared_ptr_runme.py
+++ b/Examples/test-suite/python/li_boost_shared_ptr_runme.py
@@ -17,7 +17,7 @@ class li_boost_shared_ptr_runme:
self.runtest()
# Expect 1 instance - the one global variable (GlobalValue)
- if (li_boost_shared_ptr.Klass.getTotal_count() != 1):
+ if (li_boost_shared_ptr.Klass_getTotal_count() != 1):
raise RuntimeError("Klass.total_count=%s" % li_boost_shared_ptr.Klass.getTotal_count())
wrapper_count = li_boost_shared_ptr.shared_ptr_wrapper_count()
diff --git a/Examples/test-suite/python/li_std_auto_ptr_runme.py b/Examples/test-suite/python/li_std_auto_ptr_runme.py
index a29771479..d82a89f42 100644
--- a/Examples/test-suite/python/li_std_auto_ptr_runme.py
+++ b/Examples/test-suite/python/li_std_auto_ptr_runme.py
@@ -2,16 +2,16 @@ from li_std_auto_ptr import *
k1 = makeKlassAutoPtr("first")
k2 = makeKlassAutoPtr("second")
-if Klass.getTotal_count() != 2:
+if Klass_getTotal_count() != 2:
raise "number of objects should be 2"
del k1
-if Klass.getTotal_count() != 1:
+if Klass_getTotal_count() != 1:
raise "number of objects should be 1"
if k2.getLabel() != "second":
raise "wrong object label"
del k2
-if Klass.getTotal_count() != 0:
+if Klass_getTotal_count() != 0:
raise "no objects should be left"
diff --git a/Examples/test-suite/python/namespace_class_runme.py b/Examples/test-suite/python/namespace_class_runme.py
index d139527b7..e009f9515 100644
--- a/Examples/test-suite/python/namespace_class_runme.py
+++ b/Examples/test-suite/python/namespace_class_runme.py
@@ -1,5 +1,8 @@
from namespace_class import *
+def is_new_style_class(cls):
+ return hasattr(cls, "__class__")
+
try:
p = Private1()
error = 1
@@ -18,7 +21,10 @@ except:
if (error):
raise RuntimeError, "Private2 is private"
-EulerT3D.toFrame(1,1,1)
+if is_new_style_class(EulerT3D):
+ EulerT3D.toFrame(1,1,1)
+else:
+ EulerT3D().toFrame(1,1,1)
b = BooT_i()
b = BooT_H()
@@ -33,6 +39,7 @@ f.moo(1)
f = FooT_H()
f.foo(Hi)
-f_type = str(type(f))
-if f_type.find("'namespace_class.FooT_H'") == -1:
- raise RuntimeError("Incorrect type: " + f_type)
+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)
diff --git a/Examples/test-suite/python/nested_template_base_runme.py b/Examples/test-suite/python/nested_template_base_runme.py
new file mode 100644
index 000000000..3d54b8391
--- /dev/null
+++ b/Examples/test-suite/python/nested_template_base_runme.py
@@ -0,0 +1,13 @@
+from nested_template_base import *
+
+
+ois = InnerS(123);
+oic = InnerC();
+
+# Check base method is available
+if (oic.outer(ois).val != 123):
+ raise RuntimeError("Wrong value calling outer");
+
+# Check non-derived class using base class
+if (oic.innerc().outer(ois).val != 123):
+ raise RuntimeError("Wrong value calling innerc");
diff --git a/Examples/test-suite/python/overload_template_fast_runme.py b/Examples/test-suite/python/overload_template_fast_runme.py
index d47f7d14d..299b91db8 100644
--- a/Examples/test-suite/python/overload_template_fast_runme.py
+++ b/Examples/test-suite/python/overload_template_fast_runme.py
@@ -1,4 +1,8 @@
from overload_template_fast import *
+
+def is_new_style_class(cls):
+ return hasattr(cls, "__class__")
+
f = foo()
a = maximum(3,4)
@@ -140,6 +144,9 @@ if (nsoverload() != 1050):
raise RuntimeError, ("nsoverload(const char *)")
-A.foo(1)
+if is_new_style_class(A):
+ A.foo(1)
+else:
+ A_foo(1)
b = B()
b.foo(1)
diff --git a/Examples/test-suite/python/preproc_runme.py b/Examples/test-suite/python/preproc_runme.py
index c989294b6..3049f00ab 100644
--- a/Examples/test-suite/python/preproc_runme.py
+++ b/Examples/test-suite/python/preproc_runme.py
@@ -12,3 +12,5 @@ if preproc.defined != 1:
if 2*preproc.one != preproc.two:
raise RuntimeError
+if preproc.methodX(99) != 199:
+ raise RuntimeError
diff --git a/Examples/test-suite/python/python_append_runme.py b/Examples/test-suite/python/python_append_runme.py
index 54d7a3e00..15b0297e9 100644
--- a/Examples/test-suite/python/python_append_runme.py
+++ b/Examples/test-suite/python/python_append_runme.py
@@ -1,12 +1,18 @@
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()
-t.static_func()
+if is_new_style_class(Test):
+ t.static_func()
+else:
+ Test_static_func()
if grabpath() != os.path.dirname(mypath):
raise RuntimeError("grabpath failed")
diff --git a/Examples/test-suite/python/refcount_runme.py b/Examples/test-suite/python/refcount_runme.py
index ab1803f24..ca15e04ac 100644
--- a/Examples/test-suite/python/refcount_runme.py
+++ b/Examples/test-suite/python/refcount_runme.py
@@ -5,7 +5,7 @@ from refcount import *
a = A3()
b1 = B(a)
-b2 = B.create(a)
+b2 = B_create(a)
@@ -14,7 +14,7 @@ if a.ref_count() != 3:
rca = b2.get_rca()
-b3 = B.create(rca)
+b3 = B_create(rca)
if a.ref_count() != 5:
raise RuntimeError("Count = %d" % a.ref_count())
@@ -39,7 +39,7 @@ b5 = global_create(a)
if b5.ref_count() != 1:
raise RuntimeError
-b6 = Factory.create(a)
+b6 = Factory_create(a)
if b6.ref_count() != 1:
raise RuntimeError
diff --git a/Examples/test-suite/python/return_const_value_runme.py b/Examples/test-suite/python/return_const_value_runme.py
index 516e9f5d9..932c4822c 100644
--- a/Examples/test-suite/python/return_const_value_runme.py
+++ b/Examples/test-suite/python/return_const_value_runme.py
@@ -1,12 +1,12 @@
import return_const_value
import sys
-p = return_const_value.Foo_ptr.getPtr()
+p = return_const_value.Foo_ptr_getPtr()
if (p.getVal() != 17):
print "Runtime test1 faild. p.getVal()=", p.getVal()
sys.exit(1)
-p = return_const_value.Foo_ptr.getConstPtr()
+p = return_const_value.Foo_ptr_getConstPtr()
if (p.getVal() != 17):
print "Runtime test2 faild. p.getVal()=", p.getVal()
sys.exit(1)
diff --git a/Examples/test-suite/python/smart_pointer_const_overload_runme.py b/Examples/test-suite/python/smart_pointer_const_overload_runme.py
index f1be315a5..098e5b4c3 100644
--- a/Examples/test-suite/python/smart_pointer_const_overload_runme.py
+++ b/Examples/test-suite/python/smart_pointer_const_overload_runme.py
@@ -56,7 +56,7 @@ def test(b, f):
raise RuntimeError
# Test static method
- b.stat()
+ b.statMethod()
if f.access != CONST_ACCESS:
raise RuntimeError
diff --git a/Examples/test-suite/python/smart_pointer_member_runme.py b/Examples/test-suite/python/smart_pointer_member_runme.py
index 70e655652..2cf3686fc 100644
--- a/Examples/test-suite/python/smart_pointer_member_runme.py
+++ b/Examples/test-suite/python/smart_pointer_member_runme.py
@@ -1,5 +1,8 @@
from smart_pointer_member import *
+def is_new_style_class(cls):
+ return hasattr(cls, "__class__")
+
f = Foo()
f.y = 1
@@ -20,8 +23,9 @@ if b.x != f.x:
if b.z != f.z:
raise RuntimeError
-if Foo.z == Bar.z:
- raise RuntimeError
+if is_new_style_class(Bar): # feature not supported in old style classes
+ if Foo.z == Bar.z:
+ raise RuntimeError
diff --git a/Examples/test-suite/python/typemap_out_optimal_runme.py b/Examples/test-suite/python/typemap_out_optimal_runme.py
index b148f2d06..95556f6bd 100644
--- a/Examples/test-suite/python/typemap_out_optimal_runme.py
+++ b/Examples/test-suite/python/typemap_out_optimal_runme.py
@@ -1,5 +1,5 @@
from typemap_out_optimal import *
cvar.XX_debug = False
-x = XX.create()
+x = XX_create()
diff --git a/Examples/test-suite/rename.h b/Examples/test-suite/rename.h
index 4750337a9..c8199eeeb 100644
--- a/Examples/test-suite/rename.h
+++ b/Examples/test-suite/rename.h
@@ -31,13 +31,27 @@ namespace Space {
};
}
+#if defined(SWIG)
+%exception Space::ABC::operator ABC %{
+#if defined(__clang__)
+ // Workaround for: warning: conversion function converting 'Space::ABC' to itself will never be used
+ result = *arg1;
+#else
+ $action
+#endif
+%}
+#endif
+
namespace Space {
// non-templated class using itself in method and operator
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 Klass() const { Klass k; return k; }
};
}
diff --git a/Examples/test-suite/rename4.i b/Examples/test-suite/rename4.i
index 3f61e0c69..9ddff362f 100644
--- a/Examples/test-suite/rename4.i
+++ b/Examples/test-suite/rename4.i
@@ -78,6 +78,15 @@ namespace Space {
};
}
+%exception Space::ABC::operator ABC %{
+#if defined(__clang__)
+ // Workaround for: warning: conversion function converting 'Space::ABC' to itself will never be used
+ result = *arg1;
+#else
+ $action
+#endif
+%}
+
namespace Space {
// non-templated class using itself in method and operator
class ABC {
@@ -90,7 +99,10 @@ class ABC {
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 Klass() const { Klass k; return k; }
};
}
diff --git a/Examples/test-suite/scilab/Makefile.in b/Examples/test-suite/scilab/Makefile.in
new file mode 100644
index 000000000..4a9a4f007
--- /dev/null
+++ b/Examples/test-suite/scilab/Makefile.in
@@ -0,0 +1,90 @@
+#######################################################################
+# Makefile for scilab test-suite
+#######################################################################
+
+LANGUAGE = scilab
+SCILAB = @SCILAB@
+SCILAB_OPT = @SCILABOPT@
+SCRIPTSUFFIX = _runme.sci
+
+srcdir = @srcdir@
+top_srcdir = ../@top_srcdir@
+top_builddir = ../@top_builddir@
+
+C_TEST_CASES += \
+ scilab_consts \
+ scilab_enums \
+ scilab_identifier_name \
+
+CPP_TEST_CASES += \
+ inout \
+ primitive_types \
+ scilab_li_matrix \
+ scilab_multivalue \
+ scilab_pointer_conversion_functions \
+
+CPP_STD_TEST_CASES += \
+ li_std_container_typemaps \
+ li_std_string_extra \
+
+include $(srcdir)/../common.mk
+
+# Overriden variables
+SRCDIR = ../$(srcdir)/
+
+# Local variables
+TEST_DIR = $*.dir
+RUNME_SCRIPT = $(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)
+SRC_RUNME_SCRIPT = $(srcdir)/$(RUNME_SCRIPT)
+
+# Hide too long identifier warnings
+SWIGOPT += -w720
+
+# Rules for the different types of tests
+%.cpptest:
+ $(setup)
+ +(cd $(TEST_DIR) && $(swig_and_compile_cpp))
+ cd $(TEST_DIR) && $(run_testcase)
+
+%.ctest:
+ $(setup)
+ +(cd $(TEST_DIR) && $(swig_and_compile_c))
+ cd $(TEST_DIR) && $(run_testcase)
+
+%.multicpptest:
+ $(setup)
+ +(cd $(TEST_DIR) && $(swig_and_compile_multi_cpp))
+ cd $(TEST_DIR) && $(run_testcase)
+
+# Copies files and creates directories needed for the test case
+setup = \
+ if [ ! -d $(TEST_DIR) ]; then \
+ mkdir $(TEST_DIR); \
+ fi; \
+ if [ -f $(SRC_RUNME_SCRIPT) ]; then \
+ echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE)" ; \
+ if [ ! -f $(TEST_DIR) ]; then \
+ cp $(SRC_RUNME_SCRIPT) $(TEST_DIR); \
+ fi; \
+ if [ ! -f $(TEST_DIR)/swigtest.start ]; then \
+ cp $(srcdir)/swigtest.start $(TEST_DIR); \
+ fi; \
+ if [ ! -f $(TEST_DIR)/swigtest.quit ]; then \
+ cp $(srcdir)/swigtest.quit $(TEST_DIR); \
+ fi; \
+ else \
+ echo "$(ACTION)ing testcase $* under $(LANGUAGE)" ; \
+ fi; \
+
+# Runs the testcase. A testcase is only run if
+# a file is found which has _runme.sci appended after the testcase name.
+run_testcase = \
+ if [ -f $(RUNME_SCRIPT) ]; then ( \
+ env LD_LIBRARY_PATH=$(srcdir):$$LD_LIBRARY_PATH $(RUNTOOL) $(SCILAB) $(SCILAB_OPT) -f $(RUNME_SCRIPT); ) \
+ fi
+
+# Clean: remove the generated files
+%.clean:
+ @rm -rf $(TEST_DIR)
+
+clean:
diff --git a/Examples/test-suite/scilab/abstract_access_runme.sci b/Examples/test-suite/scilab/abstract_access_runme.sci
new file mode 100644
index 000000000..900a2618b
--- /dev/null
+++ b/Examples/test-suite/scilab/abstract_access_runme.sci
@@ -0,0 +1,16 @@
+exec("swigtest.start", -1);
+
+try
+ D = new_D();
+catch
+ swigtesterror();
+end
+if A_do_x(D) <> 1 then swigtesterror(); end
+
+try
+ delete_D(D);
+catch
+ swigtesterror();
+end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/abstract_inherit_ok_runme.sci b/Examples/test-suite/scilab/abstract_inherit_ok_runme.sci
new file mode 100644
index 000000000..0ee1e291b
--- /dev/null
+++ b/Examples/test-suite/scilab/abstract_inherit_ok_runme.sci
@@ -0,0 +1,11 @@
+exec("swigtest.start", -1);
+
+try
+ Spam = new_Spam()
+catch
+ swigtesterror();
+end
+
+if Foo_blah(Spam)<>0 then swigtesterror; end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/abstract_inherit_runme.sci b/Examples/test-suite/scilab/abstract_inherit_runme.sci
new file mode 100644
index 000000000..b9058e614
--- /dev/null
+++ b/Examples/test-suite/scilab/abstract_inherit_runme.sci
@@ -0,0 +1,10 @@
+exec("swigtest.start", -1);
+
+try
+ // This call must fail because the constructor does not exist
+ Spam = new_Spam()
+ swigtesterror();
+catch
+end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/abstract_signature_runme.sci b/Examples/test-suite/scilab/abstract_signature_runme.sci
new file mode 100644
index 000000000..d60acfd76
--- /dev/null
+++ b/Examples/test-suite/scilab/abstract_signature_runme.sci
@@ -0,0 +1,10 @@
+exec("swigtest.start", -1);
+
+// These calls must fail
+ierr = execstr('abstract_foo_meth(1)', 'errcatch');
+if ierr == 0 then swigtesterror(); end
+
+ierr = execstr('abstract_bar_meth(1)', 'errcatch');
+if ierr == 0 then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/abstract_typedef2_runme.sci b/Examples/test-suite/scilab/abstract_typedef2_runme.sci
new file mode 100644
index 000000000..8da9c2fab
--- /dev/null
+++ b/Examples/test-suite/scilab/abstract_typedef2_runme.sci
@@ -0,0 +1,15 @@
+exec("swigtest.start", -1);
+
+try
+ a = new_A_UF();
+catch
+ swigtesterror();
+end
+
+try
+ delete_A_UF(a);
+catch
+ swigtesterror();
+end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/abstract_typedef_runme.sci b/Examples/test-suite/scilab/abstract_typedef_runme.sci
new file mode 100644
index 000000000..bfb03a2f1
--- /dev/null
+++ b/Examples/test-suite/scilab/abstract_typedef_runme.sci
@@ -0,0 +1,17 @@
+exec("swigtest.start", -1);
+
+try
+ e = new_Engine();
+catch
+ swigtesterror();
+end
+
+try
+ a = new_A();
+catch
+ swigtesterror();
+end
+
+// TODO: test write method
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/abstract_virtual_runme.sci b/Examples/test-suite/scilab/abstract_virtual_runme.sci
new file mode 100644
index 000000000..55379eee2
--- /dev/null
+++ b/Examples/test-suite/scilab/abstract_virtual_runme.sci
@@ -0,0 +1,27 @@
+exec("swigtest.start", -1);
+
+try
+ d = new_D();
+catch
+ swigtesterror();
+end
+
+try
+ delete_D(d);
+catch
+ swigtesterror();
+end
+
+try
+ e = new_E();
+catch
+ swigtesterror();
+end
+
+try
+ delete_E(e);
+catch
+ swigtesterror();
+end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/access_change_runme.sci b/Examples/test-suite/scilab/access_change_runme.sci
new file mode 100644
index 000000000..e3705a2b3
--- /dev/null
+++ b/Examples/test-suite/scilab/access_change_runme.sci
@@ -0,0 +1,39 @@
+exec("swigtest.start", -1);
+
+try
+ baseInt = new_BaseInt();
+catch
+ swigtesterror();
+end
+
+try
+ delete_BaseInt(baseInt);
+catch
+ swigtesterror();
+end
+
+try
+ derivedInt = new_DerivedInt();
+catch
+ swigtesterror();
+end
+
+try
+ delete_DerivedInt(derivedInt);
+catch
+ swigtesterror();
+end
+
+try
+ bottomInt = new_BottomInt();
+catch
+ swigtesterror();
+end
+
+try
+ delete_BottomInt(bottomInt);
+catch
+ swigtesterror();
+end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/add_link_runme.sci b/Examples/test-suite/scilab/add_link_runme.sci
new file mode 100644
index 000000000..f15d84e1d
--- /dev/null
+++ b/Examples/test-suite/scilab/add_link_runme.sci
@@ -0,0 +1,27 @@
+exec("swigtest.start", -1);
+
+try
+ foo = new_Foo();
+catch
+ swigtesterror();
+end
+
+try
+ foo2 = Foo_blah(foo);
+catch
+ swigtesterror();
+end
+
+try
+ delete_Foo(foo);
+catch
+ swigtesterror();
+end
+
+try
+ delete_Foo(foo2);
+catch
+ swigtesterror();
+end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/aggregate_runme.sci b/Examples/test-suite/scilab/aggregate_runme.sci
new file mode 100644
index 000000000..ba5768013
--- /dev/null
+++ b/Examples/test-suite/scilab/aggregate_runme.sci
@@ -0,0 +1,21 @@
+exec("swigtest.start", -1);
+
+if UP_get()<>1 then swigtesterror(); end
+if typeof(UP_get())<>"constant" then pause; end
+
+if DOWN_get()<>2 then swigtesterror(); end
+if typeof(DOWN_get())<>"constant" then pause; end
+
+if LEFT_get()<>3 then swigtesterror(); end
+if typeof(LEFT_get())<>"constant" then pause; end
+
+if RIGHT_get()<>4 then swigtesterror(); end
+if typeof(RIGHT_get())<>"constant" then pause; end
+
+// TODO: move is a Scilab function...
+//result = move(UP_get());
+//result = move(DOWN_get());
+//result = move(LEFT_get());
+//result = move(RIGHT_get());
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/allowexcept_runme.sci b/Examples/test-suite/scilab/allowexcept_runme.sci
new file mode 100644
index 000000000..014c77830
--- /dev/null
+++ b/Examples/test-suite/scilab/allowexcept_runme.sci
@@ -0,0 +1,5 @@
+exec("swigtest.start", -1);
+
+// TODO: add tests here
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/allprotected_runme.sci b/Examples/test-suite/scilab/allprotected_runme.sci
new file mode 100644
index 000000000..7bc74fac0
--- /dev/null
+++ b/Examples/test-suite/scilab/allprotected_runme.sci
@@ -0,0 +1,80 @@
+exec("swigtest.start", -1);
+
+// Class Klass
+try
+ klass = new_Klass("allprotected_klass")
+catch
+ swigtesterror(lasterror());
+end
+
+checkequal(Klass_getName(klass), "allprotected_klass", "Klass_getName(new_Klass(""allprotected_klass""))");
+
+// Class PubBase
+try
+ pubBase = new_PubBase("allprotected_PubBase");
+catch
+ swigtesterror(lasterror());
+end
+
+checkequal(PubBase_virtualMethod(pubBase), "PublicBase", "PubBase_virtualMethod(pubBase)");
+
+class = PubBase_instanceMethod(pubBase, klass);
+checkequal(Klass_getName(class), "allprotected_klass", "Klass_getName(PubBase_instanceMethod(pubBase, klass))");
+
+class = PubBase_instanceOverload(pubBase, klass);
+checkequal(Klass_getName(class), "allprotected_klass", "Klass_getName(PubBase_instanceOverloaded(pubBase, klass))");
+
+class = PubBase_instanceOverload(pubBase, klass, "allprotected_klass2");
+checkequal(Klass_getName(class), "allprotected_klass2", "Klass_getName(PubBase_instanceOverloaded(pubBase, klass, ""allprotected_klass2""))");
+
+class = PubBase_staticMethod(klass);
+checkequal(Klass_getName(class), "allprotected_klass", "Klass_getName(PubBase_staticMethod(klass))");
+
+class = PubBase_staticOverloaded(klass);
+checkequal(Klass_getName(class), "allprotected_klass", "Klass_getName(PubBase_staticOverloaded(klass))");
+
+
+class = PubBase_staticOverloaded(klass, "allprotected_klass3");
+checkequal(Klass_getName(class), "allprotected_klass3", "Klass_getName(PubBase_staticOverloaded(klass, ""allprotected_klass3""))");
+
+checkequal(PubBase_EnumVal1_get(), 0, "PubBase_EnumVal1_get()");
+checkequal(PubBase_EnumVal2_get(), 1, "(PubBase_EnumVal2_get()");
+
+
+PubBase_instanceMemb_set(pubBase, 12);
+checkequal(PubBase_instanceMemb_get(pubBase), 12, "PubBase_instanceMemb_get(pubBase)");
+
+checkequal(PubBase_staticConstM_get(), 20, "PubBase_staticConstM_get()");
+checkequal(PubBase_staticMember_get(), 10, "PubBase_staticMember_get()")
+
+PubBase_stringMember_set(pubBase, "dummy");
+checkequal(PubBase_stringMember_get(pubBase), "dummy", "PubBase_stringMember_get()");
+
+// TODO does not work (wrong ENUM mapping?)
+//PubBase_anEnum_get(PubBase)
+//PubBase_anEnum_set(PubBase, ???)
+
+
+// Class ProcBase
+try
+// Constructor is propected and must not be defined here
+ ProcBase = new_ProctectedBase("allprotected_ProcBase");
+ swigtesterror();
+catch
+end
+
+checkequal(ProcBase_EnumVal1_get(), 0, "ProcBase_EnumVal1_get()");
+checkequal(ProcBase_EnumVal2_get(), 1, "ProcBase_EnumVal2_get()");
+
+try
+ delete_Klass(klass);
+catch
+ swigtesterror();
+end
+try
+ delete_PubBase(pubBase);
+catch
+ swigtesterror();
+end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/anonymous_bitfield_runme.sci b/Examples/test-suite/scilab/anonymous_bitfield_runme.sci
new file mode 100644
index 000000000..9bc462a89
--- /dev/null
+++ b/Examples/test-suite/scilab/anonymous_bitfield_runme.sci
@@ -0,0 +1,60 @@
+exec("swigtest.start", -1);
+
+try
+ foo = new_Foo();
+catch
+ swigtesterror();
+end
+
+checkequal(Foo_x_get(foo), 0, "Foo_x_get()");
+
+checkequal(Foo_y_get(foo), 0, "Foo_y_get()");
+
+checkequal(Foo_z_get(foo), 0, "Foo_y_get()");
+
+checkequal(Foo_f_get(foo), 0, "Foo_f_get()");
+
+checkequal(Foo_seq_get(foo), 0, "Foo_seq_get()");
+
+try
+ Foo_x_set(foo, 5);
+catch
+ swigtesterror();
+end
+checkequal(Foo_x_get(foo), 5, "Foo_x_get()");
+
+try
+ Foo_y_set(foo, 5);
+catch
+ swigtesterror();
+end
+checkequal(Foo_y_get(foo), 5, "Foo_y_get()");
+
+try
+ Foo_f_set(foo, 1);
+catch
+ swigtesterror();
+end
+checkequal(Foo_f_get(foo), 1, "Foo_f_get()");
+
+try
+ Foo_z_set(foo, 13);
+catch
+ swigtesterror();
+end
+checkequal(Foo_z_get(foo), 13, "Foo_z_get()");
+
+try
+ Foo_seq_set(foo, 3);
+catch
+ swigtesterror();
+end
+checkequal(Foo_seq_get(foo), 3, "Foo_seq_get()");
+
+try
+ delete_Foo(foo);
+catch
+ swigtesterror();
+end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/apply_signed_char_runme.sci b/Examples/test-suite/scilab/apply_signed_char_runme.sci
new file mode 100644
index 000000000..f4aa782eb
--- /dev/null
+++ b/Examples/test-suite/scilab/apply_signed_char_runme.sci
@@ -0,0 +1,43 @@
+exec("swigtest.start", -1);
+
+smallnum = -127;
+checkequal(CharValFunction(smallnum), smallnum, "CharValFunction(smallnum)");
+checkequal(CCharValFunction(smallnum), smallnum, "CCharValFunction(smallnum)");
+checkequal(CCharRefFunction(smallnum), smallnum, "CCharRefFunction(smallnum)");
+
+try
+ globalchar_set(smallnum);
+catch
+ swigtesterror();
+end
+checkequal(globalchar_get(), smallnum, "globalchar_get()");
+checkequal(globalconstchar_get(), -110, "globalconstchar_get()");
+
+try
+ dirTest = new_DirTest();
+catch
+ swigtesterror();
+end
+
+checkequal(DirTest_CharValFunction(dirTest, smallnum), smallnum, "DirTest_CharValFunction(dirTest, smallnum)");
+checkequal(DirTest_CCharValFunction(dirTest, smallnum), smallnum, "DirTest_CCharValFunction(dirTest, smallnum)");
+checkequal(DirTest_CCharRefFunction(dirTest, smallnum), smallnum, "DirTest_CCharRefFunction(dirTest, smallnum)");
+
+// TODO Too long identifiers
+//if dirTest_memberchar_get(dirTest) <> -111 then swigtesterror(); end
+//try
+// dirTest_memberchar_set(dirTest, smallnum)
+//catch
+// swigtesterror();
+//end
+//if dirTest_memberchar_get(dirTest) <> smallnum then swigtesterror(); end
+
+//if dirTest_memberconstchar_get(dirTest) <> -112 then swigtesterror(); end
+
+try
+ delete_DirTest(dirTest);
+catch
+ swigtesterror();
+end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/apply_strings_runme.sci b/Examples/test-suite/scilab/apply_strings_runme.sci
new file mode 100644
index 000000000..6fb039a7e
--- /dev/null
+++ b/Examples/test-suite/scilab/apply_strings_runme.sci
@@ -0,0 +1,45 @@
+exec("swigtest.start", -1);
+
+testString = "Scilab test string";
+
+checkequal(UCharFunction(testString), testString, "UCharFunction(testString)");
+checkequal(SCharFunction(testString), testString, "SCharFunction(testString)");
+checkequal(CUCharFunction(testString), testString, "CUCharFunction(testString)");
+checkequal(CSCharFunction(testString), testString, "CSCharFunction(testString)");
+//checkequal(CharFunction(testString), testString, "CharFunction(testString)");
+//checkequal(CCharFunction(testString), testString, "CCharFunction(testString)");
+
+try
+ tNum = new_TNum();
+catch
+ swigtesterror();
+end
+//TNumber_DigitsMemberA_get()
+//TNumber_DigitsMemberA_set
+//TNumber_DigitsMemberB_get()
+//TNumber_DigitsMemberB_set
+try
+ delete_TNum(tNum);
+catch
+ swigtesterror();
+end
+
+try
+ dirTest = new_DirTest();
+catch
+ swigtesterror();
+end
+
+checkequal(DirTest_UCharFunction(dirTest, testString), testString, "DirTest_UCharFunction");
+checkequal(DirTest_SCharFunction(dirTest, testString), testString, "DirTest_SCharFunction(dirTest, testString)");
+checkequal(DirTest_CUCharFunction(dirTest, testString), testString, "DirTest_CUCharFunction(dirTest, testString)");
+checkequal(DirTest_CSCharFunction(dirTest, testString), testString, "DirTest_CSharFunction(dirTest, testString)");
+//checkequal(DirTest_CharFunction(dirTest, testString), testString, "DirTest_CharFunction(dirTest, testString)");
+//checkequal(DirTest_CCharFunction(dirTest, testString), testString, "DirTest_CCharFunction(dirTest, testString)");
+try
+ delete_DirTest(dirTest);
+catch
+ swigtesterror();
+end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/array_member_runme.sci b/Examples/test-suite/scilab/array_member_runme.sci
new file mode 100644
index 000000000..d839f48ee
--- /dev/null
+++ b/Examples/test-suite/scilab/array_member_runme.sci
@@ -0,0 +1,16 @@
+exec("swigtest.start", -1);
+
+f = new_Foo();
+Foo_data_set(f, [0:7]);
+checkequal(Foo_data_get(f), [0:7], "Foo_data_get()");
+
+Foo_text_set(f, "abcdefgh");
+checkequal(Foo_text_get(f), "abcdefgh", "Foo_text_get()");
+delete_Foo(f);
+
+m = new_MyBuff();
+MyBuff_x_set(m, [0:11]);
+checkequal(MyBuff_x_get(m), [0:11], "MyBuff_x_get()");
+delete_MyBuff(m);
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/arrays_dimensionless_runme.sci b/Examples/test-suite/scilab/arrays_dimensionless_runme.sci
new file mode 100644
index 000000000..ac737545f
--- /dev/null
+++ b/Examples/test-suite/scilab/arrays_dimensionless_runme.sci
@@ -0,0 +1,55 @@
+exec("swigtest.start", -1);
+
+// bool
+checkequal(arr_bool([%T %F %F %T %F %T %T %T], 8), 5, "arr_bool");
+
+// char
+checkequal(arr_char(["charptr"], 7), 756, "arr_char");
+
+// signed char
+checkequal(arr_schar([1, 2, 3, 4], 4), 10, "arr_schar");
+checkequal(arr_schar(int8([1, 2, 3, 4]), 4), 10, "arr_schar");
+
+// unsigned char
+checkequal(arr_uchar([1, 2, 3, 4], 4), 10, "arr_uchar");
+checkequal(arr_uchar(uint8([1, 2, 3, 4]), 4), 10, "arr_uchar");
+
+// short
+checkequal(arr_short([1, 2, 3, 4], 4), 10, "arr_short");
+checkequal(arr_short(int16([1, 2, 3, 4]), 4), 10, "arr_short");
+
+// unsigned short
+checkequal(arr_ushort([1, 2, 3, 4], 4), 10, "arr_ushort");
+checkequal(arr_ushort(uint16([1, 2, 3, 4]), 4), 10, "arr_ushort");
+
+// int
+checkequal(arr_int([1, 2, 3, 4], 4), 10, "arr_int");
+checkequal(arr_int(int32([1, 2, 3, 4]), 4), 10, "arr_int");
+
+// unsigned int
+checkequal(arr_uint([1, 2, 3, 4], 4), 10, "");
+checkequal(arr_uint(uint32([1, 2, 3, 4]), 4), 10, "");
+
+// long
+checkequal(arr_long([1, 2, 3, 4], 4), 10, "arr_long");
+checkequal(arr_long(int32([1, 2, 3, 4]), 4), 10, "arr_long");
+
+// unsigned long
+checkequal(arr_ulong([1, 2, 3, 4], 4), 10, "arr_ulong");
+checkequal(arr_ulong(uint32([1, 2, 3, 4]), 4), 10, "arr_ulong");
+
+// long long
+// No equivalent in Scilab 5
+
+// unsigned long long
+// No equivalent in Scilab 5
+
+// float
+a = [1, 2, 3, 4];
+checkequal(arr_float(a, 4), 10, "arr_float");
+
+// double
+a = [1, 2, 3, 4];
+checkequal(arr_double(a, 4), 10, "arr_double");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/arrays_global_runme.sci b/Examples/test-suite/scilab/arrays_global_runme.sci
new file mode 100644
index 000000000..2426276c5
--- /dev/null
+++ b/Examples/test-suite/scilab/arrays_global_runme.sci
@@ -0,0 +1,54 @@
+exec("swigtest.start", -1);
+
+function testArray(arrayName, arraySetFunc, arrayGetFunc, in_values, ..
+ expected_out_values)
+ try
+ arraySetFunc(in_values);
+ catch
+ swigtesterror("error in " + arrayName + "_set()");
+ end
+ try
+ checkequal(arrayGetFunc(), expected_out_values, arrayName + "_get()");
+ catch
+ swigtesterror("error in " + arrayName + "_get()");
+ end
+endfunction
+
+m = [-10, 20];
+um = [10, 20];
+testArray("array_c", array_c_set, array_c_get, ['ab'], ['ab']);
+testArray("array_sc", array_sc_set, array_sc_get, m, m);
+testArray("array_sc", array_sc_set, array_sc_get, int8(m), m);
+testArray("array_uc", array_uc_set, array_uc_get, uint8(um), um);
+testArray("array_s", array_s_set, array_s_get, m, m);
+testArray("array_s", array_s_set, array_s_get, int16(m), m);
+testArray("array_us", array_us_set, array_us_get, uint16(um), um);
+testArray("array_i", array_i_set, array_i_get, m, m);
+testArray("array_i", array_i_set, array_i_get, int32(m), m);
+testArray("array_ui", array_ui_set, array_ui_get, uint32(um), um);
+testArray("array_l", array_l_set, array_l_get, m, m);
+testArray("array_l", array_l_set, array_l_get, int32(m), m);
+testArray("array_ul", array_ul_set, array_ul_get, uint32(um), um);
+testArray("array_f", array_f_set, array_f_get, [-2.5, 2.5], [-2.5, 2.5]);
+testArray("array_d", array_d_set, array_d_get, [-10.5, 20.4], [-10.5, 20.4]);
+
+checkequal(array_const_i_get(), [10, 20], "array_const_i_get()");
+
+ierr = execstr('array_i_set([0:10]', 'errcatch');
+if ierr == 0 then swigtesterror("Overflow error expected"); end
+
+checkequal(BeginString_FIX44a_get(), "FIX.a.a", "BeginString_FIX44a_get()");
+checkequal(BeginString_FIX44b_get(), "FIX.b.b", "BeginString_FIX44b_get()");
+checkequal(BeginString_FIX44c_get(), "FIX.c.c", "BeginString_FIX44c_get()");
+checkequal(BeginString_FIX44d_get(), "FIX.d.d", "BeginString_FIX44d_get()");
+BeginString_FIX44b_set(strcat(["12","\0","45"]));
+checkequal(BeginString_FIX44b_get(), "12\045", "BeginString_FIX44b_get()");
+checkequal(BeginString_FIX44d_get(), "FIX.d.d", "BeginString_FIX44d_get()");
+checkequal(BeginString_FIX44e_get(), "FIX.e.e", "BeginString_FIX44e_get()");
+checkequal(BeginString_FIX44f_get(), "FIX.f.f", "BeginString_FIX44f_get()");
+
+checkequal(test_a("hello","hi","chello","chi"), "hi", "test_a()");
+
+checkequal(test_b("1234567","hi"), "1234567", "test_b()");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/arrays_global_twodim_runme.sci b/Examples/test-suite/scilab/arrays_global_twodim_runme.sci
new file mode 100644
index 000000000..6af5ff217
--- /dev/null
+++ b/Examples/test-suite/scilab/arrays_global_twodim_runme.sci
@@ -0,0 +1,12 @@
+exec("swigtest.start", -1);
+
+a = [1, 2, 3, 4; 5, 6, 7, 8;]
+
+//try
+// array_d_set(a);
+//catch
+// swigtesterror();
+//end
+//if array_d_get() <> a then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/bools_runme.sci b/Examples/test-suite/scilab/bools_runme.sci
new file mode 100644
index 000000000..9516a5df5
--- /dev/null
+++ b/Examples/test-suite/scilab/bools_runme.sci
@@ -0,0 +1,20 @@
+exec("swigtest.start", -1);
+
+function checkBool(bool_val, expected_bool_val)
+ if typeof(bool_val) <> "boolean" then swigtesterror(); end
+ if bool_val <> expected_bool_val then swigtesterror(); end
+endfunction
+
+checkBool(constbool_get(), %f);
+
+checkBool(bool1_get(), %t);
+checkBool(bool2_get(), %f);
+
+checkBool(bo(%t), %t);
+checkBool(bo(%f), %f);
+
+bs = new_BoolSt();
+checkBool(BoolSt_m_bool1_get(bs), %t);
+checkBool(BoolSt_m_bool2_get(bs), %f);
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/char_constant_runme.sci b/Examples/test-suite/scilab/char_constant_runme.sci
new file mode 100644
index 000000000..e48e3068d
--- /dev/null
+++ b/Examples/test-suite/scilab/char_constant_runme.sci
@@ -0,0 +1,9 @@
+exec("swigtest.start", -1);
+
+if CHAR_CONSTANT_get() <> "x" then swigtesterror(); end
+if STRING_CONSTANT_get() <> "xyzzy" then swigtesterror(); end
+if ESC_CONST_get() <> ascii(1) then swigtesterror(); end
+if ia_get() <> ascii('a') then swigtesterror(); end
+if ib_get() <> ascii('b') then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/constover_runme.sci b/Examples/test-suite/scilab/constover_runme.sci
new file mode 100644
index 000000000..5b8935f68
--- /dev/null
+++ b/Examples/test-suite/scilab/constover_runme.sci
@@ -0,0 +1,22 @@
+exec("swigtest.start", -1);
+
+p = test("test");
+if strcmp(p, "test") <> 0 then swigtesterror(); end
+
+p = test_pconst("test");
+if strcmp(p, "test_pconst") <> 0 then swigtesterror(); end
+
+f = new_Foo();
+p = Foo_test(f, "test");
+if strcmp(p,"test") <> 0 then swigtesterror(); end
+
+p = Foo_test_pconst(f, "test");
+if strcmp(p,"test_pconst") <> 0 then swigtesterror(); end
+
+p = Foo_test_constm(f, "test");
+if strcmp(p,"test_constmethod") <> 0 then swigtesterror(); end
+
+p = Foo_test_pconstm(f, "test");
+if strcmp(p,"test_pconstmethod") <> 0 then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/constructor_copy_runme.sci b/Examples/test-suite/scilab/constructor_copy_runme.sci
new file mode 100644
index 000000000..bfd2b1c20
--- /dev/null
+++ b/Examples/test-suite/scilab/constructor_copy_runme.sci
@@ -0,0 +1,36 @@
+exec("swigtest.start", -1);
+
+
+f1 = new_Foo1(3);
+f11 = new_Foo1(f1);
+
+checkequal(Foo1_x_get(f1), Foo1_x_get(f11), "Foo1_x_get(f1) <> Foo1_x_get(f11)");
+
+delete_Foo1(f1);
+delete_Foo1(f11);
+
+f8 = new_Foo8();
+try
+ f81 = new_Foo8(f8);
+ swigtesterror("Foo(f8) called.");
+catch
+end
+
+bi = new_Bari(5);
+bc = new_Bari(bi);
+
+checkequal(Bari_x_get(bi), Bari_x_get(bc), "Bar_x_get(bi) <> Bar_x_get(bc)");
+
+delete_Bari(bi);
+delete_Bari(bc);
+
+bd = new_Bard(5);
+try
+ bc = Bard(bd);
+ swigtesterror("Bard(bd) called.");
+catch
+end
+
+
+exec("swigtest.quit", -1);
+
diff --git a/Examples/test-suite/scilab/cpp_basic_runme.sci b/Examples/test-suite/scilab/cpp_basic_runme.sci
new file mode 100644
index 000000000..6b64de4db
--- /dev/null
+++ b/Examples/test-suite/scilab/cpp_basic_runme.sci
@@ -0,0 +1,64 @@
+exec("swigtest.start", -1);
+
+f = new_Foo(4);
+checkequal(Foo_num_get(f), 4, "Foo_num_get(f)");
+Foo_num_set(f, -17);
+checkequal(Foo_num_get(f), -17, "Foo_num_get(f)");
+
+b = new_Bar();
+Bar_fptr_set(b, f);
+
+fptr = Bar_fptr_get(b);
+checkequal(Foo_num_get(fptr), -17, "Foo_num_get(ftr)");
+
+checkequal(Bar_test(b, -3, fptr), -5, "Bar_test(b, -3, fptr)");
+
+fref = Bar_fref_get(b);
+checkequal(Foo_num_get(fref), -4, "Foo_num_get(fref)");
+
+checkequal(Bar_test(b, 12, fref), 23, "Bar_test(b, 12, fref)");
+
+f2 = new_Foo(23);
+Bar_fref_set(b, f2);
+
+fref = Bar_fref_get(b);
+checkequal(Foo_num_get(fref), 23, "Foo_num_get(fref)");
+
+fval = Bar_fval_get(b);
+checkequal(Bar_test(b, 3, fval), 33, "Bar_test(b, 3, fval)");
+
+Bar_fval_set(b, new_Foo(-15));
+
+fval = Bar_fval_get(b);
+checkequal(Foo_num_get(fval), -15, "Foo_num_get(fval)");
+checkequal(Bar_test(b, 3, fval), -27, "Bar_test(b, 3, fval)");
+
+f3 = Bar_testFoo(b, 12, fref);
+checkequal(Foo_num_get(f3), 32, "Foo_num_get(f3)");
+
+
+// Test globals
+f4 = new_Foo(6);
+Bar_global_fptr_set(f4);
+checkequal(Foo_num_get(Bar_global_fptr_get()), 6, "Foo_num_get(Bar_global_fptr_get())");
+
+checkequal(Foo_num_get(Bar_global_fref_get()), 23, "Foo_num_get(Bar_global_fref_get())");
+
+checkequal(Foo_num_get(Bar_global_fval_get()), 3, "Foo_num_get(Bar_global_fval_get())");
+
+
+// Test member function pointers
+func1_ptr = get_func1_ptr();
+func2_ptr = get_func2_ptr();
+
+Foo_num_set(f, 4);
+checkequal(Foo_func1(f, 2), 16, "Foo_func1(f, 2)");
+checkequal(Foo_func2(f, 2), -8, "Foo_func2(f, 2)");
+
+Foo_func_ptr_set(f, func1_ptr);
+checkequal(test_func_ptr(f, 2), 16, "Foo_test_func_ptr(f, 2)");
+
+Foo_func_ptr_set(f, func2_ptr);
+checkequal(test_func_ptr(f, 2), -8, "Foo_test_func_ptr(f, 2)");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/cpp_enum_runme.sci b/Examples/test-suite/scilab/cpp_enum_runme.sci
new file mode 100644
index 000000000..d684affe9
--- /dev/null
+++ b/Examples/test-suite/scilab/cpp_enum_runme.sci
@@ -0,0 +1,10 @@
+exec("swigtest.start", -1);
+
+f = new_Foo();
+
+if Foo_hola_get(f) <> Hello_get() then swigtesterror("Foo_hola_get() <> ""Hello"""); end
+
+Foo_hola_set(f, Hi_get());
+if Foo_hola_get(f) <> Hi_get() then swigtesterror("Foo_hola_get() <> ""Hi"""); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/default_args_runme.sci b/Examples/test-suite/scilab/default_args_runme.sci
new file mode 100644
index 000000000..15754fdfd
--- /dev/null
+++ b/Examples/test-suite/scilab/default_args_runme.sci
@@ -0,0 +1,67 @@
+exec("swigtest.start", -1);
+
+checkequal(anonymous(), 7771, "anonymous()");
+checkequal(anonymous(1234), 1234, "anonymous(1234)");
+
+checkequal(booltest(), %T, "booltest()");
+checkequal(booltest(%T), %T, "booltest(%T)");
+checkequal(booltest(%F), %F, "booltest(%T)");
+
+ec = new_EnumClass();
+checkequal(EnumClass_blah(ec), %T, "EnumClass_blah(ec)");
+
+checkequal(casts1(), [], "casts1()");
+checkequal(casts1("Ciao"), "Ciao", "casts1(""Ciao"")");
+checkequal(casts2(), "Hello", "casts2()");
+checkequal(chartest1(), 'x', "chartest1()");
+checkequal(chartest2(), '', "chartest2()");
+checkequal(chartest1('y'), 'y', "chartest1(''y'')");
+checkequal(reftest1(), 42, "reftest1()");
+checkequal(reftest1(400), 400, "reftest1(400)");
+checkequal(reftest2(), "hello", "reftest2()");
+
+// Rename
+f = new_Foo();
+Foo_newname(f);
+Foo_newname(f, 10);
+Foo_renamed3arg(f, 10, 10.0);
+Foo_renamed2arg(f, 10);
+Foo_renamed1arg(f);
+delete_Foo(f);
+
+// Static functions
+checkequal(Statics_staticmethod(), 10+20+30, "Statics_staticmethod()");
+checkequal(Statics_staticmethod(100), 100+20+30, "Statics_staticmethod(100)");
+checkequal(Statics_staticmethod(100, 200, 300), 100+200+300, "Statics_staticmethod(100, 200, 300)");
+
+tricky = new_Tricky();
+checkequal(Tricky_privatedefault(tricky), 200, "Tricky_privatedefault(tricky)");
+checkequal(Tricky_protectedint(tricky), 2000, "Tricky_protectedint(tricky)");
+checkequal(Tricky_protecteddouble(tricky), 987.654, "Tricky_protecteddouble(tricky)");
+checkequal(Tricky_functiondefault(tricky), 500, "Tricky_functiondefault(tricky)");
+checkequal(Tricky_contrived(tricky), 'X', "Tricky_contrived(tricky)");
+delete_Tricky(tricky);
+
+// Default argument is a constructor
+k = constructorcall();
+checkequal(Klass_val_get(k), -1, "Klass_constructorcall()");
+delete_Klass(k);
+k = constructorcall(new_Klass(2222));
+checkequal(Klass_val_get(k), 2222, "Klass_constructorcall(new Klass(2222)");
+delete_Klass(k);
+k = constructorcall(new_Klass());
+checkequal(Klass_val_get(k), -1, "Klass_constructorcall(new_Klass()");
+delete_Klass(k);
+
+// Const methods
+cm = new_ConstMethods();
+checkequal(ConstMethods_coo(cm), 20, "ConstMethods_coo()");
+checkequal(ConstMethods_coo(cm, 1.0), 20, "ConstMethods_coo(1.0)");
+
+// C linkage (extern "C")
+checkequal(cfunc1(1), 2, "cfunc1(1)");
+checkequal(cfunc2(1), 3, "cfunc2(1)");
+checkequal(cfunc3(1), 4, "cfunc3(1)");
+
+exec("swigtest.quit", -1);
+
diff --git a/Examples/test-suite/scilab/default_constructor_runme.sci b/Examples/test-suite/scilab/default_constructor_runme.sci
new file mode 100644
index 000000000..6c5250bec
--- /dev/null
+++ b/Examples/test-suite/scilab/default_constructor_runme.sci
@@ -0,0 +1,113 @@
+exec("swigtest.start", -1);
+
+a = new_A();
+delete_A(a);
+
+aa = new_AA();
+delete_AA(aa);
+
+try
+ b = new_B();
+ swigtestswigtesterror("new_BB created.")
+catch
+end
+
+del_b = delete_B;
+
+try
+ bb = new_BB();
+ swigtesterror("new_BB created.")
+catch
+
+end
+
+del_bb = delete_BB;
+
+try
+ c = new_C();
+ swigtesterror("new_C created.")
+catch
+end
+
+del_c = delete_C;
+
+cc = new_CC();
+delete_CC(cc);
+
+try
+ d = new_D();
+ swigtesterror("new_D created")
+catch
+end
+
+del_d = delete_D;
+
+try
+ dd = new_DD();
+ swigtesterror("new_DD created")
+catch
+end
+
+dd = delete_DD;
+
+try
+ ad = new_AD();
+ swigtesterror("new_AD created")
+catch
+end
+
+del_ad = delete_AD;
+
+exec("swigtest.start", -1);
+
+e = new_E();
+delete_E(e);
+
+ee = new_EE();
+delete_EE(ee);
+
+try
+ eb = new_EB();
+ swigtesterror("new_EB created")
+catch
+end
+
+del_eb = delete_EB;
+
+f = new_F();
+
+try
+ del_f = delete_F;
+ swigtesterror("delete_F created")
+catch
+end
+
+F_destroy(f);
+
+ff = new_FFF();
+try
+ del_ff = delete_FFF;
+ swigtesterror("delete_FFF created")
+catch
+end
+
+F_destroy(ff);
+
+g = new_G();
+
+try
+ del_g = delete_G;
+ swigtesterror("delete_G created")
+catch
+end
+
+G_destroy(g);
+
+gg = new_GG();
+delete_GG(gg);
+
+hh = new_HH(1,1);
+
+exec("swigtest.quit", -1);
+
+
diff --git a/Examples/test-suite/scilab/empty_runme.sci b/Examples/test-suite/scilab/empty_runme.sci
new file mode 100644
index 000000000..48db2d52b
--- /dev/null
+++ b/Examples/test-suite/scilab/empty_runme.sci
@@ -0,0 +1,3 @@
+exec("swigtest.start", -1);
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/enums_runme.sci b/Examples/test-suite/scilab/enums_runme.sci
new file mode 100644
index 000000000..7320d7867
--- /dev/null
+++ b/Examples/test-suite/scilab/enums_runme.sci
@@ -0,0 +1,39 @@
+exec("swigtest.start", -1);
+
+if typeof(CSP_ITERATION_FWD_get()) <> "constant" then swigtesterror(); end
+if typeof(CSP_ITERATION_BWD_get()) <> "constant" then swigtesterror(); end
+if typeof(ABCDE_get()) <> "constant" then swigtesterror(); end
+if typeof(FGHJI_get()) <> "constant" then swigtesterror(); end
+
+try
+ bar1(CSP_ITERATION_FWD_get())
+ bar1(CSP_ITERATION_BWD_get())
+ bar1(1)
+ bar1(int32(1))
+
+ bar2(ABCDE_get())
+ bar2(FGHJI_get())
+ bar2(1)
+ bar2(int32(1))
+
+ bar3(ABCDE_get())
+ bar3(FGHJI_get())
+ bar3(1)
+ bar3(int32(1))
+catch
+ swigtesterror()
+end
+
+if typeof(enumInstance_get()) <> "constant" then swigtesterror(); end
+if enumInstance_get() <> 2 then swigtesterror(); end
+
+if typeof(Slap_get()) <> "constant" then swigtesterror(); end
+if Slap_get() <> 10 then swigtesterror(); end
+
+if typeof(Mine_get()) <> "constant" then swigtesterror(); end
+if Mine_get() <> 11 then swigtesterror(); end
+
+if typeof(Thigh_get()) <> "constant" then swigtesterror(); end
+if Thigh_get() <> 12 then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/funcptr_cpp_runme.sci b/Examples/test-suite/scilab/funcptr_cpp_runme.sci
new file mode 100644
index 000000000..cb4c3cd0d
--- /dev/null
+++ b/Examples/test-suite/scilab/funcptr_cpp_runme.sci
@@ -0,0 +1,7 @@
+exec("swigtest.start", -1);
+
+checkequal(call1(ADD_BY_VALUE_get(), 10, 11), 21, "ADD_BY_VALUE");
+checkequal(call2(ADD_BY_POINTER_get(), 12, 13), 25, "ADD_BY_POINTER");
+checkequal(call3(ADD_BY_REFERENCE_get(), 14, 15), 29, "ADD_BY_REFERENCE");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/funcptr_runme.sci b/Examples/test-suite/scilab/funcptr_runme.sci
new file mode 100644
index 000000000..430d15349
--- /dev/null
+++ b/Examples/test-suite/scilab/funcptr_runme.sci
@@ -0,0 +1,6 @@
+exec("swigtest.start", -1);
+
+if add(7, 9) <> 16 then swigtesterror(); end
+if do_op(7, 9, funcvar_get()) <> 16 then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/global_vars_runme.sci b/Examples/test-suite/scilab/global_vars_runme.sci
new file mode 100644
index 000000000..721eaf614
--- /dev/null
+++ b/Examples/test-suite/scilab/global_vars_runme.sci
@@ -0,0 +1,31 @@
+exec("swigtest.start", -1);
+
+b_set("hello");
+checkequal(b_get(), "hello", "b_get()");
+
+sa = new_A();
+A_x_set(sa, 5);
+checkequal(A_x_get(sa), 5, "A_x_get(sa)");
+
+a_set(sa);
+checkequal(A_x_get(a_get()), 5, "A_x_get(a)");
+
+ap_set(sa);
+A_x_set(sa, 14);
+checkequal(A_x_get(ap_get()), 14, "A_x_get(ap)");
+delete_A(sa);
+
+sa2 = new_A();
+cap_set(sa2);
+A_x_set(sa2, 16);
+checkequal(A_x_get(cap_get()), 16, "A_x_get(cap)");
+
+checkequal(A_x_get(ar_get()), 5, "A_x_get(ar)");
+ar_set(sa2);
+checkequal(A_x_get(ar_get()), 16, "A_x_get(ar)");
+delete_A(sa2);
+
+x_set(11);
+checkequal(x_get(), 11, "x_get()");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/inctest_runme.sci b/Examples/test-suite/scilab/inctest_runme.sci
new file mode 100644
index 000000000..5a8df7b8f
--- /dev/null
+++ b/Examples/test-suite/scilab/inctest_runme.sci
@@ -0,0 +1,20 @@
+exec("swigtest.start", -1);
+
+try
+ a = new_A();
+catch
+ printf("did not find A\ntherefore, I did not include ""testdir/subdir1/hello.i""\n");
+ swigtesterror();
+end
+
+try
+ b = new_B();
+catch
+ printf("did not find B\ntherefore, I did not include ""testdir/subdir2/hello.i""\n");
+ swigtesterror();
+end
+
+if importtest1(5) <> 15 then swigtesterror(); end
+if importtest2("black") <> "white" then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/inherit_missing_runme.sci b/Examples/test-suite/scilab/inherit_missing_runme.sci
new file mode 100644
index 000000000..d68ab7e1f
--- /dev/null
+++ b/Examples/test-suite/scilab/inherit_missing_runme.sci
@@ -0,0 +1,15 @@
+exec("swigtest.start", -1);
+
+a = new_Foo();
+b = new_Bar();
+c = new_Spam();
+
+checkequal(do_blah(a), "Foo::blah", "do_blah(a)");
+checkequal(do_blah(b), "Bar::blah", "do_blah(b)");
+checkequal(do_blah(c), "Spam::blah", "do_blah(c)");
+
+delete_Foo(a);
+delete_Bar(b);
+delete_Spam(c);
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/inout_runme.sci b/Examples/test-suite/scilab/inout_runme.sci
new file mode 100644
index 000000000..6c25a6deb
--- /dev/null
+++ b/Examples/test-suite/scilab/inout_runme.sci
@@ -0,0 +1,15 @@
+exec("swigtest.start", -1);
+
+a = AddOne1(10);
+if a <> 11 then swigtesterror(); end
+
+[a, b, c] = AddOne3(1, 2, 3);
+if a <> 2 then swigtesterror(); end
+if b <> 3 then swigtesterror(); end
+if c <> 4 then swigtesterror(); end
+
+a = AddOne1r(20);
+if a <> 21 then swigtesterror(); end
+
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/integers_runme.sci b/Examples/test-suite/scilab/integers_runme.sci
new file mode 100644
index 000000000..1a59578d8
--- /dev/null
+++ b/Examples/test-suite/scilab/integers_runme.sci
@@ -0,0 +1,29 @@
+exec("swigtest.start", -1);
+
+// Negative values
+checkequal(signed_char_identity(-1), -1, "signed_char_identity(-1)");
+checkequal(signed_short_identity(-1), -1, "signed_short_identity(-1)");
+checkequal(signed_int_identity(-1), -1, "signed_int_identity(-1)");
+checkequal(signed_long_identity(-1), -1, "signed_long_identity(-1)");
+
+// Overflow errors
+ierr = execstr('signed_char_identity(2^8)', 'errcatch');
+checkequal(ierr, 20007, 'signed_char_identity(2^8)');
+ierr = execstr('signed_short_identity(2^16)', 'errcatch');
+checkequal(ierr, 20007, 'signed_short_identity(2^16)');
+ierr = execstr('signed_int_identity(2^32)', 'errcatch');
+checkequal(ierr, 20007, 'signed_int_identity(2^32)');
+ierr = execstr('signed_long_identity(2^64)', 'errcatch');
+checkequal(ierr, 20007, 'signed_long_identity(2^64)');
+
+// Value errors
+ierr = execstr('signed_char_identity(100.2)', 'errcatch');
+checkequal(ierr, 20009, 'signed_char_identity(100.2)');
+ierr = execstr('signed_short_identity(100.2)', 'errcatch');
+checkequal(ierr, 20009, 'signed_short_identity(100.2)');
+ierr = execstr('signed_int_identity(100.2)', 'errcatch');
+checkequal(ierr, 20009, 'signed_int_identity(100.2)');
+ierr = execstr('signed_long_identity(100.2)', 'errcatch');
+checkequal(ierr, 20009, 'signed_long_identity(100.2)');
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/li_carrays_runme.sci b/Examples/test-suite/scilab/li_carrays_runme.sci
new file mode 100644
index 000000000..0ac157446
--- /dev/null
+++ b/Examples/test-suite/scilab/li_carrays_runme.sci
@@ -0,0 +1,11 @@
+exec("swigtest.start", -1);
+
+d = new_intArray(10);
+
+intArray_setitem(d, 0, 7);
+
+intArray_setitem(d, 5, intArray_getitem(d, 0) + 3);
+
+checkequal(intArray_getitem(d, 5) + intArray_getitem(d, 0), 17, "d(5) + d(0) <> 17");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/li_cpointer_runme.sci b/Examples/test-suite/scilab/li_cpointer_runme.sci
new file mode 100644
index 000000000..0aa4339c8
--- /dev/null
+++ b/Examples/test-suite/scilab/li_cpointer_runme.sci
@@ -0,0 +1,8 @@
+exec("swigtest.start", -1);
+
+p = new_intp();
+intp_assign(p, 3);
+checkequal(intp_value(p), 3, "intp_value(p)");
+delete_intp(p);
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/li_math_runme.sci b/Examples/test-suite/scilab/li_math_runme.sci
new file mode 100644
index 000000000..d05f8eb18
--- /dev/null
+++ b/Examples/test-suite/scilab/li_math_runme.sci
@@ -0,0 +1,9 @@
+exec("swigtest.start", -1);
+
+try
+ x = fmod(M_PI_get(), M_1_PI_get())
+catch
+ swigtesterror();
+end
+
+exec("swigtest.quit", -1);
\ No newline at end of file
diff --git a/Examples/test-suite/scilab/li_std_container_typemaps_runme.sci b/Examples/test-suite/scilab/li_std_container_typemaps_runme.sci
new file mode 100644
index 000000000..e4832efe6
--- /dev/null
+++ b/Examples/test-suite/scilab/li_std_container_typemaps_runme.sci
@@ -0,0 +1,108 @@
+// test STL containers typemaps
+
+exec("swigtest.start", -1);
+
+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)
+function [classAPtr_list, classAPtr1, classAPtr2] = testCreateContainerPtr(container, value1, value2)
+ classAPtr1 = new_ClassA(value1);
+ classAPtr2 = new_ClassA(value2);
+ func = msprintf("ret_ClassAPtr_%s", container);
+ cmd = msprintf("classAPtr_list = %s(classAPtr1, classAPtr2);", func);
+ ierr = execstr(cmd, "errcatch");
+ if ierr <> 0 then swigtesterror("error in " + cmd); end
+ if ~exists('classAPtr_list') | (size(classAPtr_list) <> 2) then
+ swigtesterror(func);
+ end
+
+ checkequal(ClassA_a_get(classAPtr_list(1)), value1, "ClassA_a_get(classAPtr_list(1))");
+ checkequal(ClassA_a_get(classAPtr_list(2)), value2, "ClassA_a_get(classAPtr_list(2))");
+endfunction
+
+// test a given container of pointer
+// -container: type of container: "vector", "set"...
+// -value1, value2: values to store in container
+// -expected_accumulate_value: expected value of an accumulation function
+// computed on the container
+function testContainerPtr(container, value1, value2, expected_accumulate_value)
+ // test container of pointers returned from flonction (expected a list)
+ [classAPtr_list, classAPtr1, classAPtr2] = testCreateContainerPtr(container, value1, value2);
+
+ // test container passed as value of function
+ func = msprintf("val_ClassAPtr_%s", container);
+ cmd = msprintf("classAPtr = %s(classAPtr_list);", func);
+ ierr = execstr(cmd, "errcatch");
+ checkerror(ierr, cmd);
+ checkequal(ClassA_a_get(classAPtr), expected_accumulate_value, func);
+
+ // recreate a container
+ [classAPtr_list, classAPtr1, classAPtr2] = testCreateContainerPtr(container, value1, value2);
+
+ // test container passed as reference of function
+ func = msprintf("ref_ClassAPtr_%s", container);
+ cmd = msprintf("classAPtr = %s(classAPtr_list);", func);
+ ierr = execstr(cmd, "errcatch");
+ checkerror(ierr, cmd);
+ checkequal(ClassA_a_get(classAPtr), expected_accumulate_value, func);
+endfunction
+
+// test a given container of a given primitive type
+// -container: type of container: "vector", "set"...
+// -value_type: type of element stored in container: "int", ...
+// -value1, value2: values to store in container
+// -expected_accumulate_value: expected value of an accumulation function
+// 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
+ func = msprintf("ret_%s_%s", value_type, container);
+ if value_type == "string" then
+ cmd = msprintf("c = %s(''%s'', ''%s'');", func, value1, value2);
+ elseif value_type == "bool" then
+ cmd = msprintf("c = %s(%s, %s);", func, "%"+string(value1), "%"+string(value2));
+ else
+ cmd = msprintf("c = %s(%d, %d);", func, value1, value2);
+ end
+ ierr = execstr(cmd, "errcatch");
+ checkerror(ierr, cmd);
+ checkequal(c, expected_returned_container, func);
+
+ // test container passed as value of function
+ func = msprintf("val_%s_%s", value_type, container);
+ cmd = msprintf("s = %s(c);", func);
+ ierr = execstr(cmd, "errcatch");
+ checkerror(ierr, cmd);
+ checkequal(s, expected_accumulate_value, func);
+
+ // test container passed as reference of function
+ func = msprintf("ref_%s_%s", value_type, container);
+ cmd = msprintf("s = %s(c);", func);
+ ierr = execstr(cmd, "errcatch");
+ checkerror(ierr, cmd);
+ checkequal(s, expected_accumulate_value, func);
+endfunction
+
+// test a given container of different types
+// -container: type of container: "vector", "set"...
+function testContainer(container)
+ testContainerType(container, "int", 1, 2, [1, 2], 3);
+ testContainerType(container, "double", 2., 3., [2., 3.], 5.);
+ testContainerType(container, "float", 2., 3., [2., 3.], 5.);
+ testContainerType(container, "string", "a", "b", ["a", "b"], "ab");
+ testContainerType(container, "bool", %F, %T, [%F, %T], %T);
+ testContainerPtr("vector", 1, 3, 4);
+endfunction
+
+
+testContainer("vector");
+testContainer("list");
+testContainer("deque");
+testContainer("set");
+testContainer("multiset");
+
+exec("swigtest.quit", -1);
+
+
diff --git a/Examples/test-suite/scilab/li_std_deque_runme.sci b/Examples/test-suite/scilab/li_std_deque_runme.sci
new file mode 100644
index 000000000..c0680846b
--- /dev/null
+++ b/Examples/test-suite/scilab/li_std_deque_runme.sci
@@ -0,0 +1,49 @@
+exec("swigtest.start", -1);
+
+// Test constructors for std::deque
+intDeque = new_IntDeque();
+intDeque2 = new_IntDeque(3);
+intDeque3 = new_IntDeque(4, 42);
+//intDeque4 = new_IntDeque(intDeque3);
+
+// Test constructors for std::deque
+doubleDeque = new_DoubleDeque();
+doubleDeque2 = new_DoubleDeque(3);
+doubleDeque3 = new_DoubleDeque(4, 42.0);
+//doubleDeque4 = new_DoubleDeque(doubleDeque3);
+
+// Test constructors for std::deque
+realDeque = new_RealDeque();
+realDeque2 = new_RealDeque(3);
+realDeque3 = new_RealDeque(4, 42.0);
+//realDeque4 = new_RealDeque(realDeque3);
+
+// average() should return the average of all values in a std::deque
+IntDeque_push_back(intDeque, 2);
+IntDeque_push_back(intDeque, 4);
+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
+RealDeque_clear(realDeque);
+RealDeque_push_front(realDeque, 2.0);
+RealDeque_push_front(realDeque, 4.0);
+halfDeque = half(realDeque);
+checkequal(halfDeque, [2., 1.], "half(realDeque)");
+
+// same for halve_in_place
+//DoubleDeque_clear(doubleDeque);
+//DoubleDeque_push_front(doubleDeque, 2.0);
+//DoubleDeque_push_front(doubleDeque, 4.0);
+//halfDeque2 = halve_in_place(doubleDeque);
+//checkequal(halfDeque2, [2., 1.], "halve_in_place(doubleDeque)");
+
+delete_IntDeque(intDeque);
+delete_DoubleDeque(doubleDeque);
+delete_RealDeque(realDeque);
+
+exec("swigtest.quit", -1);
+
+
+
diff --git a/Examples/test-suite/scilab/li_std_except_runme.sci b/Examples/test-suite/scilab/li_std_except_runme.sci
new file mode 100644
index 000000000..3b6522f45
--- /dev/null
+++ b/Examples/test-suite/scilab/li_std_except_runme.sci
@@ -0,0 +1,33 @@
+exec('swigtest.start', -1);
+
+function checkException(cmd, expected_ierr, expected_error_msg)
+ ierr = execstr(cmd, 'errcatch');
+ checkequal(ierr, expected_ierr, cmd + ': ierr');
+ checkequal(lasterror(), 'SWIG/Scilab: ' + expected_error_msg, cmd + ': msg');
+endfunction
+
+t = new_Test();
+
+checkException('Test_throw_bad_exception(t)', 20010, 'SystemError: std::bad_exception');
+
+checkException('Test_throw_domain_error(t)', 20009, 'ValueError: oops');
+
+checkException('Test_throw_exception(t)', 20010, 'SystemError: std::exception');
+
+checkException('Test_throw_invalid_argum(t)', 20009, 'ValueError: oops');
+
+checkException('Test_throw_length_error(t)', 20004, 'IndexError: oops');
+
+checkException('Test_throw_logic_error(t)', 20003, 'RuntimeError: oops');
+
+checkException('Test_throw_out_of_range(t)', 20004, 'IndexError: oops');
+
+checkException('Test_throw_overflow_erro(t)', 20007, 'OverflowError: oops');
+
+checkException('Test_throw_range_error(t)', 20007, 'OverflowError: oops');
+
+checkException('Test_throw_runtime_error(t)', 20003, 'RuntimeError: oops');
+
+delete_Test(t);
+
+exec('swigtest.quit', -1);
diff --git a/Examples/test-suite/scilab/li_std_pair_runme.sci b/Examples/test-suite/scilab/li_std_pair_runme.sci
new file mode 100644
index 000000000..e5f5607ee
--- /dev/null
+++ b/Examples/test-suite/scilab/li_std_pair_runme.sci
@@ -0,0 +1,38 @@
+exec("swigtest.start", -1);
+
+function checkPair(pair, expected_first, expected_second, func)
+ checkequal(IntPair_first_get(pair), expected_first, func + ": first");;
+ checkequal(IntPair_second_get(pair), expected_second, func + ": second");;
+endfunction
+
+intPair = makeIntPair(7, 6);
+checkPair(intPair, 7, 6, "makeIntPair()");
+
+intPairPtr = makeIntPairPtr(7, 6);
+checkPair(intPairPtr, 7, 6, "makeIntPairPtr()");
+
+intPairRef = makeIntPairRef(7, 6);
+checkPair(intPairRef, 7, 6, "makeIntPairRef()");
+
+intPairConstRef = makeIntPairConstRef(7, 6);
+checkPair(intPairConstRef, 7, 6, "makeIntPairConstRef()");
+
+// call fns
+checkequal(product1(intPair), 42, "product1(intPair)");
+checkequal(product2(intPair), 42, "product2(intPair)");
+checkequal(product3(intPair), 42, "product3(intPair)")
+
+// also use the pointer version
+checkequal(product1(intPairPtr), 42, "product1(intPairPtr)");
+checkequal(product2(intPairPtr), 42, "product2(intPairPtr)");
+checkequal(product3(intPairPtr), 42, "product3(intPairPtr)");
+
+// or the other types
+checkequal(product1(intPairRef), 42, "product1(intPairRef)");
+checkequal(product2(intPairRef), 42, "product2(intPairRef)");
+checkequal(product3(intPairRef), 42, "product3(intPairRef)");
+checkequal(product1(intPairConstRef), 42, "product3(intPairConstRef)");
+checkequal(product2(intPairConstRef), 42, "product2(intPairConstRef)");
+checkequal(product3(intPairConstRef), 42, "product1(intPairConstRef)");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/li_std_string_extra_runme.sci b/Examples/test-suite/scilab/li_std_string_extra_runme.sci
new file mode 100644
index 000000000..b96b07e84
--- /dev/null
+++ b/Examples/test-suite/scilab/li_std_string_extra_runme.sci
@@ -0,0 +1,58 @@
+exec("swigtest.start", -1);
+
+x = "hello";
+
+// li_std_string tests
+
+// Function tests
+
+checkequal(test_ccvalue(x), x, "test_ccvalue()");
+checkequal(test_cvalue(x), x, "test_cvalue(x)");
+checkequal(test_value(x), x, "test_value()");
+
+checkequal(test_const_reference(x), x, "test_const_reference(x)");
+checkequal(test_reference_input(x), x, "test_reference_input(x)");
+checkequal(test_reference_inout(x), x+x, "test_reference_inout(x)");
+
+//checkequal(test_reference_out(), "test_reference_out message", "test_reference_out()");
+//checkequal(test_const_pointer_out(), "x", "test_const_pointer_out()");
+
+s = "initial string";
+
+// Global variable tests
+
+checkequal(GlobalString2_get(), "global string 2", "GlobalString2_get()");
+GlobalString2_set(s);
+checkequal(GlobalString2_get(), s, "GlobalString2_get()");
+
+checkequal(ConstGlobalString_get(), "const global string", "ConstGlobalString_get()");
+
+// Member variable tests
+
+myStructure = new_Structure();
+checkequal(Structure_Str2_get(myStructure), "member string 2", "Structure_Str2_get(myStructure)");
+
+Structure_Str2_set(myStructure, s);
+checkequal(Structure_Str2_get(myStructure), s, "Structure_Str2_get(myStructure)");
+
+checkequal(Structure_ConstStr_get(myStructure), "const member string", "Structure_ConstStr_get(myStructure)");
+
+checkequal(Structure_StaticStr2_get(), "static member string 2", "Structure_StaticStr2_get()");
+
+Structure_StaticStr2_set(s);
+checkequal(Structure_StaticStr2_get(), s, "Structure_StaticStr2_get()");
+
+checkequal(Structure_ConstStati_get(), "const static member string", "Structure_ConstStaticStr_get()");
+
+
+checkequal(stdstring_empty(), "", "stdstring_empty()");
+checkequal(c_empty(), "", "c_empty()");
+
+
+// li_std_string_extra tests
+
+//checkequal(test_value_basic1(x), x, "");
+//checkequal(test_value_basic2(x), x, "");
+//checkequal(test_value_basic3(x), x, "");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/li_std_vector_runme.sci b/Examples/test-suite/scilab/li_std_vector_runme.sci
new file mode 100644
index 000000000..4f21edd18
--- /dev/null
+++ b/Examples/test-suite/scilab/li_std_vector_runme.sci
@@ -0,0 +1,12 @@
+exec("swigtest.start", -1);
+
+// TODO: support for STL vectors operator =
+iv = new_DoubleVector();
+//for i=1:4
+// iv(i) = i;
+//end
+//x = average(iv);
+
+//if x <> 2.5 then swigtesterror(); end
+exit
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/li_typemaps_runme.sci b/Examples/test-suite/scilab/li_typemaps_runme.sci
new file mode 100644
index 000000000..d9ea0218f
--- /dev/null
+++ b/Examples/test-suite/scilab/li_typemaps_runme.sci
@@ -0,0 +1,116 @@
+exec("swigtest.start", -1);
+
+
+// double
+checkequal(in_double(22.22), 22.22, "in_double");
+checkequal(inr_double(22.22), 22.22, "inr_double");
+checkequal(out_double(22.22), 22.22, "out_double");
+checkequal(outr_double(22.22), 22.22, "outr_double");
+checkequal(inout_double(22.22), 22.22, "inout_double");
+checkequal(inoutr_double(22.22), 22.22, "inoutr_double");
+
+// signed char
+checkequal(in_schar(22), 22, "in_schar");
+checkequal(inr_schar(22), 22, "inr_schar");
+checkequal(out_schar(22), 22, "out_schar");
+checkequal(outr_schar(22), 22, "outr_schar");
+checkequal(inout_schar(22), 22, "inout_schar");
+checkequal(inoutr_schar(22), 22, "inoutr_schar");
+
+// unsigned char
+checkequal(in_uchar(uint8(22)), 22, "in_uchar");
+checkequal(inr_uchar(uint8(22)), 22, "inr_uchar");
+checkequal(out_uchar(uint8(22)), 22, "out_uchar");
+checkequal(outr_uchar(uint8(22)), 22, "outr_uchar");
+checkequal(inout_uchar(uint8(22)), 22, "inout_uchar");
+checkequal(inoutr_uchar(uint8(22)), 22, "inoutr_uchar");
+
+// short
+checkequal(in_short(22), 22, "in_short");
+checkequal(inr_short(22), 22, "inr_short");
+checkequal(out_short(22), 22, "out_short");
+checkequal(outr_short(22), 22, "outr_short");
+checkequal(inout_short(22), 22, "inout_short");
+checkequal(inoutr_short(22), 22, "inoutr_short");
+
+// unsigned short
+checkequal(in_ushort(uint16(22)), 22, "in_ushort");
+checkequal(inr_ushort(uint16(22)), 22, "in_ushort");
+checkequal(out_ushort(uint16(22)), 22, "out_ushort");
+checkequal(outr_ushort(uint16(22)), 22, "outr_ushort");
+checkequal(inout_ushort(uint16(22)), 22, "inout_ushort");
+checkequal(inoutr_ushort(uint16(22)), 22, "inoutr_ushort");
+
+// int
+checkequal(in_int(22), 22, "in_int");
+checkequal(inr_int(22), 22, "inr_int");
+checkequal(out_int(22), 22, "out_int");
+checkequal(outr_int(22), 22, "outr_int");
+checkequal(inout_int(22), 22, "inout_int");
+checkequal(inoutr_int(22), 22, "inoutr_int");
+
+// unsigned int
+checkequal(in_uint(uint32(22)), 22, "in_uint");
+checkequal(inr_uint(uint32(22)), 22, "inr_uint");
+checkequal(out_uint(uint32(22)), 22, "out_uint");
+checkequal(outr_uint(uint32(22)), 22, "outr_uint");
+checkequal(inout_uint(uint32(22)), 22, "inout_uint");
+checkequal(inoutr_uint(uint32(22)), 22, "inoutr_uint");
+
+// long
+checkequal(in_long(22), 22, "in_long");
+checkequal(inr_long(22), 22, "inr_long");
+checkequal(out_long(22), 22, "out_long");
+checkequal(outr_long(22), 22, "outr_long");
+checkequal(inout_long(22), 22, "inout_long");
+checkequal(inoutr_long(22), 22, "inoutr_long");
+
+// unsigned long
+checkequal(in_ulong(uint32(22)), 22, "in_ulong");
+checkequal(inr_ulong(uint32(22)), 22, "inr_ulong");
+checkequal(out_ulong(uint32(22)), 22, "out_ulong");
+checkequal(outr_ulong(uint32(22)), 22, "outr_ulong");
+checkequal(inout_ulong(uint32(22)), 22, "inout_ulong");
+checkequal(inoutr_ulong(uint32(22)), 22, "inoutr_ulong");
+
+// bool
+checkequal(in_bool(%t), %t, "in_bool");
+checkequal(inr_bool(%f), %f, "inr_bool");
+checkequal(out_bool(%t), %t, "out_bool");
+checkequal(outr_bool(%f), %f, "outr_bool");
+checkequal(inout_bool(%t), %t, "inout_bool");
+checkequal(inoutr_bool(%f), %f, "inoutr_bool");
+
+// float
+checkequal(in_float(2.5), 2.5, "in_float");
+checkequal(inr_float(2.5), 2.5, "inr_float");
+checkequal(out_float(2.5), 2.5, "out_float");
+checkequal(outr_float(2.5), 2.5, "outr_float");
+checkequal(inout_float(2.5), 2.5, "inout_float");
+checkequal(inoutr_float(2.5), 2.5, "inoutr_float");
+
+// long long
+// Not supported in Scilab 5.5
+//checkequal(in_longlong(22), 22, "in_longlong");
+//checkequal(inr_longlong(22), 22, "inr_longlong");
+//checkequal(out_longlong(22), 22, "out_longlong");
+//checkequal(outr_longlong(22), 22, "outr_longlong");
+//checkequal(inout_longlong(22), 22, "inout_longlong");
+//checkequal(inoutr_longlong(22), 22, "inoutr_longlong");
+
+// unsigned long long
+// Not supported in Scilab 5.5
+//checkequal(in_ulonglong(uint64(22)), 22, "in_ulonglong");
+//checkequal(inr_ulonglong(uint64(22)), 22, "inr_ulonglong");
+//checkequal(out_ulonglong(uint64(22)), 22, "out_ulonglong");
+//checkequal(outr_ulonglong(uint64(22)), 22, "outr_ulonglong");
+//checkequal(inout_ulonglong(uint64(22)), 22, "inout_ulonglong");
+//checkequal(inoutr_ulonglong(uint64(22)), 22, "inoutr_ulonglong");
+
+// the others
+//a,b = inoutr_int2(1, 2);
+//checkequal(a<>1 || b<>2), "");
+//f,i = out_foo(10)
+//checkequal(f.a, 10 || i, 20), "");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/member_pointer_runme.sci b/Examples/test-suite/scilab/member_pointer_runme.sci
new file mode 100644
index 000000000..5d90f172f
--- /dev/null
+++ b/Examples/test-suite/scilab/member_pointer_runme.sci
@@ -0,0 +1,20 @@
+exec("swigtest.start", -1);
+
+s = new_Square(10);
+
+// Functions
+checkequal(do_op(s, areapt()), 100.0, "Square area");
+checkequal(do_op(s, perimeterpt()), 40.0, "Square perimeter");
+
+// Variables
+checkequal(do_op(s, areavar_get()), 100.0, "Square area");
+areavar_set(perimeterpt());
+checkequal(do_op(s, areavar_get()), 40.0, "Square perimeter");
+
+// Constants
+checkequal(do_op(s, AREAPT_get()), 100.0, "Square area");
+checkequal(do_op(s, PERIMPT_get()), 40.0, "Square perimeter");
+
+delete_Square(s);
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/name_runme.sci b/Examples/test-suite/scilab/name_runme.sci
new file mode 100644
index 000000000..dd901df61
--- /dev/null
+++ b/Examples/test-suite/scilab/name_runme.sci
@@ -0,0 +1,11 @@
+exec("swigtest.start", -1);
+
+try
+ foo_2();
+catch
+ swigtesterror();
+end
+if bar_2_get() <> 17 then swigtesterror(); end
+if Baz_2_get() <> 47 then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/nested_structs_runme.sci b/Examples/test-suite/scilab/nested_structs_runme.sci
new file mode 100644
index 000000000..1899fe378
--- /dev/null
+++ b/Examples/test-suite/scilab/nested_structs_runme.sci
@@ -0,0 +1,34 @@
+exec("swigtest.start", -1);
+
+try
+ outer = new_Outer();
+ setValues(outer, 10);
+
+ inner1 = Outer_inner1_get(outer);
+ inner2 = Outer_inner2_get(outer);
+ inner3 = Outer_inner3_get(outer);
+ inner4 = Outer_inner4_get(outer);
+catch
+ swigtesterror();
+end
+
+checkequal(Outer_inner1_val_get(inner1), 10, "Outer_inner1_val_get(inner1)");
+checkequal(Outer_inner1_val_get(inner2), 20, "Outer_inner1_val_get(inner2)");
+checkequal(Outer_inner1_val_get(inner3), 20, "Outer_inner1_val_get(inner3)");
+checkequal(Outer_inner1_val_get(inner4), 40, "Outer_inner1_val_get(inner4)");
+
+try
+ inside1 = Outer_inside1_get(outer);
+ inside2 = Outer_inside2_get(outer);
+ inside3 = Outer_inside3_get(outer);
+ inside4 = Outer_inside4_get(outer);
+catch
+ swigtesterror();
+end
+
+checkequal(Named_val_get(inside1), 100, "Named_val_get(inside1)");
+checkequal(Named_val_get(inside2), 200, "Named_val_get(inside2)");
+checkequal(Named_val_get(inside3), 200, "Named_val_get(inside3)");
+checkequal(Named_val_get(inside4), 400, "Named_val_get(inside4)");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/newobject2_runme.sci b/Examples/test-suite/scilab/newobject2_runme.sci
new file mode 100644
index 000000000..da1d50cbd
--- /dev/null
+++ b/Examples/test-suite/scilab/newobject2_runme.sci
@@ -0,0 +1,31 @@
+exec("swigtest.start", -1);
+
+try
+ x = makeFoo();
+catch
+ swigtesterror();
+end
+if fooCount() <> 1 then swigtesterror(); end
+
+try
+ y = makeFoo();
+catch
+ swigtesterror();
+end
+if fooCount() <> 2 then swigtesterror(); end
+
+try
+ delete_Foo(x);
+catch
+ swigtesterror();
+end
+if fooCount() <> 1 then swigtesterror(); end
+
+try
+ delete_Foo(y);
+catch
+ swigtesterror();
+end
+if fooCount() <> 0 then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/null_pointer_runme.sci b/Examples/test-suite/scilab/null_pointer_runme.sci
new file mode 100644
index 000000000..2c693d259
--- /dev/null
+++ b/Examples/test-suite/scilab/null_pointer_runme.sci
@@ -0,0 +1,7 @@
+exec("swigtest.start", -1);
+
+p = getnull();
+checkequal(SWIG_this(p), 0, "SWIG_this(p)");
+checkequal(func(p), %T, "func(p)");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/operator_overload_runme.sci b/Examples/test-suite/scilab/operator_overload_runme.sci
new file mode 100644
index 000000000..ca41acd75
--- /dev/null
+++ b/Examples/test-suite/scilab/operator_overload_runme.sci
@@ -0,0 +1,82 @@
+exec("swigtest.start", -1);
+
+function checktrue(value, msg)
+ checkequal(value, %T, msg)
+endfunction
+
+a = new_Op();
+b = new_Op(5);
+c = new_Op(b);
+d = new_Op(2);
+dd = new_Op();
+
+// Assignment operator
+Op_Equal(dd, d);
+
+// Comparison operator
+checktrue(Op_NotEqual(a, b), "Op_NotEqual(a, b)");
+checktrue(Op_EqualEqual(b, c), "Op_EqualEqual(b, c)");
+checktrue(Op_NotEqual(a, d), "Op_NotEqual(a, d)");
+checktrue(Op_EqualEqual(d, dd), "Op_EqualEqual(d, dd)");
+
+checktrue(Op_LessThan(a, b), "Op_LessThan(a, b)");
+checktrue(Op_LessThanEqual(a, b), "Op_LessThanEqual(a, b)");
+checktrue(Op_LessThanEqual(b, c), "Op_LessThanEqual(b, c)");
+checktrue(Op_GreaterThanEqual(b, c), "Op_GreaterThanEqual(b, c)");
+checktrue(Op_GreaterThan(b, d), "Op_GreaterThan(b, d)");
+checktrue(Op_GreaterThanEqual(b, d), "Op_GreaterThanEqual(b, d)");
+
+delete_Op(a);
+delete_Op(b);
+delete_Op(c);
+delete_Op(d);
+delete_Op(dd);
+
+f = new_Op(1);
+g = new_Op(1);
+
+expop = new_Op();
+
+op = Op_Plus(f, g);
+Op_i_set(expop, 2);
+checktrue(Op_EqualEqual(op, expop), "Op_Plus(f, g) <> Op(2)");
+delete_Op(op);
+
+op = Op_Minus(f, g);
+Op_i_set(expop, 0);
+checktrue(Op_EqualEqual(op, expop), "Op_Minus(f, g) <> Op(0)");
+delete_Op(op);
+
+op = Op_Multiply(f, g);
+Op_i_set(expop, 1);
+checktrue(Op_EqualEqual(op, expop), "Op_Multiply(f, g) <> Op(1)");
+delete_Op(op);
+
+op = Op_Divide(f, g);
+Op_i_set(expop, 1);
+checktrue(Op_EqualEqual(op, expop), "Op_Divide(f, g) <> Op(1)");
+delete_Op(op);
+
+// Unary operator
+op = Op_PlusPlusPrefix(new_Op(3));
+Op_i_set(expop, 4);
+checktrue(Op_EqualEqual(op, expop), "Op_PlusPlusPrefix(op) <> Op(4)");
+
+// Square bracket operator
+checkequal(Op_IndexIntoConst(op, uint32(0)), 4, "Op_IndexIntoConst(op, 0) <> 4");
+checkequal(Op_IndexIntoConst(op, uint32(1)), 0, "Op_IndexIntoConst(op, 1) <> 0");
+
+// Functor
+i = new_Op(3);
+checkequal(Op_Functor(i), 3, "Op_Functor(i)");
+checkequal(Op_Functor(i, 1), 4, "Op_Functor(i, 1)");
+
+delete_Op(f);
+delete_Op(g);
+
+delete_Op(i);
+
+delete_Op(expop);
+
+exec("swigtest.quit", -1);
+
diff --git a/Examples/test-suite/scilab/overload_arrays_runme.sci b/Examples/test-suite/scilab/overload_arrays_runme.sci
new file mode 100644
index 000000000..4d9a8b035
--- /dev/null
+++ b/Examples/test-suite/scilab/overload_arrays_runme.sci
@@ -0,0 +1,46 @@
+exec("swigtest.start", -1);
+
+// Functions
+
+checkequal(foo(int32([1, 2, 3])), "foo:int[SIZE]", "foo(int[SIZE])");
+checkequal(foo([1, 2, 3]), "foo:double[SIZE]", "foo(double[SIZE])");
+checkequal(foo(["1" "2" "3"]), "foo:char *[SIZE]", "foo(char *[SIZE])");
+
+// Class methods
+
+s = new_Spam();
+checkequal(Spam_foo(s, int32([1, 2, 3])), "foo:int[SIZE]", "Spam::foo(int[SIZE])");
+checkequal(Spam_foo(s, [1, 2, 3]), "foo:double[SIZE]", "Spam::foo(double[SIZE])");
+checkequal(Spam_foo(s, ["1" "2" "3"]), "foo:char *[SIZE]", "Spam::foo(char *[SIZE])");
+delete_Spam(s);
+
+// Static class methods
+
+checkequal(Spam_bar(int32([1, 2, 3])), "bar:int[SIZE]", "Spam::bar(int[SIZE])");
+checkequal(Spam_bar([1, 2, 3]), "bar:double[SIZE]", "Spam::bar(double[SIZE])");
+checkequal(Spam_bar("hello"), "bar:char *[SIZE]", "Spam::bar(char *[SIZE])");
+
+// Constructors
+
+s = new_Spam();
+checkequal(Spam_type_get(s), "none", "Spam::Spam()");
+delete_Spam(s);
+
+s = new_Spam(int32([1, 2, 3]));
+checkequal(Spam_type_get(s), "int[SIZE]", "Spam::Spam(int[SIZE])");
+delete_Spam(s);
+
+s = new_Spam([1, 2, 3]);
+checkequal(Spam_type_get(s), "double[SIZE]", "Spam::Spam(double[SIZE])");
+delete_Spam(s);
+
+s = new_Spam(["1" "2" "3"]);
+checkequal(Spam_type_get(s), "char *[SIZE]", "Spam::Spam(char *[SIZE])");
+delete_Spam(s);
+
+
+a = new_ClassA();
+b = ClassA_method1(a, [1 2 3]);
+
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/overload_complicated_runme.sci b/Examples/test-suite/scilab/overload_complicated_runme.sci
new file mode 100644
index 000000000..f1c24717a
--- /dev/null
+++ b/Examples/test-suite/scilab/overload_complicated_runme.sci
@@ -0,0 +1,25 @@
+exec("swigtest.start", -1);
+
+NULL = SWIG_ptr(0);
+p = new_Pop(NULL);
+p = new_Pop(NULL, %T);
+
+checkequal(Pop_hip(p, %T), 701, "Pop_hip(%T)");
+checkequal(Pop_hip(p, NULL), 702, "Pop_hip(NULL)");
+
+checkequal(Pop_hop(p, %T), 801, "Pop_hop(%T)");
+checkequal(Pop_hop(p, NULL), 805, "Pop_hop(NULL)");
+
+checkequal(Pop_pop(p, %T), 901, "Pop_pop(%T)");
+checkequal(Pop_pop(p, NULL), 904, "Pop_pop(NULL)");
+checkequal(Pop_pop(p), 905, "Pop_pop()");
+
+checkequal(Pop_bop(p, NULL), 1001, "Pop_bop(NULL)");
+
+checkequal(Pop_bip(p, NULL), 2002, "Pop_bip(%T)");
+
+checkequal(muzak(%T), 3001, "muzak(%T)");
+checkequal(muzak(NULL), 3002, "muzak(%T)");
+
+exec("swigtest.quit", -1);
+
diff --git a/Examples/test-suite/scilab/overload_copy_runme.sci b/Examples/test-suite/scilab/overload_copy_runme.sci
new file mode 100644
index 000000000..6d163ffa7
--- /dev/null
+++ b/Examples/test-suite/scilab/overload_copy_runme.sci
@@ -0,0 +1,10 @@
+exec("swigtest.start", -1);
+
+f = new_Foo();
+g = new_Foo(f);
+
+delete_Foo(f);
+delete_Foo(g);
+
+exec("swigtest.quit", -1);
+
diff --git a/Examples/test-suite/scilab/overload_extend_runme.sci b/Examples/test-suite/scilab/overload_extend_runme.sci
new file mode 100644
index 000000000..416477bcb
--- /dev/null
+++ b/Examples/test-suite/scilab/overload_extend_runme.sci
@@ -0,0 +1,13 @@
+exec("swigtest.start", -1);
+
+//try
+// x = new_Foo();
+//catch
+// swigtesterror();
+//end
+//if Foo_test(x) <> 0 then swigtesterror(); end
+//if Foo_test(x, 1) <> 1 then swigtesterror(); end
+//if Foo_test(x, 2, 3) <> 5 then swigtesterror(); end
+//if Foo_test(x, "Hello, swig!") <> 2 then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/overload_extendc_runme.sci b/Examples/test-suite/scilab/overload_extendc_runme.sci
new file mode 100644
index 000000000..bf474ddbf
--- /dev/null
+++ b/Examples/test-suite/scilab/overload_extendc_runme.sci
@@ -0,0 +1,15 @@
+exec("swigtest.start", -1);
+
+try
+ x = new_Foo();
+catch
+ swigtesterror();
+end
+if Foo_test(x, 1) <> 1 then swigtesterror(); end
+if Foo_test(x, "Hello swig!") <> 2 then swigtesterror(); end
+if Foo_test(x, 2, 3) <> 3 then swigtesterror(); end
+if Foo_test(x, x) <> 30 then swigtesterror(); end
+if Foo_test(x, x, 4) <> 24 then swigtesterror(); end
+if Foo_test(x, x, 4, 5) <> 9 then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/overload_numeric_runme.sci b/Examples/test-suite/scilab/overload_numeric_runme.sci
new file mode 100644
index 000000000..ea79cff61
--- /dev/null
+++ b/Examples/test-suite/scilab/overload_numeric_runme.sci
@@ -0,0 +1,16 @@
+exec("swigtest.start", -1);
+
+nums = new_Nums();
+
+// In overloading in Scilab, double has priority over all other numeric types
+checkequal(Nums_over(nums, 0), "double", "Nums_over(nums, 0)");
+
+// Just checkequal if the following are accepted without exceptions being thrown
+Nums_doublebounce(nums, %inf);
+Nums_doublebounce(nums, -%inf);
+Nums_doublebounce(nums, %nan);
+
+delete_Nums(nums);
+
+exec("swigtest.quit", -1);
+
diff --git a/Examples/test-suite/scilab/overload_simple_runme.sci b/Examples/test-suite/scilab/overload_simple_runme.sci
new file mode 100644
index 000000000..23be43db9
--- /dev/null
+++ b/Examples/test-suite/scilab/overload_simple_runme.sci
@@ -0,0 +1,73 @@
+exec("swigtest.start", -1);
+
+// Functions
+
+checkequal(foo(int32(3)), "foo:int", "foo(int)");
+checkequal(foo(3), "foo:double", "foo(double)");
+checkequal(foo("hello"), "foo:char *", "foo(char* )");
+f = new_Foo();
+checkequal(foo(f), "foo:Foo *", "foo(Foo *)");
+//b = new_Bar();
+//checkequal(foo(b), "foo:Bar *", "foo(Bar *)");
+//v = malloc_void(32);
+//checkequal(foo(v), "foo:void *", "foo(void *)");
+
+// Class methods
+
+s = new_Spam();
+checkequal(Spam_foo(s, int32(3)), "foo:int", "Spam::foo(int)");
+checkequal(Spam_foo(s, 3), "foo:double", "Spam::foo(double)");
+checkequal(Spam_foo(s, "hello"), "foo:char *", "Spam::foo(char *)");
+checkequal(Spam_foo(s, f), "foo:Foo *", "Spam::foo(Foo *)");
+//checkequal(Spam_foo(s, b), "foo:Bar *", "Spam::foo(Bar *)");
+//checkequal(Spam_foo(s, v), "foo:void *", "Spam::foo(void *)");
+delete_Spam(s);
+
+// Static class methods
+
+checkequal(Spam_bar(int32(3)), "bar:int", "Spam::bar(int)");
+checkequal(Spam_bar(3.1), "bar:double", "Spam::bar(double)");
+checkequal(Spam_bar("hello"), "bar:char *", "Spam::bar(char *)");
+checkequal(Spam_bar(f), "bar:Foo *", "Spam::bar(Foo *)");
+//checkequal(Spam_bar(b), "bar:Bar *", "Spam::bar(Bar *)");
+//checkequal(Spam_bar(b), "bar:void *", "Spam::bar(void *)");
+
+// Constructors
+
+s = new_Spam();
+checkequal(Spam_type_get(s), "none", "Spam::Spam()");
+delete_Spam(s);
+
+s = new_Spam(int32(3));
+checkequal(Spam_type_get(s), "int", "Spam::Spam(int)");
+delete_Spam(s);
+
+s = new_Spam(3.1);
+checkequal(Spam_type_get(s), "double", "Spam::Spam(double)");
+delete_Spam(s);
+
+s = new_Spam("hello");
+checkequal(Spam_type_get(s), "char *", "Spam::Spam(char *)");
+delete_Spam(s);
+
+s = new_Spam(f);
+checkequal(Spam_type_get(s), "Foo *", "Spam::Spam(Foo *)");
+delete_Spam(s);
+
+//s = new_Spam(b);
+//checkequal(Spam_type_get(s), "Bar *", "Spam::Spam(Bar *)");
+//delete_Spam(s);
+
+//s = new_Spam(v);
+//checkequal(Spam_type_get(s), "void *", "Spam::Spam(void *)");
+//delete_Spam(s);
+
+delete_Foo(f);
+//delete_Bar(b);
+//free_void(v);
+
+a = new_ClassA();
+b = ClassA_method1(a, 1);
+
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/preproc_constants_runme.sci b/Examples/test-suite/scilab/preproc_constants_runme.sci
new file mode 100644
index 000000000..d3d0a4b56
--- /dev/null
+++ b/Examples/test-suite/scilab/preproc_constants_runme.sci
@@ -0,0 +1,30 @@
+exec("swigtest.start", -1);
+
+checkequal(CONST_INT1_get(), 10, "CONST_INT1");
+checkequal(CONST_DOUBLE3_get(), 12.3, "CONST_DOUBLE3");
+checkequal(CONST_BOOL1_get(), %T, "CONST_BOOL1");
+checkequal(CONST_CHAR_get(), 'x', "CONST_CHAR");
+checkequal(CONST_STRING1_get(), "const string", "CONST_STRING1");
+
+// Test global constants can be seen within functions
+function test_global()
+ global CONST_INT1
+ global CONST_DOUBLE3
+ global CONST_BOOL1
+ global CONST_CHAR
+ global CONST_STRING1
+
+ checkequal(CONST_INT1_get(), 10, "CONST_INT1");
+ checkequal(CONST_DOUBLE3_get(), 12.3, "CONST_DOUBLE3");
+ checkequal(CONST_BOOL1_get(), %T, "CONST_BOOL1");
+ checkequal(CONST_CHAR_get(), 'x', "CONST_CHAR");
+ checkequal(CONST_STRING1_get(), "const string", "CONST_STRING1");
+endfunction
+
+test_global();
+
+
+// Test assignement in enums
+checkequal(kValue_get(), 4, "kValue");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/preproc_runme.sci b/Examples/test-suite/scilab/preproc_runme.sci
new file mode 100644
index 000000000..a54815a34
--- /dev/null
+++ b/Examples/test-suite/scilab/preproc_runme.sci
@@ -0,0 +1,8 @@
+exec("swigtest.start", -1);
+
+if endif_get() <> 1 then swigtesterror(); end
+if define_get() <> 1 then swigtesterror(); end
+if defined_get() <> 1 then swigtesterror(); end
+if 2 * one_get() <> two_get() then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/primitive_ref_runme.sci b/Examples/test-suite/scilab/primitive_ref_runme.sci
new file mode 100644
index 000000000..9ff400ea5
--- /dev/null
+++ b/Examples/test-suite/scilab/primitive_ref_runme.sci
@@ -0,0 +1,24 @@
+exec("swigtest.start", -1);
+
+checkequal(ref_int(3), 3, "ref_int() test fails.");
+checkequal(ref_uint(uint32(3)), 3, "ref_uint() test fails.");
+
+checkequal(ref_short(3), 3, "ref_short() test fails.");
+checkequal(ref_ushort(uint16(3)), 3, "ref_ushort() test fails.");
+
+checkequal(ref_long(3), 3, "ref_long() test fails.");
+checkequal(ref_ulong(uint32(3)), 3, "ref_ulong() test fails.");
+
+checkequal(ref_schar(3), 3, "ref_schar() test fails.");
+checkequal(ref_uchar(uint8(3)), 3, "ref_uchar() test fails.");
+
+checkequal(ref_float(3), 3, "ref_float() test fails.");
+checkequal(ref_double(3), 3, "ref_double() test fails.");
+
+checkequal(ref_bool(%T), %T, "ref_bool() test fails.");
+
+checkequal(ref_char('x'), 'x', "ref_char() test fails.");
+
+checkequal(ref_over(0), 0, "ref_over() test fails.");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/primitive_types_runme.sci b/Examples/test-suite/scilab/primitive_types_runme.sci
new file mode 100644
index 000000000..423ee44ae
--- /dev/null
+++ b/Examples/test-suite/scilab/primitive_types_runme.sci
@@ -0,0 +1,57 @@
+exec("swigtest.start", -1);
+
+// Check passing by value
+
+checkequal(val_double(42), 42, "val_double() test fails.");
+checkequal(val_float(42), 42, "val_float() test fails.");
+
+checkequal(val_char('a'), 'a', "val_char() test fails.");
+checkequal(val_schar(42), 42, "val_schar() test fails.");
+checkequal(val_schar(int8(42)), 42, "val_schar() test fails.");
+checkequal(val_uchar(uint8(42)), 42, "val_uchar() test fails.");
+
+checkequal(val_short(42), 42, "val_short() test fails.");
+checkequal(val_short(int16(42)), 42, "val_short() test fails.");
+checkequal(val_ushort(uint16(42)), 42, "val_ushort() test fails.");
+
+checkequal(val_int(42), 42, "val_int() test fails.");
+checkequal(val_int(int32(42)), 42, "val_int() test fails.");
+checkequal(val_uint(uint32(42)), 42, "val_uint() test fails.");
+
+checkequal(val_long(42), 42, "val_long() test fails.");
+checkequal(val_long(int32(42)), 42, "val_long() test fails.");
+checkequal(val_ulong(uint32(42)), 42, "val_long() test fails.");
+
+checkequal(val_bool(%t), %t, "val_bool() test fails.");
+
+// longlong is not supported in Scilab 5.x
+//checkequal(val_llong(42), 42, "val_llong() test fails.");
+//checkequal(val_llong(int64(42)), 42, "val_llong() test fails.");
+//checkequal(val_ullong(uint64(42)), 42, "val_ullong() test fails.");
+
+// Check passing by reference
+checkequal(ref_char('a'), 'a', "ref_char() test fails.");
+checkequal(ref_schar(42), 42, "ref_schar() test fails.");
+checkequal(ref_schar(int8(42)), 42, "ref_schar() test fails.");
+checkequal(ref_uchar(uint8(42)), 42, "ref_uchar() test fails.");
+
+checkequal(ref_short(42), 42, "ref_short() test fails.")
+checkequal(ref_short(int16(42)), 42, "ref_short() test fails.")
+checkequal(ref_ushort(uint16(42)), 42, "ref_ushort() test fails.")
+
+checkequal(ref_int(42), 42, "ref_int() test fails.");
+checkequal(ref_int(int32(42)), 42, "ref_int() test fails.");
+checkequal(ref_uint(uint32(42)), 42, "ref_uint() test fails.");
+
+checkequal(ref_long(42), 42, "ref_long() test fails.");
+checkequal(ref_long(int32(42)), 42, "ref_long() test fails.");
+checkequal(ref_ulong(uint32(42)), 42, "ref_ulong() test fails.");
+
+checkequal(ref_bool(%t), %t, "ref_bool() test fails.");
+
+// long long is not supported in Scilab 5.x
+//checkequal(ref_llong(42), 42, "ref_llong() test fails.");
+//checkequal(ref_llong(int64(42)), 42, "ref_llong() test fails.");
+//checkequal(ref_ullong(uint64(42)), 42, "ref_ullong() test fails.");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/ret_by_value_runme.sci b/Examples/test-suite/scilab/ret_by_value_runme.sci
new file mode 100644
index 000000000..6475c8678
--- /dev/null
+++ b/Examples/test-suite/scilab/ret_by_value_runme.sci
@@ -0,0 +1,28 @@
+exec("swigtest.start", -1);
+
+try
+ a = get_test();
+catch
+ swigtesterror();
+end
+
+// Test default values
+checkequal(test_myInt_get(a), 100, "test_myInt_get() test fails.");
+checkequal(test_myShort_get(a), 200, "test_myShort_get() test fails.");
+
+// Write new values
+try
+ test_myInt_set(a, 42)
+ test_myShort_set(a, 12)
+catch
+ swigtesterror();
+end
+
+// Read new values
+checkequal(test_myInt_get(a), 42, "test_myInt_get() test fails.");
+checkequal(test_myShort_get(a), 12, "test_myShort_get() test fails.");
+
+// Destroy pointer
+delete_test(a);
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/return_const_value_runme.sci b/Examples/test-suite/scilab/return_const_value_runme.sci
new file mode 100644
index 000000000..662bf3625
--- /dev/null
+++ b/Examples/test-suite/scilab/return_const_value_runme.sci
@@ -0,0 +1,11 @@
+exec("swigtest.start", -1);
+
+foo_ptr = Foo_ptr_getPtr();
+foo = Foo_ptr___deref__(foo_ptr);
+checkequal(Foo_getVal(foo), 17, "Foo_getVal(p)");
+
+foo_ptr = Foo_ptr_getConstPtr();
+foo = Foo_ptr___deref__(foo_ptr);
+checkequal(Foo_getVal(foo), 17, "Foo_getVal(p)");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/scilab_consts_runme.sci b/Examples/test-suite/scilab/scilab_consts_runme.sci
new file mode 100644
index 000000000..d33b45743
--- /dev/null
+++ b/Examples/test-suite/scilab/scilab_consts_runme.sci
@@ -0,0 +1,35 @@
+exec("swigtest.start", -1);
+
+checkequal(ICONST0_get(), 42, "ICONST0_get()");
+checkequal(FCONST0_get(), 2.1828, "FCONST0_get()");
+checkequal(CCONST0_get(), "x", "CCONST0_get()");
+//checkequal(CCONST0_2_get(), "\n", "CCONST0_2_get()");
+checkequal(SCONST0_get(), "Hello World", "SCONST0_get()");
+checkequal(SCONST0_2_get(), """Hello World""", "SCONST0_2_get()");
+checkequal(EXPR0_get(), 48.5484, "EXPR0_get()");
+checkequal(iconst0_get(), 37, "iconst0_get()");
+checkequal(fconst0_get(), 42.2, "fconst0_get()");
+
+checkequal(UNSIGNED0_get(), hex2dec("5FFF"), "UNSIGNED0_get()");
+checkequal(LONG0_get(), hex2dec("3FFF0000"), "LONG0_get()");
+checkequal(ULONG0_get(), hex2dec("5FF0000"), "ULONG0_get()");
+
+if isdef('BAR0') then swigtesterror("BAR0"); end
+
+checkequal(ICONST1, int32(42), "ICONST1");
+checkequal(FCONST1, 2.1828, "FCONST1");
+checkequal(CCONST1, "x", "CCONST1");
+//checkequal(CCONST1_2, "\n", "CCONST1_2");
+checkequal(SCONST1, "Hello World", "SCONST1");
+checkequal(SCONST1_2, """Hello World""", "SCONST1_2");
+checkequal(EXPR1, 48.5484, "EXPR1");
+checkequal(iconst1, int32(37), "iconst1");
+checkequal(fconst1, 42.2, "fconst1");
+
+checkequal(UNSIGNED1, uint32(hex2dec("5FFF")), "UNSIGNED1");
+checkequal(LONG1, int32(hex2dec("3FFF0000")), "LONG1");
+checkequal(ULONG1, uint32(hex2dec("5FF0000")), "ULONG1");
+
+if isdef('BAR1') then swigtesterror("BAR1"); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/scilab_enums_runme.sci b/Examples/test-suite/scilab/scilab_enums_runme.sci
new file mode 100644
index 000000000..3e9fb7ae0
--- /dev/null
+++ b/Examples/test-suite/scilab/scilab_enums_runme.sci
@@ -0,0 +1,27 @@
+exec("swigtest.start", -1);
+
+function checkEnum(enum_val, expected_enum_val)
+ if typeof(enum_val) <> "constant" then swigtesterror(); end
+ if enum_val <> expected_enum_val then swigtesterror(); end
+endfunction
+
+checkEnum(ENUM_1, 0);
+checkEnum(ENUM_2, 1);
+
+checkEnum(ENUM_EXPLICIT_1_1, 5);
+checkEnum(ENUM_EXPLICIT_1_2, 6);
+
+checkEnum(ENUM_EXPLICIT_2_1, 0);
+checkEnum(ENUM_EXPLICIT_2_2, 10);
+
+checkEnum(ENUM_EXPLICIT_3_1, 2);
+checkEnum(ENUM_EXPLICIT_3_2, 5);
+checkEnum(ENUM_EXPLICIT_3_3, 8);
+
+checkEnum(TYPEDEF_ENUM_1_1, 21);
+checkEnum(TYPEDEF_ENUM_1_2, 22);
+
+checkEnum(TYPEDEF_ENUM_2_1, 31);
+checkEnum(TYPEDEF_ENUM_2_2, 32);
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/scilab_identifier_name_runme.sci b/Examples/test-suite/scilab/scilab_identifier_name_runme.sci
new file mode 100644
index 000000000..9a4f3cc08
--- /dev/null
+++ b/Examples/test-suite/scilab/scilab_identifier_name_runme.sci
@@ -0,0 +1,29 @@
+exec("swigtest.start", -1);
+
+
+// Test truncating variables, constants, functions identifier names
+// not truncated
+gvar_identifier_name_set(-101);
+checkequal(gvar_identifier_name_get(), -101, "gvar_identifier_name_get()");
+checkequal(CONS_IDENTIFIER_NAME_get(), -11, "CONS_IDENTIFIER_NAME_get()");
+checkequal(function_identifier_name(), -21, "function_identifier_name()");
+
+// truncated
+too_long_gvar_identi_set(101);
+checkequal(too_long_gvar_identi_get(), 101, "too_long_variable_id_get()");
+checkequal(TOO_LONG_CONST_IDENT_get(), 11, "TOO_LONG_CONST_IDENT_get()");
+checkequal(too_long_function_identi(), 21, "too_long_function_identi()");
+
+// Test truncating when %scilabconst mode is activated
+checkequal(SC_CONST_IDENTIFIER_NAME, int32(-12), "SC_TOO_LONG_IDENTIF");
+checkequal(SC_TOO_LONG_CONST_IDENTI, int32(14), "SC_TOO_LONG_IDENTIF");
+
+// Test truncating in the case of struct
+st = new_st();
+st_m_identifier_name_set(st, 15);
+checkequal(st_m_identifier_name_get(st), 15, "st_m_identifier_name_get(st)");
+st_too_long_member_i_set(st, 25);
+checkequal(st_too_long_member_i_get(st), 25, "st_too_long_member_i_get(st)");
+delete_st(st);
+
+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
new file mode 100644
index 000000000..41924d6f9
--- /dev/null
+++ b/Examples/test-suite/scilab/scilab_li_matrix_runme.sci
@@ -0,0 +1,67 @@
+// test matrix.i library
+
+exec("swigtest.start", -1);
+
+// test matrix passed as output argument from fonction
+function test_outMatrix(func, valueType, expectedOutMatrix)
+ funcName = msprintf("out%s%s", valueType, func);
+ cmd = msprintf("outMatrix = %s();", funcName);
+ ierr = execstr(cmd, "errcatch");
+ if ierr <> 0 then
+ swigtesterror(msprintf("Error %d in %s", ierr, funcName));
+ end
+ checkequal(outMatrix, expectedOutMatrix, funcName);
+endfunction
+
+// test matrix passed as input argument of fonction
+function test_inMatrix(func, valueType, inMatrix, expectedInValue)
+ funcName = msprintf("in%s%s", valueType, func);
+ cmd = msprintf("inValue = %s(inMatrix);", funcName);
+ ierr = execstr(cmd, "errcatch");
+ if ierr <> 0 then
+ swigtesterror(msprintf("Error %d in %s", ierr, funcName));
+ end
+ checkequal(inValue, expectedInValue, funcName);
+endfunction
+
+// test matrixes passed as input and output arguments of fonction
+function test_inoutMatrix(func, valueType, inoutMatrix, expectedInoutMatrix)
+ funcName = msprintf("inout%s%s", valueType, func);
+ cmd = msprintf("inoutMatrix = %s(inoutMatrix);", funcName);
+ ierr = execstr(cmd, "errcatch");
+ if ierr <> 0 then
+ swigtesterror(msprintf("Error %d in %s", ierr, funcName));
+ end
+ checkequal(inoutMatrix, expectedInoutMatrix, funcName);
+endfunction
+
+function test_matrix_typemaps(valueType, ..
+ expectedOutMatrixDims, expectedOutMatrixSize, ..
+ expectedInValue, ..
+ expectedInoutMatrixDims, expectedInoutMatrixSize)
+
+ test_outMatrix("MatrixDims", valueType, expectedOutMatrixDims);
+ test_outMatrix("MatrixSize", valueType, expectedOutMatrixSize);
+ matrixDims = expectedOutMatrixDims;
+ matrixSize = expectedOutMatrixSize;
+ test_inMatrix("MatrixDims", valueType, matrixDims, expectedInValue);
+ test_inMatrix("MatrixSize", valueType, matrixSize, expectedInValue);
+ test_inoutMatrix("MatrixDims", valueType, matrixDims, expectedInoutMatrixDims);
+ test_inoutMatrix("MatrixSize", valueType, matrixSize, expectedInoutMatrixSize);
+endfunction
+
+
+m = [0 3; 1 4; 2 5];
+v = [0 1 2 3 4 5];
+test_matrix_typemaps("Int", m, v, sum(m), m .* m, v .* v);
+test_matrix_typemaps("Double", m, v, sum(m), m .* m, v .* v);
+
+m = ["A" "D"; "B" "E"; "C" "F"];
+v = ["A" "B" "C" "D" "E" "F"];
+test_matrix_typemaps("CharPtr", m, v, strcat(m), m + m, v + v);
+
+m = [%T %F; %F %T; %T %F];
+v = [%T %F %T %F %T %F];
+test_matrix_typemaps("Bool", m, v, %T, ~m, ~v);
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/scilab_multivalue_runme.sci b/Examples/test-suite/scilab/scilab_multivalue_runme.sci
new file mode 100644
index 000000000..581890408
--- /dev/null
+++ b/Examples/test-suite/scilab/scilab_multivalue_runme.sci
@@ -0,0 +1,87 @@
+exec("swigtest.start", -1);
+
+// OUTPUT
+
+[a, b] = output2();
+checkequal(a, 1, "[a, b] = output2(): a");
+checkequal(b, 2, "[a, b] = output2(): b");
+
+[ret, a, b] = output2Ret();
+checkequal(ret, 3, "[a, b] = output2Ret(): b");
+checkequal(a, 1, "[a, b] = output2Ret(): a");
+checkequal(b, 2, "[a, b] = output2Ret(): b");
+
+[c, d] = output2Input2(1, 2);
+checkequal(c, 2, "[c, d] = output2Input2(1, 2): c");
+checkequal(d, 4, "[c, d] = output2Input2(1, 2): d");
+
+[ret, c, d] = output2Input2Ret(1, 2);
+checkequal(ret, 6, "[ret, c, d] = output2Input2Ret(1, 2): ret");
+checkequal(c, 2, "[ret, c, d] = output2Input2Ret(1, 2): c");
+checkequal(d, 4, "[ret, c, d = output2Input2Ret(1, 2): d");
+
+[ret, a, b, c] = output3Input1Ret(10);
+checkequal(ret, 10, "[ret, a, b, c] = output3Input1Ret(10): ret");
+checkequal(a, 11, "[ret, a, b, c] = output3Input1Ret(10): a");
+checkequal(b, 12, "[ret, a, b, c] = output3Input1Ret(10): b");
+checkequal(c, 13, "[ret, a, b, c] = output3Input1Ret(10): c");
+
+[ret, a, b, c] = output3Input3Ret(10, 20, 30);
+checkequal(ret, 66, "[ret, a, b, c] = output3Input1Ret(10, 20, 30): ret");
+checkequal(a, 11, "[ret, a, b, c] = output3Input1Ret(10, 20, 30): a");
+checkequal(b, 22, "[ret, a, b, c] = output3Input1Ret(10, 20, 30): b");
+checkequal(c, 33, "[ret, a, b, c] = output3Input1Ret(10, 20, 30): c");
+
+
+// INOUT
+
+[a, b] = inout2(1, 2);
+checkequal(a, 2, "[a, b] = output2(1, 2): a");
+checkequal(b, 4, "[a, b] = output2(1, 2): b");
+
+[ret, a, b] = inout2Ret(1, 2);
+checkequal(ret, 6, "[a, b] = inout2Ret(1, 2): b");
+checkequal(a, 2, "[a, b] = inout2Ret(1, 2): a");
+checkequal(b, 4, "[a, b] = inout2Ret(1, 2): b");
+
+[c, d] = inout2Input2(1, 2, 1, 1);
+checkequal(c, 2, "[c, d] = inout2Input2(1, 2): c");
+checkequal(d, 3, "[c, d] = inout2Input2(1, 2): d");
+
+[ret, c, d] = inout2Input2Ret(1, 2, 1, 1);
+checkequal(ret, 5, "[c, d] = inout2Input2Ret(1, 2): ret");
+checkequal(c, 2, "[c, d] = inout2Input2Ret(1, 2): c");
+checkequal(d, 3, "[c, d] = inout2Input2Ret(1, 4): d");
+
+[ret, a, b, c] = inout3Input1Ret(10, 1, 2, 3);
+checkequal(ret, 10, "[ret, a, b, c] = output3Input1Ret(ret, 1, 2, 3): ret");
+checkequal(a, 11, "[ret, a, b, c] = output3Input1Ret(ret, 1, 2, 3): a");
+checkequal(b, 12, "[ret, a, b, c] = output3Input1Ret(ret, 1, 2, 3): b");
+checkequal(c, 13, "[ret, a, b, c] = output3Input1Ret(ret, 1, 2, 3): c");
+
+[ret, a, b, c] = inout3Input3Ret(10, 1, 20, 2, 30, 3);
+checkequal(ret, 66, "[ret, a, b, c] = output3Input1Ret(10, 20, 30): ret");
+checkequal(a, 11, "[ret, a, b, c] = inout3Input1Ret(10, 1, 20, 2, 30, 3): a");
+checkequal(b, 22, "[ret, a, b, c] = inout3Input1Ret(10, 1, 20, 2, 30, 3): b");
+checkequal(c, 33, "[ret, a, b, c] = inout3Input1Ret(10, 1, 20, 2, 30, 3): c");
+
+
+// CLASS
+
+a = new_ClassA();
+
+[ret, c, d] = ClassA_output2Input2Ret(a, 1, 2);
+checkequal(ret, 6, "[ret, c, d] = ClassA_output2Input2Ret(a, 1, 2): ret");
+checkequal(c, 2, "[c, d] = ClassA_output2Input2Ret(a, 1, 2): c");
+checkequal(d, 4, "[c, d] = ClassA_output2Input2Ret(a, 1, 2): d");
+
+[ret, c, d] = ClassA_inout2Input2Ret(a, 1, 2, 1, 1);
+checkequal(ret, 5, "[ret, c, d] = ClassA_inout2Input2Ret(a, 1, 2): ret");
+checkequal(c, 2, "[c, d] = ClassA_inout2Input2(a, 1, 2): c");
+checkequal(d, 3, "[c, d] = ClassA_inout2Input2(a, 1, 2): d");
+
+delete_ClassA(a);
+
+
+exec("swigtest.quit", -1);
+
diff --git a/Examples/test-suite/scilab/scilab_pointer_conversion_functions_runme.sci b/Examples/test-suite/scilab/scilab_pointer_conversion_functions_runme.sci
new file mode 100644
index 000000000..d24f60eb9
--- /dev/null
+++ b/Examples/test-suite/scilab/scilab_pointer_conversion_functions_runme.sci
@@ -0,0 +1,18 @@
+exec("swigtest.start", -1);
+
+// Test on NULL
+null = getNull();
+checkequal(SWIG_this(null), 0, "SWIG_this(null)");
+
+null = SWIG_ptr(0);
+checkequal(isNull(null), %T, "func(null)");
+
+// Test on variable
+expected_foo_addr = getFooAddress();
+foo_addr = SWIG_this(pfoo_get());
+checkequal(foo_addr, expected_foo_addr, "SWIG_this(pfoo_get())");
+
+pfoo = SWIG_ptr(foo_addr);
+checkequal(equalFooPointer(pfoo), %T, "equalFooPointer(pfoo)");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/simple_array_runme.sci b/Examples/test-suite/scilab/simple_array_runme.sci
new file mode 100644
index 000000000..8ff1a3a57
--- /dev/null
+++ b/Examples/test-suite/scilab/simple_array_runme.sci
@@ -0,0 +1,12 @@
+exec("swigtest.start", -1);
+
+try
+ initArray();
+catch
+ swigtesterror();
+end
+
+if x_get() <> int32([0,1,2,3,4,5,6,7,8,9]) then swigtesterror(); end
+if y_get() <> [0/7,1/7,2/7,3/7,4/7,5/7,6/7] then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/sizet_runme.sci b/Examples/test-suite/scilab/sizet_runme.sci
new file mode 100644
index 000000000..117024973
--- /dev/null
+++ b/Examples/test-suite/scilab/sizet_runme.sci
@@ -0,0 +1,11 @@
+exec("swigtest.start", -1);
+
+s = 2000;
+s = test1(s+1);
+s = test2(s+1);
+s = test3(s+1);
+s = test4(s+1);
+if s <> 2004 then swigtesterror(); end
+
+exec("swigtest.quit", -1);
+
diff --git a/Examples/test-suite/scilab/smart_pointer_simple_runme.sci b/Examples/test-suite/scilab/smart_pointer_simple_runme.sci
new file mode 100644
index 000000000..7ab9085fe
--- /dev/null
+++ b/Examples/test-suite/scilab/smart_pointer_simple_runme.sci
@@ -0,0 +1,13 @@
+exec("swigtest.start", -1);
+
+f = new_Foo();
+b = new_Bar(f);
+
+Bar_x_set(b, 3);
+if Bar_x_get(b) <> 3 then swigtesterror(); end
+
+fp = Bar___deref__(b);
+Bar_x_set(b, 4);
+if Bar_x_get(b) <> 4 then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/sneaky1_runme.sci b/Examples/test-suite/scilab/sneaky1_runme.sci
new file mode 100644
index 000000000..5d9e24407
--- /dev/null
+++ b/Examples/test-suite/scilab/sneaky1_runme.sci
@@ -0,0 +1,31 @@
+exec("swigtest.start", -1);
+
+try
+ x = add(3, 4);
+catch
+ swigtesterror();
+end
+if x <> 7 then swigtesterror(); end
+
+try
+ y = subtract(3,4);
+catch
+ swigtesterror();
+end
+if y <> -1 then swigtesterror(); end
+
+try
+ z = mul(3,4);
+catch
+ swigtesterror();
+end
+if z <> 12 then swigtesterror(); end
+
+try
+ w = divide(3,4);
+catch
+ swigtesterror();
+end
+if w <> 0 then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/struct_initialization_runme.sci b/Examples/test-suite/scilab/struct_initialization_runme.sci
new file mode 100644
index 000000000..fcdb3fccc
--- /dev/null
+++ b/Examples/test-suite/scilab/struct_initialization_runme.sci
@@ -0,0 +1,15 @@
+exec("swigtest.start", -1);
+
+if StructC_x_get(instanceC1_get()) <> 10 then swigtesterror(); end
+
+if StructD_x_get(instanceD1_get()) <> 10 then swigtesterror(); end
+
+if StructD_x_get(instanceD2_get()) <> 20 then swigtesterror(); end
+
+if StructD_x_get(instanceD3_get()) <> 30 then swigtesterror(); end
+
+if StructE_x_get(instanceE1_get()) <> 1 then swigtesterror(); end
+
+if StructF_x_get(instanceF1_get()) <> 1 then swigtesterror(); end
+
+exec("swigtest.quit", -1);
\ No newline at end of file
diff --git a/Examples/test-suite/scilab/struct_rename_runme.sci b/Examples/test-suite/scilab/struct_rename_runme.sci
new file mode 100644
index 000000000..2737d446e
--- /dev/null
+++ b/Examples/test-suite/scilab/struct_rename_runme.sci
@@ -0,0 +1,11 @@
+exec("swigtest.start", -1);
+
+try
+ a = new_Bar();
+ Bar_x_set(a,100);
+catch
+ swigtesterror();
+end
+if Bar_x_get(a) <> 100 then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/struct_value_runme.sci b/Examples/test-suite/scilab/struct_value_runme.sci
new file mode 100644
index 000000000..b00970ef9
--- /dev/null
+++ b/Examples/test-suite/scilab/struct_value_runme.sci
@@ -0,0 +1,16 @@
+exec("swigtest.start", -1);
+
+foo = new_Foo();
+Foo_x_set(foo, 1);
+if Foo_x_get(foo) <> 1 then swigtesterror(); end
+
+bar = new_Bar();
+Bar_a_set(bar, foo);
+a = Bar_a_get(bar);
+if Foo_x_get(a) <> 1 then swigtesterror(); end
+
+Bar_b_set(bar, foo);
+b = Bar_b_get(bar);
+if Foo_x_get(b) <> 1 then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/swigtest.quit b/Examples/test-suite/scilab/swigtest.quit
new file mode 100644
index 000000000..307077da1
--- /dev/null
+++ b/Examples/test-suite/scilab/swigtest.quit
@@ -0,0 +1,2 @@
+// Exit from Scilab
+exit
diff --git a/Examples/test-suite/scilab/swigtest.start b/Examples/test-suite/scilab/swigtest.start
new file mode 100644
index 000000000..e4347bd90
--- /dev/null
+++ b/Examples/test-suite/scilab/swigtest.start
@@ -0,0 +1,57 @@
+lines(0);
+warning('off');
+ilib_verbose(0);
+
+// Get test name (used in swigtest.quit file)
+[units, typ, names] = file(1);
+swigtestname = strsubst(fileparts(names, "fname"), "_runme", "");
+
+// Does the library exists? If not then exit!
+libname = "lib" + swigtestname + getdynlibext();
+if ~isfile(libname) then
+ mfprintf(0, "*** LIBRARY NOT FOUND: %s ***\n", libname);
+ exit(1)
+end
+
+// Load library
+try
+ exec("loader.sce", -1);
+catch
+ mfprintf(0, "*** LOADER EXECUTION FAILED ***\n");
+ exit(1)
+end
+
+// Module initialization
+try
+ moduleInit = sprintf("%s_Init()", swigtestname);
+ execstr(moduleInit);
+catch
+ mfprintf(0, "*** MODULE INIT FAILED ***\n");
+ exit(1)
+end
+
+// Error management function
+function swigtesterror(msg)
+ [lines, names] = where();
+ if size(lines, '*') > 0
+ mfprintf(0, "*** TEST FAILED (at line %d) ***\n", lines($));
+ if argn(2) >= 1 then disp(msg); end
+ else
+ mfprintf(0, "*** TEST FAILED ***\n");
+ end;
+ exit(1)
+endfunction
+
+// Check equal function
+function checkequal(returned, expected, message)
+ if typeof(returned) <> typeof(expected) then
+ returned_type_msg = ["returned type:"; typeof(returned)];
+ expected_type_msg = ["expected type:"; typeof(expected)];
+ swigtesterror([message; returned_type_msg; expected_type_msg]);
+ end
+ if ~isequal(returned, expected) then
+ returned_value_msg = ["returned value:"; string(returned)];
+ expected_value_msg = ["expected value:"; string(expected)];
+ swigtesterror([message; returned_value_msg; expected_value_msg]);
+ end
+endfunction
diff --git a/Examples/test-suite/scilab/template_classes_runme.sci b/Examples/test-suite/scilab/template_classes_runme.sci
new file mode 100644
index 000000000..b4b3a2c53
--- /dev/null
+++ b/Examples/test-suite/scilab/template_classes_runme.sci
@@ -0,0 +1,8 @@
+exec("swigtest.start", -1);
+
+ri = new_RectangleInt();
+pi = RectangleInt_getPoint(ri);
+x = PointInt_getX(pi);
+delete_RectangleInt(ri);
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/template_ns_runme.sci b/Examples/test-suite/scilab/template_ns_runme.sci
new file mode 100644
index 000000000..aea784114
--- /dev/null
+++ b/Examples/test-suite/scilab/template_ns_runme.sci
@@ -0,0 +1,15 @@
+exec("swigtest.start", -1);
+
+p1 = new_pairii(2, 3);
+p2 = new_pairii(p1);
+
+checkequal(pairii_first_get(p2), 2, "pairii_first(p2) test fails.");
+checkequal(pairii_second_get(p2), 3, "pairii_second(p2) test fails.");
+
+p3 = new_pairdd(0.5, 2.5);
+p4 = new_pairdd(p3);
+
+checkequal(pairdd_first_get(p4), 0.5, "pairdd_first(p4) test fails.");
+checkequal(pairdd_second_get(p4), 2.5, "pairdd_second(p4) test fails.");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/template_rename_runme.sci b/Examples/test-suite/scilab/template_rename_runme.sci
new file mode 100644
index 000000000..9c9512930
--- /dev/null
+++ b/Examples/test-suite/scilab/template_rename_runme.sci
@@ -0,0 +1,15 @@
+exec("swigtest.start", -1);
+
+i = new_iFoo();
+checkequal(iFoo_blah_test(i, 4), 4, "iFoo_blah_test(i, 4) test fails");
+checkequal(iFoo_spam_test(i, 5), 5, "iFoo_spam_test(i, 5) test fails");
+checkequal(iFoo_groki_test(i, 6), 6, "iFoo_groki_test(i, 6) test fails");
+delete_iFoo(i);
+
+d = new_iFoo();
+checkequal(dFoo_blah_test(d, 4), 4, "dFoo_blah_test(d, 4) test fails");
+checkequal(dFoo_spam(d, 5), 5, "dFoo_spam_test(d, 5) test fails");
+checkequal(dFoo_grok_test(d, 6), 6, "dFoo_groki_test(d, 6) test fails");
+delete_dFoo(d);
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/template_static_runme.sci b/Examples/test-suite/scilab/template_static_runme.sci
new file mode 100644
index 000000000..e17c46143
--- /dev/null
+++ b/Examples/test-suite/scilab/template_static_runme.sci
@@ -0,0 +1,8 @@
+exec("swigtest.start", -1);
+
+checkequal(foo_i_test_get(), 0, "foo_i_test_get() test fails.");
+checkequal(foo_d_test_get(), 0, "foo_i_test_get() test fails.");
+
+checkequal(Foo_bar_double(0), 1, "Foo_bar_double() test fails");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/throw_exception_runme.sci b/Examples/test-suite/scilab/throw_exception_runme.sci
new file mode 100644
index 000000000..2eada4be2
--- /dev/null
+++ b/Examples/test-suite/scilab/throw_exception_runme.sci
@@ -0,0 +1,23 @@
+exec("swigtest.start", -1);
+
+function checkException(cmd, expected_error_msg)
+ ierr = execstr(cmd, 'errcatch');
+ checkequal(ierr, 20000, cmd + ': ierr');
+ checkequal(lasterror(), 'SWIG/Scilab: ' + expected_error_msg, cmd + ': msg');
+endfunction
+
+foo = new_Foo();
+
+checkException('Foo_test_int(foo)', 'Exception (int) occured: 37');
+
+checkException('Foo_test_msg(foo)', 'Exception (char const *) occured: Dead');
+
+checkException('Foo_test_multi(foo, 1)', 'Exception (int) occured: 37');
+
+checkException('Foo_test_multi(foo, 2)', 'Exception (char const *) occured: Dead');
+
+checkException('Foo_test_cls(foo)', 'Exception (CError) occured.');
+
+delete_Foo(foo);
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/typedef_struct_runme.sci b/Examples/test-suite/scilab/typedef_struct_runme.sci
new file mode 100644
index 000000000..e41c21629
--- /dev/null
+++ b/Examples/test-suite/scilab/typedef_struct_runme.sci
@@ -0,0 +1,29 @@
+exec("swigtest.start", -1);
+
+try
+ x = new_LineObj();
+ LineObj_numpoints_set(x, 100);
+catch
+ swigtesterror();
+end
+if LineObj_numpoints_get(x) <> 100 then swigtesterror(); end
+
+if MS_NOOVERRIDE_get() <> -1111 then swigtesterror(); end
+
+try
+ y = make_a();
+ A_t_a_set(y, 200);
+catch
+ swigtesterror();
+end
+if A_t_a_get(y) <> 200 then swigtesterror(); end
+
+try
+ A_t_b_set(y, 300);
+catch
+ swigtesterror();
+end
+if A_t_b_get(y) <> 300 then swigtesterror(); end
+
+exec("swigtest.quit", -1);
+
diff --git a/Examples/test-suite/scilab/union_parameter_runme.sci b/Examples/test-suite/scilab/union_parameter_runme.sci
new file mode 100644
index 000000000..2918856d9
--- /dev/null
+++ b/Examples/test-suite/scilab/union_parameter_runme.sci
@@ -0,0 +1,35 @@
+// Some lines are commented out because of too long identifiers...
+
+exec("swigtest.start", -1);
+
+event = new_SDL_Event();
+
+for i=1:2
+ evAvailable = SDL_PollEvent(event);
+ evType = SDL_Event_type_get(event);
+
+ if evType==1 then
+ specEvent = SDL_Event_active_get(event);
+ _type = SDL_ActiveEvent_type_get(specEvent);
+
+ if _type <> evType then swigtesterror(); end
+
+ gain = SDL_ActiveEvent_gain_get(specEvent);
+ //state = SDL_ActiveEvent_state_get(specEvent);
+ end
+
+ if evType==2 then
+ specEvent = SDL_Event_key_get(event);
+ //_type = SDL_KeyboardEvent_type_get(specEvent);
+
+ //if _type <> evType then swigtesterror(); end
+
+ //_which = SDL_KeyboardEvent_which_get(specEvent);
+ //state = SDL_KeyboardEvent_state_get(specEvent);
+ end
+
+end
+
+delete_SDL_Event(event);
+
+exec("swigtest.quit", -1);
\ No newline at end of file
diff --git a/Examples/test-suite/scilab/unions_runme.sci b/Examples/test-suite/scilab/unions_runme.sci
new file mode 100644
index 000000000..c8c6a9444
--- /dev/null
+++ b/Examples/test-suite/scilab/unions_runme.sci
@@ -0,0 +1,23 @@
+exec("swigtest.start", -1);
+
+try
+ small = new_SmallStruct();
+ SmallStruct_jill_set(small, 200);
+
+ big = new_BigStruct();
+ BigStruct_jack_set(big, 300);
+
+ Jill = SmallStruct_jill_get(small);
+catch
+ swigtesterror();
+end
+if Jill <> 200 then swigtesterror(); end
+
+try
+ Jack = BigStruct_jack_get(big);
+catch
+ swigtesterror();
+end
+if Jack <> 300 then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/varargs_overload_runme.sci b/Examples/test-suite/scilab/varargs_overload_runme.sci
new file mode 100644
index 000000000..7603b667c
--- /dev/null
+++ b/Examples/test-suite/scilab/varargs_overload_runme.sci
@@ -0,0 +1,21 @@
+exec("swigtest.start", -1);
+
+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(2, 2.2), "2 2.2", "vararg_over2(2, 2.2)")
+
+checkequal(vararg_over3("Hello"), "Hello", "vararg_over3(""Hello"")");
+
+checkequal(vararg_over3(2, 2.2, "hey"), "2 2.2 hey", "vararg_over3(2, 2.2, ""hey"")");
+
+checkequal(vararg_over4("Hello"), "Hello", "vararg_over4(""Hello"")");
+
+checkequal(vararg_over4(123), "123", "vararg_over4(123)");
+
+checkequal(vararg_over4("Hello", 123), "Hello", "vararg_over4(""Hello"", 123)");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/varargs_runme.sci b/Examples/test-suite/scilab/varargs_runme.sci
new file mode 100644
index 000000000..333838c00
--- /dev/null
+++ b/Examples/test-suite/scilab/varargs_runme.sci
@@ -0,0 +1,17 @@
+exec("swigtest.start", -1);
+
+checkequal(test("Hello"), "Hello", "test(""Hello"")");
+
+f = new_Foo("Greetings");
+checkequal(Foo_str_get(f), "Greetings", "new_Foo(""Greetings"")");
+
+checkequal(Foo_test(f, "Hello"), "Hello", "Foo_test(f)");
+delete_Foo(f);
+
+checkequal(Foo_statictest("Hello", 1), "Hello", "Foo_statictest(""Hello"", 1)");
+
+checkequal(test_def("Hello", 1), "Hello", "test_def(""Hello"", 1)");
+
+checkequal(test_def("Hello"), "Hello", "test_def(""Hello"")");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/voidtest_runme.sci b/Examples/test-suite/scilab/voidtest_runme.sci
new file mode 100644
index 000000000..395e8f630
--- /dev/null
+++ b/Examples/test-suite/scilab/voidtest_runme.sci
@@ -0,0 +1,22 @@
+exec("swigtest.start", -1);
+
+globalfunc();
+
+f = new_Foo();
+Foo_memberfunc(f);
+
+Foo_staticmemberfunc();
+
+v1 = vfunc1(f);
+checkequal(SWIG_this(v1), SWIG_this(f), "vfunc1(f) <> f");
+
+v2 = vfunc2(f);
+checkequal(SWIG_this(v2), SWIG_this(f), "vfunc2(f) <> f");
+
+v3 = vfunc3(v1);
+checkequal(SWIG_this(v3), SWIG_this(f), "vfunc3(f) <> f");
+
+Foo_memberfunc(v3);
+
+exec("swigtest.quit", -1);
+
diff --git a/Examples/test-suite/scilab_consts.i b/Examples/test-suite/scilab_consts.i
new file mode 100644
index 000000000..11f2504b7
--- /dev/null
+++ b/Examples/test-suite/scilab_consts.i
@@ -0,0 +1,52 @@
+%module scilab_consts
+
+/* Default mode: constants are wrapped as getter functions */
+%scilabconst(0);
+
+#define ICONST0 42
+#define FCONST0 2.1828
+#define CCONST0 'x'
+#define CCONST0_2 '\n'
+#define SCONST0 "Hello World"
+#define SCONST0_2 "\"Hello World\""
+
+/* Constants with type */
+#define UNSIGNED0 0x5FFFU
+#define LONG0 0x3FFF0000L
+#define ULONG0 0x5FF0000UL
+
+/* Expressions should work too */
+#define EXPR0 ICONST0 + 3*FCONST0
+
+/* This shouldn't do anything, bar is not defined */
+#define BAR0 bar
+
+/* SWIG directive %constant produces constants too */
+%constant int iconst0 = 37;
+%constant double fconst0 = 42.2;
+
+
+/* Alternative mode: constants are wrapped as variables */
+%scilabconst(1);
+
+#define ICONST1 42
+#define FCONST1 2.1828
+#define CCONST1 'x'
+#define CCONST1_2 '\n'
+#define SCONST1 "Hello World"
+#define SCONST1_2 "\"Hello World\""
+
+/* Constants with type */
+#define UNSIGNED1 0x5FFFU
+#define LONG1 0x3FFF0000L
+#define ULONG1 0x5FF0000UL
+
+/* Expressions should work too */
+#define EXPR1 ICONST1 + 3*FCONST1
+
+/* This shouldn't do anything, bar is not defined */
+#define BAR1 bar
+
+/* SWIG directive %constant produces constants too */
+%constant int iconst1 = 37;
+%constant double fconst1 = 42.2;
diff --git a/Examples/test-suite/scilab_enums.i b/Examples/test-suite/scilab_enums.i
new file mode 100644
index 000000000..32d5a34de
--- /dev/null
+++ b/Examples/test-suite/scilab_enums.i
@@ -0,0 +1,38 @@
+%module scilab_enums
+
+%scilabconst(1);
+
+%inline %{
+
+enum ENUM {
+ ENUM_1,
+ ENUM_2
+};
+
+enum ENUM_EXPLICIT_1 {
+ ENUM_EXPLICIT_1_1 = 5,
+ ENUM_EXPLICIT_1_2
+};
+
+enum ENUM_EXPLICIT_2 {
+ ENUM_EXPLICIT_2_1,
+ ENUM_EXPLICIT_2_2 = 10
+};
+
+enum ENUM_EXPLICIT_3 {
+ ENUM_EXPLICIT_3_1 = 2,
+ ENUM_EXPLICIT_3_2 = 5,
+ ENUM_EXPLICIT_3_3 = 8
+};
+
+typedef enum {
+ TYPEDEF_ENUM_1_1 = 21,
+ TYPEDEF_ENUM_1_2 = 22
+} TYPEDEF_ENUM_1;
+
+typedef enum TYPEDEF_ENUM_2 {
+ TYPEDEF_ENUM_2_1 = 31,
+ TYPEDEF_ENUM_2_2 = 32
+} TYPEDEF_ENUM_2;
+
+%}
diff --git a/Examples/test-suite/scilab_identifier_name.i b/Examples/test-suite/scilab_identifier_name.i
new file mode 100644
index 000000000..94dde47e0
--- /dev/null
+++ b/Examples/test-suite/scilab_identifier_name.i
@@ -0,0 +1,53 @@
+%module scilab_identifier_name
+
+//
+// Test long identifier name (> 24 characters) truncating
+//
+
+// Test truncating variables, constants, functions identifier names
+
+%inline %{
+// these identifier names wont be truncated
+int gvar_identifier_name = -1;
+#define CONS_IDENTIFIER_NAME -11
+int function_identifier_name() { return -21; };
+
+// these identifier names will be truncated
+int too_long_gvar_identifier_name_1 = 1;
+int too_long_gvar_identifier_name_2 = 2;
+
+#define TOO_LONG_CONST_IDENTIFIER_NAME_1 11
+
+int too_long_function_identifier_name_1() { return 21; };
+%}
+
+// Test truncating when %scilabconst mode is activated
+%scilabconst(1);
+
+%inline %{
+#define SC_CONST_IDENTIFIER_NAME -12;
+
+#define SC_TOO_LONG_CONST_IDENTIFIER_NAME_1 13
+#define SC_TOO_LONG_CONST_IDENTIFIER_NAME_2 14
+%}
+%scilabconst(0);
+
+// Test truncating in the case of struct
+%inline %{
+struct st {
+ int m_identifier_name;
+ int too_long_member_identifier_name;
+};
+
+%}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Examples/test-suite/scilab_li_matrix.i b/Examples/test-suite/scilab_li_matrix.i
new file mode 100644
index 000000000..ae5ad76bb
--- /dev/null
+++ b/Examples/test-suite/scilab_li_matrix.i
@@ -0,0 +1,161 @@
+%module scilab_li_matrix
+
+%include "matrix.i"
+
+%define %use_matrix_apply(TYPE...)
+%apply (TYPE *IN, int IN_ROWCOUNT, int IN_COLCOUNT) { (TYPE *matrix, int nbRow, int nbCol) }
+%apply (TYPE **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT) { (TYPE **matrixRes, int *nbRowRes, int *nbColRes) }
+%apply (TYPE *IN, int IN_SIZE) { (TYPE *matrix, int size) }
+%apply (TYPE **OUT, int *OUT_SIZE) { (TYPE **matrixRes, int *sizeRes) }
+%enddef
+
+%use_matrix_apply(int);
+%use_matrix_apply(double);
+%use_matrix_apply(char *);
+%use_matrix_apply(bool);
+
+%inline %{
+
+/*
+ * (T *matrixIn, int matrixInSize) pattern functions
+ */
+
+template T inMatrixSize(T *matrix, int size) {
+ T sum = 0;
+ int i;
+ for (i = 0; i < size; i++)
+ sum += matrix[i];
+ return sum;
+}
+
+template void outMatrixSize(T **matrixRes, int *sizeRes) {
+ int size;
+ int i;
+ *sizeRes = 6;
+ *matrixRes = (T*) malloc(*sizeRes * sizeof(T));
+ for (i = 0; i < *sizeRes; i++)
+ (*matrixRes)[i] = i;
+}
+
+template void inoutMatrixSize(T *matrix, int size, T **matrixRes, int *sizeRes) {
+ int i;
+ *sizeRes = size;
+ *matrixRes = (T*) malloc(size * sizeof(T));
+ for (i = 0; i < size; i++) {
+ (*matrixRes)[i] = matrix[i] * matrix[i];
+ }
+}
+
+/*
+ * (char **matrixIn, int matrixInSize) pattern functions
+ */
+
+template<> char* inMatrixSize(char **matrix, int size) {
+ char *s = (char *) calloc(size + 1, sizeof(char));
+ int i;
+ for (i = 0; i < size; i++)
+ strcat(s, matrix[i]);
+ return s;
+}
+
+template<> void outMatrixSize(char ***matrixRes, int *sizeRes) {
+ char *s;
+ int i;
+ *sizeRes = 6;
+ *matrixRes = (char **) malloc(*sizeRes * sizeof(char *));
+ for (i = 0; i < *sizeRes; i++) {
+ s = (char *) malloc(sizeof(char)+1);
+ sprintf(s, "%c", char(65 + i));
+ (*matrixRes)[i] = s;
+ }
+}
+
+template<> void inoutMatrixSize(char **matrix, int size,
+ char ***matrixRes, int *sizeRes) {
+ int i;
+ char *s;
+ *sizeRes = size;
+ *matrixRes = (char **) malloc(*sizeRes * sizeof(char* ));
+ for (i = 0; i < *sizeRes; i++) {
+ s = (char *) malloc((2 * strlen(matrix[i]) + 1) * sizeof(char));
+ sprintf(s, "%s%s", matrix[i], matrix[i]);
+ (*matrixRes)[i] = s;
+ }
+}
+
+/*
+ * (bool **matrixIn, int matrixInSize) pattern functions
+ */
+
+template<> bool inMatrixSize(bool *matrix, int size) {
+ bool b = true;
+ int i;
+ b = matrix[0];
+ for (i = 1; i < size; i++)
+ b = b ^ matrix[i];
+ return b;
+}
+
+template<> void outMatrixSize(bool **matrixRes, int *sizeRes) {
+ int i;
+ *sizeRes = 6;
+ *matrixRes = (bool*) malloc(*sizeRes * sizeof(bool));
+ for (i = 0; i < *sizeRes; i++) {
+ (*matrixRes)[i] = i % 2 == 0;
+ }
+}
+
+template<> void inoutMatrixSize(bool *matrix, int size,
+ bool **matrixRes, int *sizeRes) {
+ int i;
+ *sizeRes = size;
+ *matrixRes = (bool*) malloc(*sizeRes * sizeof(bool));
+ for (i = 0; i < *sizeRes; i++) {
+ (*matrixRes)[i] = matrix[i] == 1 ? 0 : 1;
+ }
+}
+
+/*
+ * (T *matrixIn, int matrixInRowCount, int matrixInColCount) pattern functions
+ */
+
+template T inMatrixDims(T *matrix, int nbRow, int nbCol) {
+ return inMatrixSize(matrix, nbRow * nbCol);
+}
+
+template void outMatrixDims(T **matrixRes, int *nbRowRes, int *nbColRes) {
+ int size = 0;
+ outMatrixSize(matrixRes, &size);
+ *nbRowRes = 3;
+ *nbColRes = 2;
+}
+
+template void inoutMatrixDims(T *matrix, int nbRow, int nbCol,
+ T **matrixRes, int *nbRowRes, int *nbColRes) {
+ *nbRowRes = nbRow;
+ *nbColRes = nbCol;
+ int sizeRes = 0;
+ inoutMatrixSize(matrix, nbRow * nbCol, matrixRes, &sizeRes);
+}
+
+%}
+
+%define %instantiate_matrix_template_functions(NAME, TYPE...)
+%template(in ## NAME ## MatrixDims) inMatrixDims;
+%template(out ## NAME ## MatrixDims) outMatrixDims;
+%template(inout ## NAME ## MatrixDims) inoutMatrixDims;
+%template(in ## NAME ## MatrixSize) inMatrixSize;
+%template(out ## NAME ## MatrixSize) outMatrixSize;
+%template(inout ## NAME ## MatrixSize) inoutMatrixSize;
+%enddef
+
+%instantiate_matrix_template_functions(Int, int);
+%instantiate_matrix_template_functions(Double, double);
+%instantiate_matrix_template_functions(CharPtr, char *);
+%instantiate_matrix_template_functions(Bool, bool);
+
+
+
+
+
+
diff --git a/Examples/test-suite/scilab_multivalue.i b/Examples/test-suite/scilab_multivalue.i
new file mode 100644
index 000000000..3165d48e1
--- /dev/null
+++ b/Examples/test-suite/scilab_multivalue.i
@@ -0,0 +1,123 @@
+%module scilab_multivalue
+
+
+
+void output2(int *OUTPUT, int *OUTPUT);
+int output2Ret(int *OUTPUT, int *OUTPUT);
+void output2Input2(int a, int b, int *OUTPUT, int *OUTPUT);
+int output2Input2Ret(int a, int b, int *OUTPUT, int *OUTPUT);
+int output3Input1Ret(int a, int *OUTPUT, int *OUTPUT, int *OUTPUT);
+int output3Input3Ret(int x, int *OUTPUT, int y, int *OUTPUT, int z, int *OUTPUT);
+
+void inout2(int *INOUT, int *INOUT);
+int inout2Ret(int *INOUT, int *INOUT);
+void inout2Input2(int a, int b, int *INOUT, int *INOUT);
+int inout2Input2Ret(int a, int b, int *INOUT, int *INOUT);
+int inout3Input1Ret(int a, int *INOUT, int *INOUT, int *INOUT);
+int inout3Input3Ret(int x, int *INOUT, int y, int *INOUT, int z, int *INOUT);
+
+class ClassA {
+public:
+ ClassA() {};
+ int output2Input2Ret(int a, int b, int *OUTPUT, int *OUTPUT);
+ int inout2Input2Ret(int a, int b, int *INOUT, int *INOUT);
+};
+
+%{
+
+// Test return of multiple values with OUTPUT
+
+void output2(int *a, int *b) {
+ *a = 1;
+ *b = 2;
+}
+
+int output2Ret(int *a, int *b) {
+ *a = 1;
+ *b = 2;
+ return *a + *b;
+}
+
+void output2Input2(int a, int b, int *c, int *d) {
+ *c = a + 1;
+ *d = b + 2;
+}
+
+int output2Input2Ret(int a, int b, int *c, int *d) {
+ *c = a + 1;
+ *d = b + 2;
+ return *c + *d;
+}
+
+int output3Input1Ret(int x, int *a, int *b, int *c) {
+ *a = x + 1;
+ *b = x + 2;
+ *c = x + 3;
+ return x;
+}
+
+int output3Input3Ret(int x, int *a, int y, int *b, int z, int *c) {
+ *a = x + 1;
+ *b = y + 2;
+ *c = z + 3;
+ return *a + *b + *c;
+}
+
+
+// Test return of multiple values with INOUT
+
+void inout2(int *a, int *b) {
+ *a = *a + 1;
+ *b = *a + 2;
+}
+
+int inout2Ret(int *a, int *b) {
+ *a = *a + 1;
+ *b = *a + 2;
+ return *a + *b;
+}
+
+void inout2Input2(int a, int b, int *c, int *d) {
+ *c = *c + a;
+ *d = *d + b;
+}
+
+int inout2Input2Ret(int a, int b, int *c, int *d) {
+ *c = *c + a;
+ *d = *d + b;
+ return *c + *d;
+}
+
+int inout3Input1Ret(int x, int *a, int *b, int *c) {
+ *a = *a + x;
+ *b = *b + x;
+ *c = *c + x;
+ return x;
+}
+
+int inout3Input3Ret(int x, int *a, int y, int *b, int z, int *c) {
+ *a = *a + x;
+ *b = *b + y;
+ *c = *c + z;
+ return *a + *b + *c;
+}
+
+// Test return multiples from class methods
+
+class ClassA {
+public:
+ ClassA() {};
+ int output2Input2Ret(int a, int b, int *c, int *d) {
+ *c = a + 1;
+ *d = b + 2;
+ return *c + *d;
+ }
+ int inout2Input2Ret(int a, int b, int *c, int *d) {
+ *c = *c + a;
+ *d = *d + b;
+ return *c + *d;
+ }
+};
+
+
+%}
diff --git a/Examples/test-suite/scilab_pointer_conversion_functions.i b/Examples/test-suite/scilab_pointer_conversion_functions.i
new file mode 100644
index 000000000..5e29926c1
--- /dev/null
+++ b/Examples/test-suite/scilab_pointer_conversion_functions.i
@@ -0,0 +1,18 @@
+%module scilab_pointer_conversion_functions
+
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) pfoo; /* Setting a pointer/reference variable may leak memory. */
+
+%inline %{
+
+void* getNull() { return NULL; }
+bool isNull(void *p) { return p == NULL; }
+
+int foo = 3;
+int *pfoo = &foo;
+
+double getFooAddress() { return (double) (unsigned long) pfoo; }
+bool equalFooPointer(void *p) { return p == pfoo; }
+
+%}
+
+
diff --git a/Examples/test-suite/sizeof_pointer.i b/Examples/test-suite/sizeof_pointer.i
index 993ba4de5..aa6cfcd5c 100644
--- a/Examples/test-suite/sizeof_pointer.i
+++ b/Examples/test-suite/sizeof_pointer.i
@@ -4,16 +4,17 @@ This testcase tests whether the sizeof operator on a pointer is working.
%module sizeof_pointer
+
%inline %{
#define NO_PROBLEM sizeof(char)
#define STAR_PROBLEM sizeof(char*)
#define STAR_STAR_PROBLEM sizeof(char**)
-typedef struct SizeofPointerTest {
+typedef struct SizePtrTst {
unsigned char array1[NO_PROBLEM];
unsigned char array2[STAR_PROBLEM];
unsigned char array3[STAR_STAR_PROBLEM];
-} SizeofPointerTest;
+} SizePtrTst;
%}
diff --git a/Examples/test-suite/smart_pointer_const_overload.i b/Examples/test-suite/smart_pointer_const_overload.i
index e3b000b52..75a137b73 100644
--- a/Examples/test-suite/smart_pointer_const_overload.i
+++ b/Examples/test-suite/smart_pointer_const_overload.i
@@ -34,7 +34,7 @@ struct Foo {
Foo() : x(0), xp(&x), y(0), yp(&y), access(0) { }
int getx() const { return x; }
void setx(int x_) { x = x_; }
- static void stat() {}
+ static void statMethod() {}
};
%}
diff --git a/Examples/test-suite/template_default_class_parms.i b/Examples/test-suite/template_default_class_parms.i
index cd37269d3..d07a1309f 100644
--- a/Examples/test-suite/template_default_class_parms.i
+++ b/Examples/test-suite/template_default_class_parms.i
@@ -31,3 +31,49 @@ namespace Space {
%template(FooAnotherType) Space::Foo;
%template() Space::ATemplate<>;
+
+
+// Github issue #280 segfault
+%inline %{
+namespace Teuchos {
+ class Describable {};
+}
+namespace KokkosClassic {
+ namespace DefaultNode {
+ struct DefaultNodeType {};
+ }
+}
+
+namespace Tpetra {
+ template
+ class Map : public Teuchos::Describable {
+ public:
+ typedef LocalOrdinal local_ordinal_type;
+ typedef GlobalOrdinal global_ordinal_type;
+ typedef Node node_type;
+ void test_func(LocalOrdinal, GlobalOrdinal, Node) {}
+ };
+}
+%}
+
+#ifdef SWIGJAVA
+// Fixes still required for other languages
+%template(MapDefaults) Tpetra::Map<>;
+#endif
+
+%inline %{
+namespace Details {
+ template < class LO = ::Tpetra::Map<>::local_ordinal_type,
+ class GO = typename ::Tpetra::Map::global_ordinal_type,
+ class NT = typename ::Tpetra::Map::node_type >
+ class Transfer : public Teuchos::Describable {
+ public:
+ void transfer_func(LO, GO, NT) {}
+ };
+}
+%}
+
+// Below is not resolving correctly yet
+//%template(TransferDefaults) Details::Transfer<>;
diff --git a/Examples/test-suite/template_nested.i b/Examples/test-suite/template_nested.i
index 81a551a41..67668fb1a 100644
--- a/Examples/test-suite/template_nested.i
+++ b/Examples/test-suite/template_nested.i
@@ -114,6 +114,8 @@ namespace ns {
};
}
%}
+
+#if !defined(SWIGSCILAB)
%extend ns::OuterClass {
%template(T_OuterClassInner2Double) Inner2;
}
@@ -125,3 +127,14 @@ namespace ns {
%template(T_OuterClassInner1Int) ns::OuterClass::Inner1;
%template(T_OuterClassInner2NormalClass) ns::OuterClass::Inner2;
%template(T_OuterClassInner2Int) ns::OuterClass::Inner2;
+
+#else
+%extend ns::OuterClass {
+ %template(T_OutClsIn2Dbl) Inner2;
+}
+
+%template(T_OutClsIn1Int) ns::OuterClass::Inner1;
+%template(T_OutClsIn2NormCls) ns::OuterClass::Inner2;
+%template(T_OutClsIn2Int) ns::OuterClass::Inner2;
+
+#endif
diff --git a/Examples/test-suite/template_template_parameters.i b/Examples/test-suite/template_template_parameters.i
index 0c3989603..89197229e 100644
--- a/Examples/test-suite/template_template_parameters.i
+++ b/Examples/test-suite/template_template_parameters.i
@@ -13,7 +13,7 @@
template class list_impl_t {};
template class t_alloc = pfc::alloc_fast >
- class list_t : public list_impl_t > {
+ class list_tt : public list_impl_t > {
public:
t_item item;
// typename t_alloc::alloc_type allotype; // SWIG can't handle this yet
@@ -32,8 +32,8 @@ void TestInstantiations() {
%}
%template(ListImplFastBool) list_impl_t >;
-%template(ListFastBool) list_t;
+%template(ListFastBool) list_tt;
%template(ListImplFastDouble) list_impl_t >;
-%template(ListDefaultDouble) list_t;
+%template(ListDefaultDouble) list_tt;
diff --git a/Examples/test-suite/throw_exception.i b/Examples/test-suite/throw_exception.i
index c1ad945fb..396c633a6 100644
--- a/Examples/test-suite/throw_exception.i
+++ b/Examples/test-suite/throw_exception.i
@@ -16,15 +16,15 @@
%inline %{
-class Error {
+class CError {
};
-void test_is_Error(Error *r) {}
+void test_is_Error(CError *r) {}
namespace Namespace {
- typedef Error ErrorTypedef;
- typedef const Error& ErrorRef;
- typedef const Error* ErrorPtr;
+ typedef CError ErrorTypedef;
+ typedef const CError& ErrorRef;
+ typedef const CError* ErrorPtr;
typedef int IntArray[10];
enum EnumTest { enum1, enum2 };
}
@@ -36,26 +36,26 @@ public:
void test_msg() throw(const char *) {
throw "Dead";
}
- void test_cls() throw(Error) {
- throw Error();
+ void test_cls() throw(CError) {
+ throw CError();
}
- void test_cls_ptr() throw(Error *) {
- static Error StaticError;
+ void test_cls_ptr() throw(CError *) {
+ static CError StaticError;
throw &StaticError;
}
- void test_cls_ref() throw(Error &) {
- static Error StaticError;
+ void test_cls_ref() throw(CError &) {
+ static CError StaticError;
throw StaticError;
}
void test_cls_td() throw(Namespace::ErrorTypedef) {
- throw Error();
+ throw CError();
}
void test_cls_ptr_td() throw(Namespace::ErrorPtr) {
- static Error StaticError;
+ static CError StaticError;
throw &StaticError;
}
void test_cls_ref_td() throw(Namespace::ErrorRef) {
- static Error StaticError;
+ static CError StaticError;
throw StaticError;
}
void test_array() throw(Namespace::IntArray) {
@@ -68,10 +68,10 @@ public:
void test_enum() throw(Namespace::EnumTest) {
throw Namespace::enum2;
}
- void test_multi(int x) throw(int, const char *, Error) {
+ void test_multi(int x) throw(int, const char *, CError) {
if (x == 1) throw 37;
if (x == 2) throw "Dead";
- if (x == 3) throw Error();
+ if (x == 3) throw CError();
}
};
diff --git a/Examples/test-suite/typemap_array_qualifiers.i b/Examples/test-suite/typemap_array_qualifiers.i
index cbc6c95ff..c3965ced2 100644
--- a/Examples/test-suite/typemap_array_qualifiers.i
+++ b/Examples/test-suite/typemap_array_qualifiers.i
@@ -33,8 +33,10 @@
typedef SomeType myarray[3];
typedef const SomeType myconstarray[4];
typedef volatile SomeType ** mycrazyarray[5];
- typedef volatile SomeType (mycrazyfunc)(SomeType);
- typedef volatile SomeType (*mycrazyfuncptr)(SomeType);
+ extern "C" {
+ typedef volatile SomeType (mycrazyfunc)(SomeType);
+ typedef volatile SomeType (*mycrazyfuncptr)(SomeType);
+ }
%}
CLEAR_SWIGTYPE_TYPEMAPS;
diff --git a/Examples/test-suite/typemap_variables.i b/Examples/test-suite/typemap_variables.i
index 687cae1da..b1ae24fdf 100644
--- a/Examples/test-suite/typemap_variables.i
+++ b/Examples/test-suite/typemap_variables.i
@@ -63,6 +63,19 @@
%typemap(javain) int Space::Struct::smember "/*int smember in */ $javainput"
%typemap(javaout) int Space::Struct::smember "/*int smember out*/ { return $jnicall; }"
+#if defined(SWIGSCILAB)
+%clear int globul;
+%clear int Space::nspace;
+%clear int Space::Struct::smember;
+%ignore Space::Struct::member;
+%typemap(varin) int globul "TYPEMAP_VARIABLES_FAIL";
+%typemap(varout, noblock=1, fragment=SWIG_From_frag(int)) int globul "if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, SWIG_From_int($result)))) return SWIG_ERROR;";
+%typemap(varin) int Space::nspace "TYPEMAP_VARIABLES_FAIL";
+%typemap(varout, noblock=1, fragment=SWIG_From_frag(int)) int Space::nspace "if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, SWIG_From_int($result)))) return SWIG_ERROR;";
+%typemap(varin) int Space::Struct::smember "TYPEMAP_VARIABLES_FAIL";
+%typemap(varout, noblock=1, fragment=SWIG_From_frag(int)) int Space::Struct::smember "if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, SWIG_From_int($result)))) return SWIG_ERROR;";
+#endif
+
%inline %{
int globul;
diff --git a/Examples/test-suite/unions.i b/Examples/test-suite/unions.i
index 49bb85de4..405d28c67 100644
--- a/Examples/test-suite/unions.i
+++ b/Examples/test-suite/unions.i
@@ -8,7 +8,7 @@ This testcase checks that unions can be set and read.
/* Must undefine small to work on Windows. small is defined as a
char in rpcndr.h */
#ifdef small
-#undef small
+#undef small
#endif
%}
@@ -37,6 +37,12 @@ typedef struct {
SmallStruct small;
} uni;
int number;
-} EmbeddedUnionTest;
+}
+#if !defined(SWIGSCILAB)
+EmbeddedUnionTest;
+#else
+EmbedUnionTst;
+#endif
%}
+
diff --git a/Examples/test-suite/varargs_overload.i b/Examples/test-suite/varargs_overload.i
index 1ba00ba65..9a24e15a8 100644
--- a/Examples/test-suite/varargs_overload.i
+++ b/Examples/test-suite/varargs_overload.i
@@ -3,6 +3,8 @@
%module varargs_overload
%inline %{
+#include
+
const char *vararg_over1(const char *fmt, ...) {
return fmt;
}
diff --git a/Examples/test-suite/voidtest.i b/Examples/test-suite/voidtest.i
index 90779e227..f0e649373 100644
--- a/Examples/test-suite/voidtest.i
+++ b/Examples/test-suite/voidtest.i
@@ -17,7 +17,5 @@ void *vfunc1(void *f) { return f; }
void *vfunc2(Foo *f) { return f; }
Foo *vfunc3(void *f) { return (Foo *) f; }
Foo *vfunc4(Foo *f) { return f; }
-
%}
-
diff --git a/Lib/csharp/enums.swg b/Lib/csharp/enums.swg
index 9b4acefc0..5cc265476 100644
--- a/Lib/csharp/enums.swg
+++ b/Lib/csharp/enums.swg
@@ -18,7 +18,7 @@
%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE &
%{ static $*1_ltype temp = ($*1_ltype)$input;
$result = &temp; %}
-%typemap(directorin) const enum SWIGTYPE & "$input = $1;"
+%typemap(directorin) const enum SWIGTYPE & "$input = (int)$1;"
%typemap(csdirectorin) const enum SWIGTYPE & "($*csclassname)$iminput"
%typemap(csdirectorout) const enum SWIGTYPE & "(int)$cscall"
@@ -51,7 +51,7 @@
%typemap(out) enum SWIGTYPE %{ $result = (int)$1; %}
%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %}
-%typemap(directorin) enum SWIGTYPE "$input = $1;"
+%typemap(directorin) enum SWIGTYPE "$input = (int)$1;"
%typemap(csdirectorin) enum SWIGTYPE "($csclassname)$iminput"
%typemap(csdirectorout) enum SWIGTYPE "(int)$cscall"
diff --git a/Lib/csharp/enumsimple.swg b/Lib/csharp/enumsimple.swg
index 484443652..24e4bcf18 100644
--- a/Lib/csharp/enumsimple.swg
+++ b/Lib/csharp/enumsimple.swg
@@ -20,7 +20,7 @@
%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE &
%{ static $*1_ltype temp = ($*1_ltype)$input;
$result = &temp; %}
-%typemap(directorin) const enum SWIGTYPE & "$input = $1;"
+%typemap(directorin) const enum SWIGTYPE & "$input = (int)$1;"
%typemap(csdirectorin) const enum SWIGTYPE & "$iminput"
%typemap(csdirectorout) const enum SWIGTYPE & "$cscall"
@@ -53,7 +53,7 @@
%typemap(out) enum SWIGTYPE %{ $result = (int)$1; %}
%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %}
-%typemap(directorin) enum SWIGTYPE "$input = $1;"
+%typemap(directorin) enum SWIGTYPE "$input = (int)$1;"
%typemap(csdirectorin) enum SWIGTYPE "$iminput"
%typemap(csdirectorout) enum SWIGTYPE "$cscall"
diff --git a/Lib/csharp/enumtypesafe.swg b/Lib/csharp/enumtypesafe.swg
index b7079343c..fd6801730 100644
--- a/Lib/csharp/enumtypesafe.swg
+++ b/Lib/csharp/enumtypesafe.swg
@@ -19,7 +19,7 @@
%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE &
%{ static $*1_ltype temp = ($*1_ltype)$input;
$result = &temp; %}
-%typemap(directorin) const enum SWIGTYPE & "$input = $1;"
+%typemap(directorin) const enum SWIGTYPE & "$input = (int)$1;"
%typemap(csdirectorin) const enum SWIGTYPE & "$*csclassname.swigToEnum($iminput)"
%typemap(csdirectorout) const enum SWIGTYPE & "$cscall.swigValue"
@@ -52,7 +52,7 @@
%typemap(out) enum SWIGTYPE %{ $result = (int)$1; %}
%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %}
-%typemap(directorin) enum SWIGTYPE "$input = $1;"
+%typemap(directorin) enum SWIGTYPE "$input = (int)$1;"
%typemap(csdirectorin) enum SWIGTYPE "$csclassname.swigToEnum($iminput)"
%typemap(csdirectorout) enum SWIGTYPE "$cscall.swigValue"
diff --git a/Lib/d/dhead.swg b/Lib/d/dhead.swg
index 786ca6e66..50e9c2e87 100644
--- a/Lib/d/dhead.swg
+++ b/Lib/d/dhead.swg
@@ -28,7 +28,7 @@ typedef enum {
SWIG_DIllegalArgumentException,
SWIG_DIllegalElementException,
SWIG_DIOException,
- SWIG_DNoSuchElementException,
+ SWIG_DNoSuchElementException
} SWIG_DExceptionCodes;
typedef void (* SWIG_DExceptionCallback_t)(const char *);
diff --git a/Lib/go/cdata.i b/Lib/go/cdata.i
index 9e6dc2161..b4411af97 100644
--- a/Lib/go/cdata.i
+++ b/Lib/go/cdata.i
@@ -8,16 +8,47 @@
typedef struct SWIGCDATA {
char *data;
intgo len;
- intgo cap;
} SWIGCDATA;
%}
-%typemap(gotype) SWIGCDATA %{ []byte %}
-%typemap(out) SWIGCDATA %{
- $result.data = (char*)_swig_goallocate($1.len);
- memcpy($result.data, $1.data, $1.len);
- $result.len = (intgo)$1.len;
- $result.cap = $result.len;
+%fragment("cdata", "header") %{
+struct swigcdata {
+ intgo size;
+ void *data;
+};
+%}
+
+%typemap(gotype) SWIGCDATA "[]byte"
+
+%typemap(imtype) SWIGCDATA "uint64"
+
+%typemap(out, fragment="cdata") SWIGCDATA(struct swigcdata *swig_out) %{
+ swig_out = (struct swigcdata *)malloc(sizeof(*swig_out));
+ if (swig_out) {
+ swig_out->size = $1.len;
+ swig_out->data = malloc(swig_out->size);
+ if (swig_out->data) {
+ memcpy(swig_out->data, $1.data, swig_out->size);
+ }
+ }
+ $result = *(long long *)(void **)&swig_out;
+%}
+
+%typemap(goout) SWIGCDATA %{
+ {
+ type swigcdata struct { size int; data uintptr }
+ p := (*swigcdata)(unsafe.Pointer(uintptr($1)))
+ if p == nil || p.data == 0 {
+ $result = nil
+ } else {
+ b := make([]byte, p.size)
+ a := (*[0x7fffffff]byte)(unsafe.Pointer(p.data))[:p.size]
+ copy(b, a)
+ Swig_free(p.data)
+ Swig_free(uintptr(unsafe.Pointer(p)))
+ $result = b
+ }
+ }
%}
/* -----------------------------------------------------------------------------
diff --git a/Lib/go/go.swg b/Lib/go/go.swg
index c680844c4..d38623b4a 100644
--- a/Lib/go/go.swg
+++ b/Lib/go/go.swg
@@ -4,6 +4,8 @@
* Go configuration module.
* ------------------------------------------------------------ */
+%include
+
/* Code insertion directives */
#define %go_import(...) %insert(go_imports) %{__VA_ARGS__%}
@@ -75,6 +77,22 @@
double
%{ $result = $1; %}
+%typemap(goout) bool,
+ char,
+ signed char,
+ unsigned char,
+ short,
+ unsigned short,
+ int,
+ unsigned int,
+ long,
+ unsigned long,
+ long long,
+ unsigned long long,
+ float,
+ double
+""
+
%typemap(out) const bool &,
const char &,
const signed char &,
@@ -91,8 +109,26 @@
const double &
%{ $result = ($*1_ltype)*$1; %}
+%typemap(goout) const bool &,
+ const char &,
+ const signed char &,
+ const unsigned char &,
+ const short &,
+ const unsigned short &,
+ const int &,
+ const unsigned int &,
+ const long &,
+ const unsigned long &,
+ const long long &,
+ const unsigned long long &,
+ const float &,
+ const double &
+""
+
%typemap(out) void ""
+%typemap(goout) void ""
+
%typemap(directorin) bool,
char,
signed char,
@@ -109,6 +145,22 @@
double
%{ $input = ($1_ltype)$1; %}
+%typemap(godirectorin) bool,
+ char,
+ signed char,
+ unsigned char,
+ short,
+ unsigned short,
+ int,
+ unsigned int,
+ long,
+ unsigned long,
+ long long,
+ unsigned long long,
+ float,
+ double
+""
+
%typemap(directorin) const bool &,
const char &,
const signed char &,
@@ -125,6 +177,22 @@
const double &
%{ $input = ($*1_ltype)$1; %}
+%typemap(godirectorin) const bool &,
+ const char &,
+ const signed char &,
+ const unsigned char &,
+ const short &,
+ const unsigned short &,
+ const int &,
+ const unsigned int &,
+ const long &,
+ const unsigned long &,
+ const long long &,
+ const unsigned long long &,
+ const float &,
+ const double &
+""
+
%typemap(directorout) bool,
char,
signed char,
@@ -141,7 +209,7 @@
double
%{ $result = ($1_ltype)$input; %}
-%typemap(directorout) const bool &,
+%typemap(directorout,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) const bool &,
const char &,
const signed char &,
const unsigned char &,
@@ -156,8 +224,8 @@
const float &,
const double &
%{
- $result = ($1_ltype)_swig_goallocate(sizeof($*1_ltype));
- *$result = *($1_ltype)&$input;
+ $result = new $*1_ltype($input);
+ swig_acquire_pointer(&swig_mem, $result);
%}
/* The size_t type. */
@@ -173,22 +241,30 @@
%typemap(out) size_t
%{ $result = $1; %}
+%typemap(goout) size_t ""
+
%typemap(out) const size_t &
%{ $result = ($*1_ltype)*$1; %}
+%typemap(goout) const size_t & ""
+
%typemap(directorin) size_t
%{ $input = (size_t)$1; %}
+%typemap(godirectorin) size_t ""
+
%typemap(directorin) const size_t &
%{ $input = ($*1_ltype)$1; %}
+%typemap(godirectorin) const size_t & ""
+
%typemap(directorout) size_t
%{ $result = ($1_ltype)$input; %}
-%typemap(directorout) const size_t &
+%typemap(directorout,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) const size_t &
%{
- $result = ($1_ltype)_swig_goallocate(sizeof($*1_ltype));
- *$result = *($1_ltype)$input;
+ $result = new $*1_ltype($input);
+ swig_acquire_pointer(&swig_mem, $result);
%}
/* Member pointers. */
@@ -201,17 +277,45 @@
%typemap(out) SWIGTYPE (CLASS::*)
%{
- $result = _swig_goallocate(sizeof($1_ltype));
- *($&1_ltype)$result = $1;
+ struct swig_out_type { intgo size; void* val; } *swig_out;
+ swig_out = (struct swig_out_type*)malloc(sizeof(*swig_out));
+ if (swig_out) {
+ swig_out->size = sizeof($1_ltype);
+ swig_out->val = malloc(swig_out->size);
+ if (swig_out->val) {
+ *($&1_ltype)(swig_out->val) = $1;
+ }
+ }
+ $result = swig_out;
+%}
+
+%typemap(goout) SWIGTYPE (CLASS::*)
+%{
+ {
+ type swig_out_type struct { size int; val uintptr }
+ p := (*swig_out_type)(unsafe.Pointer($1))
+ if p == nil || p.val == 0 {
+ $result = nil
+ } else {
+ m := make([]byte, p.size)
+ a := (*[1024]byte)(unsafe.Pointer(p.val))[:p.size]
+ copy(m, a)
+ Swig_free(p.val)
+ Swig_free(uintptr(unsafe.Pointer(p)))
+ $result = &m[0]
+ }
+ }
%}
%typemap(directorin) SWIGTYPE (CLASS::*)
%{ $input = *($&1_ltype)$1; %}
+%typemap(godirectorin) SWIGTYPE (CLASS::*) ""
+
%typemap(directorout) SWIGTYPE (CLASS::*)
%{
- $result = _swig_goallocate(sizeof($1_ltype));
- *($&1_ltype)$result = $input;
+ $result = new $1_ltype($input);
+ swig_acquire_pointer(&swig_mem, $result);
%}
/* Pointers. */
@@ -227,9 +331,13 @@
%typemap(out) SWIGTYPE *
%{ *($&1_ltype)&$result = ($1_ltype)$1; %}
+%typemap(goout) SWIGTYPE * ""
+
%typemap(directorin) SWIGTYPE *
%{ *($&1_ltype)&$input = ($1_ltype)$1; %}
+%typemap(godirectorin) SWIGTYPE * ""
+
%typemap(directorout) SWIGTYPE *
%{ $result = *($&1_ltype)&$input; %}
@@ -249,6 +357,8 @@
%typemap(out) SWIGTYPE *const&
%{ *($1_ltype)&$result = *$1; %}
+%typemap(goout) SWIGTYPE *const& ""
+
/* References. */
/* Converting a C++ reference to Go has to be handled in the C++
@@ -262,9 +372,13 @@
%typemap(out) SWIGTYPE &
%{ *($&1_ltype)&$result = $1; %}
+%typemap(goout) SWIGTYPE & ""
+
%typemap(directorin) SWIGTYPE &
%{ $input = ($1_ltype)&$1; %}
+%typemap(godirectorin) SWIGTYPE & ""
+
%typemap(directorout) SWIGTYPE &
%{ *($&1_ltype)&$result = $input; %}
@@ -277,9 +391,13 @@
%typemap(out) SWIGTYPE &&
%{ *($&1_ltype)&$result = $1; %}
+%typemap(goout) SWIGTYPE && ""
+
%typemap(directorin) SWIGTYPE &&
%{ $input = ($1_ltype)&$1_name; %}
+%typemap(godirectorin) SWIGTYPE && ""
+
%typemap(directorout) SWIGTYPE &&
%{ *($&1_ltype)&$result = $input; %}
@@ -295,9 +413,13 @@
%typemap(out) SWIGTYPE []
%{ *($&1_ltype)&$result = $1; %}
+%typemap(goout) SWIGTYPE [] ""
+
%typemap(directorin) SWIGTYPE []
%{ $input = *($1_ltype)&$1; %}
+%typemap(godirectorin) SWIGTYPE [] ""
+
%typemap(directorout) SWIGTYPE []
%{ *($&1_ltype)&$result = $input; %}
@@ -323,18 +445,32 @@
%typemap(in) char *&, signed char *&, unsigned char *&
%{ $1 = ($1_ltype)$input.p; %}
-%typemap(out)
+%typemap(out,fragment="AllocateString")
char *, char *&, char[ANY], char[],
signed char *, signed char *&, signed char[ANY], signed char[],
unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[]
-%{ $result = _swig_makegostring((char*)$1, $1 ? strlen((char*)$1) : 0); %}
+%{ $result = Swig_AllocateString((char*)$1, $1 ? strlen((char*)$1) : 0); %}
-%typemap(directorin)
+%typemap(goout,fragment="CopyString")
+ char *, char *&, char[ANY], char[],
+ signed char *, signed char *&, signed char[ANY], signed char[],
+ unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[]
+%{ $result = swigCopyString($1) %}
+
+%typemap(directorin,fragment="AllocateString")
char *, char *&, char[ANY], char[],
signed char *, signed char *&, signed char[ANY], signed char[],
unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[]
%{
- $input = _swig_makegostring((char*)$1, $1 ? strlen((char*)$1) : 0);
+ $input = Swig_AllocateString((char*)$1, $1 ? strlen((char*)$1) : 0);
+%}
+
+%typemap(godirectorin,fragment="CopyString")
+ char *, char *&, char[ANY], char[],
+ signed char *, signed char *&, signed char[ANY], signed char[],
+ unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[]
+%{
+ $result = swigCopyString($input)
%}
%typemap(directorout)
@@ -353,11 +489,17 @@
$2 = ($2_ltype)$input.n;
%}
-%typemap(out) (char *STRING, size_t LENGTH)
-%{ $result = _swig_makegostring((char*)$1, (size_t)$2); %}
+%typemap(out,fragment="AllocateString") (char *STRING, size_t LENGTH)
+%{ $result = Swig_AllocateString((char*)$1, (size_t)$2); %}
-%typemap(directorin) (char *STRING, size_t LENGTH)
-%{ $input = _swig_makegostring((char*)$1, $2); %}
+%typemap(goout,fragment="CopyString") (char *STRING, size_t LENGTH)
+%{ $result = swigCopyString($1) %}
+
+%typemap(directorin,fragment="AllocateString") (char *STRING, size_t LENGTH)
+%{ $input = Swig_AllocateString((char*)$1, $2); %}
+
+%typemap(godirectorin,fragment="CopyString") (char *STRING, size_t LENGTH)
+%{ $result = swigCopyString($input) %}
%typemap(directorout) (char *STRING, size_t LENGTH)
%{
@@ -378,8 +520,12 @@
%typemap(out) enum SWIGTYPE
%{ $result = (intgo)$1; %}
+%typemap(goout) enum SWIGTYPE ""
+
%typemap(directorin) enum SWIGTYPE
-%{ $input = ($1_ltype)$1; %}
+%{ $input = (intgo)$1; %}
+
+%typemap(godirectorin) enum SWIGTYPE ""
%typemap(directorout) enum SWIGTYPE
%{ $result = ($1_ltype)$input; %}
@@ -390,6 +536,8 @@
$input = &e;
%}
+%typemap(godirectorin) enum SWIGTYPE & ""
+
%typemap(directorout) enum SWIGTYPE &
%{
$*1_ltype f = ($*1_ltype)*$input;
@@ -423,9 +571,13 @@
}
#endif
+%typemap(goout) SWIGTYPE ""
+
%typemap(directorin) SWIGTYPE
%{ $input = ($&1_ltype)&$1; %}
+%typemap(godirectorin) SWIGTYPE ""
+
%typemap(directorout) SWIGTYPE
%{ $result = *($&1_ltype)$input; %}
diff --git a/Lib/go/goruntime.swg b/Lib/go/goruntime.swg
index ef64186b7..19ccf5ae9 100644
--- a/Lib/go/goruntime.swg
+++ b/Lib/go/goruntime.swg
@@ -4,6 +4,12 @@
* Go runtime code for the various generated files.
* ------------------------------------------------------------ */
+%inline %{
+static void Swig_free(void* p) {
+ free(p);
+}
+%}
+
%insert(runtime) %{
#include
#include
@@ -242,3 +248,72 @@ var Swig_escape_val interface{}
type _swig_fnptr *byte
type _swig_memberptr *byte
%}
+
+/* Handle memory management for directors. */
+
+%insert(director) %{
+#include