Merge branch 'gsoc2012-scilab'
* gsoc2012-scilab: (800 commits) Cosmetic changes in a few test cases Scilab testcase fix Fix preproc_line_file test Fix 'not defined SWIGSCILAB' in testcases Add missing SWIGSCILAB in wrappers and fix unions test for non-scilab languages scilab: other doc minor fixes cosmetic changes in doc remove -nobuilder option remove useless direct_gateway function in wrapper scilab: fix throw_exception test Scilab command line options put in alphabetical order and some html tweaks Fix typo Scilab cosmetics Scilab makefile tidyup change 'Module' section to 'Builder modes' and other fixes reduce slightly the gateway source update doc fix failing unit tests with Scilab V6 fix buildermode error with Scilab V6 fix Scilab V6 support after merge of gateway & wrapper sources do no generate builder by default gateway source is moved into wrapper source beautify scilab.cxx Check for pkg-config before attempting to use it in configure Travis: No need for parallel builds for Scilab now since removing builder Scilab minor coding improvements scilab: test li_std_string_extra is fixed by previous commit scilab: fix std::string length issue scilab: simplify builder script file scilab: rename build command line options scilab: update .gitignore scilab: add the SWIG banner to the generated gateway XML scilab: remove outputlibrary option + renaming module to gateway scilab: fix compilation warnings in primitive_types test scilab: fix matrix2 example compilation warnings scilab: fix primitive types test compilation warnings scilab: fix compilation error in scilab 5.3.3 scilab: fix scilab include search regression in configure.ac scilab: fix test-suite makefiles and util scripts for standard build tools scilab: fix matrix2 example module name scilab: build now examples/tests with standard tools in (no more builder.sce) scilab: fix gateway entry point name scilab: swig generates loader script scilab: fix generated gateway source (missing include, entry point name) scilab: fix segmentation fault scilab: generate gateway source with swig scilab: change swig options, new option -gatewayxml, remove -internalmodule scilab: support typed constants (U UL L) in scilabconst(1) scilab: fix SWIG_SciString_FromChar compilation error on some compilers scilab: fix union and nested tests (they are C and not CPP tests) scilab: fix preproc_line_file test scilab: fix unions test scilab: fix nested test scilab: fix li_std_combinations test scilab: fix template_nested test scilab: fix li_boost_shared_ptr test scilab: fix tests having too long identifier names scilab: fix int typemaps (functions and fragment names) scilab: fix segfault scilab: fix tests having too long identifier names scilab: fix allprotected test scilab: truncates too long (struct, class) member names scilab: fix li_std_string_extra test, missing std_char_traits.i scilab: fix li_std_string_extra, missing lib std_basic_string.i scilab: add li_std_string_extra test scilab: truncates too long identifier names (in addition to display warnings) scilab: fix li_std_except test error codes scilab: fix tests returning wrong error code scilab: fix test-suite (scripts were not executed) scilab: rearrange some comments scilab: in builder.sce use absolute path for source files scilab: fix C++ examples cleaning More clear description of buildverbositylevel scilab: fix Examples Makefile exit code scilab: remove useless SWIG_Scilab_GetOutputPositionAndReset() scilab: rename function name management routines scilab: fix li_std_vector test scilab: rename wrapper global variable fname to SwigFuncName Revert "scilab: remove useless SWIG_Scilab_SetOutput() second parameter" Revert "scilab: fix compilation error (extra parenthesis)" Revert "scilab: fix compilation error (too many args in SWIG_Scilab_SetOutput)" scilab: display loading errors in examples scilab: fix compilation error (too many args in SWIG_Scilab_SetOutput) scilab: fix compilation error (extra parenthesis) scilab: fix wrong code in generated script builder.sce scilab: remove useless SWIG_Scilab_SetOutput() second parameter scilab: remove error messages in example contract scilab: remove example matrix2 warnings Scilab parameter name changes Fix previous commit. Correct global variable name in Scilab wrappers Suppress testcase warning Synchronize common scilab examples with other languages File renames in Scilab std_list example Have just one Scilab constants example Use CXXSRCS for testing for Scilab like other languages Scilab overloaded method testcase warning suppression Suppress Identifier name exceeds 24 characters warning in Scilab example Add RUNPIPE back in for Scilab examples Scilab long identifier name warning message improvement Scilab minor build system improvement scilab: fix doc scilab: apply K&R coding style for typemaps scilab: file name is 'example' as in other examples scilab: use SWIG_Scilab_Raise() for exceptions scilab: macro SWIG_SCILAB_ERROR (value 999 by default) for SWIG errors scilab: use a macro instead of 999 for error code scilab: add missing exit in template example scilab: template example same as in other languages scilab: fix comment typo scilab: remove indentation in example scilab; new example scilab_const scilab: enum example same as in other languages scilab: constants example same as in other languages scilab: hide too long identifier warnings scilab: fix last commit on warnings scilab: set travis warning options scilab: apply boost_shared_ptr fix scilab: use language specific warnings for too long identifier names scilab: fix String & printf previous commit scilab: display truncated name in long identifier name warnings scilab: display by default warnings for long identifier names scilab: use String and Printf in scilab.cxx scilab: no need to use prefix "g_" for global names scilab: coding style remove "_" from parameter names scilab: coding style: remove "_" from parameter names scilab: fix missing include in li_std_container_typemaps test scilab: clean contract example scilab: fix Examples makefile missing separator scilab: coding style: remove "_" from parameter names scilab: fix typo error scilab: library stl.i include same libraries as in other languages scilab: fix exit code in Example makefile scilab: code style: remove underscore in parameters (first part) scilab: rollback INCLUDE scilab: rollback (INCLUDE) scilab: remove debug stuff scilab: use TARGET in Examples Makefile scilab: reorder arguments scilab: remove useless SCRIPTDIR scilab: simplify Examples makefile (removing INCLUDE stuff) scilab: simplify Examples makefile scilab: remove debug stuff scilab: remove debug stuff scilab: remove debug stuff scilab: fix copy of additional sources in current dir + delete it scilab: test fix example contract by copying first sources in current dir scilab: fix build error management scilab: debug travis scilab: rollback scilab: test copy scilab: test copy scilab: test copy scilab: test example contract another source scilab: test example contract with another source scilab: debug travis scilab: test copy source scilab: test enum example, source renamed scilab: test: example contract, source renamed scilab: in example makefiles, use abspath for additional sources scilab: fix example runme path scilab: test travis without class example debug travis Revert "scilab: in Examples makefile use relative path for additional sources" scilab: in Examples makefile use relative path for additional sources scilab: use swig -o option in Examples makefile scilab: debug travis scilab: debug travis scilab: debug travis scilab: debug travis scilab: debug travis (examples) scilab: fix contract example (catch expected errors) scilab: generate builder.sce in currrent dir scilab: remove debug stuff Beautify scilab.cxx Use Insert instead of DohInsertitem Remove author names - they are in the COPYRIGHT file Cosmetic test case change Fix ancient bad merge from trunk Run overload_arrays testcase in all languages not just Scilab Better Scilab workaround for testcase Fix ancient merge error Revert "scilab: implement enum_var test" scilab: debug travis scilab: fix struct example makefile scilab: fix Example Makefile again scilab: Example makefile, try again scilab: fix last commit scilab: fix Example makefile scilab: fix last commit scilab: Examples makefile, remove scilab args macro and checks scilab: fix commit fragment stdint scilab: in configure, use pkg-config + disable scilab if headers not found scilab: rename swig_this(), swig_ptr() to SWIG_this(), SWIG_ptr() scilab: rename fragment scilab: remove matrix2 example README scilab: fix test-suite: change to test dir before running test scilab: fix test-suite clean scilab: no need to copy runme script in in-source build Update scilab examples from other languages ...
This commit is contained in:
commit
290aa164bc
266 changed files with 15287 additions and 130 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
103
COPYRIGHT
103
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 <MartinFroehlich@ACM.org> (Guile)
|
||||
Marcio Luis Teixeira <marciot@holly.colostate.edu> (Guile)
|
||||
Duncan Temple Lang (R)
|
||||
Miklos Vajna <vmiklos@frugalware.org> (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 <MartinFroehlich@ACM.org> (Guile)
|
||||
Marcio Luis Teixeira <marciot@holly.colostate.edu> (Guile)
|
||||
Duncan Temple Lang (R)
|
||||
Miklos Vajna <vmiklos@frugalware.org> (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 <sploving1@163.com> (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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
2002
Doc/Manual/Scilab.html
Normal file
2002
Doc/Manual/Scilab.html
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -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 ######
|
||||
##################################################################
|
||||
|
|
|
|||
16
Examples/scilab/check.list
Normal file
16
Examples/scilab/check.list
Normal file
|
|
@ -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
|
||||
|
||||
15
Examples/scilab/class/Makefile
Normal file
15
Examples/scilab/class/Makefile
Normal file
|
|
@ -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
|
||||
28
Examples/scilab/class/example.cxx
Normal file
28
Examples/scilab/class/example.cxx
Normal file
|
|
@ -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;
|
||||
}
|
||||
34
Examples/scilab/class/example.h
Normal file
34
Examples/scilab/class/example.h
Normal file
|
|
@ -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();
|
||||
};
|
||||
9
Examples/scilab/class/example.i
Normal file
9
Examples/scilab/class/example.i
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
/* File : example.i */
|
||||
%module example
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
||||
/* Let's just grab the original header file here */
|
||||
%include "example.h"
|
||||
52
Examples/scilab/class/runme.sci
Normal file
52
Examples/scilab/class/runme.sci
Normal file
|
|
@ -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
|
||||
15
Examples/scilab/constants/Makefile
Normal file
15
Examples/scilab/constants/Makefile
Normal file
|
|
@ -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
|
||||
30
Examples/scilab/constants/example.i
Normal file
30
Examples/scilab/constants/example.i
Normal file
|
|
@ -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;
|
||||
|
||||
|
||||
18
Examples/scilab/constants/runme.sci
Normal file
18
Examples/scilab/constants/runme.sci
Normal file
|
|
@ -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
|
||||
15
Examples/scilab/contract/Makefile
Normal file
15
Examples/scilab/contract/Makefile
Normal file
|
|
@ -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
|
||||
23
Examples/scilab/contract/example.c
Normal file
23
Examples/scilab/contract/example.c
Normal file
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
21
Examples/scilab/contract/example.i
Normal file
21
Examples/scilab/contract/example.i
Normal file
|
|
@ -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;
|
||||
%}
|
||||
46
Examples/scilab/contract/runme.sci
Normal file
46
Examples/scilab/contract/runme.sci
Normal file
|
|
@ -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
|
||||
|
||||
|
||||
|
||||
15
Examples/scilab/enum/Makefile
Normal file
15
Examples/scilab/enum/Makefile
Normal file
|
|
@ -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
|
||||
37
Examples/scilab/enum/example.cxx
Normal file
37
Examples/scilab/enum/example.cxx
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/* File : example.c */
|
||||
|
||||
#include "example.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void Foo::enum_test(speed s) {
|
||||
if (s == IMPULSE) {
|
||||
printf("IMPULSE speed\n");
|
||||
} else if (s == WARP) {
|
||||
printf("WARP speed\n");
|
||||
} else if (s == LUDICROUS) {
|
||||
printf("LUDICROUS speed\n");
|
||||
} else {
|
||||
printf("Unknown speed\n");
|
||||
}
|
||||
}
|
||||
|
||||
void enum_test(color c, Foo::speed s) {
|
||||
if (c == RED) {
|
||||
printf("color = RED, ");
|
||||
} else if (c == BLUE) {
|
||||
printf("color = BLUE, ");
|
||||
} else if (c == GREEN) {
|
||||
printf("color = GREEN, ");
|
||||
} else {
|
||||
printf("color = Unknown color!, ");
|
||||
}
|
||||
if (s == Foo::IMPULSE) {
|
||||
printf("speed = IMPULSE speed\n");
|
||||
} else if (s == Foo::WARP) {
|
||||
printf("speed = WARP speed\n");
|
||||
} else if (s == Foo::LUDICROUS) {
|
||||
printf("speed = LUDICROUS speed\n");
|
||||
} else {
|
||||
printf("speed = Unknown speed!\n");
|
||||
}
|
||||
}
|
||||
13
Examples/scilab/enum/example.h
Normal file
13
Examples/scilab/enum/example.h
Normal file
|
|
@ -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);
|
||||
|
||||
10
Examples/scilab/enum/example.i
Normal file
10
Examples/scilab/enum/example.i
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
/* File : example.i */
|
||||
%module example
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
||||
%include "example.h"
|
||||
|
||||
|
||||
36
Examples/scilab/enum/runme.sci
Normal file
36
Examples/scilab/enum/runme.sci
Normal file
|
|
@ -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
|
||||
15
Examples/scilab/funcptr/Makefile
Normal file
15
Examples/scilab/funcptr/Makefile
Normal file
|
|
@ -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
|
||||
19
Examples/scilab/funcptr/example.c
Normal file
19
Examples/scilab/funcptr/example.c
Normal file
|
|
@ -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;
|
||||
9
Examples/scilab/funcptr/example.h
Normal file
9
Examples/scilab/funcptr/example.h
Normal file
|
|
@ -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);
|
||||
|
||||
11
Examples/scilab/funcptr/example.i
Normal file
11
Examples/scilab/funcptr/example.i
Normal file
|
|
@ -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);
|
||||
|
||||
22
Examples/scilab/funcptr/runme.sci
Normal file
22
Examples/scilab/funcptr/runme.sci
Normal file
|
|
@ -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
|
||||
|
||||
|
||||
|
||||
15
Examples/scilab/matrix/Makefile
Normal file
15
Examples/scilab/matrix/Makefile
Normal file
|
|
@ -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
|
||||
61
Examples/scilab/matrix/example.c
Normal file
61
Examples/scilab/matrix/example.c
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/* FILE : matrix.c : some simple 4x4 matrix operations */
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
36
Examples/scilab/matrix/example.i
Normal file
36
Examples/scilab/matrix/example.i
Normal file
|
|
@ -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*/
|
||||
|
||||
}
|
||||
43
Examples/scilab/matrix/runme.sci
Normal file
43
Examples/scilab/matrix/runme.sci
Normal file
|
|
@ -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
|
||||
15
Examples/scilab/matrix2/Makefile
Normal file
15
Examples/scilab/matrix2/Makefile
Normal file
|
|
@ -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
|
||||
118
Examples/scilab/matrix2/example.c
Normal file
118
Examples/scilab/matrix2/example.c
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
// Double matrix functions
|
||||
|
||||
double sumDoubleMatrix(double *inputMatrix, int nbRow, int nbCol)
|
||||
{
|
||||
int i;
|
||||
double total = 0.0;
|
||||
for (i=0; i<nbRow*nbCol; i++)
|
||||
{
|
||||
total += inputMatrix[i];
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
void squareDoubleMatrix(double *inputMatrix, int nbRow, int nbCol, double** resultMatrix, int* nbRowRes, int* nbColRes)
|
||||
{
|
||||
int i;
|
||||
int size = nbRow * nbCol;
|
||||
*nbRowRes = nbRow;
|
||||
*nbColRes = nbCol;
|
||||
*resultMatrix = (double*) malloc(size * sizeof(double));
|
||||
for (i=0; i<size; i++)
|
||||
{
|
||||
(*resultMatrix)[i] = inputMatrix[i] * inputMatrix[i];
|
||||
}
|
||||
}
|
||||
|
||||
void getDoubleMatrix(double **resultMatrix, int *nbRowRes, int *nbColRes)
|
||||
{
|
||||
int i;
|
||||
int size;
|
||||
*nbRowRes = 5;
|
||||
*nbColRes = 3;
|
||||
size = (*nbRowRes) * (*nbColRes);
|
||||
*resultMatrix = (double*) malloc(size * sizeof(double));
|
||||
for (i=0; i<size; i++)
|
||||
{
|
||||
(*resultMatrix)[i] = i*2;
|
||||
}
|
||||
}
|
||||
|
||||
// Integer matrix functions
|
||||
|
||||
int sumIntegerMatrix(int *inputMatrix, int nbRow, int nbCol)
|
||||
{
|
||||
int i;
|
||||
int total = 0;
|
||||
for (i=0; i<nbRow*nbCol; i++)
|
||||
{
|
||||
total += inputMatrix[i];
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
void squareIntegerMatrix(int *inputMatrix, int nbRow, int nbCol, int** resultMatrix, int* nbRowRes, int* nbColRes)
|
||||
{
|
||||
int i;
|
||||
int size = nbRow * nbCol;
|
||||
*nbRowRes = nbRow;
|
||||
*nbColRes = nbCol;
|
||||
*resultMatrix = (int*) malloc(size * sizeof(int));
|
||||
for (i=0; i<size; i++)
|
||||
{
|
||||
(*resultMatrix)[i] = inputMatrix[i] * inputMatrix[i];
|
||||
}
|
||||
}
|
||||
|
||||
void getIntegerMatrix(int **resultMatrix, int *nbRowRes, int *nbColRes)
|
||||
{
|
||||
int i;
|
||||
int size;
|
||||
*nbRowRes = 5;
|
||||
*nbColRes = 3;
|
||||
size = (*nbRowRes) * (*nbColRes);
|
||||
*resultMatrix = (int*) malloc(size * sizeof(int));
|
||||
for (i=0; i<size; i++)
|
||||
{
|
||||
(*resultMatrix)[i] = i*2;
|
||||
}
|
||||
}
|
||||
|
||||
// String matrix functions
|
||||
|
||||
char* concatStringVector(char **inputVector, int size)
|
||||
{
|
||||
int i;
|
||||
int resultSize;
|
||||
char *result;
|
||||
resultSize = 3 * size + 1;
|
||||
result = calloc(resultSize, sizeof(char));
|
||||
strcpy(result, inputVector[0]);
|
||||
for (i=1; i<size; i++)
|
||||
{
|
||||
strcat(result, " ");
|
||||
strcat(result, (const char*) inputVector[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void getStringVector(char ***resultVector, int *sizeRes)
|
||||
{
|
||||
int i;
|
||||
*sizeRes = 12;
|
||||
*resultVector = (char**) malloc((*sizeRes) * sizeof(char*));
|
||||
for (i=0; i<*sizeRes; i++)
|
||||
{
|
||||
char* pc = (char*) calloc(3, sizeof(char));
|
||||
sprintf(pc, "%d", i);
|
||||
(*resultVector)[i] = pc;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
26
Examples/scilab/matrix2/example.i
Executable file
26
Examples/scilab/matrix2/example.i
Executable file
|
|
@ -0,0 +1,26 @@
|
|||
%module example
|
||||
|
||||
%include matrix.i
|
||||
|
||||
%apply (double *IN, int IN_ROWCOUNT, int IN_COLCOUNT) { (double *inputMatrix, int nbRow, int nbCol) }
|
||||
%apply (double **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT) { (double **resultMatrix, int *nbRowRes, int *nbColRes) }
|
||||
|
||||
%apply (int *IN, int IN_ROWCOUNT, int IN_COLCOUNT) { (int *inputMatrix, int nbRow, int nbCol) }
|
||||
%apply (int **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT) { (int **resultMatrix, int *nbRowRes, int *nbColRes) }
|
||||
|
||||
%apply (char **IN, int IN_SIZE) { (char **inputVector, int size) }
|
||||
%apply (char ***OUT, int *OUT_SIZE) { (char ***resultVector, int *sizeRes) }
|
||||
|
||||
%inline %{
|
||||
extern double sumDoubleMatrix(double *inputMatrix, int nbRow, int nbCol);
|
||||
extern void squareDoubleMatrix(double *inputMatrix, int nbRow, int nbCol, double **resultMatrix, int *nbRowRes, int *nbColRes);
|
||||
extern void getDoubleMatrix(double **resultMatrix, int *nbRowRes, int *nbColRes);
|
||||
|
||||
extern int sumIntegerMatrix(int *inputMatrix, int nbRow, int nbCol);
|
||||
extern void squareIntegerMatrix(int *inputMatrix, int nbRow, int nbCol, int **resultMatrix, int *nbRowRes, int *nbColRes);
|
||||
extern void getIntegerMatrix(int **resultMatrix, int *nbRowRes, int *nbColRes);
|
||||
|
||||
extern char* concatStringVector(char **inputVector, int size);
|
||||
extern void getStringVector(char ***resultVector, int *sizeRes);
|
||||
%}
|
||||
|
||||
24
Examples/scilab/matrix2/main.c
Normal file
24
Examples/scilab/matrix2/main.c
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
double sumitems(double *first, int nbRow, int nbCol);
|
||||
void main(){
|
||||
/**
|
||||
* --> 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]);
|
||||
}
|
||||
}
|
||||
51
Examples/scilab/matrix2/runme.sci
Normal file
51
Examples/scilab/matrix2/runme.sci
Normal file
|
|
@ -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
|
||||
|
||||
|
||||
|
||||
15
Examples/scilab/pointer/Makefile
Normal file
15
Examples/scilab/pointer/Makefile
Normal file
|
|
@ -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
|
||||
16
Examples/scilab/pointer/example.c
Normal file
16
Examples/scilab/pointer/example.c
Normal file
|
|
@ -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;
|
||||
}
|
||||
30
Examples/scilab/pointer/example.i
Normal file
30
Examples/scilab/pointer/example.i
Normal file
|
|
@ -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);
|
||||
|
||||
|
||||
|
||||
|
||||
47
Examples/scilab/pointer/runme.sci
Normal file
47
Examples/scilab/pointer/runme.sci
Normal file
|
|
@ -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
|
||||
|
||||
15
Examples/scilab/simple/Makefile
Normal file
15
Examples/scilab/simple/Makefile
Normal file
|
|
@ -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
|
||||
18
Examples/scilab/simple/example.c
Normal file
18
Examples/scilab/simple/example.c
Normal file
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
7
Examples/scilab/simple/example.i
Normal file
7
Examples/scilab/simple/example.i
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
/* File : example.i */
|
||||
%module example
|
||||
|
||||
%inline %{
|
||||
extern int gcd(int x, int y);
|
||||
extern double Foo;
|
||||
%}
|
||||
29
Examples/scilab/simple/runme.sci
Normal file
29
Examples/scilab/simple/runme.sci
Normal file
|
|
@ -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
|
||||
|
||||
15
Examples/scilab/std_list/Makefile
Normal file
15
Examples/scilab/std_list/Makefile
Normal file
|
|
@ -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
|
||||
61
Examples/scilab/std_list/example.cxx
Normal file
61
Examples/scilab/std_list/example.cxx
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/* File : example.cpp */
|
||||
|
||||
#include "example.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <numeric>
|
||||
#include <sstream>
|
||||
|
||||
|
||||
template <typename T>
|
||||
std::list<T> concat_list(const std::list<T> list, const std::list<T> other_list)
|
||||
{
|
||||
std::list<T> out_list(list);
|
||||
out_list.insert(out_list.end(), other_list.begin(), other_list.end());
|
||||
return out_list;
|
||||
}
|
||||
|
||||
// int lists
|
||||
|
||||
std::list<int> create_integer_list(const int rangemin, const int rangemax)
|
||||
{
|
||||
std::list<int> out_list;
|
||||
for (int i = rangemin; i <= rangemax; i++)
|
||||
{
|
||||
out_list.push_back(i);
|
||||
}
|
||||
return out_list;
|
||||
}
|
||||
|
||||
int sum_integer_list(const std::list<int>& list)
|
||||
{
|
||||
return std::accumulate(list.begin(), list.end(), 0);
|
||||
}
|
||||
|
||||
std::list<int> concat_integer_list(const std::list<int> list, const std::list<int> other_list)
|
||||
{
|
||||
return concat_list<int>(list, other_list);
|
||||
}
|
||||
|
||||
// string lists
|
||||
|
||||
std::list<std::string> create_string_list(const char* svalue)
|
||||
{
|
||||
std::list<std::string> out_list;
|
||||
std::string str(svalue);
|
||||
|
||||
std::istringstream iss(str);
|
||||
std::copy(std::istream_iterator<std::string>(iss),
|
||||
std::istream_iterator<std::string>(),
|
||||
std::inserter<std::list<std::string> >(out_list, out_list.begin()));
|
||||
|
||||
return out_list;
|
||||
}
|
||||
|
||||
std::list<std::string> concat_string_list(const std::list<std::string> list, const std::list<std::string> other_list)
|
||||
{
|
||||
return concat_list<std::string>(list, other_list);
|
||||
}
|
||||
|
||||
14
Examples/scilab/std_list/example.h
Normal file
14
Examples/scilab/std_list/example.h
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
/* File : example.h */
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
|
||||
// integer lists
|
||||
std::list<int> create_integer_list(const int size, const int value);
|
||||
int sum_integer_list(const std::list<int>& list);
|
||||
std::list<int> concat_integer_list(const std::list<int> list, const std::list<int> other_list);
|
||||
|
||||
// string lists
|
||||
std::list<std::string> create_string_list(const char* value);
|
||||
std::list<std::string> concat_string_list(const std::list<std::string> list, const std::list<std::string> other_list);
|
||||
19
Examples/scilab/std_list/example.i
Normal file
19
Examples/scilab/std_list/example.i
Normal file
|
|
@ -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<int>;
|
||||
%template(StringList) list<std::string>;
|
||||
}
|
||||
|
||||
%include "example.h"
|
||||
39
Examples/scilab/std_list/runme.sci
Normal file
39
Examples/scilab/std_list/runme.sci
Normal file
|
|
@ -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
|
||||
|
||||
15
Examples/scilab/std_vector/Makefile
Normal file
15
Examples/scilab/std_vector/Makefile
Normal file
|
|
@ -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
|
||||
25
Examples/scilab/std_vector/example.h
Normal file
25
Examples/scilab/std_vector/example.h
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/* File : example.h */
|
||||
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <numeric>
|
||||
|
||||
double average(std::vector<int> v) {
|
||||
return std::accumulate(v.begin(),v.end(),0.0)/v.size();
|
||||
}
|
||||
|
||||
std::vector<double> half(const std::vector<double>& v) {
|
||||
std::vector<double> w(v);
|
||||
for (unsigned int i=0; i<w.size(); i++)
|
||||
w[i] /= 2.0;
|
||||
return w;
|
||||
}
|
||||
|
||||
void halve_in_place(std::vector<double>& v) {
|
||||
// would you believe this is the same as the above?
|
||||
std::transform(v.begin(),v.end(),v.begin(),
|
||||
std::bind2nd(std::divides<double>(),2.0));
|
||||
}
|
||||
|
||||
|
||||
19
Examples/scilab/std_vector/example.i
Normal file
19
Examples/scilab/std_vector/example.i
Normal file
|
|
@ -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<int>;
|
||||
%template(DoubleVector) vector<double>;
|
||||
}
|
||||
|
||||
/* Let's just grab the original header file here */
|
||||
%include "example.h"
|
||||
|
||||
37
Examples/scilab/std_vector/runme.sci
Normal file
37
Examples/scilab/std_vector/runme.sci
Normal file
|
|
@ -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<int>
|
||||
|
||||
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<double>
|
||||
|
||||
v = new_DoubleVector();
|
||||
for i = 1:4
|
||||
DoubleVector_push_back(v, i);
|
||||
end;
|
||||
disp(half(v));
|
||||
|
||||
exit
|
||||
|
||||
15
Examples/scilab/struct/Makefile
Normal file
15
Examples/scilab/struct/Makefile
Normal file
|
|
@ -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
|
||||
11
Examples/scilab/struct/example.i
Normal file
11
Examples/scilab/struct/example.i
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
%module example
|
||||
|
||||
%rename(Bar) Foo;
|
||||
|
||||
%inline %{
|
||||
typedef struct {
|
||||
int x;
|
||||
} Foo;
|
||||
|
||||
%}
|
||||
|
||||
18
Examples/scilab/struct/runme.sci
Normal file
18
Examples/scilab/struct/runme.sci
Normal file
|
|
@ -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
|
||||
15
Examples/scilab/template/Makefile
Normal file
15
Examples/scilab/template/Makefile
Normal file
|
|
@ -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
|
||||
32
Examples/scilab/template/example.h
Normal file
32
Examples/scilab/template/example.h
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/* File : example.h */
|
||||
|
||||
// Some template definitions
|
||||
|
||||
template<class T> T max(T a, T b) { return a>b ? a : b; }
|
||||
|
||||
template<class T> 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
|
||||
};
|
||||
|
||||
17
Examples/scilab/template/example.i
Normal file
17
Examples/scilab/template/example.i
Normal file
|
|
@ -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<int>;
|
||||
%template(maxdouble) max<double>;
|
||||
%template(vecint) vector<int>;
|
||||
%template(vecdouble) vector<double>;
|
||||
|
||||
45
Examples/scilab/template/runme.sci
Normal file
45
Examples/scilab/template/runme.sci
Normal file
|
|
@ -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
|
||||
|
||||
15
Examples/scilab/variables/Makefile
Normal file
15
Examples/scilab/variables/Makefile
Normal file
|
|
@ -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
|
||||
95
Examples/scilab/variables/example.c
Normal file
95
Examples/scilab/variables/example.c
Normal file
|
|
@ -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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "example.h"
|
||||
|
||||
int ivar = 0;
|
||||
short svar = 0;
|
||||
long lvar = 0;
|
||||
unsigned int uivar = 0;
|
||||
unsigned short usvar = 0;
|
||||
unsigned long ulvar = 0;
|
||||
signed char scvar = 0;
|
||||
unsigned char ucvar = 0;
|
||||
char cvar = 0;
|
||||
float fvar = 0;
|
||||
double dvar = 0;
|
||||
char *strvar = 0;
|
||||
const char cstrvar[] = "Goodbye";
|
||||
int *iptrvar = 0;
|
||||
char name[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);
|
||||
}
|
||||
6
Examples/scilab/variables/example.h
Normal file
6
Examples/scilab/variables/example.h
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
/* File: example.h */
|
||||
|
||||
typedef struct {
|
||||
int x,y;
|
||||
} Point;
|
||||
|
||||
52
Examples/scilab/variables/example.i
Normal file
52
Examples/scilab/variables/example.i
Normal file
|
|
@ -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();
|
||||
%}
|
||||
|
||||
73
Examples/scilab/variables/runme.sci
Normal file
73
Examples/scilab/variables/runme.sci
Normal file
|
|
@ -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
|
||||
|
||||
|
|
@ -8,6 +8,11 @@
|
|||
|
||||
%include "std_string.i"
|
||||
|
||||
#ifdef SWIGSCILAB
|
||||
%rename(ProcBase) ProtectedBase;
|
||||
%rename(PubBase) PublicBase;
|
||||
#endif
|
||||
|
||||
%feature("director") PublicBase;
|
||||
%feature("director") ProtectedBase;
|
||||
|
||||
|
|
|
|||
|
|
@ -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 &};
|
||||
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
%module array_member
|
||||
|
||||
#if defined(SWIGSCILAB)
|
||||
%rename(RayPkt) RayPacketData;
|
||||
#endif
|
||||
|
||||
%inline %{
|
||||
|
||||
typedef struct Foo {
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
|
|
|||
|
|
@ -7,6 +7,10 @@ This test case tests that various types of arrays are working.
|
|||
#include <stdlib.h>
|
||||
%}
|
||||
|
||||
#if defined(SWIGSCILAB)
|
||||
%rename(ArrSt) ArrayStruct;
|
||||
#endif
|
||||
|
||||
%inline %{
|
||||
#define ARRAY_LEN 2
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
%}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <stdio.h>
|
||||
%}
|
||||
#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;
|
||||
|
|
|
|||
|
|
@ -308,6 +308,7 @@ CPP_TEST_CASES += \
|
|||
operator_pointer_ref \
|
||||
operbool \
|
||||
ordering \
|
||||
overload_arrays \
|
||||
overload_bool \
|
||||
overload_copy \
|
||||
overload_extend \
|
||||
|
|
|
|||
|
|
@ -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. */
|
||||
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@
|
|||
%nocopyctor Bar<double>;
|
||||
|
||||
%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 T>
|
||||
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<Space::Flow>::vector(size_type);
|
||||
%ignore std::vector<Space::Flow>::resize(size_type);
|
||||
|
|
@ -126,7 +126,7 @@ public:
|
|||
template <class T>
|
||||
struct ModelUtils_T {};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
||||
|
|
@ -144,13 +144,13 @@ namespace Space1 {
|
|||
class TotalReturnSwap {
|
||||
public:
|
||||
TotalReturnSwap() {}
|
||||
};
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class TotalReturnSwap_T {
|
||||
public:
|
||||
TotalReturnSwap_T() {}
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 <iostream>
|
||||
%}
|
||||
|
|
@ -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
|
||||
{
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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<T1,T2> _f;
|
||||
pair<T1,T2> _g;
|
||||
|
|
|
|||
|
|
@ -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<KlassDerived>& sptr) {
|
|||
long use_count(const SwigBoost::shared_ptr<Klass>& sptr) {
|
||||
return sptr.use_count();
|
||||
}
|
||||
const SwigBoost::shared_ptr<Klass>& ref_1() {
|
||||
const SwigBoost::shared_ptr<Klass>& ref_1() {
|
||||
static SwigBoost::shared_ptr<Klass> sptr;
|
||||
return sptr;
|
||||
}
|
||||
|
|
@ -334,7 +344,11 @@ template <class T1, class T2> struct Base {
|
|||
};
|
||||
%}
|
||||
|
||||
#if !defined(SWIGSCILAB)
|
||||
%template(BaseIntDouble) Base<int, double>;
|
||||
#else
|
||||
%template(BaseIDbl) Base<int, double>;
|
||||
#endif
|
||||
|
||||
%inline %{
|
||||
template <class T1, class T2> struct Pair : Base<T1, T2> {
|
||||
|
|
@ -356,9 +370,9 @@ SwigBoost::shared_ptr< Pair<int, double> > 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
|
||||
|
|
|
|||
|
|
@ -9,15 +9,23 @@
|
|||
%template(PairIntString) std::pair<int, std::string>;
|
||||
|
||||
%template(VectorPairIntString) std::vector< std::pair<int, std::string> >;
|
||||
%template(PairIntVectorString) std::pair< int, std::vector<std::string> >;
|
||||
|
||||
%template(VectorVectorString) std::vector< std::vector<std::string> >;
|
||||
|
||||
#if !defined(SWIGSCILAB)
|
||||
%template(PairIntVectorString) std::pair< int, std::vector<std::string> >;
|
||||
%template(PairIntPairIntString) std::pair< int, std::pair<int, std::string> >;
|
||||
#else
|
||||
%template(PairIntVecStr) std::pair< int, std::vector<std::string> >;
|
||||
%template(PairIntPairIntStr) std::pair< int, std::pair<int, std::string> >;
|
||||
#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<double, std::string> >;
|
||||
|
||||
|
||||
|
|
|
|||
132
Examples/test-suite/li_std_container_typemaps.i
Normal file
132
Examples/test-suite/li_std_container_typemaps.i
Normal file
|
|
@ -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 <vector>
|
||||
#include <list>
|
||||
#include <deque>
|
||||
#include <set>
|
||||
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <numeric>
|
||||
|
||||
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<typename T> T binaryOperation(T x, T y) {
|
||||
return static_cast<T>(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<typename SeqCont>
|
||||
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<value_type>);
|
||||
}
|
||||
|
||||
static value_type ref_container(const SeqCont& container) {
|
||||
return std::accumulate(container.begin(), container.end(), value_type(),
|
||||
binaryOperation<value_type>);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, class Container>
|
||||
Container ret_container(const T value1, const T value2) {
|
||||
return sequence_container<Container>::ret_container(value1, value2);
|
||||
}
|
||||
template<typename T, class Container>
|
||||
T val_container(const Container container) {
|
||||
return sequence_container<Container >::val_container(container);
|
||||
}
|
||||
template<typename T, class Container>
|
||||
T ref_container(const Container& container) {
|
||||
return sequence_container<Container >::ref_container(container);
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
||||
%define %instantiate_containers_templates(TYPE...)
|
||||
namespace std
|
||||
{
|
||||
%template(TYPE ## _vector) std::vector<TYPE>;
|
||||
%template(TYPE ## _list) std::list<TYPE>;
|
||||
%template(TYPE ## _deque) std::deque<TYPE>;
|
||||
%template(TYPE ## _set) std::set<TYPE>;
|
||||
%template(TYPE ## _multiset) std::multiset<TYPE>;
|
||||
}
|
||||
%enddef
|
||||
|
||||
%define %instantiate_containers_functions(TYPE...)
|
||||
namespace std
|
||||
{
|
||||
%template(ret_ ## TYPE ## _vector) ret_container<TYPE, std::vector<TYPE> >;
|
||||
%template(val_ ## TYPE ## _vector) val_container<TYPE, std::vector<TYPE> >;
|
||||
%template(ref_ ## TYPE ## _vector) ref_container<TYPE, std::vector<TYPE> >;
|
||||
%template(ret_ ## TYPE ## _list) ret_container<TYPE, std::list<TYPE> >;
|
||||
%template(val_ ## TYPE ## _list) val_container<TYPE, std::list<TYPE> >;
|
||||
%template(ref_ ## TYPE ## _list) ref_container<TYPE, std::list<TYPE> >;
|
||||
%template(ret_ ## TYPE ## _deque) ret_container<TYPE, std::deque<TYPE> >;
|
||||
%template(val_ ## TYPE ## _deque) val_container<TYPE, std::deque<TYPE> >;
|
||||
%template(ref_ ## TYPE ## _deque) ref_container<TYPE, std::deque<TYPE> >;
|
||||
%template(ret_ ## TYPE ## _set) ret_container<TYPE, std::set<TYPE> >;
|
||||
%template(val_ ## TYPE ## _set) val_container<TYPE, std::set<TYPE> >;
|
||||
%template(ref_ ## TYPE ## _set) ref_container<TYPE, std::set<TYPE> >;
|
||||
%template(ret_ ## TYPE ## _multiset) ret_container<TYPE, std::multiset<TYPE> >;
|
||||
%template(val_ ## TYPE ## _multiset) val_container<TYPE, std::multiset<TYPE> >;
|
||||
%template(ref_ ## TYPE ## _multiset) ref_container<TYPE, std::multiset<TYPE> >;
|
||||
}
|
||||
%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);
|
||||
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
%include <stdint.i>
|
||||
|
||||
%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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -73,12 +73,6 @@ see bottom for a set of possible tests
|
|||
%rename(OrOperator) operator ||;
|
||||
#endif
|
||||
|
||||
#ifdef SWIG_ALLEGRO_CL
|
||||
%{
|
||||
#include <stdio.h>
|
||||
%}
|
||||
#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 <stdio.h>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#include <iso646.h> /* for named logical operator, eg 'operator or' */
|
||||
|
|
|
|||
148
Examples/test-suite/overload_arrays.i
Normal file
148
Examples/test-suite/overload_arrays.i
Normal file
|
|
@ -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];}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -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 %{
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
90
Examples/test-suite/scilab/Makefile.in
Normal file
90
Examples/test-suite/scilab/Makefile.in
Normal file
|
|
@ -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:
|
||||
16
Examples/test-suite/scilab/abstract_access_runme.sci
Normal file
16
Examples/test-suite/scilab/abstract_access_runme.sci
Normal file
|
|
@ -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);
|
||||
11
Examples/test-suite/scilab/abstract_inherit_ok_runme.sci
Normal file
11
Examples/test-suite/scilab/abstract_inherit_ok_runme.sci
Normal file
|
|
@ -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);
|
||||
10
Examples/test-suite/scilab/abstract_inherit_runme.sci
Normal file
10
Examples/test-suite/scilab/abstract_inherit_runme.sci
Normal file
|
|
@ -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);
|
||||
10
Examples/test-suite/scilab/abstract_signature_runme.sci
Normal file
10
Examples/test-suite/scilab/abstract_signature_runme.sci
Normal file
|
|
@ -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);
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue