Another merge with master.
Updated Doxygen error numbers yet again, as Python errors got added in the meanwhile, pushing the Doxygen ones further off. And re-merged PEP8/whitespace-related conflicts in autodoc_runme.py once again (if anybody is looking for a motivating example about why significant whitespace is bad, here is a great use case).
This commit is contained in:
commit
302955a152
448 changed files with 8836 additions and 5079 deletions
91
.gitignore
vendored
91
.gitignore
vendored
|
|
@ -101,32 +101,11 @@ Doc/Manual/SWIGDocumentation.html
|
||||||
Doc/Manual/SWIGDocumentation.pdf
|
Doc/Manual/SWIGDocumentation.pdf
|
||||||
Doc/Manual/*.book
|
Doc/Manual/*.book
|
||||||
|
|
||||||
# Test Suite Generated Files
|
# SWIG common generated files
|
||||||
Examples/test-suite/allegrocl/*/
|
|
||||||
Examples/test-suite/cffi/*/
|
|
||||||
Examples/test-suite/chicken/*/
|
|
||||||
Examples/test-suite/clisp/*/
|
|
||||||
Examples/test-suite/csharp/*/
|
|
||||||
Examples/test-suite/d/*/
|
|
||||||
Examples/test-suite/go/*/
|
|
||||||
Examples/test-suite/guile/*/
|
|
||||||
Examples/test-suite/java/*/
|
|
||||||
Examples/test-suite/javascript/*/
|
|
||||||
Examples/test-suite/lua/*/
|
|
||||||
Examples/test-suite/mzscheme/*/
|
|
||||||
Examples/test-suite/ocaml/*/
|
|
||||||
Examples/test-suite/octave/*/
|
|
||||||
Examples/test-suite/perl5/*/
|
|
||||||
Examples/test-suite/php/*/
|
|
||||||
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.c
|
||||||
|
*_wrap.cpp
|
||||||
*_wrap.cxx
|
*_wrap.cxx
|
||||||
|
*_wrap.h
|
||||||
*-gypcopy.cxx
|
*-gypcopy.cxx
|
||||||
|
|
||||||
# Scratch directories
|
# Scratch directories
|
||||||
|
|
@ -137,27 +116,73 @@ Examples/scratch
|
||||||
|
|
||||||
########## Language specific files ##########
|
########## Language specific files ##########
|
||||||
|
|
||||||
# C# generated files
|
# C#
|
||||||
*_runme.exe.mdb
|
Examples/test-suite/csharp/*/
|
||||||
*_runme.exe
|
*runme.exe.mdb
|
||||||
|
*runme.exe
|
||||||
|
Examples/csharp/*/*.cs
|
||||||
|
!Examples/csharp/*/runme.cs
|
||||||
|
|
||||||
# Go generated files
|
# D
|
||||||
|
Examples/test-suite/d/*/
|
||||||
|
Examples/d/**/example.d
|
||||||
|
Examples/d/**/example_im.d
|
||||||
|
Examples/d/**/runme
|
||||||
|
|
||||||
|
# Go
|
||||||
*.[5689]
|
*.[5689]
|
||||||
*_gc.c
|
*_gc.c
|
||||||
|
|
||||||
# Javascript generated files
|
# Guile
|
||||||
|
Examples/guile/*/my-guile
|
||||||
|
|
||||||
|
# Java
|
||||||
|
Examples/test-suite/java/*/
|
||||||
|
Examples/java/*/*.java
|
||||||
|
!Examples/java/*/runme.java
|
||||||
|
|
||||||
|
# Javascript
|
||||||
|
Examples/test-suite/javascript/*/
|
||||||
*.gyp
|
*.gyp
|
||||||
|
|
||||||
# Octave generated files
|
# Octave
|
||||||
swigexample*.oct
|
swigexample*.oct
|
||||||
Examples/test-suite/octave/*.oct
|
Examples/test-suite/octave/*.oct
|
||||||
|
|
||||||
# Python generated files, based on:
|
# Perl5
|
||||||
# https://github.com/github/gitignore/blob/master/Python.gitignore
|
Examples/test-suite/perl5/*.pm
|
||||||
|
Examples/perl5/*/*.pm
|
||||||
|
|
||||||
|
# PHP
|
||||||
|
Examples/test-suite/php/php_*.h
|
||||||
|
Examples/test-suite/php/*.php
|
||||||
|
!Examples/test-suite/php/*runme.php
|
||||||
|
!Examples/test-suite/php/skel.php
|
||||||
|
Examples/php/*/php_*.h
|
||||||
|
Examples/php/*/example.php
|
||||||
|
|
||||||
|
# Python
|
||||||
|
# Based on https://github.com/github/gitignore/blob/master/Python.gitignore
|
||||||
*.py[cod]
|
*.py[cod]
|
||||||
*/__pycache__/
|
*/__pycache__/
|
||||||
/__pycache__/
|
/__pycache__/
|
||||||
|
Examples/test-suite/python/*.py
|
||||||
|
!Examples/test-suite/python/*runme.py
|
||||||
|
Examples/python/*/example.py
|
||||||
|
Examples/python/**/bar.py
|
||||||
|
Examples/python/**/base.py
|
||||||
|
Examples/python/**/foo.py
|
||||||
|
Examples/python/**/spam.py
|
||||||
|
|
||||||
# Scilab generated files
|
# R
|
||||||
|
Examples/test-suite/r/*.R
|
||||||
|
Examples/test-suite/r/*.Rout
|
||||||
|
!Examples/test-suite/r/*runme.R
|
||||||
|
Examples/r/*/example.R
|
||||||
|
Examples/r/*/*.Rout
|
||||||
|
Examples/r/*/.RData
|
||||||
|
|
||||||
|
# Scilab
|
||||||
|
Examples/test-suite/scilab/*/
|
||||||
loader.sce
|
loader.sce
|
||||||
|
|
||||||
|
|
|
||||||
56
.travis.yml
56
.travis.yml
|
|
@ -1,11 +1,14 @@
|
||||||
language: cpp
|
language: cpp
|
||||||
compiler:
|
|
||||||
- clang
|
|
||||||
- gcc
|
|
||||||
env:
|
|
||||||
- SWIGLANG=
|
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
|
- compiler: clang
|
||||||
|
env: SWIGLANG=
|
||||||
|
- compiler: gcc
|
||||||
|
env: SWIGLANG=
|
||||||
|
- compiler: gcc
|
||||||
|
env: SWIGLANG= GCC5=1 CPP11=1
|
||||||
|
- compiler: gcc
|
||||||
|
env: SWIGLANG= GCC5=1 CPP14=1
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
env: SWIGLANG=csharp
|
env: SWIGLANG=csharp
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
|
|
@ -28,6 +31,8 @@ matrix:
|
||||||
env: SWIGLANG=octave SWIGJOBS=-j3 # 3.2
|
env: SWIGLANG=octave SWIGJOBS=-j3 # 3.2
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
env: SWIGLANG=octave SWIGJOBS=-j3 VER=3.8
|
env: SWIGLANG=octave SWIGJOBS=-j3 VER=3.8
|
||||||
|
- compiler: gcc
|
||||||
|
env: SWIGLANG=octave SWIGJOBS=-j3 VER=4.0
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
env: SWIGLANG=perl5
|
env: SWIGLANG=perl5
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
|
|
@ -50,27 +55,51 @@ matrix:
|
||||||
env: SWIGLANG=python SWIG_FEATURES=-builtin
|
env: SWIGLANG=python SWIG_FEATURES=-builtin
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3
|
env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3
|
||||||
|
- compiler: gcc
|
||||||
|
env: SWIGLANG=python SWIG_FEATURES=-O
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
env: SWIGLANG=python SWIG_FEATURES=-classic
|
env: SWIGLANG=python SWIG_FEATURES=-classic
|
||||||
|
- compiler: gcc
|
||||||
|
env: SWIGLANG=r
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
env: SWIGLANG=ruby
|
env: SWIGLANG=ruby
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
env: SWIGLANG=scilab
|
env: SWIGLANG=scilab
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
env: SWIGLANG=tcl
|
env: SWIGLANG=tcl
|
||||||
|
- compiler: gcc
|
||||||
|
env: SWIGLANG=csharp GCC5=1 CPP11=1
|
||||||
|
- compiler: gcc
|
||||||
|
env: SWIGLANG=java GCC5=1 CPP11=1
|
||||||
|
- compiler: gcc
|
||||||
|
env: SWIGLANG=python GCC5=1 CPP11=1
|
||||||
allow_failures:
|
allow_failures:
|
||||||
|
# Lots of failing tests currently
|
||||||
|
- compiler: gcc
|
||||||
|
env: SWIGLANG=ocaml
|
||||||
# Occasional gcc internal compiler error
|
# Occasional gcc internal compiler error
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
env: SWIGLANG=octave SWIGJOBS=-j3 VER=3.8
|
env: SWIGLANG=octave SWIGJOBS=-j3 VER=3.8
|
||||||
|
# Occasional gcc internal compiler error
|
||||||
|
- compiler: gcc
|
||||||
|
env: SWIGLANG=octave SWIGJOBS=-j3 VER=4.0
|
||||||
# Not quite working yet
|
# Not quite working yet
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
env: SWIGLANG=python SWIG_FEATURES=-classic
|
env: SWIGLANG=python SWIG_FEATURES=-classic
|
||||||
|
# Not quite working yet
|
||||||
|
- compiler: gcc
|
||||||
|
env: SWIGLANG=python SWIG_FEATURES=-O
|
||||||
|
# Runtime errors in Travis environment
|
||||||
|
- compiler: gcc
|
||||||
|
env: SWIGLANG=r
|
||||||
before_install:
|
before_install:
|
||||||
- date -u
|
- date -u
|
||||||
- uname -a
|
- uname -a
|
||||||
- lsb_release -a
|
- lsb_release -a
|
||||||
- sudo apt-get -qq update
|
- sudo apt-get -qq update
|
||||||
- time sudo apt-get -qq install libboost-dev
|
- if test -n "$GCC5"; then sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt-get -qq update && sudo apt-get install -qq g++-5 && export CC=gcc-5 && export CXX=g++-5; fi
|
||||||
|
- if test -z "$GCC5"; then sudo apt-get -qq install libboost-dev; fi
|
||||||
|
- if test -n "$GCC5"; then sudo add-apt-repository -y ppa:boost-latest/ppa && sudo apt-get -qq update && sudo apt-get install -qq libboost1.55-dev; fi
|
||||||
- if test -z "$SWIGLANG"; then sudo apt-get -qq install yodl; fi
|
- if test -z "$SWIGLANG"; then sudo apt-get -qq install yodl; fi
|
||||||
- if test "$SWIGLANG" = "csharp"; then sudo apt-get -qq install mono-devel; fi
|
- if test "$SWIGLANG" = "csharp"; then sudo apt-get -qq install mono-devel; fi
|
||||||
- if test "$SWIGLANG" = "d"; then wget http://downloads.dlang.org/releases/2014/dmd_2.066.0-0_amd64.deb; sudo dpkg -i dmd_2.066.0-0_amd64.deb; fi
|
- if test "$SWIGLANG" = "d"; then wget http://downloads.dlang.org/releases/2014/dmd_2.066.0-0_amd64.deb; sudo dpkg -i dmd_2.066.0-0_amd64.deb; fi
|
||||||
|
|
@ -80,22 +109,28 @@ before_install:
|
||||||
- if test "$SWIGLANG" = "javascript" -a "$ENGINE" = "v8"; then sudo apt-get install -qq libv8-dev; fi
|
- if test "$SWIGLANG" = "javascript" -a "$ENGINE" = "v8"; then sudo apt-get install -qq libv8-dev; fi
|
||||||
- if test "$SWIGLANG" = "guile"; then sudo apt-get -qq install guile-2.0-dev; fi
|
- if test "$SWIGLANG" = "guile"; then sudo apt-get -qq install guile-2.0-dev; fi
|
||||||
- if test "$SWIGLANG" = "lua"; then sudo apt-get -qq install lua5.1 liblua5.1-dev; fi
|
- if test "$SWIGLANG" = "lua"; then sudo apt-get -qq install lua5.1 liblua5.1-dev; fi
|
||||||
|
# configure also looks for ocamldlgen, but this isn't packaged. But it isn't used by default so this doesn't matter.
|
||||||
|
- if test "$SWIGLANG" = "ocaml"; then sudo apt-get -qq install ocaml ocaml-findlib; fi
|
||||||
- if test "$SWIGLANG" = "octave" -a -z "$VER"; then sudo apt-get -qq install octave3.2 octave3.2-headers; fi
|
- if test "$SWIGLANG" = "octave" -a -z "$VER"; then sudo apt-get -qq install octave3.2 octave3.2-headers; fi
|
||||||
- if test "$SWIGLANG" = "octave" -a "$VER"; then sudo add-apt-repository -y ppa:kwwette/octaves && sudo apt-get -qq update && sudo apt-get -qq install liboctave${VER}-dev; fi
|
- if test "$SWIGLANG" = "octave" -a "$VER"; then sudo add-apt-repository -y ppa:kwwette/octaves && sudo apt-get -qq update && sudo apt-get -qq install liboctave${VER}-dev; fi
|
||||||
- if test "$SWIGLANG" = "php"; then sudo apt-get install php5-cli php5-dev; fi
|
- if test "$SWIGLANG" = "php"; then sudo apt-get install php5-cli php5-dev; fi
|
||||||
- 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"; 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 "$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" = "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 && CONFIGOPTS+=("--with-python${PY3}=python${VER}"); fi
|
||||||
|
- if test "$SWIGLANG" = "r"; then sudo apt-get -qq install r-base; fi
|
||||||
- if test "$SWIGLANG" = "scilab"; then sudo apt-get -qq install scilab; 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
|
- if test "$SWIGLANG" = "tcl"; then sudo apt-get -qq install tcl8.4-dev; fi
|
||||||
|
- if test -n "$CPP11"; then CONFIGOPTS+=(--enable-cpp11-testing --without-maximum-compile-warnings "CXXFLAGS=-std=c++11 -Wall -Wextra" "CFLAGS=-std=c11 -Wall -Wextra") && export CSTD=c11 && export CPPSTD=c++11; fi
|
||||||
|
- if test -n "$CPP14"; then CONFIGOPTS+=(--enable-cpp11-testing --without-maximum-compile-warnings "CXXFLAGS=-std=c++14 -Wall -Wextra" "CFLAGS=-std=c11 -Wall -Wextra") && export CSTD=c11 && export CPPSTD=c++14; fi
|
||||||
- $CC --version
|
- $CC --version
|
||||||
- $CXX --version
|
- $CXX --version
|
||||||
# Stricter compile flags for examples. Various headers and SWIG generated code prevents full use of -pedantic.
|
# 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
|
- if test -n "$SWIGLANG"; then export cflags=$(Tools/testflags.py --language $SWIGLANG --cflags --std=$CSTD) && echo $cflags; fi
|
||||||
- export cxxflags=$(./testflags.py --language $SWIGLANG --cxxflags) && echo $cxxflags
|
- if test -n "$SWIGLANG"; then export cxxflags=$(Tools/testflags.py --language $SWIGLANG --cxxflags --std=$CPPSTD) && echo $cxxflags; fi
|
||||||
script:
|
script:
|
||||||
- echo 'Configuring...' && echo -en 'travis_fold:start:script.1\\r'
|
- echo 'Configuring...' && echo -en 'travis_fold:start:script.1\\r'
|
||||||
- ./autogen.sh && mkdir -p build/build && cd build/build && ../../configure $CONFIGOPTS
|
- echo "${CONFIGOPTS[@]}"
|
||||||
|
- ./autogen.sh && mkdir -p build/build && cd build/build && ../../configure "${CONFIGOPTS[@]}"
|
||||||
- echo -en 'travis_fold:end:script.1\\r'
|
- echo -en 'travis_fold:end:script.1\\r'
|
||||||
- make -s $SWIGJOBS
|
- make -s $SWIGJOBS
|
||||||
- ./swig -version && ./swig -pcreversion
|
- ./swig -version && ./swig -pcreversion
|
||||||
|
|
@ -113,4 +148,3 @@ script:
|
||||||
branches:
|
branches:
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
- error-declaration-after-statement
|
|
||||||
|
|
|
||||||
8
ANNOUNCE
8
ANNOUNCE
|
|
@ -1,8 +1,8 @@
|
||||||
*** ANNOUNCE: SWIG 3.0.6 (in progress) ***
|
*** ANNOUNCE: SWIG 3.0.7 (in progress) ***
|
||||||
|
|
||||||
http://www.swig.org
|
http://www.swig.org
|
||||||
|
|
||||||
We're pleased to announce SWIG-3.0.6, the latest SWIG release.
|
We're pleased to announce SWIG-3.0.7, the latest SWIG release.
|
||||||
|
|
||||||
What is SWIG?
|
What is SWIG?
|
||||||
=============
|
=============
|
||||||
|
|
@ -22,11 +22,11 @@ Availability
|
||||||
============
|
============
|
||||||
The release is available for download on Sourceforge at
|
The release is available for download on Sourceforge at
|
||||||
|
|
||||||
http://prdownloads.sourceforge.net/swig/swig-3.0.6.tar.gz
|
http://prdownloads.sourceforge.net/swig/swig-3.0.7.tar.gz
|
||||||
|
|
||||||
A Windows version is also available at
|
A Windows version is also available at
|
||||||
|
|
||||||
http://prdownloads.sourceforge.net/swig/swigwin-3.0.6.zip
|
http://prdownloads.sourceforge.net/swig/swigwin-3.0.7.zip
|
||||||
|
|
||||||
Please report problems with this release to the swig-devel mailing list,
|
Please report problems with this release to the swig-devel mailing list,
|
||||||
details at http://www.swig.org/mail.html.
|
details at http://www.swig.org/mail.html.
|
||||||
|
|
|
||||||
|
|
@ -402,6 +402,29 @@ swigtests() {
|
||||||
rm -rf $TESTDIR
|
rm -rf $TESTDIR
|
||||||
mkdir $TESTDIR
|
mkdir $TESTDIR
|
||||||
cd $TESTDIR || exit 1
|
cd $TESTDIR || exit 1
|
||||||
|
|
||||||
|
unset CCACHE_DIR
|
||||||
|
unset CCACHE_TEMPDIR
|
||||||
|
unset CCACHE_LOGFILE
|
||||||
|
unset CCACHE_VERBOSE
|
||||||
|
unset CCACHE_PATH
|
||||||
|
unset CCACHE_CC
|
||||||
|
unset CCACHE_PREFIX
|
||||||
|
unset CCACHE_DISABLE
|
||||||
|
unset CCACHE_READONLY
|
||||||
|
unset CCACHE_CPP2
|
||||||
|
unset CCACHE_NOCOMPRESS
|
||||||
|
unset CCACHE_NOSTATS
|
||||||
|
unset CCACHE_NLEVELS
|
||||||
|
unset CCACHE_HARDLINK
|
||||||
|
unset CCACHE_RECACHE
|
||||||
|
unset CCACHE_UMASK
|
||||||
|
unset CCACHE_HASHDIR
|
||||||
|
unset CCACHE_UNIFY
|
||||||
|
unset CCACHE_EXTENSION
|
||||||
|
unset CCACHE_STRIPC
|
||||||
|
unset CCACHE_SWIG
|
||||||
|
|
||||||
CCACHE_DIR="ccache dir" # with space in directory name (like Windows default)
|
CCACHE_DIR="ccache dir" # with space in directory name (like Windows default)
|
||||||
mkdir "$CCACHE_DIR"
|
mkdir "$CCACHE_DIR"
|
||||||
export CCACHE_DIR
|
export CCACHE_DIR
|
||||||
|
|
|
||||||
212
CHANGES
212
CHANGES
|
|
@ -3,6 +3,208 @@ SWIG (Simplified Wrapper and Interface Generator)
|
||||||
See the CHANGES.current file for changes in the current version.
|
See the CHANGES.current file for changes in the current version.
|
||||||
See the RELEASENOTES file for a summary of changes in each release.
|
See the RELEASENOTES file for a summary of changes in each release.
|
||||||
|
|
||||||
|
Version 3.0.6 (5 Jul 2015)
|
||||||
|
==========================
|
||||||
|
|
||||||
|
2015-07-02: wsfulton
|
||||||
|
Fix syntax error when the template keyword is used in types, eg:
|
||||||
|
|
||||||
|
std::template vector<int> v;
|
||||||
|
|
||||||
|
2015-07-02: ngladitz
|
||||||
|
[Lua] Push characters as unformatted 1-character strings to avoid
|
||||||
|
unprintable characters such as (char)127 being converted to
|
||||||
|
"<\127>" with Lua 5.3 and later. (github PR #452)
|
||||||
|
|
||||||
|
2015-06-29: olly
|
||||||
|
[Python] Improve handling of whitespace in %pythoncode.
|
||||||
|
|
||||||
|
Previously SWIG looked at the indentation of the first line and
|
||||||
|
removed that many characters from each subsequent line, regardless
|
||||||
|
of what those characters were. This was made worse because SWIG's
|
||||||
|
preprocessor removes any whitespace before a '#'. Fixes github
|
||||||
|
issue #379, reported by Joe Orton.
|
||||||
|
|
||||||
|
2015-06-12: wsfulton
|
||||||
|
[R] Fix #430 - call to SWIG_createNewRef in copyToC was incorrectly named.
|
||||||
|
|
||||||
|
2015-06-11: sghirate
|
||||||
|
[C#] Patch #427 adds in new command line option -outfile to combine all the
|
||||||
|
generated C# code into a single file.
|
||||||
|
|
||||||
|
2015-06-09: wsfulton
|
||||||
|
Fix seg fault processing C++11 type aliasing. Issue #424.
|
||||||
|
|
||||||
|
2015-05-28: wsfulton
|
||||||
|
[Python] Add new feature "python:cdefaultargs" to control default argument
|
||||||
|
code generation. By default, SWIG attempts to convert C/C++ default argument values
|
||||||
|
into Python values and generates code into the Python layer with these values.
|
||||||
|
Recent versions of SWIG are able to convert more of these values, however, the
|
||||||
|
new behaviour can be circumvented if desired via this new feature, such that
|
||||||
|
the default argument values are obtained from the C layer and not the Python layer.
|
||||||
|
For example:
|
||||||
|
|
||||||
|
struct CDA {
|
||||||
|
int fff(int a = 1, bool b = false);
|
||||||
|
};
|
||||||
|
|
||||||
|
The default code generation in the Python layer is:
|
||||||
|
|
||||||
|
class CDA(_object):
|
||||||
|
...
|
||||||
|
def fff(self, a=1, b=False):
|
||||||
|
return _default_args.CDA_fff(self, a, b)
|
||||||
|
|
||||||
|
Adding the feature:
|
||||||
|
|
||||||
|
%feature("python:cdefaultargs") CDA::fff;
|
||||||
|
|
||||||
|
Results in:
|
||||||
|
|
||||||
|
class CDA(_object):
|
||||||
|
...
|
||||||
|
def fff(self, *args):
|
||||||
|
return _default_args.CDA_fff(self, *args)
|
||||||
|
|
||||||
|
Some code generation modes, eg -builtin and -fastproxy, are unaffected by this as
|
||||||
|
the default values are always obtained from the C layer.
|
||||||
|
|
||||||
|
2015-05-27: wsfulton
|
||||||
|
[Python] Deal with an integer as the default value of a typedef to bool
|
||||||
|
parameter in the C++ prototype. See #327. Regression from 3.0.0 onwards.
|
||||||
|
|
||||||
|
2015-05-19: olly
|
||||||
|
[Python] Fix warning when compiling generated code with MSVC.
|
||||||
|
(Fixes https://sourceforge.net/p/swig/patches/351/ reported by
|
||||||
|
Mateusz Szyma¿ski).
|
||||||
|
|
||||||
|
2015-05-14: wsfulton
|
||||||
|
Fix seg fault wrapping shared_ptr of classes with private constructors and destructors.
|
||||||
|
This also fixes the "unref" feature when used on classes with private destructors.
|
||||||
|
|
||||||
|
2015-05-10: wsfulton
|
||||||
|
[Java] Fix multi-argument typemaps (char *STRING, size_t LENGTH)
|
||||||
|
so that they can be applied to a wider range of types. Fixes #385.
|
||||||
|
|
||||||
|
2015-05-07: olly
|
||||||
|
[Python] Deal with an integer as the default value of a bool
|
||||||
|
parameter in the C++ prototype. Fixes github #327, reported by
|
||||||
|
Greg Allen.
|
||||||
|
|
||||||
|
2015-05-07: LindleyF
|
||||||
|
[Java] Allow feature("director") and feature("ref") to be used
|
||||||
|
together. Github PR#403.
|
||||||
|
|
||||||
|
2015-05-05: olly
|
||||||
|
Suppress warning 325 "Nested class not currently supported (Foo
|
||||||
|
ignored)" when Foo has already been explicitly ignored with "%ignore".
|
||||||
|
|
||||||
|
2015-05-04: wsfulton
|
||||||
|
Add support for friend templates, including operator overloading - fixes #196. Considering
|
||||||
|
the example below, previously the operator gave a syntax error and friendfunc incorrectly
|
||||||
|
warned with:
|
||||||
|
|
||||||
|
"Warning 503: Can't wrap 'friendfunc<(Type)>' unless renamed to a valid identifier."
|
||||||
|
|
||||||
|
template <class Type> class MyClass {
|
||||||
|
friend int friendfunc <Type>(double is, MyClass <Type> & x);
|
||||||
|
friend int operator<< <Type>(double un, const MyClass <Type> &x);
|
||||||
|
};
|
||||||
|
|
||||||
|
The following also previously incorrectly warned with:
|
||||||
|
|
||||||
|
"Warning 302: Identifier 'template_friend' redefined (ignored),"
|
||||||
|
|
||||||
|
template<typename T> T template_friend(T);
|
||||||
|
struct MyTemplate {
|
||||||
|
template<typename T> friend T template_friend(T);
|
||||||
|
};
|
||||||
|
|
||||||
|
2015-05-01: wsfulton
|
||||||
|
Fix handling of conversion operators where the operator is split over multiple
|
||||||
|
lines or has comments within the operator type. Fixes #401.
|
||||||
|
|
||||||
|
Also fix similar problem with normal operators which gave a syntax error if split over
|
||||||
|
multiple lines or had a comment within the operator declaration.
|
||||||
|
|
||||||
|
2015-04-30: olly
|
||||||
|
Ignore unknown preprocessor directives which are inside an inactive
|
||||||
|
conditional (github issue #394, reported by Dan Wilcox).
|
||||||
|
Regression introduced in 3.0.3.
|
||||||
|
|
||||||
|
2015-04-27: vadz
|
||||||
|
[Python] Fix "default" typemap used after an argument with "numinputs=0" (#377).
|
||||||
|
|
||||||
|
2015-04-24: wsfulton
|
||||||
|
[Python] Fix #256. Code generated with '-builtin -modernargs' segfaults for any
|
||||||
|
method taking zero arguments.
|
||||||
|
|
||||||
|
Also fixes: "SystemError: error return without exception set" during error checking
|
||||||
|
when using just -builtin and the incorrect number of arguments is passed to a class
|
||||||
|
method expecting zero arguments.
|
||||||
|
|
||||||
|
2015-04-23: wsfulton
|
||||||
|
[Java] Bug #386 - Memory leak fix in (char *STRING, size_t LENGTH) typemaps.
|
||||||
|
|
||||||
|
2015-04-23: vadz
|
||||||
|
[Python] Make "default" typemap work again (#330, #377).
|
||||||
|
|
||||||
|
2015-04-23: vadz
|
||||||
|
[Python] Fix the use of default values for the pointer types (#365, #376).
|
||||||
|
|
||||||
|
2015-04-23: wsfulton
|
||||||
|
Fix 'make check-ccache' which is part of 'make check' when one of the CCACHE_
|
||||||
|
environment variables, for example CCACHE_DISABLE, is set.
|
||||||
|
|
||||||
|
2015-04-14: wsfulton
|
||||||
|
Clearer warning message for badly constructed typecheck typemaps. For example, was:
|
||||||
|
|
||||||
|
example.i:3: Warning 467: Overloaded foo(int) not supported (no type checking
|
||||||
|
rule for 'int').
|
||||||
|
|
||||||
|
Now:
|
||||||
|
|
||||||
|
example.i:3: Warning 467: Overloaded foo(int) not supported (incomplete type checking
|
||||||
|
rule - no precedence level in typecheck typemap for 'int').
|
||||||
|
|
||||||
|
2015-04-11: wsfulton
|
||||||
|
[Java] Fix #353 - Linker multiple definition of 'ExceptionMatches' when
|
||||||
|
using directors and multiple modules.
|
||||||
|
|
||||||
|
2015-04-11: wsfulton
|
||||||
|
Merge #320 - Make __dict__ accessible for Python builtin classes.
|
||||||
|
|
||||||
|
2015-04-07: wsfulton
|
||||||
|
Fix #375 - parsing of extern "C" and typedef for example:
|
||||||
|
extern "C" typedef void (*Hook2_t)(int, const char *);
|
||||||
|
extern "C" typedef int Integer;
|
||||||
|
|
||||||
|
2015-03-12: olly
|
||||||
|
-DSWIG_DIRECTOR_STATIC is now supported for all languages with
|
||||||
|
director support, not only Python and PHP.
|
||||||
|
|
||||||
|
2015-03-02: ianlancetaylor
|
||||||
|
[Go] Add -cgo option, required for Go versions 1.5 and
|
||||||
|
later.
|
||||||
|
|
||||||
|
2015-02-26: olly
|
||||||
|
Fix segmentation fault when top==NULL, introduced by nested class
|
||||||
|
handling (reported in issue#346 by Pawe¿ Tomulik).
|
||||||
|
|
||||||
|
2015-02-09: wsfulton
|
||||||
|
[Guile] Fix generated code for static const char member variables when
|
||||||
|
defined and declared inline.
|
||||||
|
|
||||||
|
2015-02-09: mishas
|
||||||
|
[Go] Fix %import of files in sub directories.
|
||||||
|
|
||||||
|
2015-02-05: ianlancetaylor
|
||||||
|
[Go] Ignore Go specific type maps (goin, goout, etc.) if they are empty.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
Version 3.0.5 (31 Jan 2015)
|
Version 3.0.5 (31 Jan 2015)
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
|
|
@ -100,6 +302,10 @@ Version 3.0.3 (30 Dec 2014)
|
||||||
[Python] Patch #201 The generated .py file no longer uses *args for all Python parameters.
|
[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.
|
Instead, the parameters are named using the C++ parameter names.
|
||||||
|
|
||||||
|
"compactdefaultargs" feature can be enabled to restore the old behaviour.
|
||||||
|
|
||||||
|
*** POTENTIAL INCOMPATIBILITY ***
|
||||||
|
|
||||||
2014-10-24: timotheecour
|
2014-10-24: timotheecour
|
||||||
[D] Patch #204 Use core.atomic.atomicOp to mutate shared variables
|
[D] Patch #204 Use core.atomic.atomicOp to mutate shared variables
|
||||||
|
|
||||||
|
|
@ -10707,7 +10913,7 @@ Version 1.3.23 (November 11, 2004)
|
||||||
|
|
||||||
now if you have
|
now if you have
|
||||||
|
|
||||||
%pythonnondynamic(1) A;
|
%pythonnondynamic A;
|
||||||
|
|
||||||
struct A {
|
struct A {
|
||||||
int a;
|
int a;
|
||||||
|
|
@ -10725,11 +10931,11 @@ Version 1.3.23 (November 11, 2004)
|
||||||
|
|
||||||
Since this is a feature, you can use
|
Since this is a feature, you can use
|
||||||
|
|
||||||
%pythonnondynamic(1);
|
%pythonnondynamic;
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
%pythondynamic(0); [ Note: %pythondynamic since deprecated ]
|
%pythondynamic; [ Note: %pythondynamic since deprecated ]
|
||||||
|
|
||||||
to force all the wrapped classes to be "nondynamic" ones.
|
to force all the wrapped classes to be "nondynamic" ones.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,27 @@ Below are the changes for the current release.
|
||||||
See the CHANGES file for changes in older releases.
|
See the CHANGES file for changes in older releases.
|
||||||
See the RELEASENOTES file for a summary of changes in each release.
|
See the RELEASENOTES file for a summary of changes in each release.
|
||||||
|
|
||||||
Version 3.0.6 (in progress)
|
Version 3.0.7 (in progress)
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
2015-02-09: wsfulton
|
2015-07-18: m7thon
|
||||||
[Guile] Fix generated code for static const char member variables when
|
[Python] Docstrings provided via %feature("docstring") are now quoted and added to
|
||||||
defined and declared inline.
|
the tp_doc slot when using python builtin classes (-builtin). When no docstring is
|
||||||
|
provided, the tp_doc slot is set to the fully qualified C/C++ class name.
|
||||||
|
Github issues #445 and #461.
|
||||||
|
|
||||||
2015-02-05: ianlancetaylor
|
2015-07-17: kwwette
|
||||||
[Go] Ignore Go specific type maps (goin, goout, etc.) if they are empty.
|
[octave] Support Octave version 4.0.0 (thanks to patches from Orion Poplawski).
|
||||||
|
|
||||||
|
2015-07-07: wsfulton
|
||||||
|
SWIG no longer generates a wrapper for a class' constructor if that class has
|
||||||
|
any base class with a private destructor. This is because your compiler should
|
||||||
|
not allow a class to be instantiated if a base has a private destructor. Some
|
||||||
|
compilers do, so if you need the old behaviour, use the "notabstract" feature, eg:
|
||||||
|
|
||||||
|
%feature("notabstract") Derived;
|
||||||
|
class Base {
|
||||||
|
~Base() {}
|
||||||
|
};
|
||||||
|
struct Derived : Base {};
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
<li><a href="#CSharp_introduction">Introduction</a>
|
<li><a href="#CSharp_introduction">Introduction</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#CSharp_introduction_swig2_compatibility">SWIG 2 Compatibility</a>
|
<li><a href="#CSharp_introduction_swig2_compatibility">SWIG 2 Compatibility</a>
|
||||||
|
<li><a href="#CSharp_commandline">Additional command line options</a>
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="#CSharp_differences_java">Differences to the Java module</a>
|
<li><a href="#CSharp_differences_java">Differences to the Java module</a>
|
||||||
<li><a href="#CSharp_void_pointers">Void pointers</a>
|
<li><a href="#CSharp_void_pointers">Void pointers</a>
|
||||||
|
|
@ -34,7 +35,7 @@
|
||||||
<li><a href="#CSharp_directors_implementation">Directors implementation</a>
|
<li><a href="#CSharp_directors_implementation">Directors implementation</a>
|
||||||
<li><a href="#CSharp_director_caveats">Director caveats</a>
|
<li><a href="#CSharp_director_caveats">Director caveats</a>
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="#CSharp_multiple_modules">Multiples modules</a>
|
<li><a href="#CSharp_multiple_modules">Multiple modules</a>
|
||||||
<li><a href="#CSharp_typemap_examples">C# Typemap examples</a>
|
<li><a href="#CSharp_typemap_examples">C# Typemap examples</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#CSharp_memory_management_member_variables">Memory management when returning references to member variables</a>
|
<li><a href="#CSharp_memory_management_member_variables">Memory management when returning references to member variables</a>
|
||||||
|
|
@ -79,6 +80,59 @@ Monodoc, available from the Mono project, has a very useful section titled <a hr
|
||||||
In order to minimize name collisions between names generated based on input to SWIG and names used in the generated code from the .NET framework, SWIG 3 fully qualifies the use of all .NET types. Furthermore, SWIG 3 avoids <tt>using</tt> directives in generated code. This breaks backwards compatibility with typemaps, pragmas, etc written for use with SWIG 2 that assume the presence of <tt>using System;</tt> or <tt>using System.Runtime.InteropServices;</tt> directives in the intermediate class imports, module imports, or proxy imports. SWIG 3 supports backwards compatibility though the use of the <tt>SWIG2_CSHARP</tt> macro. If <tt>SWIG2_CSHARP</tt> is defined, SWIG 3 generates <tt>using</tt> directives in the intermediate class, module class, and proxy class code similar to those generated by SWIG 2. This can be done without modifying any of the input code by passing the <tt>-DSWIG2_CSHARP</tt> commandline parameter when executing <tt>swig</tt>.
|
In order to minimize name collisions between names generated based on input to SWIG and names used in the generated code from the .NET framework, SWIG 3 fully qualifies the use of all .NET types. Furthermore, SWIG 3 avoids <tt>using</tt> directives in generated code. This breaks backwards compatibility with typemaps, pragmas, etc written for use with SWIG 2 that assume the presence of <tt>using System;</tt> or <tt>using System.Runtime.InteropServices;</tt> directives in the intermediate class imports, module imports, or proxy imports. SWIG 3 supports backwards compatibility though the use of the <tt>SWIG2_CSHARP</tt> macro. If <tt>SWIG2_CSHARP</tt> is defined, SWIG 3 generates <tt>using</tt> directives in the intermediate class, module class, and proxy class code similar to those generated by SWIG 2. This can be done without modifying any of the input code by passing the <tt>-DSWIG2_CSHARP</tt> commandline parameter when executing <tt>swig</tt>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<H3><a name="CSharp_commandline"></a>20.1.2 Additional command line options</H3>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The following table lists the additional commandline options available for the C# module. They can also be seen by using:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="code"><pre>
|
||||||
|
swig -csharp -help
|
||||||
|
</pre></div>
|
||||||
|
|
||||||
|
<table summary="C# specific options">
|
||||||
|
<tr>
|
||||||
|
<th>C# specific options</th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>-dllimport <dl></td>
|
||||||
|
<td>Override DllImport attribute name to <dl></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>-namespace <nm></td>
|
||||||
|
<td>Generate wrappers into C# namespace <nm></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>-noproxy</td>
|
||||||
|
<td>Generate the low-level functional interface instead of proxy classes</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>-oldvarnames</td>
|
||||||
|
<td>Old intermediary method names for variable wrappers</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>-outfile <file></td>
|
||||||
|
<td>Write all C# into a single <file> located in the output directory
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The -outfile option combines all the generated C# code into a single output file instead of creating multiple C# files.
|
||||||
|
The default, when this option is not provided, is to generate separate .cs files for the module class,
|
||||||
|
intermediary class and each of the generated proxy and type wrapper classes.
|
||||||
|
Note that the file extension (.cs) will not be automatically added and needs to be provided.
|
||||||
|
Due to possible compiler limits it is not advisable to use <tt>-outfile</tt> for large projects.
|
||||||
|
</p>
|
||||||
|
|
||||||
<H2><a name="CSharp_differences_java"></a>20.2 Differences to the Java module</H2>
|
<H2><a name="CSharp_differences_java"></a>20.2 Differences to the Java module</H2>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1682,7 +1736,7 @@ However, a call from C# to <tt>CSharpDefaults.DefaultMethod()</tt> will of cours
|
||||||
should pass the call on to <tt>CSharpDefaults.DefaultMethod(int)</tt>using the C++ default value, as shown above.
|
should pass the call on to <tt>CSharpDefaults.DefaultMethod(int)</tt>using the C++ default value, as shown above.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="CSharp_multiple_modules"></a>20.7 Multiples modules</H2>
|
<H2><a name="CSharp_multiple_modules"></a>20.7 Multiple modules</H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -725,6 +725,7 @@
|
||||||
<li><a href="CSharp.html#CSharp_introduction">Introduction</a>
|
<li><a href="CSharp.html#CSharp_introduction">Introduction</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="CSharp.html#CSharp_introduction_swig2_compatibility">SWIG 2 Compatibility</a>
|
<li><a href="CSharp.html#CSharp_introduction_swig2_compatibility">SWIG 2 Compatibility</a>
|
||||||
|
<li><a href="CSharp.html#CSharp_commandline">Additional command line options</a>
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="CSharp.html#CSharp_differences_java">Differences to the Java module</a>
|
<li><a href="CSharp.html#CSharp_differences_java">Differences to the Java module</a>
|
||||||
<li><a href="CSharp.html#CSharp_void_pointers">Void pointers</a>
|
<li><a href="CSharp.html#CSharp_void_pointers">Void pointers</a>
|
||||||
|
|
@ -747,7 +748,7 @@
|
||||||
<li><a href="CSharp.html#CSharp_directors_implementation">Directors implementation</a>
|
<li><a href="CSharp.html#CSharp_directors_implementation">Directors implementation</a>
|
||||||
<li><a href="CSharp.html#CSharp_director_caveats">Director caveats</a>
|
<li><a href="CSharp.html#CSharp_director_caveats">Director caveats</a>
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="CSharp.html#CSharp_multiple_modules">Multiples modules</a>
|
<li><a href="CSharp.html#CSharp_multiple_modules">Multiple modules</a>
|
||||||
<li><a href="CSharp.html#CSharp_typemap_examples">C# Typemap examples</a>
|
<li><a href="CSharp.html#CSharp_typemap_examples">C# Typemap examples</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="CSharp.html#CSharp_memory_management_member_variables">Memory management when returning references to member variables</a>
|
<li><a href="CSharp.html#CSharp_memory_management_member_variables">Memory management when returning references to member variables</a>
|
||||||
|
|
@ -1074,7 +1075,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="Javascript.html#Javascript_applications_webkit">Creating Applications with node-webkit</a>
|
<li><a href="Javascript.html#Javascript_applications_webkit">Creating Applications with node-webkit</a>
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="Javascript.html#Javascript_nn14">Examples</a>
|
<li><a href="Javascript.html#Javascript_examples">Examples</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="Javascript.html#Javascript_simple_example">Simple</a>
|
<li><a href="Javascript.html#Javascript_simple_example">Simple</a>
|
||||||
<li><a href="Javascript.html#Javascript_class_example">Class</a>
|
<li><a href="Javascript.html#Javascript_class_example">Class</a>
|
||||||
|
|
@ -1529,6 +1530,7 @@
|
||||||
<li><a href="Python.html#Python_nn47">Simple pointers</a>
|
<li><a href="Python.html#Python_nn47">Simple pointers</a>
|
||||||
<li><a href="Python.html#Python_nn48">Unbounded C Arrays</a>
|
<li><a href="Python.html#Python_nn48">Unbounded C Arrays</a>
|
||||||
<li><a href="Python.html#Python_nn49">String handling</a>
|
<li><a href="Python.html#Python_nn49">String handling</a>
|
||||||
|
<li><a href="Python.html#Python_default_args">Default arguments</a>
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="Python.html#Python_nn53">Typemaps</a>
|
<li><a href="Python.html#Python_nn53">Typemaps</a>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -1762,7 +1764,7 @@
|
||||||
<li><a href="Scilab.html#Scilab_wrapping_pointers_null_pointers">Null pointers</a>
|
<li><a href="Scilab.html#Scilab_wrapping_pointers_null_pointers">Null pointers</a>
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="Scilab.html#Scilab_wrapping_structs">Structures</a>
|
<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_classes">C++ classes</a>
|
||||||
<li><a href="Scilab.html#Scilab_wrapping_cpp_inheritance">C++ inheritance</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_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_templates">C++ templates</a>
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,14 @@ swig -go -help
|
||||||
<th>Go specific options</th>
|
<th>Go specific options</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>-cgo</td>
|
||||||
|
<td>Generate files to be used as input for the Go cgo tool. This
|
||||||
|
option is required for Go 1.5 and later, and works for Go 1.2 and
|
||||||
|
later. In the future this option will likely become the
|
||||||
|
default.</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>-intgosize <s></td>
|
<td>-intgosize <s></td>
|
||||||
<td>Set the size for the Go type <tt>int</tt>. This controls the size
|
<td>Set the size for the Go type <tt>int</tt>. This controls the size
|
||||||
|
|
@ -171,8 +179,13 @@ swig -go -help
|
||||||
<H3><a name="Go_outputs"></a>23.3.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
|
<p>There are two different approaches to generating output files,
|
||||||
files:</p>
|
controlled by SWIG's <tt>-cgo</tt> option. The <tt>-cgo</tt> option
|
||||||
|
works with Go version 1.2 or later. It is required when using Go
|
||||||
|
version 1.5 or later.</p>
|
||||||
|
|
||||||
|
<p>With or without the <tt>-cgo</tt> option, SWIG will generate the
|
||||||
|
following files when generating Go code:</p>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
|
|
@ -180,21 +193,30 @@ MODULE.go will contain the Go functions that your Go code will call.
|
||||||
These functions will be wrappers for the C++ functions defined by your
|
These functions will be wrappers for the C++ functions defined by your
|
||||||
module. This file should, of course, be compiled with the Go
|
module. This file should, of course, be compiled with the Go
|
||||||
compiler.
|
compiler.
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
MODULE_wrap.c or MODULE_wrap.cxx will contain C/C++ functions will be
|
MODULE_wrap.c or MODULE_wrap.cxx will contain C/C++ functions will be
|
||||||
invoked by the Go wrapper code. This file should be compiled with the
|
invoked by the Go wrapper code. This file should be compiled with the
|
||||||
usual C or C++ compiler and linked into a shared library.
|
usual C or C++ compiler.
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
MODULE_wrap.h will be generated if you use the directors feature. It
|
MODULE_wrap.h will be generated if you use the directors feature. It
|
||||||
provides a definition of the generated C++ director classes. It is
|
provides a definition of the generated C++ director classes. It is
|
||||||
generally not necessary to use this file, but in some special cases it
|
generally not necessary to use this file, but in some special cases it
|
||||||
may be helpful to include it in your code, compiled with the usual C
|
may be helpful to include it in your code, compiled with the usual C
|
||||||
or C++ compiler.
|
or C++ compiler.
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<p>When neither the <tt>-cgo</tt> nor the <tt>-gccgo</tt> option is
|
||||||
|
used, SWIG will also generate an additional file:</p>
|
||||||
|
|
||||||
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
If using the gc compiler, MODULE_gc.c will contain C code which should
|
MODULE_gc.c will contain C code which should be compiled with the C
|
||||||
be compiled with the C compiler distributed as part of the gc
|
compiler distributed as part of the gc compiler. It should then be
|
||||||
compiler. It should then be combined with the compiled MODULE.go
|
combined with the compiled MODULE.go using go tool pack.
|
||||||
using gopack. This file will not be generated when using gccgo.
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -203,14 +225,33 @@ support for SWIG. To use it, put your SWIG interface into a file with
|
||||||
the extension .swig, or, if you are wrapping C++ code, .swigcxx. Put
|
the extension .swig, or, if you are wrapping C++ code, .swigcxx. Put
|
||||||
that file in a GOPATH/src directory as usual for Go sources. Put
|
that file in a GOPATH/src directory as usual for Go sources. Put
|
||||||
other interface code in the same directory with extensions of .c and
|
other interface code in the same directory with extensions of .c and
|
||||||
.cxx. The go build command and go install commands will automatically
|
.cxx. The <tt>go build</tt> and <tt>go install</tt> commands will
|
||||||
run SWIG for you and will build the interface code.
|
automatically run SWIG for you and will build the interface code.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
You can also use SWIG directly yourself. When using the gc compiler
|
You can also use SWIG directly yourself. When using
|
||||||
version 1.2 or later, or when using gccgo, the code generated by SWIG
|
the <tt>-cgo</tt> option, SWIG will generate files that can be used
|
||||||
can be linked directly into the Go program. A typical command
|
directly by <tt>go build</tt>. Put your SWIG input file in a
|
||||||
|
directory under GOPATH/src, and give it a name that does not end in
|
||||||
|
.swig or .swigcxx.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="code"><pre>
|
||||||
|
% swig -go -cgo example.i
|
||||||
|
% go install
|
||||||
|
</pre></div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
You will now have a Go package that you can import from other Go
|
||||||
|
packages as usual.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
To use SWIG without the <tt>-cgo</tt> option, more steps are required.
|
||||||
|
Recall that this only works with Go versions before 1.5. When using
|
||||||
|
Go version 1.2 or later, or when using gccgo, the code generated by
|
||||||
|
SWIG can be linked directly into the Go program. A typical command
|
||||||
sequence when using the gc compiler would look like this:
|
sequence when using the gc compiler would look like this:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
@ -227,9 +268,8 @@ sequence when using the gc compiler would look like this:
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
You can also put the wrapped code into a shared library, and when
|
You can also put the wrapped code into a shared library, and when
|
||||||
using the gc compiler before version 1.2 this is the only supported
|
using the Go versions before 1.2 this is the only supported option. A
|
||||||
option. A typical command sequence for this approach would look like
|
typical command sequence for this approach would look like this:
|
||||||
this:
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="code"><pre>
|
<div class="code"><pre>
|
||||||
|
|
@ -396,34 +436,120 @@ for this by calling the Swigcptr() method.
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Calling <tt>NewClassName</tt> for some C++ class <tt>ClassName</tt>
|
Calling <tt>NewClassName</tt> for a C++ class <tt>ClassName</tt> will allocate
|
||||||
will allocate memory using the C++ memory allocator. This memory will
|
memory using the C++ memory allocator. This memory will not be automatically
|
||||||
not be automatically freed by Go's garbage collector as the object ownership is
|
freed by Go's garbage collector as the object ownership is not tracked. When
|
||||||
not tracked. When you are done with the C++ object you must free it manually
|
you are done with the C++ object you must free it using
|
||||||
using <tt>DeleteClassName</tt>.
|
<tt>DeleteClassName</tt>.<br>
|
||||||
</p>
|
<br>
|
||||||
|
The most Go idiomatic way to manage the memory for some C++ class is to call
|
||||||
<p>
|
<tt>NewClassName</tt> followed by a
|
||||||
A common technique is to store the C++ object into a Go object, and
|
<tt><a href="https://golang.org/doc/effective_go.html#defer">defer</a></tt> of
|
||||||
use the Go function <tt>runtime.SetFinalizer</tt> to free the C++ object when
|
the <tt>DeleteClassName</tt> call. Using <tt>defer</tt> ensures that the memory
|
||||||
the Go object is freed. It is strongly recommended to read the
|
of the C++ object is freed as soon as the function containing the <tt>defer</tt>
|
||||||
<a href="https://golang.org/pkg/runtime/#SetFinalizer">runtime.SetFinalizer</a>
|
statement returns. Furthemore <tt>defer</tt> works great for short-lived
|
||||||
documentation before using this technique to understand its limitations.
|
objects and fits nicely C++'s RAII idiom. Example:
|
||||||
For example, if the SWIG package is imported as "wrap":
|
|
||||||
</p>
|
</p>
|
||||||
<div class="code">
|
<div class="code">
|
||||||
<pre>
|
<pre>
|
||||||
|
func UseClassName(...) ... {
|
||||||
|
o := NewClassName(...)
|
||||||
|
defer DeleteClassName(o)
|
||||||
|
// Use the ClassName object
|
||||||
|
return ...
|
||||||
|
}
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
With increasing complexity, especially complex C++ object hierarchies, the
|
||||||
|
correct placement of <tt>defer</tt> statements becomes harder and harder as C++
|
||||||
|
objects need to be freed in the correct order. This problem can be eased by
|
||||||
|
keeping a C++ object function local so that it is only available to the function
|
||||||
|
that creates a C++ object and functions called by this function. Example:
|
||||||
|
</p>
|
||||||
|
<div class="code">
|
||||||
|
<pre>
|
||||||
|
func WithClassName(constructor args, f func(ClassName, ...interface{}) error, data ...interface{}) error {
|
||||||
|
o := NewClassName(constructor args)
|
||||||
|
defer DeleteClassName(o)
|
||||||
|
return f(o, data...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func UseClassName(o ClassName, data ...interface{}) (err error) {
|
||||||
|
// Use the ClassName object and additional data and return error.
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
WithClassName(constructor args, UseClassName, additional data)
|
||||||
|
}
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Using <tt>defer</tt> has limitations though, especially when it comes to
|
||||||
|
long-lived C++ objects whichs lifetimes are hard to predict. For such C++
|
||||||
|
objects a common technique is to store the C++ object into a Go object, and to
|
||||||
|
use the Go function <tt>runtime.SetFinalizer</tt> to add a finalizer which frees
|
||||||
|
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 the
|
||||||
|
<tt>runtime.SetFinalizer</tt> limitations.<br>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Common pitfalls with <tt>runtime.SetFinalizer</tt> are:
|
||||||
|
</p>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
If a hierarchy of C++ objects will be automatically freed by Go finalizers then
|
||||||
|
the Go objects that store the C++ objects need to replicate the hierarchy of the
|
||||||
|
C++ objects to prevent that C++ objects are freed prematurely while other C++
|
||||||
|
objects still rely on them.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
The usage of Go finalizers is problematic with C++'s RAII idiom as it isn't
|
||||||
|
predictable when the finalizer will run and this might require a Close or Delete
|
||||||
|
method to be added the Go object that stores a C++ object to mitigate.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
The Go finalizer function typically runs in a different OS thread which can be
|
||||||
|
problematic with C++ code that uses thread-local storage.
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<tt>runtime.SetFinalizer</tt> Example:
|
||||||
|
</p>
|
||||||
|
<div class="code">
|
||||||
|
<pre>
|
||||||
|
import (
|
||||||
|
"runtime"
|
||||||
|
"wrap" // SWIG generated wrapper code
|
||||||
|
)
|
||||||
|
|
||||||
type GoClassName struct {
|
type GoClassName struct {
|
||||||
w wrap.ClassName
|
wcn wrap.ClassName
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGoClassName() *GoClassName {
|
func NewGoClassName() *GoClassName {
|
||||||
r := &GoClassName{wrap.NewClassName()}
|
o := &GoClassName{wcn: wrap.NewClassName()}
|
||||||
runtime.SetFinalizer(r,
|
runtime.SetFinalizer(o, deleteGoClassName)
|
||||||
func(r *GoClassName) {
|
return o
|
||||||
wrap.DeleteClassName(r.w)
|
}
|
||||||
})
|
|
||||||
return r
|
func deleteGoClassName(o *GoClassName) {
|
||||||
|
// Runs typically in a different OS thread!
|
||||||
|
wrap.DeleteClassName(o.wcn)
|
||||||
|
o.wcn = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *GoClassName) Close() {
|
||||||
|
// If the C++ object has a Close method.
|
||||||
|
o.wcn.Close()
|
||||||
|
|
||||||
|
// If the GoClassName object is no longer in an usable state.
|
||||||
|
runtime.SetFinalizer(o, nil) // Remove finalizer.
|
||||||
|
deleteGoClassName() // Free the C++ object.
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -457,6 +457,12 @@ be used on any platform. Again, this is an important part of staying out
|
||||||
of the programmer's way----the last thing any developer wants to do is
|
of the programmer's way----the last thing any developer wants to do is
|
||||||
to spend their time debugging the output of a tool that relies on
|
to spend their time debugging the output of a tool that relies on
|
||||||
non-portable or unreliable programming features.
|
non-portable or unreliable programming features.
|
||||||
|
Dependencies are often a source of incompatibilities and problems and so
|
||||||
|
additional third party libraries are not used in the generated code.
|
||||||
|
SWIG will also generally avoid generating code that introduces a dependency
|
||||||
|
on the C++ Standard Template Library (STL).
|
||||||
|
SWIG will generate code that depends on the C libraries though.
|
||||||
|
</p>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="#Javascript_applications_webkit">Creating Applications with node-webkit</a>
|
<li><a href="#Javascript_applications_webkit">Creating Applications with node-webkit</a>
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="#Javascript_nn14">Examples</a>
|
<li><a href="#Javascript_examples">Examples</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#Javascript_simple_example">Simple</a>
|
<li><a href="#Javascript_simple_example">Simple</a>
|
||||||
<li><a href="#Javascript_class_example">Class</a>
|
<li><a href="#Javascript_class_example">Class</a>
|
||||||
|
|
@ -197,10 +197,10 @@ $ sudo npm install -g node-gyp</pre>
|
||||||
<pre>
|
<pre>
|
||||||
$ swig -javascript -node -c++ example.i</pre>
|
$ swig -javascript -node -c++ example.i</pre>
|
||||||
</div>
|
</div>
|
||||||
<p>Then run <code>node-gyp</code></p>
|
<p>Then run <code>node-gyp build</code> to actually create the module:</p>
|
||||||
<div class="shell">
|
<div class="shell">
|
||||||
<pre>
|
<pre>
|
||||||
$ node-gyp</pre>
|
$ node-gyp build</pre>
|
||||||
</div>
|
</div>
|
||||||
<p>This will create a <code>build</code> folder containing the native module. To use the extension you need to 'require' it in your Javascript source file:</p>
|
<p>This will create a <code>build</code> folder containing the native module. To use the extension you need to 'require' it in your Javascript source file:</p>
|
||||||
<div class="code">
|
<div class="code">
|
||||||
|
|
@ -410,7 +410,7 @@ open new windows, and many more things.
|
||||||
};</pre>
|
};</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H2><a name="Javascript_nn14"></a>26.4 Examples</H2>
|
<H2><a name="Javascript_examples"></a>26.4 Examples</H2>
|
||||||
|
|
||||||
|
|
||||||
<p>Some basic examples are shown here in more detail.</p>
|
<p>Some basic examples are shown here in more detail.</p>
|
||||||
|
|
|
||||||
|
|
@ -1900,7 +1900,9 @@ Adding the missing <tt>%shared_ptr</tt> macros will fix this:
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<b>Note:</b> There is currently no support for <tt>%shared_ptr</tt> and the director feature.
|
<b>Note:</b> There is somewhat limited support for <tt>%shared_ptr</tt> and the director feature
|
||||||
|
and the degress of success varies among the different target languages.
|
||||||
|
Please help to improve this support by providing patches with improvements.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -891,7 +891,7 @@ void spam(short);
|
||||||
<p>
|
<p>
|
||||||
or
|
or
|
||||||
</p>
|
</p>
|
||||||
<DIV CLASS="CODE"><PRE>VOID FOO(bAR *B);
|
<div class="code"><pre>void foo(Bar *b);
|
||||||
void foo(Bar &b);
|
void foo(Bar &b);
|
||||||
</pre></div>
|
</pre></div>
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -250,7 +250,9 @@ the functions <tt>SWIG_TypeQuery</tt>, <tt>SWIG_NewPointerObj</tt>, and others s
|
||||||
to be called. Calling these functions from a typemap is supported, since the typemap code
|
to be called. Calling these functions from a typemap is supported, since the typemap code
|
||||||
is embedded into the <tt>_wrap.c</tt> file, which has those declarations available. If you need
|
is embedded into the <tt>_wrap.c</tt> file, which has those declarations available. If you need
|
||||||
to call the SWIG run-time functions from another C file, there is one header you need
|
to call the SWIG run-time functions from another C file, there is one header you need
|
||||||
to include. To generate the header that needs to be included, run the following command:
|
to include. To generate the header that needs to be included, SWIG can be run in a different
|
||||||
|
mode via <tt>-external-runtime</tt> to generate the run-time instead of the normal mode of
|
||||||
|
processing an input interface file. For example:
|
||||||
|
|
||||||
<div class="shell"><pre>
|
<div class="shell"><pre>
|
||||||
$ swig -python -external-runtime <filename>
|
$ swig -python -external-runtime <filename>
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@
|
||||||
<title>SWIG and Ocaml</title>
|
<title>SWIG and Ocaml</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
<a name="n1"></a>
|
|
||||||
<H1><a name="Ocaml"></a>31 SWIG and Ocaml</H1>
|
<H1><a name="Ocaml"></a>31 SWIG and Ocaml</H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
|
|
@ -59,8 +59,11 @@
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
This chapter describes SWIG's
|
This chapter describes SWIG's support of Ocaml.
|
||||||
support of Ocaml. Ocaml is a relatively recent addition to the ML family,
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Ocaml is a relatively recent addition to the ML family,
|
||||||
and is a recent addition to SWIG. It's the second compiled, typed
|
and is a recent addition to SWIG. It's the second compiled, typed
|
||||||
language to be added. Ocaml has widely acknowledged benefits for engineers,
|
language to be added. Ocaml has widely acknowledged benefits for engineers,
|
||||||
mostly derived from a sophisticated type system, compile-time checking
|
mostly derived from a sophisticated type system, compile-time checking
|
||||||
|
|
@ -84,7 +87,7 @@ If you're not familiar with the Objective Caml language, you can visit
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
SWIG 1.3 works with Ocaml 3.04 and above. Given the choice,
|
SWIG 3.0 works with Ocaml 3.08.3 and above. Given the choice,
|
||||||
you should use the latest stable release. The SWIG Ocaml module has
|
you should use the latest stable release. The SWIG Ocaml module has
|
||||||
been tested on Linux (x86,PPC,Sparc) and Cygwin on Windows. The
|
been tested on Linux (x86,PPC,Sparc) and Cygwin on Windows. The
|
||||||
best way to determine whether your system will work is to compile the
|
best way to determine whether your system will work is to compile the
|
||||||
|
|
@ -92,9 +95,8 @@ examples and test-suite which come with SWIG. You can do this by running
|
||||||
<tt>make check</tt> from the SWIG root directory after installing SWIG.
|
<tt>make check</tt> from the SWIG root directory after installing SWIG.
|
||||||
The Ocaml module has been tested using the system's dynamic linking (the
|
The Ocaml module has been tested using the system's dynamic linking (the
|
||||||
usual -lxxx against libxxx.so, as well as with Gerd Stolpmann's
|
usual -lxxx against libxxx.so, as well as with Gerd Stolpmann's
|
||||||
<a
|
<a href="http://download.camlcity.org/download/">Dl package</a>.
|
||||||
href="http://download.camlcity.org/download/">Dl package
|
The ocaml_dynamic and ocaml_dynamic_cpp targets in the
|
||||||
</a>. The ocaml_dynamic and ocaml_dynamic_cpp targets in the
|
|
||||||
file Examples/Makefile illustrate how to compile and link SWIG modules that
|
file Examples/Makefile illustrate how to compile and link SWIG modules that
|
||||||
will be loaded dynamically. This has only been tested on Linux so far.
|
will be loaded dynamically. This has only been tested on Linux so far.
|
||||||
</p>
|
</p>
|
||||||
|
|
@ -134,8 +136,7 @@ the type of each SWIG'ed module's c_obj is derived from Swig.c_obj_t. This
|
||||||
also allows SWIG to acquire new conversions painlessly, as well as giving
|
also allows SWIG to acquire new conversions painlessly, as well as giving
|
||||||
the user more freedom with respect to custom typing.
|
the user more freedom with respect to custom typing.
|
||||||
|
|
||||||
Use <tt>ocamlc</tt> or <tt>ocamlopt</tt> to compile your
|
Use <tt>ocamlc</tt> or <tt>ocamlopt</tt> to compile your SWIG interface like:
|
||||||
SWIG interface like:
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="code">
|
<div class="code">
|
||||||
|
|
@ -154,7 +155,9 @@ the user more freedom with respect to custom typing.
|
||||||
|
|
||||||
<div class="code">
|
<div class="code">
|
||||||
<pre>
|
<pre>
|
||||||
% cp example_wrap.cxx example_wrap.cxx.c<br>% ocamlc -c ... -ccopt -xc++ example_wrap.cxx.c<br>% ...<br>
|
% cp example_wrap.cxx example_wrap.cxx.c
|
||||||
|
% ocamlc -c ... -ccopt -xc++ example_wrap.cxx.c
|
||||||
|
% ...
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -273,7 +276,7 @@ In the code as seen by the typemap
|
||||||
writer, there is a value, swig_result, that always contains the
|
writer, there is a value, swig_result, that always contains the
|
||||||
current return data. It is a list, and must be appended with the
|
current return data. It is a list, and must be appended with the
|
||||||
caml_list_append function, or with functions and macros provided by
|
caml_list_append function, or with functions and macros provided by
|
||||||
objective caml.<br>
|
objective caml.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="code"><pre>
|
<div class="code"><pre>
|
||||||
|
|
@ -303,11 +306,10 @@ type c_obj =
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>caml_ptr_val receives a c_obj and returns a void *. This
|
<li>caml_ptr_val receives a c_obj and returns a void *. This
|
||||||
should be used for all pointer purposes.</li>
|
should be used for all pointer purposes.</li>
|
||||||
<li>caml_long_val receives a c_obj and returns a long. This
|
<li>caml_long_val receives a c_obj and returns a long. This
|
||||||
should be used for most integral purposes.<br>
|
should be used for most integral purposes.</li>
|
||||||
</li>
|
|
||||||
<li>caml_val_ptr receives a void * and returns a c_obj.</li>
|
<li>caml_val_ptr receives a void * and returns a c_obj.</li>
|
||||||
<li>caml_val_bool receives a C int and returns a c_obj representing
|
<li>caml_val_bool receives a C int and returns a c_obj representing
|
||||||
its bool value.</li>
|
its bool value.</li>
|
||||||
|
|
@ -318,26 +320,25 @@ appropriate C value and returns a c_obj representing it.</li>
|
||||||
a string value.</li>
|
a string value.</li>
|
||||||
<li>caml_val_obj receives a void * and an object type and returns
|
<li>caml_val_obj receives a void * and an object type and returns
|
||||||
a C_obj, which contains a closure giving method access.</li>
|
a C_obj, which contains a closure giving method access.</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Because of this style, a typemap can return any kind of value it
|
Because of this style, a typemap can return any kind of value it
|
||||||
wants from a function. This enables out typemaps and inout typemaps
|
wants from a function. This enables out typemaps and inout typemaps
|
||||||
to work well. The one thing to remember about outputting values
|
to work well. The one thing to remember about outputting values
|
||||||
is that you must append them to the return list with swig_result = caml_list_append(swig_result,v).
|
is that you must append them to the return list with swig_result = caml_list_append(swig_result,v).
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
This function will return a new list that has your element
|
This function will return a new list that has your element
|
||||||
appended. Upon return to caml space, the fnhelper function
|
appended. Upon return to caml space, the fnhelper function
|
||||||
beautifies the result. A list containing a single item degrades to
|
beautifies the result. A list containing a single item degrades to
|
||||||
only that item (i.e. [ C_int 3 ] -> C_int 3), and a list
|
only that item (i.e. [ C_int 3 ] -> C_int 3), and a list
|
||||||
containing more than one item is wrapped in C_list (i.e. [ C_char
|
containing more than one item is wrapped in C_list (i.e. [ C_char
|
||||||
'a' ; C_char 'b' -> C_list [ C_char 'a' ; C_char b
|
'a' ; C_char 'b' -> C_list [ C_char 'a' ; C_char b
|
||||||
]). This is in order to make return values easier to handle
|
]). This is in order to make return values easier to handle
|
||||||
when functions have only one return value, such as constructors,
|
when functions have only one return value, such as constructors,
|
||||||
and operators. In addition, string, pointer, and object
|
and operators. In addition, string, pointer, and object
|
||||||
values are interchangeable with respect to caml_ptr_val, so you can
|
values are interchangeable with respect to caml_ptr_val, so you can
|
||||||
allocate memory as caml strings and still use the resulting
|
allocate memory as caml strings and still use the resulting
|
||||||
pointers for C purposes, even using them to construct simple objects
|
pointers for C purposes, even using them to construct simple objects
|
||||||
|
|
@ -348,9 +349,10 @@ is that you must append them to the return list with swig_result = caml_list_a
|
||||||
The wild card type that you can use in lots of different ways is
|
The wild card type that you can use in lots of different ways is
|
||||||
C_obj. It allows you to wrap any type of thing you like as an
|
C_obj. It allows you to wrap any type of thing you like as an
|
||||||
object using the same mechanism that the ocaml module
|
object using the same mechanism that the ocaml module
|
||||||
does. When evaluated in caml_ptr_val, the returned value is
|
does. When evaluated in caml_ptr_val, the returned value is
|
||||||
the result of a call to the object's "&" operator, taken as a pointer.
|
the result of a call to the object's "&" operator, taken as a pointer.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
You should only construct values using objective caml, or using the
|
You should only construct values using objective caml, or using the
|
||||||
functions caml_val_* functions provided as static functions to a SWIG
|
functions caml_val_* functions provided as static functions to a SWIG
|
||||||
|
|
@ -399,11 +401,11 @@ it describes the output SWIG will generate for class definitions.
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
SWIG will wrap enumerations as polymorphic variants in the output
|
SWIG will wrap enumerations as polymorphic variants in the output
|
||||||
Ocaml code, as above in C_enum. In order to support all
|
Ocaml code, as above in C_enum. In order to support all
|
||||||
C++-style uses of enums, the function int_to_enum and enum_to_int are
|
C++-style uses of enums, the function int_to_enum and enum_to_int are
|
||||||
provided for ocaml code to produce and consume these values as
|
provided for ocaml code to produce and consume these values as
|
||||||
integers. Other than that, correct uses of enums will not have
|
integers. Other than that, correct uses of enums will not have
|
||||||
a problem. Since enum labels may overlap between enums, the
|
a problem. Since enum labels may overlap between enums, the
|
||||||
enum_to_int and int_to_enum functions take an enum type label as an
|
enum_to_int and int_to_enum functions take an enum type label as an
|
||||||
argument. Example:
|
argument. Example:
|
||||||
</p>
|
</p>
|
||||||
|
|
@ -577,12 +579,12 @@ void printfloats( float *tab, int len );
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
C++ classes, along with structs and unions are represented by C_obj
|
C++ classes, along with structs and unions are represented by C_obj
|
||||||
(string -> c_obj -> c_obj) wrapped closures. These objects
|
(string -> c_obj -> c_obj) wrapped closures. These objects
|
||||||
contain a method list, and a type, which allow them to be used like
|
contain a method list, and a type, which allow them to be used like
|
||||||
C++ objects. When passed into typemaps that use pointers, they
|
C++ objects. When passed into typemaps that use pointers, they
|
||||||
degrade to pointers through their "&" method. Every method
|
degrade to pointers through their "&" method. Every method
|
||||||
an object has is represented as a string in the object's method table,
|
an object has is represented as a string in the object's method table,
|
||||||
and each method table exists in memory only once. In addition
|
and each method table exists in memory only once. In addition
|
||||||
to any other operators an object might have, certain builtin ones are
|
to any other operators an object might have, certain builtin ones are
|
||||||
provided by SWIG: (all of these take no arguments (C_void))
|
provided by SWIG: (all of these take no arguments (C_void))
|
||||||
</p>
|
</p>
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ Also, there are a dozen or so examples in the Examples/octave directory, and hun
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
As of SWIG 3.0.3, the Octave module has been tested with Octave versions 3.2.4, 3.4.3, 3.6.4, and 3.8.1.
|
As of SWIG 3.0.7, the Octave module is regularly tested with Octave versions 3.2.4, 3.8.1, and 4.0.0.
|
||||||
Use of older Octave versions is not recommended, as these versions are no longer tested with SWIG.
|
Use of older Octave versions is not recommended, as these versions are no longer tested with SWIG.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,7 @@
|
||||||
<li><a href="#Python_nn47">Simple pointers</a>
|
<li><a href="#Python_nn47">Simple pointers</a>
|
||||||
<li><a href="#Python_nn48">Unbounded C Arrays</a>
|
<li><a href="#Python_nn48">Unbounded C Arrays</a>
|
||||||
<li><a href="#Python_nn49">String handling</a>
|
<li><a href="#Python_nn49">String handling</a>
|
||||||
|
<li><a href="#Python_default_args">Default arguments</a>
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="#Python_nn53">Typemaps</a>
|
<li><a href="#Python_nn53">Typemaps</a>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -3382,6 +3383,18 @@ 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
|
an error for invalid preprocessor directives, so you may have to update
|
||||||
existing interface files to delimit blocks of Python code correctly.</p>
|
existing interface files to delimit blocks of Python code correctly.</p>
|
||||||
|
|
||||||
|
<p>As an alternative to providing a block containing Python code, you can
|
||||||
|
include python code from a file. The code is inserted exactly as in the
|
||||||
|
file, so this avoids any issues with the SWIG preprocessor. It's a good
|
||||||
|
approach if you have a non-trivial chunk of Python code to insert. To
|
||||||
|
use this feature you specify a filename in double quotes, for example:</p>
|
||||||
|
|
||||||
|
<div class="code">
|
||||||
|
<pre>
|
||||||
|
%pythoncode "somecode.py"
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
<p>Sometimes you may want to replace or modify the wrapper function
|
<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
|
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
|
in SWIG provides some features that enable you to do this. First, to
|
||||||
|
|
@ -3404,7 +3417,7 @@ def bar(*args):
|
||||||
class Foo {
|
class Foo {
|
||||||
public:
|
public:
|
||||||
int bar(int x);
|
int bar(int x);
|
||||||
}
|
};
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -3441,7 +3454,7 @@ proxy, just before the return statement.
|
||||||
class Foo {
|
class Foo {
|
||||||
public:
|
public:
|
||||||
int bar(int x);
|
int bar(int x);
|
||||||
}
|
};
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -3470,7 +3483,7 @@ SWIG version 1.3.28 you can use the directive forms
|
||||||
class Foo {
|
class Foo {
|
||||||
public:
|
public:
|
||||||
int bar(int x);
|
int bar(int x);
|
||||||
}
|
};
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -3500,7 +3513,7 @@ class Foo {
|
||||||
public:
|
public:
|
||||||
int bar(int x);
|
int bar(int x);
|
||||||
int bar();
|
int bar();
|
||||||
}
|
};
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -4147,6 +4160,106 @@ If you need to return binary data, you might use the
|
||||||
also be used to extra binary data from arbitrary pointers.
|
also be used to extra binary data from arbitrary pointers.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<H3><a name="Python_default_args"></a>36.7.5 Default arguments</H3>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
C++ default argument code generation is documented in the main
|
||||||
|
<a href="SWIG.html#SWIGPlus_default_args">Default arguments</a> section.
|
||||||
|
There is also an optional Python specific feature that can be used called the <tt>python:cdefaultargs</tt>
|
||||||
|
<a href="Customization.html#Customization_feature_flags">feature flag</a>.
|
||||||
|
By default, SWIG attempts to convert C++ default argument values
|
||||||
|
into Python values and generates code into the Python layer containing these values.
|
||||||
|
For example:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="code">
|
||||||
|
<pre>
|
||||||
|
struct CDA {
|
||||||
|
int fff(int a = 1, bool b = false);
|
||||||
|
};
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
From Python this can be called as follows:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="targetlang">
|
||||||
|
<pre>
|
||||||
|
>>> CDA().fff() # C++ layer receives a=1 and b=false
|
||||||
|
>>> CDA().fff(2) # C++ layer receives a=2 and b=false
|
||||||
|
>>> CDA().fff(3, True) # C++ layer receives a=3 and b=true
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The default code generation in the Python layer is:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="targetlang">
|
||||||
|
<pre>
|
||||||
|
class CDA(object):
|
||||||
|
...
|
||||||
|
def fff(self, a=1, b=False):
|
||||||
|
return _default_args.CDA_fff(self, a, b)
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Adding the feature:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="code">
|
||||||
|
<pre>
|
||||||
|
%feature("python:cdefaultargs") CDA::fff;
|
||||||
|
struct CDA {
|
||||||
|
int fff(int a = 1, bool b = false);
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
results in identical behaviour when called from Python, however, it results in different code generation:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="targetlang">
|
||||||
|
<pre>
|
||||||
|
class CDA(object):
|
||||||
|
...
|
||||||
|
def fff(self, *args):
|
||||||
|
return _default_args.CDA_fff(self, *args)
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The default arguments are obtained in the C++ wrapper layer instead of the Python layer.
|
||||||
|
Some code generation modes are quite different, eg <tt>-builtin</tt> and <tt>-fastproxy</tt>,
|
||||||
|
and are unaffected by <tt>python:cdefaultargs</tt> as the default values are always obtained from the C++ layer.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Note that not all default arguments can be converted into a Python equivalent.
|
||||||
|
When SWIG does not convert them, it will generate code to obtain them from the C++ layer as if
|
||||||
|
<tt>python:cdefaultargs</tt> was specified.
|
||||||
|
This will happen if just one argument cannot be converted into a Python equivalent.
|
||||||
|
This occurs typically when the argument is not fully numeric, such as <tt>int(1)</tt>:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="code">
|
||||||
|
<pre>
|
||||||
|
struct CDA {
|
||||||
|
int fff(int a = int(1), bool b = false);
|
||||||
|
};
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<b>Compatibility Note:</b> SWIG-3.0.6 introduced the <tt>python:cdefaultargs</tt> feature.
|
||||||
|
Versions of SWIG prior to this varied in their ability to convert C++ default values into
|
||||||
|
equivalent Python default argument values.
|
||||||
|
</p>
|
||||||
|
|
||||||
<H2><a name="Python_nn53"></a>36.8 Typemaps</H2>
|
<H2><a name="Python_nn53"></a>36.8 Typemaps</H2>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,23 @@ Without it, inheritance of wrapped objects may fail.
|
||||||
These two files can be loaded in any order
|
These two files can be loaded in any order
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
If you are compiling code yourself (not using R itself), there are a few things to watch out for:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>The output shared library name (to the left of the file extension) MUST match the module name, or alternatively, you can also set the -package NAME command line argument. See swig -r -help for more information
|
||||||
|
<li>If you do not set the output file name appropriately, you might see errors like
|
||||||
|
<div class="shell">
|
||||||
|
<pre>
|
||||||
|
> fact(4)
|
||||||
|
Error in .Call("R_swig_fact", s_arg1, as.logical(.copy), PACKAGE = "example") :
|
||||||
|
"R_swig_fact" not available for .Call() for package "example"
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
<li>Make sure the architecture of the shared library(x64 for instance), matches the architecture of the R program you want to load your shared library into
|
||||||
|
</ul>
|
||||||
|
|
||||||
<H2><a name="R_nn4"></a>37.3 Precompiling large R files</H2>
|
<H2><a name="R_nn4"></a>37.3 Precompiling large R files</H2>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,8 @@ can be obtained by typing <tt>swig -help</tt> or <tt>swig
|
||||||
-I<em>dir</em> Add a directory to the file include path
|
-I<em>dir</em> Add a directory to the file include path
|
||||||
-l<em>file</em> Include a SWIG library file.
|
-l<em>file</em> Include a SWIG library file.
|
||||||
-module <em>name</em> Set the name of the SWIG module
|
-module <em>name</em> Set the name of the SWIG module
|
||||||
-o <em>outfile</em> Name of output file
|
-o <em>outfile</em> Set name of C/C++ output file to <outfile>
|
||||||
|
-oh <em>headfile</em> Set name of C++ output header file for directors to <headfile>
|
||||||
-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
|
-outdir <em>dir</em> Set language specific files output directory
|
||||||
-pcreversion Display PCRE version information
|
-pcreversion Display PCRE version information
|
||||||
|
|
@ -212,7 +213,7 @@ additional files depending on the target language. By default, an input file
|
||||||
with the name <tt>file.i</tt> is transformed into a file
|
with the name <tt>file.i</tt> is transformed into a file
|
||||||
<tt>file_wrap.c</tt> or <tt>file_wrap.cxx</tt> (depending on whether
|
<tt>file_wrap.c</tt> or <tt>file_wrap.cxx</tt> (depending on whether
|
||||||
or not the <tt>-c++</tt> option has been used). The name of the
|
or not the <tt>-c++</tt> option has been used). The name of the
|
||||||
output file can be changed using the <tt>-o</tt> option. In certain
|
output C/C++ file can be changed using the <tt>-o</tt> option. In certain
|
||||||
cases, file suffixes are used by the compiler to determine the source
|
cases, file suffixes are used by the compiler to determine the source
|
||||||
language (C, C++, etc.). Therefore, you have to use the
|
language (C, C++, etc.). Therefore, you have to use the
|
||||||
<tt>-o</tt> option to change the suffix of the SWIG-generated wrapper
|
<tt>-o</tt> option to change the suffix of the SWIG-generated wrapper
|
||||||
|
|
|
||||||
|
|
@ -2101,13 +2101,13 @@ Therefore, earlier methods will shadow methods that appear later.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
When wrapping an overloaded function, there is a chance that you will get an error message like this:
|
When wrapping an overloaded function, there is a chance that you will get a warning message like this:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="shell">
|
<div class="shell">
|
||||||
<pre>
|
<pre>
|
||||||
example.i:3: Warning 467: Overloaded foo(int) not supported (no type checking
|
example.i:3: Warning 467: Overloaded foo(int) not supported (incomplete type checking rule -
|
||||||
rule for 'int').
|
no precedence level in typecheck typemap for 'int').
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -2116,7 +2116,8 @@ This error means that the target language module supports overloading,
|
||||||
but for some reason there is no type-checking rule that can be used to
|
but for some reason there is no type-checking rule that can be used to
|
||||||
generate a working dispatch function. The resulting behavior is then
|
generate a working dispatch function. The resulting behavior is then
|
||||||
undefined. You should report this as a bug to the
|
undefined. You should report this as a bug to the
|
||||||
<a href="http://www.swig.org/bugs.html">SWIG bug tracking database</a>.
|
<a href="http://www.swig.org/bugs.html">SWIG bug tracking database</a>
|
||||||
|
if this is due to one of the typemaps supplied with SWIG.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
<li><a href="#Scilab_wrapping_pointers_null_pointers">Null pointers</a>
|
<li><a href="#Scilab_wrapping_pointers_null_pointers">Null pointers</a>
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="#Scilab_wrapping_structs">Structures</a>
|
<li><a href="#Scilab_wrapping_structs">Structures</a>
|
||||||
<li><a href="#Scilab_wrapping_cpp_classes">C++ Classes</a>
|
<li><a href="#Scilab_wrapping_cpp_classes">C++ classes</a>
|
||||||
<li><a href="#Scilab_wrapping_cpp_inheritance">C++ inheritance</a>
|
<li><a href="#Scilab_wrapping_cpp_inheritance">C++ inheritance</a>
|
||||||
<li><a href="#Scilab_wrapping_pointers_references_values_arrays">Pointers, references, values, and arrays</a>
|
<li><a href="#Scilab_wrapping_pointers_references_values_arrays">Pointers, references, values, and arrays</a>
|
||||||
<li><a href="#Scilab_wrapping_cpp_templates">C++ templates</a>
|
<li><a href="#Scilab_wrapping_cpp_templates">C++ templates</a>
|
||||||
|
|
@ -931,7 +931,7 @@ ans =
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Scilab_wrapping_cpp_classes"></a>39.3.8 C++ Classes</H3>
|
<H3><a name="Scilab_wrapping_cpp_classes"></a>39.3.8 C++ classes</H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1365,7 +1365,7 @@ void throw_int() throw(int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void throw_stl_invalid_arg(int i) throw(std::invalid_argument) {
|
void throw_stl_invalid_arg(int i) throw(std::invalid_argument) {
|
||||||
if (i &lt 0)
|
if (i < 0)
|
||||||
throw std::invalid_argument("argument is negative.");
|
throw std::invalid_argument("argument is negative.");
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
<H1><a name="Sections"></a>SWIG-3.0 Documentation</H1>
|
<H1><a name="Sections"></a>SWIG-3.0 Documentation</H1>
|
||||||
|
|
||||||
Last update : SWIG-3.0.6 (in progress)
|
Last update : SWIG-3.0.7 (in progress)
|
||||||
|
|
||||||
<H2>Sections</H2>
|
<H2>Sections</H2>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4429,7 +4429,7 @@ before arrays, and so forth.
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Using the above table as a guide, each target language defines a collection of "typecheck" typemaps.
|
Using the above table as a guide, each target language defines a collection of "typecheck" typemaps.
|
||||||
The follow excerpt from the Python module illustrates this:
|
The following excerpt from the Python module illustrates this:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="code">
|
<div class="code">
|
||||||
|
|
@ -4542,11 +4542,31 @@ Here is an example,
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
The bottom line: If you are writing new typemaps and you are using overloaded methods, you will probably
|
The bottom line: If you are writing new typemaps and you are using overloaded methods, you will probably
|
||||||
have to write typecheck code or copy existing code. Since this is a relatively new SWIG feature, there are
|
have to write new typecheck code or copy and modify existing typecheck code.
|
||||||
few examples to work with. However, you might look at some of the existing library files likes 'typemaps.i' for
|
|
||||||
a guide.
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
If you write a typecheck typemap and omit the precedence level, for example commenting it out as shown below:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="code">
|
||||||
|
<pre>
|
||||||
|
%typemap(typecheck /*,precedence=SWIG_TYPECHECK_INTEGER*/) int {
|
||||||
|
$1 = PyInt_Check($input) ? 1 : 0;
|
||||||
|
}
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
then the type is given a precedence higher than any other known precedence level and a <a href="Warnings.html#Warnings">warning</a> is issued:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="shell">
|
||||||
|
<pre>
|
||||||
|
example.i:18: Warning 467: Overloaded method foo(int) not supported (incomplete type checking rule - no precedence level in typecheck typemap for 'int').
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<b>Notes:</b>
|
<b>Notes:</b>
|
||||||
</p>
|
</p>
|
||||||
|
|
|
||||||
|
|
@ -492,7 +492,7 @@ example.i(4) : Syntax error in input(1).
|
||||||
<li>464. Unsupported constant value.
|
<li>464. Unsupported constant value.
|
||||||
<li>465. Unable to handle type <em>type</em>.
|
<li>465. Unable to handle type <em>type</em>.
|
||||||
<li>466. Unsupported variable type <em>type</em>.
|
<li>466. Unsupported variable type <em>type</em>.
|
||||||
<li>467. Overloaded <em>declaration</em> not supported (no type checking rule for '<em>type</em>')
|
<li>467. Overloaded <em>declaration</em> not supported (incomplete type checking rule - no precedence level in typecheck typemap for '<em>type</em>')
|
||||||
<li>468. No 'throw' typemap defined for exception type <em>type</em>
|
<li>468. No 'throw' typemap defined for exception type <em>type</em>
|
||||||
<li>469. No or improper directorin typemap defined for <em>type</em>
|
<li>469. No or improper directorin typemap defined for <em>type</em>
|
||||||
<li>470. Thread/reentrant unsafe wrapping, consider returning by value instead.
|
<li>470. Thread/reentrant unsafe wrapping, consider returning by value instead.
|
||||||
|
|
|
||||||
|
|
@ -388,6 +388,53 @@ Include it like you would any other interface file, for example:
|
||||||
__declspec(dllexport) ULONG __stdcall foo(DWORD, __int32);
|
__declspec(dllexport) ULONG __stdcall foo(DWORD, __int32);
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
|
<p>Note that if you follow Microsoft's recommendation of wrapping the
|
||||||
|
<tt>__declspec</tt> calls in a preprocessor definition, you will need to
|
||||||
|
make sure that the definition is included by SWIG as well, by either defining it
|
||||||
|
manually or via a header. For example, if you have specified the
|
||||||
|
preprocessor definition in a header named <tt>export_lib.h</tt> and include
|
||||||
|
other headers which depend on it, you should use the <tt>%include</tt> directive
|
||||||
|
to include the definition explicitly. For example, if you had a header file,
|
||||||
|
<tt>bar.h</tt>, which depended on <tt>export_lib.h</tt>, your SWIG definition
|
||||||
|
file might look like:</p>
|
||||||
|
|
||||||
|
<div class="code"><pre>
|
||||||
|
// bar.i
|
||||||
|
%module bar
|
||||||
|
%include <windows.i>
|
||||||
|
%include "export_lib.h"
|
||||||
|
%include "bar.h"
|
||||||
|
</pre></div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
where export_lib.h may contain:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="code"><pre>
|
||||||
|
// export_lib.h
|
||||||
|
#define BAR_API __declspec(dllexport)
|
||||||
|
</pre></div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
and bar.h may look like:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="code"><pre>
|
||||||
|
// bar.h
|
||||||
|
#include "export_lib.h"
|
||||||
|
BAR_API void bar_function(int, double);
|
||||||
|
</pre></div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Using the preprocessor to remove BAR_API is a popular simpler solution:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="code"><pre>
|
||||||
|
// bar.i
|
||||||
|
%module bar
|
||||||
|
#define BAR_API
|
||||||
|
%include "bar.h"
|
||||||
|
</pre></div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -321,6 +321,9 @@ else
|
||||||
SWIGPYTHON = $(SWIG) -python -py3
|
SWIGPYTHON = $(SWIG) -python -py3
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
PEP8 = @PEP8@
|
||||||
|
PEP8_FLAGS = --ignore=E402,E501,E30,W291,W391
|
||||||
|
|
||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
# Build a C dynamically loadable module
|
# Build a C dynamically loadable module
|
||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
|
|
@ -373,8 +376,10 @@ endif
|
||||||
PY2TO3 = 2to3 `2to3 -l | grep -v -E "Available|import$$" | awk '{print "-f "$$0}'`
|
PY2TO3 = 2to3 `2to3 -l | grep -v -E "Available|import$$" | awk '{print "-f "$$0}'`
|
||||||
|
|
||||||
python_run: $(PYSCRIPT)
|
python_run: $(PYSCRIPT)
|
||||||
export PYTHONPATH=".:$$PYTHONPATH"; \
|
ifneq (,$(PEP8))
|
||||||
$(RUNTOOL) $(PYTHON) $(PYSCRIPT) $(RUNPIPE)
|
$(PEP8) $(PEP8_FLAGS) $(PYSCRIPT)
|
||||||
|
endif
|
||||||
|
env PYTHONPATH=$$PWD $(RUNTOOL) $(PYTHON) $(PYSCRIPT) $(RUNPIPE)
|
||||||
|
|
||||||
ifneq (,$(SRCDIR))
|
ifneq (,$(SRCDIR))
|
||||||
$(RUNME).py: $(SRCDIR)$(RUNME).py
|
$(RUNME).py: $(SRCDIR)$(RUNME).py
|
||||||
|
|
@ -883,7 +888,7 @@ OCAMLFIND=@OCAMLFIND@
|
||||||
OCAMLMKTOP=@OCAMLMKTOP@ $(SWIGWHERE)
|
OCAMLMKTOP=@OCAMLMKTOP@ $(SWIGWHERE)
|
||||||
NOLINK ?= false
|
NOLINK ?= false
|
||||||
OCAMLPP= -pp "camlp4o ./swigp4.cmo"
|
OCAMLPP= -pp "camlp4o ./swigp4.cmo"
|
||||||
OCAMLP4WHERE=`$(COMPILETOOL) camlp4 -where`
|
OCAMLP4WHERE=`$(COMPILETOOL) @CAMLP4@ -where`
|
||||||
OCAMLCORE=\
|
OCAMLCORE=\
|
||||||
rm -rf swig.mli swig.ml swigp4.ml && \
|
rm -rf swig.mli swig.ml swigp4.ml && \
|
||||||
$(SWIG) -ocaml -co swig.mli 2>/dev/null && \
|
$(SWIG) -ocaml -co swig.mli 2>/dev/null && \
|
||||||
|
|
@ -1345,6 +1350,8 @@ CSHARPCOMPILER = @CSHARPCOMPILER@
|
||||||
CSHARPCILINTERPRETER = @CSHARPCILINTERPRETER@
|
CSHARPCILINTERPRETER = @CSHARPCILINTERPRETER@
|
||||||
CSHARPCILINTERPRETER_FLAGS = @CSHARPCILINTERPRETER_FLAGS@
|
CSHARPCILINTERPRETER_FLAGS = @CSHARPCILINTERPRETER_FLAGS@
|
||||||
CSHARPCFLAGS = @CSHARPCFLAGS@
|
CSHARPCFLAGS = @CSHARPCFLAGS@
|
||||||
|
CSHARPFLAGS =
|
||||||
|
CSHARPOPTIONS =
|
||||||
CSHARPSO = @CSHARPSO@
|
CSHARPSO = @CSHARPSO@
|
||||||
CSHARP_RUNME = $(CSHARPCILINTERPRETER) $(CSHARPCILINTERPRETER_FLAGS) ./$(RUNME).exe
|
CSHARP_RUNME = $(CSHARPCILINTERPRETER) $(CSHARPCILINTERPRETER_FLAGS) ./$(RUNME).exe
|
||||||
|
|
||||||
|
|
@ -1377,7 +1384,7 @@ SRCDIR_CSHARPSRCS =
|
||||||
endif
|
endif
|
||||||
|
|
||||||
csharp_compile: $(SRCDIR_SRCS)
|
csharp_compile: $(SRCDIR_SRCS)
|
||||||
$(COMPILETOOL) $(CSHARPCOMPILER) $(CSHARPFLAGS) $(CSHARPSRCS) $(SRCDIR_CSHARPSRCS)
|
$(COMPILETOOL) $(CSHARPCOMPILER) $(CSHARPFLAGS) $(CSHARPOPTIONS) $(CSHARPSRCS) $(SRCDIR_CSHARPSRCS)
|
||||||
|
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
# Run CSharp example
|
# Run CSharp example
|
||||||
|
|
@ -1710,7 +1717,7 @@ SCILAB_LIBPREFIX = lib
|
||||||
|
|
||||||
scilab:
|
scilab:
|
||||||
$(SWIG) -scilab $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
|
$(SWIG) -scilab $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
|
||||||
$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SCILAB_INC) $(INCLUDES) $(ISRCS) $(SRCDIR_SRCS) $(SRCDIR_CSRCS)
|
$(CC) -g -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SCILAB_INC) $(INCLUDES) $(ISRCS) $(SRCDIR_SRCS) $(SRCDIR_CSRCS)
|
||||||
$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(IOBJS) $(OBJS) $(LIBS) -o $(SCILAB_LIBPREFIX)$(TARGET)$(SO)
|
$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(IOBJS) $(OBJS) $(LIBS) -o $(SCILAB_LIBPREFIX)$(TARGET)$(SO)
|
||||||
|
|
||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
|
|
@ -1719,7 +1726,7 @@ scilab:
|
||||||
|
|
||||||
scilab_cpp:
|
scilab_cpp:
|
||||||
$(SWIG) -c++ -scilab $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
|
$(SWIG) -c++ -scilab $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
|
||||||
$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(SCILAB_INC) $(INCLUDES) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS)
|
$(CXX) -g -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)
|
$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(IOBJS) $(OBJS) $(LIBS) $(CPP_DLLIBS) -o $(SCILAB_LIBPREFIX)$(TARGET)$(SO)
|
||||||
|
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
|
|
@ -1727,7 +1734,7 @@ scilab_cpp:
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
|
|
||||||
scilab_run:
|
scilab_run:
|
||||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(SCILAB) $(SCILAB_OPT) -f $(SRCDIR)$(RUNME).sci $(RUNPIPE)
|
env LD_LIBRARY_PATH=$$PWD $(RUNTOOL) $(SCILAB) $(SCILAB_OPT) -f $(SRCDIR)$(RUNME).sci $(RUNPIPE)
|
||||||
|
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
# Scilab version
|
# Scilab version
|
||||||
|
|
@ -1750,28 +1757,37 @@ scilab_clean:
|
||||||
##### Go ######
|
##### Go ######
|
||||||
##################################################################
|
##################################################################
|
||||||
|
|
||||||
|
# TODO: The Go make targets need simplifying to use configure time
|
||||||
|
# configuration or to use Make's ifeq rather than using lots of
|
||||||
|
# runtime shell code. The output will then be a lot less verbose.
|
||||||
|
|
||||||
GO = @GO@
|
GO = @GO@
|
||||||
GOGCC = @GOGCC@
|
GOGCC = @GOGCC@
|
||||||
|
GCCGO = @GCCGO@
|
||||||
GO1 = @GO1@
|
GO1 = @GO1@
|
||||||
GO12 = @GO12@
|
GO12 = @GO12@
|
||||||
GO13 = @GO13@
|
GO13 = @GO13@
|
||||||
|
GO15 = @GO15@
|
||||||
GOC = @GOC@
|
GOC = @GOC@
|
||||||
GOOPT = @GOOPT@
|
GOOPT = @GOOPT@
|
||||||
|
GCCGOOPT = @GCCGOOPT@
|
||||||
GOVERSIONOPTION = @GOVERSIONOPTION@
|
GOVERSIONOPTION = @GOVERSIONOPTION@
|
||||||
|
|
||||||
GOSWIGARG = `if $(GOGCC) ; then echo -gccgo; fi`
|
GOSWIGARG = `if $(GOGCC) ; then echo -gccgo; fi`
|
||||||
GOCOMPILEARG = `if $(GOGCC) ; then echo -c -g; elif $(GO1) ; then echo tool $(GOC:c=g) ; fi` `if $(GO13) ; then echo -pack ; fi`
|
GOCOMPILEARG = `if $(GO15); then echo tool compile; elif $(GO1) ; then echo tool $(GOC:c=g) ; fi` `if $(GO13) || $(GO15); then echo -pack ; fi`
|
||||||
|
|
||||||
GOSRCS = $(INTERFACE:.i=.go)
|
GOSRCS = $(INTERFACE:.i=.go)
|
||||||
GOCSRCS = $(INTERFACE:.i=_gc.c)
|
GOCSRCS = $(INTERFACE:.i=_gc.c)
|
||||||
|
|
||||||
GOLD = $(GOC:c=l)
|
GOLD = `if $(GO15); then echo link; else echo $(GOC:c=l); fi`
|
||||||
GOTOOL = `if $(GO1) ; then echo go tool; fi`
|
GOTOOL = `if $(GO1) ; then echo go tool; fi`
|
||||||
GOPACK = `if $(GO1) ; then echo go tool pack; else echo gopack; fi`
|
GOPACK = `if $(GO1) ; then echo go tool pack; else echo gopack; fi`
|
||||||
|
|
||||||
GOPACKAGE = $(INTERFACE:.i=.a)
|
GOPACKAGE = $(notdir $(INTERFACE:.i=.a))
|
||||||
|
|
||||||
GOOBJEXT = $(GOC:c=)
|
GOPATHDIR = gopath/src/$(INTERFACE:.i=)
|
||||||
|
|
||||||
|
GOOBJEXT = `if $(GO15); then echo o; else echo $(GOC:c=); fi`
|
||||||
GOGCOBJS = $(GOSRCS:.go=.$(GOOBJEXT))
|
GOGCOBJS = $(GOSRCS:.go=.$(GOOBJEXT))
|
||||||
GOGCCOBJS = $(GOSRCS:.go=.@OBJEXT@)
|
GOGCCOBJS = $(GOSRCS:.go=.@OBJEXT@)
|
||||||
|
|
||||||
|
|
@ -1779,19 +1795,21 @@ GOGCCOBJS = $(GOSRCS:.go=.@OBJEXT@)
|
||||||
# Build a Go module (C)
|
# Build a Go module (C)
|
||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
|
|
||||||
go: $(SRCDIR_SRCS)
|
go_nocgo: $(SRCDIR_SRCS)
|
||||||
$(SWIG) -go $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
|
$(SWIG) -go $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
|
||||||
if $(GO12) || $(GO13) || $(GOGCC); then \
|
if $(GO12) || $(GO13) || $(GO15) || $(GOGCC); then \
|
||||||
$(CC) -g -c $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES); \
|
$(CC) -g -c $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES); \
|
||||||
else \
|
else \
|
||||||
$(CC) -g -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES); \
|
$(CC) -g -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES); \
|
||||||
$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO); \
|
$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO); \
|
||||||
fi
|
fi
|
||||||
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(GOSRCS)
|
if $(GOGCC) ; then \
|
||||||
if ! $(GOGCC) ; then \
|
$(COMPILETOOL) $(GCCGO) -g -c -I . $(GOSRCS); \
|
||||||
|
else \
|
||||||
|
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(GOSRCS); \
|
||||||
$(COMPILETOOL) $(GOTOOL) $(GOC) -I $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`} $(GOCSRCS); \
|
$(COMPILETOOL) $(GOTOOL) $(GOC) -I $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`} $(GOCSRCS); \
|
||||||
rm -f $(GOPACKAGE); \
|
rm -f $(GOPACKAGE); \
|
||||||
if $(GO13); then \
|
if $(GO13) || $(GO15); then \
|
||||||
cp $(GOGCOBJS) $(GOPACKAGE); \
|
cp $(GOGCOBJS) $(GOPACKAGE); \
|
||||||
$(COMPILETOOL) $(GOPACK) r $(GOPACKAGE) $(GOCSRCS:.c=.$(GOOBJEXT)) $(OBJS) $(IOBJS); \
|
$(COMPILETOOL) $(GOPACK) r $(GOPACKAGE) $(GOCSRCS:.c=.$(GOOBJEXT)) $(OBJS) $(IOBJS); \
|
||||||
elif $(GO12); then \
|
elif $(GO12); then \
|
||||||
|
|
@ -1801,12 +1819,54 @@ go: $(SRCDIR_SRCS)
|
||||||
fi; \
|
fi; \
|
||||||
fi
|
fi
|
||||||
if test -f $(SRCDIR)$(RUNME).go; then \
|
if test -f $(SRCDIR)$(RUNME).go; then \
|
||||||
$(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \
|
|
||||||
if $(GOGCC) ; then \
|
if $(GOGCC) ; then \
|
||||||
$(COMPILETOOL) $(GO) -o $(RUNME) $(RUNME).@OBJEXT@ $(GOGCCOBJS) $(OBJS) $(IOBJS); \
|
$(COMPILETOOL) $(GCCGO) -g -c $(SRCDIR)$(RUNME).go; \
|
||||||
elif $(GO12) || $(GO13); then \
|
$(COMPILETOOL) $(GCCGO) -o $(RUNME) $(RUNME).@OBJEXT@ $(GOGCCOBJS) $(OBJS) $(IOBJS); \
|
||||||
|
elif $(GO12) || $(GO13) || $(GO15); then \
|
||||||
|
$(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \
|
||||||
$(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld "$(CC)" -extldflags "$(CFLAGS) $(LDFLAGS)" -o $(RUNME) $(RUNME).$(GOOBJEXT); \
|
$(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld "$(CC)" -extldflags "$(CFLAGS) $(LDFLAGS)" -o $(RUNME) $(RUNME).$(GOOBJEXT); \
|
||||||
else \
|
else \
|
||||||
|
$(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \
|
||||||
|
$(COMPILETOOL) $(GOTOOL) $(GOLD) -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $(RUNME) $(RUNME).$(GOOBJEXT); \
|
||||||
|
fi; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
go: $(SRCDIR_SRCS)
|
||||||
|
$(SWIG) -go -cgo $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
|
||||||
|
@mkdir gopath 2>/dev/null || true
|
||||||
|
@mkdir gopath/src 2>/dev/null || true
|
||||||
|
@mkdir gopath/src/$(INTERFACE:.i=) 2>/dev/null || true
|
||||||
|
rm -f $(GOPATHDIR)/*
|
||||||
|
cp $(ISRCS) $(GOPATHDIR)/
|
||||||
|
if test -f $(IWRAP:.i=.h); then \
|
||||||
|
cp $(IWRAP:.i=.h) $(GOPATHDIR)/; \
|
||||||
|
fi
|
||||||
|
if test -n "$(SRCDIR_SRCS)"; then \
|
||||||
|
cp $(SRCDIR_SRCS) $(GOPATHDIR)/; \
|
||||||
|
fi
|
||||||
|
cp $(GOSRCS) $(GOPATHDIR)/
|
||||||
|
GOPATH=`pwd`/gopath; \
|
||||||
|
export GOPATH; \
|
||||||
|
CGO_CPPFLAGS="$(CPPFLAGS) $(INCLUDES) -I `cd $(SRCDIR) && pwd` -I `pwd`"; \
|
||||||
|
export CGO_CPPFLAGS; \
|
||||||
|
CGO_CFLAGS="$(CFLAGS)"; \
|
||||||
|
export CGO_CFLAGS; \
|
||||||
|
CGO_LDFLAGS="$(LDFLAGS) -lm"; \
|
||||||
|
export CGO_LDFLAGS; \
|
||||||
|
(cd $(GOPATHDIR)/ && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o $(GOPACKAGE))
|
||||||
|
cp $(GOPATHDIR)/$(GOPACKAGE) $(dir $(INTERFACE))/$(GOPACKAGE)
|
||||||
|
if $(GOGCC); then \
|
||||||
|
cp $(dir $(INTERFACE))/$(GOPACKAGE) $(dir $(INTERFACE))/$(GOPACKAGE:.a=.gox); \
|
||||||
|
fi
|
||||||
|
if test -f $(SRCDIR)$(RUNME).go; then \
|
||||||
|
if $(GOGCC) ; then \
|
||||||
|
$(COMPILETOOL) $(GCCGO) -c -g $(SRCDIR)$(RUNME).go; \
|
||||||
|
$(COMPILETOOL) $(GCCGO) -o $(RUNME) $(RUNME).@OBJEXT@ $(dir $(INTERFACE))/$(GOPACKAGE); \
|
||||||
|
elif $(GO12) || $(GO13) || $(GO15); then \
|
||||||
|
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -o $(RUNME).$(GOOBJEXT) $(SRCDIR)$(RUNME).go; \
|
||||||
|
$(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld "$(CC)" -extldflags "$(CFLAGS) $(LDFLAGS)" -o $(RUNME) $(RUNME).$(GOOBJEXT); \
|
||||||
|
else \
|
||||||
|
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \
|
||||||
$(COMPILETOOL) $(GOTOOL) $(GOLD) -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $(RUNME) $(RUNME).$(GOOBJEXT); \
|
$(COMPILETOOL) $(GOTOOL) $(GOLD) -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $(RUNME) $(RUNME).$(GOOBJEXT); \
|
||||||
fi; \
|
fi; \
|
||||||
fi
|
fi
|
||||||
|
|
@ -1815,19 +1875,29 @@ go: $(SRCDIR_SRCS)
|
||||||
# Build a Go module (C++)
|
# Build a Go module (C++)
|
||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
|
|
||||||
go_cpp: $(SRCDIR_SRCS)
|
go_cpp_nocgo: $(SRCDIR_SRCS)
|
||||||
$(SWIG) -go -c++ $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
|
$(SWIG) -go -c++ $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
|
||||||
if $(GO12) || $(GO13) || $(GOGCC); then \
|
if $(GO12) || $(GO13) || $(GO15) || $(GOGCC); then \
|
||||||
$(CXX) -g -c $(CPPFLAGS) $(CXXFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES); \
|
if test -n "$(SRCDIR_CXXSRCS)$(SRCDIR_SRCS)"; then \
|
||||||
|
$(CXX) -g -c $(CPPFLAGS) $(CXXFLAGS) $(SRCDIR_CXXSRCS) $(SRCDIR_SRCS) $(INCLUDES); \
|
||||||
|
fi; \
|
||||||
|
$(foreach f,$(ICXXSRCS), \
|
||||||
|
$(CXX) -g -c $(CPPFLAGS) $(CXXFLAGS) -o $(addsuffix .@OBJEXT@,$(basename $f)) $f $(INCLUDES); \
|
||||||
|
) \
|
||||||
else \
|
else \
|
||||||
$(CXX) -g -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES); \
|
$(CXX) -g -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES); \
|
||||||
$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO); \
|
$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO); \
|
||||||
fi
|
fi
|
||||||
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(GOSRCS)
|
|
||||||
if ! $(GOGCC) ; then \
|
if ! $(GOGCC) ; then \
|
||||||
$(COMPILETOOL) $(GOTOOL) $(GOC) -I $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`} $(GOCSRCS); \
|
$(foreach f,$(GOSRCS), \
|
||||||
|
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . -o $(addsuffix .$(GOOBJEXT),$(basename $f)) $f \
|
||||||
|
); \
|
||||||
|
$(foreach f,$(GOCSRCS), \
|
||||||
|
$(COMPILETOOL) $(GOTOOL) $(GOC) -I $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`} \
|
||||||
|
-o $(addsuffix .$(GOOBJEXT),$(basename $f)) $f; \
|
||||||
|
) \
|
||||||
rm -f $(GOPACKAGE); \
|
rm -f $(GOPACKAGE); \
|
||||||
if $(GO13); then \
|
if $(GO13) || $(GO15); then \
|
||||||
cp $(GOGCOBJS) $(GOPACKAGE); \
|
cp $(GOGCOBJS) $(GOPACKAGE); \
|
||||||
$(COMPILETOOL) $(GOPACK) r $(GOPACKAGE) $(GOCSRCS:.c=.$(GOOBJEXT)) $(OBJS) $(IOBJS); \
|
$(COMPILETOOL) $(GOPACK) r $(GOPACKAGE) $(GOCSRCS:.c=.$(GOOBJEXT)) $(OBJS) $(IOBJS); \
|
||||||
elif $(GO12); then \
|
elif $(GO12); then \
|
||||||
|
|
@ -1835,14 +1905,65 @@ go_cpp: $(SRCDIR_SRCS)
|
||||||
else \
|
else \
|
||||||
$(COMPILETOOL) $(GOPACK) grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)); \
|
$(COMPILETOOL) $(GOPACK) grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)); \
|
||||||
fi; \
|
fi; \
|
||||||
|
else \
|
||||||
|
$(foreach f,$(GOSRCS), \
|
||||||
|
$(COMPILETOOL) $(GCCGO) -g -c -I . -o $(addsuffix .@OBJEXT@,$(basename $f)) $f \
|
||||||
|
); \
|
||||||
fi
|
fi
|
||||||
if test -f $(SRCDIR)$(RUNME).go; then \
|
if test -f $(SRCDIR)$(RUNME).go; then \
|
||||||
$(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \
|
|
||||||
if $(GOGCC) ; then \
|
if $(GOGCC) ; then \
|
||||||
$(COMPILETOOL) $(GO) -o $(RUNME) $(RUNME).@OBJEXT@ $(GOGCCOBJS) $(OBJS) $(IOBJS) -lstdc++; \
|
$(COMPILETOOL) $(GCCGO) -g -c $(SRCDIR)$(RUNME).go; \
|
||||||
elif $(GO12) || $(GO13); then \
|
$(COMPILETOOL) $(GCCGO) -o $(RUNME) $(RUNME).@OBJEXT@ $(GOGCCOBJS) $(OBJS) $(IOBJS) -lstdc++; \
|
||||||
|
elif $(GO12) || $(GO13) || $(GO15); then \
|
||||||
|
$(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \
|
||||||
$(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld "$(CXX)" -extldflags "$(CXXFLAGS) $(LDFLAGS)" -o $(RUNME) $(RUNME).$(GOOBJEXT); \
|
$(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld "$(CXX)" -extldflags "$(CXXFLAGS) $(LDFLAGS)" -o $(RUNME) $(RUNME).$(GOOBJEXT); \
|
||||||
else \
|
else \
|
||||||
|
$(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \
|
||||||
|
$(COMPILETOOL) $(GOTOOL) $(GOLD) -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $(RUNME) $(RUNME).$(GOOBJEXT); \
|
||||||
|
fi; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
go_cpp: $(SRCDIR_SRCS)
|
||||||
|
$(SWIG) -go -c++ -cgo $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
|
||||||
|
@mkdir gopath 2>/dev/null || true
|
||||||
|
@mkdir gopath/src 2>/dev/null || true
|
||||||
|
@mkdir gopath/src/$(INTERFACE:.i=) 2>/dev/null || true
|
||||||
|
rm -f $(GOPATHDIR)/*
|
||||||
|
cp $(ICXXSRCS) $(GOPATHDIR)/
|
||||||
|
if test -f $(IWRAP:.i=.h); then \
|
||||||
|
cp $(IWRAP:.i=.h) $(GOPATHDIR)/; \
|
||||||
|
fi
|
||||||
|
if test -n "$(SRCDIR_CXXSRCS)"; then \
|
||||||
|
cp $(SRCDIR_CXXSRCS) $(GOPATHDIR)/; \
|
||||||
|
fi
|
||||||
|
if test -n "$(SRCDIR_SRCS)"; then \
|
||||||
|
cp $(SRCDIR_SRCS) $(GOPATHDIR)/; \
|
||||||
|
fi
|
||||||
|
cp $(GOSRCS) $(GOPATHDIR)/
|
||||||
|
GOPATH=`pwd`/gopath; \
|
||||||
|
export GOPATH; \
|
||||||
|
CGO_CPPFLAGS="$(CPPFLAGS) $(INCLUDES) -I `cd $(SRCDIR) && pwd` -I `pwd`"; \
|
||||||
|
export CGO_CPPFLAGS; \
|
||||||
|
CGO_CFLAGS="$(CFLAGS)"; \
|
||||||
|
export CGO_CFLAGS; \
|
||||||
|
CGO_CXXFLAGS="$(CXXFLAGS)"; \
|
||||||
|
export CGO_CXXFLAGS; \
|
||||||
|
CGO_LDFLAGS="$(LDFLAGS) -lm"; \
|
||||||
|
export CGO_LDFLAGS; \
|
||||||
|
(cd $(GOPATHDIR) && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o $(GOPACKAGE))
|
||||||
|
cp $(GOPATHDIR)/$(GOPACKAGE) $(dir $(INTERFACE))/$(GOPACKAGE)
|
||||||
|
if $(GOGCC); then \
|
||||||
|
cp $(dir $(INTERFACE))/$(GOPACKAGE) $(dir $(INTERFACE))/$(GOPACKAGE:.a=.gox); \
|
||||||
|
fi
|
||||||
|
if test -f $(SRCDIR)$(RUNME).go; then \
|
||||||
|
if $(GOGCC) ; then \
|
||||||
|
$(COMPILETOOL) $(GCCGO) -g -c $(SRCDIR)$(RUNME).go; \
|
||||||
|
$(COMPILETOOL) $(GCCGO) -o $(RUNME) $(RUNME).@OBJEXT@ $(dir $(INTERFACE))/$(GOPACKAGE) -lstdc++; \
|
||||||
|
elif $(GO12) || $(GO13) || $(GO15); then \
|
||||||
|
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -o $(RUNME).$(GOOBJEXT) $(SRCDIR)$(RUNME).go; \
|
||||||
|
$(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld "$(CXX)" -extldflags "$(CXXFLAGS) $(LDFLAGS)" -o $(RUNME) $(RUNME).$(GOOBJEXT); \
|
||||||
|
else \
|
||||||
|
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \
|
||||||
$(COMPILETOOL) $(GOTOOL) $(GOLD) -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $(RUNME) $(RUNME).$(GOOBJEXT); \
|
$(COMPILETOOL) $(GOTOOL) $(GOLD) -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $(RUNME) $(RUNME).$(GOOBJEXT); \
|
||||||
fi; \
|
fi; \
|
||||||
fi
|
fi
|
||||||
|
|
@ -1852,7 +1973,7 @@ go_cpp: $(SRCDIR_SRCS)
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
|
|
||||||
go_run:
|
go_run:
|
||||||
env LD_LIBRARY_PATH=$$PWD $(RUNTOOL) ./$(RUNME) $(RUNPIPE)
|
env $(RUNTOOL) ./$(RUNME) $(RUNPIPE)
|
||||||
|
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
# Version display
|
# Version display
|
||||||
|
|
@ -1866,7 +1987,8 @@ go_version:
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
|
|
||||||
go_clean:
|
go_clean:
|
||||||
rm -f *_wrap* *_gc* .~* $(RUNME) $(GOSRCS)
|
rm -f *_wrap* *_gc* *.gox .~* $(RUNME) $(GOSRCS)
|
||||||
|
rm -rf gopath
|
||||||
rm -f core @EXTRA_CLEAN@
|
rm -f core @EXTRA_CLEAN@
|
||||||
rm -f *.@OBJEXT@ *.[568] *.a *@SO@
|
rm -f *.@OBJEXT@ *.[568] *.a *@SO@
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@
|
||||||
#include "example.h"
|
#include "example.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%include "std_string.i"
|
|
||||||
|
|
||||||
/* turn on director wrapping Callback */
|
/* turn on director wrapping Callback */
|
||||||
%feature("director") Callback;
|
%feature("director") Callback;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@
|
||||||
#include "example.h"
|
#include "example.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%include "std_string.i"
|
|
||||||
|
|
||||||
/* turn on director wrapping Callback */
|
/* turn on director wrapping Callback */
|
||||||
%feature("director") Callback;
|
%feature("director") Callback;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@
|
||||||
#include "example.h"
|
#include "example.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%include "std_string.i"
|
|
||||||
|
|
||||||
/* turn on director wrapping Callback */
|
/* turn on director wrapping Callback */
|
||||||
%feature("director") Callback;
|
%feature("director") Callback;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,16 +74,21 @@ extern int count(char *bytes, int len, char c);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
/* Return the mutated string as a modified element in the array. */
|
/* Return the mutated string as a modified element in the array. */
|
||||||
%typemap(argout) (char *str, int len)
|
%typemap(argout,fragment="AllocateString") (char *str, int len)
|
||||||
%{
|
%{
|
||||||
{
|
{
|
||||||
_gostring_ *a;
|
_gostring_ *a;
|
||||||
|
|
||||||
a = (_gostring_*) $input.array;
|
a = (_gostring_*) $input.array;
|
||||||
a[0] = _swig_makegostring($1, $2);
|
a[0] = Swig_AllocateString($1, $2);
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
%typemap(goargout,fragment="CopyString") (char *str, int len)
|
||||||
|
%{
|
||||||
|
$input[0] = swigCopyString($input[0])
|
||||||
|
%}
|
||||||
|
|
||||||
%typemap(freearg) (char *str, int len)
|
%typemap(freearg) (char *str, int len)
|
||||||
%{
|
%{
|
||||||
free($1);
|
free($1);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIG = $(TOP)/../preinst-swig
|
||||||
SRCS = matrix.c vector.c
|
SRCS = matrix.c vector.c
|
||||||
TARGET = matrix
|
TARGET = my-guile
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
|
|
||||||
check: build
|
check: build
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ type the following :
|
||||||
|
|
||||||
Alternatively, use the command-line:
|
Alternatively, use the command-line:
|
||||||
|
|
||||||
./matrix -e do-test -s runme.scm
|
./my-guile -e do-test -s runme.scm
|
||||||
|
|
||||||
Or, if your operating system is spiffy enough:
|
Or, if your operating system is spiffy enough:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIG = $(TOP)/../preinst-swig
|
||||||
SRCS = example.c
|
SRCS = example.c
|
||||||
TARGET = port
|
TARGET = my-guile
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
|
|
||||||
check: build
|
check: build
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
This example illustrates the translation from Scheme file ports to
|
This example illustrates the translation from Scheme file ports to
|
||||||
temporary FILE streams. Read the source and run ./port -s runme.scm
|
temporary FILE streams. Read the source and run ./my-guile -s runme.scm
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@
|
||||||
#include "example.h"
|
#include "example.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%include "std_string.i"
|
|
||||||
|
|
||||||
/* turn on director wrapping Callback */
|
/* turn on director wrapping Callback */
|
||||||
%feature("director") Callback;
|
%feature("director") Callback;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,5 +24,3 @@ extern void sub(int *INPUT, int *INPUT, int *OUTPUT);
|
||||||
|
|
||||||
%apply int *OUTPUT { int *r };
|
%apply int *OUTPUT { int *r };
|
||||||
extern int divide(int n, int d, int *r);
|
extern int divide(int n, int d, int *r);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,6 @@
|
||||||
#include "example.h"
|
#include "example.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%include "std_string.i"
|
|
||||||
|
|
||||||
/* turn on director wrapping Callback */
|
/* turn on director wrapping Callback */
|
||||||
%feature("director") Callback;
|
%feature("director") Callback;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@
|
||||||
#include "example.h"
|
#include "example.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%include "std_string.i"
|
|
||||||
|
|
||||||
/* turn on director wrapping Callback */
|
/* turn on director wrapping Callback */
|
||||||
%feature("director") Callback;
|
%feature("director") Callback;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@
|
||||||
#include "example.h"
|
#include "example.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%include "std_string.i"
|
|
||||||
|
|
||||||
/* turn on director wrapping Callback */
|
/* turn on director wrapping Callback */
|
||||||
%feature("director") Callback;
|
%feature("director") Callback;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@
|
||||||
#include "example.h"
|
#include "example.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%include "std_string.i"
|
|
||||||
|
|
||||||
/* turn on director wrapping Callback */
|
/* turn on director wrapping Callback */
|
||||||
%feature("director") Callback;
|
%feature("director") Callback;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,10 @@ import example
|
||||||
|
|
||||||
|
|
||||||
class PyCallback(example.Callback):
|
class PyCallback(example.Callback):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
example.Callback.__init__(self)
|
example.Callback.__init__(self)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
print "PyCallback.run()"
|
print "PyCallback.run()"
|
||||||
|
|
||||||
|
|
@ -25,7 +27,7 @@ callback = example.Callback()
|
||||||
callback.thisown = 0
|
callback.thisown = 0
|
||||||
caller.setCallback(callback)
|
caller.setCallback(callback)
|
||||||
caller.call()
|
caller.call()
|
||||||
caller.delCallback();
|
caller.delCallback()
|
||||||
|
|
||||||
print
|
print
|
||||||
print "Adding and calling a Python callback"
|
print "Adding and calling a Python callback"
|
||||||
|
|
@ -53,4 +55,3 @@ caller.delCallback()
|
||||||
|
|
||||||
print
|
print
|
||||||
print "python exit"
|
print "python exit"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,3 @@ try:
|
||||||
print "FOO = ", example.FOO, "(Arg! This shouldn't print anything)"
|
print "FOO = ", example.FOO, "(Arg! This shouldn't print anything)"
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
print "FOO isn't defined (good)"
|
print "FOO isn't defined (good)"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,12 +19,3 @@ example.cvar.Foo = 3.1415926
|
||||||
|
|
||||||
# See if the change took effect
|
# See if the change took effect
|
||||||
print "Foo = ", example.cvar.Foo
|
print "Foo = ", example.cvar.Foo
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,3 @@
|
||||||
import example
|
import example
|
||||||
|
|
||||||
print "example.Foo.bar.__doc__ =", repr(example.Foo.bar.__doc__), "(Should be 'No comment')"
|
print "example.Foo.bar.__doc__ =", repr(example.Foo.bar.__doc__), "(Should be 'No comment')"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,4 +28,3 @@ f = example.Foo()
|
||||||
f.enum_test(example.Foo.IMPULSE)
|
f.enum_test(example.Foo.IMPULSE)
|
||||||
f.enum_test(example.Foo.WARP)
|
f.enum_test(example.Foo.WARP)
|
||||||
f.enum_test(example.Foo.LUDICROUS)
|
f.enum_test(example.Foo.LUDICROUS)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,8 @@ else:
|
||||||
try:
|
try:
|
||||||
t.hosed()
|
t.hosed()
|
||||||
except BaseException, e:
|
except BaseException, e:
|
||||||
# Throwing builtin classes as exceptions not supported (-builtin option)
|
# Throwing builtin classes as exceptions not supported (-builtin
|
||||||
|
# option)
|
||||||
print e
|
print e
|
||||||
|
|
||||||
for i in range(1, 4):
|
for i in range(1, 4):
|
||||||
|
|
@ -39,5 +40,3 @@ for i in range(1,4):
|
||||||
print e.args[0]
|
print e.args[0]
|
||||||
except example.Exc, e:
|
except example.Exc, e:
|
||||||
print e.code, e.msg
|
print e.code, e.msg
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,3 @@ try:
|
||||||
q.dequeue()
|
q.dequeue()
|
||||||
except example.EmptyError, e:
|
except example.EmptyError, e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,10 @@ import example
|
||||||
# CEO class, which overrides Employee::getPosition().
|
# CEO class, which overrides Employee::getPosition().
|
||||||
|
|
||||||
class CEO(example.Manager):
|
class CEO(example.Manager):
|
||||||
|
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
example.Manager.__init__(self, name)
|
example.Manager.__init__(self, name)
|
||||||
|
|
||||||
def getPosition(self):
|
def getPosition(self):
|
||||||
return "CEO"
|
return "CEO"
|
||||||
|
|
||||||
|
|
@ -78,4 +80,3 @@ print "----------------------"
|
||||||
# All done.
|
# All done.
|
||||||
|
|
||||||
print "python exit"
|
print "python exit"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,4 +14,3 @@ for i in range(0,100):
|
||||||
|
|
||||||
print a.result()
|
print a.result()
|
||||||
print b.result()
|
print b.result()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,3 @@ if y:
|
||||||
print "bad swig"
|
print "bad swig"
|
||||||
else:
|
else:
|
||||||
print "good swig"
|
print "good swig"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ TOP = ../..
|
||||||
SWIG = $(realpath $(TOP)/../preinst-swig)
|
SWIG = $(realpath $(TOP)/../preinst-swig)
|
||||||
SWIGOPT =
|
SWIGOPT =
|
||||||
LIBS =
|
LIBS =
|
||||||
PY3 =
|
|
||||||
|
|
||||||
import_packages_subdirs = \
|
import_packages_subdirs = \
|
||||||
same_modnames1 \
|
same_modnames1 \
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ TOP = ../../..
|
||||||
SWIG = $(realpath $(TOP)/../preinst-swig)
|
SWIG = $(realpath $(TOP)/../preinst-swig)
|
||||||
SWIGOPT =
|
SWIGOPT =
|
||||||
LIBS =
|
LIBS =
|
||||||
PY3 =
|
|
||||||
|
|
||||||
ifeq (,$(PY3))
|
ifeq (,$(PY3))
|
||||||
PKG1DIR = "py2"
|
PKG1DIR = "py2"
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ TOP = ../../..
|
||||||
SWIG = $(realpath $(TOP)/../preinst-swig)
|
SWIG = $(realpath $(TOP)/../preinst-swig)
|
||||||
SWIGOPT =
|
SWIGOPT =
|
||||||
LIBS =
|
LIBS =
|
||||||
PY3 =
|
|
||||||
|
|
||||||
ifeq (,$(PY3))
|
ifeq (,$(PY3))
|
||||||
PKG1DIR = "py2"
|
PKG1DIR = "py2"
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ TOP = ../../..
|
||||||
SWIG = $(realpath $(TOP)/../preinst-swig)
|
SWIG = $(realpath $(TOP)/../preinst-swig)
|
||||||
SWIGOPT =
|
SWIGOPT =
|
||||||
LIBS =
|
LIBS =
|
||||||
PY3 =
|
|
||||||
|
|
||||||
ifeq (,$(PY3))
|
ifeq (,$(PY3))
|
||||||
PKG1DIR = "py2"
|
PKG1DIR = "py2"
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ TOP = ../../..
|
||||||
SWIG = $(realpath $(TOP)/../preinst-swig)
|
SWIG = $(realpath $(TOP)/../preinst-swig)
|
||||||
SWIGOPT =
|
SWIGOPT =
|
||||||
LIBS =
|
LIBS =
|
||||||
PY3 =
|
|
||||||
|
|
||||||
ifeq (,$(PY3))
|
ifeq (,$(PY3))
|
||||||
PKG1DIR = "py2"
|
PKG1DIR = "py2"
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ TOP = ../../..
|
||||||
SWIG = $(realpath $(TOP)/../preinst-swig)
|
SWIG = $(realpath $(TOP)/../preinst-swig)
|
||||||
SWIGOPT =
|
SWIGOPT =
|
||||||
LIBS =
|
LIBS =
|
||||||
PY3 =
|
|
||||||
|
|
||||||
ifeq (,$(PY3))
|
ifeq (,$(PY3))
|
||||||
PKG1DIR = "py2"
|
PKG1DIR = "py2"
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ TOP = ../../..
|
||||||
SWIG = $(realpath $(TOP)/../preinst-swig)
|
SWIG = $(realpath $(TOP)/../preinst-swig)
|
||||||
SWIGOPT =
|
SWIGOPT =
|
||||||
LIBS =
|
LIBS =
|
||||||
PY3 =
|
|
||||||
|
|
||||||
ifeq (,$(PY3))
|
ifeq (,$(PY3))
|
||||||
PKG1DIR = "py2"
|
PKG1DIR = "py2"
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ print "Testing " + testname + " - %module(package=...) + python 'import' in __in
|
||||||
import pkg1.pkg2.foo
|
import pkg1.pkg2.foo
|
||||||
print " Finished importing pkg1.pkg2.foo"
|
print " Finished importing pkg1.pkg2.foo"
|
||||||
|
|
||||||
var2 = pkg1.pkg2.foo.Pkg2_Foo();
|
var2 = pkg1.pkg2.foo.Pkg2_Foo()
|
||||||
if str(type(var2)).find("'pkg1.pkg2.foo.Pkg2_Foo'") == -1:
|
if str(type(var2)).find("'pkg1.pkg2.foo.Pkg2_Foo'") == -1:
|
||||||
raise RuntimeError("failed type checking: " + str(type(var2)))
|
raise RuntimeError("failed type checking: " + str(type(var2)))
|
||||||
print " Successfully created object pkg1.pkg2.foo.Pkg2_Foo"
|
print " Successfully created object pkg1.pkg2.foo.Pkg2_Foo"
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,3 @@ if y:
|
||||||
print "bad swig"
|
print "bad swig"
|
||||||
else:
|
else:
|
||||||
print "good swig"
|
print "good swig"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ extern int gcd(int x, int y);
|
||||||
if (!PyList_Check($input)) {
|
if (!PyList_Check($input)) {
|
||||||
SWIG_exception(SWIG_ValueError, "Expecting a list");
|
SWIG_exception(SWIG_ValueError, "Expecting a list");
|
||||||
}
|
}
|
||||||
$1 = PyList_Size($input);
|
$1 = (int)PyList_Size($input);
|
||||||
if ($1 == 0) {
|
if ($1 == 0) {
|
||||||
SWIG_exception(SWIG_ValueError, "List must contain at least 1 element");
|
SWIG_exception(SWIG_ValueError, "List must contain at least 1 element");
|
||||||
}
|
}
|
||||||
|
|
@ -73,7 +73,7 @@ extern int gcdmain(int argc, char *argv[]);
|
||||||
}
|
}
|
||||||
utf8str = PyUnicode_AsUTF8String($input);
|
utf8str = PyUnicode_AsUTF8String($input);
|
||||||
PyBytes_AsStringAndSize(utf8str, &cstr, &len);
|
PyBytes_AsStringAndSize(utf8str, &cstr, &len);
|
||||||
$1 = strndup(cstr, (size_t)len);
|
$1 = strncpy((char *)malloc(len+1), cstr, (size_t)len);
|
||||||
$2 = (int)len;
|
$2 = (int)len;
|
||||||
Py_DECREF(utf8str);
|
Py_DECREF(utf8str);
|
||||||
%#else
|
%#else
|
||||||
|
|
@ -82,7 +82,7 @@ extern int gcdmain(int argc, char *argv[]);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
$1 = PyString_AsString($input);
|
$1 = PyString_AsString($input);
|
||||||
$2 = PyString_Size($input);
|
$2 = (int)PyString_Size($input);
|
||||||
%#endif
|
%#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -106,11 +106,11 @@ extern int count(char *bytes, int len, char c);
|
||||||
Py_ssize_t len;
|
Py_ssize_t len;
|
||||||
PyObject *utf8str = PyUnicode_AsUTF8String($input);
|
PyObject *utf8str = PyUnicode_AsUTF8String($input);
|
||||||
PyBytes_AsStringAndSize(utf8str, &cstr, &len);
|
PyBytes_AsStringAndSize(utf8str, &cstr, &len);
|
||||||
$1 = strndup(cstr, (size_t)len);
|
$1 = strncpy((char *)malloc(len+1), cstr, (size_t)len);
|
||||||
$2 = (int)len;
|
$2 = (int)len;
|
||||||
Py_DECREF(utf8str);
|
Py_DECREF(utf8str);
|
||||||
%#else
|
%#else
|
||||||
$2 = PyString_Size($input);
|
$2 = (int)PyString_Size($input);
|
||||||
$1 = (char *) malloc($2+1);
|
$1 = (char *) malloc($2+1);
|
||||||
memmove($1,PyString_AsString($input),$2);
|
memmove($1,PyString_AsString($input),$2);
|
||||||
%#endif
|
%#endif
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,3 @@ print example.count("Hello World", "l")
|
||||||
# Call the capitalize function
|
# Call the capitalize function
|
||||||
|
|
||||||
print example.capitalize("hello world")
|
print example.capitalize("hello world")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,4 +18,3 @@ print "e =",e
|
||||||
# Big expression
|
# Big expression
|
||||||
f = ((a + b) * (c + b * e)) + (-a)
|
f = ((a + b) * (c + b * e)) + (-a)
|
||||||
print "f =", f
|
print "f =", f
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import sys
|
||||||
sys.path.append('..')
|
sys.path.append('..')
|
||||||
import harness
|
import harness
|
||||||
|
|
||||||
|
|
||||||
def proc(mod):
|
def proc(mod):
|
||||||
for i in range(1000000):
|
for i in range(1000000):
|
||||||
x = mod.MyClass()
|
x = mod.MyClass()
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import sys
|
||||||
sys.path.append('..')
|
sys.path.append('..')
|
||||||
import harness
|
import harness
|
||||||
|
|
||||||
|
|
||||||
def proc(mod):
|
def proc(mod):
|
||||||
x = mod.MyClass()
|
x = mod.MyClass()
|
||||||
for i in range(10000000):
|
for i in range(10000000):
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import time
|
||||||
import imp
|
import imp
|
||||||
from subprocess import *
|
from subprocess import *
|
||||||
|
|
||||||
|
|
||||||
def run(proc):
|
def run(proc):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -15,14 +16,17 @@ def run (proc) :
|
||||||
print "%s took %f seconds" % (mod.__name__, t2 - t1)
|
print "%s took %f seconds" % (mod.__name__, t2 - t1)
|
||||||
|
|
||||||
except IndexError:
|
except IndexError:
|
||||||
proc = Popen([sys.executable, 'runme.py', 'Simple_baseline'], stdout=PIPE)
|
proc = Popen(
|
||||||
|
[sys.executable, 'runme.py', 'Simple_baseline'], stdout=PIPE)
|
||||||
(stdout, stderr) = proc.communicate()
|
(stdout, stderr) = proc.communicate()
|
||||||
print stdout
|
print stdout
|
||||||
|
|
||||||
proc = Popen([sys.executable, 'runme.py', 'Simple_optimized'], stdout=PIPE)
|
proc = Popen(
|
||||||
|
[sys.executable, 'runme.py', 'Simple_optimized'], stdout=PIPE)
|
||||||
(stdout, stderr) = proc.communicate()
|
(stdout, stderr) = proc.communicate()
|
||||||
print stdout
|
print stdout
|
||||||
|
|
||||||
proc = Popen([sys.executable, 'runme.py', 'Simple_builtin'], stdout=PIPE)
|
proc = Popen(
|
||||||
|
[sys.executable, 'runme.py', 'Simple_builtin'], stdout=PIPE)
|
||||||
(stdout, stderr) = proc.communicate()
|
(stdout, stderr) = proc.communicate()
|
||||||
print stdout
|
print stdout
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import sys
|
||||||
sys.path.append('..')
|
sys.path.append('..')
|
||||||
import harness
|
import harness
|
||||||
|
|
||||||
|
|
||||||
def proc(mod):
|
def proc(mod):
|
||||||
x = mod.H()
|
x = mod.H()
|
||||||
for i in range(10000000):
|
for i in range(10000000):
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import sys
|
||||||
sys.path.append('..')
|
sys.path.append('..')
|
||||||
import harness
|
import harness
|
||||||
|
|
||||||
|
|
||||||
def proc(mod):
|
def proc(mod):
|
||||||
x = mod.H()
|
x = mod.H()
|
||||||
for i in range(10000000):
|
for i in range(10000000):
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import sys
|
||||||
sys.path.append('..')
|
sys.path.append('..')
|
||||||
import harness
|
import harness
|
||||||
|
|
||||||
|
|
||||||
def proc(mod):
|
def proc(mod):
|
||||||
x = mod.MyClass()
|
x = mod.MyClass()
|
||||||
for i in range(10000000):
|
for i in range(10000000):
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
# file: runme.py
|
# file: runme.py
|
||||||
|
|
||||||
import example;
|
import example
|
||||||
|
|
||||||
# First create some objects using the pointer library.
|
# First create some objects using the pointer library.
|
||||||
print "Testing the pointer library";
|
print "Testing the pointer library"
|
||||||
a = example.new_intp();
|
a = example.new_intp()
|
||||||
b = example.new_intp();
|
b = example.new_intp()
|
||||||
c = example.new_intp();
|
c = example.new_intp()
|
||||||
example.intp_assign(a,37);
|
example.intp_assign(a, 37)
|
||||||
example.intp_assign(b,42);
|
example.intp_assign(b, 42)
|
||||||
|
|
||||||
print " a =", a
|
print " a =", a
|
||||||
print " b =", b
|
print " b =", b
|
||||||
|
|
@ -30,15 +30,12 @@ example.delete_intp(c)
|
||||||
# This should be much easier. Now how it is no longer
|
# This should be much easier. Now how it is no longer
|
||||||
# necessary to manufacture pointers.
|
# necessary to manufacture pointers.
|
||||||
|
|
||||||
print "Trying the typemap library";
|
print "Trying the typemap library"
|
||||||
r = example.sub(37, 42)
|
r = example.sub(37, 42)
|
||||||
print " 37 - 42 =", r
|
print " 37 - 42 =", r
|
||||||
|
|
||||||
# Now try the version with multiple return values
|
# Now try the version with multiple return values
|
||||||
|
|
||||||
print "Testing multiple return values";
|
print "Testing multiple return values"
|
||||||
q, r = example.divide(42, 37)
|
q, r = example.divide(42, 37)
|
||||||
print " 42/37 = %d remainder %d" % (q, r)
|
print " 42/37 = %d remainder %d" % (q, r)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,4 +60,3 @@ print "Cleaning up"
|
||||||
del va
|
del va
|
||||||
del a
|
del a
|
||||||
del b
|
del b
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,12 +19,3 @@ example.cvar.Foo = 3.1415926
|
||||||
|
|
||||||
# See if the change took effect
|
# See if the change took effect
|
||||||
print "Foo = ", example.cvar.Foo
|
print "Foo = ", example.cvar.Foo
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,4 +52,3 @@ del ss
|
||||||
s = 3
|
s = 3
|
||||||
print example.cvar.Shape_nshapes, "shapes remain"
|
print example.cvar.Shape_nshapes, "shapes remain"
|
||||||
print "Goodbye"
|
print "Goodbye"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,6 @@ pmap["hi"] = 1
|
||||||
pmap["hello"] = 2
|
pmap["hello"] = 2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
dmap = {}
|
dmap = {}
|
||||||
dmap["hello"] = 1.0
|
dmap["hello"] = 1.0
|
||||||
dmap["hi"] = 2.0
|
dmap["hi"] = 2.0
|
||||||
|
|
@ -54,7 +52,6 @@ print hmap.keys()
|
||||||
print hmap.values()
|
print hmap.values()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
dmap = {}
|
dmap = {}
|
||||||
dmap["hello"] = 2
|
dmap["hello"] = 2
|
||||||
dmap["hi"] = 4
|
dmap["hi"] = 4
|
||||||
|
|
|
||||||
|
|
@ -33,4 +33,3 @@ example.halve_in_place(v)
|
||||||
for i in range(len(v)):
|
for i in range(len(v)):
|
||||||
print v[i], "; ",
|
print v[i], "; ",
|
||||||
print
|
print
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,5 +30,3 @@ print sum
|
||||||
|
|
||||||
del iv
|
del iv
|
||||||
del dv
|
del dv
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,11 +25,3 @@ example.fprintf(stdout,"The value is %d\n")
|
||||||
# This function calls our NULL-terminated function
|
# This function calls our NULL-terminated function
|
||||||
|
|
||||||
example.printv("Hello", "World", "this", "is", "a", "test.")
|
example.printv("Hello", "World", "this", "is", "a", "test.")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,16 +46,16 @@ print "\nVariables (values printed from C)"
|
||||||
|
|
||||||
example.print_vars()
|
example.print_vars()
|
||||||
|
|
||||||
print "\nNow I'm going to try and modify some read only variables";
|
print "\nNow I'm going to try and modify some read only variables"
|
||||||
|
|
||||||
print " Tring to set 'path'";
|
print " Tring to set 'path'"
|
||||||
try:
|
try:
|
||||||
example.cvar.path = "Whoa!"
|
example.cvar.path = "Whoa!"
|
||||||
print "Hey, what's going on?!?! This shouldn't work"
|
print "Hey, what's going on?!?! This shouldn't work"
|
||||||
except:
|
except:
|
||||||
print "Good."
|
print "Good."
|
||||||
|
|
||||||
print " Trying to set 'status'";
|
print " Trying to set 'status'"
|
||||||
try:
|
try:
|
||||||
example.cvar.status = 0
|
example.cvar.status = 0
|
||||||
print "Hey, what's going on?!?! This shouldn't work"
|
print "Hey, what's going on?!?! This shouldn't work"
|
||||||
|
|
@ -70,6 +70,3 @@ example.cvar.pt = example.cvar.ptptr
|
||||||
print "The new value is"
|
print "The new value is"
|
||||||
example.pt_print()
|
example.pt_print()
|
||||||
print "You should see the value", example.Point_print(example.cvar.ptptr)
|
print "You should see the value", example.Point_print(example.cvar.ptptr)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,13 +13,8 @@ namespace ArrayExample
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Eight node_list;
|
Eight node_list;
|
||||||
#ifndef _MSC_VER
|
|
||||||
const Eight node_list2;
|
const Eight node_list2;
|
||||||
ConstEight node_list3;
|
ConstEight node_list3;
|
||||||
#else
|
|
||||||
Eight node_list2;
|
|
||||||
Eight node_list3;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void fn1(Eight a) {}
|
void fn1(Eight a) {}
|
||||||
void fn2(const Eight a) {}
|
void fn2(const Eight a) {}
|
||||||
|
|
@ -32,6 +27,8 @@ namespace ArrayExample
|
||||||
void fn7(Eight*& a) {}
|
void fn7(Eight*& a) {}
|
||||||
void fn8(ConstEight*& a) {}
|
void fn8(ConstEight*& a) {}
|
||||||
void fn9(const ConstEight*& a) {}
|
void fn9(const ConstEight*& a) {}
|
||||||
|
|
||||||
|
ExampleDetail() : node_list(), node_list2(), node_list3() {}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
15
Examples/test-suite/chartest.i
Normal file
15
Examples/test-suite/chartest.i
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
%module chartest
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
char printable_global_char = 'a';
|
||||||
|
char unprintable_global_char = 0x7F;
|
||||||
|
|
||||||
|
char GetPrintableChar() {
|
||||||
|
return 'a';
|
||||||
|
}
|
||||||
|
|
||||||
|
char GetUnprintableChar() {
|
||||||
|
return 0x7F;
|
||||||
|
}
|
||||||
|
|
||||||
|
%}
|
||||||
|
|
@ -138,6 +138,7 @@ CPP_TEST_CASES += \
|
||||||
casts \
|
casts \
|
||||||
char_binary \
|
char_binary \
|
||||||
char_strings \
|
char_strings \
|
||||||
|
chartest \
|
||||||
class_forward \
|
class_forward \
|
||||||
class_ignore \
|
class_ignore \
|
||||||
class_scope_weird \
|
class_scope_weird \
|
||||||
|
|
@ -156,6 +157,7 @@ CPP_TEST_CASES += \
|
||||||
conversion \
|
conversion \
|
||||||
conversion_namespace \
|
conversion_namespace \
|
||||||
conversion_ns_template \
|
conversion_ns_template \
|
||||||
|
conversion_operators \
|
||||||
cplusplus_throw \
|
cplusplus_throw \
|
||||||
cpp_basic \
|
cpp_basic \
|
||||||
cpp_enum \
|
cpp_enum \
|
||||||
|
|
@ -198,6 +200,7 @@ CPP_TEST_CASES += \
|
||||||
director_protected \
|
director_protected \
|
||||||
director_protected_overloaded \
|
director_protected_overloaded \
|
||||||
director_redefined \
|
director_redefined \
|
||||||
|
director_ref \
|
||||||
director_smartptr \
|
director_smartptr \
|
||||||
director_thread \
|
director_thread \
|
||||||
director_unroll \
|
director_unroll \
|
||||||
|
|
@ -233,6 +236,7 @@ CPP_TEST_CASES += \
|
||||||
features \
|
features \
|
||||||
fragments \
|
fragments \
|
||||||
friends \
|
friends \
|
||||||
|
friends_template \
|
||||||
funcptr_cpp \
|
funcptr_cpp \
|
||||||
fvirtual \
|
fvirtual \
|
||||||
global_namespace \
|
global_namespace \
|
||||||
|
|
@ -243,6 +247,7 @@ CPP_TEST_CASES += \
|
||||||
ignore_parameter \
|
ignore_parameter \
|
||||||
import_nomodule \
|
import_nomodule \
|
||||||
inherit \
|
inherit \
|
||||||
|
inherit_member \
|
||||||
inherit_missing \
|
inherit_missing \
|
||||||
inherit_same_name \
|
inherit_same_name \
|
||||||
inherit_target_language \
|
inherit_target_language \
|
||||||
|
|
@ -407,6 +412,7 @@ CPP_TEST_CASES += \
|
||||||
template_inherit \
|
template_inherit \
|
||||||
template_inherit_abstract \
|
template_inherit_abstract \
|
||||||
template_int_const \
|
template_int_const \
|
||||||
|
template_keyword_in_type \
|
||||||
template_methods \
|
template_methods \
|
||||||
template_namespace_forward_declaration \
|
template_namespace_forward_declaration \
|
||||||
template_using_directive_and_declaration_forward \
|
template_using_directive_and_declaration_forward \
|
||||||
|
|
@ -540,6 +546,7 @@ CPP11_TEST_CASES = \
|
||||||
cpp11_template_explicit \
|
cpp11_template_explicit \
|
||||||
cpp11_template_typedefs \
|
cpp11_template_typedefs \
|
||||||
cpp11_type_traits \
|
cpp11_type_traits \
|
||||||
|
cpp11_type_aliasing \
|
||||||
cpp11_uniform_initialization \
|
cpp11_uniform_initialization \
|
||||||
cpp11_unrestricted_unions \
|
cpp11_unrestricted_unions \
|
||||||
cpp11_userdefined_literals \
|
cpp11_userdefined_literals \
|
||||||
|
|
|
||||||
55
Examples/test-suite/conversion_operators.i
Normal file
55
Examples/test-suite/conversion_operators.i
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
%module conversion_operators
|
||||||
|
|
||||||
|
// Test bug #401 where the conversion operator name incorrectly included the newline character
|
||||||
|
// Also test comments around conversion operators due to special handling in the scanner for conversion operators
|
||||||
|
|
||||||
|
// These one line ignores should match the conversion operator names to suppress Warning 503 - SWIGWARN_LANG_IDENTIFIER
|
||||||
|
%ignore operator const EcReal;
|
||||||
|
%ignore operator EcImaginary const;
|
||||||
|
%ignore operator EcComplex const;
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
|
||||||
|
struct EcReal {};
|
||||||
|
struct EcImaginary {};
|
||||||
|
struct EcComplex {};
|
||||||
|
|
||||||
|
struct EcAngle {
|
||||||
|
operator const EcReal
|
||||||
|
(
|
||||||
|
) const;
|
||||||
|
operator EcImaginary
|
||||||
|
const (
|
||||||
|
) const;
|
||||||
|
operator
|
||||||
|
EcComplex
|
||||||
|
const (
|
||||||
|
) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct EcAngle2 {
|
||||||
|
operator const EcReal/* C comment */
|
||||||
|
(
|
||||||
|
) const;
|
||||||
|
operator EcImaginary/* C comment */
|
||||||
|
const (
|
||||||
|
) const;
|
||||||
|
operator/* C comment */
|
||||||
|
EcComplex
|
||||||
|
const (
|
||||||
|
) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct EcAngle3 {
|
||||||
|
operator const EcReal // C++ comment
|
||||||
|
(
|
||||||
|
) const;
|
||||||
|
operator EcImaginary // C++ comment
|
||||||
|
const (
|
||||||
|
) const;
|
||||||
|
operator // C++ comment
|
||||||
|
EcComplex
|
||||||
|
const (
|
||||||
|
) const;
|
||||||
|
};
|
||||||
|
%}
|
||||||
|
|
@ -100,9 +100,6 @@ int runLambdaInline() {
|
||||||
|
|
||||||
%{
|
%{
|
||||||
// TODO
|
// TODO
|
||||||
struct LambdaStruct {
|
|
||||||
static constexpr auto lambda_struct1 = [=]() { return thing; };
|
|
||||||
};
|
|
||||||
int(*lambda101notauto)(int, int) = [] (int a, int b) { return a + b; };
|
int(*lambda101notauto)(int, int) = [] (int a, int b) { return a + b; };
|
||||||
int lambda102 = [] (int a, int b) mutable { return a + b; }(1, 2);
|
int lambda102 = [] (int a, int b) mutable { return a + b; }(1, 2);
|
||||||
void lambda_init(int = ([=]{ return 0; })());
|
void lambda_init(int = ([=]{ return 0; })());
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ struct NoExceptClass {
|
||||||
NoExceptClass() noexcept {}
|
NoExceptClass() noexcept {}
|
||||||
NoExceptClass(const NoExceptClass&) noexcept {}
|
NoExceptClass(const NoExceptClass&) noexcept {}
|
||||||
NoExceptClass(NoExceptClass&&) noexcept {}
|
NoExceptClass(NoExceptClass&&) noexcept {}
|
||||||
NoExceptClass& operator=(const NoExceptClass&) noexcept {}
|
NoExceptClass& operator=(const NoExceptClass&) noexcept { return *this; }
|
||||||
~NoExceptClass() noexcept {}
|
~NoExceptClass() noexcept {}
|
||||||
|
|
||||||
void noex0() noexcept {}
|
void noex0() noexcept {}
|
||||||
|
|
|
||||||
|
|
@ -31,14 +31,17 @@ struct Thingy {
|
||||||
// test both primitive and user defined rvalue reference default arguments and compactdefaultargs
|
// test both primitive and user defined rvalue reference default arguments and compactdefaultargs
|
||||||
void compactDefaultArgs(const bool &&b = (const bool &&)PublicGlobalTrue, const UserDef &&u = (const UserDef &&)PublicUserDef) {}
|
void compactDefaultArgs(const bool &&b = (const bool &&)PublicGlobalTrue, const UserDef &&u = (const UserDef &&)PublicUserDef) {}
|
||||||
void privateDefaultArgs(const bool &&b = (const bool &&)PrivateTrue) {}
|
void privateDefaultArgs(const bool &&b = (const bool &&)PrivateTrue) {}
|
||||||
operator int &&() {}
|
operator int &&() { return std::move(0); }
|
||||||
|
Thingy(const Thingy& rhs) : val(rhs.val), lvalref(rhs.lvalref), rvalref(copy_int(rhs.rvalref)) {}
|
||||||
Thingy& operator=(const Thingy& rhs) {
|
Thingy& operator=(const Thingy& rhs) {
|
||||||
val = rhs.val;
|
val = rhs.val;
|
||||||
lvalref = rhs.lvalref;
|
lvalref = rhs.lvalref;
|
||||||
rvalref = rhs.rvalref;
|
rvalref = rhs.rvalref;
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
static const bool PrivateTrue;
|
static const bool PrivateTrue;
|
||||||
|
int copy_int(int& i) { return i; }
|
||||||
Thingy();
|
Thingy();
|
||||||
};
|
};
|
||||||
const bool Thingy::PrivateTrue = true;
|
const bool Thingy::PrivateTrue = true;
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,14 @@
|
||||||
%module cpp11_template_typedefs
|
%module cpp11_template_typedefs
|
||||||
|
|
||||||
%warnfilter(SWIGWARN_CPP11_ALIAS_TEMPLATE) TypedefName;
|
%warnfilter(SWIGWARN_CPP11_ALIAS_TEMPLATE) TypedefName;
|
||||||
|
%warnfilter(SWIGWARN_CPP11_ALIAS_TEMPLATE) TypedefNamePtr;
|
||||||
%warnfilter(SWIGWARN_CPP11_ALIAS_TEMPLATE) MyIntKeyClass;
|
%warnfilter(SWIGWARN_CPP11_ALIAS_TEMPLATE) MyIntKeyClass;
|
||||||
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) PF;
|
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) PF;
|
||||||
|
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) BucketAllocator1;
|
||||||
|
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) BucketAllocator2;
|
||||||
|
|
||||||
|
// This warning should go away when type aliasing is supported
|
||||||
|
#pragma SWIG nowarn=SWIGWARN_PARSE_USING_UNDEF // Nothing known about 'p.SomeType< char *,T2,4 >'.
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
template< typename T1, typename T2, int >
|
template< typename T1, typename T2, int >
|
||||||
|
|
@ -16,6 +22,8 @@ class SomeType {
|
||||||
// template aliasing
|
// template aliasing
|
||||||
template< typename T2 >
|
template< typename T2 >
|
||||||
using TypedefName = SomeType<char*, T2, 5>;
|
using TypedefName = SomeType<char*, T2, 5>;
|
||||||
|
template< typename T2 >
|
||||||
|
using TypedefNamePtr = SomeType<char*, T2, 4>*;
|
||||||
|
|
||||||
// type aliasing
|
// type aliasing
|
||||||
typedef void (*PFD)(double); // Old style
|
typedef void (*PFD)(double); // Old style
|
||||||
|
|
@ -28,5 +36,21 @@ class MyCPP11Class {
|
||||||
};
|
};
|
||||||
template<typename VAL> using MyIntKeyClass = MyCPP11Class<int,VAL>;
|
template<typename VAL> using MyIntKeyClass = MyCPP11Class<int,VAL>;
|
||||||
MyIntKeyClass<char> intchar;
|
MyIntKeyClass<char> intchar;
|
||||||
|
|
||||||
|
TypedefName<int> alias1(TypedefName<int> a) { return a; }
|
||||||
|
TypedefNamePtr<int> alias1(TypedefNamePtr<int> a = nullptr) { return a; }
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
typedef double Val;
|
||||||
|
template<typename T> struct ListBucket {
|
||||||
|
};
|
||||||
|
namespace Alloc {
|
||||||
|
template<typename T> struct rebind {
|
||||||
|
typedef int other;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
using BucketAllocator1 = typename Alloc::template rebind<ListBucket<Val>>::other;
|
||||||
|
using BucketAllocator2 = typename Alloc::template rebind<::template ListBucket<double>>::other;
|
||||||
|
%}
|
||||||
|
|
|
||||||
66
Examples/test-suite/cpp11_type_aliasing.i
Normal file
66
Examples/test-suite/cpp11_type_aliasing.i
Normal file
|
|
@ -0,0 +1,66 @@
|
||||||
|
%module cpp11_type_aliasing
|
||||||
|
|
||||||
|
// Type aliasing seg fault : Github issue #424
|
||||||
|
|
||||||
|
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) Target;
|
||||||
|
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) Int;
|
||||||
|
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) IntRef;
|
||||||
|
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) IntPtrRef;
|
||||||
|
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) IntRValueRef;
|
||||||
|
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) IntArray;
|
||||||
|
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) HalideTargetPtr1;
|
||||||
|
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) HalideTargetPtr2;
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
namespace Halide {
|
||||||
|
|
||||||
|
struct Target {
|
||||||
|
int bits;
|
||||||
|
Target(int bits=32) : bits(bits) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
class NamesInterface {
|
||||||
|
public:
|
||||||
|
using Target = Halide::Target;
|
||||||
|
};
|
||||||
|
|
||||||
|
Target get_host_target() {
|
||||||
|
return Target();
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
template <typename T> class GeneratorParam {
|
||||||
|
T value;
|
||||||
|
public:
|
||||||
|
GeneratorParam(const char *name, const T &v) : value(v) {}
|
||||||
|
|
||||||
|
T getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class GeneratorBase : public NamesInterface {
|
||||||
|
public:
|
||||||
|
GeneratorParam<Target> target{ "target", Halide::get_host_target() };
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
%}
|
||||||
|
|
||||||
|
%template(Halide_Target) Halide::Internal::GeneratorParam<Halide::Target>;
|
||||||
|
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
using Int = int;
|
||||||
|
using IntRef = int&;
|
||||||
|
using IntPtrRef = int*&;
|
||||||
|
using IntRValueRef = int&&;
|
||||||
|
using IntArray = int[];
|
||||||
|
|
||||||
|
using HalideTargetPtr1 = Halide::Target*;
|
||||||
|
namespace Halide {
|
||||||
|
using HalideTargetPtr2 = Target*;
|
||||||
|
}
|
||||||
|
%}
|
||||||
|
|
@ -6,8 +6,7 @@ LANGUAGE = csharp
|
||||||
SCRIPTSUFFIX = _runme.cs
|
SCRIPTSUFFIX = _runme.cs
|
||||||
CSHARPCILINTERPRETER = @CSHARPCILINTERPRETER@
|
CSHARPCILINTERPRETER = @CSHARPCILINTERPRETER@
|
||||||
CSHARPCILINTERPRETER_FLAGS = @CSHARPCILINTERPRETER_FLAGS@
|
CSHARPCILINTERPRETER_FLAGS = @CSHARPCILINTERPRETER_FLAGS@
|
||||||
CSHARPPATHSEPARATOR = "@CSHARPPATHSEPARATOR@"
|
CSHARPCONVERTPATH = @top_srcdir@/@CSHARPCONVERTPATH@
|
||||||
CSHARPCYGPATH_W = @CSHARPCYGPATH_W@
|
|
||||||
|
|
||||||
srcdir = @srcdir@
|
srcdir = @srcdir@
|
||||||
top_srcdir = ../@top_srcdir@
|
top_srcdir = ../@top_srcdir@
|
||||||
|
|
@ -79,13 +78,13 @@ run_testcase = \
|
||||||
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||||
$(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \
|
$(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \
|
||||||
CSHARPFLAGS='-nologo -debug+ $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \
|
CSHARPFLAGS='-nologo -debug+ $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \
|
||||||
CSHARPSRCS='`$(CSHARPCYGPATH_W) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` `find $* -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile && \
|
CSHARPSRCS='`$(CSHARPCONVERTPATH) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` `find $* -name "*.cs" -exec $(CSHARPCONVERTPATH) "{}" \+`' csharp_compile && \
|
||||||
env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_FALLBACK_LIBRARY_PATH= $(RUNTOOL) $(CSHARPCILINTERPRETER) $(CSHARPCILINTERPRETER_FLAGS) ./$*_runme.exe; \
|
env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_FALLBACK_LIBRARY_PATH= $(RUNTOOL) $(CSHARPCILINTERPRETER) $(CSHARPCILINTERPRETER_FLAGS) ./$*_runme.exe; \
|
||||||
else \
|
else \
|
||||||
cd $* && \
|
cd $* && \
|
||||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
|
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
|
||||||
CSHARPFLAGS='-nologo -debug+ $(CSHARPFLAGSSPECIAL) -t:module -out:$*.netmodule' \
|
CSHARPFLAGS='-nologo -debug+ $(CSHARPFLAGSSPECIAL) -t:module -out:$*.netmodule' \
|
||||||
CSHARPSRCS='`find . -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile; \
|
CSHARPSRCS='`find . -name "*.cs" -exec ../$(CSHARPCONVERTPATH) "{}" \+`' csharp_compile; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Clean: remove testcase directories
|
# Clean: remove testcase directories
|
||||||
|
|
|
||||||
|
|
@ -12,13 +12,5 @@ public class runme
|
||||||
throw new Exception("Protected destructor exception should have been thrown");
|
throw new Exception("Protected destructor exception should have been thrown");
|
||||||
} catch (MethodAccessException) {
|
} catch (MethodAccessException) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// calling private destructor test
|
|
||||||
try {
|
|
||||||
using (FFF f = new FFF()) {
|
|
||||||
}
|
|
||||||
throw new Exception("Private destructor exception should have been thrown");
|
|
||||||
} catch (MethodAccessException) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,5 +16,12 @@ public class runme
|
||||||
|
|
||||||
HiddenDestructor hidden = HiddenDestructor.create();
|
HiddenDestructor hidden = HiddenDestructor.create();
|
||||||
hidden.Dispose();
|
hidden.Dispose();
|
||||||
|
|
||||||
|
HiddenPrivateDestructor hiddenPrivate = HiddenPrivateDestructor.create();
|
||||||
|
if (HiddenPrivateDestructor.DeleteCount != 0)
|
||||||
|
throw new ApplicationException("Count should be zero");
|
||||||
|
hiddenPrivate.Dispose();
|
||||||
|
if (HiddenPrivateDestructor.DeleteCount != 1)
|
||||||
|
throw new ApplicationException("Count should be one");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ public class runme
|
||||||
}
|
}
|
||||||
int actualCount = Klass.getTotal_count();
|
int actualCount = Klass.getTotal_count();
|
||||||
if (actualCount != expectedCount)
|
if (actualCount != expectedCount)
|
||||||
throw new ApplicationException("Expected count: " + expectedCount + " Actual count: " + actualCount);
|
Console.Error.WriteLine("Expected count: " + expectedCount + " Actual count: " + actualCount); // Finalizers are not guaranteed to be run and sometimes they just don't
|
||||||
}
|
}
|
||||||
|
|
||||||
int wrapper_count = li_boost_shared_ptr.shared_ptr_wrapper_count();
|
int wrapper_count = li_boost_shared_ptr.shared_ptr_wrapper_count();
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ public class li_std_auto_ptr_runme {
|
||||||
};
|
};
|
||||||
int actualCount = Klass.getTotal_count();
|
int actualCount = Klass.getTotal_count();
|
||||||
if (actualCount != expectedCount)
|
if (actualCount != expectedCount)
|
||||||
throw new ApplicationException("Expected count: " + expectedCount + " Actual count: " + actualCount);
|
Console.Error.WriteLine("Expected count: " + expectedCount + " Actual count: " + actualCount); // Finalizers are not guaranteed to be run and sometimes they just don't
|
||||||
}
|
}
|
||||||
|
|
||||||
if (k2.getLabel() != "second")
|
if (k2.getLabel() != "second")
|
||||||
|
|
@ -51,7 +51,7 @@ public class li_std_auto_ptr_runme {
|
||||||
}
|
}
|
||||||
int actualCount = Klass.getTotal_count();
|
int actualCount = Klass.getTotal_count();
|
||||||
if (actualCount != expectedCount)
|
if (actualCount != expectedCount)
|
||||||
throw new ApplicationException("Expected count: " + expectedCount + " Actual count: " + actualCount);
|
Console.Error.WriteLine("Expected count: " + expectedCount + " Actual count: " + actualCount); // Finalizers are not guaranteed to be run and sometimes they just don't
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
module default_constructor_runme;
|
module default_constructor_runme;
|
||||||
|
|
||||||
import default_constructor.FFF;
|
|
||||||
import default_constructor.G;
|
import default_constructor.G;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|
@ -15,16 +14,4 @@ void main() {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Private destructor test.
|
|
||||||
try {
|
|
||||||
{
|
|
||||||
scope f = new FFF();
|
|
||||||
}
|
|
||||||
throw new Exception("Private destructor exception should have been thrown");
|
|
||||||
} catch (Exception e) {
|
|
||||||
if (e.msg != "C++ destructor does not have public access") {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
module default_constructor_runme;
|
module default_constructor_runme;
|
||||||
|
|
||||||
import default_constructor.FFF;
|
|
||||||
import default_constructor.G;
|
import default_constructor.G;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|
@ -8,7 +7,6 @@ void main() {
|
||||||
// destruction yet.
|
// destruction yet.
|
||||||
|
|
||||||
// enforceThrows((){ scope g = new G(); }, "Protected destructor exception should have been thrown");
|
// enforceThrows((){ scope g = new G(); }, "Protected destructor exception should have been thrown");
|
||||||
// enforceThrows((){ scope f = new FFF(); }, "Private destructor exception should have been thrown");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enforceThrows(void delegate() dg, string errorMessage) {
|
private void enforceThrows(void delegate() dg, string errorMessage) {
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,12 @@ struct Display {
|
||||||
// Bad Python wrappers were being generated when NULL used for primitive type
|
// Bad Python wrappers were being generated when NULL used for primitive type
|
||||||
float draw1(float v = 0) { return v; }
|
float draw1(float v = 0) { return v; }
|
||||||
float draw2(float *v = 0) { return v ? *v : 0; }
|
float draw2(float *v = 0) { return v ? *v : 0; }
|
||||||
|
bool bool0(bool x = 0) { return x; }
|
||||||
|
bool bool1(bool x = 1) { return x; }
|
||||||
|
|
||||||
|
typedef bool mybool;
|
||||||
|
bool mybool0(mybool x = 0) { return x; }
|
||||||
|
bool mybool1(mybool x = 1) { return x; }
|
||||||
};
|
};
|
||||||
float* createPtr(float v) { static float val; val = v; return &val; }
|
float* createPtr(float v) { static float val; val = v; return &val; }
|
||||||
%}
|
%}
|
||||||
|
|
@ -14,5 +20,11 @@ struct Display {
|
||||||
// Bad Python wrappers were being generated when NULL used for primitive type
|
// Bad Python wrappers were being generated when NULL used for primitive type
|
||||||
float draw1(float v = NULL) { return v; }
|
float draw1(float v = NULL) { return v; }
|
||||||
float draw2(float *v = NULL) { return v ? *v : 0; }
|
float draw2(float *v = NULL) { return v ? *v : 0; }
|
||||||
|
bool bool0(bool x = 0) { return x; }
|
||||||
|
bool bool1(bool x = 1) { return x; }
|
||||||
|
|
||||||
|
typedef bool mybool;
|
||||||
|
bool mybool0(mybool x = 0) { return x; }
|
||||||
|
bool mybool1(mybool x = 1) { return x; }
|
||||||
};
|
};
|
||||||
float* createPtr(float v) { static float val; val = v; return &val; }
|
float* createPtr(float v) { static float val; val = v; return &val; }
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,10 @@
|
||||||
%rename(renamed2arg) Foo::renameme(int x) const;
|
%rename(renamed2arg) Foo::renameme(int x) const;
|
||||||
%rename(renamed1arg) Foo::renameme() const;
|
%rename(renamed1arg) Foo::renameme() const;
|
||||||
|
|
||||||
|
%typemap(default) double* null_by_default "$1=0;";
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
|
typedef void* MyHandle;
|
||||||
|
|
||||||
// Define a class
|
// Define a class
|
||||||
class Foo {
|
class Foo {
|
||||||
|
|
@ -139,6 +142,12 @@
|
||||||
// test the method itself being renamed
|
// test the method itself being renamed
|
||||||
void oldname(int x = 1234) {}
|
void oldname(int x = 1234) {}
|
||||||
void renameme(int x = 1234, double d=123.4) const {}
|
void renameme(int x = 1234, double d=123.4) const {}
|
||||||
|
|
||||||
|
// test default values for pointer arguments
|
||||||
|
int double_if_void_ptr_is_null(int n, void* p = NULL) { return p ? n : 2*n; }
|
||||||
|
int double_if_handle_is_null(int n, MyHandle h = 0) { return h ? n : 2*n; }
|
||||||
|
int double_if_dbl_ptr_is_null(int n, double* null_by_default)
|
||||||
|
{ return null_by_default ? n : 2*n; }
|
||||||
};
|
};
|
||||||
int Foo::bar = 1;
|
int Foo::bar = 1;
|
||||||
int Foo::spam = 2;
|
int Foo::spam = 2;
|
||||||
|
|
@ -269,3 +278,26 @@ struct ConstMethods {
|
||||||
} Pointf;
|
} Pointf;
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
// Default arguments after ignored ones.
|
||||||
|
%typemap(in, numinputs=0) int square_error { $1 = 2; };
|
||||||
|
%typemap(default, noblock=1) int def17 { $1 = 17; };
|
||||||
|
|
||||||
|
// Enabling autodoc feature has a side effect of disabling the generation of
|
||||||
|
// aliases for functions that can hide problems with default arguments at
|
||||||
|
// Python level.
|
||||||
|
%feature("autodoc","0") slightly_off_square;
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
inline int slightly_off_square(int square_error, int def17) { return def17*def17 + square_error; }
|
||||||
|
%}
|
||||||
|
|
||||||
|
// Python C default args
|
||||||
|
%feature("python:cdefaultargs") CDA::cdefaultargs_test1;
|
||||||
|
%inline %{
|
||||||
|
struct CDA {
|
||||||
|
int cdefaultargs_test1(int a = 1) { return a; }
|
||||||
|
int cdefaultargs_test2(int a = 1) { return a; }
|
||||||
|
};
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,16 @@
|
||||||
SWIGWARN_D_MULTIPLE_INHERITANCE,
|
SWIGWARN_D_MULTIPLE_INHERITANCE,
|
||||||
SWIGWARN_PHP_MULTIPLE_INHERITANCE) AD; /* C#, D, Java, PHP multiple inheritance */
|
SWIGWARN_PHP_MULTIPLE_INHERITANCE) AD; /* C#, D, Java, PHP multiple inheritance */
|
||||||
|
|
||||||
|
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
|
||||||
|
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
|
||||||
|
SWIGWARN_D_MULTIPLE_INHERITANCE,
|
||||||
|
SWIGWARN_PHP_MULTIPLE_INHERITANCE) GGG; /* C#, D, Java, PHP multiple inheritance */
|
||||||
|
|
||||||
|
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
|
||||||
|
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
|
||||||
|
SWIGWARN_D_MULTIPLE_INHERITANCE,
|
||||||
|
SWIGWARN_PHP_MULTIPLE_INHERITANCE) HHH; /* C#, D, Java, PHP multiple inheritance */
|
||||||
|
|
||||||
%warnfilter(SWIGWARN_LANG_FRIEND_IGNORE) F; /* friend function */
|
%warnfilter(SWIGWARN_LANG_FRIEND_IGNORE) F; /* friend function */
|
||||||
|
|
||||||
%delobject F::destroy;
|
%delobject F::destroy;
|
||||||
|
|
@ -103,14 +113,15 @@ public:
|
||||||
|
|
||||||
void bar(F *) { }
|
void bar(F *) { }
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
// Single inheritance, base has private destructor
|
||||||
#pragma warning(disable: 4624) // : destructor could not be generated because a base class destructor is inaccessible
|
|
||||||
#endif
|
|
||||||
class FFF : public F {
|
class FFF : public F {
|
||||||
};
|
};
|
||||||
#if defined(_MSC_VER)
|
|
||||||
#pragma warning(default: 4624) // : destructor could not be generated because a base class destructor is inaccessible
|
// Multiple inheritance, one base has private destructor
|
||||||
#endif
|
class GGG : public A, public F {
|
||||||
|
};
|
||||||
|
class HHH : public F, public A {
|
||||||
|
};
|
||||||
|
|
||||||
/* A class with a protected destructor */
|
/* A class with a protected destructor */
|
||||||
class G {
|
class G {
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
%apply (char *STRING, size_t LENGTH) { (char *dataBufferAA, int sizeAA) };
|
%apply (char *STRING, size_t LENGTH) { (char *dataBufferAA, int sizeAA) };
|
||||||
%apply (char *STRING, size_t LENGTH) { (char *dataBufferBB, int sizeBB) };
|
%apply (char *STRING, size_t LENGTH) { (char *dataBufferBB, int sizeBB) };
|
||||||
|
%apply (char* STRING, size_t LENGTH) { (const void* data, size_t datalen) };
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
@ -20,6 +21,7 @@ public:
|
||||||
if (dataBufferBB)
|
if (dataBufferBB)
|
||||||
memset(dataBufferBB, -1, sizeBB);
|
memset(dataBufferBB, -1, sizeBB);
|
||||||
}
|
}
|
||||||
|
virtual void writeData(const void* data, size_t datalen) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Caller {
|
class Caller {
|
||||||
|
|
@ -50,6 +52,17 @@ public:
|
||||||
void call_null() {
|
void call_null() {
|
||||||
_callback->run(NULL, 0, NULL, 0);
|
_callback->run(NULL, 0, NULL, 0);
|
||||||
}
|
}
|
||||||
|
int callWriteData() {
|
||||||
|
int sum = 0;
|
||||||
|
if (_callback) {
|
||||||
|
char* aa = (char*)malloc(BUFFER_SIZE_AA);
|
||||||
|
memset(aa, 9, BUFFER_SIZE_AA);
|
||||||
|
_callback->writeData(aa, BUFFER_SIZE_AA);
|
||||||
|
for (int i = 0; i < BUFFER_SIZE_AA; i++)
|
||||||
|
sum += aa[i];
|
||||||
|
}
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
%ignore OverloadedProtectedMethod(int n, int xoffset = 0, int yoffset = 0);
|
%ignore OverloadedProtectedMethod(int n, int xoffset = 0, int yoffset = 0);
|
||||||
%ignore DIgnoreConstructor(bool b);
|
%ignore DIgnoreConstructor(bool b);
|
||||||
%ignore DIgnoreOnlyConstructor(bool b);
|
%ignore DIgnoreOnlyConstructor(bool b);
|
||||||
|
%ignore DIgnoreDestructor::~DIgnoreDestructor;
|
||||||
%ignore Pointers;
|
%ignore Pointers;
|
||||||
%ignore References;
|
%ignore References;
|
||||||
%ignore PublicMethod1;
|
%ignore PublicMethod1;
|
||||||
|
|
@ -101,6 +102,13 @@ class DIgnoreOnlyConstructor
|
||||||
DIgnoreOnlyConstructor(bool b) {}
|
DIgnoreOnlyConstructor(bool b) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class DIgnoreDestructor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DIgnoreDestructor() {}
|
||||||
|
virtual ~DIgnoreDestructor() {}
|
||||||
|
};
|
||||||
|
|
||||||
%{
|
%{
|
||||||
class DIgnoreConstructor
|
class DIgnoreConstructor
|
||||||
{
|
{
|
||||||
|
|
@ -118,5 +126,12 @@ class DIgnoreOnlyConstructor
|
||||||
private: // Hide constructor
|
private: // Hide constructor
|
||||||
DIgnoreOnlyConstructor(bool b) {}
|
DIgnoreOnlyConstructor(bool b) {}
|
||||||
};
|
};
|
||||||
%}
|
|
||||||
|
|
||||||
|
class DIgnoreDestructor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DIgnoreDestructor() {}
|
||||||
|
virtual ~DIgnoreDestructor() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
%}
|
||||||
|
|
|
||||||
82
Examples/test-suite/director_ref.i
Normal file
82
Examples/test-suite/director_ref.i
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
%module(directors="1") director_ref
|
||||||
|
|
||||||
|
%{
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class Foo {
|
||||||
|
public:
|
||||||
|
Foo(int i = -1) : count(0) {}
|
||||||
|
virtual void OnDelete() {}
|
||||||
|
virtual ~Foo() {}
|
||||||
|
virtual std::string Msg(std::string msg = "default") { return "Foo-" + msg; }
|
||||||
|
|
||||||
|
std::string GetMsg() { return Msg(); }
|
||||||
|
std::string GetMsg(std::string msg) { return Msg(msg); }
|
||||||
|
|
||||||
|
void Ref() { ++count; }
|
||||||
|
void Unref() { --count; if (count == 0) { OnDelete(); delete this; } }
|
||||||
|
int GetRefCount() { return count; }
|
||||||
|
private:
|
||||||
|
int count;
|
||||||
|
};
|
||||||
|
|
||||||
|
class FooPtr {
|
||||||
|
public:
|
||||||
|
FooPtr(Foo* f = NULL) : my_f(f) { if (my_f) { my_f->Ref(); } }
|
||||||
|
~FooPtr() { if (my_f) { my_f->Unref(); } }
|
||||||
|
void Reset(Foo* f = NULL) {
|
||||||
|
if (f) { f->Ref(); }
|
||||||
|
if (my_f) { my_f->Unref(); }
|
||||||
|
my_f = f;
|
||||||
|
}
|
||||||
|
int GetOwnedRefCount() {
|
||||||
|
if (my_f) { return my_f->GetRefCount(); }
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Foo* my_f;
|
||||||
|
};
|
||||||
|
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include <std_string.i>
|
||||||
|
|
||||||
|
%feature("director") Foo;
|
||||||
|
%feature("ref") Foo "$this->Ref();"
|
||||||
|
%feature("unref") Foo "$this->Unref();"
|
||||||
|
|
||||||
|
class Foo {
|
||||||
|
public:
|
||||||
|
Foo(int i = -1) : count(0) {}
|
||||||
|
virtual void OnDelete() {}
|
||||||
|
virtual ~Foo() {}
|
||||||
|
virtual std::string Msg(std::string msg = "default") { return "Foo-" + msg; }
|
||||||
|
|
||||||
|
std::string GetMsg() { return Msg(); }
|
||||||
|
std::string GetMsg(std::string msg) { return Msg(msg); }
|
||||||
|
|
||||||
|
void Ref() { ++count; }
|
||||||
|
void Unref() { --count; if (count == 0) { OnDelete(); delete this; } }
|
||||||
|
int GetRefCount() { return count; }
|
||||||
|
private:
|
||||||
|
int count;
|
||||||
|
};
|
||||||
|
|
||||||
|
class FooPtr {
|
||||||
|
public:
|
||||||
|
FooPtr(Foo* f = NULL) : my_f(f) { if (my_f) { my_f->Ref(); } }
|
||||||
|
~FooPtr() { if (my_f) { my_f->Unref(); } }
|
||||||
|
void Reset(Foo* f = NULL) {
|
||||||
|
if (f) { f->Ref(); }
|
||||||
|
if (my_f) { my_f->Unref(); }
|
||||||
|
my_f = f;
|
||||||
|
}
|
||||||
|
int GetOwnedRefCount() {
|
||||||
|
if (my_f) { return my_f->GetRefCount(); }
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Foo* my_f;
|
||||||
|
};
|
||||||
|
|
@ -100,4 +100,9 @@ void overloadinline2(const int *) {}
|
||||||
void overload5(int *) {}
|
void overload5(int *) {}
|
||||||
void overload5(const int *) {}
|
void overload5(const int *) {}
|
||||||
|
|
||||||
|
%ignore Outer2::QuietInner;
|
||||||
|
struct Outer2 {
|
||||||
|
struct QuietInner {
|
||||||
|
VARIABLEMACRO(MyInnerVar)
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
|
||||||
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