diff --git a/.gitignore b/.gitignore
index 3bf08798a..78b72338f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -122,6 +122,7 @@ 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
@@ -145,6 +146,9 @@ Examples/test-suite/octave/*.oct
*/__pycache__/
/__pycache__/
+# Scilab generated files
+loader.sce
+
# Go generated files
*.[5689]
*_gc.c
diff --git a/.travis.yml b/.travis.yml
index 3a726db3e..5e00eea8c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -52,6 +52,8 @@ matrix:
env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3
- compiler: gcc
env: SWIGLANG=ruby
+ - compiler: gcc
+ env: SWIGLANG=scilab
- compiler: gcc
env: SWIGLANG=tcl
allow_failures:
@@ -79,6 +81,7 @@ 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=(
@@ -95,6 +98,7 @@ before_install:
["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"
+ ["scilab"]="-Werror -std=gnu89 -fdiagnostics-show-option -pedantic -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"
@@ -110,6 +114,7 @@ before_install:
["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"
+ ["scilab"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
)
- $CC --version
- $CXX --version
@@ -133,3 +138,4 @@ script:
branches:
only:
- master
+ - gsoc2012-scilab
diff --git a/COPYRIGHT b/COPYRIGHT
index 1344630bb..4a26f5947 100644
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -11,57 +11,62 @@ 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)
- 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)
+ Vadim Zeitlin (PCRE)
+ 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/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/Scilab.html b/Doc/Manual/Scilab.html
new file mode 100644
index 000000000..b862afc57
--- /dev/null
+++ b/Doc/Manual/Scilab.html
@@ -0,0 +1,2002 @@
+
+
+
+SWIG and Scilab
+
+
+
+
+
+
+ 37 SWIG and Scilab
+
+
+
+
+
+
+
+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.
+
+
+
+ 37.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.
+
+
+
+ 37.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:
+
+
+
+%module example
+
+%inline %{
+double Foo = 3.0;
+
+int fact(int n) {
+ if (n < 0) {
+ return 0;
+ }
+ else if (n == 0) {
+ return 1;
+ }
+ else {
+ return n * fact(n-1);
+ }
+}
+%}
+
+
+
+Note: a code in an %inline section is both parsed and wrapped by SWIG, and inserted as is in the wrapper source file.
+
+
+
+ 37.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.
+
+
+
+ 37.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:
+
+
+
+$ gcc -fPIC -c -I/usr/local/include/scilab example_wrap.c
+$ gcc -shared example_wrap.o -o libexample.so
+
+
+
+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.
+
+
+ 37.2.3 Loading the module
+
+
+Loading a module is done by running the loader script in Scilab:
+
+
+
+
+
+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.
+
+
+ 37.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:
+
+
+--> Foo_get
+ans =
+
+ 3.
+
+--> Foo_set(4);
+
+--> Foo_get
+ans =
+
+ 4.
+
+
+
+Note: for conciseness, we assume in the subsequent Scilab code examples that the modules have been beforehand built and loaded in Scilab.
+
+
+ 37.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:
+
+
+
+
+
+ 37.3 A basic tour of C/C++ wrapping
+
+ 37.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.
+
+
+
37.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.
+
+
+
37.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.
+
+
+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.
+
+
+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.
+
+
+
+
+ 37.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:
+
+
+
+--> exec loader.sce;
+--> c = Foo_get();
+
+--> Foo_set(4);
+
+--> c
+c =
+
+ 3.
+
+--> Foo_get()
+ans =
+
+ 4.
+
+
+
+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;
+}
+%}
+
+
+
+It works the same:
+
+
+--> exec loader.sce
+
+--> initArrays();
+--> x_get()
+ ans =
+
+ 1. 1. 1. 1. 1. 1. 1. 1. 1. 1.
+
+--> y_set([0:6] / 10);
+--> y_get()
+ ans =
+
+ 0. 0.1 0.2 0.3 0.4 0.5 0.6
+
+
+
+ 37.3.5 Constants and enumerations
+
+ Constants
+
+
+There is not any constant in Scilab. By default, C/C++ constants are wrapped as getter functions. For example, for the following constants:
+
+
+
+%module example
+#define ICONST 42
+#define FCONST 2.1828
+#define CCONST 'x'
+#define CCONST2 '\n'
+#define SCONST "Hello World"
+#define SCONST2 "\"Hello World\""
+
+
+
+the following getter functions are generated:
+
+
+
+--> 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:
+
+
+
+%module example
+
+%scilabconst(1);
+#define ICONST 42
+#define FCONST 2.1828
+#define CCONST 'x'
+#define CCONST2 '\n'
+#define SCONST "Hello World"
+#define SCONST2 "\"Hello World\""
+
+
+
+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
+
+
+ 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.
+
+
+
+
+ 37.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:
+
+
+
+%module example
+
+%{
+#include <stdio.h>
+%}
+
+FILE *fopen(const char *filename, const char *mode);
+int fputs(const char *, FILE *);
+int fclose(FILE *);
+
+
+
+These functions can be used in a natural way from Scilab:
+
+
+
+--> f = fopen("junk", "w");
+--> typeof(f)
+ ans =
+
+ pointer
+
+--> fputs("Hello World", f);
+--> fclose(f);
+
+
+
+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).
+
+
+ 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);
+
+
+ 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
+
+
+
+ 37.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.
+
+
+
+
+Usage example:
+
+
+
+--> f = new_Foo();
+--> Foo_x_set(f, 100);
+--> Foo_x_get(f)
+ans =
+
+ 100.
+
+--> Foo_arr_set(f, [0:3]);
+--> Foo_arr_get(f)
+ans =
+
+ 0. 1. 2. 3.
+
+--> delete_Foo(f);
+
+
+
+
+Members of a structure that are also structures are also accepted and wrapped as a pointer:
+
+
+
+%module example
+
+%inline %{
+
+typedef struct {
+ int x;
+} Bar;
+
+typedef struct {
+ Bar b;
+} Foo;
+
+%}
+
+
+
+
+--> b = new_Bar();
+--> Bar_x_set(b, 20.);
+
+--> f = new_Foo();
+--> Foo_b_set(f, b);
+
+--> b2 = Foo_b_get(f);
+--> Bar_x_get(b2);
+ans =
+
+ 20.
+
+
+
+
+ 37.3.8 C++ Classes
+
+
+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.
+
+
+
+For example, the following class:
+
+
+
+%module example
+
+%inline %{
+
+class Point {
+public:
+ int x, y;
+ Point(int _x, int _y) : x(_x), y(_y) {}
+ double distance(const Point& rhs) {
+ return sqrt(pow(x-rhs.x, 2) + pow(y-rhs.y, 2));
+ }
+ void set(int _x, int _y) {
+ x=_x;
+ y=_y;
+ }
+};
+
+%}
+
+
+
+can be used in Scilab like this:
+
+
+
+--> p1 = Point_new(3, 5);
+--> p2 = Point_new(1, 2);
+--> p1.distance(p2)
+ans =
+
+ 3.6056
+
+--> delete_Point(p1);
+--> delete_Point(p2);
+
+
+ 37.3.9 C++ inheritance
+
+
+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 :
+
+
+
+%module example
+
+%inline %{
+
+class Shape {
+public:
+ double x, y;
+ void set_location(double _x, double _y) { x = _x; y = _y; }
+ virtual double get_perimeter() { return 0; };
+};
+
+class Circle : public Shape {
+public:
+ int radius;
+ Circle(int _radius): radius(_radius) {};
+ virtual double get_perimeter() { return 6.28 * radius; }
+};
+
+class Square : public Shape {
+public:
+ int size;
+ Square(int _size): size(_size) {};
+ virtual double get_perimeter() { return 4 * size; }
+};
+
+%}
+
+
+
+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
+
+
+ 37.3.10 Pointers, references, values, and arrays
+
+
+In C++ objects can be passed by value, pointer, reference, or by an array:
+
+
+%module example
+
+%{
+#include <sciprint.h>
+%}
+
+%inline %{
+
+class Foo {
+public:
+ Foo(int _x) : x(_x) {}
+ int x;
+};
+
+void spam1(Foo *f) { sciprint("%d\n", f->x); } // Pass by pointer
+void spam2(Foo &f) { sciprint("%d\n", f.x); } // Pass by reference
+void spam3(Foo f) { sciprint("%d\n", f.x); } // Pass by value
+void spam4(Foo f[]) { sciprint("%d\n", f[0].x); } // Array of objects
+
+%}
+
+
+
+In SWIG, there is no real distinction between these.
+So in Scilab, it is perfectly legal to do this:
+
+
+--> f = new_Foo()
+--> spam1(f)
+3
+--> spam2(f)
+3
+--> spam3(f)
+3
+--> spam4(f)
+3
+
+
+
+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.
+
+
+ 37.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.
+
+
+ 37.3.11 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() :
+
+
+
+%module example
+
+%rename(plus) operator +;
+%rename(toDouble) operator double();
+
+%inline %{
+
+class Complex {
+public:
+ Complex(double re, double im) : real(re), imag(im) {};
+
+ Complex operator+(const Complex& other) {
+ double result_real = real + other.real;
+ double result_imaginary = imag + other.imag;
+ return Complex(result_real, result_imaginary);
+ }
+ operator double() { return real; }
+private:
+ double real;
+ double imag;
+};
+
+%}
+
+
+
+
+--> c1 = new_Complex(3, 7);
+
+--> c2 = Complex_plus(c, new_Complex(1,1));
+
+--> Complex_toDouble(c2)
+ ans =
+
+ 4.
+
+
+
+
+ 34.3.12 C++ namespaces
+
+
+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 :
+
+
+
+
+%module example
+
+%inline %{
+
+namespace foo {
+ int fact(int n) {
+ if (n > 1)
+ return n * fact(n-1);
+ else
+ return 1;
+ }
+
+ struct Vector {
+ double x,y,z;
+ };
+};
+
+%}
+
+
+
+
+
+In Scilab, there is no need to the specify the Foo namespace:
+
+
+
+
+--> fact(3)
+ ans =
+
+ 6.
+
+--> v = new_Vector();
+--> Vector_x_set(v, 3.4);
+--> Vector_y_get(v)
+ ans =
+
+ 0.
+
+
+
+
+If your program has more than one namespace, name conflicts can be resolved using %rename .
+For example:
+
+
+
+
+%rename(Bar_spam) Bar::spam;
+
+namespace Foo {
+ int spam();
+}
+
+namespace Bar {
+ int spam();
+}
+
+
+
+
+Note: the nspace feature is not supported.
+
+
+
+ 37.3.13 C++ exceptions
+
+
+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 !";
+}
+%}
+
+
+
+
+-->throw_exception()
+ !--error 999
+SWIG/Scilab: Exception (char const *) occured: 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.");
+}
+%}
+
+
+
+
+--> throw_int();
+ !--error 999
+SWIG/Scilab: Exception (int) occured: 12
+
+-->throw_stl_invalid_arg(-1);
+ !--error 999
+SWIG/Scilab: ValueError: 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.
+
+
+
37.3.14 C++ STL
+
+
+The Standard Template Library (STL) is partially supported. See STL for more details.
+
+
+ 37.4 Type mappings and libraries
+
+ 37.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.
+
+
+
+
+
+ 37.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...
+
+
+
+ 37.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":"");
+ }
+}
+%}
+
+
+
+
+--> printArray([0 1 2 3], 4)
+[ 0 1 2 3 ]
+
+--> printArray([0.2; -1.8; 2; 3.7], 4)
+[ 0 -1 2 3 ]
+
+--> printArray([0 1; 2 3], 4)
+[ 0 2 1 3 ]
+
+--> printArray([0; 1; 2; 3], 4)
+[ 0 1 2 3 ]
+
+
+
+ 37.4.4 Pointer-to-pointers
+
+
+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");
+ }
+}
+
+%}
+
+
+
+ These functions are used like this in Scilab:
+
+
+
+--> m = create_matrix();
+
+--> print_matrix(m);
+ 1. 2.
+ 3. 4.
+
+--> set_matrix(m, 1, 1, 5.);
+
+--> get_matrix(m, 1, 1)
+ ans =
+
+ 5.
+
+
+
+ 37.4.5 Matrices
+
+
+The matrix.i library provides a set of typemaps which can be useful when working with one-dimensional and two-dimensional matrices.
+
+
+
+In order to use this library, just include it in the interface file:
+
+
+
+
+
+
+Several typemaps are available for the common Scilab matrix types:
+
+double
+int
+char *
+bool
+
+
+
+
+For example: for a matrix of int , we have the typemaps, for input:
+
+(int *IN, int IN_ROWCOUNT, int IN_COLCOUNT)
+(int IN_ROWCOUNT, int IN_COLCOUNT, int *IN)
+(int *IN, int IN_SIZE)
+(int IN_SIZE, int *IN)
+
+
+
+and output:
+
+(int **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+(int *OUT_ROWCOUNT, int *OUT_COLCOUNT, int **OUT)
+(int **OUT, int *OUT_SIZE)
+(int *OUT_SIZE, int **OUT)
+
+
+
+
+They marshall a Scilab matrix type into the appropriate 2 or 3 C parameters.
+The following is an example using the typemaps in this library:
+
+
+
+%module example
+
+%include <matrix.i>
+
+%apply (int *IN, int IN_ROWCOUNT, int IN_COLCOUNT) { (int *matrix, int matrixNbRow, int matrixNbCol) };
+%apply (int **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT) { (int **outMatrix, int *outMatrixNbRow, int *outMatrixNbCol) };
+
+%inline %{
+
+void absolute(int *matrix, int matrixNbRow, int matrixNbCol,
+ int **outMatrix, int *outMatrixNbRow, int *outMatrixNbCol) {
+ int i, j;
+ *outMatrixNbRow = matrixNbRow;
+ *outMatrixNbCol = matrixNbCol;
+ *outMatrix = malloc(matrixNbRow * matrixNbCol * sizeof(int));
+ for (i=0; i < matrixNbRow * matrixNbCol; i++) {
+ (*outMatrix)[i] = matrix[i] > 0 ? matrix[i]:-matrix[i];
+ }
+}
+
+%}
+
+
+
+
+--> absolute([-0 1 -2; 3 4 -5])
+ ans =
+
+ 0. 1. 2.
+ 3. 4. 5.
+
+
+
+
+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.
+
+
+
+ 37.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:
+
+
+
+
+Then for each container used, the appropriate template must be instantiated, in the std namespace:
+
+namespace std {
+ %template(IntVector) vector<int>;
+ %template(DoubleVector) vector<double>;
+}
+
+
+
+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:
+
+
+
+%module example
+
+%include <stl.i>
+
+namespace std {
+ %template(IntVector) vector<int>;
+}
+
+%{
+#include <numeric>
+%}
+
+%inline %{
+
+double average(std::vector<int> v) {
+ return std::accumulate(v.begin(), v.end(), 0.0) / v.size();
+}
+
+%}
+
+
+
+
+--> 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);
+
+
+
+
37.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 :
+
+
+
+
+ 37.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.
+
+
+ 37.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.
+
+
+
+ 37.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 )
+
+
+
+
+The command is:
+
+
+
+$ swig -scilab -builder -buildercflags -I/opt/foo/include -builderldflags "-L/opt/foo/lib -lfoo" -buildersources baa1.cxx,baa2.cxx example.i
+
+
+
+ 37.7 Generated scripts
+
+
+In this part we give some details about the generated Scilab scripts.
+
+
+ 37.7.1 Builder script
+
+
+builder.sce is the name of the builder script generated by SWIG in builder mode. It contains code like this:
+
+
+ilib_name = "examplelib";
+files = ["example_wrap.c"];
+libs = [];
+table = ["fact","_wrap_fact";"Foo_set","_wrap_Foo_set";"Foo_get","_wrap_Foo_get";];
+ilib_build(ilib_name,table,files,libs);
+
+
+
+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.
+files : string matrix containing objects files needed for shared library creation.
+libs : string matrix containing extra libraries needed for shared library creation.
+table : two column string matrix containing a table of pairs of 'scilab function name', 'C function name'.
+
+
+ 37.7.2 Loader script
+
+
+The loader script is used to load in Scilab all the module functions. When loaded, these functions can be used as other Scilab functions.
+
+
+
+The loader script loader.sce contains code similar to:
+
+
+
+// ------------------------------------------------------
+// generated by builder.sce: Please do not edit this file
+// ------------------------------------------------------
+
+libexamplelib_path = get_file_path('loader.sce');
+list_functions = [ 'fact';
+ 'Foo_set';
+ 'Foo_get';
+];
+addinter(libexamplelib_path+'/libexamplelib.so','libexamplelib',list_functions);
+// remove temp. variables on stack
+clear libexamplelib_path;
+clear list_functions;
+clear get_file_path;
+// ------------------------------------------------------
+
+
+
+addinter(files,spname,fcts) performs dynamic linking of a compiled C interface function.
+
+
+files : a character string or a vector of character strings defining the object files (containing the C interface functions) to link with.
+spname : a character string. Name of interface routine entry point.
+fcts : vector of character strings. The name of new Scilab function.
+
+
+
+ 37.8 Other resources
+
+
+Example use cases can be found in the Examples/scilab directory.
+The test suite in the Examples/test-suite/scilab can be another source of useful use cases.
+The Scilab API is used in the generated code and is a useful reference when examining the output.
+This guide describes the Scilab external modules structure and files, in particular the files that are generated by SWIG for Scilab.
+
+
diff --git a/Examples/Makefile.in b/Examples/Makefile.in
index 4ff380f73..6520f6e2b 100644
--- a/Examples/Makefile.in
+++ b/Examples/Makefile.in
@@ -1665,7 +1665,6 @@ endif
# ----------------------------------------------------------------
# Build a R dynamically loadable module (C++)
# ----------------------------------------------------------------
-
r_cpp: $(SRCDIR_CXXSRCS)
$(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACEPATH)
ifneq ($(SRCDIR_CXXSRCS),)
@@ -1697,6 +1696,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/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/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 742db540b..6376bc79d 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -308,6 +308,7 @@ CPP_TEST_CASES += \
operator_pointer_ref \
operbool \
ordering \
+ overload_arrays \
overload_bool \
overload_copy \
overload_extend \
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/director_frob.i b/Examples/test-suite/director_frob.i
index cf555eb66..9f7ae68f2 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
{
};
diff --git a/Examples/test-suite/enum_missing.i b/Examples/test-suite/enum_missing.i
index de71952e7..2684497fa 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;
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/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 76a3cba0a..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"
@@ -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_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_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/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 fe405479c..a8de84b49 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;
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/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..3bdd025ef 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)
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/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/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/scilab/boost_shared_ptr.i b/Lib/scilab/boost_shared_ptr.i
new file mode 100644
index 000000000..095b7fe43
--- /dev/null
+++ b/Lib/scilab/boost_shared_ptr.i
@@ -0,0 +1,318 @@
+%include
+
+// Set SHARED_PTR_DISOWN to $disown if required, for example
+// #define SHARED_PTR_DISOWN $disown
+#if !defined(SHARED_PTR_DISOWN)
+#define SHARED_PTR_DISOWN 0
+#endif
+
+// Language specific macro implementing all the customisations for handling the smart pointer
+%define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...)
+
+// %naturalvar is as documented for member variables
+%naturalvar TYPE;
+%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
+
+// destructor wrapper customisation
+%feature("unref") TYPE
+//"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n"
+ "(void)arg1; delete smartarg1;"
+
+// Typemap customisations...
+
+// plain value
+%typemap(in) CONST TYPE (void *argp, int res = 0) {
+ int newmem = 0;
+ res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (!argp) {
+ %argument_nullref("$type", $symname, $argnum);
+ } else {
+ $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get());
+ if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ }
+}
+%typemap(out) CONST TYPE {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1));
+ %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+}
+
+%typemap(varin) CONST TYPE {
+ void *argp = 0;
+ int newmem = 0;
+ int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %variable_fail(res, "$type", "$name");
+ }
+ if (!argp) {
+ %argument_nullref("$type", $symname, $argnum);
+ } else {
+ $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get());
+ if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ }
+}
+%typemap(varout) CONST TYPE {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1));
+ %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+}
+
+// plain pointer
+// Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance
+%typemap(in) CONST TYPE * (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) {
+ int newmem = 0;
+ res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (newmem & SWIG_CAST_NEW_MEMORY) {
+ tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ $1 = %const_cast(tempshared.get(), $1_ltype);
+ } else {
+ smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ $1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype);
+ }
+}
+
+%typemap(out, fragment="SWIG_null_deleter_python") CONST TYPE * {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0;
+ %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), $owner | SWIG_POINTER_OWN));
+}
+
+%typemap(varin) CONST TYPE * {
+ void *argp = 0;
+ int newmem = 0;
+ int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %variable_fail(res, "$type", "$name");
+ }
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared;
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0;
+ if (newmem & SWIG_CAST_NEW_MEMORY) {
+ tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ $1 = %const_cast(tempshared.get(), $1_ltype);
+ } else {
+ smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ $1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype);
+ }
+}
+%typemap(varout, fragment="SWIG_null_deleter_python") CONST TYPE * {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0;
+ %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+}
+
+// plain reference
+%typemap(in) CONST TYPE & (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) {
+ int newmem = 0;
+ res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (!argp) { %argument_nullref("$type", $symname, $argnum); }
+ if (newmem & SWIG_CAST_NEW_MEMORY) {
+ tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ $1 = %const_cast(tempshared.get(), $1_ltype);
+ } else {
+ $1 = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype);
+ }
+}
+%typemap(out, fragment="SWIG_null_deleter_python") CONST TYPE & {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner);
+ %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+}
+
+%typemap(varin) CONST TYPE & {
+ void *argp = 0;
+ int newmem = 0;
+ int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %variable_fail(res, "$type", "$name");
+ }
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared;
+ if (!argp) { %argument_nullref("$type", $symname, $argnum); }
+ if (newmem & SWIG_CAST_NEW_MEMORY) {
+ tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ $1 = *%const_cast(tempshared.get(), $1_ltype);
+ } else {
+ $1 = *%const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype);
+ }
+}
+%typemap(varout, fragment="SWIG_null_deleter_python") CONST TYPE & {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(&$1 SWIG_NO_NULL_DELETER_0);
+ %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+}
+
+// plain pointer by reference
+// Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance
+%typemap(in) TYPE *CONST& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) {
+ int newmem = 0;
+ res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (newmem & SWIG_CAST_NEW_MEMORY) {
+ tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ temp = %const_cast(tempshared.get(), $*1_ltype);
+ } else {
+ temp = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $*1_ltype);
+ }
+ $1 = &temp;
+}
+%typemap(out, fragment="SWIG_null_deleter_python") TYPE *CONST& {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner);
+ %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+}
+
+%typemap(varin) TYPE *CONST& %{
+#error "varin typemap not implemented"
+%}
+%typemap(varout) TYPE *CONST& %{
+#error "varout typemap not implemented"
+%}
+
+// shared_ptr by value
+%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (void *argp, int res = 0) {
+ int newmem = 0;
+ res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (argp) $1 = *(%reinterpret_cast(argp, $<ype));
+ if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype);
+}
+%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0;
+ %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+}
+
+%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
+ int newmem = 0;
+ void *argp = 0;
+ int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %variable_fail(res, "$type", "$name");
+ }
+ $1 = argp ? *(%reinterpret_cast(argp, $<ype)) : SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE >();
+ if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype);
+}
+%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0;
+ %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+}
+
+// shared_ptr by reference
+%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & (void *argp, int res = 0, $*1_ltype tempshared) {
+ int newmem = 0;
+ res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (newmem & SWIG_CAST_NEW_MEMORY) {
+ if (argp) tempshared = *%reinterpret_cast(argp, $ltype);
+ delete %reinterpret_cast(argp, $ltype);
+ $1 = &tempshared;
+ } else {
+ $1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared;
+ }
+}
+%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0;
+ %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+}
+
+%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{
+#error "varin typemap not implemented"
+%}
+%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{
+#error "varout typemap not implemented"
+%}
+
+// shared_ptr by pointer
+%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * (void *argp, int res = 0, $*1_ltype tempshared) {
+ int newmem = 0;
+ res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (newmem & SWIG_CAST_NEW_MEMORY) {
+ if (argp) tempshared = *%reinterpret_cast(argp, $ltype);
+ delete %reinterpret_cast(argp, $ltype);
+ $1 = &tempshared;
+ } else {
+ $1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared;
+ }
+}
+%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 && *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0;
+ %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+ if ($owner) delete $1;
+}
+
+%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{
+#error "varin typemap not implemented"
+%}
+%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{
+#error "varout typemap not implemented"
+%}
+
+// shared_ptr by pointer reference
+%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (void *argp, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, $*1_ltype temp = 0) {
+ int newmem = 0;
+ res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (argp) tempshared = *%reinterpret_cast(argp, $*ltype);
+ if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $*ltype);
+ temp = &tempshared;
+ $1 = &temp;
+}
+%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 && **$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0;
+ %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+}
+
+%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{
+#error "varin typemap not implemented"
+%}
+%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{
+#error "varout typemap not implemented"
+%}
+
+// Typecheck typemaps
+// Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting
+// function is not called thereby avoiding a possible smart pointer copy constructor call when casting up the inheritance chain.
+%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1)
+ TYPE CONST,
+ TYPE CONST &,
+ TYPE CONST *,
+ TYPE *CONST&,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& {
+ int res = SWIG_ConvertPtr($input, 0, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), 0);
+ $1 = SWIG_CheckState(res);
+}
+
+
+// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug
+%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
+#error "typemaps for $1_type not available"
+%}
+%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
+#error "typemaps for $1_type not available"
+%}
+
+
+%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
+
+
+%enddef
+
diff --git a/Lib/scilab/carrays.i b/Lib/scilab/carrays.i
new file mode 100644
index 000000000..014de37ff
--- /dev/null
+++ b/Lib/scilab/carrays.i
@@ -0,0 +1,5 @@
+%define %array_class(TYPE,NAME)
+ %array_class_wrap(TYPE,NAME,__paren__,__paren_asgn__)
+%enddef
+
+%include
diff --git a/Lib/scilab/cmalloc.i b/Lib/scilab/cmalloc.i
new file mode 100644
index 000000000..248f06b96
--- /dev/null
+++ b/Lib/scilab/cmalloc.i
@@ -0,0 +1 @@
+%include
diff --git a/Lib/scilab/cpointer.i b/Lib/scilab/cpointer.i
new file mode 100644
index 000000000..d824792fa
--- /dev/null
+++ b/Lib/scilab/cpointer.i
@@ -0,0 +1 @@
+%include
diff --git a/Lib/scilab/exception.i b/Lib/scilab/exception.i
new file mode 100644
index 000000000..17f4175c4
--- /dev/null
+++ b/Lib/scilab/exception.i
@@ -0,0 +1,6 @@
+%include
+
+
+%insert("runtime") {
+ %define_as(SWIG_exception(code, msg), SWIG_Scilab_Error(code, msg);)
+}
diff --git a/Lib/scilab/matrix.i b/Lib/scilab/matrix.i
new file mode 100644
index 000000000..0936d9365
--- /dev/null
+++ b/Lib/scilab/matrix.i
@@ -0,0 +1,11 @@
+/*
+ * Matrix typemaps
+ *
+ */
+
+%include
+%include
+%include
+%include
+
+
diff --git a/Lib/scilab/sciarray.swg b/Lib/scilab/sciarray.swg
new file mode 100644
index 000000000..c00e3837e
--- /dev/null
+++ b/Lib/scilab/sciarray.swg
@@ -0,0 +1,115 @@
+/* --------------------------------------------------------------------------
+ *
+ * Arrays typemaps
+ *
+ * --------------------------------------------------------------------------*/
+
+%{
+#include
+%}
+
+%define %scilab_asarray_withallocatecopy(TYPEMAPTYPE, FRAGMENTNAME, CTYPE, TEMPDATATYPE)
+%typemap(TYPEMAPTYPE, fragment="FRAGMENTNAME") CTYPE {
+ size_t i = 0;
+ int iRows = 0;
+ int iCols = 0;
+ TEMPDATATYPE *pTempData = NULL;
+ if (FRAGMENTNAME(pvApiCtx, $input, &iRows, &iCols, &pTempData, fname)) {
+ return SWIG_ERROR;
+ }
+ $1 = ($1_ltype)MALLOC(sizeof($*1_ltype) * iRows * iCols);
+ for (i = 0; i < iRows * iCols; i++) {
+ $1[i] = ($*1_ltype) pTempData[i];
+ }
+}
+%enddef
+
+%define %scilab_asarrayandsize_withcopy(TYPEMAPTYPE, FRAGMENTNAME, CTYPE, TEMPDATATYPE)
+%typemap(TYPEMAPTYPE, fragment="FRAGMENTNAME") CTYPE {
+ int iRows = 0;
+ int iCols = 0;
+ TEMPDATATYPE *pTempData = NULL;
+ if (FRAGMENTNAME(pvApiCtx, $input, &iRows, &iCols, &pTempData, fname)) {
+ return SWIG_ERROR;
+ }
+ if (iRows*iCols <= $1_dim0) {
+ size_t i;
+ for (i = 0; i < $1_dim0; i++) {
+ $1[i] = ($*1_ltype) pTempData[i];
+ }
+ }
+ else {
+ char errmsg[100];
+ sprintf(errmsg, "Size of input data (%d) is too big (maximum is %d)",
+ iRows*iCols, $1_dim0);
+ SWIG_exception_fail(SWIG_OverflowError, errmsg);
+ }
+}
+%enddef
+
+%define %scilab_fromarrayandsize(TYPEMAPTYPE, FRAGMENTNAME, CTYPE)
+%typemap(TYPEMAPTYPE, noblock=1, fragment="FRAGMENTNAME") CTYPE {
+ %set_output(FRAGMENTNAME(pvApiCtx, $result, 1, $1_dim0, $1));
+}
+%enddef
+
+%define %scilab_array_typemaps(CTYPE, ASARRAY_FRAGMENT, FROMARRAY_FRAGMENT, TEMPDATATYPE)
+ %scilab_asarrayandsize_withcopy(varin, ASARRAY_FRAGMENT, CTYPE[ANY], TEMPDATATYPE);
+ %scilab_asarray_withallocatecopy(in, ASARRAY_FRAGMENT, CTYPE[ANY], TEMPDATATYPE);
+ %scilab_fromarrayandsize(varout, FROMARRAY_FRAGMENT, CTYPE[ANY]);
+ %scilab_fromarrayandsize(out, FROMARRAY_FRAGMENT, CTYPE[ANY]);
+
+ %apply SWIGTYPE[] { CTYPE[] };
+ %scilab_asarray_withallocatecopy(in, ASARRAY_FRAGMENT, CTYPE[], TEMPDATATYPE);
+%enddef
+
+
+// Double
+%scilab_array_typemaps(double, SWIG_SciDouble_AsDoubleArrayAndSize,
+ SWIG_SciDouble_FromDoubleArrayAndSize, double);
+
+// Signed char
+
+%scilab_array_typemaps(signed char, SWIG_SciDoubleOrInt8_AsSignedCharArrayAndSize,
+ SWIG_SciDouble_FromSignedCharArrayAndSize, signed char);
+
+// Unsigned char
+%scilab_array_typemaps(unsigned char, SWIG_SciDoubleOrUint8_AsUnsignedCharArrayAndSize,
+ SWIG_SciDouble_FromUnsignedCharArrayAndSize, unsigned char);
+
+// Short
+%scilab_array_typemaps(short, SWIG_SciDoubleOrInt16_AsShortArrayAndSize,
+ SWIG_SciDouble_FromShortArrayAndSize, short);
+
+// Unsigned short
+%scilab_array_typemaps(unsigned short, SWIG_SciDoubleOrUint16_AsUnsignedShortArrayAndSize,
+ SWIG_SciDouble_FromUnsignedShortArrayAndSize, unsigned short);
+
+// Int
+%scilab_array_typemaps(int, SWIG_SciDoubleOrInt32_AsIntArrayAndSize,
+ SWIG_SciDouble_FromIntArrayAndSize, int);
+
+// Unsigned int
+%scilab_array_typemaps(unsigned int, SWIG_SciDoubleOrUint32_AsUnsignedIntArrayAndSize,
+ SWIG_SciDouble_FromUnsignedIntArrayAndSize, unsigned int);
+
+// Long
+%scilab_array_typemaps(long, SWIG_SciDoubleOrInt32_AsIntArrayAndSize,
+ SWIG_SciDouble_FromLongArrayAndSize, int);
+
+// Unsigned long
+%scilab_array_typemaps(unsigned long, SWIG_SciDoubleOrUint32_AsUnsignedIntArrayAndSize,
+ SWIG_SciDouble_FromUnsignedLongArrayAndSize, unsigned int);
+
+// Float
+%scilab_array_typemaps(float, SWIG_SciDouble_AsFloatArrayAndSize,
+ SWIG_SciDouble_FromFloatArrayAndSize, float);
+
+// Bool
+%scilab_array_typemaps(bool, SWIG_SciBoolean_AsIntArrayAndSize,
+ SWIG_SciBoolean_FromBoolArrayAndSize, int);
+
+// Char *
+%scilab_array_typemaps(char *, SWIG_SciString_AsCharPtrArrayAndSize,
+ SWIG_SciString_FromCharPtrArrayAndSize, char *);
+
diff --git a/Lib/scilab/scibool.swg b/Lib/scilab/scibool.swg
new file mode 100644
index 000000000..ea7938dc8
--- /dev/null
+++ b/Lib/scilab/scibool.swg
@@ -0,0 +1,157 @@
+/*
+ * C-type: bool
+ * Scilab type: boolean scalar
+ */
+%fragment(SWIG_AsVal_frag(bool), "header") {
+SWIGINTERN int
+SWIG_AsVal_dec(bool)(SwigSciObject iVar, bool *pbValue) {
+ SciErr sciErr;
+ int iRet = 0;
+ int *piAddrVar = NULL;
+ int iTempValue = 0;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (!isBooleanType(pvApiCtx, piAddrVar)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A boolean expected.\n"), SWIG_Scilab_GetFuncName(), iVar);
+ return SWIG_ERROR;
+ }
+
+ if (!isScalar(pvApiCtx, piAddrVar)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A boolean expected.\n"), SWIG_Scilab_GetFuncName(), iVar);
+ return SWIG_ERROR;
+ }
+
+ iRet = getScalarBoolean(pvApiCtx, piAddrVar, &iTempValue);
+ if (iRet) {
+ return SWIG_ERROR;
+ }
+
+ *pbValue = iTempValue;
+
+ return SWIG_OK;
+}
+}
+
+%fragment(SWIG_From_frag(bool), "header") {
+SWIGINTERN int
+SWIG_From_dec(bool)(bool bValue) {
+ if (createScalarBoolean(pvApiCtx, SWIG_NbInputArgument(pvApiCtx)
+ + SWIG_Scilab_GetOutputPosition(), bValue))
+ return SWIG_ERROR;
+ return SWIG_OK;
+}
+}
+
+/*
+ * C-type: bool[]
+ * Scilab type: boolean matrix
+ */
+%fragment("SWIG_SciBoolean_AsBoolArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciBoolean_AsBoolArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, bool **pbValue, char *fname) {
+ SciErr sciErr;
+ int *piAddrVar = NULL;
+ int *piValue = NULL;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (isBooleanType(pvApiCtx, piAddrVar)) {
+ int i;
+ sciErr = getMatrixOfBoolean(pvApiCtx, piAddrVar, iRows, iCols, &piValue);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ *pbValue = (bool*) malloc((*iRows) * (*iCols) * sizeof(bool));
+ for (i = 0; i < (*iRows) * (*iCols); i++)
+ (*pbValue)[i] = piValue[i] != 0;
+ }
+ else {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A boolean matrix expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+
+ return SWIG_OK;
+}
+}
+
+%fragment("SWIG_SciBoolean_FromBoolArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciBoolean_FromBoolArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, bool *pbValue) {
+ SciErr sciErr;
+ int *piValue = NULL;
+ int i;
+
+ piValue = (int*) malloc(iRows * iCols * sizeof(int));
+ for (i = 0; i < iRows * iCols; i++)
+ piValue[i] = pbValue[i];
+
+ sciErr = createMatrixOfBoolean(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, piValue);
+ if(sciErr.iErr) {
+ printError(&sciErr, 0);
+ free(piValue);
+ return SWIG_ERROR;
+ }
+
+ free(piValue);
+ return SWIG_OK;
+}
+}
+
+/*
+ * C-type: int[]
+ * Scilab type: boolean matrix
+ */
+%fragment("SWIG_SciBoolean_AsIntArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciBoolean_AsIntArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, int **piValue, char *fname) {
+ SciErr sciErr;
+ int *piAddrVar = NULL;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (isBooleanType(pvApiCtx, piAddrVar)) {
+ int i;
+ sciErr = getMatrixOfBoolean(pvApiCtx, piAddrVar, iRows, iCols, piValue);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ }
+ else {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A boolean matrix expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+
+ return SWIG_OK;
+}
+}
+
+%fragment("SWIG_SciBoolean_FromIntArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciBoolean_FromIntArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, int *piValue) {
+ SciErr sciErr;
+
+ sciErr = createMatrixOfBoolean(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, piValue);
+ if(sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ return SWIG_OK;
+}
+}
diff --git a/Lib/scilab/scichar.swg b/Lib/scilab/scichar.swg
new file mode 100644
index 000000000..509a40c18
--- /dev/null
+++ b/Lib/scilab/scichar.swg
@@ -0,0 +1,285 @@
+/*
+ * C-type: char or char*
+ * Scilab type: string
+ */
+
+/*
+ * CHAR
+ */
+
+%fragment(SWIG_AsVal_frag(char), "header", fragment="SWIG_SciString_AsChar") {
+#define SWIG_AsVal_char(scilabValue, valuePointer) SWIG_SciString_AsChar(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_SciString_AsChar", "header") {
+SWIGINTERN int
+SWIG_SciString_AsChar(void *pvApiCtx, int iVar, char *pcValue, char *fname) {
+ SciErr sciErr;
+ int iType = 0;
+ int iRows = 0;
+ int iCols = 0;
+ int *piAddrVar = NULL;
+ char *pstStrings = NULL;
+ int piLength = 0;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iType != sci_strings) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A string expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+
+ pstStrings = (char *)malloc(sizeof(char));
+ sciErr = getMatrixOfString(pvApiCtx, piAddrVar, &iRows, &iCols, &piLength, (char **)&pstStrings);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iRows * iCols != 1) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A string expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+ *pcValue = pstStrings[0];
+
+ free(pstStrings);
+
+ return SWIG_OK;
+}
+}
+
+%fragment(SWIG_From_frag(char), "header", fragment="SWIG_SciString_FromChar") {
+#define SWIG_From_char(value) SWIG_SciString_FromChar(pvApiCtx, SWIG_Scilab_GetOutputPosition(), value)
+}
+%fragment("SWIG_SciString_FromChar", "header") {
+SWIGINTERN int
+SWIG_SciString_FromChar(void *pvApiCtx, int iVarOut, char chValue) {
+ char *pchValue = (char*)malloc(sizeof(char) * 2);
+ pchValue[0] = chValue;
+ pchValue[1] = '\0';
+
+ if (createSingleString(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, pchValue))
+ return SWIG_ERROR;
+
+ free(pchValue);
+ return SWIG_OK;
+}
+}
+
+/*
+ * CHAR *
+*/
+
+%fragment("SWIG_AsCharArray", "header", fragment = "SWIG_SciString_AsCharPtr") {
+#define SWIG_AsCharArray(scilabValue, charPtrPointer, charPtrLength) SWIG_SciString_AsCharPtr(pvApiCtx, scilabValue, charPtrPointer, charPtrLength, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_SciString_AsCharPtr", "header") {
+SWIGINTERN int
+SWIG_SciString_AsCharPtr(void *pvApiCtx, int iVar, char *pcValue, int iLength, char *fname) {
+ SciErr sciErr;
+ int *piAddrVar = NULL;
+ char* pcTmpValue = NULL;
+ int iRet;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ iRet = getAllocatedSingleString(pvApiCtx, piAddrVar, &pcTmpValue);
+ if (iRet) {
+ return SWIG_ERROR;
+ }
+
+ if (pcValue != NULL) {
+ strncpy(pcValue, pcTmpValue, iLength);
+ }
+
+ free(pcTmpValue);
+
+ return SWIG_OK;
+}
+}
+
+%fragment("SWIG_AsCharPtrAndSize", "header", fragment = "SWIG_SciString_AsCharPtrAndSize") {
+#define SWIG_AsCharPtrAndSize(scilabValue, charPtrPointer, charPtrLength, allocMemory) SWIG_SciString_AsCharPtrAndSize(pvApiCtx, scilabValue, charPtrPointer, charPtrLength, allocMemory, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_SciString_AsCharPtrAndSize", "header") {
+SWIGINTERN int
+SWIG_SciString_AsCharPtrAndSize(void *pvApiCtx, int iVar, char **pcValue, size_t *piLength, int *alloc, char *fname) {
+ SciErr sciErr;
+ int *piAddrVar = NULL;
+ int iRet;
+ char *pstStrings = NULL;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ iRet = getAllocatedSingleString(pvApiCtx, piAddrVar, &pstStrings);
+ if (iRet) {
+ return SWIG_ERROR;
+ }
+
+ // TODO: return SWIG_ERROR if pcValue NULL (now returning SWIG_ERROR fails some typechecks)
+ if (pcValue) {
+ *pcValue = pstStrings;
+ }
+
+ if (alloc != NULL) {
+ *alloc = SWIG_NEWOBJ;
+ }
+
+ if (piLength != NULL) {
+ *piLength = strlen(*pcValue);
+ }
+
+ return SWIG_OK;
+}
+}
+
+%fragment("SWIG_FromCharPtr", "header", fragment = "SWIG_SciString_FromCharPtr") {
+#define SWIG_FromCharPtr(charPtr) SWIG_SciString_FromCharPtr(pvApiCtx, SWIG_Scilab_GetOutputPosition(), charPtr)
+}
+%fragment("SWIG_SciString_FromCharPtr", "header") {
+SWIGINTERN int
+SWIG_SciString_FromCharPtr(void *pvApiCtx, int iVarOut, const char *pchValue) {
+ if (pchValue) {
+ SciErr sciErr;
+ const char* pstStrings[1];
+ pstStrings[0] = pchValue;
+
+ sciErr = createMatrixOfString(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, 1, 1, pstStrings);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ }
+ else {
+ int iRet = createEmptyMatrix(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut);
+ if (iRet) {
+ return SWIG_ERROR;
+ }
+ }
+
+ return SWIG_OK;
+}
+}
+
+/*
+ * CHAR * ARRAY
+ */
+
+%fragment("SWIG_SciString_AsCharPtrArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciString_AsCharPtrArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, char ***charPtrArray, char *fname) {
+ SciErr sciErr;
+ int i = 0;
+ int *piAddrVar = NULL;
+ int* piLength = NULL;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getMatrixOfString(pvApiCtx, piAddrVar, iRows, iCols, NULL, NULL);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ piLength = (int*) malloc((*iRows) * (*iCols) * sizeof(int));
+
+ sciErr = getMatrixOfString(pvApiCtx, piAddrVar, iRows, iCols, piLength, NULL);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ *charPtrArray = (char**) malloc((*iRows) * (*iCols) * sizeof(char*));
+ for(i = 0 ; i < (*iRows) * (*iCols); i++) {
+ (*charPtrArray)[i] = (char*) malloc(sizeof(char) * (piLength[i] + 1));
+ }
+
+ sciErr = getMatrixOfString(pvApiCtx, piAddrVar, iRows, iCols, piLength, *charPtrArray);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ free(piLength);
+ return SWIG_OK;
+}
+}
+
+%fragment("SWIG_SciString_FromCharPtrArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciString_FromCharPtrArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, char **charPtrArray) {
+ SciErr sciErr;
+
+ sciErr = createMatrixOfString(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, (const char* const*) charPtrArray);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ return SWIG_OK;
+}
+}
+
+%fragment("SWIG_FromCharPtrAndSize", "header", fragment = "SWIG_SciString_FromCharPtr") {
+#define SWIG_FromCharPtrAndSize(charPtr, charPtrLength) SWIG_SciString_FromCharPtr(pvApiCtx, SWIG_Scilab_GetOutputPosition(), charPtr)
+}
+
+
+/*
+ * Char* Scilab variable
+ */
+
+%fragment(SWIG_CreateScilabVariable_frag(char), "wrapper") {
+SWIGINTERN int
+SWIG_CreateScilabVariable_dec(char)(void *pvApiCtx, const char* psVariableName, const char cVariableValue) {
+ SciErr sciErr;
+ char sValue[2];
+ const char* psStrings[1];
+
+ sValue[0] = cVariableValue;
+ sValue[1] = '\0';
+ psStrings[0] = sValue;
+
+ sciErr = createNamedMatrixOfString(pvApiCtx, psVariableName, 1, 1, psStrings);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ return SWIG_OK;
+}
+}
+
+%fragment(SWIG_CreateScilabVariable_frag(charptr), "wrapper") {
+SWIGINTERN int
+SWIG_CreateScilabVariable_dec(charptr)(void *pvApiCtx, const char* psVariableName, const char* psVariableValue) {
+ SciErr sciErr;
+ const char* psStrings[1];
+ psStrings[0] = psVariableValue;
+
+ sciErr = createNamedMatrixOfString(pvApiCtx, psVariableName, 1, 1, psStrings);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ return SWIG_OK;
+}
+}
diff --git a/Lib/scilab/scicontainer.swg b/Lib/scilab/scicontainer.swg
new file mode 100644
index 000000000..529d27888
--- /dev/null
+++ b/Lib/scilab/scicontainer.swg
@@ -0,0 +1,445 @@
+/* -----------------------------------------------------------------------------
+ * scicontainer.swg
+ *
+ * Scilab list <-> C++ container wrapper
+ *
+ * This wrapper, and its iterator, allows a general use (and reuse) of
+ * the mapping between C++ and Scilab, thanks to the C++ templates.
+ *
+ * Of course, it needs the C++ compiler to support templates, but
+ * since we will use this wrapper with the STL containers, that should
+ * be the case.
+ * ----------------------------------------------------------------------------- */
+
+%{
+#include
+%}
+
+#if !defined(SWIG_NO_EXPORT_ITERATOR_METHODS)
+# if !defined(SWIG_EXPORT_ITERATOR_METHODS)
+# define SWIG_EXPORT_ITERATOR_METHODS SWIG_EXPORT_ITERATOR_METHODS
+# endif
+#endif
+
+
+// #define (SWIG_SCILAB_EXTRA_NATIVE_CONTAINERS)
+// if defined: sequences in return are converted from/to Scilab lists or matrices
+// if not defined: sequences are passed from/to Scilab as pointers
+
+%{
+#define SWIG_STD_NOASSIGN_STL
+%}
+
+%include
+%include
+
+%{
+#include
+%}
+
+%include
+%include
+
+%fragment("SciSequence_Cont", "header",
+ fragment="StdTraits",
+ fragment="SwigSciIterator_T")
+{
+namespace swig
+{
+ template
+ struct SciSequence_Ref
+ {
+ SciSequence_Ref(const SwigSciObject& seq, int index)
+ : _seq(seq), _index(index)
+ {
+ if (traits_as_sequence::get(_seq, &piSeqAddr) != SWIG_OK)
+ {
+ throw std::invalid_argument("Cannot get sequence data.");
+ }
+ }
+
+ operator T () const
+ {
+ try
+ {
+ return traits_asval_sequenceitem::asval(_seq, piSeqAddr, _index);
+ }
+ catch (std::exception& e)
+ {
+ SWIG_exception(SWIG_RuntimeError, e.what());
+ }
+ }
+
+ SciSequence_Ref& operator=(const T& v)
+ {
+ // TODO
+ return *this;
+ }
+
+ private:
+ SwigSciObject _seq;
+ int _index;
+ void *piSeqAddr;
+ };
+
+
+ template
+ struct SciSequence_ArrowProxy
+ {
+ SciSequence_ArrowProxy(const T& x): m_value(x) {}
+ const T* operator->() const { return &m_value; }
+ operator const T*() const { return &m_value; }
+ T m_value;
+ };
+
+ template
+ struct SwigSciSequence_InputIterator
+ {
+ typedef SwigSciSequence_InputIterator self;
+
+ typedef std::random_access_iterator_tag iterator_category;
+ typedef Reference reference;
+ typedef T value_type;
+ typedef T* pointer;
+ typedef int difference_type;
+
+ SwigSciSequence_InputIterator()
+ {
+ }
+
+ SwigSciSequence_InputIterator(const SwigSciObject& seq, int index)
+ : _seq(seq), _index(index)
+ {
+ }
+
+ reference operator*() const
+ {
+ return reference(_seq, _index);
+ }
+
+ SciSequence_ArrowProxy
+ operator->() const {
+ return SciSequence_ArrowProxy(operator*());
+ }
+
+ bool operator==(const self& ri) const
+ {
+ return (_index == ri._index);
+ }
+
+ bool operator!=(const self& ri) const
+ {
+ return !(operator==(ri));
+ }
+
+ self& operator ++ ()
+ {
+ ++_index;
+ return *this;
+ }
+
+ self& operator -- ()
+ {
+ --_index;
+ return *this;
+ }
+
+ self& operator += (difference_type n)
+ {
+ _index += n;
+ return *this;
+ }
+
+ self operator +(difference_type n) const
+ {
+ return self(_seq, _index + n);
+ }
+
+ self& operator -= (difference_type n)
+ {
+ _index -= n;
+ return *this;
+ }
+
+ self operator -(difference_type n) const
+ {
+ return self(_seq, _index - n);
+ }
+
+ difference_type operator - (const self& ri) const
+ {
+ return _index - ri._index;
+ }
+
+ bool operator < (const self& ri) const
+ {
+ return _index < ri._index;
+ }
+
+ reference
+ operator[](difference_type n) const
+ {
+ return reference(_seq, _index + n);
+ }
+
+ private:
+ SwigSciObject _seq;
+ difference_type _index;
+ };
+
+ template
+ struct SciSequence_Cont
+ {
+ typedef SciSequence_Ref reference;
+ typedef const SciSequence_Ref const_reference;
+ typedef T value_type;
+ typedef T* pointer;
+ typedef int difference_type;
+ typedef int size_type;
+ typedef const pointer const_pointer;
+ typedef SwigSciSequence_InputIterator iterator;
+ typedef SwigSciSequence_InputIterator const_iterator;
+
+ SciSequence_Cont(const SwigSciObject& seq) : _seq(seq)
+ {
+ }
+
+ ~SciSequence_Cont()
+ {
+ }
+
+ size_type size() const
+ {
+ int iSeqSize;
+ if (traits_as_sequence::size(_seq, &iSeqSize) == SWIG_OK)
+ {
+ return iSeqSize;
+ }
+ else
+ {
+ return SWIG_ERROR;
+ }
+ }
+
+ bool empty() const
+ {
+ return size() == 0;
+ }
+
+ iterator begin()
+ {
+ return iterator(_seq, 0);
+ }
+
+ const_iterator begin() const
+ {
+ return const_iterator(_seq, 0);
+ }
+
+ iterator end()
+ {
+ return iterator(_seq, size());
+ }
+
+ const_iterator end() const
+ {
+ return const_iterator(_seq, size());
+ }
+
+ reference operator[](difference_type n)
+ {
+ return reference(_seq, n);
+ }
+
+ const_reference operator[](difference_type n) const
+ {
+ return const_reference(_seq, n);
+ }
+
+ private:
+ SwigSciObject _seq;
+ };
+}
+}
+
+%define %swig_sequence_iterator(Sequence...)
+#if defined(SWIG_EXPORT_ITERATOR_METHODS)
+ class iterator;
+ class reverse_iterator;
+ class const_iterator;
+ class const_reverse_iterator;
+
+ %typemap(out,noblock=1,fragment="SciSequence_Cont")
+ iterator, reverse_iterator, const_iterator, const_reverse_iterator {
+ %set_output(SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &)),
+ swig::SciSwigIterator::descriptor(),SWIG_POINTER_OWN));
+ }
+ %typemap(out,fragment="SciSequence_Cont")
+ std::pair, std::pair {
+ // TODO: return a Scilab list from the pair (see code for Octave)
+ }
+
+ %fragment("SciSwigPairBoolOutputIterator", "header",
+ fragment=SWIG_From_frag(bool), fragment="SciSequence_Cont") {}
+
+ %typemap(out,fragment="SciSwigPairBoolOutputIterator")
+ std::pair, std::pair {
+ // TODO: return a Scilab list from the pair (see code for Octave)
+ }
+
+ %typemap(in,noblock=1,fragment="SciSequence_Cont")
+ iterator(swig::SciSwigIterator *iter = 0, int res),
+ reverse_iterator(swig::SciSwigIterator *iter = 0, int res),
+ const_iterator(swig::SciSwigIterator *iter = 0, int res),
+ const_reverse_iterator(swig::SciSwigIterator *iter = 0, int res) {
+ res = SWIG_ConvertPtr((SwigSciObject)$input, %as_voidptrptr(&iter), swig::SciSwigIterator::descriptor(), 0);
+ if (!SWIG_IsOK(res) || !iter) {
+ %argument_fail(SWIG_TypeError, "$type", $symname, $argnum);
+ } else {
+ swig::SwigSciIterator_T<$type > *iter_t = dynamic_cast *>(iter);
+ if (iter_t) {
+ $1 = iter_t->get_current();
+ } else {
+ %argument_fail(SWIG_TypeError, "$type", $symname, $argnum);
+ }
+ }
+ }
+
+ %typecheck(%checkcode(ITERATOR),noblock=1,fragment="SciSequence_Cont")
+ iterator, reverse_iterator, const_iterator, const_reverse_iterator {
+ swig::SciSwigIterator *iter = 0;
+ int res = SWIG_ConvertPtr((SwigSciObject)$input, %as_voidptrptr(&iter), swig::SciSwigIterator::descriptor(), 0);
+ $1 = (SWIG_IsOK(res) && iter && (dynamic_cast *>(iter) != 0));
+ }
+
+ %fragment("SciSequence_Cont");
+#endif //SWIG_EXPORT_ITERATOR_METHODS
+%enddef
+
+// The Scilab container methods
+
+%define %swig_container_methods(Container...)
+%enddef
+
+%define %swig_sequence_methods_common(Sequence...)
+ %swig_sequence_iterator(%arg(Sequence))
+ %swig_container_methods(%arg(Sequence))
+
+%enddef
+
+%define %swig_sequence_methods(Sequence...)
+ %swig_sequence_methods_common(%arg(Sequence))
+%enddef
+
+%define %swig_sequence_methods_val(Sequence...)
+ %swig_sequence_methods_common(%arg(Sequence))
+%enddef
+
+//
+// Common fragments
+//
+
+%fragment("StdSequenceTraits","header",
+ fragment="StdTraits",
+ fragment="SciSequence_Cont",
+ fragment=SWIG_Traits_SequenceItem_frag(ptr))
+{
+namespace swig {
+ template
+ inline void
+ assign(const SciSeq& sciSeq, Seq* seq) {
+%#ifdef SWIG_STD_NOASSIGN_STL
+ typedef typename SciSeq::value_type value_type;
+ typename SciSeq::const_iterator it = sciSeq.begin();
+ for (;it != sciSeq.end(); ++it) {
+ seq->insert(seq->end(),(value_type)(*it));
+ }
+%#else
+ seq->assign(sciSeq.begin(), sciSeq.end());
+%#endif
+ }
+
+ template
+ struct traits_asptr_stdseq {
+ typedef Seq sequence;
+ typedef T value_type;
+
+ static int asptr(const SwigSciObject& obj, sequence **seq)
+ {
+ swig_type_info *typeInfo = swig::type_info();
+ if (typeInfo)
+ {
+ sequence *p;
+ if (SWIG_ConvertPtr(obj, (void**)&p, typeInfo, 0) == SWIG_OK)
+ {
+ if (seq)
+ *seq = p;
+ return SWIG_OLDOBJ;
+ }
+ }
+
+ if (traits_as_sequence::check(obj) == SWIG_OK)
+ {
+ try
+ {
+ SciSequence_Cont sciSeq(obj);
+ if (seq)
+ {
+ *seq = new sequence();
+ assign(sciSeq, *seq);
+ return SWIG_NEWOBJ;
+ }
+ else
+ {
+ return true;
+ }
+ }
+ catch (std::exception& e)
+ {
+ SWIG_exception(SWIG_RuntimeError, e.what());
+ }
+ }
+ }
+ };
+
+ template
+ struct traits_from_stdseq {
+ typedef Seq sequence;
+ typedef T value_type;
+ typedef typename Seq::size_type size_type;
+ typedef typename sequence::const_iterator const_iterator;
+
+ static SwigSciObject from(const sequence& seq)
+ {
+ %#ifdef SWIG_SCILAB_EXTRA_NATIVE_CONTAINERS
+ swig_type_info *typeInfo = swig::type_info();
+ if (typeInfo)
+ {
+ return SWIG_NewPointerObj(new sequence(seq), typeInfo, SWIG_POINTER_OWN);
+ }
+ %#endif
+
+ try
+ {
+ void *data;
+ size_type size = seq.size();
+ if (traits_from_sequence::create(size, &data) == SWIG_OK) {
+ const_iterator it;
+ int index = 0;
+ for (it = seq.begin(); it != seq.end(); ++it)
+ {
+ traits_from_sequenceitem::from(data, index, *it);
+ index++;
+ }
+ return traits_from_sequence::set(size, data);
+ }
+ return SWIG_OK;
+ }
+ catch (std::exception& e)
+ {
+ SWIG_exception(SWIG_RuntimeError, e.what());
+ }
+ }
+ };
+}
+}
diff --git a/Lib/scilab/scidouble.swg b/Lib/scilab/scidouble.swg
new file mode 100644
index 000000000..1b8263306
--- /dev/null
+++ b/Lib/scilab/scidouble.swg
@@ -0,0 +1,108 @@
+/*
+ * DOUBLE SCALAR
+ */
+%fragment(SWIG_AsVal_frag(double), "header", fragment="SWIG_SciDouble_AsDouble") {
+%#define SWIG_AsVal_double(scilabValue, valuePointer) SWIG_SciDouble_AsDouble(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_SciDouble_AsDouble", "header") {
+SWIGINTERN int
+SWIG_SciDouble_AsDouble(void *pvApiCtx, SwigSciObject iVar, double *pdblValue, char *fname) {
+ SciErr sciErr;
+ int iRet = 0;
+ int *piAddrVar = NULL;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (!isDoubleType(pvApiCtx, piAddrVar) || isVarComplex(pvApiCtx, piAddrVar)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A real expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+
+ if (!isScalar(pvApiCtx, piAddrVar)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A real expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+
+ iRet = getScalarDouble(pvApiCtx, piAddrVar, pdblValue);
+ if (iRet) {
+ return SWIG_ERROR;
+ }
+
+ return SWIG_OK;
+}
+}
+
+%fragment(SWIG_From_frag(double), "header", fragment="SWIG_SciDouble_FromDouble") {
+%#define SWIG_From_double(scilabValue) SWIG_SciDouble_FromDouble(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_SciDouble_FromDouble", "header") {
+SWIGINTERN int
+SWIG_SciDouble_FromDouble(void *pvApiCtx, int iVarOut, double dblValue, char *fname) {
+ if (createScalarDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, dblValue))
+ return SWIG_ERROR;
+ return SWIG_OK;
+}
+}
+
+/*
+ * DOUBLE ARRAY
+ */
+
+%fragment("SWIG_SciDouble_AsDoubleArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciDouble_AsDoubleArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, double **pdValue, char *fname) {
+ SciErr sciErr;
+ int *piAddrVar = NULL;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (isDoubleType(pvApiCtx, piAddrVar) && !isVarComplex(pvApiCtx, piAddrVar)) {
+ sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, iRows, iCols, pdValue);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ }
+ else {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A real matrix expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+
+ return SWIG_OK;
+}
+}
+
+%fragment("SWIG_SciDouble_FromDoubleArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciDouble_FromDoubleArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, double *pdblValue) {
+ SciErr sciErr;
+ sciErr = createMatrixOfDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, pdblValue);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ return SWIG_OK;
+}
+}
+
+%fragment(SWIG_CreateScilabVariable_frag(double), "wrapper") {
+SWIGINTERN int
+SWIG_CreateScilabVariable_dec(double)(void *pvApiCtx, const char* psVariableName, const double dVariableValue) {
+ SciErr sciErr;
+ sciErr = createNamedMatrixOfDouble(pvApiCtx, psVariableName, 1, 1, &dVariableValue);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ return SWIG_OK;
+}
+}
diff --git a/Lib/scilab/scienum.swg b/Lib/scilab/scienum.swg
new file mode 100644
index 000000000..54ec1f85c
--- /dev/null
+++ b/Lib/scilab/scienum.swg
@@ -0,0 +1,31 @@
+/*
+ * C-type: enum
+ * Scilab type: double or int32
+ */
+
+%fragment(SWIG_AsVal_frag(Enum), "header", fragment="SWIG_Int_AsEnum") {
+%#define SWIG_AsVal_Enum(scilabValue, valuePointer) SWIG_Int_AsEnum(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_Int_AsEnum", "header", fragment="SWIG_SciDoubleOrInt32_AsInt") {
+SWIGINTERN int
+SWIG_Int_AsEnum(void *pvApiCtx, int iVar, int *enumValue, char *fname) {
+ int iValue = 0;
+ if (SWIG_SciDoubleOrInt32_AsInt(pvApiCtx, iVar, &iValue, fname) != SWIG_OK)
+ return SWIG_ERROR;
+ *enumValue = iValue;
+ return SWIG_OK;
+}
+}
+
+%fragment(SWIG_From_frag(Enum), "header", fragment="SWIG_Int_FromEnum") {
+%#define SWIG_From_Enum(scilabValue) SWIG_Int_FromEnum(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_Int_FromEnum", "header", fragment="SWIG_SciDouble_FromInt") {
+SWIGINTERN int
+SWIG_Int_FromEnum(void *pvApiCtx, int iVarOut, int enumValue, char *fname) {
+ if (SWIG_SciDouble_FromInt(pvApiCtx, iVarOut, enumValue, fname) != SWIG_OK)
+ return SWIG_ERROR;
+ SWIG_Scilab_SetOutput(pvApiCtx, iVarOut);
+ return SWIG_OK;
+}
+}
diff --git a/Lib/scilab/sciexception.swg b/Lib/scilab/sciexception.swg
new file mode 100644
index 000000000..a5eb4c00f
--- /dev/null
+++ b/Lib/scilab/sciexception.swg
@@ -0,0 +1,60 @@
+/*
+ * Exception typemaps (throws)
+ */
+
+%include
+
+%typemap(throws, noblock=1) int, unsigned int, signed int,
+ int&,unsigned int&, signed int&,
+ long, unsigned long, signed long,
+ short, unsigned short,signed short,
+ long long, unsigned long long,
+ unsigned char, signed char,
+ long&, unsigned long&, signed long&,
+ short&, unsigned short&, signed short&,
+ long long&, unsigned long long&,
+ unsigned char&, signed char&,
+ size_t, size_t&,
+ ptrdiff_t, ptrdiff_t& {
+ char obj[20];
+ sprintf(obj, "%d", (int)$1);
+ SWIG_Scilab_Raise_Ex(obj, "$type", $descriptor);
+}
+
+%typemap(throws, noblock=1) enum SWIGTYPE {
+ char obj[20];
+ sprintf(obj, "%d", (int)$1);
+ SWIG_Scilab_Raise_Ex(obj, "$type", $descriptor);
+}
+
+%typemap(throws, noblock=1) float, double,
+ float&, double& {
+ char obj[20];
+ sprintf(obj, "%5.3f", (double)$1);
+ SWIG_Scilab_Raise_Ex(obj, "$type", $descriptor);
+}
+
+%typemap(throws, noblock=1) bool, bool& {
+ SWIG_Scilab_Raise_Ex($1 ? "true" : "false", "$type", $descriptor);
+}
+
+%typemap(throws, noblock=1) char*, char[ANY] {
+ SWIG_Scilab_Raise_Ex($1, "$type", $descriptor);
+}
+
+%typemap(throws, noblock=1) char, char& {
+ char obj[1];
+ sprintf(obj, "%c", (char)$1);
+ SWIG_Scilab_Raise_Ex(obj, "$type", $descriptor);
+}
+
+%typemap(throws, noblock=1) SWIGTYPE,
+ SWIGTYPE*,
+ SWIGTYPE [ANY],
+ SWIGTYPE & {
+ SWIG_Scilab_Raise_Ex((char*)NULL, "$type", $descriptor);
+}
+
+%typemap(throws, noblock=1) (...) {
+ SWIG_exception(SWIG_RuntimeError, "unknown exception");
+}
diff --git a/Lib/scilab/scifloat.swg b/Lib/scilab/scifloat.swg
new file mode 100644
index 000000000..f0af17c0e
--- /dev/null
+++ b/Lib/scilab/scifloat.swg
@@ -0,0 +1,83 @@
+/*
+ * FLOAT SCALAR
+ */
+
+%fragment(SWIG_AsVal_frag(float), "header", fragment=SWIG_AsVal_frag(double)) {
+SWIGINTERN int
+SWIG_AsVal_dec(float)(SwigSciObject iVar, float *pfValue) {
+ double dblValue = 0.0;
+ if(SWIG_AsVal_dec(double)(iVar, &dblValue) != SWIG_OK) {
+ return SWIG_ERROR;
+ }
+ if (pfValue)
+ *pfValue = (float) dblValue;
+ return SWIG_OK;
+}
+}
+
+%fragment(SWIG_From_frag(float), "header") {
+SWIGINTERN int
+SWIG_From_dec(float)(float flValue) {
+ if (createScalarDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx)
+ + SWIG_Scilab_GetOutputPosition(), (double)flValue))
+ return SWIG_ERROR;
+ return SWIG_OK;
+}
+}
+
+%fragment("SWIG_SciDouble_AsFloatArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciDouble_AsFloatArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, float **pfValue, char *fname) {
+ SciErr sciErr;
+ int *piAddrVar = NULL;
+ double *pdValue = NULL;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (isDoubleType(pvApiCtx, piAddrVar) && !isVarComplex(pvApiCtx, piAddrVar)) {
+ int i;
+
+ sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, iRows, iCols, &pdValue);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ *pfValue = (float *) malloc((*iRows) * (*iCols) * sizeof(float));
+ for (i=0; i < (*iRows) * (*iCols); i++)
+ (*pfValue)[i] = (float) pdValue[i];
+
+ return SWIG_OK;
+ }
+ else {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A real matrix expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+}
+}
+
+%fragment("SWIG_SciDouble_FromFloatArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciDouble_FromFloatArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, float *pfValue) {
+ SciErr sciErr;
+ double *pdValue;
+ int i;
+
+ pdValue = (double *) malloc(iRows * iCols * sizeof(double));
+ for (i = 0; i < iRows * iCols; i++)
+ pdValue[i] = pfValue[i];
+
+ sciErr = createMatrixOfDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, pdValue);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ free(pdValue);
+ return SWIG_OK;
+}
+}
diff --git a/Lib/scilab/sciint.swg b/Lib/scilab/sciint.swg
new file mode 100644
index 000000000..2d6993569
--- /dev/null
+++ b/Lib/scilab/sciint.swg
@@ -0,0 +1,202 @@
+/*
+ * C-type: int
+ * Scilab type: double or int32
+ */
+
+%fragment(SWIG_AsVal_frag(int), "header", fragment="SWIG_SciDoubleOrInt32_AsInt", fragment="") {
+%#define SWIG_AsVal_int(scilabValue, valuePointer) SWIG_SciDoubleOrInt32_AsInt(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_SciDoubleOrInt32_AsInt", "header") {
+SWIGINTERN int
+SWIG_SciDoubleOrInt32_AsInt(void *pvApiCtx, SwigSciObject iVar, int *piValue, char *fname)
+{
+ SciErr sciErr;
+ int iType = 0;
+ int iRows = 0;
+ int iCols = 0;
+ int *piAddrVar = NULL;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (iType == sci_ints) {
+ if (piValue) {
+ int iPrec = 0;
+ int *piData = NULL;
+
+ sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iPrec != SCI_INT32) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit signed integer or a double expected.\n"), fname, iVar);
+ return SWIG_TypeError;
+ }
+ sciErr = getMatrixOfInteger32(pvApiCtx, piAddrVar, &iRows, &iCols, &piData);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iRows * iCols != 1) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 32-bit signed integer or a double expected.\n"), fname, iVar);
+ return SWIG_TypeError;
+ }
+ *piValue = *piData;
+ }
+ }
+ else if (iType == sci_matrix) {
+ if (piValue) {
+ double *pdData = NULL;
+ double dValue = 0.0f;
+ sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, &iRows, &iCols, &pdData);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iRows * iCols != 1) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 32-bit signed integer or a double expected.\n"), fname, iVar);
+ return SWIG_TypeError;
+ }
+ dValue = *pdData;
+ if (dValue != floor(dValue)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The double value cannot be converted to a 32-bit signed integer.\n"), fname, iVar);
+ return SWIG_ValueError;
+ }
+ if ((dValue < INT_MIN) || (dValue > INT_MAX)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Overflow error for input argument #%d: The double value cannot be converted to a 32-bit signed integer.\n"), fname, iVar);
+ return SWIG_OverflowError;
+ }
+ *piValue = (int) dValue;
+ }
+ }
+ else {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit signed integer or a double expected.\n"), fname, iVar);
+ return SWIG_TypeError;
+ }
+
+ return SWIG_OK;
+}
+}
+
+%fragment(SWIG_From_frag(int), "header", fragment="SWIG_SciDouble_FromInt") {
+%#define SWIG_From_int(scilabValue) SWIG_SciDouble_FromInt(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_SciDouble_FromInt", "header") {
+SWIGINTERN int
+SWIG_SciDouble_FromInt(void *pvApiCtx, int iVarOut, int iValue, char *fname){
+ if (createScalarDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx)
+ + iVarOut, (double) iValue))
+ return SWIG_ERROR;
+ return SWIG_OK;
+}
+}
+
+/*
+ * C-type: int[]
+ * Scilab type: double or int32 matrix
+ */
+%fragment("SWIG_SciDoubleOrInt32_AsIntArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciDoubleOrInt32_AsIntArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, int **piValue, char *fname) {
+ SciErr sciErr;
+ int iType = 0;
+ int *piAddrVar = NULL;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (iType == sci_matrix) {
+ double *pdData = NULL;
+ int size = 0;
+ int i;
+
+ sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, iRows, iCols, &pdData);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ size = (*iRows) * (*iCols);
+ *piValue = (int*) malloc(size * sizeof(int*));
+ for (i = 0; i < size; i++)
+ (*piValue)[i] = (int) pdData[i];
+ }
+ else if (iType == sci_ints) {
+ int iPrec = 0;
+ sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iPrec != SCI_INT32) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit signed integer or a double matrix expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+ sciErr = getMatrixOfInteger32(pvApiCtx, piAddrVar, iRows, iCols, piValue);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ }
+ else {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit signed integer or a double matrix expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+ return SWIG_OK;
+}
+}
+
+%fragment("SWIG_SciDouble_FromIntArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciDouble_FromIntArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, const int *piData) {
+ SciErr sciErr;
+ double *pdValues = NULL;
+ int i;
+
+ pdValues = (double*) malloc(iRows * iCols * sizeof(double));
+ for (i=0; i
+
+%fragment("SciSwigIterator","header",fragment="") {
+namespace swig {
+ struct stop_iteration {
+ };
+
+ struct SciSwigIterator {
+ private:
+ SwigSciObject _seq;
+
+ protected:
+ SciSwigIterator(SwigSciObject seq) : _seq(seq)
+ {
+ }
+
+ public:
+ virtual ~SciSwigIterator() {}
+
+ virtual SwigSciObject value() const = 0;
+
+ virtual SciSwigIterator *incr(size_t n = 1) = 0;
+
+ virtual SciSwigIterator *decr(size_t n = 1)
+ {
+ throw stop_iteration();
+ }
+
+ virtual ptrdiff_t distance(const SciSwigIterator &x) const
+ {
+ throw std::invalid_argument("operation not supported");
+ }
+
+ virtual bool equal (const SciSwigIterator &x) const
+ {
+ throw std::invalid_argument("operation not supported");
+ }
+
+ virtual SciSwigIterator *copy() const = 0;
+
+ SwigSciObject next()
+ {
+ SwigSciObject obj = value();
+ incr();
+ return obj;
+ }
+
+ SwigSciObject previous()
+ {
+ decr();
+ return value();
+ }
+
+ SciSwigIterator *advance(ptrdiff_t n)
+ {
+ return (n > 0) ? incr(n) : decr(-n);
+ }
+
+ bool operator == (const SciSwigIterator& x) const
+ {
+ return equal(x);
+ }
+
+ bool operator != (const SciSwigIterator& x) const
+ {
+ return ! operator==(x);
+ }
+
+ SciSwigIterator* operator ++ () {
+ incr();
+ return this;
+ }
+
+ SciSwigIterator* operator -- () {
+ decr();
+ return this;
+ }
+
+ SciSwigIterator* operator + (ptrdiff_t n) const
+ {
+ return copy()->advance(n);
+ }
+
+ SciSwigIterator* operator - (ptrdiff_t n) const
+ {
+ return copy()->advance(-n);
+ }
+
+ ptrdiff_t operator - (const SciSwigIterator& x) const
+ {
+ return x.distance(*this);
+ }
+
+ static swig_type_info* descriptor() {
+ static int init = 0;
+ static swig_type_info* desc = 0;
+ if (!init) {
+ desc = SWIG_TypeQuery("swig::SciSwigIterator *");
+ init = 1;
+ }
+ return desc;
+ }
+ };
+}
+}
+
+%fragment("SwigSciIterator_T","header",fragment="",fragment="SciSwigIterator",fragment="StdTraits",fragment="StdIteratorTraits") {
+namespace swig {
+ template
+ class SwigSciIterator_T : public SciSwigIterator
+ {
+ public:
+ typedef OutIterator out_iterator;
+ typedef typename std::iterator_traits::value_type value_type;
+ typedef SwigSciIterator_T self_type;
+
+ SwigSciIterator_T(out_iterator curr, SwigSciObject seq)
+ : SciSwigIterator(seq), current(curr)
+ {
+ }
+
+ const out_iterator& get_current() const
+ {
+ return current;
+ }
+
+
+ bool equal (const SciSwigIterator &iter) const
+ {
+ const self_type *iters = dynamic_cast(&iter);
+ if (iters) {
+ return (current == iters->get_current());
+ } else {
+ throw std::invalid_argument("bad iterator type");
+ }
+ }
+
+ ptrdiff_t distance(const SciSwigIterator &iter) const
+ {
+ const self_type *iters = dynamic_cast(&iter);
+ if (iters) {
+ return std::distance(current, iters->get_current());
+ } else {
+ throw std::invalid_argument("bad iterator type");
+ }
+ }
+
+ protected:
+ out_iterator current;
+ };
+
+ template
+ struct from_oper
+ {
+ typedef const ValueType& argument_type;
+ typedef SwigSciObject result_type;
+ result_type operator()(argument_type v) const
+ {
+ return swig::from(v);
+ }
+ };
+
+ template::value_type,
+ typename FromOper = from_oper >
+ class SciSwigIteratorOpen_T : public SwigSciIterator_T
+ {
+ public:
+ FromOper from;
+ typedef OutIterator out_iterator;
+ typedef ValueType value_type;
+ typedef SwigSciIterator_T base;
+ typedef SciSwigIteratorOpen_T self_type;
+
+ SciSwigIteratorOpen_T(out_iterator curr, SwigSciObject seq)
+ : SwigSciIterator_T(curr, seq)
+ {
+ }
+
+ SwigSciObject value() const {
+ return from(static_cast(*(base::current)));
+ }
+
+ SciSwigIterator *copy() const
+ {
+ return new self_type(*this);
+ }
+
+ SciSwigIterator *incr(size_t n = 1)
+ {
+ while (n--) {
+ ++base::current;
+ }
+ return this;
+ }
+
+ SciSwigIterator *decr(size_t n = 1)
+ {
+ while (n--) {
+ --base::current;
+ }
+ return this;
+ }
+ };
+
+ template::value_type,
+ typename FromOper = from_oper >
+ class SciSwigIteratorClosed_T : public SwigSciIterator_T
+ {
+ public:
+ FromOper from;
+ typedef OutIterator out_iterator;
+ typedef ValueType value_type;
+ typedef SwigSciIterator_T base;
+ typedef SciSwigIteratorClosed_T self_type;
+
+ SciSwigIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, SwigSciObject seq)
+ : SwigSciIterator_T(curr, seq), begin(first), end(last)
+ {
+ }
+
+ SwigSciObject value() const {
+ if (base::current == end) {
+ throw stop_iteration();
+ } else {
+ return from(static_cast(*(base::current)));
+ }
+ }
+
+ SciSwigIterator *copy() const
+ {
+ return new self_type(*this);
+ }
+
+ SciSwigIterator *incr(size_t n = 1)
+ {
+ while (n--) {
+ if (base::current == end) {
+ throw stop_iteration();
+ } else {
+ ++base::current;
+ }
+ }
+ return this;
+ }
+
+ SciSwigIterator *decr(size_t n = 1)
+ {
+ while (n--) {
+ if (base::current == begin) {
+ throw stop_iteration();
+ } else {
+ --base::current;
+ }
+ }
+ return this;
+ }
+
+ private:
+ out_iterator begin;
+ out_iterator end;
+ };
+
+ template
+ inline SciSwigIterator*
+ make_output_iterator(const OutIter& current, const OutIter& begin,const OutIter& end, SwigSciObject seq = SwigSciObject())
+ {
+ return new SciSwigIteratorClosed_T(current, begin, end, seq);
+ }
+
+ template
+ inline SciSwigIterator*
+ make_output_iterator(const OutIter& current, SwigSciObject seq = SwigSciObject())
+ {
+ return new SciSwigIteratorOpen_T(current, seq);
+ }
+}
+}
+
+
+%fragment("SciSwigIterator");
+namespace swig
+{
+// Throw a StopIteration exception
+ %ignore stop_iteration;
+ struct stop_iteration {};
+
+ %typemap(throws, noblock=1) stop_iteration
+ {
+ SWIG_Scilab_Raise(0, "stop_iteration", NULL);
+ return SWIG_ERROR;
+ }
+
+// Mark methods that return new objects
+ %newobject SciSwigIterator::copy;
+ %newobject SciSwigIterator::operator + (ptrdiff_t n) const;
+ %newobject SciSwigIterator::operator - (ptrdiff_t n) const;
+
+ %nodirector SciSwigIterator;
+
+ %catches(swig::stop_iteration) SciSwigIterator::value() const;
+ %catches(swig::stop_iteration) SciSwigIterator::incr(size_t n = 1);
+ %catches(swig::stop_iteration) SciSwigIterator::decr(size_t n = 1);
+ %catches(std::invalid_argument) SciSwigIterator::distance(const SciSwigIterator &x) const;
+ %catches(std::invalid_argument) SciSwigIterator::equal (const SciSwigIterator &x) const;
+ %catches(swig::stop_iteration) SciSwigIterator::next();
+ %catches(swig::stop_iteration) SciSwigIterator::previous();
+ %catches(swig::stop_iteration) SciSwigIterator::advance(ptrdiff_t n);
+ %catches(swig::stop_iteration) SciSwigIterator::operator += (ptrdiff_t n);
+ %catches(swig::stop_iteration) SciSwigIterator::operator -= (ptrdiff_t n);
+ %catches(swig::stop_iteration) SciSwigIterator::operator + (ptrdiff_t n) const;
+ %catches(swig::stop_iteration) SciSwigIterator::operator - (ptrdiff_t n) const;
+
+ %ignore SciSwigIterator::operator==;
+ %ignore SciSwigIterator::operator!=;
+ %ignore SciSwigIterator::operator++;
+ %ignore SciSwigIterator::operator--;
+ %ignore SciSwigIterator::operator+;
+ %ignore SciSwigIterator::operator-;
+
+ struct SciSwigIterator
+ {
+ protected:
+ SciSwigIterator(SwigSciObject seq);
+
+ public:
+ virtual ~SciSwigIterator();
+
+ virtual SwigSciObject value() const = 0;
+
+ virtual SciSwigIterator *incr(size_t n = 1) = 0;
+
+ virtual SciSwigIterator *decr(size_t n = 1);
+
+ virtual ptrdiff_t distance(const SciSwigIterator &x) const;
+
+ virtual bool equal (const SciSwigIterator &x) const;
+
+ virtual SciSwigIterator *copy() const = 0;
+
+ SwigSciObject next();
+ SwigSciObject previous();
+ SciSwigIterator *advance(ptrdiff_t n);
+
+ bool operator == (const SciSwigIterator& x) const;
+ bool operator != (const SciSwigIterator& x) const;
+ SciSwigIterator* operator ++ ();
+ SciSwigIterator* operator -- ();
+ SciSwigIterator* operator + (ptrdiff_t n) const;
+ SciSwigIterator* operator - (ptrdiff_t n) const;
+ ptrdiff_t operator - (const SciSwigIterator& x) const;
+ };
+}
diff --git a/Lib/scilab/scilab.swg b/Lib/scilab/scilab.swg
new file mode 100644
index 000000000..3b5f6e817
--- /dev/null
+++ b/Lib/scilab/scilab.swg
@@ -0,0 +1,6 @@
+%include
+%include
+%include
+%include
+%include
+
diff --git a/Lib/scilab/scilist.swg b/Lib/scilab/scilist.swg
new file mode 100644
index 000000000..513f40b64
--- /dev/null
+++ b/Lib/scilab/scilist.swg
@@ -0,0 +1,91 @@
+/*
+ * Scilab list related functions
+ *
+ */
+
+%fragment("SWIG_ScilabList", "header")
+{
+SWIGINTERN int
+SWIG_GetScilabList(SwigSciObject obj, int **piListAddr)
+{
+ SciErr sciErr;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, obj, piListAddr);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ return SWIG_OK;
+}
+
+SWIGINTERN int
+SWIG_GetScilabListSize(SwigSciObject obj, int *piListSize)
+{
+ SciErr sciErr;
+ int *piListAddr;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, obj, &piListAddr);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getListItemNumber(pvApiCtx, piListAddr, piListSize);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ return SWIG_OK;
+}
+
+SWIGINTERN int
+SWIG_GetScilabListAndSize(SwigSciObject obj, int **piListAddr, int *piListSize)
+{
+ SciErr sciErr;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, obj, piListAddr);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getListItemNumber(pvApiCtx, *piListAddr, piListSize);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ return SWIG_OK;
+}
+
+SWIGINTERN int
+SWIG_CheckScilabList(SwigSciObject obj)
+{
+ SciErr sciErr;
+ int *piListAddr;
+ int iType;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, obj, &piListAddr);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getVarType(pvApiCtx, piListAddr, &iType);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if ((iType != sci_list) && (iType != sci_tlist) && (iType != sci_mlist)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A list is expected.\n"), SWIG_Scilab_GetFuncName(), obj);
+ return SWIG_ERROR;
+ }
+
+ return SWIG_OK;
+}
+
+}
+
diff --git a/Lib/scilab/scilong.swg b/Lib/scilab/scilong.swg
new file mode 100644
index 000000000..4e55be539
--- /dev/null
+++ b/Lib/scilab/scilong.swg
@@ -0,0 +1,123 @@
+/*
+ * C-type: long
+ * Scilab type: double or int32
+ */
+
+%fragment(SWIG_AsVal_frag(long), "header", fragment="SWIG_SciDoubleOrInt32_AsLong", fragment="") {
+%#define SWIG_AsVal_long(scilabValue, valuePointer) SWIG_SciDoubleOrInt32_AsLong(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName());
+}
+%fragment("SWIG_SciDoubleOrInt32_AsLong", "header") {
+SWIGINTERN int
+SWIG_SciDoubleOrInt32_AsLong(void *pvApiCtx, SwigSciObject iVar, long *plValue, char *fname) {
+ SciErr sciErr;
+ int iType = 0;
+ int iRows = 0;
+ int iCols = 0;
+ int *piAddrVar = NULL;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (iType == sci_ints) {
+ int iPrec = 0;
+ int *piData = NULL;
+
+ sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iPrec != SCI_INT32) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit signed integer or a double expected.\n"), fname, iVar);
+ return SWIG_TypeError;
+ }
+ sciErr = getMatrixOfInteger32(pvApiCtx, piAddrVar, &iRows, &iCols, &piData);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iRows * iCols != 1) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 32-bit signed integer or a double expected.\n"), fname, iVar);
+ return SWIG_TypeError;
+ }
+ *plValue = (long) *piData;
+ }
+ else if (iType == sci_matrix) {
+ double *pdData = NULL;
+ double dValue = 0.0f;
+
+ sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, &iRows, &iCols, &pdData);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iRows * iCols != 1) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 32-bit signed integer or a double expected.\n"), fname, iVar);
+ return SWIG_TypeError;
+ }
+ dValue = *pdData;
+ if (dValue != floor(dValue)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The double value cannot be converted to a 32-bit signed integer.\n"), fname, iVar);
+ return SWIG_ValueError;
+ }
+ if ((dValue < LONG_MIN) || (dValue > LONG_MAX)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Overflow error for input argument #%d: The double value cannot be converted to a 32-bit signed integer.\n"), fname, iVar);
+ return SWIG_OverflowError;
+ }
+ *plValue = (long) dValue;
+ }
+ else {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit signed integer or a double expected.\n"), fname, iVar);
+ return SWIG_TypeError;
+ }
+
+ return SWIG_OK;
+}
+}
+
+%fragment(SWIG_From_frag(long), "header", fragment="SWIG_SciDouble_FromLong") {
+%#define SWIG_From_long(scilabValue) SWIG_SciDouble_FromLong(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_SciDouble_FromLong", "header") {
+SWIGINTERN int
+SWIG_SciDouble_FromLong(void *pvApiCtx, int iVarOut, long lValue, char *fname) {
+ if (createScalarDouble(pvApiCtx,
+ SWIG_NbInputArgument(pvApiCtx) + iVarOut, (double) lValue))
+ return SWIG_ERROR;
+ return SWIG_OK;
+}
+}
+
+
+%fragment("SWIG_SciDouble_FromLongArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciDouble_FromLongArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, const long *plData) {
+ SciErr sciErr;
+ int i;
+ double *pdValues = NULL;
+
+ pdValues = (double*) malloc(iRows * iCols * sizeof(double));
+ for (i=0; i
+
+// in (bool *IN, int IN_ROWCOUNT, int IN_COLCOUNT)
+
+%typemap(in, noblock=1, fragment="SWIG_SciBoolean_AsBoolArrayAndSize") (bool *IN, int IN_ROWCOUNT, int IN_COLCOUNT)
+{
+ if (SWIG_SciBoolean_AsBoolArrayAndSize(pvApiCtx, $input, &$2, &$3, &$1, fname) != SWIG_OK) {
+ return SWIG_ERROR;
+ }
+}
+
+// in (int IN_ROWCOUNT, int IN_COLCOUNT, bool *IN)
+
+%typemap(in, noblock=1, fragment="SWIG_SciBoolean_AsBoolArrayAndSize") (int IN_ROWCOUNT, int IN_COLCOUNT, bool *IN)
+{
+ if (SWIG_SciBoolean_AsBoolArrayAndSize(pvApiCtx, $input, &$1, &$2, &$3, fname) != SWIG_OK) {
+ return SWIG_ERROR;
+ }
+}
+
+// in (bool *IN, int IN_SIZE)
+
+%typemap(in, noblock=1, fragment="SWIG_SciBoolean_AsBoolArrayAndSize") (bool *IN, int IN_SIZE)
+{
+ int rowCount;
+ int colCount;
+ if (SWIG_SciBoolean_AsBoolArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$1, fname) == SWIG_OK) {
+ $2 = rowCount * colCount;
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+// in (int IN_SIZE, bool *IN)
+
+%typemap(in, noblock=1) (int IN_SIZE, bool *IN)
+{
+ int rowCount;
+ int colCount;
+ if (SWIG_SciBoolean_AsBoolArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$2, fname) == SWIG_OK) {
+ $1 = rowCount * colCount;
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+// out (bool **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+
+%typemap(in, noblock=1, numinputs=0) (bool **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+{
+}
+
+%typemap(arginit, noblock=1) (bool **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+{
+ $1 = (bool**) malloc(sizeof(bool*));
+ $2 = (int*) malloc(sizeof(int));
+ $3 = (int*) malloc(sizeof(int));
+}
+
+%typemap(freearg, noblock=1) (bool **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+{
+ free(*$1);
+ free($1);
+ free($2);
+ free($3);
+}
+
+%typemap(argout, noblock=1, fragment="SWIG_SciBoolean_FromBoolArrayAndSize") (bool **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+{
+ if (SWIG_SciBoolean_FromBoolArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$2, *$3, *$1) == SWIG_OK) {
+ SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+// out (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, bool **OUT)
+
+%typemap(in, noblock=1, numinputs=0) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, bool **OUT)
+{
+}
+
+%typemap(arginit, noblock=1) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, bool **OUT)
+{
+ $1 = (int*) malloc(sizeof(int));
+ $2 = (int*) malloc(sizeof(int));
+ $3 = (bool**) malloc(sizeof(bool*));
+}
+
+%typemap(argout, noblock=1, fragment="SWIG_SciBoolean_FromBoolArrayAndSize") (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, bool **OUT)
+{
+ if (SWIG_SciBoolean_FromBoolArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$1, *$2, *$3) == SWIG_OK) {
+ SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+%typemap(freearg, noblock=1) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, bool **OUT)
+{
+ free($1);
+ free($2);
+ free(*$3);
+ free($3);
+}
+
+
+// out (bool **OUT, int *OUT_SIZE)
+
+%typemap(in, noblock=1, numinputs=0) (bool **OUT, int *OUT_SIZE)
+{
+}
+
+%typemap(arginit, noblock=1) (bool **OUT, int *OUT_SIZE)
+{
+ $1 = (bool**) malloc(sizeof(bool*));
+ $2 = (int*) malloc(sizeof(int));
+}
+
+%typemap(argout, noblock=1, fragment="SWIG_SciBoolean_FromBoolArrayAndSize") (bool **OUT, int *OUT_SIZE)
+{
+ if (SWIG_SciBoolean_FromBoolArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$2, *$1) == SWIG_OK) {
+ SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+%typemap(freearg, noblock=1) (bool **OUT, int *OUT_SIZE)
+{
+ free(*$1);
+ free($1);
+ free($2);
+}
+
+
+// out (int *OUT_SIZE, bool **OUT)
+
+%typemap(in, noblock=1, numinputs=0) (int *OUT_SIZE, bool **OUT)
+{
+}
+
+%typemap(arginit, noblock=1) (int *OUT_SIZE, bool **OUT)
+{
+ $1 = (int*) malloc(sizeof(int));
+ $2 = (bool**) malloc(sizeof(bool*));
+}
+
+%typemap(argout, noblock=1, fragment="SWIG_SciBoolean_FromBoolArrayAndSize") (int *OUT_SIZE, bool **OUT)
+{
+ if (SWIG_SciBoolean_FromBoolArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$1, *$2) == SWIG_OK) {
+ SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+%typemap(freearg, noblock=1) (int *OUT_SIZE, bool **OUT)
+{
+ free($1);
+ free(*$2);
+ free($2);
+}
diff --git a/Lib/scilab/scimatrixchar.swg b/Lib/scilab/scimatrixchar.swg
new file mode 100644
index 000000000..f86733ed3
--- /dev/null
+++ b/Lib/scilab/scimatrixchar.swg
@@ -0,0 +1,203 @@
+/*
+ * C-type: char*
+ * Scilab type: string matrix
+ */
+
+%include
+
+// in (char **IN, int IN_ROWCOUNT, int IN_COLCOUNT)
+
+%typemap(in, noblock=1, fragment="SWIG_SciString_AsCharPtrArrayAndSize") (char **IN, int IN_ROWCOUNT, int IN_COLCOUNT)
+{
+ if (SWIG_SciString_AsCharPtrArrayAndSize(pvApiCtx, $input, &$2, &$3, &$1, fname) != SWIG_OK) {
+ return SWIG_ERROR;
+ }
+}
+
+// in (int IN_ROWCOUNT, int IN_COLCOUNT, char **IN)
+
+%typemap(in, noblock=1, fragment="SWIG_SciString_AsCharPtrArrayAndSize") (int IN_ROWCOUNT, int IN_COLCOUNT, char **IN)
+{
+ if (SWIG_SciString_AsCharPtrArrayAndSize(pvApiCtx, $input, &$1, &$2, &$3, fname) != SWIG_OK {
+ return SWIG_ERROR;
+ }
+}
+
+// in (char **IN, int IN_SIZE)
+
+%typemap(in, noblock=1, fragment="SWIG_SciString_AsCharPtrArrayAndSize") (char **IN, int IN_SIZE)
+{
+ int rowCount;
+ int colCount;
+ if (SWIG_SciString_AsCharPtrArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$1, fname) == SWIG_OK) {
+ $2 = rowCount * colCount;
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+// in (int IN_SIZE, char **IN)
+
+%typemap(in, noblock=1, fragment="SWIG_SciString_AsCharPtrArrayAndSize") (int IN_SIZE, char **IN)
+{
+ int rowCount;
+ int colCount;
+ if (SWIG_SciString_AsCharPtrArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$2, fname) == SWIG_OK) {
+ $1 = rowCount * colCount;
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+// out (char ***OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+
+%typemap(in, noblock=1, numinputs=0) (char ***OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+{
+}
+
+%typemap(arginit, noblock=1) (char ***OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+{
+ $1 = (char***) malloc(sizeof(char**));
+ $2 = (int*) malloc(sizeof(int));
+ $3 = (int*) malloc(sizeof(int));
+}
+
+%typemap(argout, noblock=1, fragment="SWIG_SciString_FromCharPtrArrayAndSize") (char ***OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+{
+ if (SWIG_SciString_FromCharPtrArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$2, *$3, *$1) == SWIG_OK) {
+ SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+%typemap(freearg, noblock=1) (char ***OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+{
+ {
+ int i;
+ for (i = 0; i < (*$2) * (*$3); i++)
+ free((*$1)[i]);
+ }
+ free(*$1);
+ free($1);
+ free($2);
+ free($3);
+}
+
+// out (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, char ***OUT)
+
+%typemap(in, noblock=1, numinputs=0) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, char ***OUT)
+{
+}
+
+%typemap(arginit, noblock=1) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, char ***OUT)
+{
+ $1 = (char***) malloc(sizeof(char**));
+ $2 = (int*) malloc(sizeof(int));
+ $3 = (int**) malloc(sizeof(int*));
+}
+
+%typemap(argout, noblock=1, fragment="SWIG_SciString_FromCharPtrArrayAndSize") (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, char ***OUT)
+{
+ if (SWIG_SciString_FromCharPtrArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$1, *$2, *$3) == SWIG_OK) {
+ SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+%typemap(freearg, noblock=1) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, char ***OUT)
+{
+ free($1);
+ free($2);
+ {
+ int i;
+ for (i = 0; i < (*$1) * (*$2); i++)
+ free((*$3)[i]);
+ }
+ free(*$3);
+ free($3);
+}
+
+
+// out (char ***OUT, int *OUT_SIZE)
+
+%typemap(in, noblock=1, numinputs=0) (char ***OUT, int *OUT_SIZE)
+{
+}
+
+%typemap(arginit, noblock=1) (char ***OUT, int *OUT_SIZE)
+{
+ $1 = (char***) malloc(sizeof(char**));
+ $2 = (int*) malloc(sizeof(int));
+}
+
+%typemap(freearg, noblock=1) (char ***OUT, int *OUT_SIZE)
+{
+ {
+ int i;
+ for (i = 0; i < *$2; i++)
+ free((*$1)[i]);
+ }
+ free(*$1);
+ free($1);
+ free($2);
+}
+
+%typemap(argout, noblock=1, fragment="SWIG_SciString_FromCharPtrArrayAndSize") (char ***OUT, int *OUT_SIZE)
+{
+ if (SWIG_SciString_FromCharPtrArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$2, *$1) == SWIG_OK) {
+ SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+// in (int IN_SIZE, char **IN)
+
+%typemap(in, noblock=1, fragment="SWIG_SciString_AsCharPtrArrayAndSize") (int IN_SIZE, char **IN)
+{
+ if (SWIG_SciString_AsCharPtrArrayAndSize(pvApiCtx, $input, 1, &$1, &$2, fname) != SWIG_OK) {
+ return SWIG_ERROR;
+ }
+}
+
+// out (int *OUT_SIZE, char ***OUT)
+
+%typemap(in, noblock=1, numinputs=0) (int *OUT_SIZE, char ***OUT)
+{
+}
+
+%typemap(arginit, noblock=1) (int *OUT_SIZE, char ***OUT)
+{
+ $1 = (int*) malloc(sizeof(int));
+ $2 = (char***) malloc(sizeof(char**));
+}
+
+%typemap(argout, noblock=1, fragment="SWIG_SciString_FromCharPtrArrayAndSize") (int *OUT_SIZE, char ***OUT)
+{
+ if (SWIG_SciString_FromCharPtrArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$1, *$2) == SWIG_OK) {
+ SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+%typemap(freearg, noblock=1) (int *OUT_SIZE, char ***OUT)
+{
+ free($1);
+ {
+ int i;
+ for (i = 0; i < *$1; i++)
+ free((*$2)[i]);
+ }
+ free(*$2);
+ free($2);
+}
+
diff --git a/Lib/scilab/scimatrixdouble.swg b/Lib/scilab/scimatrixdouble.swg
new file mode 100644
index 000000000..8da9ae729
--- /dev/null
+++ b/Lib/scilab/scimatrixdouble.swg
@@ -0,0 +1,174 @@
+/*
+ * C-type: double array
+ * Scilab type: double matrix
+ */
+
+%include
+
+// in (double *IN, int IN_ROWCOUNT, int IN_COLCOUNT)
+
+%typemap(in, noblock=1, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") (double *IN, int IN_ROWCOUNT, int IN_COLCOUNT)
+{
+ if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &$2, &$3, &$1, fname) != SWIG_OK) {
+ return SWIG_ERROR;
+ }
+}
+
+// in (int IN_ROWCOUNT, int IN_COLCOUNT, double *IN)
+
+%typemap(in, noblock=1, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") (int IN_ROWCOUNT, int IN_COLCOUNT, double *IN)
+{
+ if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &$1, &$2, &$3, fname) != SWIG_OK) {
+ return SWIG_ERROR;
+ }
+}
+
+// in (double *IN, int IN_SIZE)
+
+%typemap(in, noblock=1, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") (double *IN, int IN_SIZE)
+{
+ int rowCount;
+ int colCount;
+ if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$1, fname) == SWIG_OK) {
+ $2 = rowCount * colCount;
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+// in (int IN_SIZE, double *IN)
+
+%typemap(in, noblock=1, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") (int IN_SIZE, double *IN)
+{
+ int rowCount;
+ int colCount;
+ if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$2, fname) == SWIG_OK) {
+ $1 = rowCount * colCount;
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+// out (double **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+
+%typemap(in, noblock=1, numinputs=0) (double **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+{
+}
+
+%typemap(arginit, noblock=1) (double **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+{
+ $1 = (double**) malloc(sizeof(double*));
+ $2 = (int*) malloc(sizeof(int));
+ $3 = (int*) malloc(sizeof(int));
+}
+
+%typemap(freearg, noblock=1) (double **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+{
+ free(*$1);
+ free($1);
+ free($2);
+ free($3);
+}
+
+%typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromDoubleArrayAndSize") (double **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+{
+ if (SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$2, *$3, *$1) == SWIG_OK) {
+ SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+// out (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, double **OUT)
+
+%typemap(in, noblock=1, numinputs=0) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, double **OUT)
+{
+}
+
+%typemap(arginit, noblock=1) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, double **OUT)
+{
+ $1 = (int*) malloc(sizeof(int));
+ $2 = (int*) malloc(sizeof(int));
+ $3 = (double**) malloc(sizeof(double*));
+}
+
+%typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromDoubleArrayAndSize") (int *IN_ROWCOUNT, int *IN_COLCOUNT, double **OUT)
+{
+ if (SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$1, *$2, *$3) == SWIG_OK) {
+ SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+%typemap(freearg, noblock=1) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, double **OUT)
+{
+ free($1);
+ free($2);
+ free(*$3);
+ free($3);
+}
+
+
+// out (double **OUT, int *OUT_SIZE)
+
+%typemap(in, noblock=1, numinputs=0) (double **OUT, int *OUT_SIZE)
+{
+}
+
+%typemap(arginit, noblock=1) (double **OUT, int *OUT_SIZE)
+{
+ $1 = (double**) malloc(sizeof(double*));
+ $2 = (int*) malloc(sizeof(int));
+}
+
+%typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromDoubleArrayAndSize") (double **OUT, int *OUT_SIZE)
+{
+ if (SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$2, *$1) == SWIG_OK) {
+ SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+%typemap(freearg, noblock=1) (double **OUT, int *OUT_SIZE)
+{
+ free(*$1);
+ free($1);
+ free($2);
+}
+
+
+// out (int *OUT_SIZE, double **OUT)
+
+%typemap(in, noblock=1, numinputs=0) (int *OUT_SIZE, double **OUT)
+{
+}
+
+%typemap(arginit, noblock=1) (int *OUT_SIZE, double **OUT)
+{
+ $1 = (int*) malloc(sizeof(int));
+ $2 = (double**) malloc(sizeof(double*));
+}
+
+%typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromDoubleArrayAndSize") (int *OUT_SIZE, double **OUT)
+{
+ if (SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$1, *$2) == SWIG_OK) {
+ SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+%typemap(freearg, noblock=1) (int *OUT_SIZE, double **OUT)
+{
+ free($1);
+ free(*$2);
+ free($2);
+}
diff --git a/Lib/scilab/scimatrixint.swg b/Lib/scilab/scimatrixint.swg
new file mode 100644
index 000000000..5b94fea2e
--- /dev/null
+++ b/Lib/scilab/scimatrixint.swg
@@ -0,0 +1,179 @@
+/*
+ * C-type: int array
+ * Scilab type: 32-bit integer matrix
+ */
+
+%include
+
+// in (int *IN, int IN_ROWCOUNT, int IN_COLCOUNT)
+
+%typemap(in, noblock=1, fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") (int *IN, int IN_ROWCOUNT, int IN_COLCOUNT)
+{
+ if (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, $input, &$2, &$3, &$1, fname) != SWIG_OK) {
+ return SWIG_ERROR;
+ }
+}
+
+
+// in (int IN_ROWCOUNT, int IN_COLCOUNT, int *IN)
+
+%typemap(in, noblock=1, fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") (int IN_ROWCOUNT, int IN_COLCOUNT, int *IN)
+{
+ if (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, $input, &$1, &$2, &$3, fname) != SWIG_OK) {
+ return SWIG_ERROR;
+ }
+}
+
+
+// in (int *IN, int IN_SIZE)
+
+%typemap(in, noblock=1, fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") (int *IN, int IN_SIZE)
+{
+ int rowCount;
+ int colCount;
+ if (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$1, fname) == SWIG_OK) {
+ $2 = rowCount * colCount;
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+
+// in (int IN_SIZE, int *IN)
+
+%typemap(in, noblock=1, fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") (int IN_SIZE, int *IN)
+{
+ int rowCount;
+ int colCount;
+ if (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$2, fname) == SWIG_OK) {
+ $1 = rowCount * colCount;
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+// out (int **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+
+%typemap(in, noblock=1, numinputs=0) (int **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+{
+}
+
+%typemap(arginit, noblock=1) (int **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+{
+ $1 = (int**) malloc(sizeof(int*));
+ $2 = (int*) malloc(sizeof(int));
+ $3 = (int*) malloc(sizeof(int));
+}
+
+%typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromIntArrayAndSize") (int **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+{
+ if (SWIG_SciDouble_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$2, *$3, *$1) == SWIG_OK) {
+ SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+%typemap(freearg, noblock=1) (int **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+{
+ free(*$1);
+ free($1);
+ free($2);
+ free($3);
+}
+
+
+// out (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, int **OUT)
+
+%typemap(in, noblock=1, numinputs=0) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, int **OUT)
+{
+}
+
+%typemap(arginit, noblock=1) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, int **OUT)
+{
+ $1 = (int*) malloc(sizeof(int));
+ $2 = (int*) malloc(sizeof(int));
+ $3 = (int**) malloc(sizeof(int*));
+}
+
+%typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromIntArrayAndSize") (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, int **OUT)
+{
+ if (SWIG_SciDouble_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$1, *$2, *$3) == SWIG_OK) {
+ SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+%typemap(freearg, noblock=1) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, int **OUT)
+{
+ free($1);
+ free($2);
+ free(*$3);
+ free($3);
+}
+
+
+// out (int **OUT, int *OUT_SIZE)
+
+%typemap(in, noblock=1, numinputs=0) (int **OUT, int *OUT_SIZE)
+{
+}
+
+%typemap(arginit) (int **OUT, int *OUT_SIZE)
+{
+ $1 = (int**) malloc(sizeof(int*));
+ $2 = (int*) malloc(sizeof(int));
+}
+
+%typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromIntArrayAndSize") (int **OUT, int *OUT_SIZE)
+{
+ if (SWIG_SciDouble_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$2, *$1) == SWIG_OK) {
+ SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+%typemap(freearg, noblock=1) (int **OUT, int *OUT_SIZE)
+{
+ free(*$1);
+ free($1);
+ free($2);
+}
+
+
+// out (int *OUT_SIZE, int **OUT)
+
+%typemap(in, noblock=1, numinputs=0) (int *OUT_SIZE, int **OUT)
+{
+}
+
+%typemap(arginit, noblock=1) (int *OUT_SIZE, int **OUT)
+{
+ $1 = (int*) malloc(sizeof(int));
+ $2 = (int**) malloc(sizeof(int*));
+}
+
+%typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromIntArrayAndSize") (int *OUT_SIZE, int **OUT)
+{
+ if (SWIG_SciDouble_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$1, *$2) == SWIG_OK) {
+ SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+%typemap(freearg, noblock=1) (int *IN_SIZE, int **OUT)
+{
+ free($1);
+ free(*$2);
+ free($2);
+}
+
diff --git a/Lib/scilab/scimisctypes.swg b/Lib/scilab/scimisctypes.swg
new file mode 100644
index 000000000..fe75e1568
--- /dev/null
+++ b/Lib/scilab/scimisctypes.swg
@@ -0,0 +1,69 @@
+// Other primitive such as size_t and ptrdiff_t
+
+/*
+ * C-type: size_t
+ * Scilab type: double or int32
+ */
+
+%fragment(SWIG_AsVal_frag(size_t), "header", fragment="SWIG_Int_AsSize") {
+%#define SWIG_AsVal_size_t(scilabValue, valuePointer) SWIG_Int_AsSize(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_Int_AsSize", "header", fragment=SWIG_AsVal_frag(int))
+{
+SWIGINTERN int
+SWIG_Int_AsSize(void *pvApiCtx, SwigSciObject iVar, size_t *piValue, char *fname) {
+ int iValue = 0;
+ if (SWIG_AsVal_dec(int)(iVar, &iValue) != SWIG_OK)
+ return SWIG_ERROR;
+
+ if (piValue)
+ *piValue = (size_t) iValue;
+
+ return SWIG_OK;
+}
+}
+
+%fragment(SWIG_From_frag(size_t), "header", fragment="SWIG_Int_FromSize") {
+%#define SWIG_From_size_t(scilabValue) SWIG_Int_FromSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_Int_FromSize", "header", fragment=SWIG_From_frag(int))
+{
+SWIGINTERN int
+SWIG_Int_FromSize(void *pvApiCtx, int iVarOut, size_t iValue, char *fname) {
+ return SWIG_From_dec(int)((int)iValue);
+}
+}
+
+/*
+ * C-type: ptrdiff_t
+ * Scilab type: double or int32
+ */
+
+%fragment(SWIG_AsVal_frag(ptrdiff_t), "header", fragment="SWIG_Int_AsPtrDiff") {
+%#define SWIG_AsVal_ptrdiff_t(scilabValue, valuePointer) SWIG_Int_AsPtrDiff(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_Int_AsPtrDiff", "header", fragment=SWIG_AsVal_frag(int))
+{
+SWIGINTERN int
+SWIG_Int_AsPtrDiff(void *pvApiCtx, SwigSciObject iVar, ptrdiff_t *piValue, char *fname) {
+ int iValue = 0;
+ if (SWIG_AsVal_dec(int)(iVar, &iValue) != SWIG_OK)
+ return SWIG_ERROR;
+
+ if (piValue)
+ *piValue = (ptrdiff_t) iValue;
+
+ return SWIG_OK;
+}
+}
+
+%fragment(SWIG_From_frag(ptrdiff_t), "header", fragment="SWIG_Int_FromPtrDiff") {
+%#define SWIG_From_ptrdiff_t(scilabValue) SWIG_Int_FromPtrDiff(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_Int_FromPtrDiff", "header", fragment=SWIG_From_frag(int)) {
+SWIGINTERN int
+SWIG_Int_FromPtrDiff(void *pvApiCtx, int iVarOut, ptrdiff_t iValue, char *fname) {
+ return SWIG_From_dec(int)((int)iValue);
+}
+}
+
diff --git a/Lib/scilab/scipointer.swg b/Lib/scilab/scipointer.swg
new file mode 100644
index 000000000..8d0526d4d
--- /dev/null
+++ b/Lib/scilab/scipointer.swg
@@ -0,0 +1,32 @@
+/*
+ * POINTER
+ */
+%fragment("SWIG_ConvertPtr", "header") {
+#define SWIG_ConvertPtr(scilabValue, voidPointer, pointerDescriptor, flags) SwigScilabPtrToObject(pvApiCtx, scilabValue, voidPointer, pointerDescriptor, flags, SWIG_Scilab_GetFuncName())
+}
+
+%fragment("SWIG_NewPointerObj", "header") {
+#define SWIG_NewPointerObj(pointer, pointerDescriptor, flags) SwigScilabPtrFromObject(pvApiCtx, SWIG_Scilab_GetOutputPosition(), pointer, pointerDescriptor, flags)
+}
+
+/*
+ * FUNCTION POINTER
+ */
+%fragment("SWIG_ConvertFunctionPtr", "header") {
+#define SWIG_ConvertFunctionPtr(scilabValue, voidPointer, pointerDescriptor) SwigScilabPtrToObject(pvApiCtx, scilabValue, voidPointer, pointerDescriptor, 0, SWIG_Scilab_GetFuncName())
+}
+
+%fragment("SWIG_NewFunctionPtrObj", "header") {
+#define SWIG_NewFunctionPtrObj(pointer, pointerDescriptor) SwigScilabPtrFromObject(pvApiCtx, SWIG_Scilab_GetOutputPosition(), pointer, pointerDescriptor, 0)
+}
+// No fragment used here, the functions "SwigScilabPtrToObject" and "SwigScilabPtrFromObject" are defined in sciruntime.swg
+
+/*
+ * C++ member pointers, ie, member methods
+ */
+%fragment("SWIG_NewMemberObj", "header") {
+#define SWIG_NewMemberObj(ptr, sz, tp) SWIG_Scilab_NewMemberObj(pvApiCtx, $result, ptr, sz, tp)
+}
+%fragment("SWIG_ConvertMember", "header") {
+#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Scilab_ConvertPacked(pvApiCtx, obj, ptr, sz, ty, SWIG_Scilab_GetFuncName())
+}
diff --git a/Lib/scilab/sciprimtypes.swg b/Lib/scilab/sciprimtypes.swg
new file mode 100644
index 000000000..b5e30d932
--- /dev/null
+++ b/Lib/scilab/sciprimtypes.swg
@@ -0,0 +1,23 @@
+%include