Another merge with master.
Change Doxygen error codes to start at 740 instead of at 720 as the latter was taken by Scilab in the meanwhile. Resolve conflicts in autodoc_runme.py once again.
This commit is contained in:
commit
300ccce46c
419 changed files with 18675 additions and 1315 deletions
24
.gitignore
vendored
24
.gitignore
vendored
|
|
@ -67,6 +67,7 @@ CCache/config.h
|
|||
CCache/config.log
|
||||
CCache/config.status
|
||||
Examples/Makefile
|
||||
Examples/d/example.mk
|
||||
Examples/guile/Makefile
|
||||
Examples/test-suite/*/Makefile
|
||||
Examples/xml/Makefile
|
||||
|
|
@ -121,16 +122,29 @@ Examples/test-suite/pike/*/
|
|||
Examples/test-suite/python/*/
|
||||
Examples/test-suite/r/*/
|
||||
Examples/test-suite/ruby/*/
|
||||
Examples/test-suite/scilab/*/
|
||||
Examples/test-suite/tcl/*/
|
||||
Examples/test-suite/uffi/*/
|
||||
*_wrap.c
|
||||
*_wrap.cxx
|
||||
*-gypcopy.cxx
|
||||
|
||||
# Scratch directories
|
||||
Examples/scratch
|
||||
|
||||
# Out of source tree build directories
|
||||
*build*/
|
||||
|
||||
########## Language specific files ##########
|
||||
|
||||
# C# generated files
|
||||
*_runme.exe.mdb
|
||||
*_runme.exe
|
||||
|
||||
# Go generated files
|
||||
*.[5689]
|
||||
*_gc.c
|
||||
|
||||
# Javascript generated files
|
||||
*.gyp
|
||||
|
||||
|
|
@ -144,12 +158,6 @@ Examples/test-suite/octave/*.oct
|
|||
*/__pycache__/
|
||||
/__pycache__/
|
||||
|
||||
# Go generated files
|
||||
*.[5689]
|
||||
*_gc.c
|
||||
# Scilab generated files
|
||||
loader.sce
|
||||
|
||||
# Scratch directories
|
||||
Examples/scratch
|
||||
|
||||
# Out of source tree build directories
|
||||
*build*/
|
||||
|
|
|
|||
51
.travis.yml
51
.travis.yml
|
|
@ -50,12 +50,21 @@ matrix:
|
|||
env: SWIGLANG=python SWIG_FEATURES=-builtin
|
||||
- compiler: gcc
|
||||
env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3
|
||||
- compiler: gcc
|
||||
env: SWIGLANG=python SWIG_FEATURES=-classic
|
||||
- compiler: gcc
|
||||
env: SWIGLANG=ruby
|
||||
- compiler: gcc
|
||||
env: SWIGLANG=scilab
|
||||
- compiler: gcc
|
||||
env: SWIGLANG=tcl
|
||||
allow_failures:
|
||||
# None
|
||||
# Occasional gcc internal compiler error
|
||||
- compiler: gcc
|
||||
env: SWIGLANG=octave SWIGJOBS=-j3 VER=3.8
|
||||
# Not quite working yet
|
||||
- compiler: gcc
|
||||
env: SWIGLANG=python SWIG_FEATURES=-classic
|
||||
before_install:
|
||||
- date -u
|
||||
- uname -a
|
||||
|
|
@ -77,40 +86,13 @@ before_install:
|
|||
- if test "$SWIGLANG" = "python"; then git clone https://github.com/jcrocholl/pep8.git && pushd pep8 && git checkout tags/1.5.7 && python ./setup.py build && sudo python ./setup.py install && popd; fi
|
||||
- if test "$SWIGLANG" = "python" -a "$PY3" -a -z "$VER"; then sudo apt-get install -qq python3-dev; fi
|
||||
- if test "$SWIGLANG" = "python" -a "$VER"; then sudo add-apt-repository -y ppa:fkrull/deadsnakes && sudo apt-get -qq update && sudo apt-get -qq install python${VER}-dev && export CONFIGOPTS="--with-python${PY3}=python${VER}"; fi
|
||||
- if test "$SWIGLANG" = "scilab"; then sudo apt-get -qq install scilab; fi
|
||||
- if test "$SWIGLANG" = "tcl"; then sudo apt-get -qq install tcl8.4-dev; fi
|
||||
# Stricter compile flags for examples. Various headers and SWIG generated code prevents full use of -pedantic.
|
||||
- declare -A CFLAGS_EXAMPLES && CFLAGS_EXAMPLES=(
|
||||
["csharp"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
|
||||
["d"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
|
||||
["go"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
|
||||
["guile"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
|
||||
["java"]="-Werror -std=gnu89 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
|
||||
["javascript"]="-Werror -std=gnu89 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
|
||||
["lua"]="-Werror -std=gnu89 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
|
||||
["octave"]="-Werror -std=gnu89 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
|
||||
["perl5"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
|
||||
["php"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
|
||||
["python"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
|
||||
["ruby"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
|
||||
["tcl"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
|
||||
)
|
||||
- declare -A CXXFLAGS_EXAMPLES && CXXFLAGS_EXAMPLES=(
|
||||
["csharp"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
|
||||
["d"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
|
||||
["go"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
|
||||
["guile"]="-Werror -std=c++98 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
|
||||
["java"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
|
||||
["javascript"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
|
||||
["lua"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
|
||||
["octave"]="-Werror -std=c++98 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
|
||||
["perl5"]="-Werror -std=c++98 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
|
||||
["php"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
|
||||
["python"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
|
||||
["ruby"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
|
||||
["tcl"]="-Werror -std=c++98 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
|
||||
)
|
||||
- $CC --version
|
||||
- $CXX --version
|
||||
# Stricter compile flags for examples. Various headers and SWIG generated code prevents full use of -pedantic.
|
||||
- export cflags=$(./testflags.py --language $SWIGLANG --cflags) && echo $cflags
|
||||
- export cxxflags=$(./testflags.py --language $SWIGLANG --cxxflags) && echo $cxxflags
|
||||
script:
|
||||
- echo 'Configuring...' && echo -en 'travis_fold:start:script.1\\r'
|
||||
- ./autogen.sh && mkdir -p build/build && cd build/build && ../../configure $CONFIGOPTS
|
||||
|
|
@ -123,11 +105,12 @@ script:
|
|||
- if test -z "$SWIGLANG"; then sudo make -s install && swig -version && ccache-swig -V; fi
|
||||
- echo -en 'travis_fold:end:script.2\\r'
|
||||
- if test -n "$SWIGLANG"; then make -s check-$SWIGLANG-version; fi
|
||||
- if test -n "$SWIGLANG"; then make -k $SWIGJOBS check-$SWIGLANG-examples CFLAGS="${CFLAGS_EXAMPLES[$SWIGLANG]}" CXXFLAGS="${CXXFLAGS_EXAMPLES[$SWIGLANG]}"; fi
|
||||
- if test -n "$SWIGLANG"; then make -k $SWIGJOBS check-$SWIGLANG-test-suite; fi
|
||||
- if test -n "$SWIGLANG"; then make $SWIGJOBS check-$SWIGLANG-examples CFLAGS="$cflags" CXXFLAGS="$cxxflags"; fi
|
||||
- if test -n "$SWIGLANG"; then make $SWIGJOBS check-$SWIGLANG-test-suite CFLAGS="$cflags" CXXFLAGS="$cxxflags"; fi
|
||||
- echo 'Cleaning...' && echo -en 'travis_fold:start:script.3\\r'
|
||||
- make check-maintainer-clean && ../../configure $CONFIGOPTS
|
||||
- echo -en 'travis_fold:end:script.3\\r'
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- error-declaration-after-statement
|
||||
|
|
|
|||
19
ANNOUNCE
19
ANNOUNCE
|
|
@ -1,8 +1,8 @@
|
|||
*** ANNOUNCE: SWIG 3.0.3 (in progress) ***
|
||||
*** ANNOUNCE: SWIG 3.0.6 (in progress) ***
|
||||
|
||||
http://www.swig.org
|
||||
|
||||
We're pleased to announce SWIG-3.0.3, the latest SWIG release.
|
||||
We're pleased to announce SWIG-3.0.6, the latest SWIG release.
|
||||
|
||||
What is SWIG?
|
||||
=============
|
||||
|
|
@ -11,21 +11,22 @@ SWIG is a software development tool that reads C/C++ header files and
|
|||
generates the wrapper code needed to make C and C++ code accessible
|
||||
from other programming languages including Perl, Python, Tcl, Ruby,
|
||||
PHP, C#, Go, Java, Javascript, Lua, Scheme (Guile, MzScheme, CHICKEN),
|
||||
D, Ocaml, Pike, Modula-3, Octave, R, Common Lisp (CLISP, Allegro CL,
|
||||
CFFI, UFFI). SWIG can also export its parse tree in the form of XML
|
||||
and Lisp s-expressions. Major applications of SWIG include generation
|
||||
of scripting language extension modules, rapid prototyping, testing,
|
||||
and user interface development for large C/C++ systems.
|
||||
D, Ocaml, Pike, Modula-3, Octave, R, Scilab, Common Lisp (CLISP,
|
||||
Allegro CL, CFFI, UFFI). SWIG can also export its parse tree in
|
||||
the form of XML and Lisp s-expressions. Major applications of SWIG
|
||||
include generation of scripting language extension modules, rapid
|
||||
prototyping, testing, and user interface development for large
|
||||
C/C++ systems.
|
||||
|
||||
Availability
|
||||
============
|
||||
The release is available for download on Sourceforge at
|
||||
|
||||
http://prdownloads.sourceforge.net/swig/swig-3.0.3.tar.gz
|
||||
http://prdownloads.sourceforge.net/swig/swig-3.0.6.tar.gz
|
||||
|
||||
A Windows version is also available at
|
||||
|
||||
http://prdownloads.sourceforge.net/swig/swigwin-3.0.3.zip
|
||||
http://prdownloads.sourceforge.net/swig/swigwin-3.0.6.zip
|
||||
|
||||
Please report problems with this release to the swig-devel mailing list,
|
||||
details at http://www.swig.org/mail.html.
|
||||
|
|
|
|||
209
CHANGES
209
CHANGES
|
|
@ -3,6 +3,211 @@ SWIG (Simplified Wrapper and Interface Generator)
|
|||
See the CHANGES.current file for changes in the current version.
|
||||
See the RELEASENOTES file for a summary of changes in each release.
|
||||
|
||||
Version 3.0.5 (31 Jan 2015)
|
||||
===========================
|
||||
|
||||
2015-01-30: wsfulton
|
||||
[Python] Fix Python -classic and property setting. Setting properties on classic classes
|
||||
was broken in swig-3.0.3 by attempting to use __setattr__. This regression is fixed now
|
||||
by using __dict__ again when using -classic.
|
||||
Fixes patch #232.
|
||||
|
||||
2015-01-27: smarchetto
|
||||
[Scilab] Support for the Scilab language has been added
|
||||
|
||||
2015-01-23: olly
|
||||
[PHP] When wrapping a returned resource as an object, check if all
|
||||
cases wrap it in the same class, and if so eliminate the pointless
|
||||
switch statement wrapper we previously generated.
|
||||
|
||||
2015-01-22: wsfulton
|
||||
[Octave] Merge patch #297 for SF bug #1277 - Octave shared_ptr support
|
||||
|
||||
2015-01-15: wsfulton
|
||||
[Python] Merge patch #250 - Fixes for using %constant and objects (non-primitive types)
|
||||
|
||||
2015-01-15: wsfulton
|
||||
[C# Go] Merge patch #308 and fix #307 - C++11 strongly typed enum support
|
||||
in directors
|
||||
|
||||
2015-01-15: wsfulton
|
||||
[Python] Second fix for #294 #296 - Regression introduced in SWIG-3.0.3 when
|
||||
wrapping functions with default arguments, this time when using kwargs.
|
||||
|
||||
Version 3.0.4 (14 Jan 2015)
|
||||
===========================
|
||||
|
||||
2015-01-12: olly
|
||||
[PHP] Fix segfault in director upcall check when using PHP built with
|
||||
ZTS enabled. Fixes #155, reported by Pierre Labastie.
|
||||
|
||||
2015-01-12: vadz
|
||||
[Python] Fix #294 #296 - Regression introduced in SWIG-3.0.3 when
|
||||
wrapping functions with default arguments. Invalid or missing default
|
||||
arguments were sometimes being generated into the python layer.
|
||||
|
||||
2015-01-08: olly
|
||||
Allow C++11 "explicit constexpr". Fixes github issue #284 reported
|
||||
by Pawel Tomulik. Also handle "constexpr explicit" and "constexpr
|
||||
static".
|
||||
|
||||
2015-01-08: olly
|
||||
When reporting an error for a construct which hasn't been
|
||||
terminated when the end of the file is reached, report it at the
|
||||
start line rather than "EOF" as then tools like editors and IDEs
|
||||
will take you to a generally more useful place for fixing the
|
||||
problem.
|
||||
|
||||
2015-01-08: olly
|
||||
Improve error messages for a few cases which previously gave the
|
||||
one of the cryptic catch-all errors "Syntax error in input".
|
||||
|
||||
2015-01-08: olly
|
||||
Provide -cppext as a general command line option for setting the
|
||||
extension used for generated C++ files (previously it was specific
|
||||
to the PHP backend). Deprecate the equivalent -suffix option
|
||||
provided by the Ocaml backend, but continue to support that for
|
||||
now.
|
||||
|
||||
Version 3.0.3 (30 Dec 2014)
|
||||
===========================
|
||||
|
||||
2014-12-27: wsfulton
|
||||
Fix #280 - abort using all default template parameters within other template
|
||||
parameters.
|
||||
|
||||
2014-12-27: talby
|
||||
[Perl] Issue #282 perl5 archlib vs archlibexp
|
||||
[Perl] tidy "warning: duplicate 'extern' declaration specifier" when building generated code
|
||||
under clang
|
||||
|
||||
2014-12-18: wsfulton
|
||||
Add support for %constant and structs/classes - issue #272
|
||||
|
||||
2014-12-09: wsfulton
|
||||
Fix #245 - regression (since swig-3.0.0) in templated constructors.
|
||||
Templated constructors could not be instantiated - they were incorrectly ignored with a warning 504:
|
||||
"Function: xyz must have a return type. Ignored."
|
||||
|
||||
2014-12-07: wsfulton
|
||||
Add support for C++11 strongly typed enumerations.
|
||||
|
||||
2014-11-21: wsfulton
|
||||
[Java C#] Fix multiply defined error when using %rename of enum items when using the "simple enum"
|
||||
wrappers.
|
||||
|
||||
2014-10-28: vadz
|
||||
[Python] Patch #201 The generated .py file no longer uses *args for all Python parameters.
|
||||
Instead, the parameters are named using the C++ parameter names.
|
||||
|
||||
2014-10-24: timotheecour
|
||||
[D] Patch #204 Use core.atomic.atomicOp to mutate shared variables
|
||||
|
||||
2014-10-21: wsfulton
|
||||
Fix issue #242 - Use of the "kwargs" feature no longer automatically turns on the
|
||||
"compactdefaultargs" feature if the target language does not support kwargs.
|
||||
Only Java and Python support kwargs, so this affects all the other languages.
|
||||
|
||||
*** POTENTIAL INCOMPATIBILITY ***
|
||||
|
||||
2014-10-10: diorcety
|
||||
[Python] Patch #232 Fix property access using directors
|
||||
|
||||
2014-10-06: wsfulton
|
||||
[Python] Fixes when using -builtin and std::vector/std::list wrappers to allow deletion
|
||||
of single elements, such as 'del vec[0]'.
|
||||
|
||||
2014-09-30: oliverb
|
||||
[Javascript] Merge patch #216 by Richie765 - Added support for many versions of v8 javascript.
|
||||
|
||||
2014-09-30: oliverb
|
||||
[Javascript] Merge patch #195 by zittix - Fixed JSClassRef declaration not using the static one.
|
||||
|
||||
2014-09-30: ianlancetaylor
|
||||
[Go] In configure script, require Go 1.1 or later.
|
||||
|
||||
2014-09-30: wsfulton
|
||||
[Python] Patch #207 - Fix No module error with -relativeimport when using single
|
||||
header file import.
|
||||
|
||||
2014-09-27: wsfulton
|
||||
Patch #208 - Initialise newly created array when using array_functions in the
|
||||
carrays.i library (C++ usage).
|
||||
|
||||
2014-09-27: wsfulton
|
||||
[Ruby] Patch #187 - Fix crash on shutdown of the Ruby interpreter if more than one
|
||||
module was loaded at a time when data is being shared between modules.
|
||||
|
||||
2014-09-27: wsfulton
|
||||
[Java] Patch #168 - Fix leak in Java director string handling after the Java
|
||||
upcall when called from a native thread.
|
||||
|
||||
2014-09-25: ianlancetaylor
|
||||
[Go] Adjust generated code to work with upcoming Go 1.4
|
||||
release.
|
||||
|
||||
2014-09-23: wsfulton
|
||||
[Python] Add patch from Thomas Maslach to fix crash in wrappers when using -threads in
|
||||
the STL iterators (SwigPyIterator destructor).
|
||||
|
||||
2014-09-17: wsfulton
|
||||
[C#] Merge patch #229 from contre - Add bool array types to arrays_csharp.i
|
||||
|
||||
2014-09-12: olly
|
||||
[PHP] Add support for specifying any PHP interfaces a wrapped class
|
||||
implements, e.g.: %typemap("phpinterfaces") MyIterator "Iterator";
|
||||
|
||||
2014-09-11: olly
|
||||
[PHP] Fix throwing a PHP exception through C++ from a subclassed
|
||||
director method - PHP NULL gets returned by the subclassed method
|
||||
in this case, so the directorout typemap needs to allow that (at
|
||||
least if an exception is active).
|
||||
|
||||
2014-09-09: ianlancetaylor
|
||||
[Go] Add goargout typemap.
|
||||
|
||||
2014-09-09: olly
|
||||
[PHP] Fix segmentation faults with directors in PHP >= 5.4, and
|
||||
reenable runme tests for director_basic testcase. Fix from
|
||||
pavel-charvat in issue#164.
|
||||
|
||||
2014-09-05: ianlancetaylor
|
||||
[Go] Add imtype, goin, goout, godirectorin, and
|
||||
godirectorout typemaps, to support writing Go code to
|
||||
convert between types.
|
||||
|
||||
2014-09-02: olly
|
||||
[Python] Fix regression in indentation of python code produced with
|
||||
-modern, introduced by changes in #188. Reported by fabiencastan
|
||||
in #218.
|
||||
|
||||
2014-09-01: olly
|
||||
Issue an error for unknown SWIG preprocessor directives, rather
|
||||
than quietly ignoring them. Reported by jrhelsey in issue#217.
|
||||
|
||||
*** POTENTIAL INCOMPATIBILITY ***
|
||||
|
||||
2014-08-15: talby
|
||||
[Perl] Include guard fix for nested modules from Anthony Heading (SF Patch #350).
|
||||
|
||||
2014-08-04: wsfulton
|
||||
[C#] Merge patch #200 from gpetrou - Changed CSharp license header to include auto-generated
|
||||
tag so that StyleCop ignores the files.
|
||||
|
||||
2014-08-04: wsfulton
|
||||
[Java] Merge patch #198 from Yuval Kashtan - Support for java.nio.ByteBuffer mapping to
|
||||
unsigned char * in various.i in NIOBUFFER typemaps.
|
||||
|
||||
2014-07-14: ianlancetaylor
|
||||
[Go] Change struct definition to use void *, not uint8, so
|
||||
that the type is recorded as possibly containing
|
||||
pointers. This ensures that the 1.3 garbage collector
|
||||
does not collect pointers passed to C++ code.
|
||||
|
||||
2014-07-01: wsfulton
|
||||
Fix SF Bug #1375 - Expansion of the $parentclassname special variable incorrectly contains
|
||||
brackets in the expanded name.
|
||||
|
||||
Version 3.0.2 (4 Jun 2014)
|
||||
==========================
|
||||
|
||||
|
|
@ -40,7 +245,7 @@ Version 3.0.1 (27 May 2014)
|
|||
symbol comprising the outer structure name and unnamed variable instance name.
|
||||
|
||||
2014-05-15: kwwette
|
||||
Add #166 - 'make check' now works out of source. This required te examples to build
|
||||
Add #166 - 'make check' now works out of source. This required the examples to build
|
||||
out of source. The main languages have been tested - C#, Go, Guile, Java, Javascript,
|
||||
Lua, Octave, Perl, PHP, Python, Ruby and Tcl.
|
||||
|
||||
|
|
@ -4308,7 +4513,7 @@ Version 1.3.32 (November 15, 2007)
|
|||
%attributeref(Class, AttributeType, AttributeName, AccessorMethod)
|
||||
|
||||
10/16/2007: olly
|
||||
[Tcl] Fix several ocurrences of "warning: deprecated conversion
|
||||
[Tcl] Fix several occurrences of "warning: deprecated conversion
|
||||
from string constant to 'char*'" from GCC 4.2 in generated C/C++
|
||||
code.
|
||||
|
||||
|
|
|
|||
128
CHANGES.current
128
CHANGES.current
|
|
@ -2,126 +2,16 @@ Below are the changes for the current release.
|
|||
See the CHANGES file for changes in older releases.
|
||||
See the RELEASENOTES file for a summary of changes in each release.
|
||||
|
||||
Version 3.0.3 (in progress)
|
||||
Version 3.0.6 (in progress)
|
||||
===========================
|
||||
|
||||
2014-12-09: wsfulton
|
||||
Fix #245 - regression (since swig-3.0.0) in templated constructors.
|
||||
Templated constructors could not be instantiated - they were incorrectly ignored with a warning 504:
|
||||
"Function: xyz must have a return type. Ignored."
|
||||
2015-02-09: wsfulton
|
||||
[Guile] Fix generated code for static const char member variables when
|
||||
defined and declared inline.
|
||||
|
||||
2014-12-07: wsfulton
|
||||
Add support for C++11 strongly typed enumerations.
|
||||
2015-02-05: ianlancetaylor
|
||||
[Go] Ignore Go specific type maps (goin, goout, etc.) if they are empty.
|
||||
|
||||
2014-11-21: wsfulton
|
||||
[Java C#] Fix multiply defined error when using %rename of enum items when using the "simple enum" wrappers.
|
||||
|
||||
2014-10-28: vadz
|
||||
[Python] Patch #201 The generated .py file no longer uses *args for all Python parameters.
|
||||
Instead, the parameters are named using the C++ parameter names.
|
||||
|
||||
2014-10-24: timotheecour
|
||||
[D] Patch #204 Use core.atomic.atomicOp to mutate shared variables
|
||||
|
||||
2014-10-21: wsfulton
|
||||
Fix issue #242 - Use of the "kwargs" feature no longer automatically turns on the
|
||||
"compactdefaultargs" feature if the target language does not support kwargs.
|
||||
Only Java and Python support kwargs, so this affects all the other languages.
|
||||
|
||||
*** POTENTIAL INCOMPATIBILITY ***
|
||||
|
||||
2014-10-10: diorcety
|
||||
[Python] Patch #232 Fix property access using directors
|
||||
|
||||
2014-10-06: wsfulton
|
||||
[Python] Fixes when using -builtin and std::vector/std::list wrappers to allow deletion
|
||||
of single elements, such as 'del vec[0]'.
|
||||
|
||||
2014-09-30: oliverb
|
||||
[Javascript] Merge patch #216 by Richie765 - Added support for many versions of v8 javascript.
|
||||
|
||||
2014-09-30: oliverb
|
||||
[Javascript] Merge patch #195 by zittix - Fixed JSClassRef declaration not using the static one.
|
||||
|
||||
2014-09-30: ianlancetaylor
|
||||
[Go] In configure script, require Go 1.1 or later.
|
||||
|
||||
2014-09-30: wsfulton
|
||||
[Python] Patch #207 - Fix No module error with -relativeimport when using single
|
||||
header file import.
|
||||
|
||||
2014-09-27: wsfulton
|
||||
Patch #208 - Initialise newly created array when using array_functions in the
|
||||
carrays.i library (C++ usage).
|
||||
|
||||
2014-09-27: wsfulton
|
||||
[Ruby] Patch #187 - Fix crash on shutdown of the Ruby interpreter if more than one
|
||||
module was loaded at a time when data is being shared between modules.
|
||||
|
||||
2014-09-27: wsfulton
|
||||
[Java] Patch #168 - Fix leak in Java director string handling after the Java
|
||||
upcall when called from a native thread.
|
||||
|
||||
2014-09-25: ianlancetaylor
|
||||
[Go] Adjust generated code to work with upcoming Go 1.4
|
||||
release.
|
||||
|
||||
2014-09-23: wsfulton
|
||||
[Python] Add patch from Thomas Maslach to fix crash in wrappers when using -threads in
|
||||
the STL iterators (SwigPyIterator destructor).
|
||||
|
||||
2014-09-17: wsfulton
|
||||
[C#] Merge patch #229 from contre - Add bool array types to arrays_csharp.i
|
||||
|
||||
2014-09-12: olly
|
||||
[PHP] Add support for specifying any PHP interfaces a wrapped class
|
||||
implements, e.g.: %typemap("phpinterfaces") MyIterator "Iterator";
|
||||
|
||||
2014-09-11: olly
|
||||
[PHP] Fix throwing a PHP exception through C++ from a subclassed
|
||||
director method - PHP NULL gets returned by the subclassed method
|
||||
in this case, so the directorout typemap needs to allow that (at
|
||||
least if an exception is active).
|
||||
|
||||
2014-09-09: ianlancetaylor
|
||||
[Go] Add goargout typemap.
|
||||
|
||||
2014-09-09: olly
|
||||
[PHP] Fix segmentation faults with directors in PHP >= 5.4, and
|
||||
reenable runme tests for director_basic testcase. Fix from
|
||||
pavel-charvat in issue#164.
|
||||
|
||||
2014-09-05: ianlancetaylor
|
||||
[Go] Add imtype, goin, goout, godirectorin, and
|
||||
godirectorout typemaps, to support writing Go code to
|
||||
convert between types.
|
||||
|
||||
2014-09-02: olly
|
||||
[Python] Fix regression in indentation of python code produced with
|
||||
-modern, introduced by changes in #188. Reported by fabiencastan
|
||||
in #218.
|
||||
|
||||
2014-09-01: olly
|
||||
Issue an error for unknown SWIG preprocessor directives, rather
|
||||
than quietly ignoring them. Reported by jrhelsey in issue#217.
|
||||
|
||||
2014-08-15: talby
|
||||
[Perl] Include guard fix for nested modules from Anthony Heading (SF Patch #350).
|
||||
|
||||
2014-08-04: wsfulton
|
||||
[C#] Merge patch #200 from gpetrou - Changed CSharp license header to include auto-generated
|
||||
tag so that StyleCop ignores the files.
|
||||
|
||||
2014-08-04: wsfulton
|
||||
[Java] Merge patch #198 from Yuval Kashtan - Support for java.nio.ByteBuffer mapping to
|
||||
unsigned char * in various.i in NIOBUFFER typemaps.
|
||||
|
||||
2014-07-14: ianlancetaylor
|
||||
[Go] Change struct definition to use void *, not uint8, so
|
||||
that the type is recorded as possibly containing
|
||||
pointers. This ensures that the 1.3 garbage collector
|
||||
does not collect pointers passed to C++ code.
|
||||
|
||||
2014-07-01: wsfulton
|
||||
Fix SF Bug #1375 - Expansion of the $parentclassname special variable incorrectly contains
|
||||
brackets in the expanded name.
|
||||
2015-02-05: ianlancetaylor
|
||||
[Go] Generated Go code no longer calls _swig_goallocate or
|
||||
_swig_makegostring, as they will no longer work as of Go 1.5.
|
||||
|
|
|
|||
105
COPYRIGHT
105
COPYRIGHT
|
|
@ -11,58 +11,63 @@ Portions also copyrighted by:
|
|||
Information-technology Promotion Agency, Japan
|
||||
|
||||
Active SWIG Developers:
|
||||
William Fulton (wsf@fultondesigns.co.uk) (SWIG core, Java, C#, Windows, Cygwin)
|
||||
Olly Betts (olly@survex.com) (PHP)
|
||||
Joseph Wang (joequant@gmail.com) (R)
|
||||
Xavier Delacour (xavier.delacour@gmail.com) (Octave)
|
||||
David Nadlinger (code@klickverbot.at) (D)
|
||||
Oliver Buchtala (oliver.buchtala@gmail.com) (Javascript)
|
||||
Neha Narang (narangneha03@gmail.com) (Javascript)
|
||||
William Fulton (wsf@fultondesigns.co.uk) (SWIG core, Java, C#, Windows, Cygwin)
|
||||
Olly Betts (olly@survex.com) (PHP)
|
||||
Joseph Wang (joequant@gmail.com) (R)
|
||||
Xavier Delacour (xavier.delacour@gmail.com) (Octave)
|
||||
David Nadlinger (code@klickverbot.at) (D)
|
||||
Oliver Buchtala (oliver.buchtala@gmail.com) (Javascript)
|
||||
Neha Narang (narangneha03@gmail.com) (Javascript)
|
||||
Simon Marchetto (simon.marchetto@scilab-enterprises.com) (Scilab)
|
||||
|
||||
Past SWIG developers and major contributors include:
|
||||
Dave Beazley (dave-swig@dabeaz.com) (SWIG core, Python, Tcl, Perl)
|
||||
Dmitry Kabak (userdima@gmail.com) (Doxygen)
|
||||
Henning Thielemann (swig@henning-thielemann.de) (Modula3)
|
||||
Matthias Köppe (mkoeppe@mail.math.uni-magdeburg.de) (Guile, MzScheme)
|
||||
Luigi Ballabio (luigi.ballabio@fastwebnet.it) (STL wrapping)
|
||||
Mikel Bancroft (mikel@franz.com) (Allegro CL)
|
||||
Surendra Singhi (efuzzyone@netscape.net) (CLISP, CFFI)
|
||||
Marcelo Matus (mmatus@acms.arizona.edu) (SWIG core, Python, UTL[python,perl,tcl,ruby])
|
||||
Art Yerkes (ayerkes@speakeasy.net) (Ocaml)
|
||||
Lyle Johnson (lyle@users.sourceforge.net) (Ruby)
|
||||
Charlie Savage (cfis@interserv.com) (Ruby)
|
||||
Thien-Thi Nguyen (ttn@glug.org) (build/test/misc)
|
||||
Richard Palmer (richard@magicality.org) (PHP)
|
||||
Sam Liddicott - Ananova Ltd (saml@liddicott.com) (PHP)
|
||||
Tim Hockin - Sun Microsystems (thockin@sun.com) (PHP)
|
||||
Kevin Ruland (PHP)
|
||||
Shibukawa Yoshiki (Japanese Translation)
|
||||
Jason Stewart (jason@openinformatics.com) (Perl5)
|
||||
Loic Dachary (Perl5)
|
||||
David Fletcher (Perl5)
|
||||
Gary Holt (Perl5)
|
||||
Masaki Fukushima (Ruby)
|
||||
Scott Michel (scottm@cs.ucla.edu) (Java directors)
|
||||
Tiger Feng (songyanf@cs.uchicago.edu) (SWIG core)
|
||||
Mark Rose (mrose@stm.lbl.gov) (Directors)
|
||||
Jonah Beckford (beckford@usermail.com) (CHICKEN)
|
||||
Ahmon Dancy (dancy@franz.com) (Allegro CL)
|
||||
Dirk Gerrits (Allegro CL)
|
||||
Neil Cawse (C#)
|
||||
Harco de Hilster (Java)
|
||||
Alexey Dyachenko (dyachenko@fromru.com) (Tcl)
|
||||
Bob Techentin (Tcl)
|
||||
Martin Froehlich <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)
|
||||
Dmitry Kabak (userdima@gmail.com) (Doxygen)
|
||||
Vadim Zeitlin (PCRE, Python, Doxygen)
|
||||
Stefan Zager (szager@gmail.com) (Python)
|
||||
Vincent Couvert (Scilab)
|
||||
Sylvestre Ledru (Scilab)
|
||||
Wolfgang Frisch (Scilab)
|
||||
|
||||
Past contributors include:
|
||||
James Michael DuPont, Clark McGrew, Dustin Mitchell, Ian Cooke, Catalin Dumitrescu, Baran
|
||||
|
|
|
|||
|
|
@ -841,6 +841,7 @@
|
|||
<div class="sectiontoc">
|
||||
<ul>
|
||||
<li><a href="Go.html#Go_overview">Overview</a>
|
||||
<li><a href="Go.html#Go_examples">Examples</a>
|
||||
<li><a href="Go.html#Go_running_swig">Running SWIG with Go</a>
|
||||
<ul>
|
||||
<li><a href="Go.html#Go_commandline">Additional Commandline Options</a>
|
||||
|
|
@ -1726,7 +1727,76 @@
|
|||
</div>
|
||||
<!-- INDEX -->
|
||||
|
||||
<h3><a href="Tcl.html#Tcl">39 SWIG and Tcl</a></h3>
|
||||
<h3><a href="Scilab.html#Scilab">39 SWIG and Scilab</a></h3>
|
||||
|
||||
<!-- INDEX -->
|
||||
<div class="sectiontoc">
|
||||
<ul>
|
||||
<li><a href="Scilab.html#Scilab_preliminaries">Preliminaries</a>
|
||||
<li><a href="Scilab.html#Scilab_running_swig">Running SWIG</a>
|
||||
<ul>
|
||||
<li><a href="Scilab.html#Scilab_running_swig_generating_module">Generating the module</a>
|
||||
<li><a href="Scilab.html#Scilab_running_swig_building_module">Building the module</a>
|
||||
<li><a href="Scilab.html#Scilab_running_swig_loading_module">Loading the module</a>
|
||||
<li><a href="Scilab.html#Scilab_running_swig_using_module">Using the module</a>
|
||||
<li><a href="Scilab.html#Scilab_running_swig_options">Scilab command line options</a>
|
||||
</ul>
|
||||
<li><a href="Scilab.html#Scilab_wrapping">A basic tour of C/C++ wrapping</a>
|
||||
<ul>
|
||||
<li><a href="Scilab.html#Scilab_wrapping_overview">Overview</a>
|
||||
<li><a href="Scilab.html#Scilab_wrapping_identifiers">Identifiers</a>
|
||||
<li><a href="Scilab.html#Scilab_wrapping_functions">Functions</a>
|
||||
<ul>
|
||||
<li><a href="Scilab.html#Scilab_nn13">Argument passing</a>
|
||||
<li><a href="Scilab.html#Scilab_nn14">Multiple output arguments</a>
|
||||
</ul>
|
||||
<li><a href="Scilab.html#Scilab_wrapping_global_variables">Global variables</a>
|
||||
<li><a href="Scilab.html#Scilab_wrapping_constants_and_enums">Constants and enumerations</a>
|
||||
<ul>
|
||||
<li><a href="Scilab.html#Scilab_wrapping_constants">Constants</a>
|
||||
<li><a href="Scilab.html#Scilab_wrapping_enums">Enumerations</a>
|
||||
</ul>
|
||||
<li><a href="Scilab.html#Scilab_wrapping_pointers">Pointers</a>
|
||||
<ul>
|
||||
<li><a href="Scilab.html#Scilab_wrapping_pointers_pointer_adresses">Utility functions</a>
|
||||
<li><a href="Scilab.html#Scilab_wrapping_pointers_null_pointers">Null pointers</a>
|
||||
</ul>
|
||||
<li><a href="Scilab.html#Scilab_wrapping_structs">Structures</a>
|
||||
<li><a href="Scilab.html#Scilab_wrapping_cpp_classes">C++ Classes</a>
|
||||
<li><a href="Scilab.html#Scilab_wrapping_cpp_inheritance">C++ inheritance</a>
|
||||
<li><a href="Scilab.html#Scilab_wrapping_pointers_references_values_arrays">Pointers, references, values, and arrays</a>
|
||||
<li><a href="Scilab.html#Scilab_wrapping_cpp_templates">C++ templates</a>
|
||||
<li><a href="Scilab.html#Scilab_wrapping_cpp_operators">C++ operators</a>
|
||||
<li><a href="Scilab.html#Scilab_wrapping_cpp_namespaces">C++ namespaces</a>
|
||||
<li><a href="Scilab.html#Scilab_wrapping_cpp_exceptions">C++ exceptions</a>
|
||||
<li><a href="Scilab.html#Scilab_wrapping_cpp_stl">C++ STL</a>
|
||||
</ul>
|
||||
<li><a href="Scilab.html#Scilab_typemaps">Type mappings and libraries</a>
|
||||
<ul>
|
||||
<li><a href="Scilab.html#Scilab_typemaps_primitive_types">Default primitive type mappings</a>
|
||||
<li><a href="Scilab.html#Scilab_typemaps_non-primitive_types">Default type mappings for non-primitive types</a>
|
||||
<li><a href="Scilab.html#Scilab_typemaps_arrays">Arrays</a>
|
||||
<li><a href="Scilab.html#Scilab_typemaps_pointer-to-pointers">Pointer-to-pointers</a>
|
||||
<li><a href="Scilab.html#Scilab_typemaps_matrices">Matrices</a>
|
||||
<li><a href="Scilab.html#Scilab_typemaps_stl">STL</a>
|
||||
</ul>
|
||||
<li><a href="Scilab.html#Scilab_module_initialization">Module initialization</a>
|
||||
<li><a href="Scilab.html#Scilab_building_modes">Building modes</a>
|
||||
<ul>
|
||||
<li><a href="Scilab.html#Scilab_building_modes_nobuilder_mode">No-builder mode</a>
|
||||
<li><a href="Scilab.html#Scilab_building_modes_builder_mode">Builder mode</a>
|
||||
</ul>
|
||||
<li><a href="Scilab.html#Scilab_generated_scripts">Generated scripts</a>
|
||||
<ul>
|
||||
<li><a href="Scilab.html#Scilab_generated_scripts_builder_script">Builder script</a>
|
||||
<li><a href="Scilab.html#Scilab_generated_scripts_loader_script">Loader script</a>
|
||||
</ul>
|
||||
<li><a href="Scilab.html#Scilab_other_resources">Other resources</a>
|
||||
</ul>
|
||||
</div>
|
||||
<!-- INDEX -->
|
||||
|
||||
<h3><a href="Tcl.html#Tcl">40 SWIG and Tcl</a></h3>
|
||||
|
||||
<!-- INDEX -->
|
||||
<div class="sectiontoc">
|
||||
|
|
@ -1792,7 +1862,7 @@
|
|||
</div>
|
||||
<!-- INDEX -->
|
||||
|
||||
<h3><a href="Extending.html#Extending">40 Extending SWIG to support new languages</a></h3>
|
||||
<h3><a href="Extending.html#Extending">41 Extending SWIG to support new languages</a></h3>
|
||||
|
||||
<!-- INDEX -->
|
||||
<div class="sectiontoc">
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
</head>
|
||||
|
||||
<body bgcolor="#ffffff">
|
||||
<H1><a name="Extending"></a>40 Extending SWIG to support new languages</H1>
|
||||
<H1><a name="Extending"></a>41 Extending SWIG to support new languages</H1>
|
||||
<!-- INDEX -->
|
||||
<div class="sectiontoc">
|
||||
<ul>
|
||||
|
|
@ -75,7 +75,7 @@
|
|||
|
||||
|
||||
|
||||
<H2><a name="Extending_nn2"></a>40.1 Introduction</H2>
|
||||
<H2><a name="Extending_nn2"></a>41.1 Introduction</H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -91,7 +91,7 @@ Also, this chapter is not meant to be a hand-holding tutorial. As a starting po
|
|||
you should probably look at one of SWIG's existing modules.
|
||||
</p>
|
||||
|
||||
<H2><a name="Extending_nn3"></a>40.2 Prerequisites</H2>
|
||||
<H2><a name="Extending_nn3"></a>41.2 Prerequisites</H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -121,7 +121,7 @@ obvious, but almost all SWIG directives as well as the low-level generation of
|
|||
wrapper code are driven by C++ datatypes.
|
||||
</p>
|
||||
|
||||
<H2><a name="Extending_nn4"></a>40.3 The Big Picture</H2>
|
||||
<H2><a name="Extending_nn4"></a>41.3 The Big Picture</H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -158,7 +158,7 @@ role in making the system work. For example, both typemaps and declaration anno
|
|||
based on pattern matching and interact heavily with the underlying type system.
|
||||
</p>
|
||||
|
||||
<H2><a name="Extending_nn5"></a>40.4 Execution Model</H2>
|
||||
<H2><a name="Extending_nn5"></a>41.4 Execution Model</H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -203,7 +203,7 @@ latter stage of compilation.
|
|||
The next few sections briefly describe some of these stages.
|
||||
</p>
|
||||
|
||||
<H3><a name="Extending_nn6"></a>40.4.1 Preprocessing</H3>
|
||||
<H3><a name="Extending_nn6"></a>41.4.1 Preprocessing</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -284,7 +284,7 @@ been expanded as well as everything else that goes into the low-level
|
|||
construction of the wrapper code.
|
||||
</p>
|
||||
|
||||
<H3><a name="Extending_nn7"></a>40.4.2 Parsing</H3>
|
||||
<H3><a name="Extending_nn7"></a>41.4.2 Parsing</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -385,7 +385,7 @@ returning a <tt>foo</tt> and taking types <tt>a</tt> and <tt>b</tt> as
|
|||
arguments).
|
||||
</p>
|
||||
|
||||
<H3><a name="Extending_nn8"></a>40.4.3 Parse Trees</H3>
|
||||
<H3><a name="Extending_nn8"></a>41.4.3 Parse Trees</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -640,7 +640,7 @@ $ swig -c++ -python -debug-module 4 example.i
|
|||
</pre>
|
||||
</div>
|
||||
|
||||
<H3><a name="Extending_nn9"></a>40.4.4 Attribute namespaces</H3>
|
||||
<H3><a name="Extending_nn9"></a>41.4.4 Attribute namespaces</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -659,7 +659,7 @@ that matches the name of the target language. For example, <tt>python:foo</tt>
|
|||
<tt>perl:foo</tt>.
|
||||
</p>
|
||||
|
||||
<H3><a name="Extending_nn10"></a>40.4.5 Symbol Tables</H3>
|
||||
<H3><a name="Extending_nn10"></a>41.4.5 Symbol Tables</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -750,7 +750,7 @@ example.i:5. Previous declaration is foo_i(int )
|
|||
</pre>
|
||||
</div>
|
||||
|
||||
<H3><a name="Extending_nn11"></a>40.4.6 The %feature directive</H3>
|
||||
<H3><a name="Extending_nn11"></a>41.4.6 The %feature directive</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -806,7 +806,7 @@ For example, the exception code above is simply
|
|||
stored without any modifications.
|
||||
</p>
|
||||
|
||||
<H3><a name="Extending_nn12"></a>40.4.7 Code Generation</H3>
|
||||
<H3><a name="Extending_nn12"></a>41.4.7 Code Generation</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -928,7 +928,7 @@ public :
|
|||
The role of these functions is described shortly.
|
||||
</p>
|
||||
|
||||
<H3><a name="Extending_nn13"></a>40.4.8 SWIG and XML</H3>
|
||||
<H3><a name="Extending_nn13"></a>41.4.8 SWIG and XML</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -941,7 +941,7 @@ internal data structures, it may be useful to keep XML in the back of
|
|||
your mind as a model.
|
||||
</p>
|
||||
|
||||
<H2><a name="Extending_nn14"></a>40.5 Primitive Data Structures</H2>
|
||||
<H2><a name="Extending_nn14"></a>41.5 Primitive Data Structures</H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -987,7 +987,7 @@ typedef Hash Typetab;
|
|||
</pre>
|
||||
</div>
|
||||
|
||||
<H3><a name="Extending_nn15"></a>40.5.1 Strings</H3>
|
||||
<H3><a name="Extending_nn15"></a>41.5.1 Strings</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -1128,7 +1128,7 @@ Returns the number of replacements made (if any).
|
|||
|
||||
</div>
|
||||
|
||||
<H3><a name="Extending_nn16"></a>40.5.2 Hashes</H3>
|
||||
<H3><a name="Extending_nn16"></a>41.5.2 Hashes</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -1205,7 +1205,7 @@ Returns the list of hash table keys.
|
|||
</div>
|
||||
|
||||
|
||||
<H3><a name="Extending_nn17"></a>40.5.3 Lists</H3>
|
||||
<H3><a name="Extending_nn17"></a>41.5.3 Lists</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -1294,7 +1294,7 @@ If <tt>t</tt> is not a standard object, it is assumed to be a <tt>char *</tt>
|
|||
and is used to create a String object.
|
||||
</div>
|
||||
|
||||
<H3><a name="Extending_nn18"></a>40.5.4 Common operations</H3>
|
||||
<H3><a name="Extending_nn18"></a>41.5.4 Common operations</H3>
|
||||
|
||||
|
||||
The following operations are applicable to all datatypes.
|
||||
|
|
@ -1349,7 +1349,7 @@ objects and report errors.
|
|||
Gets the line number associated with <tt>x</tt>.
|
||||
</div>
|
||||
|
||||
<H3><a name="Extending_nn19"></a>40.5.5 Iterating over Lists and Hashes</H3>
|
||||
<H3><a name="Extending_nn19"></a>41.5.5 Iterating over Lists and Hashes</H3>
|
||||
|
||||
|
||||
To iterate over the elements of a list or a hash table, the following functions are used:
|
||||
|
|
@ -1394,7 +1394,7 @@ for (j = First(j); j.item; j= Next(j)) {
|
|||
|
||||
</div>
|
||||
|
||||
<H3><a name="Extending_nn20"></a>40.5.6 I/O</H3>
|
||||
<H3><a name="Extending_nn20"></a>41.5.6 I/O</H3>
|
||||
|
||||
|
||||
Special I/O functions are used for all internal I/O. These operations
|
||||
|
|
@ -1528,7 +1528,7 @@ Printf(f, "%s\n", s);
|
|||
Similarly, the preprocessor and parser all operate on string-files.
|
||||
</p>
|
||||
|
||||
<H2><a name="Extending_nn21"></a>40.6 Navigating and manipulating parse trees</H2>
|
||||
<H2><a name="Extending_nn21"></a>41.6 Navigating and manipulating parse trees</H2>
|
||||
|
||||
|
||||
Parse trees are built as collections of hash tables. Each node is a hash table in which
|
||||
|
|
@ -1662,7 +1662,7 @@ Deletes a node from the parse tree. Deletion reconnects siblings and properly u
|
|||
the parent so that sibling nodes are unaffected.
|
||||
</div>
|
||||
|
||||
<H2><a name="Extending_nn22"></a>40.7 Working with attributes</H2>
|
||||
<H2><a name="Extending_nn22"></a>41.7 Working with attributes</H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -1779,7 +1779,7 @@ the attribute is optional. <tt>Swig_restore()</tt> must always be called after
|
|||
function.
|
||||
</div>
|
||||
|
||||
<H2><a name="Extending_nn23"></a>40.8 Type system</H2>
|
||||
<H2><a name="Extending_nn23"></a>41.8 Type system</H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -1788,7 +1788,7 @@ pointers, references, and pointers to members. A detailed discussion of
|
|||
type theory is impossible here. However, let's cover the highlights.
|
||||
</p>
|
||||
|
||||
<H3><a name="Extending_nn24"></a>40.8.1 String encoding of types</H3>
|
||||
<H3><a name="Extending_nn24"></a>41.8.1 String encoding of types</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -1889,7 +1889,7 @@ make the final type, the two parts are just joined together using
|
|||
string concatenation.
|
||||
</p>
|
||||
|
||||
<H3><a name="Extending_nn25"></a>40.8.2 Type construction</H3>
|
||||
<H3><a name="Extending_nn25"></a>41.8.2 Type construction</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -2058,7 +2058,7 @@ Returns the prefix of a type. For example, if <tt>ty</tt> is
|
|||
<tt>ty</tt> is unmodified.
|
||||
</div>
|
||||
|
||||
<H3><a name="Extending_nn26"></a>40.8.3 Type tests</H3>
|
||||
<H3><a name="Extending_nn26"></a>41.8.3 Type tests</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -2145,7 +2145,7 @@ Checks if <tt>ty</tt> is a varargs type.
|
|||
Checks if <tt>ty</tt> is a templatized type.
|
||||
</div>
|
||||
|
||||
<H3><a name="Extending_nn27"></a>40.8.4 Typedef and inheritance</H3>
|
||||
<H3><a name="Extending_nn27"></a>41.8.4 Typedef and inheritance</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -2247,7 +2247,7 @@ Fully reduces <tt>ty</tt> according to typedef rules. Resulting datatype
|
|||
will consist only of primitive typenames.
|
||||
</div>
|
||||
|
||||
<H3><a name="Extending_nn28"></a>40.8.5 Lvalues</H3>
|
||||
<H3><a name="Extending_nn28"></a>41.8.5 Lvalues</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -2284,7 +2284,7 @@ Literal y; // type = 'Literal', ltype='p.char'
|
|||
</pre>
|
||||
</div>
|
||||
|
||||
<H3><a name="Extending_nn29"></a>40.8.6 Output functions</H3>
|
||||
<H3><a name="Extending_nn29"></a>41.8.6 Output functions</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -2346,7 +2346,7 @@ SWIG, but is most commonly associated with type-descriptor objects
|
|||
that appear in wrappers (e.g., <tt>SWIGTYPE_p_double</tt>).
|
||||
</div>
|
||||
|
||||
<H2><a name="Extending_nn30"></a>40.9 Parameters</H2>
|
||||
<H2><a name="Extending_nn30"></a>41.9 Parameters</H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -2445,7 +2445,7 @@ included. Used to emit prototypes.
|
|||
Returns the number of required (non-optional) arguments in <tt>p</tt>.
|
||||
</div>
|
||||
|
||||
<H2><a name="Extending_nn31"></a>40.10 Writing a Language Module</H2>
|
||||
<H2><a name="Extending_nn31"></a>41.10 Writing a Language Module</H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -2460,7 +2460,7 @@ describes the creation of a minimal Python module. You should be able to extra
|
|||
this to other languages.
|
||||
</p>
|
||||
|
||||
<H3><a name="Extending_nn32"></a>40.10.1 Execution model</H3>
|
||||
<H3><a name="Extending_nn32"></a>41.10.1 Execution model</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -2470,7 +2470,7 @@ the parsing of command line options, all aspects of code generation are controll
|
|||
different methods of the <tt>Language</tt> that must be defined by your module.
|
||||
</p>
|
||||
|
||||
<H3><a name="Extending_starting_out"></a>40.10.2 Starting out</H3>
|
||||
<H3><a name="Extending_starting_out"></a>41.10.2 Starting out</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -2578,7 +2578,7 @@ that activates your module. For example, <tt>swig -python foo.i</tt>. The
|
|||
messages from your new module should appear.
|
||||
</p>
|
||||
|
||||
<H3><a name="Extending_nn34"></a>40.10.3 Command line options</H3>
|
||||
<H3><a name="Extending_nn34"></a>41.10.3 Command line options</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -2637,7 +2637,7 @@ to mark the option as valid. If you forget to do this, SWIG will terminate wit
|
|||
unrecognized command line option error.
|
||||
</p>
|
||||
|
||||
<H3><a name="Extending_nn35"></a>40.10.4 Configuration and preprocessing</H3>
|
||||
<H3><a name="Extending_nn35"></a>41.10.4 Configuration and preprocessing</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -2686,7 +2686,7 @@ an implementation file <tt>python.cxx</tt> and a configuration file
|
|||
<tt>python.swg</tt>.
|
||||
</p>
|
||||
|
||||
<H3><a name="Extending_nn36"></a>40.10.5 Entry point to code generation</H3>
|
||||
<H3><a name="Extending_nn36"></a>41.10.5 Entry point to code generation</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -2744,7 +2744,7 @@ int Python::top(Node *n) {
|
|||
</pre>
|
||||
</div>
|
||||
|
||||
<H3><a name="Extending_nn37"></a>40.10.6 Module I/O and wrapper skeleton</H3>
|
||||
<H3><a name="Extending_nn37"></a>41.10.6 Module I/O and wrapper skeleton</H3>
|
||||
|
||||
|
||||
<!-- please report bugs in this section to mgossage -->
|
||||
|
|
@ -2892,7 +2892,7 @@ functionWrapper : void Shape_y_set(Shape *self,double y)
|
|||
</pre>
|
||||
</div>
|
||||
|
||||
<H3><a name="Extending_nn38"></a>40.10.7 Low-level code generators</H3>
|
||||
<H3><a name="Extending_nn38"></a>41.10.7 Low-level code generators</H3>
|
||||
|
||||
|
||||
<!-- please report bugs in this section to mgossage -->
|
||||
|
|
@ -3046,7 +3046,7 @@ but without the typemaps, there is still work to do.
|
|||
</p>
|
||||
|
||||
|
||||
<H3><a name="Extending_configuration_files"></a>40.10.8 Configuration files</H3>
|
||||
<H3><a name="Extending_configuration_files"></a>41.10.8 Configuration files</H3>
|
||||
|
||||
|
||||
<!-- please report bugs in this section to ttn -->
|
||||
|
|
@ -3190,7 +3190,7 @@ politely displays the ignoring language message.
|
|||
</dl>
|
||||
|
||||
|
||||
<H3><a name="Extending_nn40"></a>40.10.9 Runtime support</H3>
|
||||
<H3><a name="Extending_nn40"></a>41.10.9 Runtime support</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -3199,7 +3199,7 @@ Discuss the kinds of functions typically needed for SWIG runtime support (e.g.
|
|||
the SWIG files that implement those functions.
|
||||
</p>
|
||||
|
||||
<H3><a name="Extending_nn41"></a>40.10.10 Standard library files</H3>
|
||||
<H3><a name="Extending_nn41"></a>41.10.10 Standard library files</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -3218,7 +3218,7 @@ The following are the minimum that are usually supported:
|
|||
Please copy these and modify for any new language.
|
||||
</p>
|
||||
|
||||
<H3><a name="Extending_nn42"></a>40.10.11 User examples</H3>
|
||||
<H3><a name="Extending_nn42"></a>41.10.11 User examples</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -3247,7 +3247,7 @@ during this process, see the section on <a href="#Extending_configuration_files"
|
|||
files</a>.
|
||||
</p>
|
||||
|
||||
<H3><a name="Extending_test_suite"></a>40.10.12 Test driven development and the test-suite</H3>
|
||||
<H3><a name="Extending_test_suite"></a>41.10.12 Test driven development and the test-suite</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -3306,7 +3306,7 @@ It is therefore essential that the runtime tests are written in a manner that di
|
|||
but error/exception out with an error message on stderr on failure.
|
||||
</p>
|
||||
|
||||
<H4><a name="Extending_running_test_suite"></a>40.10.12.1 Running the test-suite</H4>
|
||||
<H4><a name="Extending_running_test_suite"></a>41.10.12.1 Running the test-suite</H4>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -3498,7 +3498,7 @@ It can be run in the same way as the other language test-suites, replacing [lang
|
|||
The test cases used and the way it works is described in <tt>Examples/test-suite/errors/Makefile.in</tt>.
|
||||
</p>
|
||||
|
||||
<H3><a name="Extending_nn43"></a>40.10.13 Documentation</H3>
|
||||
<H3><a name="Extending_nn43"></a>41.10.13 Documentation</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -3530,7 +3530,7 @@ Some topics that you'll want to be sure to address include:
|
|||
if available.
|
||||
</ul>
|
||||
|
||||
<H3><a name="Extending_prerequisites"></a>40.10.14 Prerequisites for adding a new language module to the SWIG distribution</H3>
|
||||
<H3><a name="Extending_prerequisites"></a>41.10.14 Prerequisites for adding a new language module to the SWIG distribution</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -3587,7 +3587,7 @@ should be added should there be an area not already covered by
|
|||
the existing tests.
|
||||
</p>
|
||||
|
||||
<H3><a name="Extending_coding_style_guidelines"></a>40.10.15 Coding style guidelines</H3>
|
||||
<H3><a name="Extending_coding_style_guidelines"></a>41.10.15 Coding style guidelines</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -3611,7 +3611,7 @@ The generated C/C++ code should also follow this style as close as possible. How
|
|||
should be avoided as unlike the SWIG developers, users will never have consistent tab settings.
|
||||
</p>
|
||||
|
||||
<H2><a name="Extending_debugging_options"></a>40.11 Debugging Options</H2>
|
||||
<H2><a name="Extending_debugging_options"></a>41.11 Debugging Options</H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -3638,7 +3638,7 @@ There are various command line options which can aid debugging a SWIG interface
|
|||
The complete list of command line options for SWIG are available by running <tt>swig -help</tt>.
|
||||
</p>
|
||||
|
||||
<H2><a name="Extending_nn46"></a>40.12 Guide to parse tree nodes</H2>
|
||||
<H2><a name="Extending_nn46"></a>41.12 Guide to parse tree nodes</H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -4046,7 +4046,7 @@ extern "X" { ... } declaration.
|
|||
</pre>
|
||||
</div>
|
||||
|
||||
<H2><a name="Extending_further_info"></a>40.13 Further Development Information</H2>
|
||||
<H2><a name="Extending_further_info"></a>41.13 Further Development Information</H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
<div class="sectiontoc">
|
||||
<ul>
|
||||
<li><a href="#Go_overview">Overview</a>
|
||||
<li><a href="#Go_examples">Examples</a>
|
||||
<li><a href="#Go_running_swig">Running SWIG with Go</a>
|
||||
<ul>
|
||||
<li><a href="#Go_commandline">Additional Commandline Options</a>
|
||||
|
|
@ -69,7 +70,22 @@ checking and runtime library are not used with Go. This should be
|
|||
borne in mind when reading the rest of the SWIG documentation.
|
||||
</p>
|
||||
|
||||
<H2><a name="Go_running_swig"></a>23.2 Running SWIG with Go</H2>
|
||||
<H2><a name="Go_examples"></a>23.2 Examples</H2>
|
||||
|
||||
|
||||
<p>
|
||||
Working examples can be found here:
|
||||
</p>
|
||||
<ul>
|
||||
<li><a href="https://golang.org/misc/swig">Examples from the Go source tree</a>
|
||||
<li><a href="https://github.com/swig/swig/tree/master/Examples/go">Examples from the SWIG source tree</a>
|
||||
</ul>
|
||||
<p>
|
||||
The examples in the 2nd link are shipped with the SWIG distribution under the Examples/go directory.
|
||||
</p>
|
||||
|
||||
|
||||
<H2><a name="Go_running_swig"></a>23.3 Running SWIG with Go</H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -78,7 +94,7 @@ default SWIG will generate code for the gc compilers. To generate
|
|||
code for gccgo, you should also use the <tt>-gccgo</tt> option.
|
||||
</p>
|
||||
|
||||
<H3><a name="Go_commandline"></a>23.2.1 Additional Commandline Options</H3>
|
||||
<H3><a name="Go_commandline"></a>23.3.1 Additional Commandline Options</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -152,7 +168,7 @@ swig -go -help
|
|||
|
||||
</table>
|
||||
|
||||
<H3><a name="Go_outputs"></a>23.2.2 Go Output Files</H3>
|
||||
<H3><a name="Go_outputs"></a>23.3.2 Go Output Files</H3>
|
||||
|
||||
|
||||
<p> When generating Go code, SWIG will generate the following
|
||||
|
|
@ -228,7 +244,7 @@ this:
|
|||
% go tool 6l main.6
|
||||
</pre></div>
|
||||
|
||||
<H2><a name="Go_basic_tour"></a>23.3 A tour of basic C/C++ wrapping</H2>
|
||||
<H2><a name="Go_basic_tour"></a>23.4 A tour of basic C/C++ wrapping</H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -238,7 +254,7 @@ modifications have to occur. This section briefly covers the
|
|||
essential aspects of this wrapping.
|
||||
</p>
|
||||
|
||||
<H3><a name="Go_package"></a>23.3.1 Go Package Name</H3>
|
||||
<H3><a name="Go_package"></a>23.4.1 Go Package Name</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -248,7 +264,7 @@ directive. You may override this by using SWIG's <tt>-package</tt>
|
|||
command line option.
|
||||
</p>
|
||||
|
||||
<H3><a name="Go_names"></a>23.3.2 Go Names</H3>
|
||||
<H3><a name="Go_names"></a>23.4.2 Go Names</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -280,7 +296,7 @@ followed by that name, and the destructor will be
|
|||
named <tt>Delete</tt> followed by that name.
|
||||
</p>
|
||||
|
||||
<H3><a name="Go_constants"></a>23.3.3 Go Constants</H3>
|
||||
<H3><a name="Go_constants"></a>23.4.3 Go Constants</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -288,7 +304,7 @@ C/C++ constants created via <tt>#define</tt> or the <tt>%constant</tt>
|
|||
directive become Go constants, declared with a <tt>const</tt>
|
||||
declaration.
|
||||
|
||||
<H3><a name="Go_enumerations"></a>23.3.4 Go Enumerations</H3>
|
||||
<H3><a name="Go_enumerations"></a>23.4.4 Go Enumerations</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -298,7 +314,7 @@ usual). The values of the enumeration will become variables in Go;
|
|||
code should avoid modifying those variables.
|
||||
</p>
|
||||
|
||||
<H3><a name="Go_classes"></a>23.3.5 Go Classes</H3>
|
||||
<H3><a name="Go_classes"></a>23.4.5 Go Classes</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -376,21 +392,24 @@ returns a go interface. If the returned pointer can be null, you can check
|
|||
for this by calling the Swigcptr() method.
|
||||
</p>
|
||||
|
||||
<H4><a name="Go_class_memory"></a>23.3.5.1 Go Class Memory Management</H4>
|
||||
<H4><a name="Go_class_memory"></a>23.4.5.1 Go Class Memory Management</H4>
|
||||
|
||||
|
||||
<p>
|
||||
Calling <tt>NewClassName</tt> for some C++ class <tt>ClassName</tt>
|
||||
will allocate memory using the C++ memory allocator. This memory will
|
||||
not be automatically freed by Go's garbage collector. When you are
|
||||
done with the C++ object you must free it using <tt>DeleteClassName</tt>.
|
||||
not be automatically freed by Go's garbage collector as the object ownership is
|
||||
not tracked. When you are done with the C++ object you must free it manually
|
||||
using <tt>DeleteClassName</tt>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
A common technique is to store the C++ object into a Go object, and
|
||||
use the Go function <tt>runtime.SetFinalizer</tt> to free the C++
|
||||
object when the Go object is freed. For example, if the SWIG package
|
||||
is imported as "wrap":
|
||||
use the Go function <tt>runtime.SetFinalizer</tt> to free the C++ object when
|
||||
the Go object is freed. It is strongly recommended to read the
|
||||
<a href="https://golang.org/pkg/runtime/#SetFinalizer">runtime.SetFinalizer</a>
|
||||
documentation before using this technique to understand its limitations.
|
||||
For example, if the SWIG package is imported as "wrap":
|
||||
</p>
|
||||
<div class="code">
|
||||
<pre>
|
||||
|
|
@ -409,7 +428,7 @@ func NewGoClassName() *GoClassName {
|
|||
</pre>
|
||||
</div>
|
||||
|
||||
<H4><a name="Go_class_inheritance"></a>23.3.5.2 Go Class Inheritance</H4>
|
||||
<H4><a name="Go_class_inheritance"></a>23.4.5.2 Go Class Inheritance</H4>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -421,7 +440,7 @@ Doing the reverse will require an explicit type assertion, which will
|
|||
be checked dynamically.
|
||||
</p>
|
||||
|
||||
<H3><a name="Go_templates"></a>23.3.6 Go Templates</H3>
|
||||
<H3><a name="Go_templates"></a>23.4.6 Go Templates</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -429,7 +448,7 @@ In order to use C++ templates in Go, you must tell SWIG to create
|
|||
wrappers for a particular template instantation. To do this, use
|
||||
the <tt>%template</tt> directive.
|
||||
|
||||
<H3><a name="Go_director_classes"></a>23.3.7 Go Director Classes</H3>
|
||||
<H3><a name="Go_director_classes"></a>23.4.7 Go Director Classes</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -472,7 +491,7 @@ method defined in Go. The Go code may of course call other methods on
|
|||
itself, and those methods may be defined either in Go or in C++.
|
||||
</p>
|
||||
|
||||
<H3><a name="Go_primitive_type_mappings"></a>23.3.8 Default Go primitive type mappings</H3>
|
||||
<H3><a name="Go_primitive_type_mappings"></a>23.4.8 Default Go primitive type mappings</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -579,7 +598,7 @@ that typemap, or add new values, to control how C/C++ types are mapped
|
|||
into Go types.
|
||||
</p>
|
||||
|
||||
<H3><a name="Go_output_arguments"></a>23.3.9 Output arguments</H3>
|
||||
<H3><a name="Go_output_arguments"></a>23.4.9 Output arguments</H3>
|
||||
|
||||
|
||||
<p>Because of limitations in the way output arguments are processed in swig,
|
||||
|
|
@ -632,7 +651,7 @@ void f(char *output);
|
|||
</pre>
|
||||
</div>
|
||||
|
||||
<H3><a name="Go_adding_additional_code"></a>23.3.10 Adding additional go code</H3>
|
||||
<H3><a name="Go_adding_additional_code"></a>23.4.10 Adding additional go code</H3>
|
||||
|
||||
|
||||
<p>Often the APIs generated by swig are not very natural in go, especially if
|
||||
|
|
@ -727,7 +746,7 @@ func bar() {
|
|||
</pre>
|
||||
</div>
|
||||
|
||||
<H3><a name="Go_typemaps"></a>23.3.11 Go typemaps</H3>
|
||||
<H3><a name="Go_typemaps"></a>23.4.11 Go typemaps</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -776,7 +795,8 @@ gotype is best converted to C/C++ using Go code.
|
|||
<td>
|
||||
Go code to convert from gotype to imtype when calling a C/C++
|
||||
function. SWIG will then internally convert imtype to a C/C++ type
|
||||
and pass it down. If this is not defined no conversion is done.
|
||||
and pass it down. If this is not defined, or is the empty string, no
|
||||
conversion is done.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
|
@ -803,7 +823,8 @@ to the desired type.
|
|||
<td>goout</td>
|
||||
<td>
|
||||
Go code to convert a value returned from a C/C++ function from imtype
|
||||
to gotype. If this is not defined no conversion is done.
|
||||
to gotype. If this is not defined, or is the empty string, no
|
||||
conversion is done.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
|
@ -824,7 +845,7 @@ be done.
|
|||
Go code to adjust an argument value when returning from a function.
|
||||
This is called after the real C/C++ function has run. The value will
|
||||
be in imtype. This is only useful for a pointer type of some sort.
|
||||
If this is not defined nothing will be done.
|
||||
If this is not defined, or is the empty string, nothing will be done.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
|
@ -842,7 +863,8 @@ to the desired type.
|
|||
<td>godirectorin</td>
|
||||
<td>
|
||||
Go code to convert a value used to call a director method from imtype
|
||||
to gotype. If this is not defined no conversion is done.
|
||||
to gotype. If this is not defined, or is the empty string, no
|
||||
conversion is done.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
|
@ -850,7 +872,8 @@ to gotype. If this is not defined no conversion is done.
|
|||
<td>godirectorout</td>
|
||||
<td>
|
||||
Go code to convert a value returned from a director method from gotype
|
||||
to imtype. If this is not defined no conversion is done.
|
||||
to imtype. If this is not defined, or is the empty string, no
|
||||
conversion is done.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
|
|
|||
|
|
@ -334,8 +334,7 @@ major features include:
|
|||
</ul>
|
||||
|
||||
<p>
|
||||
Currently, the only major C++ feature not supported is nested classes--a limitation
|
||||
that should be removed in a future release, but has some workarounds for the moment.
|
||||
Most of C++11 is also supported. Details are in the <a href="CPlusPlus11.html">C++11</a> section.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
|
|
|||
|
|
@ -142,6 +142,7 @@ least work for Linux though):
|
|||
|
||||
<H3><a name="Php_nn1_3"></a>34.1.2 Using PHP Extensions</H3>
|
||||
|
||||
|
||||
<p>
|
||||
To test the extension from a PHP script, you first need to tell PHP to
|
||||
load it. To do this, add a line like this to the <tt>[PHP]</tt> section of
|
||||
|
|
@ -773,6 +774,7 @@ Ko::threats();
|
|||
|
||||
<H4><a name="Php_nn2_6_5"></a>34.2.6.5 Specifying Implemented Interfaces</H4>
|
||||
|
||||
|
||||
<p>
|
||||
PHP supports the concept of abstract interfaces which a class can implement.
|
||||
Since SWIG 3.0.3, you can tell SWIG that a wrapped class (for example
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -2169,15 +2169,15 @@ for Python 2.2):
|
|||
import _example
|
||||
|
||||
class Foo(object):
|
||||
def __init__(self):
|
||||
self.this = _example.new_Foo()
|
||||
self.thisown = 1
|
||||
def __del__(self):
|
||||
if self.thisown:
|
||||
_example.delete_Foo(self.this)
|
||||
def spam(self,arg1):
|
||||
return _example.Foo_spam(self.this,arg1)
|
||||
x = property(_example.Foo_x_get, _example.Foo_x_set)
|
||||
def __init__(self):
|
||||
self.this = _example.new_Foo()
|
||||
self.thisown = 1
|
||||
def __del__(self):
|
||||
if self.thisown:
|
||||
_example.delete_Foo(self.this)
|
||||
def spam(self,arg1):
|
||||
return _example.Foo_spam(self.this,arg1)
|
||||
x = property(_example.Foo_x_get, _example.Foo_x_set)
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -2219,9 +2219,9 @@ like in a proxy class:
|
|||
<div class="targetlang">
|
||||
<pre>
|
||||
class Foo(object):
|
||||
def __init__(self):
|
||||
self.this = _example.new_Foo()
|
||||
self.thisown = 1
|
||||
def __init__(self):
|
||||
self.this = _example.new_Foo()
|
||||
self.thisown = 1
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -2313,11 +2313,11 @@ private:
|
|||
|
||||
<div class="targetlang">
|
||||
<pre>
|
||||
class MyPyException (Exception) :
|
||||
def __init__(self, msg, *args) :
|
||||
class MyPyException(Exception):
|
||||
def __init__(self, msg, *args):
|
||||
Exception.__init__(self, *args)
|
||||
self.myexc = MyException(msg)
|
||||
def what (self) :
|
||||
def what(self):
|
||||
return self.myexc.what()
|
||||
</pre>
|
||||
</div>
|
||||
|
|
@ -2841,6 +2841,7 @@ the methods one() and two() (but not three()):
|
|||
class Foo {
|
||||
public:
|
||||
Foo(int foo);
|
||||
virtual ~Foo();
|
||||
virtual void one();
|
||||
virtual void two();
|
||||
};
|
||||
|
|
@ -2861,11 +2862,12 @@ then at the python side you can define
|
|||
import mymodule
|
||||
|
||||
class MyFoo(mymodule.Foo):
|
||||
def __init__(self, foo):
|
||||
mymodule.Foo(self, foo)
|
||||
def __init__(self, foo):
|
||||
mymodule.Foo.__init__(self, foo)
|
||||
# super().__init__(foo) # Alternative construction for Python3
|
||||
|
||||
def one(self):
|
||||
print "one from python"
|
||||
def one(self):
|
||||
print "one from python"
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -3368,6 +3370,18 @@ print("Loading", "Whizz", "Bang", sep=' ... ')
|
|||
</pre>
|
||||
</div>
|
||||
|
||||
<p>When using <tt>%pythoncode</tt> and <tt>%pythonbegin</tt> you generally
|
||||
want to make sure that the block is delimited by <tt>%{</tt> and <tt>%}</tt>.
|
||||
If you delimit it with <tt>{</tt> and <tt>}</tt> then any lines with a
|
||||
leading <tt>#</tt> will be handled by SWIG as preprocessor directives, when
|
||||
you probably meant them as Python comments. Prior to SWIG 3.0.3, invalid
|
||||
preprocessor directives were silently ignored, so generally using the wrong
|
||||
delimiters resulted in such comments not appearing in the generated output
|
||||
(though a comment starting with a valid preprocessor directive could cause
|
||||
problems, for example: <tt># error handling</tt>). SWIG 3.0.3 and later report
|
||||
an error for invalid preprocessor directives, so you may have to update
|
||||
existing interface files to delimit blocks of Python code correctly.</p>
|
||||
|
||||
<p>Sometimes you may want to replace or modify the wrapper function
|
||||
that SWIG creates in the proxy <tt>.py</tt> file. The Python module
|
||||
in SWIG provides some features that enable you to do this. First, to
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@
|
|||
<H2><a name="Ruby_nn2"></a>38.1 Preliminaries</H2>
|
||||
|
||||
|
||||
<p> SWIG 1.3 is known to work with Ruby versions 1.6 and later.
|
||||
<p> SWIG 3.0 is known to work with Ruby versions 1.8 and later.
|
||||
Given the choice, you should use the latest stable version of Ruby. You
|
||||
should also determine if your system supports shared libraries and
|
||||
dynamic loading. SWIG will work with or without dynamic loading, but
|
||||
|
|
@ -191,7 +191,7 @@ header file. This file is usually contained in a directory such as </p>
|
|||
|
||||
<div class="code shell diagram">
|
||||
<pre>/usr/lib/ruby/1.8/x86_64-linux-gnu/ruby.h
|
||||
/usr/local/lib/ruby/1.6/i686-linux/ruby.h
|
||||
/usr/include/ruby-2.1.0/ruby.h
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -201,8 +201,14 @@ installed, you can run Ruby to find out. For example: </p>
|
|||
|
||||
<div class="code shell">
|
||||
<pre>$ ruby -e 'puts $:.join("\n")'
|
||||
/usr/local/lib/ruby/site_ruby/1.6 /usr/local/lib/ruby/site_ruby/1.6/i686-linux
|
||||
/usr/local/lib/ruby/site_ruby /usr/local/lib/ruby/1.6 /usr/local/lib/ruby/1.6/i686-linux .
|
||||
/usr/local/lib/site_ruby/2.1.0
|
||||
/usr/local/lib/x86_64-linux-gnu/site_ruby
|
||||
/usr/local/lib/site_ruby
|
||||
/usr/lib/ruby/vendor_ruby/2.1.0
|
||||
/usr/lib/x86_64-linux-gnu/ruby/vendor_ruby/2.1.0
|
||||
/usr/lib/ruby/vendor_ruby
|
||||
/usr/lib/ruby/2.1.0
|
||||
/usr/lib/x86_64-linux-gnu/ruby/2.1.0
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -260,7 +266,7 @@ operating system would look something like this: </p>
|
|||
<div class="code shell">
|
||||
<pre>$ swig -ruby example.i
|
||||
$ gcc -O2 -fPIC -c example.c
|
||||
$ gcc -O2 -fPIC -c example_wrap.c -I/usr/local/lib/ruby/1.6/i686-linux
|
||||
$ gcc -O2 -fPIC -c example_wrap.c -I/usr/include/ruby-2.1.0
|
||||
$ gcc -shared example.o example_wrap.o -o example.so
|
||||
</pre>
|
||||
</div>
|
||||
|
|
@ -334,7 +340,7 @@ using the C++ compiler. For example: </p>
|
|||
<pre>
|
||||
$ swig -c++ -ruby example.i
|
||||
$ g++ -fPIC -c example.cxx
|
||||
$ g++ -fPIC -c example_wrap.cxx -I/usr/local/lib/ruby/1.6/i686-linux
|
||||
$ g++ -fPIC -c example_wrap.cxx -I/usr/include/ruby-2.1.0
|
||||
$ g++ -shared example.o example_wrap.o -o example.so
|
||||
</pre>
|
||||
</div>
|
||||
|
|
@ -2823,7 +2829,7 @@ not support optional arguments, such as Java and C#, effectively ignore
|
|||
the value specified by this typemap as all arguments must be given.</p>
|
||||
|
||||
<p> Once a default typemap has been applied to an argument, all
|
||||
arguments that follow must have default values. See the <a href="http://www.swig.org/Doc1.3/SWIGDocumentation.html#SWIG_default_args">
|
||||
arguments that follow must have default values. See the <a href="SWIG.html#SWIG_default_args">
|
||||
Default/optional arguments</a> section for further information on
|
||||
default argument wrapping.</p>
|
||||
|
||||
|
|
@ -3017,7 +3023,7 @@ catch(char const *_e) {
|
|||
|
||||
<p> Note that if your methods do not have an exception
|
||||
specification yet they do throw exceptions, SWIG cannot know how to
|
||||
deal with them. For a neat way to handle these, see the <a href="http://www.swig.org/Doc1.3/SWIGDocumentation.html#exception">Exception
|
||||
deal with them. For a neat way to handle these, see the <a href="Customization.html#Customization_exception">Exception
|
||||
handling with %exception</a> section.</p>
|
||||
|
||||
<H4><a name="Ruby_directorin_typemap"></a>38.7.6.14 directorin typemap</H4>
|
||||
|
|
@ -4466,7 +4472,7 @@ and then type <tt>make</tt> to build the shared library: </p>
|
|||
<pre>$ <b>ruby extconf.rb</b>
|
||||
creating Makefile
|
||||
$ <b>make</b>
|
||||
g++ -fPIC -g -O2 -I. -I/usr/local/lib/ruby/1.7/i686-linux \
|
||||
g++ -fPIC -g -O2 -I. -I/usr/include/ruby-2.1.0 \
|
||||
-I. -c shape_wrap.cxx
|
||||
gcc -shared -L/usr/local/lib -o shape.so shape_wrap.o -L. \
|
||||
-lruby -lruby -lc</pre>
|
||||
|
|
@ -5351,7 +5357,7 @@ used for callbacks, for example. </p>
|
|||
<p>To solve the problem, SWIG can now generate code with director
|
||||
functions containing the optional macros SWIG_INIT_STACK and
|
||||
SWIG_RELEASE_STACK. These macros will try to force Ruby to
|
||||
reinitiliaze the beginning of the stack the first time a
|
||||
reinitialize the beginning of the stack the first time a
|
||||
director
|
||||
function is called. This will lead Ruby to measure and not
|
||||
collect any VALUE objects defined from that point on. </p>
|
||||
|
|
|
|||
|
|
@ -138,6 +138,7 @@ can be obtained by typing <tt>swig -help</tt> or <tt>swig
|
|||
-xml Generate XML wrappers
|
||||
|
||||
-c++ Enable C++ parsing
|
||||
-cppext <em>ext</em> Change file extension of C++ generated files to <em>ext</em> (default is cxx, except for PHP which uses cpp)
|
||||
-D<em>symbol</em> Define a preprocessor symbol
|
||||
-Fstandard Display error/warning messages in commonly used format
|
||||
-Fmicrosoft Display error/warning messages in Microsoft format
|
||||
|
|
@ -146,7 +147,7 @@ can be obtained by typing <tt>swig -help</tt> or <tt>swig
|
|||
-l<em>file</em> Include a SWIG library file.
|
||||
-module <em>name</em> Set the name of the SWIG module
|
||||
-o <em>outfile</em> Name of output file
|
||||
-outcurrentdir Set default output dir to current dir instead of input file's path
|
||||
-outcurrentdir Set default output dir to current dir instead of input file's path
|
||||
-outdir <em>dir</em> Set language specific files output directory
|
||||
-pcreversion Display PCRE version information
|
||||
-swiglib Show location of SWIG library
|
||||
|
|
|
|||
|
|
@ -3614,18 +3614,52 @@ and the second will take two integer arguments.
|
|||
</p>
|
||||
|
||||
<p>
|
||||
Needless to say, SWIG's template support provides plenty of
|
||||
opportunities to break the universe. That said, an important final
|
||||
point is that <b>SWIG does not perform extensive error checking of
|
||||
templates!</b> Specifically, SWIG does not perform type checking nor
|
||||
does it check to see if the actual contents of the template
|
||||
declaration make any sense. Since the C++ compiler will hopefully
|
||||
check this when it compiles the resulting wrapper file, there is no
|
||||
practical reason for SWIG to duplicate this functionality (besides,
|
||||
none of the SWIG developers are masochistic enough to want to
|
||||
implement this right now).
|
||||
Needless to say, SWIG's template support provides plenty of opportunities to
|
||||
break the universe. That said, an important final point is that <b>SWIG does
|
||||
not perform extensive error checking of templates!</b> Specifically, SWIG does
|
||||
not perform type checking nor does it check to see if the actual contents of the
|
||||
template declaration make any sense. Since the C++ compiler checks this when it
|
||||
compiles the resulting wrapper file, there is no practical reason for SWIG to
|
||||
duplicate this functionality.
|
||||
</p>
|
||||
|
||||
<a name="SWIGPlus_template_nested_class_example"></a>
|
||||
<p>
|
||||
As SWIG's template support does not perform type checking <tt>%template</tt>
|
||||
can be used as early as after a template declaration. You can, and rarely have
|
||||
to, use <tt>%template</tt> before the template parameters have been declared.
|
||||
For example:
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
template <class T> class OuterTemplateClass {};
|
||||
|
||||
// The nested class OuterClass::InnerClass inherits from the template class
|
||||
// OuterTemplateClass<OuterClass::InnerStruct> and thus the template needs
|
||||
// to be expanded with %template before the OuterClass declaration.
|
||||
%template(OuterTemplateClass_OuterClass__InnerStruct)
|
||||
OuterTemplateClass<OuterClass::InnerStruct>
|
||||
|
||||
|
||||
// Don't forget to use %feature("flatnested") for OuterClass::InnerStruct and
|
||||
// OuterClass::InnerClass if the target language doesn't support nested classes.
|
||||
class OuterClass {
|
||||
public:
|
||||
// Forward declarations:
|
||||
struct InnerStruct;
|
||||
class InnerClass;
|
||||
};
|
||||
|
||||
struct OuterClass::InnerStruct {};
|
||||
|
||||
// Expanding the template at this point with %template is too late as the
|
||||
// OuterClass::InnerClass declaration is processed inside OuterClass.
|
||||
|
||||
class OuterClass::InnerClass : public OuterTemplateClass<InnerStruct> {};
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<b>Compatibility Note</b>: The first implementation of template support relied heavily on
|
||||
macro expansion in the preprocessor. Templates have been more tightly integrated into
|
||||
|
|
@ -5000,6 +5034,12 @@ class Bar {
|
|||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
If a nested class, within an outer class, has to be used as a template parameter within the outer class, then the template will
|
||||
have to be instantiated with <tt>%template</tt> before the beginning of the outer class.
|
||||
An example can be found in the
|
||||
<a href="#SWIGPlus_template_nested_class_example">Templates</a> section.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Compatibility Note:</b>
|
||||
|
|
|
|||
2051
Doc/Manual/Scilab.html
Normal file
2051
Doc/Manual/Scilab.html
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -6,7 +6,7 @@
|
|||
<body bgcolor="#ffffff">
|
||||
<H1><a name="Sections"></a>SWIG-3.0 Documentation</H1>
|
||||
|
||||
Last update : SWIG-3.0.3 (in progress)
|
||||
Last update : SWIG-3.0.6 (in progress)
|
||||
|
||||
<H2>Sections</H2>
|
||||
|
||||
|
|
@ -55,6 +55,7 @@ Last update : SWIG-3.0.3 (in progress)
|
|||
<li><a href="Python.html#Python">Python support</a></li>
|
||||
<li><a href="R.html#R">R support</a></li>
|
||||
<li><a href="Ruby.html#Ruby">Ruby support</a></li>
|
||||
<li><a href="Scilab.html#Scilab">Scilab support</a></li>
|
||||
<li><a href="Tcl.html#Tcl">Tcl support</a></li>
|
||||
</ul>
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
</head>
|
||||
|
||||
<body bgcolor="#ffffff">
|
||||
<H1><a name="Tcl"></a>39 SWIG and Tcl</H1>
|
||||
<H1><a name="Tcl"></a>40 SWIG and Tcl</H1>
|
||||
<!-- INDEX -->
|
||||
<div class="sectiontoc">
|
||||
<ul>
|
||||
|
|
@ -83,7 +83,7 @@ Tcl 8.0 or a later release. Earlier releases of SWIG supported Tcl 7.x, but
|
|||
this is no longer supported.
|
||||
</p>
|
||||
|
||||
<H2><a name="Tcl_nn2"></a>39.1 Preliminaries</H2>
|
||||
<H2><a name="Tcl_nn2"></a>40.1 Preliminaries</H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -109,7 +109,7 @@ build a Tcl extension module. To finish building the module, you
|
|||
need to compile this file and link it with the rest of your program.
|
||||
</p>
|
||||
|
||||
<H3><a name="Tcl_nn3"></a>39.1.1 Getting the right header files</H3>
|
||||
<H3><a name="Tcl_nn3"></a>40.1.1 Getting the right header files</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -127,7 +127,7 @@ this is the case, you should probably make a symbolic link so that <tt>tcl.h</tt
|
|||
header file.
|
||||
</p>
|
||||
|
||||
<H3><a name="Tcl_nn4"></a>39.1.2 Compiling a dynamic module</H3>
|
||||
<H3><a name="Tcl_nn4"></a>40.1.2 Compiling a dynamic module</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -163,7 +163,7 @@ The name of the module is specified using the <tt>%module</tt> directive or the
|
|||
<tt>-module</tt> command line option.
|
||||
</p>
|
||||
|
||||
<H3><a name="Tcl_nn5"></a>39.1.3 Static linking</H3>
|
||||
<H3><a name="Tcl_nn5"></a>40.1.3 Static linking</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -229,7 +229,7 @@ minimal in most situations (and quite frankly not worth the extra
|
|||
hassle in the opinion of this author).
|
||||
</p>
|
||||
|
||||
<H3><a name="Tcl_nn6"></a>39.1.4 Using your module</H3>
|
||||
<H3><a name="Tcl_nn6"></a>40.1.4 Using your module</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -357,7 +357,7 @@ to the default system configuration (this requires root access and you will need
|
|||
the man pages).
|
||||
</p>
|
||||
|
||||
<H3><a name="Tcl_nn7"></a>39.1.5 Compilation of C++ extensions</H3>
|
||||
<H3><a name="Tcl_nn7"></a>40.1.5 Compilation of C++ extensions</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -440,7 +440,7 @@ erratic program behavior. If working with lots of software components, you
|
|||
might want to investigate using a more formal standard such as COM.
|
||||
</p>
|
||||
|
||||
<H3><a name="Tcl_nn8"></a>39.1.6 Compiling for 64-bit platforms</H3>
|
||||
<H3><a name="Tcl_nn8"></a>40.1.6 Compiling for 64-bit platforms</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -467,7 +467,7 @@ also introduce problems on platforms that support more than one
|
|||
linking standard (e.g., -o32 and -n32 on Irix).
|
||||
</p>
|
||||
|
||||
<H3><a name="Tcl_nn9"></a>39.1.7 Setting a package prefix</H3>
|
||||
<H3><a name="Tcl_nn9"></a>40.1.7 Setting a package prefix</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -486,7 +486,7 @@ option will append the prefix to the name when creating a command and
|
|||
call it "<tt>Foo_bar</tt>".
|
||||
</p>
|
||||
|
||||
<H3><a name="Tcl_nn10"></a>39.1.8 Using namespaces</H3>
|
||||
<H3><a name="Tcl_nn10"></a>40.1.8 Using namespaces</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -508,7 +508,7 @@ When the <tt>-namespace</tt> option is used, objects in the module
|
|||
are always accessed with the namespace name such as <tt>Foo::bar</tt>.
|
||||
</p>
|
||||
|
||||
<H2><a name="Tcl_nn11"></a>39.2 Building Tcl/Tk Extensions under Windows 95/NT</H2>
|
||||
<H2><a name="Tcl_nn11"></a>40.2 Building Tcl/Tk Extensions under Windows 95/NT</H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -519,7 +519,7 @@ covers the process of using SWIG with Microsoft Visual C++.
|
|||
although the procedure may be similar with other compilers.
|
||||
</p>
|
||||
|
||||
<H3><a name="Tcl_nn12"></a>39.2.1 Running SWIG from Developer Studio</H3>
|
||||
<H3><a name="Tcl_nn12"></a>40.2.1 Running SWIG from Developer Studio</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -577,7 +577,7 @@ MSDOS > tclsh80
|
|||
%
|
||||
</pre></div>
|
||||
|
||||
<H3><a name="Tcl_nn13"></a>39.2.2 Using NMAKE</H3>
|
||||
<H3><a name="Tcl_nn13"></a>40.2.2 Using NMAKE</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -640,7 +640,7 @@ to get you started. With a little practice, you'll be making lots of
|
|||
Tcl extensions.
|
||||
</p>
|
||||
|
||||
<H2><a name="Tcl_nn14"></a>39.3 A tour of basic C/C++ wrapping</H2>
|
||||
<H2><a name="Tcl_nn14"></a>40.3 A tour of basic C/C++ wrapping</H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -651,7 +651,7 @@ classes. This section briefly covers the essential aspects of this
|
|||
wrapping.
|
||||
</p>
|
||||
|
||||
<H3><a name="Tcl_nn15"></a>39.3.1 Modules</H3>
|
||||
<H3><a name="Tcl_nn15"></a>40.3.1 Modules</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -685,7 +685,7 @@ To fix this, supply an extra argument to <tt>load</tt> like this:
|
|||
</pre>
|
||||
</div>
|
||||
|
||||
<H3><a name="Tcl_nn16"></a>39.3.2 Functions</H3>
|
||||
<H3><a name="Tcl_nn16"></a>40.3.2 Functions</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -710,7 +710,7 @@ like you think it does:
|
|||
%
|
||||
</pre></div>
|
||||
|
||||
<H3><a name="Tcl_nn17"></a>39.3.3 Global variables</H3>
|
||||
<H3><a name="Tcl_nn17"></a>40.3.3 Global variables</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -790,7 +790,7 @@ extern char *path; // Read-only (due to %immutable)
|
|||
</pre>
|
||||
</div>
|
||||
|
||||
<H3><a name="Tcl_nn18"></a>39.3.4 Constants and enums</H3>
|
||||
<H3><a name="Tcl_nn18"></a>40.3.4 Constants and enums</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -874,7 +874,7 @@ When an identifier name is given, it is used to perform an implicit hash-table l
|
|||
conversion. This allows the <tt>global</tt> statement to be omitted.
|
||||
</p>
|
||||
|
||||
<H3><a name="Tcl_nn19"></a>39.3.5 Pointers</H3>
|
||||
<H3><a name="Tcl_nn19"></a>40.3.5 Pointers</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -970,7 +970,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return
|
|||
<tt>None</tt> if the conversion can't be performed.
|
||||
</p>
|
||||
|
||||
<H3><a name="Tcl_nn20"></a>39.3.6 Structures</H3>
|
||||
<H3><a name="Tcl_nn20"></a>40.3.6 Structures</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -1252,7 +1252,7 @@ Note: Tcl only destroys the underlying object if it has ownership. See the
|
|||
memory management section that appears shortly.
|
||||
</p>
|
||||
|
||||
<H3><a name="Tcl_nn21"></a>39.3.7 C++ classes</H3>
|
||||
<H3><a name="Tcl_nn21"></a>40.3.7 C++ classes</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -1319,7 +1319,7 @@ In Tcl, the static member is accessed as follows:
|
|||
</pre>
|
||||
</div>
|
||||
|
||||
<H3><a name="Tcl_nn22"></a>39.3.8 C++ inheritance</H3>
|
||||
<H3><a name="Tcl_nn22"></a>40.3.8 C++ inheritance</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -1368,7 +1368,7 @@ For instance:
|
|||
It is safe to use multiple inheritance with SWIG.
|
||||
</p>
|
||||
|
||||
<H3><a name="Tcl_nn23"></a>39.3.9 Pointers, references, values, and arrays</H3>
|
||||
<H3><a name="Tcl_nn23"></a>40.3.9 Pointers, references, values, and arrays</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -1422,7 +1422,7 @@ to hold the result and a pointer is returned (Tcl will release this memory
|
|||
when the return value is garbage collected).
|
||||
</p>
|
||||
|
||||
<H3><a name="Tcl_nn24"></a>39.3.10 C++ overloaded functions</H3>
|
||||
<H3><a name="Tcl_nn24"></a>40.3.10 C++ overloaded functions</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -1545,7 +1545,7 @@ first declaration takes precedence.
|
|||
Please refer to the "SWIG and C++" chapter for more information about overloading.
|
||||
</p>
|
||||
|
||||
<H3><a name="Tcl_nn25"></a>39.3.11 C++ operators</H3>
|
||||
<H3><a name="Tcl_nn25"></a>40.3.11 C++ operators</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -1647,7 +1647,7 @@ There are ways to make this operator appear as part of the class using the <tt>%
|
|||
Keep reading.
|
||||
</p>
|
||||
|
||||
<H3><a name="Tcl_nn26"></a>39.3.12 C++ namespaces</H3>
|
||||
<H3><a name="Tcl_nn26"></a>40.3.12 C++ namespaces</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -1711,7 +1711,7 @@ utilizes thousands of small deeply nested namespaces each with
|
|||
identical symbol names, well, then you get what you deserve.
|
||||
</p>
|
||||
|
||||
<H3><a name="Tcl_nn27"></a>39.3.13 C++ templates</H3>
|
||||
<H3><a name="Tcl_nn27"></a>40.3.13 C++ templates</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -1763,7 +1763,7 @@ More details can be found in the <a href="SWIGPlus.html#SWIGPlus">SWIG and C++</
|
|||
examples will appear later.
|
||||
</p>
|
||||
|
||||
<H3><a name="Tcl_nn28"></a>39.3.14 C++ Smart Pointers</H3>
|
||||
<H3><a name="Tcl_nn28"></a>40.3.14 C++ Smart Pointers</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -1847,7 +1847,7 @@ simply use the <tt>__deref__()</tt> method. For example:
|
|||
</pre>
|
||||
</div>
|
||||
|
||||
<H2><a name="Tcl_nn29"></a>39.4 Further details on the Tcl class interface</H2>
|
||||
<H2><a name="Tcl_nn29"></a>40.4 Further details on the Tcl class interface</H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -1860,7 +1860,7 @@ of low-level details were omitted. This section provides a brief overview
|
|||
of how the proxy classes work.
|
||||
</p>
|
||||
|
||||
<H3><a name="Tcl_nn30"></a>39.4.1 Proxy classes</H3>
|
||||
<H3><a name="Tcl_nn30"></a>40.4.1 Proxy classes</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -1925,7 +1925,7 @@ function. This allows objects to be encapsulated objects that look a lot like
|
|||
as shown in the last section.
|
||||
</p>
|
||||
|
||||
<H3><a name="Tcl_nn31"></a>39.4.2 Memory management</H3>
|
||||
<H3><a name="Tcl_nn31"></a>40.4.2 Memory management</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -2113,7 +2113,7 @@ typemaps--an advanced topic discussed later.
|
|||
</p>
|
||||
|
||||
|
||||
<H2><a name="Tcl_nn32"></a>39.5 Input and output parameters</H2>
|
||||
<H2><a name="Tcl_nn32"></a>40.5 Input and output parameters</H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -2301,7 +2301,7 @@ set c [lindex $dim 1]
|
|||
</pre>
|
||||
</div>
|
||||
|
||||
<H2><a name="Tcl_nn33"></a>39.6 Exception handling </H2>
|
||||
<H2><a name="Tcl_nn33"></a>40.6 Exception handling </H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -2435,7 +2435,7 @@ Since SWIG's exception handling is user-definable, you are not limited to C++ ex
|
|||
See the chapter on "<a href="Customization.html#Customization">Customization Features</a>" for more examples.
|
||||
</p>
|
||||
|
||||
<H2><a name="Tcl_nn34"></a>39.7 Typemaps</H2>
|
||||
<H2><a name="Tcl_nn34"></a>40.7 Typemaps</H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -2452,7 +2452,7 @@ Typemaps are only used if you want to change some aspect of the primitive
|
|||
C-Tcl interface.
|
||||
</p>
|
||||
|
||||
<H3><a name="Tcl_nn35"></a>39.7.1 What is a typemap?</H3>
|
||||
<H3><a name="Tcl_nn35"></a>40.7.1 What is a typemap?</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -2569,7 +2569,7 @@ parameter is omitted):
|
|||
</pre>
|
||||
</div>
|
||||
|
||||
<H3><a name="Tcl_nn36"></a>39.7.2 Tcl typemaps</H3>
|
||||
<H3><a name="Tcl_nn36"></a>40.7.2 Tcl typemaps</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -2707,7 +2707,7 @@ Initialize an argument to a value before any conversions occur.
|
|||
Examples of these methods will appear shortly.
|
||||
</p>
|
||||
|
||||
<H3><a name="Tcl_nn37"></a>39.7.3 Typemap variables</H3>
|
||||
<H3><a name="Tcl_nn37"></a>40.7.3 Typemap variables</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -2778,7 +2778,7 @@ properly assigned.
|
|||
The Tcl name of the wrapper function being created.
|
||||
</div>
|
||||
|
||||
<H3><a name="Tcl_nn38"></a>39.7.4 Converting a Tcl list to a char ** </H3>
|
||||
<H3><a name="Tcl_nn38"></a>40.7.4 Converting a Tcl list to a char ** </H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -2840,7 +2840,7 @@ argv[2] = Larry
|
|||
3
|
||||
</pre></div>
|
||||
|
||||
<H3><a name="Tcl_nn39"></a>39.7.5 Returning values in arguments</H3>
|
||||
<H3><a name="Tcl_nn39"></a>40.7.5 Returning values in arguments</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -2882,7 +2882,7 @@ result, a Tcl function using these typemaps will work like this :
|
|||
%
|
||||
</pre></div>
|
||||
|
||||
<H3><a name="Tcl_nn40"></a>39.7.6 Useful functions</H3>
|
||||
<H3><a name="Tcl_nn40"></a>40.7.6 Useful functions</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -2958,7 +2958,7 @@ int Tcl_IsShared(Tcl_Obj *obj);
|
|||
</pre>
|
||||
</div>
|
||||
|
||||
<H3><a name="Tcl_nn41"></a>39.7.7 Standard typemaps</H3>
|
||||
<H3><a name="Tcl_nn41"></a>40.7.7 Standard typemaps</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -3043,7 +3043,7 @@ work)
|
|||
</pre>
|
||||
</div>
|
||||
|
||||
<H3><a name="Tcl_nn42"></a>39.7.8 Pointer handling</H3>
|
||||
<H3><a name="Tcl_nn42"></a>40.7.8 Pointer handling</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -3119,7 +3119,7 @@ For example:
|
|||
</pre>
|
||||
</div>
|
||||
|
||||
<H2><a name="Tcl_nn43"></a>39.8 Turning a SWIG module into a Tcl Package.</H2>
|
||||
<H2><a name="Tcl_nn43"></a>40.8 Turning a SWIG module into a Tcl Package.</H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -3191,7 +3191,7 @@ As a final note, most SWIG examples do not yet use the
|
|||
to use the <tt>load</tt> command instead.
|
||||
</p>
|
||||
|
||||
<H2><a name="Tcl_nn44"></a>39.9 Building new kinds of Tcl interfaces (in Tcl)</H2>
|
||||
<H2><a name="Tcl_nn44"></a>40.9 Building new kinds of Tcl interfaces (in Tcl)</H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -3290,7 +3290,7 @@ danger of blowing something up (although it is easily accomplished
|
|||
with an out of bounds array access).
|
||||
</p>
|
||||
|
||||
<H3><a name="Tcl_nn45"></a>39.9.1 Proxy classes</H3>
|
||||
<H3><a name="Tcl_nn45"></a>40.9.1 Proxy classes</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -3411,7 +3411,7 @@ short, but clever Tcl script can be combined with SWIG to do many
|
|||
interesting things.
|
||||
</p>
|
||||
|
||||
<H2><a name="Tcl_nn46"></a>39.10 Tcl/Tk Stubs</H2>
|
||||
<H2><a name="Tcl_nn46"></a>40.10 Tcl/Tk Stubs</H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
|
|||
|
|
@ -349,9 +349,9 @@ These can be overridden using command line options, for example:
|
|||
|
||||
<div class="shell"><pre>
|
||||
$ swig -python -Fstandard example.i
|
||||
example.i:4: Syntax error in input.
|
||||
example.i:4: Syntax error in input(1).
|
||||
$ swig -python -Fmicrosoft example.i
|
||||
example.i(4) : Syntax error in input.
|
||||
example.i(4) : Syntax error in input(1).
|
||||
</pre></div>
|
||||
|
||||
<H2><a name="Warnings_nn9"></a>15.9 Warning number reference</H2>
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ Pike.html
|
|||
Python.html
|
||||
R.html
|
||||
Ruby.html
|
||||
Scilab.html
|
||||
Tcl.html
|
||||
Extending.html
|
||||
Doxygen.html
|
||||
|
|
|
|||
|
|
@ -485,11 +485,10 @@ guile: $(SRCDIR_SRCS)
|
|||
$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ISRCS) $(SRCDIR_SRCS)
|
||||
$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(GUILE_LIBS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO)
|
||||
|
||||
guile_cpp: $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO)
|
||||
$(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO): $(SRCDIR_SRCS)
|
||||
guile_cpp: $(SRCDIR_SRCS)
|
||||
$(SWIG) -c++ -guile -Linkage passive $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
|
||||
$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS)
|
||||
$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(GUILE_LIBS) $(LIBS) $(CPP_DLLIBS) -o $@
|
||||
$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(GUILE_LIBS) $(LIBS) $(CPP_DLLIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO)
|
||||
|
||||
guile_externalhdr:
|
||||
$(SWIG) -guile -external-runtime $(TARGET)
|
||||
|
|
@ -596,7 +595,7 @@ java_cpp: $(SRCDIR_SRCS)
|
|||
# ----------------------------------------------------------------
|
||||
|
||||
java_compile: $(SRCDIR_SRCS)
|
||||
$(COMPILETOOL) $(JAVAC) $(JAVACFLAGS) $(addprefix $(SRCDIR),$(JAVASRCS))
|
||||
$(COMPILETOOL) $(JAVAC) $(addprefix $(SRCDIR),$(JAVASRCS))
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Run java example
|
||||
|
|
@ -633,9 +632,6 @@ java_clean:
|
|||
ROOT_DIR = @ROOT_DIR@
|
||||
JSINCLUDES = @JSCOREINC@ @JSV8INC@
|
||||
JSDYNAMICLINKING = @JSCOREDYNAMICLINKING@ @JSV8DYNAMICLINKING@
|
||||
JSSO =@JSSO@
|
||||
JSLDSHARED = @JSLDSHARED@
|
||||
JSCXXSHARED = @JSCXXSHARED@
|
||||
NODEJS = @NODEJS@
|
||||
NODEGYP = @NODEGYP@
|
||||
|
||||
|
|
@ -731,7 +727,7 @@ javascript_clean:
|
|||
rm -rf build
|
||||
rm -f *_wrap* $(RUNME)
|
||||
rm -f core @EXTRA_CLEAN@
|
||||
rm -f *.@OBJEXT@ *@JSSO@ *.$(SO)
|
||||
rm -f *.@OBJEXT@ *@SO@
|
||||
rm -f binding.gyp example-gypcopy.cxx
|
||||
cd $(ROOT_DIR)/Tools/javascript && $(MAKE) -s clean
|
||||
|
||||
|
|
@ -1096,7 +1092,7 @@ ruby_version:
|
|||
# -----------------------------------------------------------------
|
||||
|
||||
ruby_clean:
|
||||
rm -f *_wrap* *~ .~* myruby@EXEEXT@ *.pm
|
||||
rm -f *_wrap* *~ .~* myruby@EXEEXT@
|
||||
rm -f core @EXTRA_CLEAN@
|
||||
rm -f *.@OBJEXT@ *$(RUBY_SO)
|
||||
|
||||
|
|
@ -1668,7 +1664,6 @@ endif
|
|||
# ----------------------------------------------------------------
|
||||
# Build a R dynamically loadable module (C++)
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
r_cpp: $(SRCDIR_CXXSRCS)
|
||||
$(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACEPATH)
|
||||
ifneq ($(SRCDIR_CXXSRCS),)
|
||||
|
|
@ -1700,6 +1695,57 @@ r_clean:
|
|||
rm -f *.@OBJEXT@ *@SO@ NAMESPACE
|
||||
rm -f $(RRSRC) $(RUNME).Rout .RData
|
||||
|
||||
##################################################################
|
||||
##### SCILAB ######
|
||||
##################################################################
|
||||
|
||||
SCILAB = @SCILAB@
|
||||
SCILAB_INC= @SCILABINCLUDE@
|
||||
SCILAB_OPT = @SCILABOPT@
|
||||
SCILAB_LIBPREFIX = lib
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# Build a C dynamically loadable module
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
scilab:
|
||||
$(SWIG) -scilab $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
|
||||
$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SCILAB_INC) $(INCLUDES) $(ISRCS) $(SRCDIR_SRCS) $(SRCDIR_CSRCS)
|
||||
$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(IOBJS) $(OBJS) $(LIBS) -o $(SCILAB_LIBPREFIX)$(TARGET)$(SO)
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# Build a C++ dynamically loadable module
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
scilab_cpp:
|
||||
$(SWIG) -c++ -scilab $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
|
||||
$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(SCILAB_INC) $(INCLUDES) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS)
|
||||
$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(IOBJS) $(OBJS) $(LIBS) $(CPP_DLLIBS) -o $(SCILAB_LIBPREFIX)$(TARGET)$(SO)
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Running a Scilab example
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
scilab_run:
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(SCILAB) $(SCILAB_OPT) -f $(SRCDIR)$(RUNME).sci $(RUNPIPE)
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Scilab version
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
scilab_version:
|
||||
echo `$(SCILAB) -version | head -1`
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Cleaning the scilab examples
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
scilab_clean:
|
||||
rm -f *_wrap* *~ .~*
|
||||
rm -f core @EXTRA_CLEAN@
|
||||
rm -f *.@OBJEXT@ *@SO@
|
||||
rm -f *.sce
|
||||
|
||||
##################################################################
|
||||
##### Go ######
|
||||
##################################################################
|
||||
|
|
|
|||
|
|
@ -29,9 +29,15 @@ EXTRA_CXXFLAGS =
|
|||
EXTRA_LDFLAGS =
|
||||
TARGET = example_wrap
|
||||
SWIGOPT = -outcurrentdir
|
||||
DSRCS = *.d
|
||||
DFLAGS = -ofrunme
|
||||
|
||||
ifeq (,$(SRCDIR))
|
||||
DSRCS = *.d
|
||||
else
|
||||
DSRCS = *.d $(addprefix ../$(SRCDIR)$(VERSION_DIR),runme.d)
|
||||
endif
|
||||
|
||||
|
||||
check: build
|
||||
$(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' d_run
|
||||
|
||||
|
|
@ -44,7 +50,10 @@ build:
|
|||
else \
|
||||
$(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' SRCS='' d; \
|
||||
fi
|
||||
$(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' DSRCS='../$(SRCDIR)$(VERSION_DIR)runme.d $(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
|
||||
$(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
|
||||
|
||||
clean:
|
||||
$(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' d_clean
|
||||
if [ -d $(VERSION_DIR) ]; then \
|
||||
$(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' d_clean; \
|
||||
fi
|
||||
test -f $(VERSION_DIR)runme.d || rm -rf $(VERSION_DIR) # Only delete dir if out of source
|
||||
|
|
|
|||
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 */
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,22 @@
|
|||
return pf(a);
|
||||
}
|
||||
|
||||
#if defined(__SUNPRO_CC)
|
||||
// workaround for: Error: Could not find a match for foobar_T<T>(int, extern "C" int(*)(int)).
|
||||
extern "C" {
|
||||
typedef int (*foobar_int_int)(int a);
|
||||
typedef double (*foobar_double_double)(double a);
|
||||
};
|
||||
template <class T>
|
||||
int foobar_T(int a, foobar_int_int pf) {
|
||||
return pf(a);
|
||||
}
|
||||
template <class T>
|
||||
double foobar_T(double a, foobar_double_double pf) {
|
||||
return pf(a);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
const T& ident(const T& x) {
|
||||
return x;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -143,6 +143,7 @@ CPP_TEST_CASES += \
|
|||
class_scope_weird \
|
||||
compactdefaultargs \
|
||||
const_const_2 \
|
||||
constant_directive \
|
||||
constant_pointers \
|
||||
constover \
|
||||
constructor_copy \
|
||||
|
|
@ -298,6 +299,7 @@ CPP_TEST_CASES += \
|
|||
nested_directors \
|
||||
nested_comment \
|
||||
nested_scope \
|
||||
nested_template_base \
|
||||
nested_workaround \
|
||||
newobject1 \
|
||||
null_pointer \
|
||||
|
|
@ -306,6 +308,7 @@ CPP_TEST_CASES += \
|
|||
operator_pointer_ref \
|
||||
operbool \
|
||||
ordering \
|
||||
overload_arrays \
|
||||
overload_bool \
|
||||
overload_copy \
|
||||
overload_extend \
|
||||
|
|
@ -514,6 +517,7 @@ CPP11_TEST_CASES = \
|
|||
cpp11_decltype \
|
||||
cpp11_default_delete \
|
||||
cpp11_delegating_constructors \
|
||||
cpp11_director_enums \
|
||||
cpp11_explicit_conversion_operators \
|
||||
cpp11_final_override \
|
||||
cpp11_function_objects \
|
||||
|
|
|
|||
28
Examples/test-suite/constant_directive.i
Normal file
28
Examples/test-suite/constant_directive.i
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
%module constant_directive
|
||||
|
||||
// %constant and struct
|
||||
%{
|
||||
struct Type1 {
|
||||
Type1(int val = 0) : val(val) {}
|
||||
int val;
|
||||
};
|
||||
static Type1 TYPE1_CONSTANT1(1);
|
||||
static Type1 TYPE1_CONST2(2);
|
||||
static Type1 TYPE1_CONST3(3);
|
||||
%}
|
||||
|
||||
struct Type1 {
|
||||
Type1(int val = 0) : val(val) {}
|
||||
int val;
|
||||
};
|
||||
|
||||
%inline %{
|
||||
Type1 getType1Instance() { return Type1(111); }
|
||||
%}
|
||||
|
||||
%constant Type1 TYPE1_CONSTANT1;
|
||||
%constant Type1 TYPE1_CONSTANT2 = TYPE1_CONST2;
|
||||
%constant Type1 *TYPE1_CONSTANT3 = &TYPE1_CONST3;
|
||||
|
||||
%constant int TYPE_INT = 0;
|
||||
|
||||
|
|
@ -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) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,9 +20,13 @@
|
|||
Bar(){ }
|
||||
Bar(int){ }
|
||||
|
||||
#if !defined(__SUNPRO_CC)
|
||||
operator int() { return 0; }
|
||||
#endif
|
||||
operator int&() { static int num = 0; return num; }
|
||||
#if !defined(__SUNPRO_CC)
|
||||
operator Foo<T>() { return Foo<T>(); }
|
||||
#endif
|
||||
operator Foo<T>&() { return *(new Foo<T>()); }
|
||||
};
|
||||
}
|
||||
|
|
|
|||
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