Merge branch 'master' into doxygen
The way Python docstrings are indented has changed on master, so use the standard inspect module in Python autodoc unit test to ignore the differences in their indentation level between -builtin and non-builtin cases to make the test still pass with the branch version, which avoids the use of different (but almost identical) values in the test itself.
This commit is contained in:
commit
e668c47b70
1094 changed files with 39390 additions and 11483 deletions
15
.gitignore
vendored
15
.gitignore
vendored
|
|
@ -85,8 +85,6 @@ swig.spec
|
||||||
# Build Artifacts
|
# Build Artifacts
|
||||||
.dirstamp
|
.dirstamp
|
||||||
CCache/ccache-swig
|
CCache/ccache-swig
|
||||||
CCache/ccache-swig.1
|
|
||||||
CCache/web/ccache-man.html
|
|
||||||
Lib/swigwarn.swg
|
Lib/swigwarn.swg
|
||||||
Source/CParse/parser.c
|
Source/CParse/parser.c
|
||||||
Source/CParse/parser.h
|
Source/CParse/parser.h
|
||||||
|
|
@ -96,7 +94,6 @@ swig
|
||||||
Tools/javascript/javascript
|
Tools/javascript/javascript
|
||||||
|
|
||||||
# Generated documentation
|
# Generated documentation
|
||||||
Doc/Manual/CCache.html
|
|
||||||
Doc/Manual/SWIGDocumentation.html
|
Doc/Manual/SWIGDocumentation.html
|
||||||
Doc/Manual/SWIGDocumentation.pdf
|
Doc/Manual/SWIGDocumentation.pdf
|
||||||
Doc/Manual/*.book
|
Doc/Manual/*.book
|
||||||
|
|
@ -114,6 +111,10 @@ Examples/scratch
|
||||||
# Out of source tree build directories
|
# Out of source tree build directories
|
||||||
*build*/
|
*build*/
|
||||||
|
|
||||||
|
# errors test-suite
|
||||||
|
Examples/test-suite/errors/*.newerr
|
||||||
|
Examples/test-suite/errors/*.py
|
||||||
|
|
||||||
########## Language specific files ##########
|
########## Language specific files ##########
|
||||||
|
|
||||||
# C#
|
# C#
|
||||||
|
|
@ -132,6 +133,14 @@ Examples/d/**/runme
|
||||||
# Go
|
# Go
|
||||||
*.[5689]
|
*.[5689]
|
||||||
*_gc.c
|
*_gc.c
|
||||||
|
Examples/test-suite/go/*.go
|
||||||
|
!Examples/test-suite/go/*runme.go
|
||||||
|
Examples/test-suite/go/*runme
|
||||||
|
Examples/test-suite/go/gopath
|
||||||
|
Examples/test-suite/go/testdir
|
||||||
|
Examples/go/*/gopath
|
||||||
|
Examples/go/*/example.go
|
||||||
|
Examples/go/*/runme
|
||||||
|
|
||||||
# Guile
|
# Guile
|
||||||
Examples/guile/*/my-guile
|
Examples/guile/*/my-guile
|
||||||
|
|
|
||||||
300
.travis.yml
300
.travis.yml
|
|
@ -2,133 +2,316 @@ language: cpp
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- compiler: clang
|
- compiler: clang
|
||||||
|
os: linux
|
||||||
|
env: SWIGLANG=
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
env: SWIGLANG=
|
env: SWIGLANG=
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
env: SWIGLANG=
|
env: SWIGLANG=
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
|
- os: linux
|
||||||
|
env: SWIGLANG= SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
|
- os: linux
|
||||||
|
env: SWIGLANG= SWIG_CC=gcc-6 SWIG_CXX=g++-6
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
env: SWIGLANG= GCC5=1 CPP11=1
|
os: linux
|
||||||
- compiler: gcc
|
|
||||||
env: SWIGLANG= GCC5=1 CPP14=1
|
|
||||||
- compiler: gcc
|
|
||||||
env: SWIGLANG=csharp
|
env: SWIGLANG=csharp
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
env: SWIGLANG=d
|
env: SWIGLANG=d
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
env: SWIGLANG=go
|
env: SWIGLANG=go
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
|
env: SWIGLANG=go VER=1.5
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
env: SWIGLANG=guile
|
env: SWIGLANG=guile
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
env: SWIGLANG=java
|
env: SWIGLANG=java
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
env: SWIGLANG=javascript ENGINE=node
|
env: SWIGLANG=javascript ENGINE=node
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
env: SWIGLANG=javascript ENGINE=jsc
|
env: SWIGLANG=javascript ENGINE=jsc
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
env: SWIGLANG=javascript ENGINE=v8
|
env: SWIGLANG=javascript ENGINE=v8
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
env: SWIGLANG=lua
|
env: SWIGLANG=lua
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
env: SWIGLANG=octave SWIGJOBS=-j3 # 3.2
|
os: linux
|
||||||
|
env: SWIGLANG=lua VER=5.3
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
env: SWIGLANG=octave SWIGJOBS=-j3 VER=3.8
|
os: linux
|
||||||
|
env: SWIGLANG=octave SWIGJOBS=-j2 # 3.2
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
env: SWIGLANG=octave SWIGJOBS=-j3 VER=4.0
|
os: linux
|
||||||
|
env: SWIGLANG=octave SWIGJOBS=-j2 VER=3.8
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
|
env: SWIGLANG=octave SWIGJOBS=-j2 VER=4.0
|
||||||
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
env: SWIGLANG=perl5
|
env: SWIGLANG=perl5
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
env: SWIGLANG=php
|
os: linux
|
||||||
|
env: SWIGLANG=php5
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
|
env: SWIGLANG=php VER=7.0
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
|
env: SWIGLANG=php VER=7.1
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
env: SWIGLANG=python VER=2.4
|
env: SWIGLANG=python VER=2.4
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
env: SWIGLANG=python VER=2.5
|
env: SWIGLANG=python VER=2.5
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
env: SWIGLANG=python VER=2.6
|
env: SWIGLANG=python VER=2.6
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
env: SWIGLANG=python # 2.7
|
env: SWIGLANG=python # 2.7
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
env: SWIGLANG=python PY3=3 # 3.2
|
os: linux
|
||||||
|
env: SWIGLANG=python PY3=3 VER=3.2
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
env: SWIGLANG=python PY3=3 VER=3.3
|
env: SWIGLANG=python PY3=3 VER=3.3
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
env: SWIGLANG=python PY3=3 VER=3.4
|
env: SWIGLANG=python PY3=3 VER=3.4
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
|
env: SWIGLANG=python PY3=3 VER=3.5
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
|
env: SWIGLANG=python SWIG_FEATURES=-builtin VER=2.6
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
env: SWIGLANG=python SWIG_FEATURES=-builtin
|
env: SWIGLANG=python SWIG_FEATURES=-builtin
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3
|
os: linux
|
||||||
|
env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.4
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
|
env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.5
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
|
env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.5 SWIGOPTPY3=
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
env: SWIGLANG=python SWIG_FEATURES=-O
|
env: SWIGLANG=python SWIG_FEATURES=-O
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
env: SWIGLANG=python SWIG_FEATURES=-classic
|
env: SWIGLANG=python SWIG_FEATURES=-classic
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
env: SWIGLANG=r
|
env: SWIGLANG=r
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
env: SWIGLANG=ruby
|
os: linux
|
||||||
|
env: SWIGLANG=ruby VER=1.9.3
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
|
env: SWIGLANG=ruby VER=2.0.0
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
|
env: SWIGLANG=ruby VER=2.3.0
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
env: SWIGLANG=scilab
|
env: SWIGLANG=scilab
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
env: SWIGLANG=tcl
|
env: SWIGLANG=tcl
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
|
- os: linux
|
||||||
|
env: SWIGLANG=csharp SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
|
- os: linux
|
||||||
|
env: SWIGLANG=java SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
|
- os: linux
|
||||||
|
env: SWIGLANG=python SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
|
- os: linux
|
||||||
|
env: SWIGLANG=csharp SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
|
- os: linux
|
||||||
|
env: SWIGLANG=java SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
|
- os: linux
|
||||||
|
env: SWIGLANG=python SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
env: SWIGLANG=csharp GCC5=1 CPP11=1
|
os: osx
|
||||||
- compiler: gcc
|
env: SWIGLANG=
|
||||||
env: SWIGLANG=java GCC5=1 CPP11=1
|
- compiler: clang
|
||||||
- compiler: gcc
|
os: osx
|
||||||
env: SWIGLANG=python GCC5=1 CPP11=1
|
env: SWIGLANG=
|
||||||
|
- compiler: clang
|
||||||
|
os: osx
|
||||||
|
env: SWIGLANG=csharp
|
||||||
|
- compiler: clang
|
||||||
|
os: osx
|
||||||
|
env: SWIGLANG=go
|
||||||
|
- compiler: clang
|
||||||
|
os: osx
|
||||||
|
env: SWIGLANG=guile
|
||||||
|
- compiler: clang
|
||||||
|
os: osx
|
||||||
|
env: SWIGLANG=java
|
||||||
|
- compiler: clang
|
||||||
|
os: osx
|
||||||
|
env: SWIGLANG=lua
|
||||||
|
- compiler: clang
|
||||||
|
os: osx
|
||||||
|
env: SWIGLANG=perl5
|
||||||
|
- compiler: clang
|
||||||
|
os: osx
|
||||||
|
env: SWIGLANG=php5
|
||||||
|
- compiler: clang
|
||||||
|
os: osx
|
||||||
|
env: SWIGLANG=python
|
||||||
|
- compiler: clang
|
||||||
|
os: osx
|
||||||
|
env: SWIGLANG=python PY3=3
|
||||||
|
- compiler: clang
|
||||||
|
os: osx
|
||||||
|
env: SWIGLANG=ruby
|
||||||
|
- compiler: clang
|
||||||
|
os: osx
|
||||||
|
env: SWIGLANG=tcl
|
||||||
|
|
||||||
allow_failures:
|
allow_failures:
|
||||||
# Lots of failing tests currently
|
# Lots of failing tests currently
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
env: SWIGLANG=ocaml
|
env: SWIGLANG=ocaml
|
||||||
# Occasional gcc internal compiler error
|
sudo: required
|
||||||
- compiler: gcc
|
dist: trusty
|
||||||
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
|
|
||||||
- compiler: gcc
|
|
||||||
env: SWIGLANG=python SWIG_FEATURES=-classic
|
|
||||||
# Not quite working yet
|
# Not quite working yet
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
env: SWIGLANG=python SWIG_FEATURES=-O
|
env: SWIGLANG=python SWIG_FEATURES=-O
|
||||||
# Runtime errors in Travis environment
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
|
# php7.1 nearly working
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
env: SWIGLANG=r
|
os: linux
|
||||||
|
env: SWIGLANG=php VER=7.1
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
before_install:
|
before_install:
|
||||||
- date -u
|
- date -u
|
||||||
- uname -a
|
- uname -a
|
||||||
- lsb_release -a
|
- if test "$TRAVIS_OS_NAME" = "linux"; then lscpu && cat /proc/cpuinfo | grep "model name" && cat /proc/meminfo | grep MemTotal; fi
|
||||||
- sudo apt-get -qq update
|
- if test "$TRAVIS_OS_NAME" = "osx"; then sysctl -a | grep brand_string; fi
|
||||||
- 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
|
# Travis overrides CC environment with compiler predefined values
|
||||||
- if test -z "$GCC5"; then sudo apt-get -qq install libboost-dev; fi
|
- if test -n "$SWIG_CC"; then export CC="$SWIG_CC"; 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 -n "$SWIG_CXX"; then export CXX="$SWIG_CXX"; fi
|
||||||
- if test -z "$SWIGLANG"; then sudo apt-get -qq install yodl; fi
|
install:
|
||||||
- if test "$SWIGLANG" = "csharp"; then sudo apt-get -qq install mono-devel; fi
|
- if test "$TRAVIS_OS_NAME" = "linux"; then source Tools/travis-linux-install.sh; 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 "$TRAVIS_OS_NAME" = "osx"; then source Tools/travis-osx-install.sh; fi
|
||||||
- if test "$SWIGLANG" = "go"; then go env | sed -e 's/^/export /' > goenvsetup && source goenvsetup && rm -f goenvsetup; fi # Until configure.ac is fixed
|
|
||||||
- if test "$SWIGLANG" = "javascript" -a "$ENGINE" = "node"; then sudo apt-get install -qq rlwrap python-software-properties && echo 'yes' | sudo add-apt-repository ppa:chris-lea/node.js && sudo apt-get -qq update && sudo apt-get install -qq nodejs && sudo npm install -g node-gyp; fi
|
|
||||||
- if test "$SWIGLANG" = "javascript" -a "$ENGINE" = "jsc"; then sudo apt-get install -qq libwebkitgtk-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" = "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 "$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" = "python"; then git clone https://github.com/jcrocholl/pep8.git && pushd pep8 && git checkout tags/1.5.7 && python ./setup.py build && sudo python ./setup.py install && popd; fi
|
|
||||||
- if test "$SWIGLANG" = "python" -a "$PY3" -a -z "$VER"; then sudo apt-get install -qq python3-dev; fi
|
|
||||||
- if test "$SWIGLANG" = "python" -a "$VER"; then sudo add-apt-repository -y ppa:fkrull/deadsnakes && sudo apt-get -qq update && sudo apt-get -qq install python${VER}-dev && 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" = "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 "$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
|
- 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
|
||||||
|
- ls -la $(which $CC)
|
||||||
|
- ls -la $(which $CXX)
|
||||||
- $CC --version
|
- $CC --version
|
||||||
- $CXX --version
|
- $CXX --version
|
||||||
# Stricter compile flags for examples. Various headers and SWIG generated code prevents full use of -pedantic.
|
|
||||||
- if test -n "$SWIGLANG"; then export cflags=$(Tools/testflags.py --language $SWIGLANG --cflags --std=$CSTD) && echo $cflags; fi
|
|
||||||
- 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'
|
||||||
|
- if test -n "$SWIGLANG"; then CONFIGOPTS+=(--without-alllang --with-$WITHLANG); fi
|
||||||
- echo "${CONFIGOPTS[@]}"
|
- echo "${CONFIGOPTS[@]}"
|
||||||
- ./autogen.sh && mkdir -p build/build && cd build/build && ../../configure "${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'
|
||||||
|
|
@ -139,12 +322,13 @@ script:
|
||||||
- echo 'Installing...' && echo -en 'travis_fold:start:script.2\\r'
|
- echo 'Installing...' && echo -en 'travis_fold:start:script.2\\r'
|
||||||
- if test -z "$SWIGLANG"; then sudo make -s install && swig -version && ccache-swig -V; fi
|
- if test -z "$SWIGLANG"; then sudo make -s install && swig -version && ccache-swig -V; fi
|
||||||
- echo -en 'travis_fold:end:script.2\\r'
|
- echo -en 'travis_fold:end:script.2\\r'
|
||||||
|
# Stricter compile flags for examples. Various headers and SWIG generated code prevents full use of -pedantic.
|
||||||
|
- if test -n "$SWIGLANG"; then cflags=$($TRAVIS_BUILD_DIR/Tools/testflags.py --language $SWIGLANG --cflags --std=$CSTD --compiler=$CC) && echo $cflags; fi
|
||||||
|
- if test -n "$SWIGLANG"; then cxxflags=$($TRAVIS_BUILD_DIR/Tools/testflags.py --language $SWIGLANG --cxxflags --std=$CPPSTD --compiler=$CC) && echo $cxxflags; fi
|
||||||
- if test -n "$SWIGLANG"; then make -s check-$SWIGLANG-version; fi
|
- if test -n "$SWIGLANG"; then make -s check-$SWIGLANG-version; fi
|
||||||
|
- if test -n "$SWIGLANG"; then make check-$SWIGLANG-enabled; fi
|
||||||
- if test -n "$SWIGLANG"; then make $SWIGJOBS check-$SWIGLANG-examples CFLAGS="$cflags" CXXFLAGS="$cxxflags"; fi
|
- if test -n "$SWIGLANG"; then make $SWIGJOBS check-$SWIGLANG-examples CFLAGS="$cflags" CXXFLAGS="$cxxflags"; fi
|
||||||
- if test -n "$SWIGLANG"; then make $SWIGJOBS check-$SWIGLANG-test-suite CFLAGS="$cflags" CXXFLAGS="$cxxflags"; fi
|
- if test -n "$SWIGLANG"; then make $SWIGJOBS check-$SWIGLANG-test-suite CFLAGS="$cflags" CXXFLAGS="$cxxflags"; fi
|
||||||
- echo 'Cleaning...' && echo -en 'travis_fold:start:script.3\\r'
|
- echo 'Cleaning...' && echo -en 'travis_fold:start:script.3\\r'
|
||||||
- make check-maintainer-clean && ../../configure $CONFIGOPTS
|
- make check-maintainer-clean && ../../configure $CONFIGOPTS
|
||||||
- echo -en 'travis_fold:end:script.3\\r'
|
- echo -en 'travis_fold:end:script.3\\r'
|
||||||
branches:
|
|
||||||
only:
|
|
||||||
- master
|
|
||||||
|
|
|
||||||
13
ANNOUNCE
13
ANNOUNCE
|
|
@ -1,8 +1,8 @@
|
||||||
*** ANNOUNCE: SWIG 3.0.7 (in progress) ***
|
*** ANNOUNCE: SWIG 3.0.11 (in progress) ***
|
||||||
|
|
||||||
http://www.swig.org
|
http://www.swig.org
|
||||||
|
|
||||||
We're pleased to announce SWIG-3.0.7, the latest SWIG release.
|
We're pleased to announce SWIG-3.0.11, the latest SWIG release.
|
||||||
|
|
||||||
What is SWIG?
|
What is SWIG?
|
||||||
=============
|
=============
|
||||||
|
|
@ -18,15 +18,20 @@ include generation of scripting language extension modules, rapid
|
||||||
prototyping, testing, and user interface development for large
|
prototyping, testing, and user interface development for large
|
||||||
C/C++ systems.
|
C/C++ systems.
|
||||||
|
|
||||||
|
Release Notes
|
||||||
|
=============
|
||||||
|
Detailed release notes are available with the release and are also
|
||||||
|
published on the SWIG web site at http://swig.org/release.html.
|
||||||
|
|
||||||
Availability
|
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.7.tar.gz
|
http://prdownloads.sourceforge.net/swig/swig-3.0.11.tar.gz
|
||||||
|
|
||||||
A Windows version is also available at
|
A Windows version is also available at
|
||||||
|
|
||||||
http://prdownloads.sourceforge.net/swig/swigwin-3.0.7.zip
|
http://prdownloads.sourceforge.net/swig/swigwin-3.0.11.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.
|
||||||
|
|
|
||||||
|
|
@ -43,17 +43,21 @@ $(srcdir)/$(PACKAGE_NAME).1: $(srcdir)/ccache.yo
|
||||||
$(srcdir)/web/ccache-man.html: $(srcdir)/ccache.yo
|
$(srcdir)/web/ccache-man.html: $(srcdir)/ccache.yo
|
||||||
yodl2html -o $(srcdir)/web/ccache-man.html $(srcdir)/ccache.yo
|
yodl2html -o $(srcdir)/web/ccache-man.html $(srcdir)/ccache.yo
|
||||||
|
|
||||||
install: $(PACKAGE_NAME)$(EXEEXT) $(srcdir)/$(PACKAGE_NAME).1
|
install: $(PACKAGE_NAME)$(EXEEXT)
|
||||||
@echo "Installing $(PACKAGE_NAME)"
|
@echo "Installing $(PACKAGE_NAME)"
|
||||||
@echo "Installing $(DESTDIR)${bindir}/`echo $(PACKAGE_NAME) | sed '$(transform)'`$(EXEEXT)"
|
@echo "Installing $(DESTDIR)${bindir}/`echo $(PACKAGE_NAME) | sed '$(transform)'`$(EXEEXT)"
|
||||||
${INSTALLCMD} -d $(DESTDIR)${bindir}
|
${INSTALLCMD} -d $(DESTDIR)${bindir}
|
||||||
${INSTALLCMD} -m 755 $(PACKAGE_NAME)$(EXEEXT) $(DESTDIR)${bindir}/`echo $(PACKAGE_NAME) | sed '$(transform)'`$(EXEEXT)
|
${INSTALLCMD} -m 755 $(PACKAGE_NAME)$(EXEEXT) $(DESTDIR)${bindir}/`echo $(PACKAGE_NAME) | sed '$(transform)'`$(EXEEXT)
|
||||||
|
|
||||||
|
install-docs: $(srcdir)/$(PACKAGE_NAME).1
|
||||||
@echo "Installing $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1"
|
@echo "Installing $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1"
|
||||||
${INSTALLCMD} -d $(DESTDIR)${mandir}/man1
|
${INSTALLCMD} -d $(DESTDIR)${mandir}/man1
|
||||||
${INSTALLCMD} -m 644 $(srcdir)/$(PACKAGE_NAME).1 $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1
|
${INSTALLCMD} -m 644 $(srcdir)/$(PACKAGE_NAME).1 $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1
|
||||||
|
|
||||||
uninstall: $(PACKAGE_NAME)$(EXEEXT) $(srcdir)/$(PACKAGE_NAME).1
|
uninstall: $(PACKAGE_NAME)$(EXEEXT)
|
||||||
rm -f $(DESTDIR)${bindir}/`echo $(PACKAGE_NAME) | sed '$(transform)'`$(EXEEXT)
|
rm -f $(DESTDIR)${bindir}/`echo $(PACKAGE_NAME) | sed '$(transform)'`$(EXEEXT)
|
||||||
|
|
||||||
|
uninstall-docs: $(srcdir)/$(PACKAGE_NAME).1
|
||||||
rm -f $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1
|
rm -f $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|
|
||||||
|
|
@ -130,6 +130,7 @@ static void failed(void)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
args_add_prefix(orig_args, p);
|
args_add_prefix(orig_args, p);
|
||||||
|
free(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ccache_verbose) {
|
if (ccache_verbose) {
|
||||||
|
|
@ -490,7 +491,9 @@ static void find_hash(ARGS *args)
|
||||||
/* also include the hash of the compiler name - as some compilers
|
/* also include the hash of the compiler name - as some compilers
|
||||||
use hard links and behave differently depending on the real name */
|
use hard links and behave differently depending on the real name */
|
||||||
if (st.st_nlink > 1) {
|
if (st.st_nlink > 1) {
|
||||||
hash_string(str_basename(args->argv[0]));
|
char *path = str_basename(args->argv[0]);
|
||||||
|
hash_string(path);
|
||||||
|
free(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
hash_int(st.st_size);
|
hash_int(st.st_size);
|
||||||
|
|
@ -523,6 +526,7 @@ static void find_hash(ARGS *args)
|
||||||
input_base, tmp_string(),
|
input_base, tmp_string(),
|
||||||
i_extension);
|
i_extension);
|
||||||
x_asprintf(&path_stderr, "%s/tmp.cpp_stderr.%s", temp_dir, tmp_string());
|
x_asprintf(&path_stderr, "%s/tmp.cpp_stderr.%s", temp_dir, tmp_string());
|
||||||
|
free(input_base);
|
||||||
|
|
||||||
if (!direct_i_file) {
|
if (!direct_i_file) {
|
||||||
/* run cpp on the input file to obtain the .i */
|
/* run cpp on the input file to obtain the .i */
|
||||||
|
|
@ -781,6 +785,7 @@ static void find_compiler(int argc, char **argv)
|
||||||
|
|
||||||
/* support user override of the compiler */
|
/* support user override of the compiler */
|
||||||
if ((path=getenv("CCACHE_CC"))) {
|
if ((path=getenv("CCACHE_CC"))) {
|
||||||
|
free(base);
|
||||||
base = x_strdup(path);
|
base = x_strdup(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -791,8 +796,10 @@ static void find_compiler(int argc, char **argv)
|
||||||
stats_update(STATS_COMPILER);
|
stats_update(STATS_COMPILER);
|
||||||
cc_log("could not find compiler (%s)\n", base);
|
cc_log("could not find compiler (%s)\n", base);
|
||||||
perror(base);
|
perror(base);
|
||||||
|
free(base);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
free(base);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1076,6 +1083,7 @@ static void process_args(int argc, char **argv)
|
||||||
if (strlen(p) < 2) {
|
if (strlen(p) < 2) {
|
||||||
cc_log("badly formed dependency file %s\n", output_file);
|
cc_log("badly formed dependency file %s\n", output_file);
|
||||||
stats_update(STATS_ARGS);
|
stats_update(STATS_ARGS);
|
||||||
|
free(default_depfile_name);
|
||||||
failed();
|
failed();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -1093,6 +1101,7 @@ static void process_args(int argc, char **argv)
|
||||||
strcat(default_depfile_name, ".d");
|
strcat(default_depfile_name, ".d");
|
||||||
args_add(stripped_args, "-MF");
|
args_add(stripped_args, "-MF");
|
||||||
args_add(stripped_args, default_depfile_name);
|
args_add(stripped_args, default_depfile_name);
|
||||||
|
free(default_depfile_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dependency_target_specified) {
|
if (!dependency_target_specified) {
|
||||||
|
|
@ -1117,6 +1126,7 @@ static void process_args(int argc, char **argv)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
args_add_prefix(stripped_args, p);
|
args_add_prefix(stripped_args, p);
|
||||||
|
free(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1305,6 +1315,7 @@ static void setup_uncached_err(void)
|
||||||
|
|
||||||
if (putenv(buf) == -1) {
|
if (putenv(buf) == -1) {
|
||||||
cc_log("putenv failed\n");
|
cc_log("putenv failed\n");
|
||||||
|
close(uncached_fd);
|
||||||
stats_update(STATS_ERROR);
|
stats_update(STATS_ERROR);
|
||||||
failed();
|
failed();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,9 @@
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#else
|
#else
|
||||||
|
#ifndef _WIN32_WINNT
|
||||||
#define _WIN32_WINNT 0x0500
|
#define _WIN32_WINNT 0x0500
|
||||||
|
#endif
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -267,6 +267,7 @@ char *find_executable(const char *name, const char *exclude_name)
|
||||||
}
|
}
|
||||||
free(fname);
|
free(fname);
|
||||||
}
|
}
|
||||||
|
free(path);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,10 @@ static void stats_update_size(enum stats stat, size_t size, size_t numfiles)
|
||||||
|
|
||||||
memset(counters, 0, sizeof(counters));
|
memset(counters, 0, sizeof(counters));
|
||||||
|
|
||||||
if (lock_fd(fd) != 0) return;
|
if (lock_fd(fd) != 0) {
|
||||||
|
close(fd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* read in the old stats */
|
/* read in the old stats */
|
||||||
stats_read_fd(fd, counters);
|
stats_read_fd(fd, counters);
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,11 @@ else
|
||||||
SWIG=swig
|
SWIG=swig
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# fix: Remove ccache from $PATH if it exists
|
||||||
|
# as it will influence the unit tests
|
||||||
|
PATH="`echo $PATH | \
|
||||||
|
sed -e 's!:/usr\(/local\)*/lib\([0-9]\)*/ccache\(/\)*!!g'`"
|
||||||
|
|
||||||
CCACHE=../ccache-swig
|
CCACHE=../ccache-swig
|
||||||
TESTDIR=test.$$
|
TESTDIR=test.$$
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -281,6 +281,7 @@ int unify_hash(const char *fname)
|
||||||
fd = open(fname, O_RDONLY|O_BINARY);
|
fd = open(fname, O_RDONLY|O_BINARY);
|
||||||
if (fd == -1 || fstat(fd, &st) != 0) {
|
if (fd == -1 || fstat(fd, &st) != 0) {
|
||||||
cc_log("Failed to open preprocessor output %s\n", fname);
|
cc_log("Failed to open preprocessor output %s\n", fname);
|
||||||
|
if (fd != -1) close(fd);
|
||||||
stats_update(STATS_PREPROCESSOR);
|
stats_update(STATS_PREPROCESSOR);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -289,12 +290,12 @@ int unify_hash(const char *fname)
|
||||||
lines in preprocessor output. I have seen lines of over
|
lines in preprocessor output. I have seen lines of over
|
||||||
100k in length, so this is well worth it */
|
100k in length, so this is well worth it */
|
||||||
map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
|
map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||||
|
close(fd);
|
||||||
if (map == (char *)-1) {
|
if (map == (char *)-1) {
|
||||||
cc_log("Failed to mmap %s\n", fname);
|
cc_log("Failed to mmap %s\n", fname);
|
||||||
stats_update(STATS_PREPROCESSOR);
|
stats_update(STATS_PREPROCESSOR);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
close(fd);
|
|
||||||
|
|
||||||
/* pass it through the unifier */
|
/* pass it through the unifier */
|
||||||
unify((unsigned char *)map, st.st_size);
|
unify((unsigned char *)map, st.st_size);
|
||||||
|
|
|
||||||
|
|
@ -189,9 +189,11 @@ void copy_fd(int fd_in, int fd_out) {
|
||||||
|
|
||||||
while ((n = gzread(gz_in, buf, sizeof(buf))) > 0) {
|
while ((n = gzread(gz_in, buf, sizeof(buf))) > 0) {
|
||||||
if (write(fd_out, buf, n) != n) {
|
if (write(fd_out, buf, n) != n) {
|
||||||
|
gzclose(gz_in);
|
||||||
fatal("Failed to copy fd");
|
fatal("Failed to copy fd");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
gzclose(gz_in);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _copy_file(const char *src, const char *dest, int mode) {
|
static int _copy_file(const char *src, const char *dest, int mode) {
|
||||||
|
|
@ -248,9 +250,11 @@ static int _copy_file(const char *src, const char *dest, int mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode == COPY_TO_CACHE) {
|
if (mode == COPY_TO_CACHE) {
|
||||||
gz_out = gzdopen(dup(fd_out), "wb");
|
int dup_fd_out = dup(fd_out);
|
||||||
|
gz_out = gzdopen(dup_fd_out, "wb");
|
||||||
if (!gz_out) {
|
if (!gz_out) {
|
||||||
gzclose(gz_in);
|
gzclose(gz_in);
|
||||||
|
close(dup_fd_out);
|
||||||
close(fd_out);
|
close(fd_out);
|
||||||
free(tmp_name);
|
free(tmp_name);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -459,6 +463,7 @@ int create_cachedirtag(const char *dir)
|
||||||
f = fopen(filename, "w");
|
f = fopen(filename, "w");
|
||||||
if (!f) goto error;
|
if (!f) goto error;
|
||||||
if (fwrite(CACHEDIR_TAG, sizeof(CACHEDIR_TAG)-1, 1, f) != 1) {
|
if (fwrite(CACHEDIR_TAG, sizeof(CACHEDIR_TAG)-1, 1, f) != 1) {
|
||||||
|
fclose(f);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (fclose(f)) goto error;
|
if (fclose(f)) goto error;
|
||||||
|
|
@ -485,7 +490,7 @@ void x_asprintf(char **ptr, const char *format, ...)
|
||||||
}
|
}
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if (!ptr) fatal("out of memory in x_asprintf");
|
if (!*ptr) fatal("out of memory in x_asprintf");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
519
CHANGES
519
CHANGES
|
|
@ -3,6 +3,519 @@ 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.10 (12 Jun 2016)
|
||||||
|
============================
|
||||||
|
|
||||||
|
2016-06-06: mromberg
|
||||||
|
[Python] Patch #698. Add support for -relativeimport for python 2.7, so -py3 is no
|
||||||
|
longer also required for relative import support.
|
||||||
|
|
||||||
|
2016-06-05: mromberg
|
||||||
|
[Python] Patch #694 - Fix package import regressions introduced in swig-3.0.9.
|
||||||
|
|
||||||
|
1) The code in 3.0.9 did not fall back to 'import _foo' if 'import bar._foo' failed
|
||||||
|
(assuming bar.foo was the main module). Every place _foo is imported now first tries
|
||||||
|
it from the package where foo was found and if that fails tries _foo as a global module.
|
||||||
|
|
||||||
|
2) The separate block of Python code that injected code to pull in the attributes
|
||||||
|
from _foo when -builtin is used made use of the -py3 switch to either do
|
||||||
|
'from ._foo import *' or "from _foo import *". This block of code no longer does this
|
||||||
|
and instead checks the Python version at runtime to switch between the two syntaxes.
|
||||||
|
|
||||||
|
In summary, swig-3.0.10 has been modified to ease the creation of wrapper modules
|
||||||
|
that can be fully made part of a Python package. SWIG no longer
|
||||||
|
assumes the dynamically linked C module is a global module.
|
||||||
|
The dynamic module can now be placed into either the same package as the pure Python
|
||||||
|
module or as a global module. Both locations are used by the Python wrapper to
|
||||||
|
locate the C module.
|
||||||
|
|
||||||
|
However, this could cause a backwards incompatibility with some code
|
||||||
|
that was relying on the ability of "from package import _module" to
|
||||||
|
pull attributes out of the package directly. If your code populates a
|
||||||
|
module (which is also a package) with attributes that are SWIG
|
||||||
|
generated modules which were not loaded in a conventional way,
|
||||||
|
swig-3.0.8 and earlier may have worked due to 'from package import
|
||||||
|
_module' bypassing a real import and pulling your module in as an
|
||||||
|
attribute. This will no longer work. Since this is not a common (or
|
||||||
|
even recommended) practice, most folk should not be affected.
|
||||||
|
|
||||||
|
*** POTENTIAL INCOMPATIBILITY ***
|
||||||
|
|
||||||
|
2016-05-31: wsfulton
|
||||||
|
Fix #690 - Smart pointer to %ignored class doesn't expose inherited methods.
|
||||||
|
Regression introduced in swig-3.0.9.
|
||||||
|
|
||||||
|
Version 3.0.9 (29 May 2016)
|
||||||
|
===========================
|
||||||
|
|
||||||
|
2016-05-24: mromberg
|
||||||
|
[Python] Patch #612 - Add support for Python's implicit namespace packages.
|
||||||
|
|
||||||
|
2016-05-23: wsfulton
|
||||||
|
[Ruby] Fix #602 - Error handling regression of opaque pointers introduced
|
||||||
|
in swig-3.0.8 when C functions explicitly reset a pointer using 'DATA_PTR(self) = 0'.
|
||||||
|
An ObjectPreviouslyDeleted error was incorrectly thrown when the pointer was used
|
||||||
|
as a parameter.
|
||||||
|
|
||||||
|
2016-05-17: tamuratak
|
||||||
|
[Ruby] Patch #651 - Correct overloaded function error message when function is
|
||||||
|
using %newobject.
|
||||||
|
|
||||||
|
2016-05-17: aurelj
|
||||||
|
[Ruby] Patch #582 - add support for docstring option in %module()
|
||||||
|
|
||||||
|
2016-05-14: wsfulton
|
||||||
|
Fix #434 - Passing classes by value as parameters in director methods did not create
|
||||||
|
a copy of the argument leading to invalid memory accesses if the object was used
|
||||||
|
after the upcall into the target language. Passing arguments by value shouldn't give
|
||||||
|
rise to these sorts of memory problems and so the objects are now copied and ownership
|
||||||
|
of their lifetime is controlled by the target language.
|
||||||
|
|
||||||
|
2016-05-07: wsfulton
|
||||||
|
Fix #611. Fix assertion handling defaultargs when using %extend for a template
|
||||||
|
class and the extended methods contain default arguments.
|
||||||
|
|
||||||
|
2016-05-05: ejulian
|
||||||
|
[Python] Patch #617. Fix operator/ wrappers.
|
||||||
|
|
||||||
|
2016-05-02: wsfulton
|
||||||
|
Fix #669. Don't issue warning about ignoring base classes when the derived class is
|
||||||
|
itself ignored.
|
||||||
|
|
||||||
|
2016-04-18: ianlancetaylor
|
||||||
|
[Go] Fix use of goout typemap when calling base method by
|
||||||
|
forcing the "type" attribute to the value we need.
|
||||||
|
|
||||||
|
2016-04-17: ianlancetaylor
|
||||||
|
[Go] Fixes for Go 1.6: avoid returning Go pointers from
|
||||||
|
directors that return string values; add a trailing 0 byte
|
||||||
|
when treating Go string as C char*.
|
||||||
|
|
||||||
|
2016-04-06: smarchetto
|
||||||
|
[Scilab] #552 Make Scilab runtime keep track of pointer types
|
||||||
|
Instead of a Scilab pointer which has no type, SWIG Scilab maps a
|
||||||
|
pointer to a structure tlist containing the pointer adress and its type.
|
||||||
|
|
||||||
|
2016-04-02: ahnolds
|
||||||
|
[Python] Apply #598. Fix misleading error message when attempting to read a non-existent
|
||||||
|
attribute. The previous cryptic error message:
|
||||||
|
AttributeError: type object 'object' has no attribute '__getattr__'
|
||||||
|
is now replaced with one mentioning the attribute name, eg:
|
||||||
|
AttributeError: 'Foo' object has no attribute 'bar'
|
||||||
|
|
||||||
|
2016-04-02: derkuci
|
||||||
|
[Python] Patch #610 to fix #607.
|
||||||
|
Fix single arguments when using python -builtin -O with %feature("compactdefaultargs")
|
||||||
|
|
||||||
|
2016-03-31: wsfulton
|
||||||
|
Fixes #594. Fix assertion for some languages when wrapping a C++11 enum class that
|
||||||
|
is private in a class.
|
||||||
|
|
||||||
|
Also don't wrap private enums for a few languages that attempted to do so.
|
||||||
|
|
||||||
|
2016-03-31: wsfulton
|
||||||
|
[Java] unsigned long long marshalling improvements when a negative number
|
||||||
|
is passed from Java to C. A cast to signed long long in the C layer will now
|
||||||
|
result in the expected value. No change for positive numbers passed to C.
|
||||||
|
Fixes #623.
|
||||||
|
|
||||||
|
2016-03-22: alexwarg
|
||||||
|
[Lua] #398 Fix lua __getitem + inheritance
|
||||||
|
The new handling of classes in Lua (not merging methods into the derived classes)
|
||||||
|
breaks for classes that provide a __getitem function. The __getitem function
|
||||||
|
prevents method calls to any method defined in a base class. This fix calls
|
||||||
|
__getitem only if the member is not found using recursive lookup.
|
||||||
|
|
||||||
|
2016-03-18: ptomulik
|
||||||
|
[Python] #563 Stop generating unnecessary _swigconstant helpers.
|
||||||
|
|
||||||
|
2016-03-16: richardbeare
|
||||||
|
[R] #636 Add extra std::vector numeric types
|
||||||
|
|
||||||
|
2016-03-14: wsfulton
|
||||||
|
[Java] Add std_array.i for C++11 std::array support.
|
||||||
|
|
||||||
|
2016-03-12: wsfulton
|
||||||
|
[Java, C#, D] Fix static const char member variables wrappers with %javaconst(1)
|
||||||
|
%csconst(1) or %dmanifestconst.
|
||||||
|
This fixes the case when an integer is used as the initializer, such as:
|
||||||
|
|
||||||
|
struct W { static const char w = 100; };
|
||||||
|
|
||||||
|
Fix generated code parsing enum values using char escape sequences
|
||||||
|
when these values appear in the Java code (usually when using %javaconst(1))
|
||||||
|
such as:
|
||||||
|
|
||||||
|
enum X { x1 = '\n', x2 = '\1' };
|
||||||
|
|
||||||
|
Similarly for static const member char variables such as:
|
||||||
|
|
||||||
|
struct Y { static const char y = '\n'; }
|
||||||
|
|
||||||
|
Likewise for D and %dmanifestconstant. For C# and %csconst(1), char
|
||||||
|
values in C# are now hex escaped as C# doesn't support C octal escaping.
|
||||||
|
|
||||||
|
2016-03-11: wsfulton
|
||||||
|
[Java C#] Add support for treating C++ base classes as Java interfaces
|
||||||
|
instead of Java proxy classes. This enable some sort of support for
|
||||||
|
multiple inheritance. The implementation is in swiginterface.i and
|
||||||
|
provides additional macros (see Java.html for full documentation):
|
||||||
|
|
||||||
|
%interface(CTYPE)
|
||||||
|
%interface_impl(CTYPE)
|
||||||
|
%interface_custom("PROXY", "INTERFACE", CTYPE)
|
||||||
|
|
||||||
|
2016-03-01: wsfulton
|
||||||
|
Add rstrip encoder for use in %rename. This is like the strip encoder but
|
||||||
|
strips the symbol's suffix instead of the prefix. The example below
|
||||||
|
will rename SomeThingCls to SomeThing and AnotherThingCls to AnotherThing:
|
||||||
|
|
||||||
|
%rename("%(rstrip:[Cls])s") "";
|
||||||
|
|
||||||
|
class SomeThingCls {};
|
||||||
|
struct AnotherThingCls {};
|
||||||
|
|
||||||
|
2016-03-01: olly
|
||||||
|
Fix isfinite() check to work with GCC6. Fixes
|
||||||
|
https://github.com/swig/swig/issues/615 reported by jplesnik.
|
||||||
|
|
||||||
|
2016-02-17: olly
|
||||||
|
[Python] Add missing keywords 'as' and 'with' to pythonkw.swg.
|
||||||
|
|
||||||
|
2016-02-07: kwwette
|
||||||
|
[Octave] recognise various unary functions
|
||||||
|
* Use __float__() for numeric conversions, e.g. when calling double()
|
||||||
|
* Map various unary functions, e.g. abs() to __abs__(), see full list
|
||||||
|
in section 32.3.10 of manual; only available in Octave 3.8.0 or later
|
||||||
|
|
||||||
|
2016-02-07: kwwette
|
||||||
|
[Octave] export function swig_octave_prereq() for testing Octave version
|
||||||
|
|
||||||
|
2016-02-06: pjohangustavsson
|
||||||
|
[C#] Fix duplicate symbol problems when linking the source generated
|
||||||
|
from multiple SWIG modules into one shared library for the -namespace
|
||||||
|
option. The namespace is now mangled into the global PInvoke function
|
||||||
|
names.
|
||||||
|
|
||||||
|
*** POTENTIAL INCOMPATIBILITY ***
|
||||||
|
|
||||||
|
2016-01-27: ahnolds
|
||||||
|
[Python] Added support for differentiating between Python Bytes
|
||||||
|
and Unicode objects using by defining SWIG_PYTHON_STRICT_BYTE_CHAR
|
||||||
|
and SWIG_PYTHON_STRICT_UNICODE_WCHAR.
|
||||||
|
|
||||||
|
2016-01-27: steeve
|
||||||
|
[Go] Ensure structs are properly packed between gc and GCC/clang.
|
||||||
|
|
||||||
|
2016-01-25: ahnolds
|
||||||
|
[Python] Support the full Python test suite in -classic mode
|
||||||
|
* Convert long/unsigned long/long long/unsigned long long to PyInt
|
||||||
|
rather than PyLong when possible. Certain python functions like
|
||||||
|
len() require a PyInt when operating on old-style classes.
|
||||||
|
* Add support for static methods in classic mode, including support
|
||||||
|
for pythonappend, pythonprepend, and docstrings.
|
||||||
|
* Removing the use of __swig_getmethods__ for static member methods
|
||||||
|
since they will always be found by the standard argument lookup
|
||||||
|
* Fix a bug where the wrong type of exception was caught when
|
||||||
|
checking for new-style class support
|
||||||
|
|
||||||
|
2016-01-23: ahnolds
|
||||||
|
[Go] Enable support for the Go test-suite on OSX:
|
||||||
|
* The linker on OSX requires that all symbols (even weak symbols)
|
||||||
|
are defined at link time. Because the function _cgo_topofstack is
|
||||||
|
only defined starting in Go version 1.4, we explicitly mark it as
|
||||||
|
undefined for older versions of Go on OSX.
|
||||||
|
* Avoid writing empty swigargs structs, since empty structs are not
|
||||||
|
allowed in extern "C" blocks.
|
||||||
|
|
||||||
|
2016-01-12: olly
|
||||||
|
[Javascript] Look for "nodejs" as well as "node", as it's packaged
|
||||||
|
as the former on Debian.
|
||||||
|
|
||||||
|
2016-01-12: olly
|
||||||
|
[Javascript] For v8 >= 4.3.0, use V8_MAJOR_VERSION.
|
||||||
|
Fixes https://github.com/swig/swig/issues/561.
|
||||||
|
|
||||||
|
2016-01-10: ahnolds
|
||||||
|
Improved size_t and ptrdiff_t typemaps to support large values
|
||||||
|
on platforms where sizeof(size_t) > sizeof(unsigned long) and
|
||||||
|
sizeof(ptrdiff_t) > sizeof(long).
|
||||||
|
|
||||||
|
Version 3.0.8 (31 Dec 2015)
|
||||||
|
===========================
|
||||||
|
|
||||||
|
2015-12-30: wsfulton
|
||||||
|
The pdf documentation is now generated by wkhtmltopdf and has colour
|
||||||
|
for the code snippets just like the html documentation!
|
||||||
|
|
||||||
|
2015-12-23: ahnolds
|
||||||
|
[Python] Fixes for conversion of signed and unsigned integer types:
|
||||||
|
|
||||||
|
No longer check for PyInt objects in Python3. Because PyInt_Check
|
||||||
|
and friends are #defined to the corresponding PyLong methods, this
|
||||||
|
had caused errors in Python3 where values greater than what could be
|
||||||
|
stored in a long were incorrectly interpreted as the value -1 with
|
||||||
|
the Python error indicator set to OverflowError. This applies to
|
||||||
|
both the conversions PyLong->long and PyLong->double.
|
||||||
|
|
||||||
|
Conversion from PyLong to long, unsigned long, long long, and
|
||||||
|
unsigned long long now raise OverflowError instead of TypeError in
|
||||||
|
both Python2 and Python3 for PyLong values outside the range
|
||||||
|
expressible by the corresponding C type. This matches the existing
|
||||||
|
behavior for other integral types (signed and unsigned ints, shorts,
|
||||||
|
and chars), as well as the conversion for PyInt to all numeric
|
||||||
|
types. This also indirectly applies to the size_t and ptrdiff_t
|
||||||
|
types, which depend on the conversions for unsigned long and long.
|
||||||
|
|
||||||
|
2015-12-19: wsfulton
|
||||||
|
[Python] Python 2 Unicode UTF-8 strings can be used as inputs to char * or
|
||||||
|
std::string types if the generated C/C++ code has SWIG_PYTHON_2_UNICODE defined.
|
||||||
|
|
||||||
|
2015-12-17: wsfulton
|
||||||
|
Issues #286, #128
|
||||||
|
Remove ccache-swig.1 man page - please use the CCache.html docs instead.
|
||||||
|
The yodl2man and yodl2html tools are no longer used and so SWIG no
|
||||||
|
longer has a dependency on these packages which were required when
|
||||||
|
building from git.
|
||||||
|
|
||||||
|
2015-12-16: zturner/coleb
|
||||||
|
[Python] Fix Python3.5 interpreter assertions when objects are being
|
||||||
|
deleted due to an existing exception. Most notably in generators
|
||||||
|
which terminate using a StopIteration exception. Fixes #559 #560 #573.
|
||||||
|
If a further exception is raised during an object destruction,
|
||||||
|
PyErr_WriteUnraisable is used on this second exception and the
|
||||||
|
original exception bubbles through.
|
||||||
|
|
||||||
|
2015-12-14: ahnolds/wsfulton
|
||||||
|
[Python] Add in missing initializers for tp_finalize,
|
||||||
|
nb_matrix_multiply, nb_inplace_matrix_multiply, ht_qualname
|
||||||
|
ht_cached_keys and tp_prev.
|
||||||
|
|
||||||
|
2015-12-12: wsfulton
|
||||||
|
Fix STL wrappers to not generate <: digraphs.
|
||||||
|
For example std::vector<::X::Y> was sometimes generated, now
|
||||||
|
corrected to std::vector< ::X::Y >.
|
||||||
|
|
||||||
|
2015-11-25: wsfulton
|
||||||
|
[Ruby] STL ranges and slices fixes.
|
||||||
|
|
||||||
|
Ruby STL container setting slices fixes:
|
||||||
|
|
||||||
|
Setting an STL container wrapper slice better matches the way Ruby
|
||||||
|
arrays work. The behaviour is now the same as Ruby arrays. The only
|
||||||
|
exception is the default value used when expanding a container
|
||||||
|
cannot be nil as this is not a valid type/value for C++ container
|
||||||
|
elements.
|
||||||
|
|
||||||
|
Obtaining a Ruby STL container ranges and slices fixes:
|
||||||
|
|
||||||
|
Access via ranges and slices now behave identically to Ruby arrays.
|
||||||
|
The fixes are mostly for out of range indices and lengths.
|
||||||
|
- Zero length slice requests return an empty container instead of nil.
|
||||||
|
- Slices which request a length greater than the size of the container
|
||||||
|
no longer chop off the last element.
|
||||||
|
- Ranges which used to return nil now return an empty array when the
|
||||||
|
the start element is a valid index.
|
||||||
|
|
||||||
|
Ruby STL container negative indexing support improved.
|
||||||
|
|
||||||
|
Using negative indexes to set values works the same as Ruby arrays, eg
|
||||||
|
|
||||||
|
%template(IntVector) std::vector<int>;
|
||||||
|
|
||||||
|
iv = IntVector.new([1,2,3,4])
|
||||||
|
iv[-4] = 9 # => [1,2,3,9]
|
||||||
|
iv[-5] = 9 # => IndexError
|
||||||
|
|
||||||
|
2015-11-21: wsfulton
|
||||||
|
[Ruby, Python] Add std::array container wrappers.
|
||||||
|
|
||||||
|
These work much like any of the other STL containers except Python/Ruby slicing
|
||||||
|
is somewhat limited because the array is a fixed size. Only slices of
|
||||||
|
the full size are supported.
|
||||||
|
|
||||||
|
2015-10-10: wsfulton
|
||||||
|
[Python] #539 - Support Python 3.5 and -builtin. PyAsyncMethods is a new
|
||||||
|
member in PyHeapTypeObject.
|
||||||
|
|
||||||
|
2015-10-06: ianlancetaylor
|
||||||
|
[Go] Don't emit a constructor function for a director
|
||||||
|
class with an abstract method, since the function will
|
||||||
|
always panic.
|
||||||
|
|
||||||
|
2015-10-01: wsfulton
|
||||||
|
Fix %shared_ptr support for private and protected inheritance.
|
||||||
|
- Remove unnecessary Warning 520: Derived class 'Derived' of 'Base'
|
||||||
|
is not similarly marked as a smart pointer
|
||||||
|
- Do not generate code that attempts to cast up the inheritance chain in the
|
||||||
|
type system runtime in such cases as it doesn't compile and can't be used.
|
||||||
|
Remove unnecessary warning 520 for %shared_ptr when the base class is ignored.
|
||||||
|
|
||||||
|
2015-10-01: vkalinin
|
||||||
|
Fix #508: Fix segfault parsing anonymous typedef nested classes.
|
||||||
|
|
||||||
|
2015-09-26: wsfulton
|
||||||
|
[Ruby] Add shared_ptr support
|
||||||
|
|
||||||
|
2015-09-13: kkaempf
|
||||||
|
[Ruby] Resolve tracking bug - issue #225.
|
||||||
|
The bug is that the tracking code uses a ruby hash and thus may
|
||||||
|
allocate objects (Bignum) while running the GC. This was tolerated in
|
||||||
|
1.8 but is invalid (raises an exception) in 1.9.
|
||||||
|
The patch uses a C hash (also used by ruby) instead.
|
||||||
|
|
||||||
|
2015-09-09: lyze
|
||||||
|
[CFFI] Extend the "export" feature in the CFFI module to support
|
||||||
|
exporting to a specified package.
|
||||||
|
|
||||||
|
2015-09-04: olly
|
||||||
|
[Python] Fix docstrings for %callback functions.
|
||||||
|
|
||||||
|
2015-09-03: demi-rluddy
|
||||||
|
[Go] Removed golang stringing for signed/unsigned char
|
||||||
|
|
||||||
|
Changed default handling of signed char* and unsigned char* to be
|
||||||
|
opaque pointers rather than strings, similarly to how other
|
||||||
|
languages work.
|
||||||
|
|
||||||
|
Any existing code relying on treating signed char* or unsigned
|
||||||
|
char* as a string can restore the old behavior with typemaps.i by
|
||||||
|
using %apply to copy the [unchanged] char* behavior.
|
||||||
|
|
||||||
|
*** POTENTIAL INCOMPATIBILITY ***
|
||||||
|
|
||||||
|
2015-08-07: talby
|
||||||
|
[Perl] tidy -Wtautological-constant-out-of-range-compare warnings when building generated code under clang
|
||||||
|
|
||||||
|
2015-08-07: xantares
|
||||||
|
[Python] pep257 & numpydoc conforming docstrings:
|
||||||
|
- Mono-line module docsstring
|
||||||
|
- Rewrite autodoc parameters section in numpydoc style:
|
||||||
|
https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt
|
||||||
|
- One line summary should end with "."
|
||||||
|
- Adds a blank line after class docstring
|
||||||
|
|
||||||
|
2015-08-05: vadz
|
||||||
|
[Java] Make (char* STRING, size_t LENGTH) typemaps usable for
|
||||||
|
strings of other types, e.g. "unsigned char*".
|
||||||
|
|
||||||
|
Version 3.0.7 (3 Aug 2015)
|
||||||
|
==========================
|
||||||
|
|
||||||
|
2015-08-02: wsfulton
|
||||||
|
[Java] Fix potential security exploit in generated Java classes.
|
||||||
|
The swigCPtr and swigCMemOwn member variables in the generated Java
|
||||||
|
classes are now declared 'transient' by default. Further details of the exploit
|
||||||
|
in Android is being published in an academic paper as part of USENIX WOOT '15:
|
||||||
|
https://www.usenix.org/conference/woot15/workshop-program/presentation/peles.
|
||||||
|
|
||||||
|
In the unlikely event that you are relying on these members being serializable,
|
||||||
|
then you will need to override the default javabody and javabody_derived typemaps
|
||||||
|
to generate the old generated code. The relevant typemaps are in the Lib directory
|
||||||
|
in the java.swg, boost_shared_ptr.i and boost_intrusive_ptr.i files. Copy the
|
||||||
|
relevant default typemaps into your interface file and remove the 'transient' keyword.
|
||||||
|
|
||||||
|
*** POTENTIAL INCOMPATIBILITY ***
|
||||||
|
|
||||||
|
2015-08-01: vadz
|
||||||
|
Make configure --without-alllang option more useful: it can now be overridden by the following
|
||||||
|
--with-xxx options, allowing to easily enable just one or two languages.
|
||||||
|
|
||||||
|
2015-07-30: wsfulton
|
||||||
|
Fix #440 - Initialise all newly created arrays when using %array_functions and %array_class
|
||||||
|
in the carrays.i library - bug is only relevant when using C++.
|
||||||
|
|
||||||
|
2015-07-29: wsfulton
|
||||||
|
[Python] Improve indentation warning and error messages for code in the following directives:
|
||||||
|
|
||||||
|
%pythonprepend
|
||||||
|
%pythonappend
|
||||||
|
%pythoncode
|
||||||
|
%pythonbegin
|
||||||
|
%feature("shadow")
|
||||||
|
|
||||||
|
Old error example:
|
||||||
|
Error: Line indented less than expected (line 3 of pythoncode)
|
||||||
|
|
||||||
|
New error example:
|
||||||
|
Error: Line indented less than expected (line 3 of %pythoncode or %insert("python") block)
|
||||||
|
as no line should be indented less than the indentation in line 1
|
||||||
|
|
||||||
|
Old warning example:
|
||||||
|
Warning 740: Whitespace prefix doesn't match (line 2 of %pythoncode or %insert("python") block)
|
||||||
|
|
||||||
|
New warning example:
|
||||||
|
Warning 740: Whitespace indentation is inconsistent compared to earlier lines (line 3 of
|
||||||
|
%pythoncode or %insert("python") block)
|
||||||
|
|
||||||
|
|
||||||
|
2015-07-28: wsfulton
|
||||||
|
[Python] Fix #475. Improve docstring indentation handling.
|
||||||
|
|
||||||
|
SWIG-3.0.5 and earlier sometimes truncated text provided in the docstring feature.
|
||||||
|
This occurred when the indentation (whitespace) in the docstring was less in the
|
||||||
|
second or later lines when compared to the first line.
|
||||||
|
SWIG-3.0.6 gave a 'Line indented less than expected' error instead of truncating
|
||||||
|
the docstring text.
|
||||||
|
Now the indentation for the 'docstring' feature is smarter and is appropriately
|
||||||
|
adjusted so that no truncation occurs.
|
||||||
|
|
||||||
|
2015-07-22: wsfulton
|
||||||
|
Support for special variable expansion in typemap attributes. Example usage expansion
|
||||||
|
in the 'out' attribute (C# specific):
|
||||||
|
|
||||||
|
%typemap(ctype, out="$*1_ltype") unsigned int& "$*1_ltype"
|
||||||
|
|
||||||
|
is equivalent to the following as $*1_ltype expands to 'unsigned int':
|
||||||
|
|
||||||
|
%typemap(ctype, out="unsigned int") unsigned int& "unsigned int"
|
||||||
|
|
||||||
|
Special variables can be used within special variable macros too. Example usage expansion:
|
||||||
|
|
||||||
|
%typemap(cstype) unsigned int "uint"
|
||||||
|
%typemap(cstype, out="$typemap(cstype, $*1_ltype)") unsigned int& "$typemap(cstype, $*1_ltype)"
|
||||||
|
|
||||||
|
Special variables are expanded first and hence the above is equivalent to:
|
||||||
|
|
||||||
|
%typemap(cstype, out="$typemap(cstype, unsigned int)") unsigned int& "$typemap(cstype, unsigned int)"
|
||||||
|
|
||||||
|
which then expands to:
|
||||||
|
|
||||||
|
%typemap(cstype, out="uint") unsigned int& "uint"
|
||||||
|
|
||||||
|
2015-07-22: lindleyf
|
||||||
|
Apply patch #439 - support for $typemap() (aka embedded typemaps or special variable
|
||||||
|
macros) in typemap attributes. A simple example where $typemap() is expanded in the
|
||||||
|
'out' attribute (C# specific):
|
||||||
|
|
||||||
|
%typemap(cstype) unsigned int "uint"
|
||||||
|
%typemap(cstype, out="$typemap(cstype, unsigned int)") unsigned int& "$typemap(cstype, unsigned int)"
|
||||||
|
|
||||||
|
is equivalent to:
|
||||||
|
|
||||||
|
%typemap(cstype, out="uint") unsigned int& "uint"
|
||||||
|
|
||||||
|
2015-07-18: m7thon
|
||||||
|
[Python] Docstrings provided via %feature("docstring") are now quoted and added to
|
||||||
|
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-07-17: kwwette
|
||||||
|
[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 {};
|
||||||
|
|
||||||
Version 3.0.6 (5 Jul 2015)
|
Version 3.0.6 (5 Jul 2015)
|
||||||
==========================
|
==========================
|
||||||
|
|
||||||
|
|
@ -312,7 +825,7 @@ Version 3.0.3 (30 Dec 2014)
|
||||||
2014-10-21: wsfulton
|
2014-10-21: wsfulton
|
||||||
Fix issue #242 - Use of the "kwargs" feature no longer automatically turns on the
|
Fix issue #242 - Use of the "kwargs" feature no longer automatically turns on the
|
||||||
"compactdefaultargs" feature if the target language does not support kwargs.
|
"compactdefaultargs" feature if the target language does not support kwargs.
|
||||||
Only Java and Python support kwargs, so this affects all the other languages.
|
This change affects all languages except Python and Ruby.
|
||||||
|
|
||||||
*** POTENTIAL INCOMPATIBILITY ***
|
*** POTENTIAL INCOMPATIBILITY ***
|
||||||
|
|
||||||
|
|
@ -7578,7 +8091,7 @@ Version 1.3.28 (February 12, 2006)
|
||||||
|
|
||||||
12/10/2005: mmatus
|
12/10/2005: mmatus
|
||||||
[UTF]
|
[UTF]
|
||||||
- Fix unneccessary calls to SWIG_TypeQuery for 'char *'
|
- Fix unnecessary calls to SWIG_TypeQuery for 'char *'
|
||||||
and 'wchar_t *', problem found by Clay Culver while
|
and 'wchar_t *', problem found by Clay Culver while
|
||||||
profiling the PyOgre project.
|
profiling the PyOgre project.
|
||||||
|
|
||||||
|
|
@ -23301,7 +23814,7 @@ Version 1.1b5 (March 12, 1997)
|
||||||
2/23/97 : Modified Python module to be better behaved under Windows
|
2/23/97 : Modified Python module to be better behaved under Windows
|
||||||
|
|
||||||
- Module initialization function is now properly exported.
|
- Module initialization function is now properly exported.
|
||||||
It should not be neccessary to explicitly export this function
|
It should not be necessary to explicitly export this function
|
||||||
yourself.
|
yourself.
|
||||||
|
|
||||||
- Bizarre compilation problems when compiling the SWIG wrapper
|
- Bizarre compilation problems when compiling the SWIG wrapper
|
||||||
|
|
|
||||||
255
CHANGES.current
255
CHANGES.current
|
|
@ -2,27 +2,246 @@ 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.7 (in progress)
|
Version 3.0.11 (in progress)
|
||||||
===========================
|
============================
|
||||||
|
|
||||||
2015-07-18: m7thon
|
2016-12-01: wsfulton
|
||||||
[Python] Docstrings provided via %feature("docstring") are now quoted and added to
|
[Python] Issue https://github.com/swig/swig/issues/769
|
||||||
the tp_doc slot when using python builtin classes (-builtin). When no docstring is
|
Add optional moduleimport attribute to %module so that the
|
||||||
provided, the tp_doc slot is set to the fully qualified C/C++ class name.
|
default module import code can be overridden. See the "Searching for the wrapper module"
|
||||||
Github issues #445 and #461.
|
documentation in Python.html. Example:
|
||||||
|
|
||||||
2015-07-17: kwwette
|
%module(moduleimport="import _foo") foo
|
||||||
[octave] Support Octave version 4.0.0 (thanks to patches from Orion Poplawski).
|
|
||||||
|
|
||||||
2015-07-07: wsfulton
|
$module also expands to the low-level C/C++ module name, so the following is the
|
||||||
SWIG no longer generates a wrapper for a class' constructor if that class has
|
same as above
|
||||||
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;
|
%module(moduleimport="import $module") foo
|
||||||
class Base {
|
|
||||||
~Base() {}
|
2016-11-30: olly
|
||||||
|
[PHP] Add support for PHP7. PHP5's C extension API has changed substantially
|
||||||
|
so you need to use -php7 to specify you want PHP7 compatible wrappers. The
|
||||||
|
default extension for generated wrappers is now .cxx (to match SWIG's default
|
||||||
|
for every other language - to generate foo_wrap.cpp you can run SWIG with
|
||||||
|
-cppext cpp). Fixes https://github.com/swig/swig/issues/571
|
||||||
|
|
||||||
|
2016-11-30: olly
|
||||||
|
[PHP] Only emit one copy of each distinct arginfo. Previously we
|
||||||
|
emitted a separate one for every wrapped function, but typically
|
||||||
|
many functions have the same number of parameters and combinations
|
||||||
|
of parameters passed by reference or not.
|
||||||
|
|
||||||
|
This change significantly reduces both the size of the generated
|
||||||
|
wrapper, and of the compiled PHP extension module (e.g. by ~6% for
|
||||||
|
the stripped extension module for Xapian's PHP7 bindings).
|
||||||
|
|
||||||
|
2016-11-28: wsfulton
|
||||||
|
Fix %rename override of wildcard %rename for templates. For example:
|
||||||
|
|
||||||
|
%rename(GlobalIntOperator) *::operator bool; // wildcard %rename
|
||||||
|
|
||||||
|
%rename(XIntOperator) X::operator bool; // fix now overrides first %rename above
|
||||||
|
OR
|
||||||
|
%rename(XIntOperator) X<int>::operator bool; // fix now overrides first %rename above
|
||||||
|
|
||||||
|
template<typename T> struct X {
|
||||||
|
operator bool();
|
||||||
|
...
|
||||||
};
|
};
|
||||||
struct Derived : Base {};
|
%template(Xint) X<int>;
|
||||||
|
|
||||||
|
2016-11-26: m7thon
|
||||||
|
[Python] Issue #709 - improved wrapping of division operators
|
||||||
|
'from __future__ import division' now works in Python 2 whether or not the
|
||||||
|
-py3 flag is used.
|
||||||
|
|
||||||
|
2016-11-12: joequant
|
||||||
|
[R] Issue #697 - fix comma issue with overload methods
|
||||||
|
|
||||||
|
2016-11-12: joequant
|
||||||
|
[R] Issue #555 - R runtime needs stdio.h
|
||||||
|
|
||||||
|
2016-11-02: wsfulton
|
||||||
|
[Python] Issue #816 - fix compilation error when using -extranative and -builtin.
|
||||||
|
|
||||||
|
2016-11-02: liorgold
|
||||||
|
Patch #741 - Add support for C++11 alias templates, see updated CPlusPlus11.html
|
||||||
|
documentation.
|
||||||
|
|
||||||
|
2016-10-30: myd7349
|
||||||
|
[C#] Patch #740 Add std_array.i for C# for wrapping std::array.
|
||||||
|
|
||||||
|
Patch also enhances std::vector<std::wstring> C# wrappers with additional functions
|
||||||
|
(Contains, IndexOf, LastIndexOf and Remove).
|
||||||
|
|
||||||
|
2016-10-30: tobilau
|
||||||
|
[Java] Fix wrappers for wstring parameters in director methods to cleanup local
|
||||||
|
ref after director callback has finished.
|
||||||
|
|
||||||
|
2016-10-23: wsfulton
|
||||||
|
[C#] Add missing csdirectorin VOID_INT_PTR and csdirectorout VOID_INT_PTR typemaps.
|
||||||
|
|
||||||
|
2016-10-23: jiulongw
|
||||||
|
Patch #781 - Fix wrapping of C compound expressions containing char constants
|
||||||
|
in quotes such as:
|
||||||
|
|
||||||
|
#define H_SUPPRESS_SCALING_MAGIC (('s'<<24) | ('u'<<16) | ('p'<<8) | 'p')
|
||||||
|
|
||||||
|
enum DifferentTypes {
|
||||||
|
typecharcompound='A'+1,
|
||||||
|
typecharcompound2='B' << 2
|
||||||
|
};
|
||||||
|
|
||||||
|
2016-10-13: wsfulton
|
||||||
|
[Python] Issue #808 - fix Python pickling and metaclass for builtin wrappers.
|
||||||
|
|
||||||
|
The metaclass (SwigPyObjectType) for SWIG objects was not defined in
|
||||||
|
a way that let importlib successfully import the Python wrappers.
|
||||||
|
The pickle module previously failed to pickle objects because it couldn't
|
||||||
|
determine what module the SWIG wrapped objects were in.
|
||||||
|
|
||||||
|
2016-09-29: wsfulton
|
||||||
|
[Allegrocl, CFFI, GO, Javascript, Ocaml, R, Scilab]
|
||||||
|
Add missing support for the "ret" typemap in a few target languages.
|
||||||
|
The documentation also now has info on the "ret" typemap.
|
||||||
|
|
||||||
|
2016-09-27: ahmed-usman
|
||||||
|
[xml] Handle template parameters correctly.
|
||||||
|
|
||||||
|
2016-09-27: dontpanic92
|
||||||
|
[Go] Fix argument names in inherited functions taking more than 8
|
||||||
|
parameters. Fixes #795.
|
||||||
|
|
||||||
|
2016-09-26: smarchetto
|
||||||
|
[Scilab] mlists that map pointers can be given a custom type name.
|
||||||
|
|
||||||
|
2016-09-25: wsfulton
|
||||||
|
Patch #793 from q-p to expand exception handling to include std::bad_cast
|
||||||
|
in std_except.i.
|
||||||
|
|
||||||
|
2016-09-24: olly
|
||||||
|
[PHP] Fix code generated for feature("director:except") -
|
||||||
|
previously the return value of call_user_function() was ignored and
|
||||||
|
we checked an uninitialised value instead. Fixes #627. Based on
|
||||||
|
patch from Sergey Seroshtan.
|
||||||
|
|
||||||
|
2016-09-22: wsfulton
|
||||||
|
[Python] More flexible python builtin slots for overloaded C++ function.
|
||||||
|
|
||||||
|
The closure names used for builtin slots are mangled with their functype so
|
||||||
|
that overloaded C++ method names can be used for multiple slots.
|
||||||
|
For example:
|
||||||
|
|
||||||
|
%feature("python:slot", "mp_subscript", functype="binaryfunc") SimpleArray::__getitem__;
|
||||||
|
%feature("python:slot", "sq_item", functype="ssizeargfunc") SimpleArray::__getitem__(Py_ssize_t n);
|
||||||
|
|
||||||
|
will generate closures:
|
||||||
|
|
||||||
|
SWIGPY_SSIZEARGFUNC_CLOSURE(_wrap_SimpleArray___getitem__) /* defines _wrap_SimpleArray___getitem___ssizeargfunc_closure */
|
||||||
|
SWIGPY_BINARYFUNC_CLOSURE(_wrap_SimpleArray___getitem__) /* defines _wrap_SimpleArray___getitem___binaryfunc_closure */
|
||||||
|
|
||||||
|
Previously only one name was defined: _wrap_SimpleArray___getitem___closure.
|
||||||
|
Hence the overloaded __getitem__ method can be used to support both mp_subscript and sq_item slots.
|
||||||
|
|
||||||
|
2016-09-17: wsfulton
|
||||||
|
[Python] Fix iterators for containers of NULL pointers (or Python None) when using
|
||||||
|
-builtin. Previously iteration would stop at the first element that was NULL.
|
||||||
|
|
||||||
|
2016-09-16: olly
|
||||||
|
[Javascript] Fix SWIG_exception() macro to return from the current
|
||||||
|
function. Fixes #789, reported by Julien Dutriaux.
|
||||||
|
|
||||||
|
2016-09-16: olly
|
||||||
|
[PHP] Fix SWIG_exception() macro to return from the current function.
|
||||||
|
Fixes #240, reported by Sergey Seroshtan.
|
||||||
|
|
||||||
|
2016-09-12: xypron
|
||||||
|
[C#] Patch #786 Keyword rename to be CLS compliant by adding an underscore
|
||||||
|
suffix instead of an underscore suffix to the C symbol name. Please use an explicit
|
||||||
|
%rename to rename the symbol with a _ prefix if you want the old symbol name.
|
||||||
|
|
||||||
|
*** POTENTIAL INCOMPATIBILITY ***
|
||||||
|
|
||||||
|
2016-09-09: olly
|
||||||
|
[Python] Fix import handling for Python 2.6 to work in a frozen
|
||||||
|
application. Fixes #145, reported by Thomas Kluyver.
|
||||||
|
|
||||||
|
2016-09-02: smarchetto
|
||||||
|
[Scilab] Pointers are mapped to mlist instead of tlist
|
||||||
|
(mlist better for scilab overloading)
|
||||||
|
|
||||||
|
2016-09-02: olly
|
||||||
|
[PHP] Fix "out" typemap for member function pointers and "in"
|
||||||
|
typemap for char INPUT[ANY].
|
||||||
|
|
||||||
|
2016-09-01: wsfulton
|
||||||
|
[Python] More efficient Python slicing.
|
||||||
|
Call reserve for container types that support it to avoid repeated
|
||||||
|
memory reallocations for new slices or slices that grow in size.
|
||||||
|
|
||||||
|
2016-09-01: wsfulton
|
||||||
|
[Python] #771 - Make builtin types hashable by default.
|
||||||
|
Default hash is the underlying C/C++ pointer. This matches up with testing for
|
||||||
|
equivalence (Py_EQ in SwigPyObject_richcompare) which compares the pointers.
|
||||||
|
|
||||||
|
2016-08-22: wsfulton
|
||||||
|
[Python] The following builtin slots can be customized like other slots via the
|
||||||
|
"python:<x>" and "python:slot" features where <x> is the appropriate slot name:
|
||||||
|
tp_allocs
|
||||||
|
tp_bases
|
||||||
|
tp_basicsize
|
||||||
|
tp_cache
|
||||||
|
tp_del
|
||||||
|
tp_dealloc
|
||||||
|
tp_flags
|
||||||
|
tp_frees
|
||||||
|
tp_getset
|
||||||
|
tp_is_gc
|
||||||
|
tp_maxalloc
|
||||||
|
tp_methods
|
||||||
|
tp_mro
|
||||||
|
tp_new
|
||||||
|
tp_next
|
||||||
|
tp_prev
|
||||||
|
tp_richcompare
|
||||||
|
tp_subclasses
|
||||||
|
tp_weaklist
|
||||||
|
was_sq_ass_slice
|
||||||
|
was_sq_slice
|
||||||
|
|
||||||
|
A few documentation improvements for slot customization.
|
||||||
|
|
||||||
|
2016-08-09: joequant
|
||||||
|
[R] Patch #765 Fix extern "C" header includes for C++ code.
|
||||||
|
|
||||||
|
2016-08-05: olly
|
||||||
|
[xml] Fix how the output filename is built to avoid problems when
|
||||||
|
it contains the embedded strings ".c", ".cpp" or ".cxx".
|
||||||
|
Fixes #540 reported by djack42.
|
||||||
|
|
||||||
|
2016-07-01: wsfulton
|
||||||
|
Fix corner case of wrapping std::vector of T pointers where a pointer to a pointer of T
|
||||||
|
also exists in the wrapped code. SF Bug 2359417 (967).
|
||||||
|
|
||||||
|
2016-06-26: wkalinin
|
||||||
|
[Java, C#] Patch #681 Fix seg fault when ignoring nested classes.
|
||||||
|
|
||||||
|
2016-06-25: mromberg
|
||||||
|
[Python] #711 Fix -castmode and conversion of signed and unsigned integer types.
|
||||||
|
See 2015-12-23 CHANGES entry for details of these improvements when they were
|
||||||
|
implemented for the default options (ie not using -castmode).
|
||||||
|
|
||||||
|
2016-06-25: ahnolds
|
||||||
|
Patch #730 - Fix %implicitconv for overloaded functions when using
|
||||||
|
-castmode or -fastdispatch options.
|
||||||
|
|
||||||
|
The result is that in all overload cases where there are multiple possibilities
|
||||||
|
with the same number of arguments, the dispatch function will first check for
|
||||||
|
exact (aka non implicit) matches, and then subsequently check for implicit
|
||||||
|
casting matches. This was already happening in the normal dispatch situation,
|
||||||
|
and in the -fastdispatch case two passes through the candidates were happening,
|
||||||
|
just with SWIG_POINTER_IMPLICIT_CONV always set. After this patch, it is not set
|
||||||
|
on the first pass, and then set on the second pass.
|
||||||
|
|
||||||
|
2016-06-25: liorgold
|
||||||
|
Patch #727 - Add support for C++11 type aliasing.
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<!-- Hand-written HTML -->
|
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>SWIG and Allegro Common Lisp</title>
|
<title>SWIG and Allegro Common Lisp</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
|
|
||||||
<H1><a name="Allegrocl"></a>18 SWIG and Allegro Common Lisp</H1>
|
<H1><a name="Allegrocl">18 SWIG and Allegro Common Lisp</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -135,10 +135,10 @@ be unhappy to see some enterprising folk use this work to add
|
||||||
to it.
|
to it.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Allegrocl_nn2"></a>18.1 Basics</H2>
|
<H2><a name="Allegrocl_nn2">18.1 Basics</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Allegrocl_nn3"></a>18.1.1 Running SWIG</H3>
|
<H3><a name="Allegrocl_nn3">18.1.1 Running SWIG</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -360,7 +360,7 @@ need to link in the Allegro shared library. The library you create from
|
||||||
the C++ wrapper will be what you then load into Allegro CL.
|
the C++ wrapper will be what you then load into Allegro CL.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Allegrocl_nn4"></a>18.1.2 Command Line Options</H3>
|
<H3><a name="Allegrocl_nn4">18.1.2 Command Line Options</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -396,7 +396,7 @@ See <a href="#Allegrocl_nn47">Section 17.5 Identifier converter
|
||||||
functions</a> for more details.
|
functions</a> for more details.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Allegrocl_nn5"></a>18.1.3 Inserting user code into generated files</H3>
|
<H3><a name="Allegrocl_nn5">18.1.3 Inserting user code into generated files</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -436,7 +436,7 @@ Note that the block <tt>%{ ... %}</tt> is effectively a shortcut for
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="Allegrocl_nn6"></a>18.2 Wrapping Overview</H2>
|
<H2><a name="Allegrocl_nn6">18.2 Wrapping Overview</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -446,7 +446,7 @@ New users to SWIG are encouraged to read
|
||||||
interested in generating an interface to C++.
|
interested in generating an interface to C++.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Allegrocl_nn7"></a>18.2.1 Function Wrapping</H3>
|
<H3><a name="Allegrocl_nn7">18.2.1 Function Wrapping</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -499,7 +499,7 @@ interested in generating an interface to C++.
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Allegrocl_nn8"></a>18.2.2 Foreign Wrappers</H3>
|
<H3><a name="Allegrocl_nn8">18.2.2 Foreign Wrappers</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -512,7 +512,7 @@ interested in generating an interface to C++.
|
||||||
typemap.
|
typemap.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Allegrocl_nn9"></a>18.2.3 FFI Wrappers</H3>
|
<H3><a name="Allegrocl_nn9">18.2.3 FFI Wrappers</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -593,7 +593,7 @@ char *xxx();
|
||||||
ff:def-foreign-call's.
|
ff:def-foreign-call's.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Allegrocl_nn10"></a>18.2.4 Non-overloaded Defuns</H3>
|
<H3><a name="Allegrocl_nn10">18.2.4 Non-overloaded Defuns</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -606,7 +606,7 @@ char *xxx();
|
||||||
this function can be manipulated via the <tt>lout</tt> typemap.
|
this function can be manipulated via the <tt>lout</tt> typemap.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Allegrocl_nn11"></a>18.2.5 Overloaded Defuns</H3>
|
<H3><a name="Allegrocl_nn11">18.2.5 Overloaded Defuns</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -622,7 +622,7 @@ char *xxx();
|
||||||
can be manipulated via the <tt>lout</tt> typemap.
|
can be manipulated via the <tt>lout</tt> typemap.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Allegrocl_nn12"></a>18.2.6 What about constant and variable access?</H3>
|
<H3><a name="Allegrocl_nn12">18.2.6 What about constant and variable access?</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -635,7 +635,7 @@ char *xxx();
|
||||||
into the foreign module.
|
into the foreign module.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Allegrocl_nn13"></a>18.2.7 Object Wrapping</H3>
|
<H3><a name="Allegrocl_nn13">18.2.7 Object Wrapping</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -657,7 +657,7 @@ char *xxx();
|
||||||
foreign function interface.
|
foreign function interface.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Allegrocl_nn14"></a>18.3 Wrapping Details</H2>
|
<H2><a name="Allegrocl_nn14">18.3 Wrapping Details</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -665,7 +665,7 @@ char *xxx();
|
||||||
translated into lisp.
|
translated into lisp.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Allegrocl_nn15"></a>18.3.1 Namespaces</H3>
|
<H3><a name="Allegrocl_nn15">18.3.1 Namespaces</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -742,7 +742,7 @@ namespace car {
|
||||||
function such as <tt>(car '(1 2 3)</tt>.
|
function such as <tt>(car '(1 2 3)</tt>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Allegrocl_nn16"></a>18.3.2 Constants</H3>
|
<H3><a name="Allegrocl_nn16">18.3.2 Constants</a></H3>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -803,7 +803,7 @@ namespace car {
|
||||||
not use the <tt>-nocwrap</tt> command-line option.
|
not use the <tt>-nocwrap</tt> command-line option.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Allegrocl_nn17"></a>18.3.3 Variables</H3>
|
<H3><a name="Allegrocl_nn17">18.3.3 Variables</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -881,7 +881,7 @@ globalvar> (globalvar.nnn::glob_float)
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Allegrocl_nn18"></a>18.3.4 Enumerations</H3>
|
<H3><a name="Allegrocl_nn18">18.3.4 Enumerations</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -957,7 +957,7 @@ EXPORT const int ACL_ENUM___FOO3__SWIG_0 = FOO3;
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Allegrocl_nn19"></a>18.3.5 Arrays</H3>
|
<H3><a name="Allegrocl_nn19">18.3.5 Arrays</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1105,10 +1105,10 @@ namespace BAR {
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Allegrocl_nn20"></a>18.3.6 Classes and Structs and Unions (oh my!)</H3>
|
<H3><a name="Allegrocl_nn20">18.3.6 Classes and Structs and Unions (oh my!)</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<H4><a name="Allegrocl_nn21"></a>18.3.6.1 CLOS wrapping of</H4>
|
<H4><a name="Allegrocl_nn21">18.3.6.1 CLOS wrapping of</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1123,7 +1123,7 @@ namespace BAR {
|
||||||
integer values.
|
integer values.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H4><a name="Allegrocl_nn22"></a>18.3.6.2 CLOS Inheritance</H4>
|
<H4><a name="Allegrocl_nn22">18.3.6.2 CLOS Inheritance</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1136,7 +1136,7 @@ namespace BAR {
|
||||||
parameter.
|
parameter.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H4><a name="Allegrocl_nn23"></a>18.3.6.3 Member fields and functions</H4>
|
<H4><a name="Allegrocl_nn23">18.3.6.3 Member fields and functions</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1152,7 +1152,7 @@ namespace BAR {
|
||||||
the interface does nothing for <tt>friend</tt> directives,
|
the interface does nothing for <tt>friend</tt> directives,
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H4><a name="Allegrocl_nn24"></a>18.3.6.4 Why not directly access C++ classes using foreign types?</H4>
|
<H4><a name="Allegrocl_nn24">18.3.6.4 Why not directly access C++ classes using foreign types?</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1170,11 +1170,11 @@ namespace BAR {
|
||||||
use the more robust wrapper functions.
|
use the more robust wrapper functions.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Allegrocl_nn25"></a>18.3.7 Templates</H3>
|
<H3><a name="Allegrocl_nn25">18.3.7 Templates</a></H3>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<H4><a name="Allegrocl_nn26"></a>18.3.7.1 Generating wrapper code for templates</H4>
|
<H4><a name="Allegrocl_nn26">18.3.7.1 Generating wrapper code for templates</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1187,7 +1187,7 @@ namespace BAR {
|
||||||
directive.
|
directive.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H4><a name="Allegrocl_nn27"></a>18.3.7.2 Implicit Template instantiation</H4>
|
<H4><a name="Allegrocl_nn27">18.3.7.2 Implicit Template instantiation</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1197,7 +1197,7 @@ namespace BAR {
|
||||||
class schema.
|
class schema.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Allegrocl_nn28"></a>18.3.8 Typedef, Templates, and Synonym Types</H3>
|
<H3><a name="Allegrocl_nn28">18.3.8 Typedef, Templates, and Synonym Types</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1277,7 +1277,7 @@ synonym>
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H4><a name="Allegrocl_nn29"></a>18.3.8.1 Choosing a primary type</H4>
|
<H4><a name="Allegrocl_nn29">18.3.8.1 Choosing a primary type</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1298,7 +1298,7 @@ synonym>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<H3><a name="Allegrocl_nn30"></a>18.3.9 Function overloading/Parameter defaulting</H3>
|
<H3><a name="Allegrocl_nn30">18.3.9 Function overloading/Parameter defaulting</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1461,7 +1461,7 @@ overload>
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Allegrocl_nn31"></a>18.3.10 Operator wrapping and Operator overloading</H3>
|
<H3><a name="Allegrocl_nn31">18.3.10 Operator wrapping and Operator overloading</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1607,7 +1607,7 @@ opoverload>
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Allegrocl_nn32"></a>18.3.11 Varargs</H3>
|
<H3><a name="Allegrocl_nn32">18.3.11 Varargs</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1628,7 +1628,7 @@ opoverload>
|
||||||
with other ways such functions can be wrapped.
|
with other ways such functions can be wrapped.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Allegrocl_nn33"></a>18.3.12 C++ Exceptions</H3>
|
<H3><a name="Allegrocl_nn33">18.3.12 C++ Exceptions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1640,7 +1640,7 @@ opoverload>
|
||||||
implemented.
|
implemented.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Allegrocl_nn34"></a>18.3.13 Pass by value, pass by reference</H3>
|
<H3><a name="Allegrocl_nn34">18.3.13 Pass by value, pass by reference</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1652,7 +1652,7 @@ opoverload>
|
||||||
newly defined types.
|
newly defined types.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Allegrocl_nn35"></a>18.4 Typemaps</H2>
|
<H2><a name="Allegrocl_nn35">18.4 Typemaps</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1663,7 +1663,7 @@ opoverload>
|
||||||
on <a href="Typemaps.html#Typemaps">Typemaps</a> for more information.
|
on <a href="Typemaps.html#Typemaps">Typemaps</a> for more information.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Allegrocl_nn36"></a>18.4.1 Code Generation in the C++ Wrapper</H3>
|
<H3><a name="Allegrocl_nn36">18.4.1 Code Generation in the C++ Wrapper</a></H3>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1693,7 +1693,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN)
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H4><a name="Allegrocl_nn37"></a>18.4.1.1 IN Typemap</H4>
|
<H4><a name="Allegrocl_nn37">18.4.1.1 IN Typemap</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1728,7 +1728,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN)
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H4><a name="Allegrocl_nn38"></a>18.4.1.2 OUT Typemap</H4>
|
<H4><a name="Allegrocl_nn38">18.4.1.2 OUT Typemap</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1752,7 +1752,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN)
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H4><a name="Allegrocl_nn39"></a>18.4.1.3 CTYPE Typemap</H4>
|
<H4><a name="Allegrocl_nn39">18.4.1.3 CTYPE Typemap</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1784,7 +1784,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN)
|
||||||
these <a href="Typemaps.html#Typemaps_nn25">common typemaps</a> here.
|
these <a href="Typemaps.html#Typemaps_nn25">common typemaps</a> here.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Allegrocl_nn40"></a>18.4.2 Code generation in Lisp wrappers</H3>
|
<H3><a name="Allegrocl_nn40">18.4.2 Code generation in Lisp wrappers</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1803,7 +1803,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN)
|
||||||
<a href="#Allegrocl_nn15">16.3.1 Namespaces</a> for details.
|
<a href="#Allegrocl_nn15">16.3.1 Namespaces</a> for details.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H4><a name="Allegrocl_nn41"></a>18.4.2.1 LIN Typemap</H4>
|
<H4><a name="Allegrocl_nn41">18.4.2.1 LIN Typemap</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1846,7 +1846,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN)
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H4><a name="Allegrocl_nn42"></a>18.4.2.2 LOUT Typemap</H4>
|
<H4><a name="Allegrocl_nn42">18.4.2.2 LOUT Typemap</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1889,7 +1889,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN)
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H4><a name="Allegrocl_nn43"></a>18.4.2.3 FFITYPE Typemap</H4>
|
<H4><a name="Allegrocl_nn43">18.4.2.3 FFITYPE Typemap</a></H4>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1939,7 +1939,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN)
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H4><a name="Allegrocl_nn44"></a>18.4.2.4 LISPTYPE Typemap</H4>
|
<H4><a name="Allegrocl_nn44">18.4.2.4 LISPTYPE Typemap</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1959,7 +1959,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN)
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H4><a name="Allegrocl_nn45"></a>18.4.2.5 LISPCLASS Typemap</H4>
|
<H4><a name="Allegrocl_nn45">18.4.2.5 LISPCLASS Typemap</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1983,7 +1983,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN)
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Allegrocl_nn46"></a>18.4.3 Modifying SWIG behavior using typemaps</H3>
|
<H3><a name="Allegrocl_nn46">18.4.3 Modifying SWIG behavior using typemaps</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2017,10 +2017,10 @@ return-val wrapper-name(parm0, parm1, ..., parmN)
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H2><a name="Allegrocl_nn47"></a>18.5 Identifier Converter functions</H2>
|
<H2><a name="Allegrocl_nn47">18.5 Identifier Converter functions</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Allegrocl_nn48"></a>18.5.1 Creating symbols in the lisp environment</H3>
|
<H3><a name="Allegrocl_nn48">18.5.1 Creating symbols in the lisp environment</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2041,11 +2041,11 @@ return-val wrapper-name(parm0, parm1, ..., parmN)
|
||||||
of arguments.
|
of arguments.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Allegrocl_nn49"></a>18.5.2 Existing identifier-converter functions</H3>
|
<H3><a name="Allegrocl_nn49">18.5.2 Existing identifier-converter functions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>Two basic identifier routines have been defined.
|
<p>Two basic identifier routines have been defined.
|
||||||
<H4><a name="Allegrocl_nn50"></a>18.5.2.1 identifier-convert-null</H4>
|
<H4><a name="Allegrocl_nn50">18.5.2.1 identifier-convert-null</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2054,7 +2054,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN)
|
||||||
strings, from which a symbol will be created.
|
strings, from which a symbol will be created.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H4><a name="Allegrocl_nn51"></a>18.5.2.2 identifier-convert-lispify</H4>
|
<H4><a name="Allegrocl_nn51">18.5.2.2 identifier-convert-lispify</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2063,7 +2063,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN)
|
||||||
same symbol transformations.
|
same symbol transformations.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H4><a name="Allegrocl_nn52"></a>18.5.2.3 Default identifier to symbol conversions</H4>
|
<H4><a name="Allegrocl_nn52">18.5.2.3 Default identifier to symbol conversions</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2072,7 +2072,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN)
|
||||||
default naming conventions.
|
default naming conventions.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Allegrocl_nn53"></a>18.5.3 Defining your own identifier-converter</H3>
|
<H3><a name="Allegrocl_nn53">18.5.3 Defining your own identifier-converter</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2128,7 +2128,7 @@ indicating the number of arguments passed to the routine indicated by
|
||||||
this identifier.
|
this identifier.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Allegrocl_nn54"></a>18.5.4 Instructing SWIG to use a particular identifier-converter</H3>
|
<H3><a name="Allegrocl_nn54">18.5.4 Instructing SWIG to use a particular identifier-converter</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>SWIG and Android</title>
|
<title>SWIG and Android</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
<body bgcolor="#FFFFFF">
|
<body bgcolor="#FFFFFF">
|
||||||
<H1><a name="Android"></a>19 SWIG and Android</H1>
|
<H1><a name="Android">19 SWIG and Android</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -30,24 +31,24 @@ This chapter describes SWIG's support of Android.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="Android_overview"></a>19.1 Overview</H2>
|
<H2><a name="Android_overview">19.1 Overview</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
The Android chapter is fairly short as support for Android is the same as for Java, where the Java Native Interface (JNI) is
|
The Android chapter is fairly short as support for Android is the same as for Java, where the Java Native Interface (JNI) is
|
||||||
used to call from Android Java into C or C++ compiled code.
|
used to call from Android Java into C or C++ compiled code.
|
||||||
Everything in the <a href="Java.html">Java chapter</a> applies to generating code for access from Android Java code.
|
Everything in the <a href="Java.html#Java">Java chapter</a> applies to generating code for access from Android Java code.
|
||||||
This chapter contains a few Android specific notes and examples.
|
This chapter contains a few Android specific notes and examples.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Android_examples"></a>19.2 Android examples</H2>
|
<H2><a name="Android_examples">19.2 Android examples</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Android_examples_intro"></a>19.2.1 Examples introduction</H3>
|
<H3><a name="Android_examples_intro">19.2.1 Examples introduction</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
The examples require the <a href="http://developer.android.com/sdk/index.html">Android SDK</a> and <a href="http://developer.android.com/sdk/ndk/index.html">Android NDK</a> which can be installed as per instructions in the links.
|
The examples require the <a href="http://developer.android.com/sdk/index.html">Android SDK</a> and <a href="http://developer.android.com/tools/sdk/ndk/index.html">Android NDK</a> which can be installed as per instructions in the links.
|
||||||
The Eclipse version is not required for these examples as just the command line tools are used (shown for Linux as the host, but Windows will be very similar, if not identical in most places).
|
The Eclipse version is not required for these examples as just the command line tools are used (shown for Linux as the host, but Windows will be very similar, if not identical in most places).
|
||||||
Add the SDK tools and NDK tools to your path and create a directory somewhere for your Android projects (adjust PATH as necessary to where you installed the tools):
|
Add the SDK tools and NDK tools to your path and create a directory somewhere for your Android projects (adjust PATH as necessary to where you installed the tools):
|
||||||
</p>
|
</p>
|
||||||
|
|
@ -76,7 +77,7 @@ $ android list targets
|
||||||
The following examples are shipped with SWIG under the Examples/android directory and include a Makefile to build and install each example.
|
The following examples are shipped with SWIG under the Examples/android directory and include a Makefile to build and install each example.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Android_example_simple"></a>19.2.2 Simple C example</H3>
|
<H3><a name="Android_example_simple">19.2.2 Simple C example</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -398,7 +399,7 @@ Run the app again and this time you will see the output pictured below, showing
|
||||||
<center><img src="android-simple.png" alt="Android screenshot of SwigSimple example"></center>
|
<center><img src="android-simple.png" alt="Android screenshot of SwigSimple example"></center>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Android_example_class"></a>19.2.3 C++ class example</H3>
|
<H3><a name="Android_example_class">19.2.3 C++ class example</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -746,7 +747,7 @@ Run the app to see the result of calling the C++ code from Java:
|
||||||
|
|
||||||
<center><img src="android-class.png" alt="Android screenshot of SwigClass example"></center>
|
<center><img src="android-class.png" alt="Android screenshot of SwigClass example"></center>
|
||||||
|
|
||||||
<H3><a name="Android_examples_other"></a>19.2.4 Other examples</H3>
|
<H3><a name="Android_examples_other">19.2.4 Other examples</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -758,7 +759,7 @@ Note that the 'extend' example is demonstrates the directors feature.
|
||||||
Normally C++ exception handling and the STL is not available by default in the version of g++ shipped with Android, but this example turns these features on as described in the next section.
|
Normally C++ exception handling and the STL is not available by default in the version of g++ shipped with Android, but this example turns these features on as described in the next section.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Android_stl"></a>19.3 C++ STL</H2>
|
<H2><a name="Android_stl">19.3 C++ STL</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Argument Handling</title>
|
<title>Argument Handling</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
<H1><a name="Arguments"></a>10 Argument Handling</H1>
|
<H1><a name="Arguments">10 Argument Handling</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -42,7 +43,7 @@ return multiple values through the arguments of a function. This chapter
|
||||||
describes some of the techniques for doing this.
|
describes some of the techniques for doing this.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Arguments_nn2"></a>10.1 The typemaps.i library</H2>
|
<H2><a name="Arguments_nn2">10.1 The typemaps.i library</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -50,7 +51,7 @@ This section describes the <tt>typemaps.i</tt> library file--commonly used to
|
||||||
change certain properties of argument conversion.
|
change certain properties of argument conversion.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Arguments_nn3"></a>10.1.1 Introduction</H3>
|
<H3><a name="Arguments_nn3">10.1.1 Introduction</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -194,7 +195,7 @@ else. To clear a typemap, the <tt>%clear</tt> directive should be used. For e
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Arguments_nn4"></a>10.1.2 Input parameters</H3>
|
<H3><a name="Arguments_nn4">10.1.2 Input parameters</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -247,7 +248,7 @@ When the function is used in the scripting language interpreter, it will work li
|
||||||
result = add(3,4)
|
result = add(3,4)
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Arguments_nn5"></a>10.1.3 Output parameters</H3>
|
<H3><a name="Arguments_nn5">10.1.3 Output parameters</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -314,7 +315,7 @@ iresult, dresult = foo(3.5, 2)
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Arguments_nn6"></a>10.1.4 Input/Output parameters</H3>
|
<H3><a name="Arguments_nn6">10.1.4 Input/Output parameters</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -379,7 +380,7 @@ rather than directly overwriting the value of the original input object.
|
||||||
SWIG. Backwards compatibility is preserved, but deprecated.
|
SWIG. Backwards compatibility is preserved, but deprecated.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Arguments_nn7"></a>10.1.5 Using different names</H3>
|
<H3><a name="Arguments_nn7">10.1.5 Using different names</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -413,7 +414,7 @@ Typemap declarations are lexically scoped so a typemap takes effect from the poi
|
||||||
file or a matching <tt>%clear</tt> declaration.
|
file or a matching <tt>%clear</tt> declaration.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Arguments_nn8"></a>10.2 Applying constraints to input values</H2>
|
<H2><a name="Arguments_nn8">10.2 Applying constraints to input values</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -423,7 +424,7 @@ insure that a value is positive, or that a pointer is non-NULL. This
|
||||||
can be accomplished including the <tt>constraints.i</tt> library file.
|
can be accomplished including the <tt>constraints.i</tt> library file.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Arguments_nn9"></a>10.2.1 Simple constraint example</H3>
|
<H3><a name="Arguments_nn9">10.2.1 Simple constraint example</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -449,7 +450,7 @@ the arguments violate the constraint condition, a scripting language
|
||||||
exception will be raised. As a result, it is possible to catch bad
|
exception will be raised. As a result, it is possible to catch bad
|
||||||
values, prevent mysterious program crashes and so on.</p>
|
values, prevent mysterious program crashes and so on.</p>
|
||||||
|
|
||||||
<H3><a name="Arguments_nn10"></a>10.2.2 Constraint methods</H3>
|
<H3><a name="Arguments_nn10">10.2.2 Constraint methods</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -465,7 +466,7 @@ NONNULL Non-NULL pointer (pointers only).
|
||||||
|
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Arguments_nn11"></a>10.2.3 Applying constraints to new datatypes</H3>
|
<H3><a name="Arguments_nn11">10.2.3 Applying constraints to new datatypes</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
474
Doc/Manual/CCache.html
Normal file
474
Doc/Manual/CCache.html
Normal file
|
|
@ -0,0 +1,474 @@
|
||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>ccache-swig(1) manpage</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body bgcolor="#ffffff">
|
||||||
|
<H1><a name="CCache">17 Using SWIG with ccache - ccache-swig(1) manpage</a></H1>
|
||||||
|
<!-- INDEX -->
|
||||||
|
<div class="sectiontoc">
|
||||||
|
<ul>
|
||||||
|
<li><a href="#CCache_nn2">NAME</a>
|
||||||
|
<li><a href="#CCache_nn3">SYNOPSIS</a>
|
||||||
|
<li><a href="#CCache_nn4">DESCRIPTION</a>
|
||||||
|
<li><a href="#CCache_nn5">OPTIONS SUMMARY</a>
|
||||||
|
<li><a href="#CCache_nn6">OPTIONS</a>
|
||||||
|
<li><a href="#CCache_nn7">INSTALLATION</a>
|
||||||
|
<li><a href="#CCache_nn8">EXTRA OPTIONS</a>
|
||||||
|
<li><a href="#CCache_nn9">ENVIRONMENT VARIABLES</a>
|
||||||
|
<li><a href="#CCache_nn10">CACHE SIZE MANAGEMENT</a>
|
||||||
|
<li><a href="#CCache_nn11">CACHE COMPRESSION</a>
|
||||||
|
<li><a href="#CCache_nn12">HOW IT WORKS</a>
|
||||||
|
<li><a href="#CCache_nn13">USING CCACHE WITH DISTCC</a>
|
||||||
|
<li><a href="#CCache_nn14">SHARING A CACHE</a>
|
||||||
|
<li><a href="#CCache_nn15">HISTORY</a>
|
||||||
|
<li><a href="#CCache_nn16">DIFFERENCES FROM COMPILERCACHE</a>
|
||||||
|
<li><a href="#CCache_nn17">CREDITS</a>
|
||||||
|
<li><a href="#CCache_nn18">AUTHOR</a>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<!-- INDEX -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<H2><a name="CCache_nn2">17.1 NAME</a></H2>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
|
||||||
|
ccache-swig - a fast compiler cache
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<H2><a name="CCache_nn3">17.2 SYNOPSIS</a></H2>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
ccache-swig [OPTION]
|
||||||
|
<p>
|
||||||
|
ccache-swig <compiler> [COMPILER OPTIONS]
|
||||||
|
<p>
|
||||||
|
<compiler> [COMPILER OPTIONS]
|
||||||
|
<p>
|
||||||
|
<H2><a name="CCache_nn4">17.3 DESCRIPTION</a></H2>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
ccache-swig is a compiler cache. It speeds up re-compilation of C/C++/SWIG code
|
||||||
|
by caching previous compiles and detecting when the same compile is
|
||||||
|
being done again. ccache-swig is ccache plus support for SWIG. ccache
|
||||||
|
and ccache-swig are used interchangeably in this document.
|
||||||
|
<p>
|
||||||
|
<H2><a name="CCache_nn5">17.4 OPTIONS SUMMARY</a></H2>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Here is a summary of the options to ccache-swig.
|
||||||
|
<p>
|
||||||
|
<pre>
|
||||||
|
|
||||||
|
-s show statistics summary
|
||||||
|
-z zero statistics
|
||||||
|
-c run a cache cleanup
|
||||||
|
-C clear the cache completely
|
||||||
|
-F <n> set maximum files in cache
|
||||||
|
-M <n> set maximum size of cache (use G, M or K)
|
||||||
|
-h this help page
|
||||||
|
-V print version number
|
||||||
|
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<H2><a name="CCache_nn6">17.5 OPTIONS</a></H2>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
These options only apply when you invoke ccache as "ccache-swig". When
|
||||||
|
invoked as a compiler none of these options apply. In that case your
|
||||||
|
normal compiler options apply and you should refer to your compilers
|
||||||
|
documentation.
|
||||||
|
<p>
|
||||||
|
<dl>
|
||||||
|
<p><dt><strong><strong>-h</strong></strong><dd> Print a options summary page
|
||||||
|
<p>
|
||||||
|
<p><dt><strong><strong>-s</strong></strong><dd> Print the current statistics summary for the cache. The
|
||||||
|
statistics are stored spread across the subdirectories of the
|
||||||
|
cache. Using "ccache-swig -s" adds up the statistics across all
|
||||||
|
subdirectories and prints the totals.
|
||||||
|
<p>
|
||||||
|
<p><dt><strong><strong>-z</strong></strong><dd> Zero the cache statistics.
|
||||||
|
<p>
|
||||||
|
<p><dt><strong><strong>-V</strong></strong><dd> Print the ccache version number
|
||||||
|
<p>
|
||||||
|
<p><dt><strong><strong>-c</strong></strong><dd> Clean the cache and re-calculate the cache file count and
|
||||||
|
size totals. Normally the -c option should not be necessary as ccache
|
||||||
|
keeps the cache below the specified limits at runtime and keeps
|
||||||
|
statistics up to date on each compile. This option is mostly useful
|
||||||
|
if you manually modify the cache contents or believe that the cache
|
||||||
|
size statistics may be inaccurate.
|
||||||
|
<p>
|
||||||
|
<p><dt><strong><strong>-C</strong></strong><dd> Clear the entire cache, removing all cached files.
|
||||||
|
<p>
|
||||||
|
<p><dt><strong><strong>-F <maxfiles></strong></strong><dd> This sets the maximum number of files allowed in
|
||||||
|
the cache. The value is stored inside the cache directory and applies
|
||||||
|
to all future compiles. Due to the way the value is stored the actual
|
||||||
|
value used is always rounded down to the nearest multiple of 16.
|
||||||
|
<p>
|
||||||
|
<p><dt><strong><strong>-M <maxsize></strong></strong><dd> This sets the maximum cache size. You can specify
|
||||||
|
a value in gigabytes, megabytes or kilobytes by appending a G, M or K
|
||||||
|
to the value. The default is gigabytes. The actual value stored is
|
||||||
|
rounded down to the nearest multiple of 16 kilobytes.
|
||||||
|
<p>
|
||||||
|
</dl>
|
||||||
|
<p>
|
||||||
|
<H2><a name="CCache_nn7">17.6 INSTALLATION</a></H2>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
There are two ways to use ccache. You can either prefix your compile
|
||||||
|
commands with "ccache-swig" or you can create a symbolic link between
|
||||||
|
ccache-swig and the names of your compilers. The first method is most
|
||||||
|
convenient if you just want to try out ccache or wish to use it for
|
||||||
|
some specific projects. The second method is most useful for when you
|
||||||
|
wish to use ccache for all your compiles.
|
||||||
|
<p>
|
||||||
|
To install for usage by the first method just copy ccache-swig to somewhere
|
||||||
|
in your path.
|
||||||
|
<p>
|
||||||
|
To install for the second method do something like this:
|
||||||
|
<pre>
|
||||||
|
|
||||||
|
cp ccache-swig /usr/local/bin/
|
||||||
|
ln -s /usr/local/bin/ccache-swig /usr/local/bin/gcc
|
||||||
|
ln -s /usr/local/bin/ccache-swig /usr/local/bin/g++
|
||||||
|
ln -s /usr/local/bin/ccache-swig /usr/local/bin/cc
|
||||||
|
ln -s /usr/local/bin/ccache-swig /usr/local/bin/swig
|
||||||
|
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
This will work as long as /usr/local/bin comes before the path to gcc
|
||||||
|
(which is usually in /usr/bin). After installing you may wish to run
|
||||||
|
"which gcc" to make sure that the correct link is being used.
|
||||||
|
<p>
|
||||||
|
Note! Do not use a hard link, use a symbolic link. A hardlink will
|
||||||
|
cause "interesting" problems.
|
||||||
|
<p>
|
||||||
|
<H2><a name="CCache_nn8">17.7 EXTRA OPTIONS</a></H2>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
When run as a compiler front end ccache usually just takes the same
|
||||||
|
command line options as the compiler you are using. The only exception
|
||||||
|
to this is the option '--ccache-skip'. That option can be used to tell
|
||||||
|
ccache that the next option is definitely not a input filename, and
|
||||||
|
should be passed along to the compiler as-is.
|
||||||
|
<p>
|
||||||
|
The reason this can be important is that ccache does need to parse the
|
||||||
|
command line and determine what is an input filename and what is a
|
||||||
|
compiler option, as it needs the input filename to determine the name
|
||||||
|
of the resulting object file (among other things). The heuristic
|
||||||
|
ccache uses in this parse is that any string on the command line that
|
||||||
|
exists as a file is treated as an input file name (usually a C
|
||||||
|
file). By using --ccache-skip you can force an option to not be
|
||||||
|
treated as an input file name and instead be passed along to the
|
||||||
|
compiler as a command line option.
|
||||||
|
<p>
|
||||||
|
<H2><a name="CCache_nn9">17.8 ENVIRONMENT VARIABLES</a></H2>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
ccache uses a number of environment variables to control operation. In
|
||||||
|
most cases you won't need any of these as the defaults will be fine.
|
||||||
|
<p>
|
||||||
|
<dl>
|
||||||
|
<p>
|
||||||
|
<p><dt><strong><strong>CCACHE_DIR</strong></strong><dd> the CCACHE_DIR environment variable specifies
|
||||||
|
where ccache will keep its cached compiler output. The default is
|
||||||
|
"$HOME/.ccache".
|
||||||
|
<p>
|
||||||
|
<p><dt><strong><strong>CCACHE_TEMPDIR</strong></strong><dd> the CCACHE_TEMPDIR environment variable specifies
|
||||||
|
where ccache will put temporary files. The default is the same as
|
||||||
|
CCACHE_DIR. Note that the CCACHE_TEMPDIR path must be on the same
|
||||||
|
filesystem as the CCACHE_DIR path, so that renames of files between
|
||||||
|
the two directories can work.
|
||||||
|
<p>
|
||||||
|
<p><dt><strong><strong>CCACHE_LOGFILE</strong></strong><dd> If you set the CCACHE_LOGFILE environment
|
||||||
|
variable then ccache will write some log information on cache hits
|
||||||
|
and misses in that file. This is useful for tracking down problems.
|
||||||
|
<p>
|
||||||
|
<p><dt><strong><strong>CCACHE_VERBOSE</strong></strong><dd> If you set the CCACHE_VERBOSE environment
|
||||||
|
variable then ccache will display on stdout all the compiler invocations
|
||||||
|
that it makes. This can useful for debugging unexpected problems.
|
||||||
|
<p>
|
||||||
|
<p><dt><strong><strong>CCACHE_PATH</strong></strong><dd> You can optionally set CCACHE_PATH to a colon
|
||||||
|
separated path where ccache will look for the real compilers. If you
|
||||||
|
don't do this then ccache will look for the first executable matching
|
||||||
|
the compiler name in the normal PATH that isn't a symbolic link to
|
||||||
|
ccache itself.
|
||||||
|
<p>
|
||||||
|
<p><dt><strong><strong>CCACHE_CC</strong></strong><dd> You can optionally set CCACHE_CC to force the name
|
||||||
|
of the compiler to use. If you don't do this then ccache works it out
|
||||||
|
from the command line.
|
||||||
|
<p>
|
||||||
|
<p><dt><strong><strong>CCACHE_PREFIX</strong></strong><dd> This option adds a prefix to the command line
|
||||||
|
that ccache runs when invoking the compiler. Also see the section
|
||||||
|
below on using ccache with distcc.
|
||||||
|
<p>
|
||||||
|
<p><dt><strong><strong>CCACHE_DISABLE</strong></strong><dd> If you set the environment variable
|
||||||
|
CCACHE_DISABLE then ccache will just call the real compiler,
|
||||||
|
bypassing the cache completely.
|
||||||
|
<p>
|
||||||
|
<p><dt><strong><strong>CCACHE_READONLY</strong></strong><dd> the CCACHE_READONLY environment variable
|
||||||
|
tells ccache to attempt to use existing cached object files, but not
|
||||||
|
to try to add anything new to the cache. If you are using this because
|
||||||
|
your CCACHE_DIR is read-only, then you may find that you also need to
|
||||||
|
set CCACHE_TEMPDIR as otherwise ccache will fail to create the
|
||||||
|
temporary files.
|
||||||
|
<p>
|
||||||
|
<p><dt><strong><strong>CCACHE_CPP2</strong></strong><dd> If you set the environment variable CCACHE_CPP2
|
||||||
|
then ccache will not use the optimisation of avoiding the 2nd call to
|
||||||
|
the pre-processor by compiling the pre-processed output that was used
|
||||||
|
for finding the hash in the case of a cache miss. This is primarily a
|
||||||
|
debugging option, although it is possible that some unusual compilers
|
||||||
|
will have problems with the intermediate filename extensions used in
|
||||||
|
this optimisation, in which case this option could allow ccache to be
|
||||||
|
used.
|
||||||
|
<p>
|
||||||
|
<p><dt><strong><strong>CCACHE_NOCOMPRESS</strong></strong><dd> If you set the environment variable
|
||||||
|
CCACHE_NOCOMPRESS then there is no compression used on files that go
|
||||||
|
into the cache. However, this setting has no effect on how files are
|
||||||
|
retrieved from the cache, compressed results will still be usable.
|
||||||
|
<p>
|
||||||
|
<p><dt><strong><strong>CCACHE_NOSTATS</strong></strong><dd> If you set the environment variable
|
||||||
|
CCACHE_NOSTATS then ccache will not update the statistics files on
|
||||||
|
each compile.
|
||||||
|
<p>
|
||||||
|
<p><dt><strong><strong>CCACHE_NLEVELS</strong></strong><dd> The environment variable CCACHE_NLEVELS allows
|
||||||
|
you to choose the number of levels of hash in the cache directory. The
|
||||||
|
default is 2. The minimum is 1 and the maximum is 8.
|
||||||
|
<p>
|
||||||
|
<p><dt><strong><strong>CCACHE_HARDLINK</strong></strong><dd> If you set the environment variable
|
||||||
|
CCACHE_HARDLINK then ccache will attempt to use hard links from the
|
||||||
|
cache directory when creating the compiler output rather than using a
|
||||||
|
file copy. Using hard links is faster, but can confuse programs like
|
||||||
|
'make' that rely on modification times. Hard links are never made for
|
||||||
|
compressed cache files.
|
||||||
|
<p>
|
||||||
|
<p><dt><strong><strong>CCACHE_RECACHE</strong></strong><dd> This forces ccache to not use any cached
|
||||||
|
results, even if it finds them. New results are still cached, but
|
||||||
|
existing cache entries are ignored.
|
||||||
|
<p>
|
||||||
|
<p><dt><strong><strong>CCACHE_UMASK</strong></strong><dd> This sets the umask for ccache and all child
|
||||||
|
processes (such as the compiler). This is mostly useful when you wish
|
||||||
|
to share your cache with other users. Note that this also affects the
|
||||||
|
file permissions set on the object files created from your
|
||||||
|
compilations.
|
||||||
|
<p>
|
||||||
|
<p><dt><strong><strong>CCACHE_HASHDIR</strong></strong><dd> This tells ccache to hash the current working
|
||||||
|
directory when calculating the hash that is used to distinguish two
|
||||||
|
compiles. This prevents a problem with the storage of the current
|
||||||
|
working directory in the debug info of a object file, which can lead
|
||||||
|
ccache to give a cached object file that has the working directory in
|
||||||
|
the debug info set incorrectly. This option is off by default as the
|
||||||
|
incorrect setting of this debug info rarely causes problems. If you
|
||||||
|
strike problems with gdb not using the correct directory then enable
|
||||||
|
this option.
|
||||||
|
<p>
|
||||||
|
<p><dt><strong><strong>CCACHE_UNIFY</strong></strong><dd> If you set the environment variable CCACHE_UNIFY
|
||||||
|
then ccache will use the C/C++ unifier when hashing the pre-processor
|
||||||
|
output if -g is not used in the compile. The unifier is slower than a
|
||||||
|
normal hash, so setting this environment variable loses a little bit
|
||||||
|
of speed, but it means that ccache can take advantage of not
|
||||||
|
recompiling when the changes to the source code consist of
|
||||||
|
reformatting only. Note that using CCACHE_UNIFY changes the hash, so
|
||||||
|
cached compiles with CCACHE_UNIFY set cannot be used when
|
||||||
|
CCACHE_UNIFY is not set and vice versa. The reason the unifier is off
|
||||||
|
by default is that it can give incorrect line number information in
|
||||||
|
compiler warning messages.
|
||||||
|
<p>
|
||||||
|
<p><dt><strong><strong>CCACHE_EXTENSION</strong></strong><dd> Normally ccache tries to automatically
|
||||||
|
determine the extension to use for intermediate C pre-processor files
|
||||||
|
based on the type of file being compiled. Unfortunately this sometimes
|
||||||
|
doesn't work, for example when using the aCC compiler on HP-UX. On
|
||||||
|
systems like this you can use the CCACHE_EXTENSION option to override
|
||||||
|
the default. On HP-UX set this environment variable to "i" if you use
|
||||||
|
the aCC compiler.
|
||||||
|
<p>
|
||||||
|
<p><dt><strong><strong>CCACHE_STRIPC</strong></strong><dd> If you set the environment variable
|
||||||
|
CCACHE_STRIPC then ccache will strip the -c option when invoking
|
||||||
|
the preprocessor. This option is primarily for the Sun Workshop
|
||||||
|
C++ compiler as without this option an unwarranted warning is displayed:
|
||||||
|
CC: Warning: "-E" redefines product from "object" to "source (stdout)"
|
||||||
|
when -E and -c is used together.
|
||||||
|
<p>
|
||||||
|
<p><dt><strong><strong>CCACHE_SWIG</strong></strong><dd> When using SWIG as the compiler and it does not
|
||||||
|
have 'swig' in the executable name, then the CCACHE_SWIG environment
|
||||||
|
variable needs to be set in order for ccache to work correctly with
|
||||||
|
SWIG. The use of CCACHE_CPP2 is also recommended for SWIG due to some
|
||||||
|
preprocessor quirks, however, use of CCACHE_CPP2 can often be skipped
|
||||||
|
-- check your generated code with and without this option set. Known
|
||||||
|
problems are using preprocessor directives within %inline blocks and
|
||||||
|
the use of '#pragma SWIG'.
|
||||||
|
<p>
|
||||||
|
</dl>
|
||||||
|
<p>
|
||||||
|
<H2><a name="CCache_nn10">17.9 CACHE SIZE MANAGEMENT</a></H2>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
By default ccache has a one gigabyte limit on the cache size and no
|
||||||
|
maximum number of files. You can set a different limit using the
|
||||||
|
"ccache -M" and "ccache -F" options, which set the size and number of
|
||||||
|
files limits.
|
||||||
|
<p>
|
||||||
|
When these limits are reached ccache will reduce the cache to 20%
|
||||||
|
below the numbers you specified in order to avoid doing the cache
|
||||||
|
clean operation too often.
|
||||||
|
<p>
|
||||||
|
<H2><a name="CCache_nn11">17.10 CACHE COMPRESSION</a></H2>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
By default on most platforms ccache will compress all files it puts
|
||||||
|
into the cache
|
||||||
|
using the zlib compression. While this involves a negligible
|
||||||
|
performance slowdown, it significantly increases the number of files
|
||||||
|
that fit in the cache. You can turn off compression setting the
|
||||||
|
CCACHE_NOCOMPRESS environment variable.
|
||||||
|
<p>
|
||||||
|
<H2><a name="CCache_nn12">17.11 HOW IT WORKS</a></H2>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The basic idea is to detect when you are compiling exactly the same
|
||||||
|
code a 2nd time and use the previously compiled output. You detect
|
||||||
|
that it is the same code by forming a hash of:
|
||||||
|
<p>
|
||||||
|
<ul>
|
||||||
|
<li> the pre-processor output from running the compiler with -E
|
||||||
|
<li> the command line options
|
||||||
|
<li> the real compilers size and modification time
|
||||||
|
<li> any stderr output generated by the compiler
|
||||||
|
</ul>
|
||||||
|
<p>
|
||||||
|
These are hashed using md4 (a strong hash) and a cache file is formed
|
||||||
|
based on that hash result. When the same compilation is done a second
|
||||||
|
time ccache is able to supply the correct compiler output (including
|
||||||
|
all warnings etc) from the cache.
|
||||||
|
<p>
|
||||||
|
ccache has been carefully written to always produce exactly the same
|
||||||
|
compiler output that you would get without the cache. If you ever
|
||||||
|
discover a case where ccache changes the output of your compiler then
|
||||||
|
please let me know.
|
||||||
|
<p>
|
||||||
|
<H2><a name="CCache_nn13">17.12 USING CCACHE WITH DISTCC</a></H2>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
distcc is a very useful program for distributing compilation across a
|
||||||
|
range of compiler servers. It is often useful to combine distcc with
|
||||||
|
ccache, so that compiles that are done are sped up by distcc, but that
|
||||||
|
ccache avoids the compile completely where possible.
|
||||||
|
<p>
|
||||||
|
To use distcc with ccache I recommend using the CCACHE_PREFIX
|
||||||
|
option. You just need to set the environment variable CCACHE_PREFIX to
|
||||||
|
'distcc' and ccache will prefix the command line used with the
|
||||||
|
compiler with the command 'distcc'.
|
||||||
|
<p>
|
||||||
|
<H2><a name="CCache_nn14">17.13 SHARING A CACHE</a></H2>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
A group of developers can increase the cache hit rate by sharing a
|
||||||
|
cache directory. The hard links however cause unwanted side effects,
|
||||||
|
as all links to a cached file share the file's modification timestamp.
|
||||||
|
This results in false dependencies to be triggered by timestamp-based
|
||||||
|
build systems whenever another user links to an existing
|
||||||
|
file. Typically, users will see that their libraries and binaries are
|
||||||
|
relinked without reason. To share a cache without side effects, the
|
||||||
|
following conditions need to be met:
|
||||||
|
<p>
|
||||||
|
<ul>
|
||||||
|
<li> Use the same <strong>CCACHE_DIR</strong> environment variable setting
|
||||||
|
<li> Unset the <strong>CCACHE_HARDLINK</strong> environment variable
|
||||||
|
<li> Make sure everyone sets the CCACHE_UMASK environment variable
|
||||||
|
to 002, this ensures that cached files are accessible to everyone in
|
||||||
|
the group.
|
||||||
|
<li> Make sure that all users have write permission in the entire
|
||||||
|
cache directory (and that you trust all users of the shared cache).
|
||||||
|
<li> Make sure that the setgid bit is set on all directories in the
|
||||||
|
cache. This tells the filesystem to inherit group ownership for new
|
||||||
|
directories. The command "chmod g+s `find $CCACHE_DIR -type d`" might
|
||||||
|
be useful for this.
|
||||||
|
<li> Set <strong>CCACHE_NOCOMPRESS</strong> for all users, if there are users with
|
||||||
|
versions of ccache that do not support compression.
|
||||||
|
</ul>
|
||||||
|
<p>
|
||||||
|
<H2><a name="CCache_nn15">17.14 HISTORY</a></H2>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
ccache was inspired by the compilercache shell script script written
|
||||||
|
by Erik Thiele and I would like to thank him for an excellent piece of
|
||||||
|
work. See
|
||||||
|
<a href="http://www.erikyyy.de/compilercache/">http://www.erikyyy.de/compilercache/</a>
|
||||||
|
for the Erik's scripts.
|
||||||
|
ccache-swig is a port of the original ccache with support added for use
|
||||||
|
with SWIG.
|
||||||
|
<p>
|
||||||
|
I wrote ccache because I wanted to get a bit more speed out of a
|
||||||
|
compiler cache and I wanted to remove some of the limitations of the
|
||||||
|
shell-script version.
|
||||||
|
<p>
|
||||||
|
<H2><a name="CCache_nn16">17.15 DIFFERENCES FROM COMPILERCACHE</a></H2>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The biggest differences between Erik's compilercache script and ccache
|
||||||
|
are:
|
||||||
|
<ul>
|
||||||
|
<li> ccache is written in C, which makes it a bit faster (calling out to
|
||||||
|
external programs is mostly what slowed down the scripts).
|
||||||
|
<li> ccache can automatically find the real compiler
|
||||||
|
<li> ccache keeps statistics on hits/misses
|
||||||
|
<li> ccache can do automatic cache management
|
||||||
|
<li> ccache can cache compiler output that includes warnings. In many
|
||||||
|
cases this gives ccache a much higher cache hit rate.
|
||||||
|
<li> ccache can handle a much wider ranger of compiler options
|
||||||
|
<li> ccache avoids a double call to cpp on a cache miss
|
||||||
|
</ul>
|
||||||
|
<p>
|
||||||
|
<H2><a name="CCache_nn17">17.16 CREDITS</a></H2>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Thanks to the following people for their contributions to ccache
|
||||||
|
<ul>
|
||||||
|
<li> Erik Thiele for the original compilercache script
|
||||||
|
<li> Luciano Rocha for the idea of compiling the pre-processor output
|
||||||
|
to avoid a 2nd cpp pass
|
||||||
|
<li> Paul Russell for many suggestions and the debian packaging
|
||||||
|
</ul>
|
||||||
|
<p>
|
||||||
|
<H2><a name="CCache_nn18">17.17 AUTHOR</a></H2>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
ccache was written by Andrew Tridgell
|
||||||
|
<a href="http://samba.org/~tridge/">http://samba.org/~tridge/</a>.
|
||||||
|
ccache was adapted to create ccache-swig for use with SWIG by William Fulton.
|
||||||
|
<p>
|
||||||
|
If you wish to report a problem or make a suggestion then please email
|
||||||
|
the SWIG developers on the swig-devel mailing list, see
|
||||||
|
<a href="http://www.swig.org/mail.html">http://www.swig.org/mail.html</a>
|
||||||
|
<p>
|
||||||
|
ccache is released under the GNU General Public License version 2 or
|
||||||
|
later. Please see the file COPYING for license details.
|
||||||
|
<p>
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>SWIG and C++11</title>
|
<title>SWIG and C++11</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
<H1><a name="CPlusPlus11"></a>7 SWIG and C++11</H1>
|
<H1><a name="CPlusPlus11">7 SWIG and C++11</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -28,7 +29,7 @@
|
||||||
<li><a href="#CPlusPlus11_strongly_typed_enumerations">Strongly typed enumerations</a>
|
<li><a href="#CPlusPlus11_strongly_typed_enumerations">Strongly typed enumerations</a>
|
||||||
<li><a href="#CPlusPlus11_double_angle_brackets">Double angle brackets</a>
|
<li><a href="#CPlusPlus11_double_angle_brackets">Double angle brackets</a>
|
||||||
<li><a href="#CPlusPlus11_explicit_conversion_operators">Explicit conversion operators</a>
|
<li><a href="#CPlusPlus11_explicit_conversion_operators">Explicit conversion operators</a>
|
||||||
<li><a href="#CPlusPlus11_alias_templates">Alias templates</a>
|
<li><a href="#CPlusPlus11_alias_templates">Type alias and alias templates</a>
|
||||||
<li><a href="#CPlusPlus11_unrestricted_unions">Unrestricted unions</a>
|
<li><a href="#CPlusPlus11_unrestricted_unions">Unrestricted unions</a>
|
||||||
<li><a href="#CPlusPlus11_variadic_templates">Variadic templates</a>
|
<li><a href="#CPlusPlus11_variadic_templates">Variadic templates</a>
|
||||||
<li><a href="#CPlusPlus11_new_string_literals">New string literals</a>
|
<li><a href="#CPlusPlus11_new_string_literals">New string literals</a>
|
||||||
|
|
@ -51,7 +52,7 @@
|
||||||
<li><a href="#CPlusPlus11_general_purpose_smart_pointers">General-purpose smart pointers</a>
|
<li><a href="#CPlusPlus11_general_purpose_smart_pointers">General-purpose smart pointers</a>
|
||||||
<li><a href="#CPlusPlus11_extensible_random_number_facility">Extensible random number facility</a>
|
<li><a href="#CPlusPlus11_extensible_random_number_facility">Extensible random number facility</a>
|
||||||
<li><a href="#CPlusPlus11_wrapper_reference">Wrapper reference</a>
|
<li><a href="#CPlusPlus11_wrapper_reference">Wrapper reference</a>
|
||||||
<li><a href="#CPlusPlus11_polymorphous_wrappers_for_function_objects">Polymorphous wrappers for function objects</a>
|
<li><a href="#CPlusPlus11_polymorphous_wrappers_for_function_objects">Polymorphic wrappers for function objects</a>
|
||||||
<li><a href="#CPlusPlus11_type_traits_for_metaprogramming">Type traits for metaprogramming</a>
|
<li><a href="#CPlusPlus11_type_traits_for_metaprogramming">Type traits for metaprogramming</a>
|
||||||
<li><a href="#CPlusPlus11_uniform_method_for_computing_return_type_of_function_objects">Uniform method for computing return type of function objects</a>
|
<li><a href="#CPlusPlus11_uniform_method_for_computing_return_type_of_function_objects">Uniform method for computing return type of function objects</a>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
@ -61,7 +62,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="CPlusPlus11_introduction"></a>7.1 Introduction</H2>
|
<H2><a name="CPlusPlus11_introduction">7.1 Introduction</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>This chapter gives you a brief overview about the SWIG
|
<p>This chapter gives you a brief overview about the SWIG
|
||||||
|
|
@ -76,10 +77,10 @@ users are welcome to help by adapting the existing container interface files and
|
||||||
as a patch for inclusion in future versions of SWIG.
|
as a patch for inclusion in future versions of SWIG.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="CPlusPlus11_core_language_changes"></a>7.2 Core language changes</H2>
|
<H2><a name="CPlusPlus11_core_language_changes">7.2 Core language changes</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_rvalue_reference_and_move_semantics"></a>7.2.1 Rvalue reference and move semantics</H3>
|
<H3><a name="CPlusPlus11_rvalue_reference_and_move_semantics">7.2.1 Rvalue reference and move semantics</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -121,7 +122,7 @@ example.i:18: Warning 503: Can't wrap 'operator =' unless renamed to a valid ide
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_generalized_constant_expressions"></a>7.2.2 Generalized constant expressions</H3>
|
<H3><a name="CPlusPlus11_generalized_constant_expressions">7.2.2 Generalized constant expressions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>SWIG parses and identifies the keyword <tt>constexpr</tt>, but cannot fully utilise it.
|
<p>SWIG parses and identifies the keyword <tt>constexpr</tt>, but cannot fully utilise it.
|
||||||
|
|
@ -138,7 +139,7 @@ constexpr int YYY = XXX() + 100;
|
||||||
When either of these is used from a target language, a runtime call is made to obtain the underlying constant.
|
When either of these is used from a target language, a runtime call is made to obtain the underlying constant.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_extern_template"></a>7.2.3 Extern template</H3>
|
<H3><a name="CPlusPlus11_extern_template">7.2.3 Extern template</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>SWIG correctly parses the keywords <tt>extern template</tt>.
|
<p>SWIG correctly parses the keywords <tt>extern template</tt>.
|
||||||
|
|
@ -151,7 +152,7 @@ extern template class std::vector<int>; // C++11 explicit instantiation su
|
||||||
%template(VectorInt) std::vector<int>; // SWIG instantiation
|
%template(VectorInt) std::vector<int>; // SWIG instantiation
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_initializer_lists"></a>7.2.4 Initializer lists</H3>
|
<H3><a name="CPlusPlus11_initializer_lists">7.2.4 Initializer lists</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -283,7 +284,7 @@ Note that the default typemap for <tt>std::initializer_list</tt> does nothing bu
|
||||||
and hence any user supplied typemaps will override it and suppress the warning.
|
and hence any user supplied typemaps will override it and suppress the warning.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_uniform_initialization"></a>7.2.5 Uniform initialization</H3>
|
<H3><a name="CPlusPlus11_uniform_initialization">7.2.5 Uniform initialization</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>The curly brackets {} for member initialization are fully
|
<p>The curly brackets {} for member initialization are fully
|
||||||
|
|
@ -316,7 +317,7 @@ AltStruct var2{2, 4.3}; // calls the constructor
|
||||||
142.15
|
142.15
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_type_inference"></a>7.2.6 Type inference</H3>
|
<H3><a name="CPlusPlus11_type_inference">7.2.6 Type inference</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>SWIG supports <tt>decltype()</tt> with some limitations. Single
|
<p>SWIG supports <tt>decltype()</tt> with some limitations. Single
|
||||||
|
|
@ -333,13 +334,13 @@ int i; int j;
|
||||||
decltype(i+j) k; // syntax error
|
decltype(i+j) k; // syntax error
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_range_based_for_loop"></a>7.2.7 Range-based for-loop</H3>
|
<H3><a name="CPlusPlus11_range_based_for_loop">7.2.7 Range-based for-loop</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>This feature is part of the implementation block only. SWIG
|
<p>This feature is part of the implementation block only. SWIG
|
||||||
ignores it.</p>
|
ignores it.</p>
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_lambda_functions_and_expressions"></a>7.2.8 Lambda functions and expressions</H3>
|
<H3><a name="CPlusPlus11_lambda_functions_and_expressions">7.2.8 Lambda functions and expressions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>SWIG correctly parses most of the Lambda functions syntax. For example:</p>
|
<p>SWIG correctly parses most of the Lambda functions syntax. For example:</p>
|
||||||
|
|
@ -365,7 +366,7 @@ auto six = [](int x, int y) { return x+y; }(4, 2);
|
||||||
Better support should be available in a later release.
|
Better support should be available in a later release.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_alternate_function_syntax"></a>7.2.9 Alternate function syntax</H3>
|
<H3><a name="CPlusPlus11_alternate_function_syntax">7.2.9 Alternate function syntax</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>SWIG fully supports the new definition of functions. For example:</p>
|
<p>SWIG fully supports the new definition of functions. For example:</p>
|
||||||
|
|
@ -400,7 +401,7 @@ auto SomeStruct::FuncName(int x, int y) -> int {
|
||||||
auto square(float a, float b) -> decltype(a);
|
auto square(float a, float b) -> decltype(a);
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_object_construction_improvement"></a>7.2.10 Object construction improvement</H3>
|
<H3><a name="CPlusPlus11_object_construction_improvement">7.2.10 Object construction improvement</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -463,7 +464,7 @@ public:
|
||||||
};
|
};
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_explicit_overrides_final"></a>7.2.11 Explicit overrides and final</H3>
|
<H3><a name="CPlusPlus11_explicit_overrides_final">7.2.11 Explicit overrides and final</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -487,12 +488,12 @@ struct DerivedStruct : BaseStruct {
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_null_pointer_constant"></a>7.2.12 Null pointer constant</H3>
|
<H3><a name="CPlusPlus11_null_pointer_constant">7.2.12 Null pointer constant</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>The <tt>nullptr</tt> constant is mostly unimportant in wrappers. In the few places it has an effect, it is treated like <tt>NULL</tt>.</p>
|
<p>The <tt>nullptr</tt> constant is mostly unimportant in wrappers. In the few places it has an effect, it is treated like <tt>NULL</tt>.</p>
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_strongly_typed_enumerations"></a>7.2.13 Strongly typed enumerations</H3>
|
<H3><a name="CPlusPlus11_strongly_typed_enumerations">7.2.13 Strongly typed enumerations</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>SWIG supports strongly typed enumerations and parses the new <tt>enum class</tt> syntax and forward declarator for the enums, such as:</p>
|
<p>SWIG supports strongly typed enumerations and parses the new <tt>enum class</tt> syntax and forward declarator for the enums, such as:</p>
|
||||||
|
|
@ -548,7 +549,7 @@ The equivalent in Java is:
|
||||||
System.out.println(Color.RainbowColors.Red.swigValue() + " " + Color.WarmColors.Red.swigValue() + " " + Color.PrimeColors.Red.swigValue());
|
System.out.println(Color.RainbowColors.Red.swigValue() + " " + Color.WarmColors.Red.swigValue() + " " + Color.PrimeColors.Red.swigValue());
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_double_angle_brackets"></a>7.2.14 Double angle brackets</H3>
|
<H3><a name="CPlusPlus11_double_angle_brackets">7.2.14 Double angle brackets</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>SWIG correctly parses the symbols >> as closing the
|
<p>SWIG correctly parses the symbols >> as closing the
|
||||||
|
|
@ -559,7 +560,7 @@ shift operator >> otherwise.</p>
|
||||||
std::vector<std::vector<int>> myIntTable;
|
std::vector<std::vector<int>> myIntTable;
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_explicit_conversion_operators"></a>7.2.15 Explicit conversion operators</H3>
|
<H3><a name="CPlusPlus11_explicit_conversion_operators">7.2.15 Explicit conversion operators</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>SWIG correctly parses the keyword <tt>explicit</tt> for operators in addition to constructors now.
|
<p>SWIG correctly parses the keyword <tt>explicit</tt> for operators in addition to constructors now.
|
||||||
|
|
@ -602,37 +603,11 @@ Conversion operators either with or without <tt>explicit</tt> need renaming to a
|
||||||
them available as a normal proxy method.
|
them available as a normal proxy method.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_alias_templates"></a>7.2.16 Alias templates</H3>
|
<H3><a name="CPlusPlus11_alias_templates">7.2.16 Type alias and alias templates</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
The following is an example of an alias template:
|
A type alias is a statement of the form:
|
||||||
|
|
||||||
<div class="code"><pre>
|
|
||||||
template< typename T1, typename T2, int >
|
|
||||||
class SomeType {
|
|
||||||
public:
|
|
||||||
T1 a;
|
|
||||||
T2 b;
|
|
||||||
int c;
|
|
||||||
};
|
|
||||||
|
|
||||||
template< typename T2 >
|
|
||||||
using TypedefName = SomeType<char*, T2, 5>;
|
|
||||||
</pre></div>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
These are partially supported as SWIG will parse these and identify them, however, they are ignored as they are not added to the type system. A warning such as the following is issued:
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div class="shell">
|
|
||||||
<pre>
|
|
||||||
example.i:13: Warning 342: The 'using' keyword in template aliasing is not fully supported yet.
|
|
||||||
</pre>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
Similarly for non-template type aliasing:
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="code"><pre>
|
<div class="code"><pre>
|
||||||
|
|
@ -640,23 +615,44 @@ using PFD = void (*)(double); // New introduced syntax
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
A warning will be issued:
|
which is equivalent to the old style typedef:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="shell">
|
|
||||||
<pre>
|
|
||||||
example.i:17: Warning 341: The 'using' keyword in type aliasing is not fully supported yet.
|
|
||||||
</pre>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<p>The equivalent old style typedefs can be used as a workaround:</p>
|
|
||||||
|
|
||||||
<div class="code"><pre>
|
<div class="code"><pre>
|
||||||
typedef void (*PFD)(double); // The old style
|
typedef void (*PFD)(double); // The old style
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_unrestricted_unions"></a>7.2.17 Unrestricted unions</H3>
|
<p>
|
||||||
|
The following is an example of an alias template:
|
||||||
|
|
||||||
|
<div class="code"><pre>
|
||||||
|
template< typename T1, typename T2, int N >
|
||||||
|
class SomeType {
|
||||||
|
public:
|
||||||
|
T1 a;
|
||||||
|
T2 b;
|
||||||
|
};
|
||||||
|
|
||||||
|
template< typename T2 >
|
||||||
|
using TypedefName = SomeType<char*, T2, 5>;
|
||||||
|
</pre></div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
SWIG supports both type aliasing and alias templates.
|
||||||
|
However, in order to use an alias template, two <tt>%template</tt> directives must be used:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="code"><pre>
|
||||||
|
%template(SomeTypeBool) SomeType<char*, bool, 5>;
|
||||||
|
%template() TypedefName<bool>;
|
||||||
|
</pre></div>
|
||||||
|
|
||||||
|
<p>Firstly, the actual template is instantiated with a name to be used by the target language, as per any template being wrapped.
|
||||||
|
Secondly, the empty template instantiation, <tt>%template()</tt>, is required for the alias template.
|
||||||
|
This second requirement is necessary to add the appropriate instantiated template type into the type system as SWIG does not automatically instantiate templates.
|
||||||
|
See the <a href="SWIGPlus.html#SWIGPlus_nn30">Templates</a> section for more general information on wrapping templates.
|
||||||
|
|
||||||
|
<H3><a name="CPlusPlus11_unrestricted_unions">7.2.17 Unrestricted unions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>SWIG fully supports any type inside a union even if it does not
|
<p>SWIG fully supports any type inside a union even if it does not
|
||||||
|
|
@ -682,7 +678,7 @@ union P {
|
||||||
} p1;
|
} p1;
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_variadic_templates"></a>7.2.18 Variadic templates</H3>
|
<H3><a name="CPlusPlus11_variadic_templates">7.2.18 Variadic templates</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>SWIG supports the variadic templates syntax (inside the <>
|
<p>SWIG supports the variadic templates syntax (inside the <>
|
||||||
|
|
@ -717,7 +713,7 @@ const int SIZE = sizeof...(ClassName<int, int>);
|
||||||
In the above example <tt>SIZE</tt> is of course wrapped as a constant.
|
In the above example <tt>SIZE</tt> is of course wrapped as a constant.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_new_string_literals"></a>7.2.19 New string literals</H3>
|
<H3><a name="CPlusPlus11_new_string_literals">7.2.19 New string literals</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>SWIG supports wide string and Unicode string constants and raw string literals.</p>
|
<p>SWIG supports wide string and Unicode string constants and raw string literals.</p>
|
||||||
|
|
@ -747,7 +743,7 @@ Note: There is a bug currently where SWIG's preprocessor incorrectly parses an o
|
||||||
inside raw string literals.
|
inside raw string literals.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_user_defined_literals"></a>7.2.20 User-defined literals</H3>
|
<H3><a name="CPlusPlus11_user_defined_literals">7.2.20 User-defined literals</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -814,7 +810,7 @@ OutputType var2 = 1234_suffix;
|
||||||
OutputType var3 = 3.1416_suffix;
|
OutputType var3 = 3.1416_suffix;
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_thread_local_storage"></a>7.2.21 Thread-local storage</H3>
|
<H3><a name="CPlusPlus11_thread_local_storage">7.2.21 Thread-local storage</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>SWIG correctly parses the <tt>thread_local</tt> keyword. For example, variables
|
<p>SWIG correctly parses the <tt>thread_local</tt> keyword. For example, variables
|
||||||
|
|
@ -834,7 +830,7 @@ A variable will be thread local if accessed from different threads from the targ
|
||||||
same way that it will be thread local if accessed from C++ code.
|
same way that it will be thread local if accessed from C++ code.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_defaulted_deleted"></a>7.2.22 Explicitly defaulted functions and deleted functions</H3>
|
<H3><a name="CPlusPlus11_defaulted_deleted">7.2.22 Explicitly defaulted functions and deleted functions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>SWIG handles explicitly defaulted functions, that is, <tt>= default</tt> added to a function declaration. Deleted definitions, which are also called deleted functions, have <tt>= delete</tt> added to the function declaration.
|
<p>SWIG handles explicitly defaulted functions, that is, <tt>= default</tt> added to a function declaration. Deleted definitions, which are also called deleted functions, have <tt>= delete</tt> added to the function declaration.
|
||||||
|
|
@ -872,12 +868,12 @@ This is a C++ compile time check and SWIG does not make any attempt to detect if
|
||||||
so in this case it is entirely possible to pass an int instead of a double to <tt>f</tt> from Java, Python etc.
|
so in this case it is entirely possible to pass an int instead of a double to <tt>f</tt> from Java, Python etc.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_type_long_long_int"></a>7.2.23 Type long long int</H3>
|
<H3><a name="CPlusPlus11_type_long_long_int">7.2.23 Type long long int</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>SWIG correctly parses and uses the new <tt>long long</tt> type already introduced in C99 some time ago.</p>
|
<p>SWIG correctly parses and uses the new <tt>long long</tt> type already introduced in C99 some time ago.</p>
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_static_assertions"></a>7.2.24 Static assertions</H3>
|
<H3><a name="CPlusPlus11_static_assertions">7.2.24 Static assertions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -892,7 +888,7 @@ struct Check {
|
||||||
};
|
};
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_sizeof"></a>7.2.25 Allow sizeof to work on members of classes without an explicit object</H3>
|
<H3><a name="CPlusPlus11_sizeof">7.2.25 Allow sizeof to work on members of classes without an explicit object</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -913,7 +909,7 @@ const int SIZE = sizeof(A::member); // does not work with C++03. Okay with C++11
|
||||||
8
|
8
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_noexcept"></a>7.2.26 Exception specifications and noexcept</H3>
|
<H3><a name="CPlusPlus11_noexcept">7.2.26 Exception specifications and noexcept</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -929,7 +925,7 @@ int noex2(int) noexcept(true);
|
||||||
int noex3(int, bool) noexcept(false);
|
int noex3(int, bool) noexcept(false);
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_alignment"></a>7.2.27 Control and query object alignment</H3>
|
<H3><a name="CPlusPlus11_alignment">7.2.27 Control and query object alignment</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -961,7 +957,7 @@ Use the preprocessor to work around this for now:
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_attributes"></a>7.2.28 Attributes</H3>
|
<H3><a name="CPlusPlus11_attributes">7.2.28 Attributes</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -974,10 +970,10 @@ int [[attr1]] i [[attr2, attr3]];
|
||||||
[[noreturn, nothrow]] void f [[noreturn]] ();
|
[[noreturn, nothrow]] void f [[noreturn]] ();
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H2><a name="CPlusPlus11_standard_library_changes"></a>7.3 Standard library changes</H2>
|
<H2><a name="CPlusPlus11_standard_library_changes">7.3 Standard library changes</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_threading_facilities"></a>7.3.1 Threading facilities</H3>
|
<H3><a name="CPlusPlus11_threading_facilities">7.3.1 Threading facilities</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>SWIG does not currently wrap or use any of the new threading
|
<p>SWIG does not currently wrap or use any of the new threading
|
||||||
|
|
@ -985,7 +981,7 @@ classes introduced (thread, mutex, locks, condition variables, task). The main r
|
||||||
SWIG target languages offer their own threading facilities so there is limited use for them.
|
SWIG target languages offer their own threading facilities so there is limited use for them.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_tuple_types"></a>7.3.2 Tuple types</H3>
|
<H3><a name="CPlusPlus11_tuple_types">7.3.2 Tuple types</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -993,7 +989,7 @@ SWIG does not provide library files for the new tuple types yet.
|
||||||
Variadic template support requires further work to provide substantial tuple wrappers.
|
Variadic template support requires further work to provide substantial tuple wrappers.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_hash_tables"></a>7.3.3 Hash tables</H3>
|
<H3><a name="CPlusPlus11_hash_tables">7.3.3 Hash tables</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1001,14 +997,14 @@ The new hash tables in the STL are <tt>unordered_set</tt>, <tt>unordered_multise
|
||||||
These are not available in SWIG, but in principle should be easily implemented by adapting the current STL containers.
|
These are not available in SWIG, but in principle should be easily implemented by adapting the current STL containers.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_regular_expressions"></a>7.3.4 Regular expressions</H3>
|
<H3><a name="CPlusPlus11_regular_expressions">7.3.4 Regular expressions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
While SWIG could provide wrappers for the new C++11 regular expressions classes, there is little need as the target languages have their own regular expression facilities.
|
While SWIG could provide wrappers for the new C++11 regular expressions classes, there is little need as the target languages have their own regular expression facilities.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_general_purpose_smart_pointers"></a>7.3.5 General-purpose smart pointers</H3>
|
<H3><a name="CPlusPlus11_general_purpose_smart_pointers">7.3.5 General-purpose smart pointers</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1017,12 +1013,12 @@ Please see the <a href="Library.html#Library_std_shared_ptr">shared_ptr smart po
|
||||||
There is no special smart pointer handling available for <tt>std::weak_ptr</tt> and <tt>std::unique_ptr</tt> yet.
|
There is no special smart pointer handling available for <tt>std::weak_ptr</tt> and <tt>std::unique_ptr</tt> yet.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_extensible_random_number_facility"></a>7.3.6 Extensible random number facility</H3>
|
<H3><a name="CPlusPlus11_extensible_random_number_facility">7.3.6 Extensible random number facility</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>This feature extends and standardizes the standard library only and does not effect the C++ language nor SWIG.</p>
|
<p>This feature extends and standardizes the standard library only and does not effect the C++ language nor SWIG.</p>
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_wrapper_reference"></a>7.3.7 Wrapper reference</H3>
|
<H3><a name="CPlusPlus11_wrapper_reference">7.3.7 Wrapper reference</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1033,7 +1029,7 @@ Users would need to write their own typemaps if wrapper references are being use
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_polymorphous_wrappers_for_function_objects"></a>7.3.8 Polymorphous wrappers for function objects</H3>
|
<H3><a name="CPlusPlus11_polymorphous_wrappers_for_function_objects">7.3.8 Polymorphic wrappers for function objects</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1064,7 +1060,7 @@ t = Test()
|
||||||
b = t(1,2) # invoke C++ function object
|
b = t(1,2) # invoke C++ function object
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_type_traits_for_metaprogramming"></a>7.3.9 Type traits for metaprogramming</H3>
|
<H3><a name="CPlusPlus11_type_traits_for_metaprogramming">7.3.9 Type traits for metaprogramming</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>The type_traits functions to support C++ metaprogramming is useful at compile time and is aimed specifically at C++ development:</p>
|
<p>The type_traits functions to support C++ metaprogramming is useful at compile time and is aimed specifically at C++ development:</p>
|
||||||
|
|
@ -1114,7 +1110,7 @@ Then the appropriate algorithm can be called for the subset of types given by th
|
||||||
2
|
2
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="CPlusPlus11_uniform_method_for_computing_return_type_of_function_objects"></a>7.3.10 Uniform method for computing return type of function objects</H3>
|
<H3><a name="CPlusPlus11_uniform_method_for_computing_return_type_of_function_objects">7.3.10 Uniform method for computing return type of function objects</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>SWIG and C#</title>
|
<title>SWIG and C#</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
<body bgcolor="#FFFFFF">
|
<body bgcolor="#FFFFFF">
|
||||||
<H1><a name="CSharp"></a>20 SWIG and C#</H1>
|
<H1><a name="CSharp">20 SWIG and C#</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -53,7 +54,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="CSharp_introduction"></a>20.1 Introduction</H2>
|
<H2><a name="CSharp_introduction">20.1 Introduction</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -70,10 +71,10 @@ SWIG C# works equally well on non-Microsoft operating systems such as Linux, Sol
|
||||||
<p>
|
<p>
|
||||||
To get the most out of this chapter an understanding of interop is required.
|
To get the most out of this chapter an understanding of interop is required.
|
||||||
The <a href="http://msdn.microsoft.com">Microsoft Developer Network (MSDN)</a> has a good reference guide in a section titled "Interop Marshaling".
|
The <a href="http://msdn.microsoft.com">Microsoft Developer Network (MSDN)</a> has a good reference guide in a section titled "Interop Marshaling".
|
||||||
Monodoc, available from the Mono project, has a very useful section titled <a href="http://www.mono-project.com/Interop_with_Native_Libraries">Interop with native libraries</a>.
|
Monodoc, available from the Mono project, has a very useful section titled <a href="http://www.mono-project.com/docs/advanced/pinvoke/">Interop with native libraries</a>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="CSharp_introduction_swig2_compatibility"></a>20.1.1 SWIG 2 Compatibility</H3>
|
<H3><a name="CSharp_introduction_swig2_compatibility">20.1.1 SWIG 2 Compatibility</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -81,7 +82,7 @@ In order to minimize name collisions between names generated based on input to S
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="CSharp_commandline"></a>20.1.2 Additional command line options</H3>
|
<H3><a name="CSharp_commandline">20.1.2 Additional command line options</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -133,7 +134,7 @@ Note that the file extension (.cs) will not be automatically added and needs to
|
||||||
Due to possible compiler limits it is not advisable to use <tt>-outfile</tt> for large projects.
|
Due to possible compiler limits it is not advisable to use <tt>-outfile</tt> for large projects.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="CSharp_differences_java"></a>20.2 Differences to the Java module</H2>
|
<H2><a name="CSharp_differences_java">20.2 Differences to the Java module</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -232,6 +233,7 @@ javabody -> csbody
|
||||||
javafinalize -> csfinalize
|
javafinalize -> csfinalize
|
||||||
javadestruct -> csdestruct
|
javadestruct -> csdestruct
|
||||||
javadestruct_derived -> csdestruct_derived
|
javadestruct_derived -> csdestruct_derived
|
||||||
|
javainterfacecode -> csinterfacecode
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
|
|
@ -299,6 +301,9 @@ $*javaclassname -> $*csclassname
|
||||||
$javaclazzname -> $csclazzname
|
$javaclazzname -> $csclazzname
|
||||||
$javainput -> $csinput
|
$javainput -> $csinput
|
||||||
$jnicall -> $imcall
|
$jnicall -> $imcall
|
||||||
|
$javainterfacename -> $csinterfacename
|
||||||
|
$&javainterfacename -> $&csinterfacename
|
||||||
|
$*javainterfacename -> $*csinterfacename
|
||||||
</pre></div>
|
</pre></div>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
@ -539,14 +544,18 @@ unless the imclassname attribute is specified in the <a href="CSharp.html#CSharp
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
The directory <tt>Examples/csharp</tt> has a number of simple examples.
|
The directory <tt>Examples/csharp</tt> has a number of simple examples.
|
||||||
Visual Studio .NET 2003 solution and project files are available for compiling with the Microsoft .NET C# compiler on Windows.
|
Visual Studio .NET 2003 solution and project files are available for compiling with the Microsoft .NET C#
|
||||||
If your SWIG installation went well on a Unix environment and your C# compiler was detected, you should be able to type <tt>make</tt> in each example directory,
|
compiler on Windows. This also works with newer versions of Visual Studio if you allow
|
||||||
then <tt>ilrun runme.exe</tt> (Portable.NET C# compiler) or <tt>mono runme.exe</tt> (Mono C# compiler) to run the examples.
|
it to convert the solution to the latest version.
|
||||||
|
If your SWIG installation went well on a Unix environment and your C# compiler was detected, you should be able to type <tt>make</tt> in each example directory.
|
||||||
|
After SWIG has run and both the C# and C/C++ compilers have finished building,
|
||||||
|
the examples will be run, by either running <tt>runme.exe</tt> or by running
|
||||||
|
<tt>mono runme.exe</tt> (Mono C# compiler).
|
||||||
Windows users can also get the examples working using a
|
Windows users can also get the examples working using a
|
||||||
<a href="http://www.cygwin.com">Cygwin</a> or <a href="http://www.mingw.org">MinGW</a> environment for automatic configuration of the example makefiles.
|
<a href="http://www.cygwin.com">Cygwin</a> or <a href="http://www.mingw.org">MinGW</a> environment for automatic configuration of the example makefiles.
|
||||||
Any one of the three C# compilers (Portable.NET, Mono or Microsoft) can be detected from within a Cygwin or Mingw environment if installed in your path.
|
Any one of the C# compilers (Mono or Microsoft) can be detected from within a Cygwin or Mingw environment if installed in your path.
|
||||||
|
|
||||||
<H2><a name="CSharp_void_pointers"></a>20.3 Void pointers</H2>
|
<H2><a name="CSharp_void_pointers">20.3 Void pointers</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -564,7 +573,7 @@ void * f(void *v);
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H2><a name="CSharp_arrays"></a>20.4 C# Arrays</H2>
|
<H2><a name="CSharp_arrays">20.4 C# Arrays</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -576,7 +585,7 @@ with one of the following three approaches; namely the SWIG C arrays library, P/
|
||||||
pinned arrays.
|
pinned arrays.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="CSharp_arrays_swig_library"></a>20.4.1 The SWIG C arrays library</H3>
|
<H3><a name="CSharp_arrays_swig_library">20.4.1 The SWIG C arrays library</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -613,7 +622,7 @@ example.print_array(c.cast()); // Pass to C
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="CSharp_arrays_pinvoke_default_array_marshalling"></a>20.4.2 Managed arrays using P/Invoke default array marshalling</H3>
|
<H3><a name="CSharp_arrays_pinvoke_default_array_marshalling">20.4.2 Managed arrays using P/Invoke default array marshalling</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -740,7 +749,7 @@ and intermediary class method
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="CSharp_arrays_pinning"></a>20.4.3 Managed arrays using pinning</H3>
|
<H3><a name="CSharp_arrays_pinning">20.4.3 Managed arrays using pinning</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -835,7 +844,7 @@ public static extern void myArrayCopy(global::System.IntPtr jarg1, global::Syste
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="CSharp_exceptions"></a>20.5 C# Exceptions</H2>
|
<H2><a name="CSharp_exceptions">20.5 C# Exceptions</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -932,7 +941,7 @@ set so should only be used when a C# exception is not created.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="CSharp_exception_example_check_typemap"></a>20.5.1 C# exception example using "check" typemap</H3>
|
<H3><a name="CSharp_exception_example_check_typemap">20.5.1 C# exception example using "check" typemap</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1114,7 +1123,7 @@ method and C# code does not handle pending exceptions via the canthrow attribute
|
||||||
Actually it will issue this warning for any function beginning with <tt>SWIG_CSharpSetPendingException</tt>.
|
Actually it will issue this warning for any function beginning with <tt>SWIG_CSharpSetPendingException</tt>.
|
||||||
</P>
|
</P>
|
||||||
|
|
||||||
<H3><a name="CSharp_exception_example_percent_exception"></a>20.5.2 C# exception example using %exception</H3>
|
<H3><a name="CSharp_exception_example_percent_exception">20.5.2 C# exception example using %exception</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1161,7 +1170,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_negativesonly(int jarg1) {
|
||||||
SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, e.what());
|
SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, e.what());
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -1180,7 +1188,7 @@ The managed code generated does check for the pending exception as mentioned ear
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="CSharp_exception_example_exception_specifications"></a>20.5.3 C# exception example using exception specifications</H3>
|
<H3><a name="CSharp_exception_example_exception_specifications">20.5.3 C# exception example using exception specifications</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1228,7 +1236,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_evensonly(int jarg1) {
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -1237,7 +1244,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_evensonly(int jarg1) {
|
||||||
Multiple catch handlers are generated should there be more than one exception specifications declared.
|
Multiple catch handlers are generated should there be more than one exception specifications declared.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="CSharp_custom_application_exception"></a>20.5.4 Custom C# ApplicationException example</H3>
|
<H3><a name="CSharp_custom_application_exception">20.5.4 Custom C# ApplicationException example</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1371,7 +1378,7 @@ try {
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H2><a name="CSharp_directors"></a>20.6 C# Directors</H2>
|
<H2><a name="CSharp_directors">20.6 C# Directors</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1384,7 +1391,7 @@ The following sections provide information on the C# director implementation and
|
||||||
However, the <a href="Java.html#Java_directors">Java directors</a> section should also be read in order to gain more insight into directors.
|
However, the <a href="Java.html#Java_directors">Java directors</a> section should also be read in order to gain more insight into directors.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="CSharp_directors_example"></a>20.6.1 Directors example</H3>
|
<H3><a name="CSharp_directors_example">20.6.1 Directors example</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1505,7 +1512,7 @@ CSharpDerived - UIntMethod(123)
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="CSharp_directors_implementation"></a>20.6.2 Directors implementation</H3>
|
<H3><a name="CSharp_directors_implementation">20.6.2 Directors implementation</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1688,7 +1695,7 @@ void SwigDirector_Base::BaseBoolMethod(Base const &b, bool flag) {
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="CSharp_director_caveats"></a>20.6.3 Director caveats</H3>
|
<H3><a name="CSharp_director_caveats">20.6.3 Director caveats</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1736,11 +1743,11 @@ 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 Multiple modules</H2>
|
<H2><a name="CSharp_multiple_modules">20.7 Multiple modules</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
When using <a href="Modules.html">multiple modules</a> it is is possible to compile each SWIG generated wrapper
|
When using <a href="Modules.html#Modules">multiple modules</a> it is is possible to compile each SWIG generated wrapper
|
||||||
into a different assembly.
|
into a different assembly.
|
||||||
However, by default the generated code may not compile if
|
However, by default the generated code may not compile if
|
||||||
generated classes in one assembly use generated classes in another assembly.
|
generated classes in one assembly use generated classes in another assembly.
|
||||||
|
|
@ -1771,7 +1778,7 @@ the <tt>[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrows
|
||||||
if you don't want users to easily stumble upon these so called 'internal workings' of the wrappers.
|
if you don't want users to easily stumble upon these so called 'internal workings' of the wrappers.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="CSharp_typemap_examples"></a>20.8 C# Typemap examples</H2>
|
<H2><a name="CSharp_typemap_examples">20.8 C# Typemap examples</a></H2>
|
||||||
|
|
||||||
|
|
||||||
This section includes a few examples of typemaps. For more examples, you
|
This section includes a few examples of typemaps. For more examples, you
|
||||||
|
|
@ -1779,7 +1786,7 @@ might look at the files "<tt>csharp.swg</tt>" and "<tt>typemaps.i</tt>" in
|
||||||
the SWIG library.
|
the SWIG library.
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="CSharp_memory_management_member_variables"></a>20.8.1 Memory management when returning references to member variables</H3>
|
<H3><a name="CSharp_memory_management_member_variables">20.8.1 Memory management when returning references to member variables</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1903,7 +1910,7 @@ public class Bike : global::System.IDisposable {
|
||||||
Note the <tt>addReference</tt> call.
|
Note the <tt>addReference</tt> call.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="CSharp_memory_management_objects"></a>20.8.2 Memory management for objects passed to the C++ layer</H3>
|
<H3><a name="CSharp_memory_management_objects">20.8.2 Memory management for objects passed to the C++ layer</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2022,7 +2029,7 @@ The 'cscode' typemap simply adds in the specified code into the C# proxy class.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="CSharp_date_marshalling"></a>20.8.3 Date marshalling using the csin typemap and associated attributes</H3>
|
<H3><a name="CSharp_date_marshalling">20.8.3 Date marshalling using the csin typemap and associated attributes</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2308,7 +2315,7 @@ public class example {
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="CSharp_date_properties"></a>20.8.4 A date example demonstrating marshalling of C# properties</H3>
|
<H3><a name="CSharp_date_properties">20.8.4 A date example demonstrating marshalling of C# properties</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2408,7 +2415,7 @@ Some points to note:
|
||||||
<li>The 'csin' typemap has 'pre', 'post' and 'cshin' attributes, and these are all ignored in the property set. The code in these attributes must instead be replicated within the 'csvarin' typemap. The line creating the <tt>temp$csinput</tt> variable is such an example; it is identical to what is in the 'pre' attribute.
|
<li>The 'csin' typemap has 'pre', 'post' and 'cshin' attributes, and these are all ignored in the property set. The code in these attributes must instead be replicated within the 'csvarin' typemap. The line creating the <tt>temp$csinput</tt> variable is such an example; it is identical to what is in the 'pre' attribute.
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<H3><a name="CSharp_date_pre_post_directors"></a>20.8.5 Date example demonstrating the 'pre' and 'post' typemap attributes for directors</H3>
|
<H3><a name="CSharp_date_pre_post_directors">20.8.5 Date example demonstrating the 'pre' and 'post' typemap attributes for directors</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2470,7 +2477,7 @@ Pay special attention to the memory management issues, using these attributes.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="CSharp_partial_classes"></a>20.8.6 Turning wrapped classes into partial classes</H3>
|
<H3><a name="CSharp_partial_classes">20.8.6 Turning wrapped classes into partial classes</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2570,7 +2577,7 @@ demonstrating that the class contains methods calling both unmanaged code - <tt>
|
||||||
The following example is an alternative approach to adding managed code to the generated proxy class.
|
The following example is an alternative approach to adding managed code to the generated proxy class.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="CSharp_extending_proxy_class"></a>20.8.7 Extending proxy classes with additional C# code</H3>
|
<H3><a name="CSharp_extending_proxy_class">20.8.7 Extending proxy classes with additional C# code</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2609,7 +2616,7 @@ public class ExtendMe : global::System.IDisposable {
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="CSharp_enum_underlying_type"></a>20.8.8 Underlying type for enums</H3>
|
<H3><a name="CSharp_enum_underlying_type">20.8.8 Underlying type for enums</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<P>
|
<P>
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<!-- Hand-written HTML -->
|
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>SWIG and Chicken</title>
|
<title>SWIG and Chicken</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
|
|
||||||
<H1><a name="Chicken"></a>21 SWIG and Chicken</H1>
|
<H1><a name="Chicken">21 SWIG and Chicken</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -72,7 +72,7 @@
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Chicken_nn2"></a>21.1 Preliminaries</H2>
|
<H2><a name="Chicken_nn2">21.1 Preliminaries</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -89,7 +89,7 @@
|
||||||
directory for the basic steps to run SWIG CHICKEN.
|
directory for the basic steps to run SWIG CHICKEN.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Chicken_nn3"></a>21.1.1 Running SWIG in C mode</H3>
|
<H3><a name="Chicken_nn3">21.1.1 Running SWIG in C mode</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -122,7 +122,7 @@
|
||||||
object files and linked into your project.
|
object files and linked into your project.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Chicken_nn4"></a>21.1.2 Running SWIG in C++ mode</H3>
|
<H3><a name="Chicken_nn4">21.1.2 Running SWIG in C++ mode</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -151,10 +151,10 @@
|
||||||
object files and linked into your project.
|
object files and linked into your project.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Chicken_nn5"></a>21.2 Code Generation</H2>
|
<H2><a name="Chicken_nn5">21.2 Code Generation</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Chicken_nn6"></a>21.2.1 Naming Conventions</H3>
|
<H3><a name="Chicken_nn6">21.2.1 Naming Conventions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -170,7 +170,7 @@
|
||||||
<tt>%rename</tt> SWIG directive in the SWIG interface file.
|
<tt>%rename</tt> SWIG directive in the SWIG interface file.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Chicken_nn7"></a>21.2.2 Modules</H3>
|
<H3><a name="Chicken_nn7">21.2.2 Modules</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -192,7 +192,7 @@
|
||||||
(uses <i>modulename</i>))</code> CHICKEN Scheme form.
|
(uses <i>modulename</i>))</code> CHICKEN Scheme form.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Chicken_nn8"></a>21.2.3 Constants and Variables</H3>
|
<H3><a name="Chicken_nn8">21.2.3 Constants and Variables</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -229,7 +229,7 @@
|
||||||
for info on how to apply the %feature.
|
for info on how to apply the %feature.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Chicken_nn9"></a>21.2.4 Functions</H3>
|
<H3><a name="Chicken_nn9">21.2.4 Functions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -248,7 +248,7 @@
|
||||||
parameters). The return values can then be accessed with <code>(call-with-values)</code>.
|
parameters). The return values can then be accessed with <code>(call-with-values)</code>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Chicken_nn10"></a>21.2.5 Exceptions</H3>
|
<H3><a name="Chicken_nn10">21.2.5 Exceptions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>The SWIG chicken module has support for exceptions thrown from
|
<p>The SWIG chicken module has support for exceptions thrown from
|
||||||
|
|
@ -290,7 +290,7 @@
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="Chicken_nn11"></a>21.3 TinyCLOS</H2>
|
<H2><a name="Chicken_nn11">21.3 TinyCLOS</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -333,7 +333,7 @@
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Chicken_nn12"></a>21.4 Linkage</H2>
|
<H2><a name="Chicken_nn12">21.4 Linkage</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -354,7 +354,7 @@
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Chicken_nn13"></a>21.4.1 Static binary or shared library linked at compile time</H3>
|
<H3><a name="Chicken_nn13">21.4.1 Static binary or shared library linked at compile time</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>We can easily use csc to build a static binary.</p>
|
<p>We can easily use csc to build a static binary.</p>
|
||||||
|
|
@ -395,7 +395,7 @@ in which case the test script does not need to be linked with example.so. The t
|
||||||
be run with <tt>csi</tt>.
|
be run with <tt>csi</tt>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Chicken_nn14"></a>21.4.2 Building chicken extension libraries</H3>
|
<H3><a name="Chicken_nn14">21.4.2 Building chicken extension libraries</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>Building a shared library like in the above section only works if the library
|
<p>Building a shared library like in the above section only works if the library
|
||||||
|
|
@ -453,7 +453,7 @@ distributed and used by anyone, even if SWIG is not installed.</p>
|
||||||
<p>See the <tt>Examples/chicken/egg</tt> directory in the SWIG source for an example that builds
|
<p>See the <tt>Examples/chicken/egg</tt> directory in the SWIG source for an example that builds
|
||||||
two eggs, one using the first method and one using the second method.</p>
|
two eggs, one using the first method and one using the second method.</p>
|
||||||
|
|
||||||
<H3><a name="Chicken_nn15"></a>21.4.3 Linking multiple SWIG modules with TinyCLOS</H3>
|
<H3><a name="Chicken_nn15">21.4.3 Linking multiple SWIG modules with TinyCLOS</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>Linking together multiple modules that share type information using the <code>%import</code>
|
<p>Linking together multiple modules that share type information using the <code>%import</code>
|
||||||
|
|
@ -477,7 +477,7 @@ with <code>(declare (uses ...))</code>.
|
||||||
To create an extension library or an egg, just create a <tt>module_load.scm</tt> file that <code>(declare (uses ...))</code>
|
To create an extension library or an egg, just create a <tt>module_load.scm</tt> file that <code>(declare (uses ...))</code>
|
||||||
all the modules.</p>
|
all the modules.</p>
|
||||||
|
|
||||||
<H2><a name="Chicken_nn16"></a>21.5 Typemaps</H2>
|
<H2><a name="Chicken_nn16">21.5 Typemaps</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -486,7 +486,7 @@ all the modules.</p>
|
||||||
<code>Lib/chicken/chicken.swg</code>.
|
<code>Lib/chicken/chicken.swg</code>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Chicken_nn17"></a>21.6 Pointers</H2>
|
<H2><a name="Chicken_nn17">21.6 Pointers</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -519,7 +519,7 @@ all the modules.</p>
|
||||||
type. flags is either zero or SWIG_POINTER_DISOWN (see below).
|
type. flags is either zero or SWIG_POINTER_DISOWN (see below).
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Chicken_collection"></a>21.6.1 Garbage collection</H3>
|
<H3><a name="Chicken_collection">21.6.1 Garbage collection</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>If the owner flag passed to <code>SWIG_NewPointerObj</code> is 1, <code>NewPointerObj</code> will add a
|
<p>If the owner flag passed to <code>SWIG_NewPointerObj</code> is 1, <code>NewPointerObj</code> will add a
|
||||||
|
|
@ -550,7 +550,7 @@ all the modules.</p>
|
||||||
must be called manually.
|
must be called manually.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Chicken_nn18"></a>21.7 Unsupported features and known problems</H2>
|
<H2><a name="Chicken_nn18">21.7 Unsupported features and known problems</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -560,7 +560,7 @@ all the modules.</p>
|
||||||
<a href="SWIGPlus.html#SWIGPlus_default_args">%feature(compactdefaultargs)</a>.</li>
|
<a href="SWIGPlus.html#SWIGPlus_default_args">%feature(compactdefaultargs)</a>.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<H3><a name="Chicken_nn19"></a>21.7.1 TinyCLOS problems with Chicken version <= 1.92</H3>
|
<H3><a name="Chicken_nn19">21.7.1 TinyCLOS problems with Chicken version <= 1.92</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>In Chicken versions equal to or below 1.92, TinyCLOS has a limitation such that generic methods do not properly work on methods
|
<p>In Chicken versions equal to or below 1.92, TinyCLOS has a limitation such that generic methods do not properly work on methods
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<HTML>
|
<HTML>
|
||||||
<HEAD>
|
<HEAD>
|
||||||
<TITLE>SWIG Users Manual</TITLE>
|
<TITLE>SWIG Users Manual</TITLE>
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</HEAD>
|
</HEAD>
|
||||||
<BODY BGCOLOR="#ffffff">
|
<BODY BGCOLOR="#ffffff">
|
||||||
|
|
||||||
<H1><a name="Contents"></a>SWIG Users Manual</H1>
|
<H1><a name="Contents"></a>SWIG Users Manual</H1>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -142,8 +144,8 @@
|
||||||
<li><a href="SWIG.html#SWIG_nn10">Basic Type Handling</a>
|
<li><a href="SWIG.html#SWIG_nn10">Basic Type Handling</a>
|
||||||
<li><a href="SWIG.html#SWIG_nn11">Global Variables</a>
|
<li><a href="SWIG.html#SWIG_nn11">Global Variables</a>
|
||||||
<li><a href="SWIG.html#SWIG_nn12">Constants</a>
|
<li><a href="SWIG.html#SWIG_nn12">Constants</a>
|
||||||
<li><a href="SWIG.html#SWIG_nn13">A brief word about <tt>const</tt></a>
|
<li><a href="SWIG.html#SWIG_nn13">A brief word about const</a>
|
||||||
<li><a href="SWIG.html#SWIG_nn14">A cautionary tale of <tt>char *</tt></a>
|
<li><a href="SWIG.html#SWIG_nn14">A cautionary tale of char *</a>
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="SWIG.html#SWIG_nn15">Pointers and complex objects</a>
|
<li><a href="SWIG.html#SWIG_nn15">Pointers and complex objects</a>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -158,7 +160,7 @@
|
||||||
<li><a href="SWIG.html#SWIG_nn22">Passing structures by value</a>
|
<li><a href="SWIG.html#SWIG_nn22">Passing structures by value</a>
|
||||||
<li><a href="SWIG.html#SWIG_nn23">Return by value</a>
|
<li><a href="SWIG.html#SWIG_nn23">Return by value</a>
|
||||||
<li><a href="SWIG.html#SWIG_nn24">Linking to structure variables</a>
|
<li><a href="SWIG.html#SWIG_nn24">Linking to structure variables</a>
|
||||||
<li><a href="SWIG.html#SWIG_nn25">Linking to <tt>char *</tt></a>
|
<li><a href="SWIG.html#SWIG_nn25">Linking to char *</a>
|
||||||
<li><a href="SWIG.html#SWIG_nn26">Arrays</a>
|
<li><a href="SWIG.html#SWIG_nn26">Arrays</a>
|
||||||
<li><a href="SWIG.html#SWIG_readonly_variables">Creating read-only variables</a>
|
<li><a href="SWIG.html#SWIG_readonly_variables">Creating read-only variables</a>
|
||||||
<li><a href="SWIG.html#SWIG_rename_ignore">Renaming and ignoring declarations</a>
|
<li><a href="SWIG.html#SWIG_rename_ignore">Renaming and ignoring declarations</a>
|
||||||
|
|
@ -285,7 +287,7 @@
|
||||||
<li><a href="CPlusPlus11.html#CPlusPlus11_strongly_typed_enumerations">Strongly typed enumerations</a>
|
<li><a href="CPlusPlus11.html#CPlusPlus11_strongly_typed_enumerations">Strongly typed enumerations</a>
|
||||||
<li><a href="CPlusPlus11.html#CPlusPlus11_double_angle_brackets">Double angle brackets</a>
|
<li><a href="CPlusPlus11.html#CPlusPlus11_double_angle_brackets">Double angle brackets</a>
|
||||||
<li><a href="CPlusPlus11.html#CPlusPlus11_explicit_conversion_operators">Explicit conversion operators</a>
|
<li><a href="CPlusPlus11.html#CPlusPlus11_explicit_conversion_operators">Explicit conversion operators</a>
|
||||||
<li><a href="CPlusPlus11.html#CPlusPlus11_alias_templates">Alias templates</a>
|
<li><a href="CPlusPlus11.html#CPlusPlus11_alias_templates">Type alias and alias templates</a>
|
||||||
<li><a href="CPlusPlus11.html#CPlusPlus11_unrestricted_unions">Unrestricted unions</a>
|
<li><a href="CPlusPlus11.html#CPlusPlus11_unrestricted_unions">Unrestricted unions</a>
|
||||||
<li><a href="CPlusPlus11.html#CPlusPlus11_variadic_templates">Variadic templates</a>
|
<li><a href="CPlusPlus11.html#CPlusPlus11_variadic_templates">Variadic templates</a>
|
||||||
<li><a href="CPlusPlus11.html#CPlusPlus11_new_string_literals">New string literals</a>
|
<li><a href="CPlusPlus11.html#CPlusPlus11_new_string_literals">New string literals</a>
|
||||||
|
|
@ -308,7 +310,7 @@
|
||||||
<li><a href="CPlusPlus11.html#CPlusPlus11_general_purpose_smart_pointers">General-purpose smart pointers</a>
|
<li><a href="CPlusPlus11.html#CPlusPlus11_general_purpose_smart_pointers">General-purpose smart pointers</a>
|
||||||
<li><a href="CPlusPlus11.html#CPlusPlus11_extensible_random_number_facility">Extensible random number facility</a>
|
<li><a href="CPlusPlus11.html#CPlusPlus11_extensible_random_number_facility">Extensible random number facility</a>
|
||||||
<li><a href="CPlusPlus11.html#CPlusPlus11_wrapper_reference">Wrapper reference</a>
|
<li><a href="CPlusPlus11.html#CPlusPlus11_wrapper_reference">Wrapper reference</a>
|
||||||
<li><a href="CPlusPlus11.html#CPlusPlus11_polymorphous_wrappers_for_function_objects">Polymorphous wrappers for function objects</a>
|
<li><a href="CPlusPlus11.html#CPlusPlus11_polymorphous_wrappers_for_function_objects">Polymorphic wrappers for function objects</a>
|
||||||
<li><a href="CPlusPlus11.html#CPlusPlus11_type_traits_for_metaprogramming">Type traits for metaprogramming</a>
|
<li><a href="CPlusPlus11.html#CPlusPlus11_type_traits_for_metaprogramming">Type traits for metaprogramming</a>
|
||||||
<li><a href="CPlusPlus11.html#CPlusPlus11_uniform_method_for_computing_return_type_of_function_objects">Uniform method for computing return type of function objects</a>
|
<li><a href="CPlusPlus11.html#CPlusPlus11_uniform_method_for_computing_return_type_of_function_objects">Uniform method for computing return type of function objects</a>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
@ -441,6 +443,8 @@
|
||||||
<li><a href="Typemaps.html#Typemaps_special_macro_descriptor">$descriptor(type)</a>
|
<li><a href="Typemaps.html#Typemaps_special_macro_descriptor">$descriptor(type)</a>
|
||||||
<li><a href="Typemaps.html#Typemaps_special_macro_typemap">$typemap(method, typepattern)</a>
|
<li><a href="Typemaps.html#Typemaps_special_macro_typemap">$typemap(method, typepattern)</a>
|
||||||
</ul>
|
</ul>
|
||||||
|
<li><a href="Typemaps.html#Typemaps_special_variable_attributes">Special variables and typemap attributes</a>
|
||||||
|
<li><a href="Typemaps.html#Typemaps_special_variables_and_macros">Special variables combined with special variable macros</a>
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="Typemaps.html#Typemaps_nn25">Common typemap methods</a>
|
<li><a href="Typemaps.html#Typemaps_nn25">Common typemap methods</a>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -453,6 +457,7 @@
|
||||||
<li><a href="Typemaps.html#Typemaps_nn32">"argout" typemap</a>
|
<li><a href="Typemaps.html#Typemaps_nn32">"argout" typemap</a>
|
||||||
<li><a href="Typemaps.html#Typemaps_nn33">"freearg" typemap</a>
|
<li><a href="Typemaps.html#Typemaps_nn33">"freearg" typemap</a>
|
||||||
<li><a href="Typemaps.html#Typemaps_nn34">"newfree" typemap</a>
|
<li><a href="Typemaps.html#Typemaps_nn34">"newfree" typemap</a>
|
||||||
|
<li><a href="Typemaps.html#Typemaps_ret">"ret" typemap</a>
|
||||||
<li><a href="Typemaps.html#Typemaps_nn35">"memberin" typemap</a>
|
<li><a href="Typemaps.html#Typemaps_nn35">"memberin" typemap</a>
|
||||||
<li><a href="Typemaps.html#Typemaps_nn36">"varin" typemap</a>
|
<li><a href="Typemaps.html#Typemaps_nn36">"varin" typemap</a>
|
||||||
<li><a href="Typemaps.html#Typemaps_nn37">"varout" typemap</a>
|
<li><a href="Typemaps.html#Typemaps_nn37">"varout" typemap</a>
|
||||||
|
|
@ -478,7 +483,7 @@
|
||||||
<li><a href="Typemaps.html#Typemaps_runtime_type_checker_usage">Usage</a>
|
<li><a href="Typemaps.html#Typemaps_runtime_type_checker_usage">Usage</a>
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="Typemaps.html#Typemaps_overloading">Typemaps and overloading</a>
|
<li><a href="Typemaps.html#Typemaps_overloading">Typemaps and overloading</a>
|
||||||
<li><a href="Typemaps.html#Typemaps_nn48">More about <tt>%apply</tt> and <tt>%clear</tt></a>
|
<li><a href="Typemaps.html#Typemaps_nn48">More about %apply and %clear</a>
|
||||||
<li><a href="Typemaps.html#Typemaps_nn47">Passing data between typemaps</a>
|
<li><a href="Typemaps.html#Typemaps_nn47">Passing data between typemaps</a>
|
||||||
<li><a href="Typemaps.html#Typemaps_nn52">C++ "this" pointer</a>
|
<li><a href="Typemaps.html#Typemaps_nn52">C++ "this" pointer</a>
|
||||||
<li><a href="Typemaps.html#Typemaps_nn51">Where to go for more information?</a>
|
<li><a href="Typemaps.html#Typemaps_nn51">Where to go for more information?</a>
|
||||||
|
|
@ -819,13 +824,13 @@
|
||||||
<li><a href="D.html#D_code_injection_typemaps">Code injection typemaps</a>
|
<li><a href="D.html#D_code_injection_typemaps">Code injection typemaps</a>
|
||||||
<li><a href="D.html#D_special_variables">Special variable macros</a>
|
<li><a href="D.html#D_special_variables">Special variable macros</a>
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="D.html#D_features"><tt>%feature</tt>s</a>
|
<li><a href="D.html#D_features">D and %feature</a>
|
||||||
<li><a href="D.html#D_pragmas">Pragmas</a>
|
<li><a href="D.html#D_pragmas">Pragmas</a>
|
||||||
<li><a href="D.html#D_exceptions">D Exceptions</a>
|
<li><a href="D.html#D_exceptions">D Exceptions</a>
|
||||||
<li><a href="D.html#D_directors">D Directors</a>
|
<li><a href="D.html#D_directors">D Directors</a>
|
||||||
<li><a href="D.html#D_other_features">Other features</a>
|
<li><a href="D.html#D_other_features">Other features</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="D.html#D_nspace">Extended namespace support (<tt>nspace</tt>)</a>
|
<li><a href="D.html#D_nspace">Extended namespace support (nspace)</a>
|
||||||
<li><a href="D.html#D_native_pointer_support">Native pointer support</a>
|
<li><a href="D.html#D_native_pointer_support">Native pointer support</a>
|
||||||
<li><a href="D.html#D_operator_overloading">Operator overloading</a>
|
<li><a href="D.html#D_operator_overloading">Operator overloading</a>
|
||||||
<li><a href="D.html#D_test_suite">Running the test-suite</a>
|
<li><a href="D.html#D_test_suite">Running the test-suite</a>
|
||||||
|
|
@ -845,8 +850,8 @@
|
||||||
<li><a href="Go.html#Go_examples">Examples</a>
|
<li><a href="Go.html#Go_examples">Examples</a>
|
||||||
<li><a href="Go.html#Go_running_swig">Running SWIG with Go</a>
|
<li><a href="Go.html#Go_running_swig">Running SWIG with Go</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="Go.html#Go_commandline">Additional Commandline Options</a>
|
<li><a href="Go.html#Go_commandline">Go-specific Commandline Options</a>
|
||||||
<li><a href="Go.html#Go_outputs">Go Output Files</a>
|
<li><a href="Go.html#Go_outputs">Generated Wrapper Files</a>
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="Go.html#Go_basic_tour">A tour of basic C/C++ wrapping</a>
|
<li><a href="Go.html#Go_basic_tour">A tour of basic C/C++ wrapping</a>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -861,6 +866,16 @@
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="Go.html#Go_templates">Go Templates</a>
|
<li><a href="Go.html#Go_templates">Go Templates</a>
|
||||||
<li><a href="Go.html#Go_director_classes">Go Director Classes</a>
|
<li><a href="Go.html#Go_director_classes">Go Director Classes</a>
|
||||||
|
<ul>
|
||||||
|
<li><a href="Go.html#Go_director_example_cpp_code">Example C++ code</a>
|
||||||
|
<li><a href="Go.html#Go_director_enable">Enable director feature</a>
|
||||||
|
<li><a href="Go.html#Go_director_ctor_dtor">Constructor and destructor</a>
|
||||||
|
<li><a href="Go.html#Go_director_overriding">Override virtual methods</a>
|
||||||
|
<li><a href="Go.html#Go_director_base_methods">Call base methods</a>
|
||||||
|
<li><a href="Go.html#Go_director_subclass">Subclass via embedding</a>
|
||||||
|
<li><a href="Go.html#Go_director_finalizer">Memory management with runtime.SetFinalizer</a>
|
||||||
|
<li><a href="Go.html#Go_director_foobargo_class">Complete FooBarGo example class</a>
|
||||||
|
</ul>
|
||||||
<li><a href="Go.html#Go_primitive_type_mappings">Default Go primitive type mappings</a>
|
<li><a href="Go.html#Go_primitive_type_mappings">Default Go primitive type mappings</a>
|
||||||
<li><a href="Go.html#Go_output_arguments">Output arguments</a>
|
<li><a href="Go.html#Go_output_arguments">Output arguments</a>
|
||||||
<li><a href="Go.html#Go_adding_additional_code">Adding additional go code</a>
|
<li><a href="Go.html#Go_adding_additional_code">Adding additional go code</a>
|
||||||
|
|
@ -953,6 +968,10 @@
|
||||||
<li><a href="Java.html#Java_namespaces">C++ namespaces</a>
|
<li><a href="Java.html#Java_namespaces">C++ namespaces</a>
|
||||||
<li><a href="Java.html#Java_templates">C++ templates</a>
|
<li><a href="Java.html#Java_templates">C++ templates</a>
|
||||||
<li><a href="Java.html#Java_smart_pointers">C++ Smart Pointers</a>
|
<li><a href="Java.html#Java_smart_pointers">C++ Smart Pointers</a>
|
||||||
|
<ul>
|
||||||
|
<li><a href="Java.html#Java_smart_pointers_shared_ptr">The shared_ptr Smart Pointer</a>
|
||||||
|
<li><a href="Java.html#Java_smart_pointers_generic">Generic Smart Pointers</a>
|
||||||
|
</ul>
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="Java.html#Java_further_details">Further details on the generated Java classes</a>
|
<li><a href="Java.html#Java_further_details">Further details on the generated Java classes</a>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -979,6 +998,7 @@
|
||||||
<li><a href="Java.html#Java_proper_enums_classes">Proper Java enum classes</a>
|
<li><a href="Java.html#Java_proper_enums_classes">Proper Java enum classes</a>
|
||||||
<li><a href="Java.html#Java_typeunsafe_enums_classes">Type unsafe enum classes</a>
|
<li><a href="Java.html#Java_typeunsafe_enums_classes">Type unsafe enum classes</a>
|
||||||
</ul>
|
</ul>
|
||||||
|
<li><a href="Java.html#Java_interfaces">Interfaces</a>
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="Java.html#Java_directors">Cross language polymorphism using directors</a>
|
<li><a href="Java.html#Java_directors">Cross language polymorphism using directors</a>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -1070,7 +1090,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="Javascript.html#Javascript_embedded_webkit">Embedded Webkit</a>
|
<li><a href="Javascript.html#Javascript_embedded_webkit">Embedded Webkit</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="Javascript.html#Javascript_osx">OSX</a>
|
<li><a href="Javascript.html#Javascript_osx">Mac OS X</a>
|
||||||
<li><a href="Javascript.html#Javascript_gtk">GTK</a>
|
<li><a href="Javascript.html#Javascript_gtk">GTK</a>
|
||||||
</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>
|
||||||
|
|
@ -1273,10 +1293,10 @@
|
||||||
<li><a href="Ocaml.html#Ocaml_nn24">Overriding Methods in Ocaml</a>
|
<li><a href="Ocaml.html#Ocaml_nn24">Overriding Methods in Ocaml</a>
|
||||||
<li><a href="Ocaml.html#Ocaml_nn25">Director Usage Example</a>
|
<li><a href="Ocaml.html#Ocaml_nn25">Director Usage Example</a>
|
||||||
<li><a href="Ocaml.html#Ocaml_nn26">Creating director objects</a>
|
<li><a href="Ocaml.html#Ocaml_nn26">Creating director objects</a>
|
||||||
<li><a href="Ocaml.html#Ocaml_nn27">Typemaps for directors, <tt>directorin, directorout, directorargout</tt></a>
|
<li><a href="Ocaml.html#Ocaml_nn27">Typemaps for directors, directorin, directorout, directorargout</a>
|
||||||
<li><a href="Ocaml.html#Ocaml_nn28"><tt>directorin</tt> typemap</a>
|
<li><a href="Ocaml.html#Ocaml_nn28">typemap</a>
|
||||||
<li><a href="Ocaml.html#Ocaml_nn29"><tt>directorout</tt> typemap</a>
|
<li><a href="Ocaml.html#Ocaml_nn29">directorout typemap</a>
|
||||||
<li><a href="Ocaml.html#Ocaml_nn30"><tt>directorargout</tt> typemap</a>
|
<li><a href="Ocaml.html#Ocaml_nn30">directorargout typemap</a>
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="Ocaml.html#Ocaml_nn31">Exceptions</a>
|
<li><a href="Ocaml.html#Ocaml_nn31">Exceptions</a>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
@ -1310,6 +1330,10 @@
|
||||||
<li><a href="Octave.html#Octave_nn19">Class extension with %extend</a>
|
<li><a href="Octave.html#Octave_nn19">Class extension with %extend</a>
|
||||||
<li><a href="Octave.html#Octave_nn20">C++ templates</a>
|
<li><a href="Octave.html#Octave_nn20">C++ templates</a>
|
||||||
<li><a href="Octave.html#Octave_nn21">C++ Smart Pointers</a>
|
<li><a href="Octave.html#Octave_nn21">C++ Smart Pointers</a>
|
||||||
|
<ul>
|
||||||
|
<li><a href="Octave.html#Octave_smart_pointers_shared_ptr">The shared_ptr Smart Pointer</a>
|
||||||
|
<li><a href="Octave.html#Octave_smart_pointers_generic">Generic Smart Pointers</a>
|
||||||
|
</ul>
|
||||||
<li><a href="Octave.html#Octave_nn22">Directors (calling Octave from C++ code)</a>
|
<li><a href="Octave.html#Octave_nn22">Directors (calling Octave from C++ code)</a>
|
||||||
<li><a href="Octave.html#Octave_nn23">Threads</a>
|
<li><a href="Octave.html#Octave_nn23">Threads</a>
|
||||||
<li><a href="Octave.html#Octave_nn24">Memory management</a>
|
<li><a href="Octave.html#Octave_nn24">Memory management</a>
|
||||||
|
|
@ -1415,7 +1439,7 @@
|
||||||
<li><a href="Php.html#Php_nn2_5">Pointers and References</a>
|
<li><a href="Php.html#Php_nn2_5">Pointers and References</a>
|
||||||
<li><a href="Php.html#Php_nn2_6">Structures and C++ classes</a>
|
<li><a href="Php.html#Php_nn2_6">Structures and C++ classes</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="Php.html#Php_nn2_6_1">Using <tt>-noproxy</tt></a>
|
<li><a href="Php.html#Php_nn2_6_1">Using -noproxy</a>
|
||||||
<li><a href="Php.html#Php_nn2_6_2">Constructors and Destructors</a>
|
<li><a href="Php.html#Php_nn2_6_2">Constructors and Destructors</a>
|
||||||
<li><a href="Php.html#Php_nn2_6_3">Static Member Variables</a>
|
<li><a href="Php.html#Php_nn2_6_3">Static Member Variables</a>
|
||||||
<li><a href="Php.html#Php_nn2_6_4">Static Member Functions</a>
|
<li><a href="Php.html#Php_nn2_6_4">Static Member Functions</a>
|
||||||
|
|
@ -1494,6 +1518,10 @@
|
||||||
<li><a href="Python.html#Python_nn25">C++ namespaces</a>
|
<li><a href="Python.html#Python_nn25">C++ namespaces</a>
|
||||||
<li><a href="Python.html#Python_nn26">C++ templates</a>
|
<li><a href="Python.html#Python_nn26">C++ templates</a>
|
||||||
<li><a href="Python.html#Python_nn27">C++ Smart Pointers</a>
|
<li><a href="Python.html#Python_nn27">C++ Smart Pointers</a>
|
||||||
|
<ul>
|
||||||
|
<li><a href="Python.html#Python_smart_pointers_shared_ptr">The shared_ptr Smart Pointer</a>
|
||||||
|
<li><a href="Python.html#Python_smart_pointers_generic">Generic Smart Pointers</a>
|
||||||
|
</ul>
|
||||||
<li><a href="Python.html#Python_nn27a">C++ reference counted objects</a>
|
<li><a href="Python.html#Python_nn27a">C++ reference counted objects</a>
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="Python.html#Python_nn28">Further details on the Python class interface</a>
|
<li><a href="Python.html#Python_nn28">Further details on the Python class interface</a>
|
||||||
|
|
@ -1502,7 +1530,7 @@
|
||||||
<li><a href="Python.html#Python_builtin_types">Built-in Types</a>
|
<li><a href="Python.html#Python_builtin_types">Built-in Types</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="Python.html#Python_builtin_limitations">Limitations</a>
|
<li><a href="Python.html#Python_builtin_limitations">Limitations</a>
|
||||||
<li><a href="Python.html#Python_builtin_overloads">Operator overloads -- use them!</a>
|
<li><a href="Python.html#Python_builtin_overloads">Operator overloads and slots -- use them!</a>
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="Python.html#Python_nn30">Memory management</a>
|
<li><a href="Python.html#Python_nn30">Memory management</a>
|
||||||
<li><a href="Python.html#Python_nn31">Python 2.2 and classic classes</a>
|
<li><a href="Python.html#Python_nn31">Python 2.2 and classic classes</a>
|
||||||
|
|
@ -1567,6 +1595,14 @@
|
||||||
<li><a href="Python.html#Python_absrelimports">Absolute and relative imports</a>
|
<li><a href="Python.html#Python_absrelimports">Absolute and relative imports</a>
|
||||||
<li><a href="Python.html#Python_absimport">Enforcing absolute import semantics</a>
|
<li><a href="Python.html#Python_absimport">Enforcing absolute import semantics</a>
|
||||||
<li><a href="Python.html#Python_importfrominit">Importing from __init__.py</a>
|
<li><a href="Python.html#Python_importfrominit">Importing from __init__.py</a>
|
||||||
|
<li><a href="Python.html#Python_implicit_namespace_packages">Implicit Namespace Packages</a>
|
||||||
|
<li><a href="Python.html#Python_package_search">Searching for the wrapper module</a>
|
||||||
|
<ul>
|
||||||
|
<li><a href="Python.html#Python_package_search_both_package_modules">Both modules in the same package</a>
|
||||||
|
<li><a href="Python.html#Python_package_search_wrapper_split">Split modules</a>
|
||||||
|
<li><a href="Python.html#Python_package_search_both_global_modules">Both modules are global</a>
|
||||||
|
<li><a href="Python.html#Python_package_search_static">Statically linked C modules</a>
|
||||||
|
</ul>
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="Python.html#Python_python3support">Python 3 Support</a>
|
<li><a href="Python.html#Python_python3support">Python 3 Support</a>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -1574,6 +1610,7 @@
|
||||||
<li><a href="Python.html#Python_nn75">Buffer interface</a>
|
<li><a href="Python.html#Python_nn75">Buffer interface</a>
|
||||||
<li><a href="Python.html#Python_nn76">Abstract base classes</a>
|
<li><a href="Python.html#Python_nn76">Abstract base classes</a>
|
||||||
<li><a href="Python.html#Python_nn77">Byte string output conversion</a>
|
<li><a href="Python.html#Python_nn77">Byte string output conversion</a>
|
||||||
|
<li><a href="Python.html#Python_2_unicode">Python 2 Unicode</a>
|
||||||
</ul>
|
</ul>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -1631,6 +1668,10 @@
|
||||||
<li><a href="Ruby.html#Ruby_C_STL_Functors">C++ STL Functors</a>
|
<li><a href="Ruby.html#Ruby_C_STL_Functors">C++ STL Functors</a>
|
||||||
<li><a href="Ruby.html#Ruby_C_Iterators">C++ STL Iterators</a>
|
<li><a href="Ruby.html#Ruby_C_Iterators">C++ STL Iterators</a>
|
||||||
<li><a href="Ruby.html#Ruby_nn24">C++ Smart Pointers</a>
|
<li><a href="Ruby.html#Ruby_nn24">C++ Smart Pointers</a>
|
||||||
|
<ul>
|
||||||
|
<li><a href="Ruby.html#Ruby_smart_pointers_shared_ptr">The shared_ptr Smart Pointer</a>
|
||||||
|
<li><a href="Ruby.html#Ruby_smart_pointers_generic">Generic Smart Pointers</a>
|
||||||
|
</ul>
|
||||||
<li><a href="Ruby.html#Ruby_nn25">Cross-Language Polymorphism</a>
|
<li><a href="Ruby.html#Ruby_nn25">Cross-Language Polymorphism</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="Ruby.html#Ruby_nn26">Exception Unrolling</a>
|
<li><a href="Ruby.html#Ruby_nn26">Exception Unrolling</a>
|
||||||
|
|
@ -1761,11 +1802,12 @@
|
||||||
<li><a href="Scilab.html#Scilab_wrapping_pointers">Pointers</a>
|
<li><a href="Scilab.html#Scilab_wrapping_pointers">Pointers</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="Scilab.html#Scilab_wrapping_pointers_pointer_adresses">Utility functions</a>
|
<li><a href="Scilab.html#Scilab_wrapping_pointers_pointer_adresses">Utility functions</a>
|
||||||
<li><a href="Scilab.html#Scilab_wrapping_pointers_null_pointers">Null pointers</a>
|
<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_cpp_overloading">C++ overloading</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>
|
||||||
<li><a href="Scilab.html#Scilab_wrapping_cpp_operators">C++ operators</a>
|
<li><a href="Scilab.html#Scilab_wrapping_cpp_operators">C++ operators</a>
|
||||||
|
|
@ -1776,7 +1818,6 @@
|
||||||
<li><a href="Scilab.html#Scilab_typemaps">Type mappings and libraries</a>
|
<li><a href="Scilab.html#Scilab_typemaps">Type mappings and libraries</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="Scilab.html#Scilab_typemaps_primitive_types">Default primitive type mappings</a>
|
<li><a href="Scilab.html#Scilab_typemaps_primitive_types">Default primitive type mappings</a>
|
||||||
<li><a href="Scilab.html#Scilab_typemaps_non-primitive_types">Default type mappings for non-primitive types</a>
|
|
||||||
<li><a href="Scilab.html#Scilab_typemaps_arrays">Arrays</a>
|
<li><a href="Scilab.html#Scilab_typemaps_arrays">Arrays</a>
|
||||||
<li><a href="Scilab.html#Scilab_typemaps_pointer-to-pointers">Pointer-to-pointers</a>
|
<li><a href="Scilab.html#Scilab_typemaps_pointer-to-pointers">Pointer-to-pointers</a>
|
||||||
<li><a href="Scilab.html#Scilab_typemaps_matrices">Matrices</a>
|
<li><a href="Scilab.html#Scilab_typemaps_matrices">Matrices</a>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Contract Checking</title>
|
<title>Contract Checking</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
<H1><a name="Contract"></a>13 Contracts</H1>
|
<H1><a name="Contract">13 Contracts</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -38,7 +39,7 @@ When one of the rules is violated by a script, a runtime exception is
|
||||||
generated rather than having the program continue to execute.
|
generated rather than having the program continue to execute.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Contract_nn2"></a>13.1 The %contract directive</H2>
|
<H2><a name="Contract_nn2">13.1 The %contract directive</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -94,7 +95,7 @@ RuntimeError: Contract violation: require: (arg1>=0)
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H2><a name="Contract_nn3"></a>13.2 %contract and classes</H2>
|
<H2><a name="Contract_nn3">13.2 %contract and classes</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -173,7 +174,7 @@ specified for the derived class all must hold. In the above example,
|
||||||
this means that both the arguments to <tt>Spam::bar</tt> must be positive.
|
this means that both the arguments to <tt>Spam::bar</tt> must be positive.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Contract_nn4"></a>13.3 Constant aggregation and %aggregate_check</H2>
|
<H2><a name="Contract_nn4">13.3 Constant aggregation and %aggregate_check</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -262,7 +263,7 @@ Regrettably, there is no automatic way to perform similar checks with enums valu
|
||||||
release.
|
release.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Contract_nn5"></a>13.4 Notes</H2>
|
<H2><a name="Contract_nn5">13.4 Notes</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Customization Features</title>
|
<title>Customization Features</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
<H1><a name="Customization"></a>12 Customization Features</H1>
|
<H1><a name="Customization">12 Customization Features</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -45,7 +46,7 @@ of exception handling is presented. Then, a more general-purpose
|
||||||
customization mechanism known as "features" is described.
|
customization mechanism known as "features" is described.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Customization_exception"></a>12.1 Exception handling with %exception</H2>
|
<H2><a name="Customization_exception">12.1 Exception handling with %exception</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -100,7 +101,7 @@ for exception handling. That directive is deprecated--<tt>%exception</tt>
|
||||||
provides the same functionality, but is substantially more flexible.
|
provides the same functionality, but is substantially more flexible.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Customization_nn3"></a>12.1.1 Handling exceptions in C code</H3>
|
<H3><a name="Customization_nn3">12.1.1 Handling exceptions in C code</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -123,8 +124,10 @@ void clear_exception() {
|
||||||
error_status = 0;
|
error_status = 0;
|
||||||
}
|
}
|
||||||
char *check_exception() {
|
char *check_exception() {
|
||||||
if (error_status) return error_message;
|
if (error_status)
|
||||||
else return NULL;
|
return error_message;
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
@ -136,13 +139,13 @@ To use these functions, functions simply call
|
||||||
|
|
||||||
<div class="code"><pre>
|
<div class="code"><pre>
|
||||||
double inv(double x) {
|
double inv(double x) {
|
||||||
if (x != 0) return 1.0/x;
|
if (x != 0)
|
||||||
|
return 1.0/x;
|
||||||
else {
|
else {
|
||||||
throw_exception("Division by zero");
|
throw_exception("Division by zero");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -166,7 +169,7 @@ Each target language has its own approach to creating a runtime error/exception
|
||||||
and for Perl it is the <tt>croak</tt> method shown above.
|
and for Perl it is the <tt>croak</tt> method shown above.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Customization_nn4"></a>12.1.2 Exception handling with longjmp()</H3>
|
<H3><a name="Customization_nn4">12.1.2 Exception handling with longjmp()</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -206,8 +209,10 @@ Now, within a C program, you can do the following :</p>
|
||||||
|
|
||||||
<div class="code"><pre>
|
<div class="code"><pre>
|
||||||
double inv(double x) {
|
double inv(double x) {
|
||||||
if (x) return 1.0/x;
|
if (x)
|
||||||
else throw(DivisionByZero);
|
return 1.0/x;
|
||||||
|
else
|
||||||
|
throw(DivisionByZero);
|
||||||
}
|
}
|
||||||
|
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
@ -240,7 +245,7 @@ Note: This implementation is only intended to illustrate the general idea. To m
|
||||||
modify it to handle nested <tt>try</tt> declarations.
|
modify it to handle nested <tt>try</tt> declarations.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Customization_nn5"></a>12.1.3 Handling C++ exceptions</H3>
|
<H3><a name="Customization_nn5">12.1.3 Handling C++ exceptions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -275,7 +280,7 @@ class OutOfMemory {};
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Customization_allowexcept"></a>12.1.4 Exception handlers for variables</H3>
|
<H3><a name="Customization_allowexcept">12.1.4 Exception handlers for variables</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -300,7 +305,7 @@ The <tt>%allowexception</tt> feature works like any other feature and so can be
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Customization_nn6"></a>12.1.5 Defining different exception handlers</H3>
|
<H3><a name="Customization_nn6">12.1.5 Defining different exception handlers</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -437,7 +442,7 @@ declarations. However, it never really worked that well and the new
|
||||||
%exception directive is much better.
|
%exception directive is much better.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Customization_exception_special_variables"></a>12.1.6 Special variables for %exception</H3>
|
<H3><a name="Customization_exception_special_variables">12.1.6 Special variables for %exception</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -540,7 +545,7 @@ Below shows the expansions for the 1st of the overloaded <tt>something</tt> wrap
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Customization_nn7"></a>12.1.7 Using The SWIG exception library</H3>
|
<H3><a name="Customization_nn7">12.1.7 Using The SWIG exception library</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -595,7 +600,7 @@ SWIG_NullReferenceError
|
||||||
The <tt>SWIG_exception()</tt> function can also be used in typemaps.
|
The <tt>SWIG_exception()</tt> function can also be used in typemaps.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Customization_ownership"></a>12.2 Object ownership and %newobject</H2>
|
<H2><a name="Customization_ownership">12.2 Object ownership and %newobject</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -752,7 +757,7 @@ char *strdup(const char *s);
|
||||||
The results might not be what you expect.
|
The results might not be what you expect.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Customization_features"></a>12.3 Features and the %feature directive</H2>
|
<H2><a name="Customization_features">12.3 Features and the %feature directive</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -834,7 +839,7 @@ The following are all equivalent:
|
||||||
The syntax in the first variation will generate the <tt>{ }</tt> delimiters used whereas the other variations will not.
|
The syntax in the first variation will generate the <tt>{ }</tt> delimiters used whereas the other variations will not.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Customization_feature_attributes"></a>12.3.1 Feature attributes</H3>
|
<H3><a name="Customization_feature_attributes">12.3.1 Feature attributes</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -875,7 +880,7 @@ In the following example, <tt>MyExceptionClass</tt> is the name of the Java clas
|
||||||
Further details can be obtained from the <a href="Java.html#Java_exception_handling">Java exception handling</a> section.
|
Further details can be obtained from the <a href="Java.html#Java_exception_handling">Java exception handling</a> section.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Customization_feature_flags"></a>12.3.2 Feature flags</H3>
|
<H3><a name="Customization_feature_flags">12.3.2 Feature flags</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -973,7 +978,7 @@ in the <tt>swig.swg</tt> Library file. The following shows the alternative synta
|
||||||
The concept of clearing features is discussed next.
|
The concept of clearing features is discussed next.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Customization_clearing_features"></a>12.3.3 Clearing features</H3>
|
<H3><a name="Customization_clearing_features">12.3.3 Clearing features</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1066,7 +1071,7 @@ The three macros below show this for the "except" feature:
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Customization_features_default_args"></a>12.3.4 Features and default arguments</H3>
|
<H3><a name="Customization_features_default_args">12.3.4 Features and default arguments</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1141,7 +1146,7 @@ specifying or not specifying default arguments in a feature is not applicable as
|
||||||
in SWIG-1.3.23 when the approach to wrapping methods with default arguments was changed.
|
in SWIG-1.3.23 when the approach to wrapping methods with default arguments was changed.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Customization_features_example"></a>12.3.5 Feature example</H3>
|
<H3><a name="Customization_features_example">12.3.5 Feature example</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>SWIG and D</title>
|
<title>SWIG and D</title>
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
<body bgcolor="#FFFFFF">
|
<body bgcolor="#FFFFFF">
|
||||||
<H1><a name="D"></a>22 SWIG and D</H1>
|
<H1><a name="D">22 SWIG and D</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -22,13 +22,13 @@
|
||||||
<li><a href="#D_code_injection_typemaps">Code injection typemaps</a>
|
<li><a href="#D_code_injection_typemaps">Code injection typemaps</a>
|
||||||
<li><a href="#D_special_variables">Special variable macros</a>
|
<li><a href="#D_special_variables">Special variable macros</a>
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="#D_features"><tt>%feature</tt>s</a>
|
<li><a href="#D_features">D and %feature</a>
|
||||||
<li><a href="#D_pragmas">Pragmas</a>
|
<li><a href="#D_pragmas">Pragmas</a>
|
||||||
<li><a href="#D_exceptions">D Exceptions</a>
|
<li><a href="#D_exceptions">D Exceptions</a>
|
||||||
<li><a href="#D_directors">D Directors</a>
|
<li><a href="#D_directors">D Directors</a>
|
||||||
<li><a href="#D_other_features">Other features</a>
|
<li><a href="#D_other_features">Other features</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#D_nspace">Extended namespace support (<tt>nspace</tt>)</a>
|
<li><a href="#D_nspace">Extended namespace support (nspace)</a>
|
||||||
<li><a href="#D_native_pointer_support">Native pointer support</a>
|
<li><a href="#D_native_pointer_support">Native pointer support</a>
|
||||||
<li><a href="#D_operator_overloading">Operator overloading</a>
|
<li><a href="#D_operator_overloading">Operator overloading</a>
|
||||||
<li><a href="#D_test_suite">Running the test-suite</a>
|
<li><a href="#D_test_suite">Running the test-suite</a>
|
||||||
|
|
@ -41,7 +41,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="D_introduction"></a>22.1 Introduction</H2>
|
<H2><a name="D_introduction">22.1 Introduction</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>From the <a href="http://www.digitalmars.com/d/">D Programming Language</a> web site: <em>D is a systems programming language. Its focus is on combining the power and high performance of C and C++ with the programmer productivity of modern languages like Ruby and Python. [...] The D language is statically typed and compiles directly to machine code.</em> As such, it is not very surprising that D is able to directly <a href="http://www.digitalmars.com/d/1.0/interfaceToC.html">interface with C libraries</a>. Why would a SWIG module for D be needed then in the first place?</p>
|
<p>From the <a href="http://www.digitalmars.com/d/">D Programming Language</a> web site: <em>D is a systems programming language. Its focus is on combining the power and high performance of C and C++ with the programmer productivity of modern languages like Ruby and Python. [...] The D language is statically typed and compiles directly to machine code.</em> As such, it is not very surprising that D is able to directly <a href="http://www.digitalmars.com/d/1.0/interfaceToC.html">interface with C libraries</a>. Why would a SWIG module for D be needed then in the first place?</p>
|
||||||
|
|
@ -50,10 +50,10 @@
|
||||||
|
|
||||||
<p>While these issues can be worked around relatively easy by hand-coding a thin wrapper layer around the C library in question, there is another issue where writing wrapper code per hand is not feasible: C++ libraries. D did not support interfacing to C++ in version 1 at all, and even if <tt>extern(C++)</tt> has been added to D2, the support is still very limited, and a custom wrapper layer is still required in many cases. </p>
|
<p>While these issues can be worked around relatively easy by hand-coding a thin wrapper layer around the C library in question, there is another issue where writing wrapper code per hand is not feasible: C++ libraries. D did not support interfacing to C++ in version 1 at all, and even if <tt>extern(C++)</tt> has been added to D2, the support is still very limited, and a custom wrapper layer is still required in many cases. </p>
|
||||||
|
|
||||||
<p>To help addressing these issues, the SWIG C# module has been forked to support D. Is has evolved quite a lot since then, but there are still many similarities, so if you do not find what you are looking for on this page, it might be worth having a look at the chapter on <a href="CSharp.html">C#</a> (and also on <a href="Java.html">Java</a>, since the C# module was in turn forked from it).</p>
|
<p>To help addressing these issues, the SWIG C# module has been forked to support D. Is has evolved quite a lot since then, but there are still many similarities, so if you do not find what you are looking for on this page, it might be worth having a look at the chapter on <a href="CSharp.html#CSharp">C#</a> (and also on <a href="Java.html#Java">Java</a>, since the C# module was in turn forked from it).</p>
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="D_command_line_invocation"></a>22.2 Command line invocation</H2>
|
<H2><a name="D_command_line_invocation">22.2 Command line invocation</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>To activate the D module, pass the <tt>-d</tt> option to SWIG at the command line. The same standard command line switches as with any other language module are available, plus the following D specific ones:</p>
|
<p>To activate the D module, pass the <tt>-d</tt> option to SWIG at the command line. The same standard command line switches as with any other language module are available, plus the following D specific ones:</p>
|
||||||
|
|
@ -64,7 +64,7 @@
|
||||||
<p>By default, SWIG generates code for D1/Tango. Use the <tt>-d2</tt> flag to target D2/Phobos instead.</p>
|
<p>By default, SWIG generates code for D1/Tango. Use the <tt>-d2</tt> flag to target D2/Phobos instead.</p>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
<dt id="D_splitproxy"><tt>-splitproxy</tt></dt>
|
<dt><a name="D_splitproxy"></a><tt>-splitproxy</tt></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p>By default, SWIG generates two D modules: the <em>proxy</em> module, named like the source module (either specified via the <tt>%module</tt> directive or via the <tt>module</tt> command line switch), which contains all the proxy classes, functions, enums, etc., and the <em>intermediary</em> module (named like the proxy module, but suffixed with <tt>_im</tt>), which contains all the <tt>extern(C)</tt> function declarations and other private parts only used internally by the proxy module.</p>
|
<p>By default, SWIG generates two D modules: the <em>proxy</em> module, named like the source module (either specified via the <tt>%module</tt> directive or via the <tt>module</tt> command line switch), which contains all the proxy classes, functions, enums, etc., and the <em>intermediary</em> module (named like the proxy module, but suffixed with <tt>_im</tt>), which contains all the <tt>extern(C)</tt> function declarations and other private parts only used internally by the proxy module.</p>
|
||||||
<p>If the split proxy mode is enabled by passing this switch at the command line, all proxy classes and enums are emitted to their own D module instead. The main proxy module only contains free functions and constants in this case.</p>
|
<p>If the split proxy mode is enabled by passing this switch at the command line, all proxy classes and enums are emitted to their own D module instead. The main proxy module only contains free functions and constants in this case.</p>
|
||||||
|
|
@ -83,10 +83,10 @@
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="D_typemaps"></a>22.3 Typemaps</H2>
|
<H2><a name="D_typemaps">22.3 Typemaps</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="D_typemap_name_comparison"></a>22.3.1 C# <-> D name comparison</H3>
|
<H3><a name="D_typemap_name_comparison">22.3.1 C# <-> D name comparison</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>If you already know the SWIG C# module, you might find the following name comparison table useful:</p>
|
<p>If you already know the SWIG C# module, you might find the following name comparison table useful:</p>
|
||||||
|
|
@ -112,7 +112,7 @@
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="D_ctype_imtype_dtype"></a>22.3.2 ctype, imtype, dtype</H3>
|
<H3><a name="D_ctype_imtype_dtype">22.3.2 ctype, imtype, dtype</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>Mapping of types between the C/C++ library, the C/C++ library wrapper exposing the C functions, the D wrapper module importing these functions and the D proxy code.</p>
|
<p>Mapping of types between the C/C++ library, the C/C++ library wrapper exposing the C functions, the D wrapper module importing these functions and the D proxy code.</p>
|
||||||
|
|
@ -120,26 +120,26 @@
|
||||||
<p>The <tt>ctype</tt> typemap is used to determine the types to use in the C wrapper functions. The types from the <tt>imtype</tt> typemap are used in the extern(C) declarations of these functions in the intermediary D module. The <tt>dtype</tt> typemap contains the D types used in the D proxy module/class.</p>
|
<p>The <tt>ctype</tt> typemap is used to determine the types to use in the C wrapper functions. The types from the <tt>imtype</tt> typemap are used in the extern(C) declarations of these functions in the intermediary D module. The <tt>dtype</tt> typemap contains the D types used in the D proxy module/class.</p>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="D_in_out_directorin_direcetorout"></a>22.3.3 in, out, directorin, directorout</H3>
|
<H3><a name="D_in_out_directorin_direcetorout">22.3.3 in, out, directorin, directorout</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>Used for converting between the types for C/C++ and D when generating the code for the wrapper functions (on the C++ side).</p>
|
<p>Used for converting between the types for C/C++ and D when generating the code for the wrapper functions (on the C++ side).</p>
|
||||||
|
|
||||||
<p>The code from the <tt>in</tt> typemap is used to convert arguments to the C wrapper function to the type used in the wrapped code (<tt>ctype</tt>->original C++ type), the <tt>out</tt> typemap is utilized to convert values from the wrapped code to wrapper function return types (original C++ type-><tt>ctype</tt>).</p>
|
<p>The code from the <tt>in</tt> typemap is used to convert arguments to the C wrapper function to the type used in the wrapped code (<tt>ctype</tt>->original C++ type), the <tt>out</tt> typemap is utilized to convert values from the wrapped code to wrapper function return types (original C++ type-><tt>ctype</tt>).</p>
|
||||||
|
|
||||||
<p>The <tt>directorin</tt> typemap is used to convert parameters to the type used in the D director callback function, its return value is processed by <tt>directorout</tt> (see below).</p>
|
<p>The <tt>directorin</tt> typemap is used to convert parameters to the type used in the D director callback function, its return value is processed by <tt>directorout</tt> (see below).</p>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="D_din_dout_ddirectorin_ddirectorout"></a>22.3.4 din, dout, ddirectorin, ddirectorout</H3>
|
<H3><a name="D_din_dout_ddirectorin_ddirectorout">22.3.4 din, dout, ddirectorin, ddirectorout</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>Typemaps for code generation in D proxy and type wrapper classes.</p>
|
<p>Typemaps for code generation in D proxy and type wrapper classes.</p>
|
||||||
|
|
||||||
<p id="D_din">The <tt>din</tt> typemap is used for converting function parameter types from the type used in the proxy module or class to the type used in the intermediary D module (the <a href="D.html#D_dinput"><tt>$dinput</tt></a> macro is replaced). To inject further parameter processing code before or after the call to the intermediary layer, the <tt>pre</tt>, <tt>post</tt> and <tt>terminator</tt> attributes can be used (please refer to the <a href="CSharp.html#CSharp_date_marshalling">C# date marshalling example</a> for more information on these).</p>
|
<p><a name="D_din"></a>The <tt>din</tt> typemap is used for converting function parameter types from the type used in the proxy module or class to the type used in the intermediary D module (the <a href="D.html#D_dinput">$dinput</a> macro is replaced). To inject further parameter processing code before or after the call to the intermediary layer, the <tt>pre</tt>, <tt>post</tt> and <tt>terminator</tt> attributes can be used (please refer to the <a href="CSharp.html#CSharp_date_marshalling">C# date marshalling example</a> for more information on these).</p>
|
||||||
|
|
||||||
<p id="D_dout">The <tt>dout</tt> typemap is used for converting function return values from the return type used in the intermediary D module to the type returned by the proxy function. The <tt>$excode</tt> special variable in <tt>dout</tt> typemaps is replaced by the <tt>excode</tt> typemap attribute code if the method can throw any exceptions from unmanaged code, otherwise by nothing (the <a href="D.html#D_imcall"><tt>$imcall</tt> and <tt>$owner</tt></a> macros are replaced).</p>
|
<p><a name="D_dout"></a>The <tt>dout</tt> typemap is used for converting function return values from the return type used in the intermediary D module to the type returned by the proxy function. The <tt>$excode</tt> special variable in <tt>dout</tt> typemaps is replaced by the <tt>excode</tt> typemap attribute code if the method can throw any exceptions from unmanaged code, otherwise by nothing (the <a href="D.html#D_imcall"><tt>$imcall</tt> and <tt>$owner</tt></a> macros are replaced).</p>
|
||||||
|
|
||||||
<p id="D_ddirectorinout">The code from the <tt>ddirectorin</tt> and <tt>ddirectorout</tt> typemaps is used for conversion in director callback functions. Arguments are converted to the type used in the proxy class method they are calling by using the code from <tt>ddirectorin</tt>, the proxy class method return value is converted to the type the C++ code expects via the <tt>ddirectorout</tt> typemap (the <a href="D.html#D_dpcall"><tt>$dcall</tt> and <tt>$winput</tt></a> macros are replaced).</p>
|
<p><a name="D_ddirectorinout"></a>The code from the <tt>ddirectorin</tt> and <tt>ddirectorout</tt> typemaps is used for conversion in director callback functions. Arguments are converted to the type used in the proxy class method they are calling by using the code from <tt>ddirectorin</tt>, the proxy class method return value is converted to the type the C++ code expects via the <tt>ddirectorout</tt> typemap (the <a href="D.html#D_dpcall"><tt>$dcall</tt> and <tt>$winput</tt></a> macros are replaced).</p>
|
||||||
|
|
||||||
<p>The full chain of type conversions when a director callback is invoked looks like this:</p>
|
<p>The full chain of type conversions when a director callback is invoked looks like this:</p>
|
||||||
|
|
||||||
|
|
@ -157,13 +157,13 @@
|
||||||
dtype DClass.method(dtype a)</pre></div>
|
dtype DClass.method(dtype a)</pre></div>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="D_typecheck_typemaps"></a>22.3.5 typecheck typemaps</H3>
|
<H3><a name="D_typecheck_typemaps">22.3.5 typecheck typemaps</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>Because, unlike many scripting languages supported by SWIG, D does not need any dynamic dispatch helper to access an overloaded function, the purpose of these is merely to issue a warning for overloaded C++ functions that cannot be overloaded in D (as more than one C++ type maps to a single D type).</p>
|
<p>Because, unlike many scripting languages supported by SWIG, D does not need any dynamic dispatch helper to access an overloaded function, the purpose of these is merely to issue a warning for overloaded C++ functions that cannot be overloaded in D (as more than one C++ type maps to a single D type).</p>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="D_code_injection_typemaps"></a>22.3.6 Code injection typemaps</H3>
|
<H3><a name="D_code_injection_typemaps">22.3.6 Code injection typemaps</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>These typemaps are used for generating the skeleton of proxy classes for C++ types.</p>
|
<p>These typemaps are used for generating the skeleton of proxy classes for C++ types.</p>
|
||||||
|
|
@ -172,10 +172,10 @@
|
||||||
|
|
||||||
<p>Using <tt>dcode</tt> and <tt>dimports</tt>, you can specify additional D code which will be emitted into the class body respectively the imports section of the D module the class is written to.</p>
|
<p>Using <tt>dcode</tt> and <tt>dimports</tt>, you can specify additional D code which will be emitted into the class body respectively the imports section of the D module the class is written to.</p>
|
||||||
|
|
||||||
<p id="D_class_code_typemaps"><tt>dconstructor</tt>, <tt>ddestructor</tt>, <tt>ddispose</tt> and <tt>ddispose_derived</tt> are used to generate the class constructor, destructor and <tt>dispose()</tt> method, respectively. The auxiliary code for handling the pointer to the C++ object is stored in <tt>dbody</tt> and <tt>dbody_derived</tt>. You can override them for specific types.</p>
|
<p><a name="D_class_code_typemaps"></a><tt>dconstructor</tt>, <tt>ddestructor</tt>, <tt>ddispose</tt> and <tt>ddispose_derived</tt> are used to generate the class constructor, destructor and <tt>dispose()</tt> method, respectively. The auxiliary code for handling the pointer to the C++ object is stored in <tt>dbody</tt> and <tt>dbody_derived</tt>. You can override them for specific types.</p>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="D_special_variables"></a>22.3.7 Special variable macros</H3>
|
<H3><a name="D_special_variables">22.3.7 Special variable macros</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>The standard SWIG special variables are available for use within typemaps as described in the <a href="Typemaps.html#Typemaps">Typemaps documentation</a>, for example <tt>$1</tt>, <tt>$input</tt>, <tt>$result</tt> etc.</p>
|
<p>The standard SWIG special variables are available for use within typemaps as described in the <a href="Typemaps.html#Typemaps">Typemaps documentation</a>, for example <tt>$1</tt>, <tt>$input</tt>, <tt>$result</tt> etc.</p>
|
||||||
|
|
@ -197,7 +197,7 @@
|
||||||
<dt><tt>$null</tt></dt>
|
<dt><tt>$null</tt></dt>
|
||||||
<dd><p>In code inserted into the generated C/C++ wrapper functions, this variable is replaced by either <tt>0</tt> or nothing at all, depending on whether the function has a return value or not. It can be used to bail out early e.g. in case of errors (<tt>return $null;</tt>).</p></dd>
|
<dd><p>In code inserted into the generated C/C++ wrapper functions, this variable is replaced by either <tt>0</tt> or nothing at all, depending on whether the function has a return value or not. It can be used to bail out early e.g. in case of errors (<tt>return $null;</tt>).</p></dd>
|
||||||
|
|
||||||
<dt id="D_dinput"><tt>$dinput</tt> (C#: <tt>$csinput</tt>)</dt>
|
<dt><a name="D_dinput"></a><tt>$dinput</tt> (C#: <tt>$csinput</tt>)</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p>This variable is used in <tt><a href="D.html#D_din">din</a></tt> typemaps and is replaced by the expression which is to be passed to C/C++.</p>
|
<p>This variable is used in <tt><a href="D.html#D_din">din</a></tt> typemaps and is replaced by the expression which is to be passed to C/C++.</p>
|
||||||
<p>For example, this input</p>
|
<p>For example, this input</p>
|
||||||
|
|
@ -214,7 +214,7 @@ void foo(SomeClass arg) {
|
||||||
example_im.foo(SomeClass.getCPointer(arg));
|
example_im.foo(SomeClass.getCPointer(arg));
|
||||||
}</pre></div></dd>
|
}</pre></div></dd>
|
||||||
|
|
||||||
<dt id="D_imcall"><tt>$imcall</tt> and <tt>$owner</tt> (C#: <tt>$imcall</tt>)</dt>
|
<dt><a name="D_imcall"></a><tt>$imcall</tt> and <tt>$owner</tt> (C#: <tt>$imcall</tt>)</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p>These variables are used in <tt><a href="D.html#D_dout">dout</a></tt> typemaps. <tt>$imcall</tt> contains the call to the intermediary module which provides the value to be used, and <tt>$owner</tt> signals if the caller is responsible for managing the object lifetime (that is, if the called method is a constructor or has been marked via <tt>%newobject</tt>).</p>
|
<p>These variables are used in <tt><a href="D.html#D_dout">dout</a></tt> typemaps. <tt>$imcall</tt> contains the call to the intermediary module which provides the value to be used, and <tt>$owner</tt> signals if the caller is responsible for managing the object lifetime (that is, if the called method is a constructor or has been marked via <tt>%newobject</tt>).</p>
|
||||||
<p>Consider the following example:</p>
|
<p>Consider the following example:</p>
|
||||||
|
|
@ -229,7 +229,8 @@ void foo(SomeClass arg) {
|
||||||
|
|
||||||
%newobject bar();
|
%newobject bar();
|
||||||
SomeClass *bar();
|
SomeClass *bar();
|
||||||
%}</pre></div>
|
%}
|
||||||
|
</pre></div>
|
||||||
<p>The code generated for <tt>foo()</tt> and <tt>bar()</tt> looks like this:</p>
|
<p>The code generated for <tt>foo()</tt> and <tt>bar()</tt> looks like this:</p>
|
||||||
<div class="targetlang"><pre>
|
<div class="targetlang"><pre>
|
||||||
SomeClass foo() {
|
SomeClass foo() {
|
||||||
|
|
@ -243,7 +244,7 @@ SomeClass bar() {
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
<dt><tt>$dcall</tt> and <tt>$winput</tt> (C#: <tt>$cscall</tt>, <tt>$iminput</tt>)</dt>
|
<dt><tt>$dcall</tt> and <tt>$winput</tt> (C#: <tt>$cscall</tt>, <tt>$iminput</tt>)</dt>
|
||||||
<dd id="D_dpcall"><p>These variables are used in the director-specific typemaps <a href="D.html#D_ddirectorinout"><tt>ddirectorin</tt></a> and <a href="D.html#D_ddirectorinout"><tt>ddirectorout</tt></a>. They are more or less the reverse of the <tt>$imcall</tt> and <tt>$dinput</tt> macros: <tt>$dcall</tt> contains the invocation of the D proxy method of which the return value is to be passed back to C++, <tt>$winput</tt> contains the parameter value from C++.</p></dd>
|
<dd><a name="D_dpcall"></a><p>These variables are used in the director-specific typemaps <a href="D.html#D_ddirectorinout"><tt>ddirectorin</tt></a> and <a href="D.html#D_ddirectorinout"><tt>ddirectorout</tt></a>. They are more or less the reverse of the <tt>$imcall</tt> and <tt>$dinput</tt> macros: <tt>$dcall</tt> contains the invocation of the D proxy method of which the return value is to be passed back to C++, <tt>$winput</tt> contains the parameter value from C++.</p></dd>
|
||||||
|
|
||||||
<dt><tt>$excode</tt></dt>
|
<dt><tt>$excode</tt></dt>
|
||||||
<dd><p>This variable is used in <tt>dout</tt> and <tt>dconstructor</tt> typemaps and is filled with the contents of the <tt>excode</tt> typemap attribute if an exception could be thrown from the C++ side. See the <a href="CSharp.html#CSharp_exceptions">C# documentation</a> for details.</p></dd>
|
<dd><p>This variable is used in <tt>dout</tt> and <tt>dconstructor</tt> typemaps and is filled with the contents of the <tt>excode</tt> typemap attribute if an exception could be thrown from the C++ side. See the <a href="CSharp.html#CSharp_exceptions">C# documentation</a> for details.</p></dd>
|
||||||
|
|
@ -263,7 +264,7 @@ SomeClass bar() {
|
||||||
</pre></div>
|
</pre></div>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
<dt id="D_importtype"><tt>$importtype(SomeDType)</tt></dt>
|
<dt><a name="D_importtype"></a><tt>$importtype(SomeDType)</tt></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p>This macro is used in the <tt>dimports</tt> typemap if a dependency on another D type generated by SWIG is added by a custom typemap.</p>
|
<p>This macro is used in the <tt>dimports</tt> typemap if a dependency on another D type generated by SWIG is added by a custom typemap.</p>
|
||||||
<p>Consider the following code snippet:</p>
|
<p>Consider the following code snippet:</p>
|
||||||
|
|
@ -295,7 +296,7 @@ $importtype(AnotherInterface)
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="D_features"></a>22.4 <tt>%feature</tt>s</H2>
|
<H2><a name="D_features">22.4 D and %feature</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>The D module defines a number of directives which modify the <a href="Customization.html#Customization_features">SWIG features</a> set globally or for a specific declaration:</p>
|
<p>The D module defines a number of directives which modify the <a href="Customization.html#Customization_features">SWIG features</a> set globally or for a specific declaration:</p>
|
||||||
|
|
@ -325,7 +326,7 @@ struct A {
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="D_pragmas"></a>22.5 Pragmas</H2>
|
<H2><a name="D_pragmas">22.5 Pragmas</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>There are a few SWIG pragmas specific to the D module, which you can use to influence the D code SWIG generates:</p>
|
<p>There are a few SWIG pragmas specific to the D module, which you can use to influence the D code SWIG generates:</p>
|
||||||
|
|
@ -364,7 +365,7 @@ struct A {
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="D_exceptions"></a>22.6 D Exceptions</H2>
|
<H2><a name="D_exceptions">22.6 D Exceptions</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>Out of the box, C++ exceptions are fundamentally incompatible to their equivalent in the D world and cannot simply be propagated to a calling D method. There is, however, an easy way to solve this problem: Just catch the exception in the C/C++ wrapper layer, pass the contents to D, and make the wrapper code rethrow the exception in the D world.</p>
|
<p>Out of the box, C++ exceptions are fundamentally incompatible to their equivalent in the D world and cannot simply be propagated to a calling D method. There is, however, an easy way to solve this problem: Just catch the exception in the C/C++ wrapper layer, pass the contents to D, and make the wrapper code rethrow the exception in the D world.</p>
|
||||||
|
|
@ -374,7 +375,7 @@ struct A {
|
||||||
<p>As this feature is implemented in exactly the same way it is for C#, please see the <a href="CSharp.html#CSharp_exceptions">C# documentation</a> for a more detailed explanation.</p>
|
<p>As this feature is implemented in exactly the same way it is for C#, please see the <a href="CSharp.html#CSharp_exceptions">C# documentation</a> for a more detailed explanation.</p>
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="D_directors"></a>22.7 D Directors</H2>
|
<H2><a name="D_directors">22.7 D Directors</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>When the directors feature is activated, SWIG generates extra code on both the C++ and the D side to enable cross-language polymorphism. Essentially, this means that if you subclass a proxy class in D, C++ code can access any overridden virtual methods just as if you created a derived class in C++.</p>
|
<p>When the directors feature is activated, SWIG generates extra code on both the C++ and the D side to enable cross-language polymorphism. Essentially, this means that if you subclass a proxy class in D, C++ code can access any overridden virtual methods just as if you created a derived class in C++.</p>
|
||||||
|
|
@ -383,16 +384,16 @@ struct A {
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="D_other_features"></a>22.8 Other features</H2>
|
<H2><a name="D_other_features">22.8 Other features</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="D_nspace"></a>22.8.1 Extended namespace support (<tt>nspace</tt>)</H3>
|
<H3><a name="D_nspace">22.8.1 Extended namespace support (nspace)</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>By default, SWIG flattens all C++ namespaces into a single target language namespace, but as for Java and C#, the <a href="SWIGPlus.html#SWIGPlus_nspace"><tt>nspace</tt></a> feature is supported for D. If it is active, C++ namespaces are mapped to D packages/modules. Note, however, that like for the other languages, <em>free</em> variables and functions are not supported yet; currently, they are all allows written to the main proxy D module.</p>
|
<p>By default, SWIG flattens all C++ namespaces into a single target language namespace, but as for Java and C#, the <a href="SWIGPlus.html#SWIGPlus_nspace"><tt>nspace</tt></a> feature is supported for D. If it is active, C++ namespaces are mapped to D packages/modules. Note, however, that like for the other languages, <em>free</em> variables and functions are not supported yet; currently, they are all allows written to the main proxy D module.</p>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="D_native_pointer_support"></a>22.8.2 Native pointer support</H3>
|
<H3><a name="D_native_pointer_support">22.8.2 Native pointer support</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>Contrary to many of the scripting languages supported by SWIG, D fully supports C-style pointers. The D module thus includes a custom mechanism to wrap C pointers directly as D pointers where applicable, that is, if the type that is pointed to is represented the same in C and D (on the bit-level), dubbed a <em>primitive type</em> below.</p>
|
<p>Contrary to many of the scripting languages supported by SWIG, D fully supports C-style pointers. The D module thus includes a custom mechanism to wrap C pointers directly as D pointers where applicable, that is, if the type that is pointed to is represented the same in C and D (on the bit-level), dubbed a <em>primitive type</em> below.</p>
|
||||||
|
|
@ -404,7 +405,7 @@ struct A {
|
||||||
<p>To determine if a type should be considered primitive, the <tt>cprimitive</tt> attribute on its <tt>dtype</tt> attribute is used. For example, the <tt>dtype</tt> typemap for <tt>float</tt> has <tt>cprimitive="1"</tt>, so the code from the <tt>nativepointer</tt> attribute is taken into account e.g. for <tt>float **</tt> or the function pointer <tt>float (*)(float *)</tt>.</p>
|
<p>To determine if a type should be considered primitive, the <tt>cprimitive</tt> attribute on its <tt>dtype</tt> attribute is used. For example, the <tt>dtype</tt> typemap for <tt>float</tt> has <tt>cprimitive="1"</tt>, so the code from the <tt>nativepointer</tt> attribute is taken into account e.g. for <tt>float **</tt> or the function pointer <tt>float (*)(float *)</tt>.</p>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="D_operator_overloading"></a>22.8.3 Operator overloading</H3>
|
<H3><a name="D_operator_overloading">22.8.3 Operator overloading</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>The D module comes with basic operator overloading support for both D1 and D2. There are, however, a few limitations arising from conceptual differences between C++ and D:</p>
|
<p>The D module comes with basic operator overloading support for both D1 and D2. There are, however, a few limitations arising from conceptual differences between C++ and D:</p>
|
||||||
|
|
@ -416,7 +417,7 @@ struct A {
|
||||||
<p>There are also some cases where the operators can be translated to D, but the differences in the implementation details are big enough that a rather involved scheme would be required for automatic wrapping them, which has not been implemented yet. This affects, for example, the array subscript operator, <tt>[]</tt>, in combination with assignments - while <tt>operator []</tt> in C++ simply returns a reference which is then written to, D resorts to a separate <tt>opIndexAssign</tt> method -, or implicit casting (which was introduced in D2 via <tt>alias this</tt>). Despite the lack of automatic support, manually handling these cases should be perfectly possible.</p>
|
<p>There are also some cases where the operators can be translated to D, but the differences in the implementation details are big enough that a rather involved scheme would be required for automatic wrapping them, which has not been implemented yet. This affects, for example, the array subscript operator, <tt>[]</tt>, in combination with assignments - while <tt>operator []</tt> in C++ simply returns a reference which is then written to, D resorts to a separate <tt>opIndexAssign</tt> method -, or implicit casting (which was introduced in D2 via <tt>alias this</tt>). Despite the lack of automatic support, manually handling these cases should be perfectly possible.</p>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="D_test_suite"></a>22.8.4 Running the test-suite</H3>
|
<H3><a name="D_test_suite">22.8.4 Running the test-suite</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>As with any other language, the SWIG test-suite can be built for D using the <tt>*-d-test-suite</tt> targets of the top-level Makefile. By default, D1 is targeted, to build it with D2, use the optional <tt>D_VERSION</tt> variable, e.g. <tt>make check-d-test-suite D_VERSION=2</tt>.</p>
|
<p>As with any other language, the SWIG test-suite can be built for D using the <tt>*-d-test-suite</tt> targets of the top-level Makefile. By default, D1 is targeted, to build it with D2, use the optional <tt>D_VERSION</tt> variable, e.g. <tt>make check-d-test-suite D_VERSION=2</tt>.</p>
|
||||||
|
|
@ -424,14 +425,14 @@ struct A {
|
||||||
<p>Note: If you want to use GDC on Linux or another platform which requires you to link <tt>libdl</tt> for dynamically loading the shared library, you might have to add <tt>-ldl</tt> manually to the <tt>d_compile</tt> target in <tt>Examples/Makefile</tt>, because GDC does not currently honor the <tt>pragma(lib,...)</tt> statement.</p>
|
<p>Note: If you want to use GDC on Linux or another platform which requires you to link <tt>libdl</tt> for dynamically loading the shared library, you might have to add <tt>-ldl</tt> manually to the <tt>d_compile</tt> target in <tt>Examples/Makefile</tt>, because GDC does not currently honor the <tt>pragma(lib,...)</tt> statement.</p>
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="D_typemap_examples"></a>22.9 D Typemap examples</H2>
|
<H2><a name="D_typemap_examples">22.9 D Typemap examples</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>There are no D-specific typemap examples yet. However, with the above <a href="D.html#D_typemap_name_comparison">name comparison table</a>, you should be able to get an idea what can be done by looking at the <a href="CSharp.html#CSharp_typemap_examples">corresponding C# section</a>.</p>
|
<p>There are no D-specific typemap examples yet. However, with the above <a href="D.html#D_typemap_name_comparison">name comparison table</a>, you should be able to get an idea what can be done by looking at the <a href="CSharp.html#CSharp_typemap_examples">corresponding C# section</a>.</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="D_planned_features"></a>22.10 Work in progress and planned features</H2>
|
<H2><a name="D_planned_features">22.10 Work in progress and planned features</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>There are a couple of features which are not implemented yet, but would be very useful and might be added in the near future:</p>
|
<p>There are a couple of features which are not implemented yet, but would be very useful and might be added in the near future:</p>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Extending SWIG to support new languages</title>
|
<title>Extending SWIG to support new languages</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
<H1><a name="Extending"></a>41 Extending SWIG to support new languages</H1>
|
<H1><a name="Extending">41 Extending SWIG to support new languages</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -75,7 +76,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="Extending_nn2"></a>41.1 Introduction</H2>
|
<H2><a name="Extending_nn2">41.1 Introduction</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -91,7 +92,7 @@ Also, this chapter is not meant to be a hand-holding tutorial. As a starting po
|
||||||
you should probably look at one of SWIG's existing modules.
|
you should probably look at one of SWIG's existing modules.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Extending_nn3"></a>41.2 Prerequisites</H2>
|
<H2><a name="Extending_nn3">41.2 Prerequisites</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -121,7 +122,7 @@ obvious, but almost all SWIG directives as well as the low-level generation of
|
||||||
wrapper code are driven by C++ datatypes.
|
wrapper code are driven by C++ datatypes.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Extending_nn4"></a>41.3 The Big Picture</H2>
|
<H2><a name="Extending_nn4">41.3 The Big Picture</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -158,7 +159,7 @@ role in making the system work. For example, both typemaps and declaration anno
|
||||||
based on pattern matching and interact heavily with the underlying type system.
|
based on pattern matching and interact heavily with the underlying type system.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Extending_nn5"></a>41.4 Execution Model</H2>
|
<H2><a name="Extending_nn5">41.4 Execution Model</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -203,7 +204,7 @@ latter stage of compilation.
|
||||||
The next few sections briefly describe some of these stages.
|
The next few sections briefly describe some of these stages.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Extending_nn6"></a>41.4.1 Preprocessing</H3>
|
<H3><a name="Extending_nn6">41.4.1 Preprocessing</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -284,7 +285,7 @@ been expanded as well as everything else that goes into the low-level
|
||||||
construction of the wrapper code.
|
construction of the wrapper code.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Extending_nn7"></a>41.4.2 Parsing</H3>
|
<H3><a name="Extending_nn7">41.4.2 Parsing</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -385,7 +386,7 @@ returning a <tt>foo</tt> and taking types <tt>a</tt> and <tt>b</tt> as
|
||||||
arguments).
|
arguments).
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Extending_nn8"></a>41.4.3 Parse Trees</H3>
|
<H3><a name="Extending_nn8">41.4.3 Parse Trees</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -640,7 +641,7 @@ $ swig -c++ -python -debug-module 4 example.i
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Extending_nn9"></a>41.4.4 Attribute namespaces</H3>
|
<H3><a name="Extending_nn9">41.4.4 Attribute namespaces</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -659,7 +660,7 @@ that matches the name of the target language. For example, <tt>python:foo</tt>
|
||||||
<tt>perl:foo</tt>.
|
<tt>perl:foo</tt>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Extending_nn10"></a>41.4.5 Symbol Tables</H3>
|
<H3><a name="Extending_nn10">41.4.5 Symbol Tables</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -750,7 +751,7 @@ example.i:5. Previous declaration is foo_i(int )
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Extending_nn11"></a>41.4.6 The %feature directive</H3>
|
<H3><a name="Extending_nn11">41.4.6 The %feature directive</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -806,7 +807,7 @@ For example, the exception code above is simply
|
||||||
stored without any modifications.
|
stored without any modifications.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Extending_nn12"></a>41.4.7 Code Generation</H3>
|
<H3><a name="Extending_nn12">41.4.7 Code Generation</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -928,7 +929,7 @@ public :
|
||||||
The role of these functions is described shortly.
|
The role of these functions is described shortly.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Extending_nn13"></a>41.4.8 SWIG and XML</H3>
|
<H3><a name="Extending_nn13">41.4.8 SWIG and XML</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -941,7 +942,7 @@ internal data structures, it may be useful to keep XML in the back of
|
||||||
your mind as a model.
|
your mind as a model.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Extending_nn14"></a>41.5 Primitive Data Structures</H2>
|
<H2><a name="Extending_nn14">41.5 Primitive Data Structures</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -987,7 +988,7 @@ typedef Hash Typetab;
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Extending_nn15"></a>41.5.1 Strings</H3>
|
<H3><a name="Extending_nn15">41.5.1 Strings</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1128,7 +1129,7 @@ Returns the number of replacements made (if any).
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Extending_nn16"></a>41.5.2 Hashes</H3>
|
<H3><a name="Extending_nn16">41.5.2 Hashes</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1205,7 +1206,7 @@ Returns the list of hash table keys.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Extending_nn17"></a>41.5.3 Lists</H3>
|
<H3><a name="Extending_nn17">41.5.3 Lists</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1294,7 +1295,7 @@ If <tt>t</tt> is not a standard object, it is assumed to be a <tt>char *</tt>
|
||||||
and is used to create a String object.
|
and is used to create a String object.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Extending_nn18"></a>41.5.4 Common operations</H3>
|
<H3><a name="Extending_nn18">41.5.4 Common operations</a></H3>
|
||||||
|
|
||||||
|
|
||||||
The following operations are applicable to all datatypes.
|
The following operations are applicable to all datatypes.
|
||||||
|
|
@ -1349,7 +1350,7 @@ objects and report errors.
|
||||||
Gets the line number associated with <tt>x</tt>.
|
Gets the line number associated with <tt>x</tt>.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Extending_nn19"></a>41.5.5 Iterating over Lists and Hashes</H3>
|
<H3><a name="Extending_nn19">41.5.5 Iterating over Lists and Hashes</a></H3>
|
||||||
|
|
||||||
|
|
||||||
To iterate over the elements of a list or a hash table, the following functions are used:
|
To iterate over the elements of a list or a hash table, the following functions are used:
|
||||||
|
|
@ -1394,7 +1395,7 @@ for (j = First(j); j.item; j= Next(j)) {
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Extending_nn20"></a>41.5.6 I/O</H3>
|
<H3><a name="Extending_nn20">41.5.6 I/O</a></H3>
|
||||||
|
|
||||||
|
|
||||||
Special I/O functions are used for all internal I/O. These operations
|
Special I/O functions are used for all internal I/O. These operations
|
||||||
|
|
@ -1528,7 +1529,7 @@ Printf(f, "%s\n", s);
|
||||||
Similarly, the preprocessor and parser all operate on string-files.
|
Similarly, the preprocessor and parser all operate on string-files.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Extending_nn21"></a>41.6 Navigating and manipulating parse trees</H2>
|
<H2><a name="Extending_nn21">41.6 Navigating and manipulating parse trees</a></H2>
|
||||||
|
|
||||||
|
|
||||||
Parse trees are built as collections of hash tables. Each node is a hash table in which
|
Parse trees are built as collections of hash tables. Each node is a hash table in which
|
||||||
|
|
@ -1662,7 +1663,7 @@ Deletes a node from the parse tree. Deletion reconnects siblings and properly u
|
||||||
the parent so that sibling nodes are unaffected.
|
the parent so that sibling nodes are unaffected.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H2><a name="Extending_nn22"></a>41.7 Working with attributes</H2>
|
<H2><a name="Extending_nn22">41.7 Working with attributes</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1779,7 +1780,7 @@ the attribute is optional. <tt>Swig_restore()</tt> must always be called after
|
||||||
function.
|
function.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H2><a name="Extending_nn23"></a>41.8 Type system</H2>
|
<H2><a name="Extending_nn23">41.8 Type system</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1788,7 +1789,7 @@ pointers, references, and pointers to members. A detailed discussion of
|
||||||
type theory is impossible here. However, let's cover the highlights.
|
type theory is impossible here. However, let's cover the highlights.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Extending_nn24"></a>41.8.1 String encoding of types</H3>
|
<H3><a name="Extending_nn24">41.8.1 String encoding of types</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1889,7 +1890,7 @@ make the final type, the two parts are just joined together using
|
||||||
string concatenation.
|
string concatenation.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Extending_nn25"></a>41.8.2 Type construction</H3>
|
<H3><a name="Extending_nn25">41.8.2 Type construction</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2058,7 +2059,7 @@ Returns the prefix of a type. For example, if <tt>ty</tt> is
|
||||||
<tt>ty</tt> is unmodified.
|
<tt>ty</tt> is unmodified.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Extending_nn26"></a>41.8.3 Type tests</H3>
|
<H3><a name="Extending_nn26">41.8.3 Type tests</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2145,7 +2146,7 @@ Checks if <tt>ty</tt> is a varargs type.
|
||||||
Checks if <tt>ty</tt> is a templatized type.
|
Checks if <tt>ty</tt> is a templatized type.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Extending_nn27"></a>41.8.4 Typedef and inheritance</H3>
|
<H3><a name="Extending_nn27">41.8.4 Typedef and inheritance</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2247,7 +2248,7 @@ Fully reduces <tt>ty</tt> according to typedef rules. Resulting datatype
|
||||||
will consist only of primitive typenames.
|
will consist only of primitive typenames.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Extending_nn28"></a>41.8.5 Lvalues</H3>
|
<H3><a name="Extending_nn28">41.8.5 Lvalues</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2284,7 +2285,7 @@ Literal y; // type = 'Literal', ltype='p.char'
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Extending_nn29"></a>41.8.6 Output functions</H3>
|
<H3><a name="Extending_nn29">41.8.6 Output functions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2346,7 +2347,7 @@ SWIG, but is most commonly associated with type-descriptor objects
|
||||||
that appear in wrappers (e.g., <tt>SWIGTYPE_p_double</tt>).
|
that appear in wrappers (e.g., <tt>SWIGTYPE_p_double</tt>).
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H2><a name="Extending_nn30"></a>41.9 Parameters</H2>
|
<H2><a name="Extending_nn30">41.9 Parameters</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2445,7 +2446,7 @@ included. Used to emit prototypes.
|
||||||
Returns the number of required (non-optional) arguments in <tt>p</tt>.
|
Returns the number of required (non-optional) arguments in <tt>p</tt>.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H2><a name="Extending_nn31"></a>41.10 Writing a Language Module</H2>
|
<H2><a name="Extending_nn31">41.10 Writing a Language Module</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2460,7 +2461,7 @@ describes the creation of a minimal Python module. You should be able to extra
|
||||||
this to other languages.
|
this to other languages.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Extending_nn32"></a>41.10.1 Execution model</H3>
|
<H3><a name="Extending_nn32">41.10.1 Execution model</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2470,7 +2471,7 @@ the parsing of command line options, all aspects of code generation are controll
|
||||||
different methods of the <tt>Language</tt> that must be defined by your module.
|
different methods of the <tt>Language</tt> that must be defined by your module.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Extending_starting_out"></a>41.10.2 Starting out</H3>
|
<H3><a name="Extending_starting_out">41.10.2 Starting out</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2533,7 +2534,7 @@ also return a pointer to the base class (<tt>Language</tt>) so that only the int
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Save the code for your language module in a file named "<tt>python.cxx</tt>" and.
|
Save the code for your language module in a file named "<tt>python.cxx</tt>" and
|
||||||
place this file in the <tt>Source/Modules</tt> directory of the SWIG distribution.
|
place this file in the <tt>Source/Modules</tt> directory of the SWIG distribution.
|
||||||
To ensure that your module is compiled into SWIG along with the other language modules,
|
To ensure that your module is compiled into SWIG along with the other language modules,
|
||||||
modify the file <tt>Source/Modules/Makefile.am</tt> to include the additional source
|
modify the file <tt>Source/Modules/Makefile.am</tt> to include the additional source
|
||||||
|
|
@ -2578,7 +2579,7 @@ that activates your module. For example, <tt>swig -python foo.i</tt>. The
|
||||||
messages from your new module should appear.
|
messages from your new module should appear.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Extending_nn34"></a>41.10.3 Command line options</H3>
|
<H3><a name="Extending_nn34">41.10.3 Command line options</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2637,7 +2638,7 @@ to mark the option as valid. If you forget to do this, SWIG will terminate wit
|
||||||
unrecognized command line option error.
|
unrecognized command line option error.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Extending_nn35"></a>41.10.4 Configuration and preprocessing</H3>
|
<H3><a name="Extending_nn35">41.10.4 Configuration and preprocessing</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2686,7 +2687,7 @@ an implementation file <tt>python.cxx</tt> and a configuration file
|
||||||
<tt>python.swg</tt>.
|
<tt>python.swg</tt>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Extending_nn36"></a>41.10.5 Entry point to code generation</H3>
|
<H3><a name="Extending_nn36">41.10.5 Entry point to code generation</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2744,7 +2745,7 @@ int Python::top(Node *n) {
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Extending_nn37"></a>41.10.6 Module I/O and wrapper skeleton</H3>
|
<H3><a name="Extending_nn37">41.10.6 Module I/O and wrapper skeleton</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<!-- please report bugs in this section to mgossage -->
|
<!-- please report bugs in this section to mgossage -->
|
||||||
|
|
@ -2892,7 +2893,7 @@ functionWrapper : void Shape_y_set(Shape *self,double y)
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Extending_nn38"></a>41.10.7 Low-level code generators</H3>
|
<H3><a name="Extending_nn38">41.10.7 Low-level code generators</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<!-- please report bugs in this section to mgossage -->
|
<!-- please report bugs in this section to mgossage -->
|
||||||
|
|
@ -3046,7 +3047,7 @@ but without the typemaps, there is still work to do.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Extending_configuration_files"></a>41.10.8 Configuration files</H3>
|
<H3><a name="Extending_configuration_files">41.10.8 Configuration files</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<!-- please report bugs in this section to ttn -->
|
<!-- please report bugs in this section to ttn -->
|
||||||
|
|
@ -3190,7 +3191,7 @@ politely displays the ignoring language message.
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Extending_nn40"></a>41.10.9 Runtime support</H3>
|
<H3><a name="Extending_nn40">41.10.9 Runtime support</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3199,7 +3200,7 @@ Discuss the kinds of functions typically needed for SWIG runtime support (e.g.
|
||||||
the SWIG files that implement those functions.
|
the SWIG files that implement those functions.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Extending_nn41"></a>41.10.10 Standard library files</H3>
|
<H3><a name="Extending_nn41">41.10.10 Standard library files</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3218,7 +3219,7 @@ The following are the minimum that are usually supported:
|
||||||
Please copy these and modify for any new language.
|
Please copy these and modify for any new language.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Extending_nn42"></a>41.10.11 User examples</H3>
|
<H3><a name="Extending_nn42">41.10.11 User examples</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3247,7 +3248,7 @@ during this process, see the section on <a href="#Extending_configuration_files"
|
||||||
files</a>.
|
files</a>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Extending_test_suite"></a>41.10.12 Test driven development and the test-suite</H3>
|
<H3><a name="Extending_test_suite">41.10.12 Test driven development and the test-suite</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3306,7 +3307,7 @@ It is therefore essential that the runtime tests are written in a manner that di
|
||||||
but error/exception out with an error message on stderr on failure.
|
but error/exception out with an error message on stderr on failure.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H4><a name="Extending_running_test_suite"></a>41.10.12.1 Running the test-suite</H4>
|
<H4><a name="Extending_running_test_suite">41.10.12.1 Running the test-suite</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3498,7 +3499,7 @@ It can be run in the same way as the other language test-suites, replacing [lang
|
||||||
The test cases used and the way it works is described in <tt>Examples/test-suite/errors/Makefile.in</tt>.
|
The test cases used and the way it works is described in <tt>Examples/test-suite/errors/Makefile.in</tt>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Extending_nn43"></a>41.10.13 Documentation</H3>
|
<H3><a name="Extending_nn43">41.10.13 Documentation</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3530,7 +3531,7 @@ Some topics that you'll want to be sure to address include:
|
||||||
if available.
|
if available.
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<H3><a name="Extending_prerequisites"></a>41.10.14 Prerequisites for adding a new language module to the SWIG distribution</H3>
|
<H3><a name="Extending_prerequisites">41.10.14 Prerequisites for adding a new language module to the SWIG distribution</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3587,7 +3588,7 @@ should be added should there be an area not already covered by
|
||||||
the existing tests.
|
the existing tests.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Extending_coding_style_guidelines"></a>41.10.15 Coding style guidelines</H3>
|
<H3><a name="Extending_coding_style_guidelines">41.10.15 Coding style guidelines</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3611,7 +3612,7 @@ The generated C/C++ code should also follow this style as close as possible. How
|
||||||
should be avoided as unlike the SWIG developers, users will never have consistent tab settings.
|
should be avoided as unlike the SWIG developers, users will never have consistent tab settings.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Extending_debugging_options"></a>41.11 Debugging Options</H2>
|
<H2><a name="Extending_debugging_options">41.11 Debugging Options</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3638,7 +3639,7 @@ There are various command line options which can aid debugging a SWIG interface
|
||||||
The complete list of command line options for SWIG are available by running <tt>swig -help</tt>.
|
The complete list of command line options for SWIG are available by running <tt>swig -help</tt>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Extending_nn46"></a>41.12 Guide to parse tree nodes</H2>
|
<H2><a name="Extending_nn46">41.12 Guide to parse tree nodes</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -4046,7 +4047,7 @@ extern "X" { ... } declaration.
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H2><a name="Extending_further_info"></a>41.13 Further Development Information</H2>
|
<H2><a name="Extending_further_info">41.13 Further Development Information</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,14 +1,14 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<!-- Hand-written HTML -->
|
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>SWIG and Guile</title>
|
<title>SWIG and Guile</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
|
|
||||||
<H1><a name="Guile"></a>24 SWIG and Guile</H1>
|
<H1><a name="Guile">24 SWIG and Guile</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
<p>
|
<p>
|
||||||
This section details guile-specific support in SWIG.
|
This section details guile-specific support in SWIG.
|
||||||
|
|
||||||
<H2><a name="Guile_nn1"></a>24.1 Supported Guile Versions</H2>
|
<H2><a name="Guile_nn1">24.1 Supported Guile Versions</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -61,7 +61,7 @@ improved performance. This is currently not tested with swig
|
||||||
so your mileage may vary. To be safe set environment variable
|
so your mileage may vary. To be safe set environment variable
|
||||||
GUILE_AUTO_COMPILE to 0 when using swig generated guile code.
|
GUILE_AUTO_COMPILE to 0 when using swig generated guile code.
|
||||||
|
|
||||||
<H2><a name="Guile_nn2"></a>24.2 Meaning of "Module"</H2>
|
<H2><a name="Guile_nn2">24.2 Meaning of "Module"</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -69,7 +69,7 @@ There are three different concepts of "module" involved, defined
|
||||||
separately for SWIG, Guile, and Libtool. To avoid horrible confusion,
|
separately for SWIG, Guile, and Libtool. To avoid horrible confusion,
|
||||||
we explicitly prefix the context, e.g., "guile-module".
|
we explicitly prefix the context, e.g., "guile-module".
|
||||||
|
|
||||||
<H2><a name="Guile_nn3"></a>24.3 Old GH Guile API</H2>
|
<H2><a name="Guile_nn3">24.3 Old GH Guile API</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>Guile 1.8 and older could be interfaced using two different api's, the SCM
|
<p>Guile 1.8 and older could be interfaced using two different api's, the SCM
|
||||||
|
|
@ -80,7 +80,7 @@ or the GH API. The GH interface to guile is deprecated. Read more about why in
|
||||||
version of SWIG that can still generate guile GH wrapper code is 2.0.9. Please
|
version of SWIG that can still generate guile GH wrapper code is 2.0.9. Please
|
||||||
use that version if you really need the GH wrapper code.
|
use that version if you really need the GH wrapper code.
|
||||||
|
|
||||||
<H2><a name="Guile_nn4"></a>24.4 Linkage</H2>
|
<H2><a name="Guile_nn4">24.4 Linkage</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -88,7 +88,7 @@ Guile support is complicated by a lack of user community cohesiveness,
|
||||||
which manifests in multiple shared-library usage conventions. A set of
|
which manifests in multiple shared-library usage conventions. A set of
|
||||||
policies implementing a usage convention is called a <b>linkage</b>.
|
policies implementing a usage convention is called a <b>linkage</b>.
|
||||||
|
|
||||||
<H3><a name="Guile_nn5"></a>24.4.1 Simple Linkage</H3>
|
<H3><a name="Guile_nn5">24.4.1 Simple Linkage</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -193,7 +193,7 @@ placed between the <code>define-module</code> form and the
|
||||||
<code>SWIG_init</code> via a preprocessor define to avoid symbol
|
<code>SWIG_init</code> via a preprocessor define to avoid symbol
|
||||||
clashes. For this case, however, passive linkage is available.
|
clashes. For this case, however, passive linkage is available.
|
||||||
|
|
||||||
<H3><a name="Guile_nn6"></a>24.4.2 Passive Linkage</H3>
|
<H3><a name="Guile_nn6">24.4.2 Passive Linkage</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>Passive linkage is just like simple linkage, but it generates an
|
<p>Passive linkage is just like simple linkage, but it generates an
|
||||||
|
|
@ -203,7 +203,7 @@ package name (see below).
|
||||||
<p>You should use passive linkage rather than simple linkage when you
|
<p>You should use passive linkage rather than simple linkage when you
|
||||||
are using multiple modules.
|
are using multiple modules.
|
||||||
|
|
||||||
<H3><a name="Guile_nn7"></a>24.4.3 Native Guile Module Linkage</H3>
|
<H3><a name="Guile_nn7">24.4.3 Native Guile Module Linkage</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>SWIG can also generate wrapper code that does all the Guile module
|
<p>SWIG can also generate wrapper code that does all the Guile module
|
||||||
|
|
@ -244,7 +244,7 @@ Newer Guile versions have a shorthand procedure for this:
|
||||||
</div>
|
</div>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<H3><a name="Guile_nn8"></a>24.4.4 Old Auto-Loading Guile Module Linkage</H3>
|
<H3><a name="Guile_nn8">24.4.4 Old Auto-Loading Guile Module Linkage</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>Guile used to support an autoloading facility for object-code
|
<p>Guile used to support an autoloading facility for object-code
|
||||||
|
|
@ -270,7 +270,7 @@ option, SWIG generates an exported module initialization function with
|
||||||
an appropriate name.
|
an appropriate name.
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Guile_nn9"></a>24.4.5 Hobbit4D Linkage</H3>
|
<H3><a name="Guile_nn9">24.4.5 Hobbit4D Linkage</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -295,7 +295,7 @@ my/lib/libfoo.so.X.Y.Z and friends. This scheme is still very
|
||||||
experimental; the (hobbit4d link) conventions are not well understood.
|
experimental; the (hobbit4d link) conventions are not well understood.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Guile_nn10"></a>24.5 Underscore Folding</H2>
|
<H2><a name="Guile_nn10">24.5 Underscore Folding</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -307,7 +307,7 @@ complained so far.
|
||||||
<code>%rename</code> to specify the Guile name of the wrapped
|
<code>%rename</code> to specify the Guile name of the wrapped
|
||||||
functions and variables (see CHANGES).
|
functions and variables (see CHANGES).
|
||||||
|
|
||||||
<H2><a name="Guile_nn11"></a>24.6 Typemaps</H2>
|
<H2><a name="Guile_nn11">24.6 Typemaps</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -399,7 +399,7 @@ constant will appear as a scheme variable. See
|
||||||
<a href="Customization.html#Customization_features">Features and the %feature directive</a>
|
<a href="Customization.html#Customization_features">Features and the %feature directive</a>
|
||||||
for info on how to apply the %feature.</p>
|
for info on how to apply the %feature.</p>
|
||||||
|
|
||||||
<H2><a name="Guile_nn12"></a>24.7 Representation of pointers as smobs</H2>
|
<H2><a name="Guile_nn12">24.7 Representation of pointers as smobs</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -420,7 +420,7 @@ representing the expected pointer type. See also
|
||||||
If the Scheme object passed was not a SWIG smob representing a compatible
|
If the Scheme object passed was not a SWIG smob representing a compatible
|
||||||
pointer, a <code>wrong-type-arg</code> exception is raised.
|
pointer, a <code>wrong-type-arg</code> exception is raised.
|
||||||
|
|
||||||
<H3><a name="Guile_nn14"></a>24.7.1 Smobs</H3>
|
<H3><a name="Guile_nn14">24.7.1 Smobs</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -439,7 +439,7 @@ structure describing this type. If a generated GOOPS module has been loaded, sm
|
||||||
the corresponding GOOPS class.</p>
|
the corresponding GOOPS class.</p>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Guile_nn15"></a>24.7.2 Garbage Collection</H3>
|
<H3><a name="Guile_nn15">24.7.2 Garbage Collection</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>Garbage collection is a feature of Guile since version 1.6. As SWIG now requires Guile > 1.8,
|
<p>Garbage collection is a feature of Guile since version 1.6. As SWIG now requires Guile > 1.8,
|
||||||
|
|
@ -453,7 +453,7 @@ is exactly like described in <a href="Customization.html#Customization_ownership
|
||||||
Object ownership and %newobject</a> in the SWIG manual. All typemaps use an $owner var, and
|
Object ownership and %newobject</a> in the SWIG manual. All typemaps use an $owner var, and
|
||||||
the guile module replaces $owner with 0 or 1 depending on feature:new.</p>
|
the guile module replaces $owner with 0 or 1 depending on feature:new.</p>
|
||||||
|
|
||||||
<H2><a name="Guile_nn16"></a>24.8 Exception Handling</H2>
|
<H2><a name="Guile_nn16">24.8 Exception Handling</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -479,7 +479,7 @@ mapping:
|
||||||
The default when not specified here is to use "swig-error".
|
The default when not specified here is to use "swig-error".
|
||||||
See Lib/exception.i for details.
|
See Lib/exception.i for details.
|
||||||
|
|
||||||
<H2><a name="Guile_nn17"></a>24.9 Procedure documentation</H2>
|
<H2><a name="Guile_nn17">24.9 Procedure documentation</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>If invoked with the command-line option <code>-procdoc
|
<p>If invoked with the command-line option <code>-procdoc
|
||||||
|
|
@ -514,7 +514,7 @@ like this:
|
||||||
typemap argument <code>doc</code>. See <code>Lib/guile/typemaps.i</code> for
|
typemap argument <code>doc</code>. See <code>Lib/guile/typemaps.i</code> for
|
||||||
details.
|
details.
|
||||||
|
|
||||||
<H2><a name="Guile_nn18"></a>24.10 Procedures with setters</H2>
|
<H2><a name="Guile_nn18">24.10 Procedures with setters</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>For global variables, SWIG creates a single wrapper procedure
|
<p>For global variables, SWIG creates a single wrapper procedure
|
||||||
|
|
@ -542,7 +542,7 @@ struct members, the procedures <code>(<var>struct</var>-<var>member</var>-get
|
||||||
pointer)</code> and <code>(<var>struct-member</var>-set pointer
|
pointer)</code> and <code>(<var>struct-member</var>-set pointer
|
||||||
value)</code> are <em>not</em> generated.
|
value)</code> are <em>not</em> generated.
|
||||||
|
|
||||||
<H2><a name="Guile_nn19"></a>24.11 GOOPS Proxy Classes</H2>
|
<H2><a name="Guile_nn19">24.11 GOOPS Proxy Classes</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>SWIG can also generate classes and generic functions for use with
|
<p>SWIG can also generate classes and generic functions for use with
|
||||||
|
|
@ -688,7 +688,7 @@ Notice that <Foo> is used before it is defined. The fix is to just put th
|
||||||
<code>%import "foo.h"</code> before the <code>%inline</code> block.
|
<code>%import "foo.h"</code> before the <code>%inline</code> block.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Guile_nn20"></a>24.11.1 Naming Issues</H3>
|
<H3><a name="Guile_nn20">24.11.1 Naming Issues</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>As you can see in the example above, there are potential naming conflicts. The default exported
|
<p>As you can see in the example above, there are potential naming conflicts. The default exported
|
||||||
|
|
@ -725,7 +725,7 @@ guile-modules. For example,</p>
|
||||||
(use-modules ((Test) #:renamer (symbol-prefix-proc 'goops:)))
|
(use-modules ((Test) #:renamer (symbol-prefix-proc 'goops:)))
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Guile_nn21"></a>24.11.2 Linking</H3>
|
<H3><a name="Guile_nn21">24.11.2 Linking</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>The guile-modules generated above all need to be linked together. GOOPS support requires
|
<p>The guile-modules generated above all need to be linked together. GOOPS support requires
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Introduction</title>
|
<title>Introduction</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
<H1><a name="Introduction"></a>2 Introduction</H1>
|
<H1><a name="Introduction">2 Introduction</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -31,7 +32,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="Introduction_nn2"></a>2.1 What is SWIG?</H2>
|
<H2><a name="Introduction_nn2">2.1 What is SWIG?</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -71,7 +72,7 @@ small; especially the research and development work that is commonly found
|
||||||
in scientific and engineering projects. However, nowadays SWIG is known to be used in many
|
in scientific and engineering projects. However, nowadays SWIG is known to be used in many
|
||||||
large open source and commercial projects.
|
large open source and commercial projects.
|
||||||
|
|
||||||
<H2><a name="Introduction_nn3"></a>2.2 Why use SWIG?</H2>
|
<H2><a name="Introduction_nn3">2.2 Why use SWIG?</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -143,7 +144,7 @@ it provides a wide variety of customization features that let you change almost
|
||||||
every aspect of the language bindings. This is the main reason why SWIG has such a large
|
every aspect of the language bindings. This is the main reason why SWIG has such a large
|
||||||
user manual ;-).
|
user manual ;-).
|
||||||
|
|
||||||
<H2><a name="Introduction_nn4"></a>2.3 A SWIG example</H2>
|
<H2><a name="Introduction_nn4">2.3 A SWIG example</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -158,8 +159,10 @@ double My_variable = 3.0;
|
||||||
|
|
||||||
/* Compute factorial of n */
|
/* Compute factorial of n */
|
||||||
int fact(int n) {
|
int fact(int n) {
|
||||||
if (n <= 1) return 1;
|
if (n <= 1)
|
||||||
else return n*fact(n-1);
|
return 1;
|
||||||
|
else
|
||||||
|
return n*fact(n-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Compute n mod m */
|
/* Compute n mod m */
|
||||||
|
|
@ -174,7 +177,7 @@ variable <tt>My_variable</tt> from Tcl. You start by making a SWIG
|
||||||
interface file as shown below (by convention, these files carry a .i
|
interface file as shown below (by convention, these files carry a .i
|
||||||
suffix) :
|
suffix) :
|
||||||
|
|
||||||
<H3><a name="Introduction_nn5"></a>2.3.1 SWIG interface file</H3>
|
<H3><a name="Introduction_nn5">2.3.1 SWIG interface file</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<div class="code"><pre>
|
<div class="code"><pre>
|
||||||
|
|
@ -199,7 +202,7 @@ module that will be created by SWIG. The <tt>%{ %}</tt> block
|
||||||
provides a location for inserting additional code, such as C header
|
provides a location for inserting additional code, such as C header
|
||||||
files or additional C declarations, into the generated C wrapper code.
|
files or additional C declarations, into the generated C wrapper code.
|
||||||
|
|
||||||
<H3><a name="Introduction_nn6"></a>2.3.2 The swig command</H3>
|
<H3><a name="Introduction_nn6">2.3.2 The swig command</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -222,7 +225,6 @@ unix > <b>tclsh</b>
|
||||||
%
|
%
|
||||||
</pre></div>
|
</pre></div>
|
||||||
<p>
|
<p>
|
||||||
|
|
||||||
The <tt>swig</tt> command produced a new file called
|
The <tt>swig</tt> command produced a new file called
|
||||||
<tt>example_wrap.c</tt> that should be compiled along with the
|
<tt>example_wrap.c</tt> that should be compiled along with the
|
||||||
<tt>example.c</tt> file. Most operating systems and scripting
|
<tt>example.c</tt> file. Most operating systems and scripting
|
||||||
|
|
@ -233,7 +235,7 @@ and variables declared in the SWIG interface. A look at the file
|
||||||
<tt>example_wrap.c</tt> reveals a hideous mess. However, you
|
<tt>example_wrap.c</tt> reveals a hideous mess. However, you
|
||||||
almost never need to worry about it.
|
almost never need to worry about it.
|
||||||
|
|
||||||
<H3><a name="Introduction_nn7"></a>2.3.3 Building a Perl5 module</H3>
|
<H3><a name="Introduction_nn7">2.3.3 Building a Perl5 module</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -259,7 +261,7 @@ unix >
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Introduction_nn8"></a>2.3.4 Building a Python module</H3>
|
<H3><a name="Introduction_nn8">2.3.4 Building a Python module</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -283,7 +285,7 @@ Type "copyright", "credits" or "license" for more information.
|
||||||
7.5
|
7.5
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Introduction_nn9"></a>2.3.5 Shortcuts</H3>
|
<H3><a name="Introduction_nn9">2.3.5 Shortcuts</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -309,7 +311,7 @@ print $example::My_variable + 4.5, "\n";
|
||||||
7.5
|
7.5
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H2><a name="Introduction_nn10"></a>2.4 Supported C/C++ language features</H2>
|
<H2><a name="Introduction_nn10">2.4 Supported C/C++ language features</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -334,7 +336,7 @@ major features include:
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Most of C++11 is also supported. Details are in the <a href="CPlusPlus11.html">C++11</a> section.
|
Most of C++11 is also supported. Details are in the <a href="CPlusPlus11.html#CPlusPlus11">C++11</a> section.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -348,7 +350,7 @@ wrapping simple C++ code. In fact, SWIG is able to handle C++ code that
|
||||||
stresses the very limits of many C++ compilers.
|
stresses the very limits of many C++ compilers.
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="Introduction_nn11"></a>2.5 Non-intrusive interface building</H2>
|
<H2><a name="Introduction_nn11">2.5 Non-intrusive interface building</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -360,7 +362,7 @@ interface and reuse the code in other applications. It is also
|
||||||
possible to support different types of interfaces depending on the application.
|
possible to support different types of interfaces depending on the application.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Introduction_build_system"></a>2.6 Incorporating SWIG into a build system</H2>
|
<H2><a name="Introduction_build_system">2.6 Incorporating SWIG into a build system</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -383,7 +385,7 @@ for further information on this and other Autoconf macros.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
There is growing support for SWIG in some build tools, for example <a href="http://www.cmake.org">CMake</a>
|
There is growing support for SWIG in some build tools, for example <a href="http://cmake.org">CMake</a>
|
||||||
is a cross-platform, open-source build manager with built in support for SWIG. CMake can detect the SWIG executable
|
is a cross-platform, open-source build manager with built in support for SWIG. CMake can detect the SWIG executable
|
||||||
and many of the target language libraries for linking against.
|
and many of the target language libraries for linking against.
|
||||||
CMake knows how to build shared libraries and loadable modules on many different operating systems.
|
CMake knows how to build shared libraries and loadable modules on many different operating systems.
|
||||||
|
|
@ -418,7 +420,7 @@ which will invoke SWIG and compile the generated C++ files into _example.so (UNI
|
||||||
For other target languages on Windows a dll, instead of a .pyd file, is usually generated.
|
For other target languages on Windows a dll, instead of a .pyd file, is usually generated.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Introduction_nn12"></a>2.7 Hands off code generation</H2>
|
<H2><a name="Introduction_nn12">2.7 Hands off code generation</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -431,7 +433,7 @@ it allows others to forget about the low-level implementation
|
||||||
details.
|
details.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Introduction_nn13"></a>2.8 SWIG and freedom</H2>
|
<H2><a name="Introduction_nn13">2.8 SWIG and freedom</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,12 +1,13 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<link rel="stylesheet" type="text/css" href="./style.css">
|
<link rel="stylesheet" type="text/css" href="./style.css">
|
||||||
<title></title>
|
<title></title>
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<H1><a name="Javascript"></a>26 SWIG and Javascript</H1>
|
<H1><a name="Javascript">26 SWIG and Javascript</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -25,7 +26,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="#Javascript_embedded_webkit">Embedded Webkit</a>
|
<li><a href="#Javascript_embedded_webkit">Embedded Webkit</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#Javascript_osx">OSX</a>
|
<li><a href="#Javascript_osx">Mac OS X</a>
|
||||||
<li><a href="#Javascript_gtk">GTK</a>
|
<li><a href="#Javascript_gtk">GTK</a>
|
||||||
</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>
|
||||||
|
|
@ -51,7 +52,7 @@
|
||||||
|
|
||||||
<p>This chapter describes SWIG's support of Javascript. It does not cover SWIG basics, but only information that is specific to this module.</p>
|
<p>This chapter describes SWIG's support of Javascript. It does not cover SWIG basics, but only information that is specific to this module.</p>
|
||||||
|
|
||||||
<H2><a name="Javascript_overview"></a>26.1 Overview</H2>
|
<H2><a name="Javascript_overview">26.1 Overview</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>Javascript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. Its arguably the most popular language for web development.
|
<p>Javascript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. Its arguably the most popular language for web development.
|
||||||
|
|
@ -62,10 +63,10 @@ Javascript has gone beyond being a browser-based scripting language and with <a
|
||||||
With <a href="https://github.com/rogerwang/node-webkit">node-webkit</a> there is a platform which uses Google's <code>Chromium</code> as Web-Browser widget and <code>node.js</code> for javascript extensions.
|
With <a href="https://github.com/rogerwang/node-webkit">node-webkit</a> there is a platform which uses Google's <code>Chromium</code> as Web-Browser widget and <code>node.js</code> for javascript extensions.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Javascript_preliminaries"></a>26.2 Preliminaries</H2>
|
<H2><a name="Javascript_preliminaries">26.2 Preliminaries</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Javascript_running_swig"></a>26.2.1 Running SWIG</H3>
|
<H3><a name="Javascript_running_swig">26.2.1 Running SWIG</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>Suppose that you defined a SWIG module such as the following:</p>
|
<p>Suppose that you defined a SWIG module such as the following:</p>
|
||||||
|
|
@ -89,11 +90,22 @@ $ swig -javascript -jsc example.i</pre>
|
||||||
$ swig -c++ -javascript -jsc example.i</pre>
|
$ swig -c++ -javascript -jsc example.i</pre>
|
||||||
</div>
|
</div>
|
||||||
<p>The V8 code that SWIG generates should work with most versions from 3.11.10 up to 3.29.14 and later.</p>
|
<p>The V8 code that SWIG generates should work with most versions from 3.11.10 up to 3.29.14 and later.</p>
|
||||||
<p>Specify the V8 version when running SWIG (e.g. 3.25.30)</p>
|
<p>The API headers for V8 >= 4.3.0 define constants which SWIG can use to
|
||||||
|
determine the V8 version it is compiling for. For versions < 4.3.0, you
|
||||||
|
need to specify the V8 version when running SWIG. This is specified as a hex
|
||||||
|
constant, but the constant is read as pairs of decimal digits, so for V8
|
||||||
|
3.25.30 use constant 0x032530. This scheme can't represent components > 99,
|
||||||
|
but this constant is only useful for V8 < 4.3.0, and no V8 versions from
|
||||||
|
that era had a component > 99. For example:</p>
|
||||||
<div class="shell">
|
<div class="shell">
|
||||||
<pre>
|
<pre>
|
||||||
$ swig -c++ -javascript -v8 -DV8_VERSION=0x032530 example.i</pre>
|
$ swig -c++ -javascript -v8 -DV8_VERSION=0x032530 example.i</pre>
|
||||||
</div>
|
</div>
|
||||||
|
<p>If you're targetting V8 >= 4.3.0, you would just run swig like so:</p>
|
||||||
|
<div class="shell">
|
||||||
|
<pre>
|
||||||
|
$ swig -c++ -javascript -v8 example.i</pre>
|
||||||
|
</div>
|
||||||
<p>This creates a C/C++ source file <code>example_wrap.c</code> or <code>example_wrap.cxx</code>. The generated C source file contains the low-level wrappers that need to be compiled and linked with the rest of your C/C++ application to create an extension module.</p>
|
<p>This creates a C/C++ source file <code>example_wrap.c</code> or <code>example_wrap.cxx</code>. The generated C source file contains the low-level wrappers that need to be compiled and linked with the rest of your C/C++ application to create an extension module.</p>
|
||||||
<p>The name of the wrapper file is derived from the name of the input file. For example, if the input file is <code>example.i</code>, the name of the wrapper file is <code>example_wrap.c</code>. To change this, you can use the -o option. The wrapped module will export one function which must be called to register the module with the Javascript interpreter. For example, if your module is named <code>example</code> the corresponding initializer for JavascriptCore would be</p>
|
<p>The name of the wrapper file is derived from the name of the input file. For example, if the input file is <code>example.i</code>, the name of the wrapper file is <code>example_wrap.c</code>. To change this, you can use the -o option. The wrapped module will export one function which must be called to register the module with the Javascript interpreter. For example, if your module is named <code>example</code> the corresponding initializer for JavascriptCore would be</p>
|
||||||
<div class="code">
|
<div class="code">
|
||||||
|
|
@ -109,7 +121,7 @@ void example_initialize(v8::Handle<v8::Object> exports)</pre>
|
||||||
<b>Note</b>: be aware that <code>v8</code> has a C++ API, and thus, the generated modules must be compiled as C++.
|
<b>Note</b>: be aware that <code>v8</code> has a C++ API, and thus, the generated modules must be compiled as C++.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Javascript_running_tests_examples"></a>26.2.2 Running Tests and Examples</H3>
|
<H3><a name="Javascript_running_tests_examples">26.2.2 Running Tests and Examples</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>The configuration for tests and examples currently supports Linux and Mac only and not MinGW (Windows) yet.</p>
|
<p>The configuration for tests and examples currently supports Linux and Mac only and not MinGW (Windows) yet.</p>
|
||||||
|
|
@ -141,7 +153,7 @@ $ make check-javascript-test-suite ENGINE=jsc</pre>
|
||||||
$ make check-javascript-examples V8_VERSION=0x032530 ENGINE=v8</pre>
|
$ make check-javascript-examples V8_VERSION=0x032530 ENGINE=v8</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Javascript_known_issues"></a>26.2.3 Known Issues</H3>
|
<H3><a name="Javascript_known_issues">26.2.3 Known Issues</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>At the moment, the Javascript generators pass all tests syntactically, i.e., the generated source code compiles. However, there are still remaining runtime issues.</p>
|
<p>At the moment, the Javascript generators pass all tests syntactically, i.e., the generated source code compiles. However, there are still remaining runtime issues.</p>
|
||||||
|
|
@ -156,17 +168,17 @@ $ make check-javascript-examples V8_VERSION=0x032530 ENGINE=v8</pre>
|
||||||
<li><p><code>instanceOf</code> does not work under JSC</p></li>
|
<li><p><code>instanceOf</code> does not work under JSC</p></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<p>The primary development environment has been Linux (Ubuntu 12.04). Windows and OSX have been tested sporadically. Therefore, the generators might have more issues on those platforms. Please report back any problem you observe to help us improving this module quickly.</p>
|
<p>The primary development environment has been Linux (Ubuntu 12.04). Windows and Mac OS X have been tested sporadically. Therefore, the generators might have more issues on those platforms. Please report back any problem you observe to help us improving this module quickly.</p>
|
||||||
|
|
||||||
<H2><a name="Javascript_integration"></a>26.3 Integration</H2>
|
<H2><a name="Javascript_integration">26.3 Integration</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>This chapter gives a short introduction how to use a native Javascript extension: as a <code>node.js</code> module, and as an extension for an embedded Webkit.</p>
|
<p>This chapter gives a short introduction how to use a native Javascript extension: as a <code>node.js</code> module, and as an extension for an embedded Webkit.</p>
|
||||||
|
|
||||||
<H3><a name="Javascript_node_extensions"></a>26.3.1 Creating node.js Extensions</H3>
|
<H3><a name="Javascript_node_extensions">26.3.1 Creating node.js Extensions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>To install <code>node.js</code> you can download an installer from their <a href="https://launchpad.net/~chris-lea/+archive/node.js">web-site</a> for OSX and Windows. For Linux you can either build the source yourself and run <code>sudo checkinstall</code> or keep to the (probably stone-age) packaged version. For Ubuntu there is a <a href="https://launchpad.net/~chris-lea/+archive/node.js/">PPA</a> available.</p>
|
<p>To install <code>node.js</code> you can download an installer from their <a href="https://launchpad.net/~chris-lea/+archive/node.js">web-site</a> for Mac OS X and Windows. For Linux you can either build the source yourself and run <code>sudo checkinstall</code> or keep to the (probably stone-age) packaged version. For Ubuntu there is a <a href="https://launchpad.net/~chris-lea/+archive/ubuntu/node.js/">PPA</a> available.</p>
|
||||||
<div class="shell">
|
<div class="shell">
|
||||||
<pre>
|
<pre>
|
||||||
$ sudo add-apt-repository ppa:chris-lea/node.js
|
$ sudo add-apt-repository ppa:chris-lea/node.js
|
||||||
|
|
@ -209,7 +221,7 @@ require("./build/Release/example")</pre>
|
||||||
</div>
|
</div>
|
||||||
<p>A more detailed explanation is given in the <a href="#Javascript_examples">Examples</a> section.</p>
|
<p>A more detailed explanation is given in the <a href="#Javascript_examples">Examples</a> section.</p>
|
||||||
|
|
||||||
<H4><a name="Javascript_troubleshooting"></a>26.3.1.1 Troubleshooting</H4>
|
<H4><a name="Javascript_troubleshooting">26.3.1.1 Troubleshooting</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -221,12 +233,12 @@ require("./build/Release/example")</pre>
|
||||||
$ sudo apt-get remove gyp</pre>
|
$ sudo apt-get remove gyp</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Javascript_embedded_webkit"></a>26.3.2 Embedded Webkit</H3>
|
<H3><a name="Javascript_embedded_webkit">26.3.2 Embedded Webkit</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>Webkit is pre-installed on OSX and available as a library for GTK.</p>
|
<p>Webkit is pre-installed on Mac OS X and available as a library for GTK.</p>
|
||||||
|
|
||||||
<H4><a name="Javascript_osx"></a>26.3.2.1 OSX</H4>
|
<H4><a name="Javascript_osx">26.3.2.1 Mac OS X</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>There is general information about programming with WebKit on <a href="https://developer.apple.com/library/mac/documentation/cocoa/conceptual/DisplayWebContent/DisplayWebContent.html">Apple Developer Documentation</a>. Details about <code>Cocoa</code> programming are not covered here.</p>
|
<p>There is general information about programming with WebKit on <a href="https://developer.apple.com/library/mac/documentation/cocoa/conceptual/DisplayWebContent/DisplayWebContent.html">Apple Developer Documentation</a>. Details about <code>Cocoa</code> programming are not covered here.</p>
|
||||||
|
|
@ -274,7 +286,7 @@ extern bool example_initialize(JSGlobalContextRef context, JSObjectRef* exports)
|
||||||
@end</pre>
|
@end</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H4><a name="Javascript_gtk"></a>26.3.2.2 GTK</H4>
|
<H4><a name="Javascript_gtk">26.3.2.2 GTK</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>There is general information about programming GTK at <a href="https://developer.gnome.org/gtk2/">GTK documentation</a> and in the <a href="https://developer.gnome.org/gtk-tutorial">GTK tutorial</a>, and for Webkit there is a <a href="http://webkitgtk.org/reference/webkitgtk/stable/index.html">Webkit GTK+ API Reference</a>.</p>
|
<p>There is general information about programming GTK at <a href="https://developer.gnome.org/gtk2/">GTK documentation</a> and in the <a href="https://developer.gnome.org/gtk-tutorial">GTK tutorial</a>, and for Webkit there is a <a href="http://webkitgtk.org/reference/webkitgtk/stable/index.html">Webkit GTK+ API Reference</a>.</p>
|
||||||
|
|
@ -319,7 +331,7 @@ int main(int argc, char* argv[])
|
||||||
}</pre>
|
}</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Javascript_applications_webkit"></a>26.3.3 Creating Applications with node-webkit</H3>
|
<H3><a name="Javascript_applications_webkit">26.3.3 Creating Applications with node-webkit</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>To get started with <code>node-webkit</code> there is a very informative set of <a href="https://github.com/rogerwang/node-webkit/wiki">wiki pages</a>.</p>
|
<p>To get started with <code>node-webkit</code> there is a very informative set of <a href="https://github.com/rogerwang/node-webkit/wiki">wiki pages</a>.</p>
|
||||||
|
|
@ -410,12 +422,12 @@ open new windows, and many more things.
|
||||||
};</pre>
|
};</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H2><a name="Javascript_examples"></a>26.4 Examples</H2>
|
<H2><a name="Javascript_examples">26.4 Examples</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>Some basic examples are shown here in more detail.</p>
|
<p>Some basic examples are shown here in more detail.</p>
|
||||||
|
|
||||||
<H3><a name="Javascript_simple_example"></a>26.4.1 Simple</H3>
|
<H3><a name="Javascript_simple_example">26.4.1 Simple</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>The common example <code>simple</code> looks like this:</p>
|
<p>The common example <code>simple</code> looks like this:</p>
|
||||||
|
|
@ -465,7 +477,7 @@ example.Foo = 3.1415926;</pre>
|
||||||
|
|
||||||
<p><b>Note</b>: ECMAScript 5, the currently implemented Javascript standard, does not have modules. <code>node.js</code> and other implementations provide this mechanism defined by the <a href="http://wiki.commonjs.org/wiki/CommonJS">CommonJS</a> group. For browsers this is provided by <a href="http://browserify.org">Browserify</a>, for instance.</p>
|
<p><b>Note</b>: ECMAScript 5, the currently implemented Javascript standard, does not have modules. <code>node.js</code> and other implementations provide this mechanism defined by the <a href="http://wiki.commonjs.org/wiki/CommonJS">CommonJS</a> group. For browsers this is provided by <a href="http://browserify.org">Browserify</a>, for instance.</p>
|
||||||
|
|
||||||
<H3><a name="Javascript_class_example"></a>26.4.2 Class</H3>
|
<H3><a name="Javascript_class_example">26.4.2 Class</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>The common example <code>class</code> defines three classes, <code>Shape</code>, <code>Circle</code>, and <code>Square</code>:</p>
|
<p>The common example <code>class</code> defines three classes, <code>Shape</code>, <code>Circle</code>, and <code>Square</code>:</p>
|
||||||
|
|
@ -595,12 +607,12 @@ at emitKey (readline.js:1095:12)</pre>
|
||||||
<b>Note</b>: In ECMAScript 5 there is no concept for classes. Instead each function can be used as a constructor function which is executed by the 'new' operator. Furthermore, during construction the key property <code>prototype</code> of the constructor function is used to attach a prototype instance to the created object. A prototype is essentially an object itself that is the first-class delegate of a class used whenever the access to a property of an object fails. The very same prototype instance is shared among all instances of one type. Prototypal inheritance is explained in more detail on in <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Inheritance_and_the_prototype_chain">Inheritance and the prototype chain</a>, for instance.
|
<b>Note</b>: In ECMAScript 5 there is no concept for classes. Instead each function can be used as a constructor function which is executed by the 'new' operator. Furthermore, during construction the key property <code>prototype</code> of the constructor function is used to attach a prototype instance to the created object. A prototype is essentially an object itself that is the first-class delegate of a class used whenever the access to a property of an object fails. The very same prototype instance is shared among all instances of one type. Prototypal inheritance is explained in more detail on in <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Inheritance_and_the_prototype_chain">Inheritance and the prototype chain</a>, for instance.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Javascript_implementation"></a>26.5 Implementation</H2>
|
<H2><a name="Javascript_implementation">26.5 Implementation</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>The Javascript Module implementation has taken a very different approach compared to other language modules in order to support different Javascript interpreters.</p>
|
<p>The Javascript Module implementation has taken a very different approach compared to other language modules in order to support different Javascript interpreters.</p>
|
||||||
|
|
||||||
<H3><a name="Javascript_source_code"></a>26.5.1 Source Code</H3>
|
<H3><a name="Javascript_source_code">26.5.1 Source Code</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>The Javascript module is implemented in <code>Source/Modules/javascript.cxx</code>. It dispatches the code generation to a <code>JSEmitter</code> instance, <code>V8Emitter</code> or <code>JSCEmitter</code>. Additionally there are some helpers: <code>Template</code>, for templated code generation, and <code>JSEmitterState</code>, which is used to manage state information during AST traversal. This rough map shall make it easier to find a way through this huge source file:</p>
|
<p>The Javascript module is implemented in <code>Source/Modules/javascript.cxx</code>. It dispatches the code generation to a <code>JSEmitter</code> instance, <code>V8Emitter</code> or <code>JSCEmitter</code>. Additionally there are some helpers: <code>Template</code>, for templated code generation, and <code>JSEmitterState</code>, which is used to manage state information during AST traversal. This rough map shall make it easier to find a way through this huge source file:</p>
|
||||||
|
|
@ -701,7 +713,7 @@ Template::Template(const String *code_) { ... }
|
||||||
...</pre>
|
...</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Javascript_code_templates"></a>26.5.2 Code Templates</H3>
|
<H3><a name="Javascript_code_templates">26.5.2 Code Templates</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>All generated code is created on the basis of code templates. The templates for <em>JavascriptCore</em> can be found in <code>Lib/javascript/jsc/javascriptcode.swg</code>, for <em>v8</em> in <code>Lib/javascript/v8/javascriptcode.swg</code>.</p>
|
<p>All generated code is created on the basis of code templates. The templates for <em>JavascriptCore</em> can be found in <code>Lib/javascript/jsc/javascriptcode.swg</code>, for <em>v8</em> in <code>Lib/javascript/v8/javascriptcode.swg</code>.</p>
|
||||||
|
|
@ -740,7 +752,7 @@ t_register.replace("$jsparent", state.clazz(NAME_MANGLED))
|
||||||
</div>
|
</div>
|
||||||
<p><code>Template</code> creates a copy of that string and <code>Template::replace</code> uses Swig's <code>Replaceall</code> to replace variables in the template. <code>Template::trim</code> can be used to eliminate leading and trailing whitespaces. <code>Template::print</code> is used to write the final template string to a Swig <code>DOH</code> (based on <code>Printv</code>). All methods allow chaining.</p>
|
<p><code>Template</code> creates a copy of that string and <code>Template::replace</code> uses Swig's <code>Replaceall</code> to replace variables in the template. <code>Template::trim</code> can be used to eliminate leading and trailing whitespaces. <code>Template::print</code> is used to write the final template string to a Swig <code>DOH</code> (based on <code>Printv</code>). All methods allow chaining.</p>
|
||||||
|
|
||||||
<H3><a name="Javascript_emitter"></a>26.5.3 Emitter</H3>
|
<H3><a name="Javascript_emitter">26.5.3 Emitter</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>The Javascript module delegates code generation to a <code>JSEmitter</code> instance. The following extract shows the essential interface:</p>
|
<p>The Javascript module delegates code generation to a <code>JSEmitter</code> instance. The following extract shows the essential interface:</p>
|
||||||
|
|
@ -859,7 +871,7 @@ int JAVASCRIPT::classHandler(Node *n) {
|
||||||
</div>
|
</div>
|
||||||
<p>In <code>enterClass</code> the emitter stores state information that is necessary when processing class members. In <code>exitClass</code> the wrapper code for the whole class is generated.</p>
|
<p>In <code>enterClass</code> the emitter stores state information that is necessary when processing class members. In <code>exitClass</code> the wrapper code for the whole class is generated.</p>
|
||||||
|
|
||||||
<H3><a name="Javascript_emitter_states"></a>26.5.4 Emitter states</H3>
|
<H3><a name="Javascript_emitter_states">26.5.4 Emitter states</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>For storing information during the AST traversal the emitter provides a <code>JSEmitterState</code> with different slots to store data representing the scopes global, class, function, and variable.</p>
|
<p>For storing information during the AST traversal the emitter provides a <code>JSEmitterState</code> with different slots to store data representing the scopes global, class, function, and variable.</p>
|
||||||
|
|
@ -903,7 +915,7 @@ state.clazz(NAME, Getattr(n, "sym:name"));</pre>
|
||||||
<p>State information can be retrieved using <code>state.clazz(NAME)</code> or with <code>Getattr</code> on <code>state.clazz()</code> which actually returns a <code>Hash</code> instance.</p>
|
<p>State information can be retrieved using <code>state.clazz(NAME)</code> or with <code>Getattr</code> on <code>state.clazz()</code> which actually returns a <code>Hash</code> instance.</p>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Javascript_jsc_exceptions"></a>26.5.5 Handling Exceptions in JavascriptCore</H3>
|
<H3><a name="Javascript_jsc_exceptions">26.5.5 Handling Exceptions in JavascriptCore</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>Applications with an embedded JavascriptCore should be able to present detailed exception messages that occur in the Javascript engine. Below is an example derived from code provided by Brian Barnes on how these exception details can be extracted.</p>
|
<p>Applications with an embedded JavascriptCore should be able to present detailed exception messages that occur in the Javascript engine. Below is an example derived from code provided by Brian Barnes on how these exception details can be extracted.</p>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>SWIG Library</title>
|
<title>SWIG Library</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
<H1><a name="Library"></a>9 SWIG library</H1>
|
<H1><a name="Library">9 SWIG library</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -59,7 +60,7 @@ Alternative libraries provide similar functionality. Please read this chapter
|
||||||
carefully if you used the old libraries.
|
carefully if you used the old libraries.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Library_nn2"></a>9.1 The %include directive and library search path</H2>
|
<H2><a name="Library_nn2">9.1 The %include directive and library search path</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -91,7 +92,7 @@ Set the environment variable to hold an alternative library directory.
|
||||||
The directories that are searched are displayed when using <tt>-verbose</tt> commandline option.
|
The directories that are searched are displayed when using <tt>-verbose</tt> commandline option.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Library_nn3"></a>9.2 C Arrays and Pointers</H2>
|
<H2><a name="Library_nn3">9.2 C Arrays and Pointers</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -103,7 +104,7 @@ pointers as class-like objects. Since these functions provide direct access to
|
||||||
memory, their use is potentially unsafe and you should exercise caution.
|
memory, their use is potentially unsafe and you should exercise caution.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Library_nn4"></a>9.2.1 cpointer.i</H3>
|
<H3><a name="Library_nn4">9.2.1 cpointer.i</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -319,7 +320,7 @@ In this example, the function <tt>int_to_uint()</tt> would be used to cast type
|
||||||
<b>Note:</b> When working with simple pointers, typemaps can often be used to provide more seamless operation.
|
<b>Note:</b> When working with simple pointers, typemaps can often be used to provide more seamless operation.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Library_carrays"></a>9.2.2 carrays.i</H3>
|
<H3><a name="Library_carrays">9.2.2 carrays.i</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -497,7 +498,7 @@ you should consider using a special array object rather than a bare pointer.
|
||||||
used with types of <tt>char</tt> or <tt>char *</tt>.
|
used with types of <tt>char</tt> or <tt>char *</tt>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Library_nn6"></a>9.2.3 cmalloc.i</H3>
|
<H3><a name="Library_nn6">9.2.3 cmalloc.i</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -658,7 +659,7 @@ Now, in a script:
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Library_nn7"></a>9.2.4 cdata.i</H3>
|
<H3><a name="Library_nn7">9.2.4 cdata.i</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -760,7 +761,7 @@ char *cdata_<em>name</em>(type* ptr, int nitems)
|
||||||
Clearly they are unsafe.
|
Clearly they are unsafe.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Library_nn8"></a>9.3 C String Handling</H2>
|
<H2><a name="Library_nn8">9.3 C String Handling</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -780,7 +781,7 @@ morality. The modules in this section provide basic functionality
|
||||||
for manipulating raw C strings.
|
for manipulating raw C strings.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Library_nn9"></a>9.3.1 Default string handling</H3>
|
<H3><a name="Library_nn9">9.3.1 Default string handling</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -821,7 +822,7 @@ interpreter and lead to a crash). Furthermore, the default behavior does
|
||||||
not work well with binary data. Instead, strings are assumed to be NULL-terminated.
|
not work well with binary data. Instead, strings are assumed to be NULL-terminated.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Library_nn10"></a>9.3.2 Passing binary data</H3>
|
<H3><a name="Library_nn10">9.3.2 Passing binary data</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -863,7 +864,7 @@ In the wrapper function, the passed string will be expanded to a pointer and len
|
||||||
The <tt>(char *STRING, int LENGTH)</tt> multi-argument typemap is also available in addition to <tt>(char *STRING, size_t LENGTH)</tt>.
|
The <tt>(char *STRING, int LENGTH)</tt> multi-argument typemap is also available in addition to <tt>(char *STRING, size_t LENGTH)</tt>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Library_nn11"></a>9.3.3 Using %newobject to release memory</H3>
|
<H3><a name="Library_nn11">9.3.3 Using %newobject to release memory</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -904,7 +905,7 @@ however, you may need to provide your own "newfree" typemap for other types.
|
||||||
See <a href="Customization.html#Customization_ownership">Object ownership and %newobject</a> for more details.
|
See <a href="Customization.html#Customization_ownership">Object ownership and %newobject</a> for more details.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Library_nn12"></a>9.3.4 cstring.i</H3>
|
<H3><a name="Library_nn12">9.3.4 cstring.i</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1364,7 +1365,7 @@ structure or class instead.
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<H2><a name="Library_stl_cpp_library"></a>9.4 STL/C++ Library</H2>
|
<H2><a name="Library_stl_cpp_library">9.4 STL/C++ Library</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1392,7 +1393,8 @@ The following table shows which C++ classes are supported and the equivalent SWI
|
||||||
<tr> <td>std::set</td> <td>set</td> <td>std_set.i</td> </tr>
|
<tr> <td>std::set</td> <td>set</td> <td>std_set.i</td> </tr>
|
||||||
<tr> <td>std::string</td> <td>string</td> <td>std_string.i</td> </tr>
|
<tr> <td>std::string</td> <td>string</td> <td>std_string.i</td> </tr>
|
||||||
<tr> <td>std::vector</td> <td>vector</td> <td>std_vector.i</td> </tr>
|
<tr> <td>std::vector</td> <td>vector</td> <td>std_vector.i</td> </tr>
|
||||||
<tr> <td>std::shared_ptr</td> <td>shared_ptr</td> <td>std_shared_ptr.i</td> </tr>
|
<tr> <td>std::array</td> <td>array (C++11)</td> <td>std_array.i</td> </tr>
|
||||||
|
<tr> <td>std::shared_ptr</td> <td>shared_ptr (C++11)</td> <td>std_shared_ptr.i</td> </tr>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
@ -1402,7 +1404,7 @@ Please look for the library files in the appropriate language library directory.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Library_std_string"></a>9.4.1 std::string</H3>
|
<H3><a name="Library_std_string">9.4.1 std::string</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1486,7 +1488,7 @@ void foo(string s, const String &t); // std_string typemaps still applie
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Library_std_vector"></a>9.4.2 std::vector</H3>
|
<H3><a name="Library_std_vector">9.4.2 std::vector</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1665,7 +1667,7 @@ if you want to make their head explode.
|
||||||
details and the public API exposed to the interpreter vary.
|
details and the public API exposed to the interpreter vary.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Library_stl_exceptions"></a>9.4.3 STL exceptions</H3>
|
<H3><a name="Library_stl_exceptions">9.4.3 STL exceptions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1715,7 +1717,7 @@ The <tt>%exception</tt> directive can be used by placing the following code befo
|
||||||
Any thrown STL exceptions will then be gracefully handled instead of causing a crash.
|
Any thrown STL exceptions will then be gracefully handled instead of causing a crash.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Library_std_shared_ptr"></a>9.4.4 shared_ptr smart pointer</H3>
|
<H3><a name="Library_std_shared_ptr">9.4.4 shared_ptr smart pointer</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1906,7 +1908,7 @@ Please help to improve this support by providing patches with improvements.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Library_std_auto_ptr"></a>9.4.5 auto_ptr smart pointer</H3>
|
<H3><a name="Library_std_auto_ptr">9.4.5 auto_ptr smart pointer</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1955,10 +1957,10 @@ int value = k.getValue();
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H2><a name="Library_nn16"></a>9.5 Utility Libraries</H2>
|
<H2><a name="Library_nn16">9.5 Utility Libraries</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Library_nn17"></a>9.5.1 exception.i</H3>
|
<H3><a name="Library_nn17">9.5.1 exception.i</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>SWIG and Common Lisp</title>
|
<title>SWIG and Common Lisp</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
<H1><a name="Lisp"></a>27 SWIG and Common Lisp</H1>
|
<H1><a name="Lisp">27 SWIG and Common Lisp</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -41,7 +42,7 @@
|
||||||
Lisp, Common Foreign Function Interface(CFFI), CLisp and UFFI
|
Lisp, Common Foreign Function Interface(CFFI), CLisp and UFFI
|
||||||
foreign function interfaces.
|
foreign function interfaces.
|
||||||
</p>
|
</p>
|
||||||
<H2><a name="Lisp_nn2"></a>27.1 Allegro Common Lisp</H2>
|
<H2><a name="Lisp_nn2">27.1 Allegro Common Lisp</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -50,7 +51,7 @@
|
||||||
<a href="Allegrocl.html#Allegrocl">here</a>
|
<a href="Allegrocl.html#Allegrocl">here</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Lisp_nn3"></a>27.2 Common Foreign Function Interface(CFFI)</H2>
|
<H2><a name="Lisp_nn3">27.2 Common Foreign Function Interface(CFFI)</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -77,7 +78,7 @@ swig -cffi -module <i>module-name</i> <i>file-name</i>
|
||||||
files and the various things which you can do with them.
|
files and the various things which you can do with them.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Lisp_nn4"></a>27.2.1 Additional Commandline Options </H3>
|
<H3><a name="Lisp_nn4">27.2.1 Additional Commandline Options </a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -118,7 +119,7 @@ swig -cffi -help
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<H3><a name="Lisp_nn5"></a>27.2.2 Generating CFFI bindings</H3>
|
<H3><a name="Lisp_nn5">27.2.2 Generating CFFI bindings</a></H3>
|
||||||
|
|
||||||
|
|
||||||
As we mentioned earlier the ideal way to use SWIG is to use interface
|
As we mentioned earlier the ideal way to use SWIG is to use interface
|
||||||
|
|
@ -143,7 +144,6 @@ struct bar * my_struct;
|
||||||
struct foo {
|
struct foo {
|
||||||
int a;
|
int a;
|
||||||
struct foo * b[100];
|
struct foo * b[100];
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int pointer_func(void (*ClosureFun)( void* _fun, void* _data, void* _evt ), int p);
|
int pointer_func(void (*ClosureFun)( void* _fun, void* _data, void* _evt ), int p);
|
||||||
|
|
@ -284,9 +284,11 @@ Let's edit the interface file such that the C type "div_t*" is changed
|
||||||
%feature("export");
|
%feature("export");
|
||||||
|
|
||||||
%feature("inline") lispsort_double;
|
%feature("inline") lispsort_double;
|
||||||
|
|
||||||
%feature("intern_function", "my-lispify") lispsort_double;
|
%feature("intern_function", "my-lispify") lispsort_double;
|
||||||
|
%feature("export", package="'some-other-package") lispsort_double;
|
||||||
|
|
||||||
%rename func123 renamed_cool_func;
|
%rename func123 renamed_cool_func;
|
||||||
|
|
||||||
%ignore "pointer_func";
|
%ignore "pointer_func";
|
||||||
|
|
||||||
%include "test.h"
|
%include "test.h"
|
||||||
|
|
@ -310,11 +312,12 @@ The feature <i>intern_function</i> ensures that all C names are
|
||||||
lispsort_double;</i>, here we are using an additional feature
|
lispsort_double;</i>, here we are using an additional feature
|
||||||
which allows us to use our lispify function.
|
which allows us to use our lispify function.
|
||||||
</p>
|
</p>
|
||||||
<p>The <i>export</i> feature allows us to export the symbols. The <i>inline</i>
|
<p>The <i>export</i> feature allows us to export the symbols. If
|
||||||
feature declaims the declared function as inline. The <i>rename</i>
|
the <i>package</i> argument is given, then the symbol will be exported to
|
||||||
directive allows us to change the name(it is useful when
|
the specified Lisp package. The <i>inline</i> feature declaims the
|
||||||
generating C wrapper code for handling overloaded
|
declared function as inline. The <i>rename</i> directive allows us to
|
||||||
functions). The <i>ignore</i> directive ignores a certain
|
change the name(it is useful when generating C wrapper code for handling
|
||||||
|
overloaded functions). The <i>ignore</i> directive ignores a certain
|
||||||
declaration.
|
declaration.
|
||||||
</p>
|
</p>
|
||||||
<p>There are several other things which are possible, to see some
|
<p>There are several other things which are possible, to see some
|
||||||
|
|
@ -381,7 +384,7 @@ The feature <i>intern_function</i> ensures that all C names are
|
||||||
(n :int)
|
(n :int)
|
||||||
(array :pointer))
|
(array :pointer))
|
||||||
|
|
||||||
(cl:export '#.(my-lispify "lispsort_double" 'function))
|
(cl:export '#.(my-lispify "lispsort_double" 'function) 'some-other-package)
|
||||||
|
|
||||||
(cffi:defcenum #.(swig-lispify "color" 'enumname)
|
(cffi:defcenum #.(swig-lispify "color" 'enumname)
|
||||||
#.(swig-lispify "RED" 'enumvalue :keyword)
|
#.(swig-lispify "RED" 'enumvalue :keyword)
|
||||||
|
|
@ -392,7 +395,7 @@ The feature <i>intern_function</i> ensures that all C names are
|
||||||
|
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Lisp_nn6"></a>27.2.3 Generating CFFI bindings for C++ code</H3>
|
<H3><a name="Lisp_nn6">27.2.3 Generating CFFI bindings for C++ code</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>This feature to SWIG (for CFFI) is very new and still far from
|
<p>This feature to SWIG (for CFFI) is very new and still far from
|
||||||
|
|
@ -456,16 +459,13 @@ namespace OpenDemo {
|
||||||
static const Test zero;
|
static const Test zero;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline Test operator* (float s, const Test& v) {return v*s;}
|
inline Test operator* (float s, const Test& v) {return v*s;}
|
||||||
|
|
||||||
|
|
||||||
inline std::ostream& operator<< (std::ostream& o, const Test& v)
|
inline std::ostream& operator<< (std::ostream& o, const Test& v)
|
||||||
{
|
{
|
||||||
return o << "(" << v.x << ")";
|
return o << "(" << v.x << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Test RandomUnitVectorOnXZPlane (void)
|
inline Test RandomUnitVectorOnXZPlane (void)
|
||||||
{
|
{
|
||||||
return RandomVectorInUnitRadiusSphere().setYtoZero().normalize();
|
return RandomVectorInUnitRadiusSphere().setYtoZero().normalize();
|
||||||
|
|
@ -568,7 +568,7 @@ If you have any questions, suggestions, patches, etc., related to CFFI
|
||||||
module feel free to contact us on the SWIG mailing list, and
|
module feel free to contact us on the SWIG mailing list, and
|
||||||
also please add a "[CFFI]" tag in the subject line.
|
also please add a "[CFFI]" tag in the subject line.
|
||||||
|
|
||||||
<H3><a name="Lisp_nn7"></a>27.2.4 Inserting user code into generated files</H3>
|
<H3><a name="Lisp_nn7">27.2.4 Inserting user code into generated files</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -608,7 +608,7 @@ Note that the block <tt>%{ ... %}</tt> is effectively a shortcut for
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="Lisp_nn8"></a>27.3 CLISP</H2>
|
<H2><a name="Lisp_nn8">27.3 CLISP</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -638,7 +638,7 @@ swig -clisp -module <i>module-name</i> <i>file-name</i>
|
||||||
interface file for the CLISP module. The CLISP module tries to
|
interface file for the CLISP module. The CLISP module tries to
|
||||||
produce code which is both human readable and easily modifyable.
|
produce code which is both human readable and easily modifyable.
|
||||||
</p>
|
</p>
|
||||||
<H3><a name="Lisp_nn9"></a>27.3.1 Additional Commandline Options </H3>
|
<H3><a name="Lisp_nn9">27.3.1 Additional Commandline Options </a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -671,7 +671,7 @@ and global variables will be created otherwise only definitions for<br/>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<H3><a name="Lisp_nn10"></a>27.3.2 Details on CLISP bindings</H3>
|
<H3><a name="Lisp_nn10">27.3.2 Details on CLISP bindings</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -795,7 +795,7 @@ struct bar {
|
||||||
|
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H2><a name="Lisp_nn11"></a>27.4 UFFI </H2>
|
<H2><a name="Lisp_nn11">27.4 UFFI </a></H2>
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>SWIG and Lua</title>
|
<title>SWIG and Lua</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
<H1><a name="Lua"></a>28 SWIG and Lua</H1>
|
<H1><a name="Lua">28 SWIG and Lua</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -82,14 +83,14 @@ Lua is an extension programming language designed to support general procedural
|
||||||
eLua stands for Embedded Lua (can be thought of as a flavor of Lua) and offers the full implementation of the Lua programming language to the embedded world, extending it with specific features for efficient and portable software embedded development. eLua runs on smaller devices like microcontrollers and provides the full features of the regular Lua desktop version. More information on eLua can be found here: <a href="http://www.eluaproject.net">http://www.eluaproject.net</a>
|
eLua stands for Embedded Lua (can be thought of as a flavor of Lua) and offers the full implementation of the Lua programming language to the embedded world, extending it with specific features for efficient and portable software embedded development. eLua runs on smaller devices like microcontrollers and provides the full features of the regular Lua desktop version. More information on eLua can be found here: <a href="http://www.eluaproject.net">http://www.eluaproject.net</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Lua_nn2"></a>28.1 Preliminaries</H2>
|
<H2><a name="Lua_nn2">28.1 Preliminaries</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
The current SWIG implementation is designed to work with Lua 5.0.x, 5.1.x and 5.2.x. It should work with later versions of Lua, but certainly not with Lua 4.0 due to substantial API changes. It is possible to either static link or dynamic link a Lua module into the interpreter (normally Lua static links its libraries, as dynamic linking is not available on all platforms). SWIG also has support for eLua starting from eLua 0.8. Due to substantial changes between SWIG 2.x and SWIG 3.0 and unavailability of testing platform, eLua status was downgraded to 'experimental'.
|
The current SWIG implementation is designed to work with Lua 5.0.x, 5.1.x and 5.2.x. It should work with later versions of Lua, but certainly not with Lua 4.0 due to substantial API changes. It is possible to either static link or dynamic link a Lua module into the interpreter (normally Lua static links its libraries, as dynamic linking is not available on all platforms). SWIG also has support for eLua starting from eLua 0.8. Due to substantial changes between SWIG 2.x and SWIG 3.0 and unavailability of testing platform, eLua status was downgraded to 'experimental'.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Lua_nn3"></a>28.2 Running SWIG</H2>
|
<H2><a name="Lua_nn3">28.2 Running SWIG</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -137,7 +138,7 @@ $ swig -lua -eluac example.i
|
||||||
The <tt>-elua</tt> option puts all the C function wrappers and variable get/set wrappers in rotables. It also generates a metatable which will control the access to these variables from eLua. It also offers a significant amount of module size compression. On the other hand, the <tt>-eluac</tt> option puts all the wrappers in a single rotable. With this option, no matter how huge the module, it will consume no additional microcontroller SRAM (crass compression). There is a catch though: Metatables are not generated with <tt>-eluac</tt>. To access any value from eLua, one must directly call the wrapper function associated with that value.
|
The <tt>-elua</tt> option puts all the C function wrappers and variable get/set wrappers in rotables. It also generates a metatable which will control the access to these variables from eLua. It also offers a significant amount of module size compression. On the other hand, the <tt>-eluac</tt> option puts all the wrappers in a single rotable. With this option, no matter how huge the module, it will consume no additional microcontroller SRAM (crass compression). There is a catch though: Metatables are not generated with <tt>-eluac</tt>. To access any value from eLua, one must directly call the wrapper function associated with that value.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Lua_commandline"></a>28.2.1 Additional command line options</H3>
|
<H3><a name="Lua_commandline">28.2.1 Additional command line options</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -178,7 +179,7 @@ swig -lua -help
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<H3><a name="Lua_nn4"></a>28.2.2 Compiling and Linking and Interpreter</H3>
|
<H3><a name="Lua_nn4">28.2.2 Compiling and Linking and Interpreter</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -249,7 +250,7 @@ LUALIB_API int ( luaopen_mod )(lua_State *L );
|
||||||
More information on building and configuring eLua can be found here: <a href="http://www.eluaproject.net/doc/v0.8/en_building.html">http://www.eluaproject.net/doc/v0.8/en_building.html</a>
|
More information on building and configuring eLua can be found here: <a href="http://www.eluaproject.net/doc/v0.8/en_building.html">http://www.eluaproject.net/doc/v0.8/en_building.html</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Lua_nn5"></a>28.2.3 Compiling a dynamic module</H3>
|
<H3><a name="Lua_nn5">28.2.3 Compiling a dynamic module</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -317,7 +318,7 @@ Is quite obvious (Go back and consult the Lua documents on how to enable loadlib
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Lua_nn6"></a>28.2.4 Using your module</H3>
|
<H3><a name="Lua_nn6">28.2.4 Using your module</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -335,19 +336,19 @@ $ ./my_lua
|
||||||
>
|
>
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H2><a name="Lua_nn7"></a>28.3 A tour of basic C/C++ wrapping</H2>
|
<H2><a name="Lua_nn7">28.3 A tour of basic C/C++ wrapping</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
By default, SWIG tries to build a very natural Lua interface to your C/C++ code. This section briefly covers the essential aspects of this wrapping.
|
By default, SWIG tries to build a very natural Lua interface to your C/C++ code. This section briefly covers the essential aspects of this wrapping.
|
||||||
</p>
|
</p>
|
||||||
<H3><a name="Lua_nn8"></a>28.3.1 Modules</H3>
|
<H3><a name="Lua_nn8">28.3.1 Modules</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
The SWIG module directive specifies the name of the Lua module. If you specify `module example', then everything is wrapped into a Lua table 'example' containing all the functions and variables. When choosing a module name, make sure you don't use the same name as a built-in Lua command or standard module name.
|
The SWIG module directive specifies the name of the Lua module. If you specify `module example', then everything is wrapped into a Lua table 'example' containing all the functions and variables. When choosing a module name, make sure you don't use the same name as a built-in Lua command or standard module name.
|
||||||
</p>
|
</p>
|
||||||
<H3><a name="Lua_nn9"></a>28.3.2 Functions</H3>
|
<H3><a name="Lua_nn9">28.3.2 Functions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -388,7 +389,7 @@ It is also possible to rename the module with an assignment.
|
||||||
24
|
24
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Lua_nn10"></a>28.3.3 Global variables</H3>
|
<H3><a name="Lua_nn10">28.3.3 Global variables</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -476,7 +477,7 @@ If you have used the <tt>-eluac</tt> option for your eLua module, you will have
|
||||||
In general, functions of the form <tt>"variable_get()"</tt> and <tt>"variable_set()"</tt> are automatically generated by SWIG for use with <tt>-eluac</tt>.
|
In general, functions of the form <tt>"variable_get()"</tt> and <tt>"variable_set()"</tt> are automatically generated by SWIG for use with <tt>-eluac</tt>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Lua_nn11"></a>28.3.4 Constants and enums</H3>
|
<H3><a name="Lua_nn11">28.3.4 Constants and enums</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -511,7 +512,7 @@ If you're using eLua and have used <tt>-elua</tt> or <tt>-eluac</tt> to generate
|
||||||
Hello World
|
Hello World
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H4><a name="Lua_nn13"></a>28.3.4.1 Constants/enums and classes/structures</H4>
|
<H4><a name="Lua_nn13">28.3.4.1 Constants/enums and classes/structures</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -567,7 +568,7 @@ If the <tt>-no-old-metatable-bindings</tt> option is used, then these old-style
|
||||||
It is worth mentioning, that <tt>example.Test.TEST1</tt> and <tt>example.Test_TEST1</tt> are different entities and changing one does not change the other.
|
It is worth mentioning, that <tt>example.Test.TEST1</tt> and <tt>example.Test_TEST1</tt> are different entities and changing one does not change the other.
|
||||||
Given the fact that these are constantes and they are not supposed to be changed, it is up to you to avoid such issues.
|
Given the fact that these are constantes and they are not supposed to be changed, it is up to you to avoid such issues.
|
||||||
</p>
|
</p>
|
||||||
<H3><a name="Lua_nn12"></a>28.3.5 Pointers</H3>
|
<H3><a name="Lua_nn12">28.3.5 Pointers</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -605,7 +606,7 @@ Lua enforces the integrity of its userdata, so it is virtually impossible to cor
|
||||||
nil
|
nil
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Lua_structures"></a>28.3.6 Structures</H3>
|
<H3><a name="Lua_structures">28.3.6 Structures</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -709,7 +710,7 @@ For eLua with the <tt>-eluac</tt> option, structure manipulation has to be perfo
|
||||||
In general, functions of the form <tt>"new_struct()"</tt>, <tt>"struct_member_get()"</tt>, <tt>"struct_member_set()"</tt> and <tt>"free_struct()"</tt> are automatically generated by SWIG for each structure defined in C. (Please note: This doesn't apply for modules generated with the <tt>-elua</tt> option)
|
In general, functions of the form <tt>"new_struct()"</tt>, <tt>"struct_member_get()"</tt>, <tt>"struct_member_set()"</tt> and <tt>"free_struct()"</tt> are automatically generated by SWIG for each structure defined in C. (Please note: This doesn't apply for modules generated with the <tt>-elua</tt> option)
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Lua_nn14"></a>28.3.7 C++ classes</H3>
|
<H3><a name="Lua_nn14">28.3.7 C++ classes</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -784,7 +785,7 @@ Both style names are generated by default now.
|
||||||
However, if the <tt>-no-old-metatable-bindings</tt> option is used, then the backward compatible names are not generated in addition to ordinary ones.
|
However, if the <tt>-no-old-metatable-bindings</tt> option is used, then the backward compatible names are not generated in addition to ordinary ones.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Lua_nn15"></a>28.3.8 C++ inheritance</H3>
|
<H3><a name="Lua_nn15">28.3.8 C++ inheritance</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -809,7 +810,7 @@ then the function <tt>spam()</tt> accepts a Foo pointer or a pointer to any clas
|
||||||
<p>
|
<p>
|
||||||
It is safe to use multiple inheritance with SWIG.
|
It is safe to use multiple inheritance with SWIG.
|
||||||
</p>
|
</p>
|
||||||
<H3><a name="Lua_nn16"></a>28.3.9 Pointers, references, values, and arrays</H3>
|
<H3><a name="Lua_nn16">28.3.9 Pointers, references, values, and arrays</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -840,7 +841,7 @@ Foo spam7();
|
||||||
<p>
|
<p>
|
||||||
then all three functions will return a pointer to some Foo object. Since the third function (spam7) returns a value, newly allocated memory is used to hold the result and a pointer is returned (Lua will release this memory when the return value is garbage collected). The other two are pointers which are assumed to be managed by the C code and so will not be garbage collected.
|
then all three functions will return a pointer to some Foo object. Since the third function (spam7) returns a value, newly allocated memory is used to hold the result and a pointer is returned (Lua will release this memory when the return value is garbage collected). The other two are pointers which are assumed to be managed by the C code and so will not be garbage collected.
|
||||||
</p>
|
</p>
|
||||||
<H3><a name="Lua_nn17"></a>28.3.10 C++ overloaded functions</H3>
|
<H3><a name="Lua_nn17">28.3.10 C++ overloaded functions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -926,7 +927,7 @@ Please refer to the "SWIG and C++" chapter for more information about overloadin
|
||||||
<p>
|
<p>
|
||||||
Dealing with the Lua coercion mechanism, the priority is roughly (integers, floats, strings, userdata). But it is better to rename the functions rather than rely upon the ordering.
|
Dealing with the Lua coercion mechanism, the priority is roughly (integers, floats, strings, userdata). But it is better to rename the functions rather than rely upon the ordering.
|
||||||
</p>
|
</p>
|
||||||
<H3><a name="Lua_nn18"></a>28.3.11 C++ operators</H3>
|
<H3><a name="Lua_nn18">28.3.11 C++ operators</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1060,7 +1061,7 @@ operators and pseudo-operators):</p>
|
||||||
</ul>
|
</ul>
|
||||||
<p>No other lua metafunction is inherited. For example, __gc is not inherited and must be redefined in every class. <tt>__tostring</tt> is subject to a special handling. If absent in class and in class bases, a default one will be provided by SWIG.
|
<p>No other lua metafunction is inherited. For example, __gc is not inherited and must be redefined in every class. <tt>__tostring</tt> is subject to a special handling. If absent in class and in class bases, a default one will be provided by SWIG.
|
||||||
</p>
|
</p>
|
||||||
<H3><a name="Lua_nn19"></a>28.3.12 Class extension with %extend</H3>
|
<H3><a name="Lua_nn19">28.3.12 Class extension with %extend</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1094,8 +1095,9 @@ Now we extend it with some new code
|
||||||
sprintf(tmp,"Complex(%g,%g)", $self->re(),$self->im());
|
sprintf(tmp,"Complex(%g,%g)", $self->re(),$self->im());
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
bool operator==(const Complex& c)
|
bool operator==(const Complex& c) {
|
||||||
{ return ($self->re()==c.re() && $self->im()==c.im());}
|
return ($self->re()==c.re() && $self->im()==c.im());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
</pre></div>
|
</pre></div>
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1116,7 +1118,7 @@ true
|
||||||
Extend works with both C and C++ code, on classes and structs. It does not modify the underlying object in any way---the extensions only show up in the Lua interface. The only item to take note of is the code has to use the '$self' instead of 'this', and that you cannot access protected/private members of the code (as you are not officially part of the class).
|
Extend works with both C and C++ code, on classes and structs. It does not modify the underlying object in any way---the extensions only show up in the Lua interface. The only item to take note of is the code has to use the '$self' instead of 'this', and that you cannot access protected/private members of the code (as you are not officially part of the class).
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Lua_nn20"></a>28.3.13 Using %newobject to release memory</H3>
|
<H3><a name="Lua_nn20">28.3.13 Using %newobject to release memory</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> If you have a function that allocates memory like this,</p>
|
<p> If you have a function that allocates memory like this,</p>
|
||||||
|
|
@ -1140,7 +1142,7 @@ char *foo();
|
||||||
</div>
|
</div>
|
||||||
<p> This will release the allocated memory.</p>
|
<p> This will release the allocated memory.</p>
|
||||||
|
|
||||||
<H3><a name="Lua_nn21"></a>28.3.14 C++ templates</H3>
|
<H3><a name="Lua_nn21">28.3.14 C++ templates</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1175,7 +1177,7 @@ In Lua:
|
||||||
<p>
|
<p>
|
||||||
Obviously, there is more to template wrapping than shown in this example. More details can be found in the SWIG and C++ chapter. Some more complicated examples will appear later.
|
Obviously, there is more to template wrapping than shown in this example. More details can be found in the SWIG and C++ chapter. Some more complicated examples will appear later.
|
||||||
</p>
|
</p>
|
||||||
<H3><a name="Lua_nn22"></a>28.3.15 C++ Smart Pointers</H3>
|
<H3><a name="Lua_nn22">28.3.15 C++ Smart Pointers</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1227,7 +1229,7 @@ If you ever need to access the underlying pointer returned by <tt>operator->(
|
||||||
> f = p:__deref__() -- Returns underlying Foo *
|
> f = p:__deref__() -- Returns underlying Foo *
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Lua_nn23"></a>28.3.16 C++ Exceptions</H3>
|
<H3><a name="Lua_nn23">28.3.16 C++ Exceptions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1370,7 +1372,7 @@ and the "<a href="Customization.html#Customization_exception">Exception handling
|
||||||
add exception specification to functions or globally (respectively).
|
add exception specification to functions or globally (respectively).
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Lua_namespaces"></a>28.3.17 Namespaces </H3>
|
<H3><a name="Lua_namespaces">28.3.17 Namespaces </a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1421,7 +1423,7 @@ Now, from Lua usage is as follows:
|
||||||
19
|
19
|
||||||
>
|
>
|
||||||
</pre></div>
|
</pre></div>
|
||||||
<H4><a name="Lua_nn27"></a>28.3.17.1 Compatibility Note </H4>
|
<H4><a name="Lua_nn27">28.3.17.1 Compatibility Note </a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1437,7 +1439,7 @@ If SWIG is running in a backwards compatible way, i.e. without the <tt>-no-old-m
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
|
|
||||||
<H4><a name="Lua_nn29"></a>28.3.17.2 Names </H4>
|
<H4><a name="Lua_nn29">28.3.17.2 Names </a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p> If SWIG is launched without <tt>-no-old-metatable-bindings</tt> option, then it enters backward-compatible mode. While in this mode, it tries
|
<p> If SWIG is launched without <tt>-no-old-metatable-bindings</tt> option, then it enters backward-compatible mode. While in this mode, it tries
|
||||||
|
|
@ -1481,7 +1483,7 @@ surrounding scope without any prefixing. Pretending that Test2 is a struct, not
|
||||||
>
|
>
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H4><a name="Lua_nn30"></a>28.3.17.3 Inheritance </H4>
|
<H4><a name="Lua_nn30">28.3.17.3 Inheritance </a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p> The internal organization of inheritance has changed.
|
<p> The internal organization of inheritance has changed.
|
||||||
|
|
@ -1522,12 +1524,12 @@ function
|
||||||
>
|
>
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H2><a name="Lua_nn24"></a>28.4 Typemaps</H2>
|
<H2><a name="Lua_nn24">28.4 Typemaps</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>This section explains what typemaps are and how to use them. The default wrapping behaviour of SWIG is enough in most cases. However sometimes SWIG may need a little additional assistance to know which typemap to apply to provide the best wrapping. This section will be explaining how to use typemaps to best effect</p>
|
<p>This section explains what typemaps are and how to use them. The default wrapping behaviour of SWIG is enough in most cases. However sometimes SWIG may need a little additional assistance to know which typemap to apply to provide the best wrapping. This section will be explaining how to use typemaps to best effect</p>
|
||||||
|
|
||||||
<H3><a name="Lua_nn25"></a>28.4.1 What is a typemap?</H3>
|
<H3><a name="Lua_nn25">28.4.1 What is a typemap?</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>A typemap is nothing more than a code generation rule that is attached to a specific C datatype. For example, to convert integers from Lua to C, you might define a typemap like this:</p>
|
<p>A typemap is nothing more than a code generation rule that is attached to a specific C datatype. For example, to convert integers from Lua to C, you might define a typemap like this:</p>
|
||||||
|
|
@ -1555,7 +1557,7 @@ Received an integer : 6
|
||||||
720
|
720
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Lua_nn26"></a>28.4.2 Using typemaps</H3>
|
<H3><a name="Lua_nn26">28.4.2 Using typemaps</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>There are many ready written typemaps built into SWIG for all common types (int, float, short, long, char*, enum and more), which SWIG uses automatically, with no effort required on your part.</p>
|
<p>There are many ready written typemaps built into SWIG for all common types (int, float, short, long, char*, enum and more), which SWIG uses automatically, with no effort required on your part.</p>
|
||||||
|
|
@ -1608,7 +1610,7 @@ void swap(int *sx, int *sy);
|
||||||
|
|
||||||
<p>Note: C++ references must be handled exactly the same way. However SWIG will automatically wrap a <tt>const int&</tt> as an input parameter (since that it obviously input).</p>
|
<p>Note: C++ references must be handled exactly the same way. However SWIG will automatically wrap a <tt>const int&</tt> as an input parameter (since that it obviously input).</p>
|
||||||
|
|
||||||
<H3><a name="Lua_typemap_arrays"></a>28.4.3 Typemaps and arrays</H3>
|
<H3><a name="Lua_typemap_arrays">28.4.3 Typemaps and arrays</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>Arrays present a challenge for SWIG, because like pointers SWIG does not know whether these are input or output values, nor
|
<p>Arrays present a challenge for SWIG, because like pointers SWIG does not know whether these are input or output values, nor
|
||||||
|
|
@ -1672,7 +1674,7 @@ and Lua tables to be 1..N, (the indexing follows the norm for the language). In
|
||||||
|
|
||||||
<p>Note: SWIG also can support arrays of pointers in a similar manner.</p>
|
<p>Note: SWIG also can support arrays of pointers in a similar manner.</p>
|
||||||
|
|
||||||
<H3><a name="Lua_typemaps_ptr_ptr_functions"></a>28.4.4 Typemaps and pointer-pointer functions</H3>
|
<H3><a name="Lua_typemaps_ptr_ptr_functions">28.4.4 Typemaps and pointer-pointer functions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>Several C++ libraries use a pointer-pointer functions to create its objects. These functions require a pointer to a pointer which is then filled with the pointer to the new object. Microsoft's COM and DirectX as well as many other libraries have this kind of function. An example is given below:</p>
|
<p>Several C++ libraries use a pointer-pointer functions to create its objects. These functions require a pointer to a pointer which is then filled with the pointer to the new object. Microsoft's COM and DirectX as well as many other libraries have this kind of function. An example is given below:</p>
|
||||||
|
|
@ -1706,7 +1708,7 @@ int Create_Math(iMath** pptr); // its creator (assume it mallocs)
|
||||||
ptr=nil -- the iMath* will be GC'ed as normal
|
ptr=nil -- the iMath* will be GC'ed as normal
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H2><a name="Lua_writing_typemaps"></a>28.5 Writing typemaps</H2>
|
<H2><a name="Lua_writing_typemaps">28.5 Writing typemaps</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>This section describes how you can modify SWIG's default wrapping behavior for various C/C++ datatypes using the <tt>%typemap</tt> directive. This is an advanced topic that assumes familiarity with the Lua C API as well as the material in the "<a href="Typemaps.html#Typemaps">Typemaps</a>" chapter.</p>
|
<p>This section describes how you can modify SWIG's default wrapping behavior for various C/C++ datatypes using the <tt>%typemap</tt> directive. This is an advanced topic that assumes familiarity with the Lua C API as well as the material in the "<a href="Typemaps.html#Typemaps">Typemaps</a>" chapter.</p>
|
||||||
|
|
@ -1715,7 +1717,7 @@ ptr=nil -- the iMath* will be GC'ed as normal
|
||||||
|
|
||||||
<p>Before proceeding, you should read the previous section on using typemaps, and look at the existing typemaps found in luatypemaps.swg and typemaps.i. These are both well documented and fairly easy to read. You should not attempt to write your own typemaps until you have read and can understand both of these files (they may well also give you an idea to base your work on).</p>
|
<p>Before proceeding, you should read the previous section on using typemaps, and look at the existing typemaps found in luatypemaps.swg and typemaps.i. These are both well documented and fairly easy to read. You should not attempt to write your own typemaps until you have read and can understand both of these files (they may well also give you an idea to base your work on).</p>
|
||||||
|
|
||||||
<H3><a name="Lua_typemaps_write"></a>28.5.1 Typemaps you can write</H3>
|
<H3><a name="Lua_typemaps_write">28.5.1 Typemaps you can write</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>There are many different types of typemap that can be written, the full list can be found in the "<a href="Typemaps.html#Typemaps">Typemaps</a>" chapter. However the following are the most commonly used ones.</p>
|
<p>There are many different types of typemap that can be written, the full list can be found in the "<a href="Typemaps.html#Typemaps">Typemaps</a>" chapter. However the following are the most commonly used ones.</p>
|
||||||
|
|
@ -1728,7 +1730,7 @@ ptr=nil -- the iMath* will be GC'ed as normal
|
||||||
(the syntax for the typecheck is different from the typemap, see typemaps for details).</li>
|
(the syntax for the typecheck is different from the typemap, see typemaps for details).</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<H3><a name="Lua_nn31"></a>28.5.2 SWIG's Lua-C API</H3>
|
<H3><a name="Lua_nn31">28.5.2 SWIG's Lua-C API</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>This section explains the SWIG specific Lua-C API. It does not cover the main Lua-C api, as this is well documented and not worth covering.</p>
|
<p>This section explains the SWIG specific Lua-C API. It does not cover the main Lua-C api, as this is well documented and not worth covering.</p>
|
||||||
|
|
@ -1738,7 +1740,7 @@ ptr=nil -- the iMath* will be GC'ed as normal
|
||||||
<div class="indent">
|
<div class="indent">
|
||||||
This is the standard function used for converting a Lua userdata to a void*. It takes the value at the given index in the Lua state and converts it to a userdata. It will then provide the necessary type checks, confirming that the pointer is compatible with the type given in 'type'. Then finally setting '*ptr' to the pointer.
|
This is the standard function used for converting a Lua userdata to a void*. It takes the value at the given index in the Lua state and converts it to a userdata. It will then provide the necessary type checks, confirming that the pointer is compatible with the type given in 'type'. Then finally setting '*ptr' to the pointer.
|
||||||
If flags is set to SWIG_POINTER_DISOWN, this is will clear any ownership flag set on the object.<br>
|
If flags is set to SWIG_POINTER_DISOWN, this is will clear any ownership flag set on the object.<br>
|
||||||
The returns a value which can be checked with the macro SWIG_IsOK()
|
This returns a value which can be checked with the macro SWIG_IsOK()
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p><tt>void SWIG_NewPointerObj(lua_State* L,void* ptr,swig_type_info *type,int own);</tt></p>
|
<p><tt>void SWIG_NewPointerObj(lua_State* L,void* ptr,swig_type_info *type,int own);</tt></p>
|
||||||
|
|
@ -1777,7 +1779,7 @@ This macro, when called within the context of a SWIG wrapped function, will disp
|
||||||
<div class="indent">
|
<div class="indent">
|
||||||
Similar to SWIG_fail_arg, except that it will display the swig_type_info information instead.</div>
|
Similar to SWIG_fail_arg, except that it will display the swig_type_info information instead.</div>
|
||||||
|
|
||||||
<H2><a name="Lua_nn32"></a>28.6 Customization of your Bindings</H2>
|
<H2><a name="Lua_nn32">28.6 Customization of your Bindings</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1786,7 +1788,7 @@ This section covers adding of some small extra bits to your module to add the la
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Lua_nn33"></a>28.6.1 Writing your own custom wrappers</H3>
|
<H3><a name="Lua_nn33">28.6.1 Writing your own custom wrappers</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1805,7 +1807,7 @@ int native_function(lua_State*L) // my native code
|
||||||
The <tt>%native</tt> directive in the above example, tells SWIG that there is a function <tt>int native_function(lua_State*L);</tt> which is to be added into the module under the name '<tt>my_func</tt>'. SWIG will not add any wrapper for this function, beyond adding it into the function table. How you write your code is entirely up to you.
|
The <tt>%native</tt> directive in the above example, tells SWIG that there is a function <tt>int native_function(lua_State*L);</tt> which is to be added into the module under the name '<tt>my_func</tt>'. SWIG will not add any wrapper for this function, beyond adding it into the function table. How you write your code is entirely up to you.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Lua_nn34"></a>28.6.2 Adding additional Lua code</H3>
|
<H3><a name="Lua_nn34">28.6.2 Adding additional Lua code</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1843,7 +1845,7 @@ Good uses for this feature is adding of new code, or writing helper functions to
|
||||||
See Examples/lua/arrays for an example of this code.
|
See Examples/lua/arrays for an example of this code.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Lua_nn35"></a>28.7 Details on the Lua binding</H2>
|
<H2><a name="Lua_nn35">28.7 Details on the Lua binding</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1854,7 +1856,7 @@ See Examples/lua/arrays for an example of this code.
|
||||||
</i>
|
</i>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Lua_nn36"></a>28.7.1 Binding global data into the module.</H3>
|
<H3><a name="Lua_nn36">28.7.1 Binding global data into the module.</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1914,7 +1916,7 @@ end
|
||||||
<p>
|
<p>
|
||||||
That way when you call '<tt>a=example.Foo</tt>', the interpreter looks at the table 'example' sees that there is no field 'Foo' and calls __index. This will in turn check in '.get' table and find the existence of 'Foo' and then return the value of the C function call 'Foo_get()'. Similarly for the code '<tt>example.Foo=10</tt>', the interpreter will check the table, then call the __newindex which will then check the '.set' table and call the C function 'Foo_set(10)'.
|
That way when you call '<tt>a=example.Foo</tt>', the interpreter looks at the table 'example' sees that there is no field 'Foo' and calls __index. This will in turn check in '.get' table and find the existence of 'Foo' and then return the value of the C function call 'Foo_get()'. Similarly for the code '<tt>example.Foo=10</tt>', the interpreter will check the table, then call the __newindex which will then check the '.set' table and call the C function 'Foo_set(10)'.
|
||||||
</p>
|
</p>
|
||||||
<H3><a name="Lua_nn37"></a>28.7.2 Userdata and Metatables</H3>
|
<H3><a name="Lua_nn37">28.7.2 Userdata and Metatables</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1994,7 +1996,7 @@ Note: Both the opaque structures (like the FILE*) and normal wrapped classes/str
|
||||||
<p>
|
<p>
|
||||||
Note: Operator overloads are basically done in the same way, by adding functions such as '__add' & '__call' to the class' metatable. The current implementation is a bit rough as it will add any member function beginning with '__' into the metatable too, assuming its an operator overload.
|
Note: Operator overloads are basically done in the same way, by adding functions such as '__add' & '__call' to the class' metatable. The current implementation is a bit rough as it will add any member function beginning with '__' into the metatable too, assuming its an operator overload.
|
||||||
</p>
|
</p>
|
||||||
<H3><a name="Lua_nn38"></a>28.7.3 Memory management</H3>
|
<H3><a name="Lua_nn38">28.7.3 Memory management</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,17 @@
|
||||||
# Makefile for generating the SWIG documentation
|
# Makefile for generating the SWIG documentation
|
||||||
#
|
#
|
||||||
# Note that the htmldoc package needs to be installed, but requires patching (using the
|
# Note that the htmldoc package needs to be installed. wkhtmltopdf patched with qt is also required
|
||||||
# margin-left.patch file from this directory) in order to correctly generate the pdf docs.
|
# and can be installed from http://wkhtmltopdf.org/downloads.html.
|
||||||
|
#
|
||||||
# The .html files are first processed and updated with chapter numbering and anchor names
|
# The .html files are first processed and updated with chapter numbering and anchor names
|
||||||
# are added to the HTML headings using the python scripts. The htmldoc program is then
|
# are added to the HTML headings using the python scripts. The htmldoc program is then
|
||||||
# used to generate the PDF document and single page HTML version of the documentation.
|
# used to generate the single page HTML version of the documentation.
|
||||||
|
# wkhtmltopdf is used to generate the pdf document from the single page html file.
|
||||||
# HTML TIDY (package also known as tidy) is also required and is used as an aid to HTML
|
# HTML TIDY (package also known as tidy) is also required and is used as an aid to HTML
|
||||||
# validation.
|
# validation.
|
||||||
#
|
#
|
||||||
# Additional html validation can be done using the validate target.
|
# Additional html validation can be done using the validate target.
|
||||||
# Additional link checking can be done using the linkchecker target.
|
# Additional link checking can be done using the linkchecker1 and linkchecker2 target.
|
||||||
#
|
#
|
||||||
|
|
||||||
# Note the # and " are escaped
|
# Note the # and " are escaped
|
||||||
|
|
@ -19,31 +21,35 @@ HTMLDOC_OPTIONS = "--book --toclevels 4 --no-numbered --toctitle \"Table of Cont
|
||||||
|
|
||||||
all: maketoc check generate
|
all: maketoc check generate
|
||||||
|
|
||||||
maketoc: CCache.html
|
maketoc:
|
||||||
python maketoc.py
|
python maketoc.py
|
||||||
|
|
||||||
|
# Use this to regenerate CCache.html should this ever be needed
|
||||||
CCache.html: ../../CCache/ccache.yo
|
CCache.html: ../../CCache/ccache.yo
|
||||||
yodl2html -o CCache.html ../../CCache/ccache.yo
|
yodl2html -o CCache.html ../../CCache/ccache.yo
|
||||||
|
|
||||||
|
# Tabs in the html files will stop the build as wkhtmltopdf does not expand them correctly - replace them with the appropriate number of tabs
|
||||||
# Use htmltidy to warn about some HTML errors. Note that it is not used to clean/tidy the HTML,
|
# Use htmltidy to warn about some HTML errors. Note that it is not used to clean/tidy the HTML,
|
||||||
# it is just used as a primitive HTML checker.
|
# it is just used as a primitive HTML checker.
|
||||||
# CCache.html is generated by yodl2html and has a few insignificant problems, so we don't put it through tidy
|
# CCache.html is generated by yodl2html and has a few insignificant problems, so we don't put it through tidy
|
||||||
check:
|
check:
|
||||||
tidy -errors --gnu-emacs yes -quiet index.html
|
all="index.html Sections.html `sed '/^#/d' chapters | grep -v CCache.html`" && for a in $$all; do echo "Check for tabs $$a" && if grep -P '\t' $$a; then echo "Please delete the tabs from the lines above" && exit 1; fi; done && for a in $$all; do echo "HTML tidy check $$a" && tidy -errors --gnu-emacs yes -quiet $$a; done;
|
||||||
tidy -errors --gnu-emacs yes -quiet Sections.html
|
|
||||||
all=`sed '/^#/d' chapters | grep -v CCache.html`; for a in $$all; do tidy -errors --gnu-emacs yes -quiet $$a; done;
|
|
||||||
|
|
||||||
generate: swightml.book swigpdf.book
|
# Note wkhtmltopdf limitations for generating pdf docs:
|
||||||
|
# 1) <H1><a name="X"></a>Text</H1> style links don't work and need changing to
|
||||||
|
# <H1><a name="X">Text</a></H1>
|
||||||
|
# 2) Tabs in <pre> elements should be expanded to 8 spaces by default, but
|
||||||
|
# are expanded to just one space and css tab-size is not working.
|
||||||
|
# 3) <pre> <tt> <code> elements do not always select a fixed-width font - try installing the
|
||||||
|
# Courier font to fix - these have been added to style.css.
|
||||||
|
generate: SWIGDocumentation.html
|
||||||
|
wkhtmltopdf --version | grep "with patched qt" || (echo "wkhtmltopdf is not the patched qt version and so cannot be used - download it from http://wkhtmltopdf.org/downloads.html" && false)
|
||||||
|
wkhtmltopdf --margin-top 20mm --margin-bottom 20mm --margin-left 10mm --margin-right 10mm --header-font-size 6 --footer-font-size 6 --header-spacing 6 --footer-spacing 6 --header-center '[doctitle]' --footer-left '[subsection]' --footer-right '[page]' SWIGDocumentation.html SWIGDocumentation.pdf
|
||||||
|
|
||||||
|
SWIGDocumentation.html: swightml.book
|
||||||
htmldoc --batch swightml.book || true
|
htmldoc --batch swightml.book || true
|
||||||
htmldoc --batch swigpdf.book || true
|
|
||||||
python fixstyle.py SWIGDocumentation.html
|
python fixstyle.py SWIGDocumentation.html
|
||||||
|
|
||||||
swigpdf.book: chapters Sections.html
|
|
||||||
echo "#HTMLDOC 1.8.24" > swigpdf.book
|
|
||||||
echo -t pdf13 -f SWIGDocumentation.pdf $(HTMLDOC_OPTIONS) --stylesheet style.css >> swigpdf.book
|
|
||||||
echo "Sections.html" >> swigpdf.book
|
|
||||||
cat chapters >> swigpdf.book
|
|
||||||
|
|
||||||
swightml.book: chapters Sections.html
|
swightml.book: chapters Sections.html
|
||||||
echo "#HTMLDOC 1.8.24" > swightml.book
|
echo "#HTMLDOC 1.8.24" > swightml.book
|
||||||
echo -t html -f SWIGDocumentation.html $(HTMLDOC_OPTIONS) >> swightml.book
|
echo -t html -f SWIGDocumentation.html $(HTMLDOC_OPTIONS) >> swightml.book
|
||||||
|
|
@ -52,10 +58,9 @@ swightml.book: chapters Sections.html
|
||||||
|
|
||||||
maintainer-clean: clean-baks
|
maintainer-clean: clean-baks
|
||||||
rm -f swightml.book
|
rm -f swightml.book
|
||||||
rm -f swigpdf.book
|
|
||||||
rm -f CCache.html
|
|
||||||
rm -f SWIGDocumentation.html
|
rm -f SWIGDocumentation.html
|
||||||
rm -f SWIGDocumentation.pdf
|
rm -f SWIGDocumentation.pdf
|
||||||
|
rm -rf linkchecker-tmp
|
||||||
|
|
||||||
clean-baks:
|
clean-baks:
|
||||||
rm -f *.bak
|
rm -f *.bak
|
||||||
|
|
@ -69,9 +74,18 @@ test:
|
||||||
validate:
|
validate:
|
||||||
all=`sed '/^#/d' chapters`; for a in $$all; do validate --emacs $$a; done;
|
all=`sed '/^#/d' chapters`; for a in $$all; do validate --emacs $$a; done;
|
||||||
|
|
||||||
# Link checking using linkchecker
|
# Link checking using linkchecker of the index.html only file (including anchors)
|
||||||
linkchecker:
|
linkchecker1:
|
||||||
@echo -----------------------------------------------------------------------
|
@echo -----------------------------------------------------------------------
|
||||||
@echo Note linkchecker versions prior to 6.1 do not work properly wrt anchors
|
@echo Note linkchecker versions prior to 6.1 do not work properly wrt anchors
|
||||||
@echo -----------------------------------------------------------------------
|
@echo -----------------------------------------------------------------------
|
||||||
linkchecker --config=./linkchecker.config index.html
|
linkchecker --config=./linkchecker.config --anchors index.html
|
||||||
|
|
||||||
|
# Check for links which don't work including those generated from the individual .html files into SWIGDocumentation.html
|
||||||
|
linkchecker2:
|
||||||
|
rm -rf linkchecker-tmp
|
||||||
|
mkdir linkchecker-tmp
|
||||||
|
cp SWIGDocumentation.html linkchecker-tmp
|
||||||
|
cp *.png linkchecker-tmp
|
||||||
|
(cd linkchecker-tmp && linkchecker --config=../linkchecker.config -F text --no-warnings SWIGDocumentation.html)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>SWIG and Modula-3</title>
|
<title>SWIG and Modula-3</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
<body bgcolor="#FFFFFF">
|
<body bgcolor="#FFFFFF">
|
||||||
<H1><a name="Modula3"></a>29 SWIG and Modula-3</H1>
|
<H1><a name="Modula3">29 SWIG and Modula-3</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -54,7 +55,7 @@ especially
|
||||||
<a href="Typemaps.html#Typemaps">typemaps</a>.
|
<a href="Typemaps.html#Typemaps">typemaps</a>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Modula3_modula3_overview"></a>29.1 Overview</H2>
|
<H2><a name="Modula3_modula3_overview">29.1 Overview</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -84,7 +85,7 @@ FFTW
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
<H3><a name="Modula3_motivation"></a>29.1.1 Motivation</H3>
|
<H3><a name="Modula3_motivation">29.1.1 Motivation</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -131,10 +132,10 @@ functions), but it doesn't allow you to easily integrate a Modula-3 module into
|
||||||
a C/C++ project.
|
a C/C++ project.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Modula3_conception"></a>29.2 Conception</H2>
|
<H2><a name="Modula3_conception">29.2 Conception</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Modula3_cinterface"></a>29.2.1 Interfaces to C libraries</H3>
|
<H3><a name="Modula3_cinterface">29.2.1 Interfaces to C libraries</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -283,7 +284,7 @@ and the principal type must be renamed (<tt>%typemap</tt>).
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Modula3_cppinterface"></a>29.2.2 Interfaces to C++ libraries</H3>
|
<H3><a name="Modula3_cppinterface">29.2.2 Interfaces to C++ libraries</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -384,10 +385,10 @@ There is no C++ library I wrote a SWIG interface for,
|
||||||
so I'm not sure if this is possible or sensible, yet.
|
so I'm not sure if this is possible or sensible, yet.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Modula3_preliminaries"></a>29.3 Preliminaries</H2>
|
<H2><a name="Modula3_preliminaries">29.3 Preliminaries</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Modula3_compilers"></a>29.3.1 Compilers</H3>
|
<H3><a name="Modula3_compilers">29.3.1 Compilers</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -400,7 +401,7 @@ For testing examples I use Critical Mass cm3.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Modula3_commandline"></a>29.3.2 Additional Commandline Options</H3>
|
<H3><a name="Modula3_commandline">29.3.2 Additional Commandline Options</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -477,10 +478,10 @@ Instead generate templates for some basic typemaps.
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<H2><a name="Modula3_typemaps"></a>29.4 Modula-3 typemaps</H2>
|
<H2><a name="Modula3_typemaps">29.4 Modula-3 typemaps</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Modula3_inoutparam"></a>29.4.1 Inputs and outputs</H3>
|
<H3><a name="Modula3_inoutparam">29.4.1 Inputs and outputs</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -694,7 +695,7 @@ consist of the following parts:
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Modula3_ordinals"></a>29.4.2 Subranges, Enumerations, Sets</H3>
|
<H3><a name="Modula3_ordinals">29.4.2 Subranges, Enumerations, Sets</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -746,7 +747,7 @@ that I'd like to automate.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Modula3_class"></a>29.4.3 Objects</H3>
|
<H3><a name="Modula3_class">29.4.3 Objects</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -759,7 +760,7 @@ is not really useful, yet.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Modula3_imports"></a>29.4.4 Imports</H3>
|
<H3><a name="Modula3_imports">29.4.4 Imports</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -792,7 +793,7 @@ IMPORT M3toC;
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Modula3_exceptions"></a>29.4.5 Exceptions</H3>
|
<H3><a name="Modula3_exceptions">29.4.5 Exceptions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -816,7 +817,7 @@ you should declare
|
||||||
<tt>%typemap("m3wrapinconv:throws") blah * %{OSError.E%}</tt>.
|
<tt>%typemap("m3wrapinconv:throws") blah * %{OSError.E%}</tt>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Modula3_typemap_example"></a>29.4.6 Example</H3>
|
<H3><a name="Modula3_typemap_example">29.4.6 Example</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -863,10 +864,10 @@ where almost everything is generated by a typemap:
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="Modula3_hints"></a>29.5 More hints to the generator</H2>
|
<H2><a name="Modula3_hints">29.5 More hints to the generator</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Modula3_features"></a>29.5.1 Features</H3>
|
<H3><a name="Modula3_features">29.5.1 Features</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<table border summary="Modula-3 features">
|
<table border summary="Modula-3 features">
|
||||||
|
|
@ -903,7 +904,7 @@ where almost everything is generated by a typemap:
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<H3><a name="Modula3_pragmas"></a>29.5.2 Pragmas</H3>
|
<H3><a name="Modula3_pragmas">29.5.2 Pragmas</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<table border summary="Modula-3 pragmas">
|
<table border summary="Modula-3 pragmas">
|
||||||
|
|
@ -926,7 +927,7 @@ where almost everything is generated by a typemap:
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<H2><a name="Modula3_remarks"></a>29.6 Remarks</H2>
|
<H2><a name="Modula3_remarks">29.6 Remarks</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Working with Modules</title>
|
<title>Working with Modules</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
<H1><a name="Modules"></a>16 Working with Modules</H1>
|
<H1><a name="Modules">16 Working with Modules</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -23,7 +24,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="Modules_introduction"></a>16.1 Modules Introduction</H2>
|
<H2><a name="Modules_introduction">16.1 Modules Introduction</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -77,7 +78,7 @@ where you want to create a collection of modules.
|
||||||
Each module in the collection is created via separate invocations of SWIG.
|
Each module in the collection is created via separate invocations of SWIG.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Modules_nn1"></a>16.2 Basics</H2>
|
<H2><a name="Modules_nn1">16.2 Basics</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -176,7 +177,7 @@ in parallel from multiple threads as SWIG provides no locking - for more on that
|
||||||
issue, read on.
|
issue, read on.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Modules_nn2"></a>16.3 The SWIG runtime code</H2>
|
<H2><a name="Modules_nn2">16.3 The SWIG runtime code</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -242,7 +243,7 @@ can peacefully coexist. So the type structures are separated by the
|
||||||
is empty. Only modules compiled with the same pair will share type information.
|
is empty. Only modules compiled with the same pair will share type information.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Modules_external_run_time"></a>16.4 External access to the runtime</H2>
|
<H2><a name="Modules_external_run_time">16.4 External access to the runtime</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>As described in <a href="Typemaps.html#Typemaps_runtime_type_checker">The run-time type checker</a>,
|
<p>As described in <a href="Typemaps.html#Typemaps_runtime_type_checker">The run-time type checker</a>,
|
||||||
|
|
@ -281,7 +282,7 @@ SWIG_TYPE_TABLE to be the same as the module whose types you are trying to
|
||||||
access.
|
access.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Modules_nn4"></a>16.5 A word of caution about static libraries</H2>
|
<H2><a name="Modules_nn4">16.5 A word of caution about static libraries</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -292,7 +293,7 @@ into it. This is very often <b>NOT</b> what you want and it can lead to unexpect
|
||||||
behavior. When working with dynamically loadable modules, you should try to work exclusively with shared libraries.
|
behavior. When working with dynamically loadable modules, you should try to work exclusively with shared libraries.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Modules_nn5"></a>16.6 References</H2>
|
<H2><a name="Modules_nn5">16.6 References</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -300,7 +301,7 @@ Due to the complexity of working with shared libraries and multiple modules, it
|
||||||
an outside reference. John Levine's "Linkers and Loaders" is highly recommended.
|
an outside reference. John Levine's "Linkers and Loaders" is highly recommended.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Modules_nn6"></a>16.7 Reducing the wrapper file size</H2>
|
<H2><a name="Modules_nn6">16.7 Reducing the wrapper file size</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<!-- Hand-written HTML -->
|
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>SWIG and MzScheme/Racket</title>
|
<title>SWIG and MzScheme/Racket</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
|
|
||||||
<H1><a name="Mzscheme"></a>30 SWIG and MzScheme/Racket</H1>
|
<H1><a name="Mzscheme">30 SWIG and MzScheme/Racket</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
<p>
|
<p>
|
||||||
This section contains information on SWIG's support of Racket, formally known as MzScheme.
|
This section contains information on SWIG's support of Racket, formally known as MzScheme.
|
||||||
|
|
||||||
<H2><a name="MzScheme_nn2"></a>30.1 Creating native structures</H2>
|
<H2><a name="MzScheme_nn2">30.1 Creating native structures</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -65,7 +65,7 @@ Then in scheme, you can use regular struct access procedures like
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H2><a name="MzScheme_simple"></a>30.2 Simple example</H2>
|
<H2><a name="MzScheme_simple">30.2 Simple example</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -166,7 +166,7 @@ Some points of interest:
|
||||||
<li> The above requests mzc to create an extension using the CGC garbage-collector. The alternative -- the 3m collector -- has generally better performance, but work is still required for SWIG to emit code which is compatible with it.
|
<li> The above requests mzc to create an extension using the CGC garbage-collector. The alternative -- the 3m collector -- has generally better performance, but work is still required for SWIG to emit code which is compatible with it.
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<H2><a name="MzScheme_external_docs"></a>30.3 External documentation</H2>
|
<H2><a name="MzScheme_external_docs">30.3 External documentation</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<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">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
<H1><a name="Ocaml"></a>31 SWIG and Ocaml</H1>
|
<H1><a name="Ocaml">31 SWIG and Ocaml</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -45,10 +46,10 @@
|
||||||
<li><a href="#Ocaml_nn24">Overriding Methods in Ocaml</a>
|
<li><a href="#Ocaml_nn24">Overriding Methods in Ocaml</a>
|
||||||
<li><a href="#Ocaml_nn25">Director Usage Example</a>
|
<li><a href="#Ocaml_nn25">Director Usage Example</a>
|
||||||
<li><a href="#Ocaml_nn26">Creating director objects</a>
|
<li><a href="#Ocaml_nn26">Creating director objects</a>
|
||||||
<li><a href="#Ocaml_nn27">Typemaps for directors, <tt>directorin, directorout, directorargout</tt></a>
|
<li><a href="#Ocaml_nn27">Typemaps for directors, directorin, directorout, directorargout</a>
|
||||||
<li><a href="#Ocaml_nn28"><tt>directorin</tt> typemap</a>
|
<li><a href="#Ocaml_nn28">typemap</a>
|
||||||
<li><a href="#Ocaml_nn29"><tt>directorout</tt> typemap</a>
|
<li><a href="#Ocaml_nn29">directorout typemap</a>
|
||||||
<li><a href="#Ocaml_nn30"><tt>directorargout</tt> typemap</a>
|
<li><a href="#Ocaml_nn30">directorargout typemap</a>
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="#Ocaml_nn31">Exceptions</a>
|
<li><a href="#Ocaml_nn31">Exceptions</a>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
@ -80,10 +81,10 @@ variants, functions, classes, etc.
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
If you're not familiar with the Objective Caml language, you can visit
|
If you're not familiar with the Objective Caml language, you can visit
|
||||||
<a href="http://www.ocaml.org/">The Ocaml Website</a>.
|
<a href="http://ocaml.org/">The Ocaml Website</a>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Ocaml_nn2"></a>31.1 Preliminaries</H2>
|
<H2><a name="Ocaml_nn2">31.1 Preliminaries</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -101,7 +102,7 @@ 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>
|
||||||
|
|
||||||
<H3><a name="Ocaml_nn3"></a>31.1.1 Running SWIG</H3>
|
<H3><a name="Ocaml_nn3">31.1.1 Running SWIG</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -124,7 +125,7 @@ you will compile the file <tt>example_wrap.c</tt> with <tt>ocamlc</tt> or
|
||||||
the resulting .ml and .mli files as well, and do the final link with -custom
|
the resulting .ml and .mli files as well, and do the final link with -custom
|
||||||
(not needed for native link).</p>
|
(not needed for native link).</p>
|
||||||
|
|
||||||
<H3><a name="Ocaml_nn4"></a>31.1.2 Compiling the code</H3>
|
<H3><a name="Ocaml_nn4">31.1.2 Compiling the code</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -161,7 +162,7 @@ in C++ mode, you must:</p>
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Ocaml_nn5"></a>31.1.3 The camlp4 module</H3>
|
<H3><a name="Ocaml_nn5">31.1.3 The camlp4 module</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -237,7 +238,7 @@ let b = C_string (getenv "PATH")
|
||||||
</td></tr>
|
</td></tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<H3><a name="Ocaml_nn6"></a>31.1.4 Using your module</H3>
|
<H3><a name="Ocaml_nn6">31.1.4 Using your module</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -251,7 +252,7 @@ option to build your functions into the primitive list. This
|
||||||
option is not needed when you build native code.
|
option is not needed when you build native code.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Ocaml_nn7"></a>31.1.5 Compilation problems and compiling with C++</H3>
|
<H3><a name="Ocaml_nn7">31.1.5 Compilation problems and compiling with C++</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -262,7 +263,7 @@ liberal with pointer types may not compile under the C++ compiler.
|
||||||
Most code meant to be compiled as C++ will not have problems.
|
Most code meant to be compiled as C++ will not have problems.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Ocaml_nn8"></a>31.2 The low-level Ocaml/C interface</H2>
|
<H2><a name="Ocaml_nn8">31.2 The low-level Ocaml/C interface</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -362,7 +363,7 @@ value items pass through directly, but you must make your own type
|
||||||
signature for a function that uses value in this way.
|
signature for a function that uses value in this way.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Ocaml_nn9"></a>31.2.1 The generated module</H3>
|
<H3><a name="Ocaml_nn9">31.2.1 The generated module</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -396,7 +397,7 @@ it describes the output SWIG will generate for class definitions.
|
||||||
</td></tr>
|
</td></tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<H3><a name="Ocaml_nn10"></a>31.2.2 Enums</H3>
|
<H3><a name="Ocaml_nn10">31.2.2 Enums</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -459,7 +460,7 @@ val x : Enum_test.c_obj = C_enum `a
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H4><a name="Ocaml_nn11"></a>31.2.2.1 Enum typing in Ocaml</H4>
|
<H4><a name="Ocaml_nn11">31.2.2.1 Enum typing in Ocaml</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -472,10 +473,10 @@ functions imported from different modules. You must convert values to master
|
||||||
values using the swig_val function before sharing them with another module.
|
values using the swig_val function before sharing them with another module.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Ocaml_nn12"></a>31.2.3 Arrays</H3>
|
<H3><a name="Ocaml_nn12">31.2.3 Arrays</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<H4><a name="Ocaml_nn13"></a>31.2.3.1 Simple types of bounded arrays</H4>
|
<H4><a name="Ocaml_nn13">31.2.3.1 Simple types of bounded arrays</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -496,7 +497,7 @@ arrays of simple types with known bounds in your code, but this only works
|
||||||
for arrays whose bounds are completely specified.
|
for arrays whose bounds are completely specified.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H4><a name="Ocaml_nn14"></a>31.2.3.2 Complex and unbounded arrays</H4>
|
<H4><a name="Ocaml_nn14">31.2.3.2 Complex and unbounded arrays</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -509,7 +510,7 @@ SWIG can't predict which of these methods will be used in the array,
|
||||||
so you have to specify it for yourself in the form of a typemap.
|
so you have to specify it for yourself in the form of a typemap.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H4><a name="Ocaml_nn15"></a>31.2.3.3 Using an object</H4>
|
<H4><a name="Ocaml_nn15">31.2.3.3 Using an object</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -523,7 +524,7 @@ Consider writing an object when the ending condition of your array is complex,
|
||||||
such as using a required sentinel, etc.
|
such as using a required sentinel, etc.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H4><a name="Ocaml_nn16"></a>31.2.3.4 Example typemap for a function taking float * and int</H4>
|
<H4><a name="Ocaml_nn16">31.2.3.4 Example typemap for a function taking float * and int</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -574,7 +575,7 @@ void printfloats( float *tab, int len );
|
||||||
</pre></td></tr></table>
|
</pre></td></tr></table>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Ocaml_nn17"></a>31.2.4 C++ Classes</H3>
|
<H3><a name="Ocaml_nn17">31.2.4 C++ Classes</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -617,7 +618,7 @@ the underlying pointer, so using create_[x]_from_ptr alters the
|
||||||
returned value for the same object.
|
returned value for the same object.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H4><a name="Ocaml_nn18"></a>31.2.4.1 STL vector and string Example</H4>
|
<H4><a name="Ocaml_nn18">31.2.4.1 STL vector and string Example</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -697,7 +698,7 @@ baz
|
||||||
#
|
#
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H4><a name="Ocaml_nn19"></a>31.2.4.2 C++ Class Example</H4>
|
<H4><a name="Ocaml_nn19">31.2.4.2 C++ Class Example</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -727,7 +728,7 @@ public:
|
||||||
};
|
};
|
||||||
</pre></td></tr></table>
|
</pre></td></tr></table>
|
||||||
|
|
||||||
<H4><a name="Ocaml_nn20"></a>31.2.4.3 Compiling the example</H4>
|
<H4><a name="Ocaml_nn20">31.2.4.3 Compiling the example</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<div class="code"><pre>
|
<div class="code"><pre>
|
||||||
|
|
@ -745,7 +746,7 @@ bash-2.05a$ ocamlmktop -custom swig.cmo -I `camlp4 -where` \
|
||||||
-L$QTPATH/lib -cclib -lqt
|
-L$QTPATH/lib -cclib -lqt
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H4><a name="Ocaml_nn21"></a>31.2.4.4 Sample Session</H4>
|
<H4><a name="Ocaml_nn21">31.2.4.4 Sample Session</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<div class="code"><pre>
|
<div class="code"><pre>
|
||||||
|
|
@ -772,10 +773,10 @@ Assuming you have a working installation of QT, you will see a window
|
||||||
containing the string "hi" in a button.
|
containing the string "hi" in a button.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Ocaml_nn22"></a>31.2.5 Director Classes</H3>
|
<H3><a name="Ocaml_nn22">31.2.5 Director Classes</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<H4><a name="Ocaml_nn23"></a>31.2.5.1 Director Introduction</H4>
|
<H4><a name="Ocaml_nn23">31.2.5.1 Director Introduction</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -802,7 +803,7 @@ class foo {
|
||||||
};
|
};
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H4><a name="Ocaml_nn24"></a>31.2.5.2 Overriding Methods in Ocaml</H4>
|
<H4><a name="Ocaml_nn24">31.2.5.2 Overriding Methods in Ocaml</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -830,7 +831,7 @@ In this example, I'll examine the objective caml code involved in providing
|
||||||
an overloaded class. This example is contained in Examples/ocaml/shapes.
|
an overloaded class. This example is contained in Examples/ocaml/shapes.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H4><a name="Ocaml_nn25"></a>31.2.5.3 Director Usage Example</H4>
|
<H4><a name="Ocaml_nn25">31.2.5.3 Director Usage Example</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<table border="1" bgcolor="#dddddd" summary="Director usage example">
|
<table border="1" bgcolor="#dddddd" summary="Director usage example">
|
||||||
|
|
@ -889,7 +890,7 @@ in a more effortless style in ocaml, while leaving the "engine" part of the
|
||||||
program in C++.
|
program in C++.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H4><a name="Ocaml_nn26"></a>31.2.5.4 Creating director objects</H4>
|
<H4><a name="Ocaml_nn26">31.2.5.4 Creating director objects</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -930,7 +931,7 @@ object from causing a core dump, as long as the object is destroyed
|
||||||
properly.
|
properly.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H4><a name="Ocaml_nn27"></a>31.2.5.5 Typemaps for directors, <tt>directorin, directorout, directorargout</tt></H4>
|
<H4><a name="Ocaml_nn27">31.2.5.5 Typemaps for directors, directorin, directorout, directorargout</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -941,7 +942,7 @@ well as a function return value in the same way you provide function arguments,
|
||||||
and to receive arguments the same way you normally receive function returns.
|
and to receive arguments the same way you normally receive function returns.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H4><a name="Ocaml_nn28"></a>31.2.5.6 <tt>directorin</tt> typemap</H4>
|
<H4><a name="Ocaml_nn28">31.2.5.6 typemap</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -952,7 +953,7 @@ code receives when you are called. In general, a simple <tt>directorin</tt> typ
|
||||||
can use the same body as a simple <tt>out</tt> typemap.
|
can use the same body as a simple <tt>out</tt> typemap.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H4><a name="Ocaml_nn29"></a>31.2.5.7 <tt>directorout</tt> typemap</H4>
|
<H4><a name="Ocaml_nn29">31.2.5.7 directorout typemap</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -963,7 +964,7 @@ for the same type, except when there are special requirements for object
|
||||||
ownership, etc.
|
ownership, etc.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H4><a name="Ocaml_nn30"></a>31.2.5.8 <tt>directorargout</tt> typemap</H4>
|
<H4><a name="Ocaml_nn30">31.2.5.8 directorargout typemap</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -980,7 +981,7 @@ In the event that you don't specify all of the necessary values, integral
|
||||||
values will read zero, and struct or object returns have undefined results.
|
values will read zero, and struct or object returns have undefined results.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Ocaml_nn31"></a>31.2.6 Exceptions</H3>
|
<H3><a name="Ocaml_nn31">31.2.6 Exceptions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,15 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>SWIG and Octave</title>
|
<title>SWIG and Octave</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
|
|
||||||
<H1><a name="Octave"></a>32 SWIG and Octave</H1>
|
<H1><a name="Octave">32 SWIG and Octave</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -33,6 +34,10 @@
|
||||||
<li><a href="#Octave_nn19">Class extension with %extend</a>
|
<li><a href="#Octave_nn19">Class extension with %extend</a>
|
||||||
<li><a href="#Octave_nn20">C++ templates</a>
|
<li><a href="#Octave_nn20">C++ templates</a>
|
||||||
<li><a href="#Octave_nn21">C++ Smart Pointers</a>
|
<li><a href="#Octave_nn21">C++ Smart Pointers</a>
|
||||||
|
<ul>
|
||||||
|
<li><a href="#Octave_smart_pointers_shared_ptr">The shared_ptr Smart Pointer</a>
|
||||||
|
<li><a href="#Octave_smart_pointers_generic">Generic Smart Pointers</a>
|
||||||
|
</ul>
|
||||||
<li><a href="#Octave_nn22">Directors (calling Octave from C++ code)</a>
|
<li><a href="#Octave_nn22">Directors (calling Octave from C++ code)</a>
|
||||||
<li><a href="#Octave_nn23">Threads</a>
|
<li><a href="#Octave_nn23">Threads</a>
|
||||||
<li><a href="#Octave_nn24">Memory management</a>
|
<li><a href="#Octave_nn24">Memory management</a>
|
||||||
|
|
@ -55,15 +60,16 @@ More information can be found at <a href="http://www.gnu.org/software/octave/">O
|
||||||
Also, there are a dozen or so examples in the Examples/octave directory, and hundreds in the test suite (Examples/test-suite and Examples/test-suite/octave).
|
Also, there are a dozen or so examples in the Examples/octave directory, and hundreds in the test suite (Examples/test-suite and Examples/test-suite/octave).
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Octave_nn2"></a>32.1 Preliminaries</H2>
|
<H2><a name="Octave_nn2">32.1 Preliminaries</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
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.
|
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.
|
||||||
|
The SWIG runtime exports the function <tt>swig_octave_prereq()</tt> for checking the version of Octave.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Octave_nn3"></a>32.2 Running SWIG</H2>
|
<H2><a name="Octave_nn3">32.2 Running SWIG</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -95,7 +101,7 @@ The <tt>-c++</tt> option is also required when wrapping C++ code:
|
||||||
This creates a C++ source file "example_wrap.cpp". A C++ file is generated even when wrapping C code as Octave is itself written in C++ and requires wrapper code to be in the same language. The generated C++ source file contains the low-level wrappers that need to be compiled and linked with the rest of your C/C++ application (in this case, the gcd implementation) to create an extension module.
|
This creates a C++ source file "example_wrap.cpp". A C++ file is generated even when wrapping C code as Octave is itself written in C++ and requires wrapper code to be in the same language. The generated C++ source file contains the low-level wrappers that need to be compiled and linked with the rest of your C/C++ application (in this case, the gcd implementation) to create an extension module.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Octave_nn4"></a>32.2.1 Command-line options</H3>
|
<H3><a name="Octave_nn4">32.2.1 Command-line options</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -118,7 +124,7 @@ The special name "." loads C global variables into the module namespace, i.e. al
|
||||||
The <em>-opprefix</em> options sets the prefix of the names of global/friend <a href="#Octave_nn18">operator</a> functions.
|
The <em>-opprefix</em> options sets the prefix of the names of global/friend <a href="#Octave_nn18">operator</a> functions.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Octave_nn5"></a>32.2.2 Compiling a dynamic module</H3>
|
<H3><a name="Octave_nn5">32.2.2 Compiling a dynamic module</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -145,7 +151,7 @@ $ mkoctfile example_wrap.cpp example.c
|
||||||
|
|
||||||
<div class="targetlang"><pre>octave:1> swigexample</pre></div>
|
<div class="targetlang"><pre>octave:1> swigexample</pre></div>
|
||||||
|
|
||||||
<H3><a name="Octave_nn6"></a>32.2.3 Using your module</H3>
|
<H3><a name="Octave_nn6">32.2.3 Using your module</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -163,10 +169,10 @@ octave:4> swigexample.cvar.Foo=4;
|
||||||
octave:5> swigexample.cvar.Foo
|
octave:5> swigexample.cvar.Foo
|
||||||
ans = 4 </pre></div>
|
ans = 4 </pre></div>
|
||||||
|
|
||||||
<H2><a name="Octave_nn7"></a>32.3 A tour of basic C/C++ wrapping</H2>
|
<H2><a name="Octave_nn7">32.3 A tour of basic C/C++ wrapping</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Octave_nn8"></a>32.3.1 Modules</H3>
|
<H3><a name="Octave_nn8">32.3.1 Modules</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -211,7 +217,7 @@ octave:4> swigexample.gcd(4,6)
|
||||||
ans = 2
|
ans = 2
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Octave_nn9"></a>32.3.2 Functions</H3>
|
<H3><a name="Octave_nn9">32.3.2 Functions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -228,7 +234,7 @@ int fact(int n); </pre></div>
|
||||||
<div class="targetlang"><pre>octave:1> swigexample.fact(4)
|
<div class="targetlang"><pre>octave:1> swigexample.fact(4)
|
||||||
24 </pre></div>
|
24 </pre></div>
|
||||||
|
|
||||||
<H3><a name="Octave_nn10"></a>32.3.3 Global variables</H3>
|
<H3><a name="Octave_nn10">32.3.3 Global variables</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -281,7 +287,7 @@ octave:2> swigexample.PI=3.142;
|
||||||
octave:3> swigexample.PI
|
octave:3> swigexample.PI
|
||||||
ans = 3.1420 </pre></div>
|
ans = 3.1420 </pre></div>
|
||||||
|
|
||||||
<H3><a name="Octave_nn11"></a>32.3.4 Constants and enums</H3>
|
<H3><a name="Octave_nn11">32.3.4 Constants and enums</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -303,7 +309,7 @@ swigexample.SCONST="Hello World"
|
||||||
swigexample.SUNDAY=0
|
swigexample.SUNDAY=0
|
||||||
.... </pre></div>
|
.... </pre></div>
|
||||||
|
|
||||||
<H3><a name="Octave_nn12"></a>32.3.5 Pointers</H3>
|
<H3><a name="Octave_nn12">32.3.5 Pointers</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -350,7 +356,7 @@ octave:2> f=swigexample.fopen("not there","r");
|
||||||
error: value on right hand side of assignment is undefined
|
error: value on right hand side of assignment is undefined
|
||||||
error: evaluating assignment expression near line 2, column 2 </pre></div>
|
error: evaluating assignment expression near line 2, column 2 </pre></div>
|
||||||
|
|
||||||
<H3><a name="Octave_nn13"></a>32.3.6 Structures and C++ classes</H3>
|
<H3><a name="Octave_nn13">32.3.6 Structures and C++ classes</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -485,7 +491,7 @@ ans = 1
|
||||||
Depending on the ownership setting of a <tt>swig_ref</tt>, it may call C++ destructors when its reference count goes to zero. See the section on memory management below for details.
|
Depending on the ownership setting of a <tt>swig_ref</tt>, it may call C++ destructors when its reference count goes to zero. See the section on memory management below for details.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Octave_nn15"></a>32.3.7 C++ inheritance</H3>
|
<H3><a name="Octave_nn15">32.3.7 C++ inheritance</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -494,7 +500,7 @@ This information contains the full class hierarchy. When an indexing operation (
|
||||||
the tree is walked to find a match in the current class as well as any of its bases. The lookup is then cached in the <tt>swig_ref</tt>.
|
the tree is walked to find a match in the current class as well as any of its bases. The lookup is then cached in the <tt>swig_ref</tt>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Octave_nn17"></a>32.3.8 C++ overloaded functions</H3>
|
<H3><a name="Octave_nn17">32.3.8 C++ overloaded functions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -504,7 +510,7 @@ The dispatch function selects which overload to call (if any) based on the passe
|
||||||
<tt>typecheck</tt> typemaps are used to analyze each argument, as well as assign precedence. See the chapter on typemaps for details.
|
<tt>typecheck</tt> typemaps are used to analyze each argument, as well as assign precedence. See the chapter on typemaps for details.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Octave_nn18"></a>32.3.9 C++ operators</H3>
|
<H3><a name="Octave_nn18">32.3.9 C++ operators</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -512,7 +518,7 @@ C++ operator overloading is supported, in a way similar to other modules.
|
||||||
The <tt>swig_ref</tt> type supports all unary and binary operators between itself and all other types that exist in the system at module load time. When an operator is used (where one of the operands is a <tt>swig_ref</tt>), the runtime routes the call to either a member function of the given object, or to a global function whose named is derived from the types of the operands (either both or just the lhs or rhs).
|
The <tt>swig_ref</tt> type supports all unary and binary operators between itself and all other types that exist in the system at module load time. When an operator is used (where one of the operands is a <tt>swig_ref</tt>), the runtime routes the call to either a member function of the given object, or to a global function whose named is derived from the types of the operands (either both or just the lhs or rhs).
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
For example, if <tt>a</tt> and <tt>b</tt> are SWIG variables in Octave, <tt>a+b</tt> becomes <tt>a.__add(b)</tt>. The wrapper is then free to implement __add to do whatever it wants. A wrapper may define the <tt>__add</tt> function manually, %rename some other function to it, or %rename a C++ operator to it.
|
For example, if <tt>a</tt> and <tt>b</tt> are SWIG variables in Octave, <tt>a+b</tt> becomes <tt>a.__add__(b)</tt>. The wrapper is then free to implement __add__ to do whatever it wants. A wrapper may define the <tt>__add__</tt> function manually, %rename some other function to it, or %rename a C++ operator to it.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
By default the C++ operators are renamed to their corresponding Octave operators. So without doing any work, the following interface
|
By default the C++ operators are renamed to their corresponding Octave operators. So without doing any work, the following interface
|
||||||
|
|
@ -539,87 +545,87 @@ assert(c.value==5);
|
||||||
Octave operators are mapped in the following way:
|
Octave operators are mapped in the following way:
|
||||||
</p>
|
</p>
|
||||||
<div class="code"><pre>
|
<div class="code"><pre>
|
||||||
__brace a{args}
|
__brace__ a{args}
|
||||||
__brace_asgn a{args} = rhs
|
__brace_asgn__ a{args} = rhs
|
||||||
__paren a(args)
|
__paren__ a(args)
|
||||||
__paren_asgn a(args) = rhs
|
__paren_asgn__ a(args) = rhs
|
||||||
__str generates string rep
|
__str__ generates string rep
|
||||||
__not !a
|
__not__ !a
|
||||||
__uplus +a
|
__uplus__ +a
|
||||||
__uminus -a
|
__uminus__ -a
|
||||||
__transpose a.'
|
__transpose__ a.'
|
||||||
__hermitian a'
|
__hermitian__ a'
|
||||||
__incr a++
|
__incr__ a++
|
||||||
__decr a--
|
__decr__ a--
|
||||||
__add a + b
|
__add__ a + b
|
||||||
__sub a - b
|
__sub__ a - b
|
||||||
__mul a * b
|
__mul__ a * b
|
||||||
__div a / b
|
__div__ a / b
|
||||||
__pow a ^ b
|
__pow__ a ^ b
|
||||||
__ldiv a \ b
|
__ldiv__ a \ b
|
||||||
__lshift a << b
|
__lshift__ a << b
|
||||||
__rshift a >> b
|
__rshift__ a >> b
|
||||||
__lt a < b
|
__lt__ a < b
|
||||||
__le a <= b
|
__le__ a <= b
|
||||||
__eq a == b
|
__eq__ a == b
|
||||||
__ge a >= b
|
__ge__ a >= b
|
||||||
__gt a > b
|
__gt__ a > b
|
||||||
__ne a != b
|
__ne__ a != b
|
||||||
__el_mul a .* b
|
__el_mul__ a .* b
|
||||||
__el_div a ./ b
|
__el_div__ a ./ b
|
||||||
__el_pow a .^ b
|
__el_pow__ a .^ b
|
||||||
__el_ldiv a .\ b
|
__el_ldiv__ a .\ b
|
||||||
__el_and a & b
|
__el_and__ a & b
|
||||||
__el_or a | b
|
__el_or__ a | b
|
||||||
</pre></div>
|
</pre></div>
|
||||||
<p>
|
<p>
|
||||||
On the C++ side, the default mappings are as follows:
|
On the C++ side, the default mappings are as follows:
|
||||||
</p>
|
</p>
|
||||||
<div class="code"><pre>
|
<div class="code"><pre>
|
||||||
%rename(__add) *::operator+;
|
%rename(__add__) *::operator+;
|
||||||
%rename(__add) *::operator+();
|
%rename(__add__) *::operator+();
|
||||||
%rename(__add) *::operator+() const;
|
%rename(__add__) *::operator+() const;
|
||||||
%rename(__sub) *::operator-;
|
%rename(__sub__) *::operator-;
|
||||||
%rename(__uminus) *::operator-();
|
%rename(__uminus__) *::operator-();
|
||||||
%rename(__uminus) *::operator-() const;
|
%rename(__uminus__) *::operator-() const;
|
||||||
%rename(__mul) *::operator*;
|
%rename(__mul__) *::operator*;
|
||||||
%rename(__div) *::operator/;
|
%rename(__div__) *::operator/;
|
||||||
%rename(__mod) *::operator%;
|
%rename(__mod__) *::operator%;
|
||||||
%rename(__lshift) *::operator<<;
|
%rename(__lshift__) *::operator<<;
|
||||||
%rename(__rshift) *::operator>>;
|
%rename(__rshift__) *::operator>>;
|
||||||
%rename(__el_and) *::operator&&;
|
%rename(__el_and__) *::operator&&;
|
||||||
%rename(__el_or) *::operator||;
|
%rename(__el_or__) *::operator||;
|
||||||
%rename(__xor) *::operator^;
|
%rename(__xor__) *::operator^;
|
||||||
%rename(__invert) *::operator~;
|
%rename(__invert__) *::operator~;
|
||||||
%rename(__lt) *::operator<;
|
%rename(__lt__) *::operator<;
|
||||||
%rename(__le) *::operator<=;
|
%rename(__le__) *::operator<=;
|
||||||
%rename(__gt) *::operator>;
|
%rename(__gt__) *::operator>;
|
||||||
%rename(__ge) *::operator>=;
|
%rename(__ge__) *::operator>=;
|
||||||
%rename(__eq) *::operator==;
|
%rename(__eq__) *::operator==;
|
||||||
%rename(__ne) *::operator!=;
|
%rename(__ne__) *::operator!=;
|
||||||
%rename(__not) *::operator!;
|
%rename(__not__) *::operator!;
|
||||||
%rename(__incr) *::operator++;
|
%rename(__incr__) *::operator++;
|
||||||
%rename(__decr) *::operator--;
|
%rename(__decr__) *::operator--;
|
||||||
%rename(__paren) *::operator();
|
%rename(__paren__) *::operator();
|
||||||
%rename(__brace) *::operator[];
|
%rename(__brace__) *::operator[];
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Octave can also utilise friend (i.e. non-member) operators with a simple %rename: see the example in the Examples/octave/operator directory.
|
Octave can also utilise friend (i.e. non-member) operators with a simple %rename: see the example in the Examples/octave/operator directory.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Octave_nn19"></a>32.3.10 Class extension with %extend</H3>
|
<H3><a name="Octave_nn19">32.3.10 Class extension with %extend</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
The %extend directive works the same as in other modules.
|
The %extend directive works the same as in other modules.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
You can use it to define special behavior, like for example defining Octave operators not mapped to C++ operators, or defining certain Octave mechanisms such as how an object prints. For example, the <tt>octave_value::{is_string,string_value,print}</tt> functions are routed to a special method <tt>__str</tt> that can be defined inside an %extend.
|
You can use it to define special behavior, like for example defining Octave operators not mapped to C++ operators, or defining certain Octave mechanisms such as how an object prints. For example, the <tt>octave_value::{is_string,string_value,print}</tt> functions are routed to a special method <tt>__str__</tt> that can be defined inside an %extend.
|
||||||
</p>
|
</p>
|
||||||
<div class="code"><pre>
|
<div class="code"><pre>
|
||||||
%extend A {
|
%extend A {
|
||||||
string __str() {
|
string __str__() {
|
||||||
stringstream sout;
|
stringstream sout;
|
||||||
sout<<$self->value;
|
sout<<$self->value;
|
||||||
return sout.str();
|
return sout.str();
|
||||||
|
|
@ -635,10 +641,19 @@ octave:2> a
|
||||||
a = 4
|
a = 4
|
||||||
octave:3> printf("%s\n",a);
|
octave:3> printf("%s\n",a);
|
||||||
4
|
4
|
||||||
octave:4> a.__str()
|
octave:4> a.__str__()
|
||||||
4
|
4
|
||||||
</pre></div>
|
</pre></div>
|
||||||
<H3><a name="Octave_nn20"></a>32.3.11 C++ templates</H3>
|
|
||||||
|
<p>
|
||||||
|
Similarly, Octave can use the <tt>__float__</tt> method to convert an object to a numeric value.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Octave 3.8.0 and later versions will also map unary functions X() to the corresponding <tt>__X__</tt> method, where X includes: abs(), acos(), acosh(), angle(), arg(), asin(), asinh(), atan(), atanh(), cbrt(), ceil(), conj(), cos(), cosh(), dawson(), erf(), erfc(), erfcinv(), erfcx(), erfi(), erfinv(), exp(), expm1(), finite(), fix(), floor(), gamma(), imag(), isalnum(), isalpha(), isascii(), iscntrl(), isdigit(), isgraph(), isinf(), islower(), isna(), isnan(), isprint(), ispunct(), isspace(), isupper(), isxdigit(), lgamma(), log(), log10(), log1p(), log2(), real(), round(), roundb(), signbit(), signum(), sin(), sinh(), sqrt(), tan(), tanh(), toascii(), tolower(), toupper()
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<H3><a name="Octave_nn20">32.3.11 C++ templates</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -687,7 +702,7 @@ Similarly, class templates can be instantiated as in the following example,
|
||||||
s+=_s;
|
s+=_s;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
std::string __str() const {
|
std::string __str__() const {
|
||||||
std::stringstream sout;
|
std::stringstream sout;
|
||||||
sout<<s;
|
sout<<s;
|
||||||
return sout.str();
|
return sout.str();
|
||||||
|
|
@ -715,14 +730,28 @@ ans =
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Octave_nn21"></a>32.3.12 C++ Smart Pointers</H3>
|
<H3><a name="Octave_nn21">32.3.12 C++ Smart Pointers</a></H3>
|
||||||
|
|
||||||
|
|
||||||
|
<H4><a name="Octave_smart_pointers_shared_ptr">32.3.12.1 The shared_ptr Smart Pointer</a></H4>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The C++11 standard provides <tt>std::shared_ptr</tt> which was derived from the Boost
|
||||||
|
implementation, <tt>boost::shared_ptr</tt>.
|
||||||
|
Both of these are available for Octave in the SWIG library and usage is outlined
|
||||||
|
in the <a href="Library.html#Library_std_shared_ptr">shared_ptr smart pointer</a> library section.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<H4><a name="Octave_smart_pointers_generic">32.3.12.2 Generic Smart Pointers</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
C++ smart pointers are fully supported as in other modules.
|
C++ smart pointers are fully supported as in other modules.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Octave_nn22"></a>32.3.13 Directors (calling Octave from C++ code)</H3>
|
<H3><a name="Octave_nn22">32.3.13 Directors (calling Octave from C++ code)</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -803,14 +832,14 @@ c-side routine called
|
||||||
octave-side routine called
|
octave-side routine called
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Octave_nn23"></a>32.3.14 Threads</H3>
|
<H3><a name="Octave_nn23">32.3.14 Threads</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
The use of threads in wrapped Director code is not supported; i.e., an Octave-side implementation of a C++ class must be called from the Octave interpreter's thread. Anything fancier (apartment/queue model, whatever) is left to the user. Without anything fancier, this amounts to the limitation that Octave must drive the module... like, for example, an optimization package that calls Octave to evaluate an objective function.
|
The use of threads in wrapped Director code is not supported; i.e., an Octave-side implementation of a C++ class must be called from the Octave interpreter's thread. Anything fancier (apartment/queue model, whatever) is left to the user. Without anything fancier, this amounts to the limitation that Octave must drive the module... like, for example, an optimization package that calls Octave to evaluate an objective function.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Octave_nn24"></a>32.3.15 Memory management</H3>
|
<H3><a name="Octave_nn24">32.3.15 Memory management</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -844,14 +873,14 @@ The %newobject directive may be used to control this behavior for pointers retur
|
||||||
In the case where one wishes for the C++ side to own an object that was created in Octave (especially a Director object), one can use the __disown() method to invert this logic. Then letting the Octave reference count go to zero will not destroy the object, but destroying the object will invalidate the Octave-side object if it still exists (and call destructors of other C++ bases in the case of multiple inheritance/<tt>subclass()</tt>'ing).
|
In the case where one wishes for the C++ side to own an object that was created in Octave (especially a Director object), one can use the __disown() method to invert this logic. Then letting the Octave reference count go to zero will not destroy the object, but destroying the object will invalidate the Octave-side object if it still exists (and call destructors of other C++ bases in the case of multiple inheritance/<tt>subclass()</tt>'ing).
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Octave_nn25"></a>32.3.16 STL support</H3>
|
<H3><a name="Octave_nn25">32.3.16 STL support</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Various STL library files are provided for wrapping STL containers.
|
Various STL library files are provided for wrapping STL containers.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Octave_nn26"></a>32.3.17 Matrix typemaps</H3>
|
<H3><a name="Octave_nn26">32.3.17 Matrix typemaps</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>SWIG and Perl5</title>
|
<title>SWIG and Perl5</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
<H1><a name="Perl5"></a>33 SWIG and Perl5</H1>
|
<H1><a name="Perl5">33 SWIG and Perl5</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -96,7 +97,7 @@ later. We're no longer testing regularly with older versions, but
|
||||||
Perl 5.6 seems to mostly work, while older versions don't.
|
Perl 5.6 seems to mostly work, while older versions don't.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Perl5_nn2"></a>33.1 Overview</H2>
|
<H2><a name="Perl5_nn2">33.1 Overview</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -117,7 +118,7 @@ described. Advanced customization features, typemaps, and other
|
||||||
options are found near the end of the chapter.
|
options are found near the end of the chapter.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Perl5_nn3"></a>33.2 Preliminaries</H2>
|
<H2><a name="Perl5_nn3">33.2 Preliminaries</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -142,7 +143,7 @@ To build the module, you will need to compile the file
|
||||||
<tt>example_wrap.c</tt> and link it with the rest of your program.
|
<tt>example_wrap.c</tt> and link it with the rest of your program.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn4"></a>33.2.1 Getting the right header files</H3>
|
<H3><a name="Perl5_nn4">33.2.1 Getting the right header files</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -174,7 +175,7 @@ $ perl -e 'use Config; print "$Config{archlib}\n";'
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn5"></a>33.2.2 Compiling a dynamic module</H3>
|
<H3><a name="Perl5_nn5">33.2.2 Compiling a dynamic module</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -207,7 +208,7 @@ the target should be named `<tt>example.so</tt>',
|
||||||
`<tt>example.sl</tt>', or the appropriate dynamic module name on your system.
|
`<tt>example.sl</tt>', or the appropriate dynamic module name on your system.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn6"></a>33.2.3 Building a dynamic module with MakeMaker</H3>
|
<H3><a name="Perl5_nn6">33.2.3 Building a dynamic module with MakeMaker</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -241,7 +242,7 @@ the preferred approach to compilation. More information about MakeMaker can be
|
||||||
found in "Programming Perl, 2nd ed." by Larry Wall, Tom Christiansen,
|
found in "Programming Perl, 2nd ed." by Larry Wall, Tom Christiansen,
|
||||||
and Randal Schwartz.</p>
|
and Randal Schwartz.</p>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn7"></a>33.2.4 Building a static version of Perl</H3>
|
<H3><a name="Perl5_nn7">33.2.4 Building a static version of Perl</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -310,7 +311,7 @@ added to it. Depending on your machine, you may need to link with
|
||||||
additional libraries such as <tt>-lsocket, -lnsl, -ldl</tt>, etc.
|
additional libraries such as <tt>-lsocket, -lnsl, -ldl</tt>, etc.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn8"></a>33.2.5 Using the module</H3>
|
<H3><a name="Perl5_nn8">33.2.5 Using the module</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -463,7 +464,7 @@ system configuration (this requires root access and you will need to
|
||||||
read the man pages).
|
read the man pages).
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn9"></a>33.2.6 Compilation problems and compiling with C++</H3>
|
<H3><a name="Perl5_nn9">33.2.6 Compilation problems and compiling with C++</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -606,7 +607,7 @@ have to find the macro that conflicts and add an #undef into the .i file. Pleas
|
||||||
any conflicting macros you find to <a href="http://www.swig.org/mail.html">swig-user mailing list</a>.
|
any conflicting macros you find to <a href="http://www.swig.org/mail.html">swig-user mailing list</a>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn10"></a>33.2.7 Compiling for 64-bit platforms</H3>
|
<H3><a name="Perl5_nn10">33.2.7 Compiling for 64-bit platforms</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -633,7 +634,7 @@ also introduce problems on platforms that support more than one
|
||||||
linking standard (e.g., -o32 and -n32 on Irix).
|
linking standard (e.g., -o32 and -n32 on Irix).
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Perl5_nn11"></a>33.3 Building Perl Extensions under Windows</H2>
|
<H2><a name="Perl5_nn11">33.3 Building Perl Extensions under Windows</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -644,7 +645,7 @@ section assumes you are using SWIG with Microsoft Visual C++
|
||||||
although the procedure may be similar with other compilers.
|
although the procedure may be similar with other compilers.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn12"></a>33.3.1 Running SWIG from Developer Studio</H3>
|
<H3><a name="Perl5_nn12">33.3.1 Running SWIG from Developer Studio</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -707,7 +708,7 @@ print "$a\n";
|
||||||
|
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn13"></a>33.3.2 Using other compilers</H3>
|
<H3><a name="Perl5_nn13">33.3.2 Using other compilers</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -715,7 +716,7 @@ SWIG is known to work with Cygwin and may work with other compilers on Windows.
|
||||||
For general hints and suggestions refer to the <a href="Windows.html#Windows">Windows</a> chapter.
|
For general hints and suggestions refer to the <a href="Windows.html#Windows">Windows</a> chapter.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Perl5_nn14"></a>33.4 The low-level interface</H2>
|
<H2><a name="Perl5_nn14">33.4 The low-level interface</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -725,7 +726,7 @@ can be used to control your application. However, it is also used to
|
||||||
construct more user-friendly proxy classes as described in the next section.
|
construct more user-friendly proxy classes as described in the next section.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn15"></a>33.4.1 Functions</H3>
|
<H3><a name="Perl5_nn15">33.4.1 Functions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -748,7 +749,7 @@ use example;
|
||||||
$a = &example::fact(2);
|
$a = &example::fact(2);
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn16"></a>33.4.2 Global variables</H3>
|
<H3><a name="Perl5_nn16">33.4.2 Global variables</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -818,7 +819,7 @@ extern char *path; // Declared later in the input
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn17"></a>33.4.3 Constants</H3>
|
<H3><a name="Perl5_nn17">33.4.3 Constants</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -858,7 +859,7 @@ print example::FOO,"\n";
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn18"></a>33.4.4 Pointers</H3>
|
<H3><a name="Perl5_nn18">33.4.4 Pointers</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -967,7 +968,7 @@ as XS and <tt>xsubpp</tt>. Given the advancement of the SWIG typesystem and the
|
||||||
SWIG and XS, this is no longer supported.
|
SWIG and XS, this is no longer supported.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn19"></a>33.4.5 Structures</H3>
|
<H3><a name="Perl5_nn19">33.4.5 Structures</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1101,7 +1102,7 @@ void Bar_f_set(Bar *b, Foo *val) {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Perl5_nn20"></a>33.4.6 C++ classes</H3>
|
<H3><a name="Perl5_nn20">33.4.6 C++ classes</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1166,7 +1167,7 @@ provides direct access to C++ objects. A higher level interface using Perl prox
|
||||||
can be built using these low-level accessors. This is described shortly.
|
can be built using these low-level accessors. This is described shortly.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn21"></a>33.4.7 C++ classes and type-checking</H3>
|
<H3><a name="Perl5_nn21">33.4.7 C++ classes and type-checking</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1202,7 +1203,7 @@ If necessary, the type-checker also adjusts the value of the pointer (as is nece
|
||||||
multiple inheritance is used).
|
multiple inheritance is used).
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn22"></a>33.4.8 C++ overloaded functions</H3>
|
<H3><a name="Perl5_nn22">33.4.8 C++ overloaded functions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1246,7 +1247,7 @@ example::Spam_foo_d($s,3.14);
|
||||||
Please refer to the "SWIG Basics" chapter for more information.
|
Please refer to the "SWIG Basics" chapter for more information.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn23"></a>33.4.9 Operators</H3>
|
<H3><a name="Perl5_nn23">33.4.9 Operators</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1273,7 +1274,7 @@ The following C++ operators are currently supported by the Perl module:
|
||||||
<li>operator or </li>
|
<li>operator or </li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn24"></a>33.4.10 Modules and packages</H3>
|
<H3><a name="Perl5_nn24">33.4.10 Modules and packages</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1368,7 +1369,7 @@ print Foo::fact(4),"\n"; # Call a function in package FooBar
|
||||||
</pre></div>
|
</pre></div>
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<H2><a name="Perl5_nn25"></a>33.5 Input and output parameters</H2>
|
<H2><a name="Perl5_nn25">33.5 Input and output parameters</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1587,7 +1588,7 @@ print "$c\n";
|
||||||
<b>Note:</b> The <tt>REFERENCE</tt> feature is only currently supported for numeric types (integers and floating point).
|
<b>Note:</b> The <tt>REFERENCE</tt> feature is only currently supported for numeric types (integers and floating point).
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Perl5_nn26"></a>33.6 Exception handling</H2>
|
<H2><a name="Perl5_nn26">33.6 Exception handling</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1752,7 +1753,7 @@ This is still supported, but it is deprecated. The newer <tt>%exception</tt> di
|
||||||
functionality, but it has additional capabilities that make it more powerful.
|
functionality, but it has additional capabilities that make it more powerful.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Perl5_nn27"></a>33.7 Remapping datatypes with typemaps</H2>
|
<H2><a name="Perl5_nn27">33.7 Remapping datatypes with typemaps</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1769,7 +1770,7 @@ Typemaps are only used if you want to change some aspect of the primitive
|
||||||
C-Perl interface.
|
C-Perl interface.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn28"></a>33.7.1 A simple typemap example</H3>
|
<H3><a name="Perl5_nn28">33.7.1 A simple typemap example</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1873,7 +1874,7 @@ example::count("e","Hello World");
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Perl5_nn29"></a>33.7.2 Perl5 typemaps</H3>
|
<H3><a name="Perl5_nn29">33.7.2 Perl5 typemaps</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1978,7 +1979,7 @@ Return of C++ member data (all languages).
|
||||||
Check value of input parameter.
|
Check value of input parameter.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn30"></a>33.7.3 Typemap variables</H3>
|
<H3><a name="Perl5_nn30">33.7.3 Typemap variables</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2049,7 +2050,7 @@ properly assigned.
|
||||||
The Perl name of the wrapper function being created.
|
The Perl name of the wrapper function being created.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn31"></a>33.7.4 Useful functions</H3>
|
<H3><a name="Perl5_nn31">33.7.4 Useful functions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2118,7 +2119,7 @@ int sv_isa(SV *, char *0;
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="Perl5_nn32"></a>33.8 Typemap Examples</H2>
|
<H2><a name="Perl5_nn32">33.8 Typemap Examples</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2127,7 +2128,7 @@ might look at the files "<tt>perl5.swg</tt>" and "<tt>typemaps.i</tt>" in
|
||||||
the SWIG library.
|
the SWIG library.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn33"></a>33.8.1 Converting a Perl5 array to a char **</H3>
|
<H3><a name="Perl5_nn33">33.8.1 Converting a Perl5 array to a char **</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2219,7 +2220,7 @@ print @$b,"\n"; # Print it out
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Perl5_nn34"></a>33.8.2 Return values</H3>
|
<H3><a name="Perl5_nn34">33.8.2 Return values</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2248,7 +2249,7 @@ can be done using the <tt>EXTEND()</tt> macro as in:
|
||||||
}
|
}
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn35"></a>33.8.3 Returning values from arguments</H3>
|
<H3><a name="Perl5_nn35">33.8.3 Returning values from arguments</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2302,7 +2303,7 @@ print "multout(7,13) = @r\n";
|
||||||
($x,$y) = multout(7,13);
|
($x,$y) = multout(7,13);
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn36"></a>33.8.4 Accessing array structure members</H3>
|
<H3><a name="Perl5_nn36">33.8.4 Accessing array structure members</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2365,7 +2366,7 @@ the "in" typemap in the previous section would be used to convert an
|
||||||
to copy the converted array into a C data structure.
|
to copy the converted array into a C data structure.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn37"></a>33.8.5 Turning Perl references into C pointers</H3>
|
<H3><a name="Perl5_nn37">33.8.5 Turning Perl references into C pointers</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2430,7 +2431,7 @@ print "$c\n";
|
||||||
|
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn38"></a>33.8.6 Pointer handling</H3>
|
<H3><a name="Perl5_nn38">33.8.6 Pointer handling</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2476,7 +2477,9 @@ is usually accessed as follows:
|
||||||
<div class="code">
|
<div class="code">
|
||||||
<pre>
|
<pre>
|
||||||
Foo *f;
|
Foo *f;
|
||||||
if (SWIG_ConvertPtr($input, (void **) &f, SWIGTYPE_p_Foo, 0) == -1) return NULL;
|
if (!SWIG_IsOK(SWIG_ConvertPtr($input, (void **) &f, SWIGTYPE_p_Foo, 0))) {
|
||||||
|
SWIG_exception_fail(SWIG_TypeError, "in method '$symname', expecting type Foo");
|
||||||
|
}
|
||||||
|
|
||||||
SV *sv = sv_newmortal();
|
SV *sv = sv_newmortal();
|
||||||
SWIG_MakePtr(sv, f, SWIGTYPE_p_Foo, 0);
|
SWIG_MakePtr(sv, f, SWIGTYPE_p_Foo, 0);
|
||||||
|
|
@ -2491,7 +2494,9 @@ variable <tt>$1_descriptor</tt>. For example:
|
||||||
<div class="code">
|
<div class="code">
|
||||||
<pre>
|
<pre>
|
||||||
%typemap(in) Foo * {
|
%typemap(in) Foo * {
|
||||||
if ((SWIG_ConvertPtr($input,(void **) &$1, $1_descriptor,0)) == -1) return NULL;
|
if (!SWIG_IsOK(SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, 0))) {
|
||||||
|
SWIG_exception_fail(SWIG_TypeError, "in method '$symname', expecting type Foo");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -2504,12 +2509,14 @@ For example:
|
||||||
<div class="code">
|
<div class="code">
|
||||||
<pre>
|
<pre>
|
||||||
%typemap(in) Foo * {
|
%typemap(in) Foo * {
|
||||||
if ((SWIG_ConvertPtr($input,(void **) &$1, $descriptor(Foo *), 0)) == -1) return NULL;
|
if (!SWIG_IsOK(SWIG_ConvertPtr($input, (void **) &$1, $descriptor(Foo *), 0))) {
|
||||||
|
SWIG_exception_fail(SWIG_TypeError, "in method '$symname', expecting type Foo");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H2><a name="Perl5_nn39"></a>33.9 Proxy classes</H2>
|
<H2><a name="Perl5_nn39">33.9 Proxy classes</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2525,7 +2532,7 @@ to the underlying code. This section describes the implementation
|
||||||
details of the proxy interface.
|
details of the proxy interface.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn40"></a>33.9.1 Preliminaries</H3>
|
<H3><a name="Perl5_nn40">33.9.1 Preliminaries</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2547,7 +2554,7 @@ SWIG creates a collection of high-level Perl wrappers. In your scripts, you wil
|
||||||
high level wrappers. The wrappers, in turn, interact with the low-level procedural module.
|
high level wrappers. The wrappers, in turn, interact with the low-level procedural module.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn41"></a>33.9.2 Structure and class wrappers</H3>
|
<H3><a name="Perl5_nn41">33.9.2 Structure and class wrappers</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2612,6 +2619,7 @@ sub DESTROY {
|
||||||
examplec::delete_Vector($self));
|
examplec::delete_Vector($self));
|
||||||
delete $OWNER{$self};
|
delete $OWNER{$self};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sub FETCH {
|
sub FETCH {
|
||||||
my ($self,$field) = @_;
|
my ($self,$field) = @_;
|
||||||
|
|
@ -2673,7 +2681,7 @@ $v->DESTROY();
|
||||||
|
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn42"></a>33.9.3 Object Ownership</H3>
|
<H3><a name="Perl5_nn42">33.9.3 Object Ownership</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2760,7 +2768,7 @@ counting, garbage collection, or advanced features one might find in
|
||||||
sophisticated languages.
|
sophisticated languages.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn43"></a>33.9.4 Nested Objects</H3>
|
<H3><a name="Perl5_nn43">33.9.4 Nested Objects</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2813,7 +2821,7 @@ $p->{f}->{x} = 0.0;
|
||||||
%${$p->{v}} = ( x=>0, y=>0, z=>0);
|
%${$p->{v}} = ( x=>0, y=>0, z=>0);
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn44"></a>33.9.5 Proxy Functions</H3>
|
<H3><a name="Perl5_nn44">33.9.5 Proxy Functions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2847,7 +2855,7 @@ This function replaces the original function, but operates in an
|
||||||
identical manner.
|
identical manner.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn45"></a>33.9.6 Inheritance</H3>
|
<H3><a name="Perl5_nn45">33.9.6 Inheritance</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2923,7 +2931,7 @@ particular, inheritance of data members is extremely tricky (and I'm
|
||||||
not even sure if it really works).
|
not even sure if it really works).
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn46"></a>33.9.7 Modifying the proxy methods</H3>
|
<H3><a name="Perl5_nn46">33.9.7 Modifying the proxy methods</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2951,7 +2959,7 @@ public:
|
||||||
};
|
};
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H2><a name="Perl5_nn47"></a>33.10 Adding additional Perl code</H2>
|
<H2><a name="Perl5_nn47">33.10 Adding additional Perl code</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3002,7 +3010,7 @@ set_transform($im, $a);
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H2><a name="Perl5_directors"></a>33.11 Cross language polymorphism</H2>
|
<H2><a name="Perl5_directors">33.11 Cross language polymorphism</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3036,7 +3044,7 @@ proxy classes, director classes, and C wrapper functions takes care of
|
||||||
all the cross-language method routing transparently.
|
all the cross-language method routing transparently.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn48"></a>33.11.1 Enabling directors</H3>
|
<H3><a name="Perl5_nn48">33.11.1 Enabling directors</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3126,7 +3134,7 @@ sub one {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Perl5_nn49"></a>33.11.2 Director classes</H3>
|
<H3><a name="Perl5_nn49">33.11.2 Director classes</a></H3>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -3206,7 +3214,7 @@ so there is no need for the extra overhead involved with routing the
|
||||||
calls through Perl.
|
calls through Perl.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn50"></a>33.11.3 Ownership and object destruction</H3>
|
<H3><a name="Perl5_nn50">33.11.3 Ownership and object destruction</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3255,7 +3263,7 @@ sub DESTROY {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Perl5_nn51"></a>33.11.4 Exception unrolling</H3>
|
<H3><a name="Perl5_nn51">33.11.4 Exception unrolling</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3311,7 +3319,7 @@ Swig::DirectorMethodException is thrown, Perl will register the
|
||||||
exception as soon as the C wrapper function returns.
|
exception as soon as the C wrapper function returns.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn52"></a>33.11.5 Overhead and code bloat</H3>
|
<H3><a name="Perl5_nn52">33.11.5 Overhead and code bloat</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3345,7 +3353,7 @@ directive) for only those methods that are likely to be extended in
|
||||||
Perl.
|
Perl.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Perl5_nn53"></a>33.11.6 Typemaps</H3>
|
<H3><a name="Perl5_nn53">33.11.6 Typemaps</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<!-- Hand crafted HTML -->
|
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>SWIG and PHP</title>
|
<title>SWIG and PHP</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
<H1><a name="Php"></a>34 SWIG and PHP</H1>
|
<H1><a name="Php">34 SWIG and PHP</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
<li><a href="#Php_nn2_5">Pointers and References</a>
|
<li><a href="#Php_nn2_5">Pointers and References</a>
|
||||||
<li><a href="#Php_nn2_6">Structures and C++ classes</a>
|
<li><a href="#Php_nn2_6">Structures and C++ classes</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#Php_nn2_6_1">Using <tt>-noproxy</tt></a>
|
<li><a href="#Php_nn2_6_1">Using -noproxy</a>
|
||||||
<li><a href="#Php_nn2_6_2">Constructors and Destructors</a>
|
<li><a href="#Php_nn2_6_2">Constructors and Destructors</a>
|
||||||
<li><a href="#Php_nn2_6_3">Static Member Variables</a>
|
<li><a href="#Php_nn2_6_3">Static Member Variables</a>
|
||||||
<li><a href="#Php_nn2_6_4">Static Member Functions</a>
|
<li><a href="#Php_nn2_6_4">Static Member Functions</a>
|
||||||
|
|
@ -49,19 +49,6 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<p>
|
|
||||||
SWIG supports generating wrappers for PHP5. Support for PHP4 was removed
|
|
||||||
in SWIG 1.3.37. The PHP developers are no longer making new PHP4 releases,
|
|
||||||
and won't even be patching critical security issues after 2008-08-08, so it
|
|
||||||
doesn't make much sense for SWIG to continue to support PHP4 now. If you
|
|
||||||
really need to continue to use PHP4, just stick with SWIG 1.3.36.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
Currently any PHP5 release should work, but we don't regularly test with
|
|
||||||
PHP < 5.3.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
In this chapter, we discuss SWIG's support of PHP. The PHP module
|
In this chapter, we discuss SWIG's support of PHP. The PHP module
|
||||||
was extensively rewritten in release 1.3.26, and support for generating
|
was extensively rewritten in release 1.3.26, and support for generating
|
||||||
|
|
@ -70,7 +57,17 @@ of the features available in some of the other languages.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
In order to use this module, you will need to have a copy of the PHP5
|
SWIG supports generating wrappers for PHP5 and PHP7. Support for PHP4 was removed
|
||||||
|
in SWIG 1.3.37.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Currently any PHP5 or PHP7 release should work, but we don't regularly test with
|
||||||
|
PHP < 5.3.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
In order to use this module, you will need to have a copy of the PHP
|
||||||
include files to compile the SWIG generated files. If you installed
|
include files to compile the SWIG generated files. If you installed
|
||||||
PHP from a binary package, you may need to install a "php-dev" or "php-devel"
|
PHP from a binary package, you may need to install a "php-dev" or "php-devel"
|
||||||
package for these to be installed. You can find out where these files are
|
package for these to be installed. You can find out where these files are
|
||||||
|
|
@ -80,16 +77,17 @@ your extension into php directly, you will need the complete PHP source tree
|
||||||
available.
|
available.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Php_nn1"></a>34.1 Generating PHP Extensions</H2>
|
<H2><a name="Php_nn1">34.1 Generating PHP Extensions</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
To build a PHP extension, run swig using the <tt>-php</tt> option as
|
To build a PHP extension, run swig using the <tt>-php5</tt> or
|
||||||
follows:
|
<tt>-php7</tt> option as follows (<tt>-php</tt> is also supported
|
||||||
|
and currently is an alias for <tt>-php5</tt>):
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="code"><pre>
|
<div class="code"><pre>
|
||||||
swig -php example.i
|
swig -php7 example.i
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -102,13 +100,18 @@ The third file,
|
||||||
<tt>example.php</tt> can be included by PHP scripts. It attempts to
|
<tt>example.php</tt> can be included by PHP scripts. It attempts to
|
||||||
dynamically load the extension and contains extra php code specified
|
dynamically load the extension and contains extra php code specified
|
||||||
in the interface file. If wrapping C++ code with PHP classes, it will
|
in the interface file. If wrapping C++ code with PHP classes, it will
|
||||||
also contain PHP5 class wrappers.
|
also contain PHP class wrappers.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
SWIG can generate PHP extensions from C++ libraries as well when
|
SWIG can generate PHP extensions from C++ libraries as well when
|
||||||
given the <tt>-c++</tt> option. The support for C++ is discussed in
|
given the <tt>-c++</tt> option. The support for C++ is discussed in
|
||||||
more detail in <a href="#Php_nn2_6">section 27.2.6</a>.
|
more detail in <a href="#Php_nn2_6">section 27.2.6</a>. The generated
|
||||||
|
C++ wrapper will be called example_wrap.cpp (for PHP5) or
|
||||||
|
example_wrap.cxx (for PHP7 where the default has been changed to align
|
||||||
|
with SWIG's default for every other language). You can specify a
|
||||||
|
different extension for the C++ wrapper using <tt>-cppext</tt> -
|
||||||
|
e.g. if you want example_wrap.cc use <tt>-cppext cc</tt>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -125,7 +128,7 @@ and it doesn't play nicely with package system. We don't recommend
|
||||||
this approach, or provide explicit support for it.
|
this approach, or provide explicit support for it.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Php_nn1_1"></a>34.1.1 Building a loadable extension</H3>
|
<H3><a name="Php_nn1_1">34.1.1 Building a loadable extension</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -140,7 +143,7 @@ least work for Linux though):
|
||||||
gcc -shared example_wrap.o example.o -o example.so
|
gcc -shared example_wrap.o example.o -o example.so
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Php_nn1_3"></a>34.1.2 Using PHP Extensions</H3>
|
<H3><a name="Php_nn1_3">34.1.2 Using PHP Extensions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -188,7 +191,7 @@ This PHP module also defines the PHP classes for the wrapped API, so you'll
|
||||||
almost certainly want to include it anyway.
|
almost certainly want to include it anyway.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Php_nn2"></a>34.2 Basic PHP interface</H2>
|
<H2><a name="Php_nn2">34.2 Basic PHP interface</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -199,7 +202,7 @@ other symbols unless care is taken to <tt>%rename</tt> them. At present
|
||||||
SWIG doesn't have support for the namespace feature added in PHP 5.3.
|
SWIG doesn't have support for the namespace feature added in PHP 5.3.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Php_nn2_1"></a>34.2.1 Constants</H3>
|
<H3><a name="Php_nn2_1">34.2.1 Constants</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -262,9 +265,9 @@ accessed incorrectly in PHP,
|
||||||
include("example.php");
|
include("example.php");
|
||||||
|
|
||||||
if(EASY_TO_MISPEL) {
|
if(EASY_TO_MISPEL) {
|
||||||
....
|
...
|
||||||
} else {
|
} else {
|
||||||
....
|
...
|
||||||
}
|
}
|
||||||
|
|
||||||
</pre>
|
</pre>
|
||||||
|
|
@ -273,10 +276,11 @@ if(EASY_TO_MISPEL) {
|
||||||
<p>
|
<p>
|
||||||
The mis-spelled constant will become the string 'EASY_TO_MISPEL', which
|
The mis-spelled constant will become the string 'EASY_TO_MISPEL', which
|
||||||
is treated as true by the if test, when the value of the intended constant
|
is treated as true by the if test, when the value of the intended constant
|
||||||
would be treated as false!
|
would be treated as false! Modern versions of PHP will at least issue
|
||||||
|
a PHP notice by default when this happens.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Php_nn2_2"></a>34.2.2 Global Variables</H3>
|
<H3><a name="Php_nn2_2">34.2.2 Global Variables</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -325,7 +329,7 @@ undefined.
|
||||||
At this time SWIG does not support custom accessor methods.
|
At this time SWIG does not support custom accessor methods.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Php_nn2_3"></a>34.2.3 Functions</H3>
|
<H3><a name="Php_nn2_3">34.2.3 Functions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -378,7 +382,7 @@ print $s; # The value of $s was not changed.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Php_nn2_4"></a>34.2.4 Overloading</H3>
|
<H3><a name="Php_nn2_4">34.2.4 Overloading</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -434,7 +438,7 @@ taking the integer argument.
|
||||||
</p>
|
</p>
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<H3><a name="Php_nn2_5"></a>34.2.5 Pointers and References</H3>
|
<H3><a name="Php_nn2_5">34.2.5 Pointers and References</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -579,7 +583,7 @@ PHP in a number of ways: by using <tt>unset</tt> on an existing
|
||||||
variable, or assigning <tt>NULL</tt> to a variable.
|
variable, or assigning <tt>NULL</tt> to a variable.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Php_nn2_6"></a>34.2.6 Structures and C++ classes</H3>
|
<H3><a name="Php_nn2_6">34.2.6 Structures and C++ classes</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -611,7 +615,7 @@ struct Complex {
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Would be used in the following way from PHP5:
|
Would be used in the following way from PHP:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="code"><pre>
|
<div class="code"><pre>
|
||||||
|
|
@ -640,13 +644,13 @@ Would be used in the following way from PHP5:
|
||||||
Member variables and methods are accessed using the <tt>-></tt> operator.
|
Member variables and methods are accessed using the <tt>-></tt> operator.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H4><a name="Php_nn2_6_1"></a>34.2.6.1 Using <tt>-noproxy</tt></H4>
|
<H4><a name="Php_nn2_6_1">34.2.6.1 Using -noproxy</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
The <tt>-noproxy</tt> option flattens the object structure and
|
The <tt>-noproxy</tt> option flattens the object structure and
|
||||||
generates collections of named functions (these are the functions
|
generates collections of named functions (these are the functions
|
||||||
which the PHP5 class wrappers call). The above example results
|
which the PHP class wrappers call). The above example results
|
||||||
in the following PHP functions:
|
in the following PHP functions:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
@ -666,7 +670,7 @@ Complex_im_set($obj,$d);
|
||||||
Complex_im_get($obj);
|
Complex_im_get($obj);
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H4><a name="Php_nn2_6_2"></a>34.2.6.2 Constructors and Destructors</H4>
|
<H4><a name="Php_nn2_6_2">34.2.6.2 Constructors and Destructors</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -707,7 +711,7 @@ the programmer can either reassign the variable or call
|
||||||
<tt>unset($v)</tt>
|
<tt>unset($v)</tt>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H4><a name="Php_nn2_6_3"></a>34.2.6.3 Static Member Variables</H4>
|
<H4><a name="Php_nn2_6_3">34.2.6.3 Static Member Variables</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -750,7 +754,7 @@ Ko::threats(10);
|
||||||
echo "There have now been " . Ko::threats() . " threats\n";
|
echo "There have now been " . Ko::threats() . " threats\n";
|
||||||
|
|
||||||
</pre></div>
|
</pre></div>
|
||||||
<H4><a name="Php_nn2_6_4"></a>34.2.6.4 Static Member Functions</H4>
|
<H4><a name="Php_nn2_6_4">34.2.6.4 Static Member Functions</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -772,7 +776,7 @@ Ko::threats();
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
|
|
||||||
<H4><a name="Php_nn2_6_5"></a>34.2.6.5 Specifying Implemented Interfaces</H4>
|
<H4><a name="Php_nn2_6_5">34.2.6.5 Specifying Implemented Interfaces</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -790,7 +794,7 @@ so:
|
||||||
If there are multiple interfaces, just list them separated by commas.
|
If there are multiple interfaces, just list them separated by commas.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Php_nn2_7"></a>34.2.7 PHP Pragmas, Startup and Shutdown code</H3>
|
<H3><a name="Php_nn2_7">34.2.7 PHP Pragmas, Startup and Shutdown code</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -878,7 +882,7 @@ The <tt>%rinit</tt> and <tt>%rshutdown</tt> statements are very similar but inse
|
||||||
into the request init (PHP_RINIT_FUNCTION) and request shutdown (PHP_RSHUTDOWN_FUNCTION) code respectively.
|
into the request init (PHP_RINIT_FUNCTION) and request shutdown (PHP_RSHUTDOWN_FUNCTION) code respectively.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Php_nn3"></a>34.3 Cross language polymorphism</H2>
|
<H2><a name="Php_nn3">34.3 Cross language polymorphism</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -913,7 +917,7 @@ wrapper functions takes care of all the cross-language method routing
|
||||||
transparently.
|
transparently.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Php_nn3_1"></a>34.3.1 Enabling directors</H3>
|
<H3><a name="Php_nn3_1">34.3.1 Enabling directors</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1002,7 +1006,7 @@ class MyFoo extends Foo {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Php_nn3_2"></a>34.3.2 Director classes</H3>
|
<H3><a name="Php_nn3_2">34.3.2 Director classes</a></H3>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1082,7 +1086,7 @@ so there is no need for the extra overhead involved with routing the
|
||||||
calls through PHP.
|
calls through PHP.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Php_nn3_3"></a>34.3.3 Ownership and object destruction</H3>
|
<H3><a name="Php_nn3_3">34.3.3 Ownership and object destruction</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1138,7 +1142,7 @@ In this example, we are assuming that FooContainer will take care of
|
||||||
deleting all the Foo pointers it contains at some point.
|
deleting all the Foo pointers it contains at some point.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Php_nn3_4"></a>34.3.4 Exception unrolling</H3>
|
<H3><a name="Php_nn3_4">34.3.4 Exception unrolling</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1197,7 +1201,7 @@ Swig::DirectorMethodException is thrown, PHP will register the exception
|
||||||
as soon as the C wrapper function returns.
|
as soon as the C wrapper function returns.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Php_nn3_5"></a>34.3.5 Overhead and code bloat</H3>
|
<H3><a name="Php_nn3_5">34.3.5 Overhead and code bloat</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1230,7 +1234,7 @@ optimized by selectively enabling director methods (using the %feature
|
||||||
directive) for only those methods that are likely to be extended in PHP.
|
directive) for only those methods that are likely to be extended in PHP.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Php_nn3_6"></a>34.3.6 Typemaps</H3>
|
<H3><a name="Php_nn3_6">34.3.6 Typemaps</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1244,7 +1248,7 @@ need to be supported.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Php_nn3_7"></a>34.3.7 Miscellaneous</H3>
|
<H3><a name="Php_nn3_7">34.3.7 Miscellaneous</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> Director typemaps for STL classes are mostly in place, and hence you
|
<p> Director typemaps for STL classes are mostly in place, and hence you
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>SWIG and Pike</title>
|
<title>SWIG and Pike</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
<H1><a name="Pike"></a>35 SWIG and Pike</H1>
|
<H1><a name="Pike">35 SWIG and Pike</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -46,10 +47,10 @@ least, make sure you read the "<a href="SWIG.html#SWIG">SWIG Basics</a>"
|
||||||
chapter.<br>
|
chapter.<br>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Pike_nn2"></a>35.1 Preliminaries</H2>
|
<H2><a name="Pike_nn2">35.1 Preliminaries</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Pike_nn3"></a>35.1.1 Running SWIG</H3>
|
<H3><a name="Pike_nn3">35.1.1 Running SWIG</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -94,7 +95,7 @@ can use the <tt>-o</tt> option:
|
||||||
<div class="code">
|
<div class="code">
|
||||||
<pre>$ <b>swig -pike -o pseudonym.c example.i</b><br></pre>
|
<pre>$ <b>swig -pike -o pseudonym.c example.i</b><br></pre>
|
||||||
</div>
|
</div>
|
||||||
<H3><a name="Pike_nn4"></a>35.1.2 Getting the right header files</H3>
|
<H3><a name="Pike_nn4">35.1.2 Getting the right header files</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -114,7 +115,7 @@ You're looking for files with the names <tt>global.h</tt>, <tt>program.h</tt>
|
||||||
and so on.
|
and so on.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Pike_nn5"></a>35.1.3 Using your module</H3>
|
<H3><a name="Pike_nn5">35.1.3 Using your module</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -129,10 +130,10 @@ Pike v7.4 release 10 running Hilfe v3.5 (Incremental Pike Frontend)
|
||||||
(1) Result: 24
|
(1) Result: 24
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H2><a name="Pike_nn6"></a>35.2 Basic C/C++ Mapping</H2>
|
<H2><a name="Pike_nn6">35.2 Basic C/C++ Mapping</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Pike_nn7"></a>35.2.1 Modules</H3>
|
<H3><a name="Pike_nn7">35.2.1 Modules</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -143,7 +144,7 @@ concerned), SWIG's <tt>%module</tt> directive doesn't really have any
|
||||||
significance.
|
significance.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Pike_nn8"></a>35.2.2 Functions</H3>
|
<H3><a name="Pike_nn8">35.2.2 Functions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -168,7 +169,7 @@ exactly as you'd expect it to:
|
||||||
(1) Result: 24
|
(1) Result: 24
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Pike_nn9"></a>35.2.3 Global variables</H3>
|
<H3><a name="Pike_nn9">35.2.3 Global variables</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -197,7 +198,7 @@ will result in two functions, <tt>Foo_get()</tt> and <tt>Foo_set()</tt>:
|
||||||
(3) Result: 3.141590
|
(3) Result: 3.141590
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Pike_nn10"></a>35.2.4 Constants and enumerated types</H3>
|
<H3><a name="Pike_nn10">35.2.4 Constants and enumerated types</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -205,7 +206,7 @@ Enumerated types in C/C++ declarations are wrapped as Pike constants,
|
||||||
not as Pike enums.
|
not as Pike enums.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Pike_nn11"></a>35.2.5 Constructors and Destructors</H3>
|
<H3><a name="Pike_nn11">35.2.5 Constructors and Destructors</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -213,7 +214,7 @@ Constructors are wrapped as <tt>create()</tt> methods, and destructors are
|
||||||
wrapped as <tt>destroy()</tt> methods, for Pike classes.
|
wrapped as <tt>destroy()</tt> methods, for Pike classes.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Pike_nn12"></a>35.2.6 Static Members</H3>
|
<H3><a name="Pike_nn12">35.2.6 Static Members</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Preface</title>
|
<title>Preface</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
<H1><a name="Preface"></a>1 Preface</H1>
|
<H1><a name="Preface">1 Preface</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -35,7 +36,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="Preface_nn2"></a>1.1 Introduction</H2>
|
<H2><a name="Preface_nn2">1.1 Introduction</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -58,7 +59,7 @@ has since evolved into a general purpose tool that is used in a wide
|
||||||
variety of applications--in fact almost anything where C/C++ programming
|
variety of applications--in fact almost anything where C/C++ programming
|
||||||
is involved.
|
is involved.
|
||||||
|
|
||||||
<H2><a name="Preface_nn4"></a>1.2 SWIG Versions</H2>
|
<H2><a name="Preface_nn4">1.2 SWIG Versions</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -70,7 +71,7 @@ An official stable version was released along with the decision to make SWIG
|
||||||
license changes and this gave rise to version 2.0.0 in 2010.
|
license changes and this gave rise to version 2.0.0 in 2010.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Preface_license"></a>1.3 SWIG License</H2>
|
<H2><a name="Preface_license">1.3 SWIG License</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -86,7 +87,7 @@ under license terms of the user's choice/requirements and at the same time the S
|
||||||
source was placed under the GNU General Public License version 3.
|
source was placed under the GNU General Public License version 3.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Preface_nn5"></a>1.4 SWIG resources</H2>
|
<H2><a name="Preface_nn5">1.4 SWIG resources</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -126,7 +127,7 @@ about this can be obtained at:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="Preface_nn6"></a>1.5 Prerequisites</H2>
|
<H2><a name="Preface_nn6">1.5 Prerequisites</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -151,7 +152,7 @@ However, this isn't meant to be a tutorial on C++ programming. For many
|
||||||
of the gory details, you will almost certainly want to consult a good C++ reference. If you don't program
|
of the gory details, you will almost certainly want to consult a good C++ reference. If you don't program
|
||||||
in C++, you may just want to skip those parts of the manual.
|
in C++, you may just want to skip those parts of the manual.
|
||||||
|
|
||||||
<H2><a name="Preface_nn7"></a>1.6 Organization of this manual</H2>
|
<H2><a name="Preface_nn7">1.6 Organization of this manual</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -163,7 +164,7 @@ can probably skip to that chapter and find almost everything you need
|
||||||
to know.
|
to know.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Preface_nn8"></a>1.7 How to avoid reading the manual</H2>
|
<H2><a name="Preface_nn8">1.7 How to avoid reading the manual</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -175,7 +176,7 @@ The SWIG distribution also comes with a large directory of
|
||||||
examples that illustrate different topics.
|
examples that illustrate different topics.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Preface_nn9"></a>1.8 Backwards compatibility</H2>
|
<H2><a name="Preface_nn9">1.8 Backwards compatibility</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -211,7 +212,7 @@ Note: The version symbol is not defined in the generated SWIG
|
||||||
wrapper file. The SWIG preprocessor has defined SWIG_VERSION since SWIG-1.3.11.
|
wrapper file. The SWIG preprocessor has defined SWIG_VERSION since SWIG-1.3.11.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Preface_release_notes"></a>1.9 Release notes</H2>
|
<H2><a name="Preface_release_notes">1.9 Release notes</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -220,7 +221,7 @@ contain, respectively, detailed release notes for the current version,
|
||||||
detailed release notes for previous releases and summary release notes from SWIG-1.3.22 onwards.
|
detailed release notes for previous releases and summary release notes from SWIG-1.3.22 onwards.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Preface_nn10"></a>1.10 Credits</H2>
|
<H2><a name="Preface_nn10">1.10 Credits</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -233,7 +234,7 @@ who have made contributions at all levels over time. Contributors
|
||||||
are mentioned either in the COPYRIGHT file or CHANGES files shipped with SWIG or in submitted bugs.
|
are mentioned either in the COPYRIGHT file or CHANGES files shipped with SWIG or in submitted bugs.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Preface_nn11"></a>1.11 Bug reports</H2>
|
<H2><a name="Preface_nn11">1.11 Bug reports</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -248,23 +249,30 @@ used, and any important pieces of the SWIG generated wrapper code. We
|
||||||
can only fix bugs if we know about them.
|
can only fix bugs if we know about them.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Preface_installation"></a>1.12 Installation</H2>
|
<H2><a name="Preface_installation">1.12 Installation</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Preface_windows_installation"></a>1.12.1 Windows installation</H3>
|
<H3><a name="Preface_windows_installation">1.12.1 Windows installation</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Please see the dedicated <a href="Windows.html">Windows chapter</a> for instructions on installing
|
Please see the dedicated <a href="Windows.html#Windows">Windows chapter</a> for instructions on installing
|
||||||
SWIG on Windows and running the examples. The Windows distribution is
|
SWIG on Windows and running the examples. The Windows distribution is
|
||||||
called swigwin and includes a prebuilt SWIG executable, swig.exe, included in
|
called swigwin and includes a prebuilt SWIG executable, swig.exe, included in
|
||||||
the top level directory. Otherwise it is exactly the same as
|
the top level directory. Otherwise it is exactly the same as
|
||||||
the main SWIG distribution. There is no need to download anything else.
|
the main SWIG distribution. There is no need to download anything else.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Preface_unix_installation"></a>1.12.2 Unix installation</H3>
|
<H3><a name="Preface_unix_installation">1.12.2 Unix installation</a></H3>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
These installation instructions are for using the distributed tarball,
|
||||||
|
for example, <tt>swig-3.0.8.tar.gz</tt>.
|
||||||
|
If you wish to build and install from source on Github, extra steps are required.
|
||||||
|
Please see the <a href="http://swig.org/svn.html">Bleeding Edge</a> page on the SWIG website.
|
||||||
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
You must use <a href="http://www.gnu.org/software/make/">GNU make</a> to build and install SWIG.
|
You must use <a href="http://www.gnu.org/software/make/">GNU make</a> to build and install SWIG.
|
||||||
</p>
|
</p>
|
||||||
|
|
@ -332,7 +340,7 @@ be configured with a subset of target languages.
|
||||||
SWIG used to include a set of runtime libraries for some languages for working
|
SWIG used to include a set of runtime libraries for some languages for working
|
||||||
with multiple modules. These are no longer built during the installation stage.
|
with multiple modules. These are no longer built during the installation stage.
|
||||||
However, users can build them just like any wrapper module as described in
|
However, users can build them just like any wrapper module as described in
|
||||||
the <a href="Modules.html">Modules chapter</a>.
|
the <a href="Modules.html#Modules">Modules chapter</a>.
|
||||||
The CHANGES file shipped with SWIG in the top level directory
|
The CHANGES file shipped with SWIG in the top level directory
|
||||||
also lists some examples which build the runtime library.
|
also lists some examples which build the runtime library.
|
||||||
</p>
|
</p>
|
||||||
|
|
@ -350,7 +358,7 @@ a number of packages to be installed. Full instructions at
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<H3><a name="Preface_osx_installation"></a>1.12.3 Macintosh OS X installation</H3>
|
<H3><a name="Preface_osx_installation">1.12.3 Macintosh OS X installation</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -370,7 +378,7 @@ installation of software you might have. However, this is generally not the rec
|
||||||
technique for building larger extension modules. Instead, you should utilize
|
technique for building larger extension modules. Instead, you should utilize
|
||||||
Darwin's two-level namespaces. Some details about this can be found here
|
Darwin's two-level namespaces. Some details about this can be found here
|
||||||
|
|
||||||
<a href="http://developer.apple.com/documentation/ReleaseNotes/DeveloperTools/TwoLevelNamespaces.html">http://developer.apple.com/documentation/ReleaseNotes/DeveloperTools/TwoLevelNamespaces.html</a>.
|
<a href="https://developer.apple.com/library/mac/documentation/Porting/Conceptual/PortingUnix/compiling/compiling.html#//apple_ref/doc/uid/TP40002850-BCIHJBBF">Understanding Two-Level Namespaces</a>.
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
@ -378,7 +386,7 @@ Darwin's two-level namespaces. Some details about this can be found here
|
||||||
Needless to say, you might have to experiment a bit to get things working at first.
|
Needless to say, you might have to experiment a bit to get things working at first.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Preface_testing"></a>1.12.4 Testing</H3>
|
<H3><a name="Preface_testing">1.12.4 Testing</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -432,7 +440,7 @@ have many different target languages installed and a slow machine, it
|
||||||
might take more than an hour to run the test-suite.
|
might take more than an hour to run the test-suite.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Preface_examples"></a>1.12.5 Examples</H3>
|
<H3><a name="Preface_examples">1.12.5 Examples</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>SWIG Preprocessor</title>
|
<title>SWIG Preprocessor</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
<H1><a name="Preprocessor"></a>8 Preprocessing</H1>
|
<H1><a name="Preprocessor">8 Preprocessing</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -37,7 +38,7 @@ However, a number of modifications and enhancements have been made. This
|
||||||
chapter describes some of these modifications.
|
chapter describes some of these modifications.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Preprocessor_nn2"></a>8.1 File inclusion</H2>
|
<H2><a name="Preprocessor_nn2">8.1 File inclusion</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -63,7 +64,7 @@ By default, the <tt>#include</tt> is ignored unless you run SWIG with the
|
||||||
is that you often don't want SWIG to try and wrap everything included
|
is that you often don't want SWIG to try and wrap everything included
|
||||||
in standard header system headers and auxiliary files.
|
in standard header system headers and auxiliary files.
|
||||||
|
|
||||||
<H2><a name="Preprocessor_nn3"></a>8.2 File imports</H2>
|
<H2><a name="Preprocessor_nn3">8.2 File imports</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -92,7 +93,7 @@ The <tt>-importall</tt> directive tells SWIG to follow all <tt>#include</tt> sta
|
||||||
as imports. This might be useful if you want to extract type definitions from system
|
as imports. This might be useful if you want to extract type definitions from system
|
||||||
header files without generating any wrappers.
|
header files without generating any wrappers.
|
||||||
|
|
||||||
<H2><a name="Preprocessor_condition_compilation"></a>8.3 Conditional Compilation</H2>
|
<H2><a name="Preprocessor_condition_compilation">8.3 Conditional Compilation</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -124,7 +125,9 @@ SWIGMZSCHEME Defined when using Mzscheme
|
||||||
SWIGOCAML Defined when using Ocaml
|
SWIGOCAML Defined when using Ocaml
|
||||||
SWIGOCTAVE Defined when using Octave
|
SWIGOCTAVE Defined when using Octave
|
||||||
SWIGPERL Defined when using Perl
|
SWIGPERL Defined when using Perl
|
||||||
SWIGPHP Defined when using PHP
|
SWIGPHP Defined when using PHP5 or PHP7
|
||||||
|
SWIGPHP5 Defined when using PHP5
|
||||||
|
SWIGPHP7 Defined when using PHP7
|
||||||
SWIGPIKE Defined when using Pike
|
SWIGPIKE Defined when using Pike
|
||||||
SWIGPYTHON Defined when using Python
|
SWIGPYTHON Defined when using Python
|
||||||
SWIGR Defined when using R
|
SWIGR Defined when using R
|
||||||
|
|
@ -156,7 +159,7 @@ SWIG (except for the symbol `<tt>SWIG</tt>' which is only defined
|
||||||
within the SWIG compiler).
|
within the SWIG compiler).
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Preprocessor_nn5"></a>8.4 Macro Expansion</H2>
|
<H2><a name="Preprocessor_nn5">8.4 Macro Expansion</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -211,7 +214,7 @@ like <tt>#x</tt>. This is a non-standard SWIG extension.
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<H2><a name="Preprocessor_nn6"></a>8.5 SWIG Macros</H2>
|
<H2><a name="Preprocessor_nn6">8.5 SWIG Macros</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -257,7 +260,7 @@ many of SWIG's advanced features and libraries are built using this mechanism (s
|
||||||
support).
|
support).
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Preprocessor_nn7"></a>8.6 C99 and GNU Extensions</H2>
|
<H2><a name="Preprocessor_nn7">8.6 C99 and GNU Extensions</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -313,14 +316,14 @@ interface building. However, they are used internally to implement a number of
|
||||||
SWIG directives and are provided to make SWIG more compatible with C99 code.
|
SWIG directives and are provided to make SWIG more compatible with C99 code.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Preprocessor_delimiters"></a>8.7 Preprocessing and delimiters</H2>
|
<H2><a name="Preprocessor_delimiters">8.7 Preprocessing and delimiters</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
The preprocessor handles { }, " " and %{ %} delimiters differently.
|
The preprocessor handles { }, " " and %{ %} delimiters differently.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Preprocessor_nn8"></a>8.7.1 Preprocessing and %{ ... %} & " ... " delimiters</H3>
|
<H3><a name="Preprocessor_nn8">8.7.1 Preprocessing and %{ ... %} & " ... " delimiters</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -345,7 +348,7 @@ the contents of the <tt>%{ ... %}</tt> block are copied without
|
||||||
modification to the output (including all preprocessor directives).
|
modification to the output (including all preprocessor directives).
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Preprocessor_nn9"></a>8.7.2 Preprocessing and { ... } delimiters</H3>
|
<H3><a name="Preprocessor_nn9">8.7.2 Preprocessing and { ... } delimiters</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -387,7 +390,7 @@ to actually go into the wrapper file, prefix the preprocessor directives with <t
|
||||||
SWIG will strip the extra <tt>%</tt> and leave the preprocessor directive in the code.
|
SWIG will strip the extra <tt>%</tt> and leave the preprocessor directive in the code.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Preprocessor_typemap_delimiters"></a>8.8 Preprocessor and Typemaps</H2>
|
<H2><a name="Preprocessor_typemap_delimiters">8.8 Preprocessor and Typemaps</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -458,7 +461,7 @@ would generate
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="Preprocessor_nn10"></a>8.9 Viewing preprocessor output</H2>
|
<H2><a name="Preprocessor_nn10">8.9 Viewing preprocessor output</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -468,7 +471,7 @@ Instead the results after the preprocessor has run are displayed.
|
||||||
This might be useful as an aid to debugging and viewing the results of macro expansions.
|
This might be useful as an aid to debugging and viewing the results of macro expansions.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Preprocessor_warning_error"></a>8.10 The #error and #warning directives</H2>
|
<H2><a name="Preprocessor_warning_error">8.10 The #error and #warning directives</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,12 +1,13 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>SWIG and R</title>
|
<title>SWIG and R</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
<H1><a name="R"></a>37 SWIG and R</H1>
|
<H1><a name="R">37 SWIG and R</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -33,7 +34,7 @@ compile and run an R interface to QuantLib running on Mandriva Linux
|
||||||
with gcc. The R bindings also work on Microsoft Windows using Visual C++.
|
with gcc. The R bindings also work on Microsoft Windows using Visual C++.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="R_nn2"></a>37.1 Bugs</H2>
|
<H2><a name="R_nn2">37.1 Bugs</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -45,7 +46,7 @@ Currently the following features are not implemented or broken:
|
||||||
<li>C Array wrappings
|
<li>C Array wrappings
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<H2><a name="R_nn3"></a>37.2 Using R and SWIG</H2>
|
<H2><a name="R_nn3">37.2 Using R and SWIG</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -136,7 +137,7 @@ Error in .Call("R_swig_fact", s_arg1, as.logical(.copy), PACKAGE = "example") :
|
||||||
<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
|
<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>
|
</ul>
|
||||||
|
|
||||||
<H2><a name="R_nn4"></a>37.3 Precompiling large R files</H2>
|
<H2><a name="R_nn4">37.3 Precompiling large R files</a></H2>
|
||||||
|
|
||||||
|
|
||||||
In cases where the R file is large, one make save a lot of loading
|
In cases where the R file is large, one make save a lot of loading
|
||||||
|
|
@ -154,7 +155,7 @@ will save a large amount of loading time.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="R_nn5"></a>37.4 General policy</H2>
|
<H2><a name="R_nn5">37.4 General policy</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -163,7 +164,7 @@ wrapping over the underlying functions and rely on the R type system
|
||||||
to provide R syntax.
|
to provide R syntax.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="R_language_conventions"></a>37.5 Language conventions</H2>
|
<H2><a name="R_language_conventions">37.5 Language conventions</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -172,7 +173,7 @@ and [ are overloaded to allow for R syntax (one based indices and
|
||||||
slices)
|
slices)
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="R_nn6"></a>37.6 C++ classes</H2>
|
<H2><a name="R_nn6">37.6 C++ classes</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -184,7 +185,7 @@ keep track of the pointer object which removes the necessity for a lot
|
||||||
of the proxy class baggage you see in other languages.
|
of the proxy class baggage you see in other languages.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="R_nn7"></a>37.7 Enumerations</H2>
|
<H2><a name="R_nn7">37.7 Enumerations</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,14 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>SWIG and Ruby</title>
|
<title>SWIG and Ruby</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
|
|
||||||
<H1><a name="Ruby"></a>38 SWIG and Ruby</H1>
|
<H1><a name="Ruby">38 SWIG and Ruby</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -42,6 +43,10 @@
|
||||||
<li><a href="#Ruby_C_STL_Functors">C++ STL Functors</a>
|
<li><a href="#Ruby_C_STL_Functors">C++ STL Functors</a>
|
||||||
<li><a href="#Ruby_C_Iterators">C++ STL Iterators</a>
|
<li><a href="#Ruby_C_Iterators">C++ STL Iterators</a>
|
||||||
<li><a href="#Ruby_nn24">C++ Smart Pointers</a>
|
<li><a href="#Ruby_nn24">C++ Smart Pointers</a>
|
||||||
|
<ul>
|
||||||
|
<li><a href="#Ruby_smart_pointers_shared_ptr">The shared_ptr Smart Pointer</a>
|
||||||
|
<li><a href="#Ruby_smart_pointers_generic">Generic Smart Pointers</a>
|
||||||
|
</ul>
|
||||||
<li><a href="#Ruby_nn25">Cross-Language Polymorphism</a>
|
<li><a href="#Ruby_nn25">Cross-Language Polymorphism</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#Ruby_nn26">Exception Unrolling</a>
|
<li><a href="#Ruby_nn26">Exception Unrolling</a>
|
||||||
|
|
@ -144,7 +149,7 @@
|
||||||
|
|
||||||
<p>This chapter describes SWIG's support of Ruby.</p>
|
<p>This chapter describes SWIG's support of Ruby.</p>
|
||||||
|
|
||||||
<H2><a name="Ruby_nn2"></a>38.1 Preliminaries</H2>
|
<H2><a name="Ruby_nn2">38.1 Preliminaries</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p> SWIG 3.0 is known to work with Ruby versions 1.8 and later.
|
<p> SWIG 3.0 is known to work with Ruby versions 1.8 and later.
|
||||||
|
|
@ -159,7 +164,7 @@ read the "<a href="SWIG.html#SWIG">SWIG Basics</a>"
|
||||||
chapter. It is also assumed that the reader has a basic understanding
|
chapter. It is also assumed that the reader has a basic understanding
|
||||||
of Ruby. </p>
|
of Ruby. </p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn3"></a>38.1.1 Running SWIG</H3>
|
<H3><a name="Ruby_nn3">38.1.1 Running SWIG</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> To build a Ruby module, run SWIG using the <tt>-ruby</tt>
|
<p> To build a Ruby module, run SWIG using the <tt>-ruby</tt>
|
||||||
|
|
@ -183,7 +188,7 @@ if compiling a C++ extension) that contains all of the code needed to
|
||||||
build a Ruby extension module. To finish building the module, you need
|
build a Ruby extension module. To finish building the module, you need
|
||||||
to compile this file and link it with the rest of your program. </p>
|
to compile this file and link it with the rest of your program. </p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn4"></a>38.1.2 Getting the right header files</H3>
|
<H3><a name="Ruby_nn4">38.1.2 Getting the right header files</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> In order to compile the wrapper code, the compiler needs the <tt>ruby.h</tt>
|
<p> In order to compile the wrapper code, the compiler needs the <tt>ruby.h</tt>
|
||||||
|
|
@ -212,7 +217,7 @@ installed, you can run Ruby to find out. For example: </p>
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn5"></a>38.1.3 Compiling a dynamic module</H3>
|
<H3><a name="Ruby_nn5">38.1.3 Compiling a dynamic module</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> Ruby extension modules are typically compiled into shared
|
<p> Ruby extension modules are typically compiled into shared
|
||||||
|
|
@ -285,7 +290,7 @@ manual pages for your compiler and linker to determine the correct set
|
||||||
of options. You might also check the <a href="http://www.dabeaz.com/cgi-bin/wiki.pl">SWIG Wiki</a>
|
of options. You might also check the <a href="http://www.dabeaz.com/cgi-bin/wiki.pl">SWIG Wiki</a>
|
||||||
for additional information. </p>
|
for additional information. </p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn6"></a>38.1.4 Using your module</H3>
|
<H3><a name="Ruby_nn6">38.1.4 Using your module</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> Ruby <i>module</i> names must be capitalized,
|
<p> Ruby <i>module</i> names must be capitalized,
|
||||||
|
|
@ -315,7 +320,7 @@ begins with: </p>
|
||||||
<p> will result in an extension module using the feature name
|
<p> will result in an extension module using the feature name
|
||||||
"example" and Ruby module name "Example". </p>
|
"example" and Ruby module name "Example". </p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn7"></a>38.1.5 Static linking</H3>
|
<H3><a name="Ruby_nn7">38.1.5 Static linking</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> An alternative approach to dynamic linking is to rebuild the
|
<p> An alternative approach to dynamic linking is to rebuild the
|
||||||
|
|
@ -330,7 +335,7 @@ finding the Ruby source, adding an entry to the <tt>ext/Setup</tt>
|
||||||
file, adding your directory to the list of extensions in the file, and
|
file, adding your directory to the list of extensions in the file, and
|
||||||
finally rebuilding Ruby. </p>
|
finally rebuilding Ruby. </p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn8"></a>38.1.6 Compilation of C++ extensions</H3>
|
<H3><a name="Ruby_nn8">38.1.6 Compilation of C++ extensions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> On most machines, C++ extension modules should be linked
|
<p> On most machines, C++ extension modules should be linked
|
||||||
|
|
@ -362,7 +367,7 @@ $libs = append_library($libs, "supc++")
|
||||||
create_makefile('example')</pre>
|
create_makefile('example')</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H2><a name="Ruby_nn9"></a>38.2 Building Ruby Extensions under Windows 95/NT</H2>
|
<H2><a name="Ruby_nn9">38.2 Building Ruby Extensions under Windows 95/NT</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p> Building a SWIG extension to Ruby under Windows 95/NT is
|
<p> Building a SWIG extension to Ruby under Windows 95/NT is
|
||||||
|
|
@ -387,7 +392,7 @@ order to build extensions, you may need to download the source
|
||||||
distribution to the Ruby package, as you will need the Ruby header
|
distribution to the Ruby package, as you will need the Ruby header
|
||||||
files. </p>
|
files. </p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn10"></a>38.2.1 Running SWIG from Developer Studio</H3>
|
<H3><a name="Ruby_nn10">38.2.1 Running SWIG from Developer Studio</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> If you are developing your application within Microsoft
|
<p> If you are developing your application within Microsoft
|
||||||
|
|
@ -451,13 +456,13 @@ Foo = 3.0
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H2><a name="Ruby_nn11"></a>38.3 The Ruby-to-C/C++ Mapping</H2>
|
<H2><a name="Ruby_nn11">38.3 The Ruby-to-C/C++ Mapping</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p> This section describes the basics of how SWIG maps C or C++
|
<p> This section describes the basics of how SWIG maps C or C++
|
||||||
declarations in your SWIG interface files to Ruby constructs. </p>
|
declarations in your SWIG interface files to Ruby constructs. </p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn12"></a>38.3.1 Modules</H3>
|
<H3><a name="Ruby_nn12">38.3.1 Modules</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> The SWIG <tt>%module</tt> directive specifies
|
<p> The SWIG <tt>%module</tt> directive specifies
|
||||||
|
|
@ -529,7 +534,7 @@ option to wrap everything into the global module, take care that the
|
||||||
names of your constants, classes and methods don't conflict with any of
|
names of your constants, classes and methods don't conflict with any of
|
||||||
Ruby's built-in names. </p>
|
Ruby's built-in names. </p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn13"></a>38.3.2 Functions</H3>
|
<H3><a name="Ruby_nn13">38.3.2 Functions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> Global functions are wrapped as Ruby module methods. For
|
<p> Global functions are wrapped as Ruby module methods. For
|
||||||
|
|
@ -563,7 +568,7 @@ irb(main):002:0> <b>Example.fact(4)</b>
|
||||||
24</pre>
|
24</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn14"></a>38.3.3 Variable Linking</H3>
|
<H3><a name="Ruby_nn14">38.3.3 Variable Linking</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> C/C++ global variables are wrapped as a pair of singleton
|
<p> C/C++ global variables are wrapped as a pair of singleton
|
||||||
|
|
@ -625,7 +630,7 @@ directive. For example: </p>
|
||||||
effect until it is explicitly disabled using <tt>%mutable</tt>.
|
effect until it is explicitly disabled using <tt>%mutable</tt>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn15"></a>38.3.4 Constants</H3>
|
<H3><a name="Ruby_nn15">38.3.4 Constants</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> C/C++ constants are wrapped as module constants initialized
|
<p> C/C++ constants are wrapped as module constants initialized
|
||||||
|
|
@ -653,7 +658,7 @@ irb(main):002:0> <b>Example::PI</b>
|
||||||
3.14159</pre>
|
3.14159</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn16"></a>38.3.5 Pointers</H3>
|
<H3><a name="Ruby_nn16">38.3.5 Pointers</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> "Opaque" pointers to arbitrary C/C++ types (i.e. types that
|
<p> "Opaque" pointers to arbitrary C/C++ types (i.e. types that
|
||||||
|
|
@ -677,7 +682,7 @@ returns an instance of an internally generated Ruby class: </p>
|
||||||
<p> A <tt>NULL</tt> pointer is always represented by
|
<p> A <tt>NULL</tt> pointer is always represented by
|
||||||
the Ruby <tt>nil</tt> object. </p>
|
the Ruby <tt>nil</tt> object. </p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn17"></a>38.3.6 Structures</H3>
|
<H3><a name="Ruby_nn17">38.3.6 Structures</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> C/C++ structs are wrapped as Ruby classes, with accessor
|
<p> C/C++ structs are wrapped as Ruby classes, with accessor
|
||||||
|
|
@ -782,7 +787,7 @@ void Bar_f_set(Bar *b, Foo *val) {
|
||||||
}</pre>
|
}</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn18"></a>38.3.7 C++ classes</H3>
|
<H3><a name="Ruby_nn18">38.3.7 C++ classes</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> Like structs, C++ classes are wrapped by creating a new Ruby
|
<p> Like structs, C++ classes are wrapped by creating a new Ruby
|
||||||
|
|
@ -837,7 +842,7 @@ Ale
|
||||||
3</pre>
|
3</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn19"></a>38.3.8 C++ Inheritance</H3>
|
<H3><a name="Ruby_nn19">38.3.8 C++ Inheritance</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> The SWIG type-checker is fully aware of C++ inheritance.
|
<p> The SWIG type-checker is fully aware of C++ inheritance.
|
||||||
|
|
@ -990,7 +995,7 @@ inherit from both <tt>Base1</tt> and <tt>Base2</tt>
|
||||||
(i.e. they exhibit <a href="http://c2.com/cgi/wiki?DuckTyping">"Duck
|
(i.e. they exhibit <a href="http://c2.com/cgi/wiki?DuckTyping">"Duck
|
||||||
Typing"</a>). </p>
|
Typing"</a>). </p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn20"></a>38.3.9 C++ Overloaded Functions</H3>
|
<H3><a name="Ruby_nn20">38.3.9 C++ Overloaded Functions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> C++ overloaded functions, methods, and constructors are
|
<p> C++ overloaded functions, methods, and constructors are
|
||||||
|
|
@ -1080,7 +1085,7 @@ arises--in this case, the first declaration takes precedence. </p>
|
||||||
<p>Please refer to the <a href="SWIGPlus.html#SWIGPlus">"SWIG
|
<p>Please refer to the <a href="SWIGPlus.html#SWIGPlus">"SWIG
|
||||||
and C++"</a> chapter for more information about overloading. </p>
|
and C++"</a> chapter for more information about overloading. </p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn21"></a>38.3.10 C++ Operators</H3>
|
<H3><a name="Ruby_nn21">38.3.10 C++ Operators</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> For the most part, overloaded operators are handled
|
<p> For the most part, overloaded operators are handled
|
||||||
|
|
@ -1122,7 +1127,7 @@ c = Example.add_complex(a, b)</pre>
|
||||||
is discussed in the <a href="#Ruby_operator_overloading">section
|
is discussed in the <a href="#Ruby_operator_overloading">section
|
||||||
on operator overloading</a>. </p>
|
on operator overloading</a>. </p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn22"></a>38.3.11 C++ namespaces</H3>
|
<H3><a name="Ruby_nn22">38.3.11 C++ namespaces</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> SWIG is aware of C++ namespaces, but namespace names do not
|
<p> SWIG is aware of C++ namespaces, but namespace names do not
|
||||||
|
|
@ -1179,7 +1184,7 @@ and create extension modules for each namespace separately. If your
|
||||||
program utilizes thousands of small deeply nested namespaces each with
|
program utilizes thousands of small deeply nested namespaces each with
|
||||||
identical symbol names, well, then you get what you deserve. </p>
|
identical symbol names, well, then you get what you deserve. </p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn23"></a>38.3.12 C++ templates</H3>
|
<H3><a name="Ruby_nn23">38.3.12 C++ templates</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> C++ templates don't present a huge problem for SWIG. However,
|
<p> C++ templates don't present a huge problem for SWIG. However,
|
||||||
|
|
@ -1221,7 +1226,7 @@ irb(main):004:0> <b>p.second</b>
|
||||||
4</pre>
|
4</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn23_1"></a>38.3.13 C++ Standard Template Library (STL)</H3>
|
<H3><a name="Ruby_nn23_1">38.3.13 C++ Standard Template Library (STL)</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> On a related note, the standard SWIG library contains a
|
<p> On a related note, the standard SWIG library contains a
|
||||||
|
|
@ -1314,7 +1319,7 @@ puts v
|
||||||
shown in these examples. More details can be found in the <a href="SWIGPlus.html#SWIGPlus">SWIG and C++</a>
|
shown in these examples. More details can be found in the <a href="SWIGPlus.html#SWIGPlus">SWIG and C++</a>
|
||||||
chapter.</p>
|
chapter.</p>
|
||||||
|
|
||||||
<H3><a name="Ruby_C_STL_Functors"></a>38.3.14 C++ STL Functors</H3>
|
<H3><a name="Ruby_C_STL_Functors">38.3.14 C++ STL Functors</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>Some containers in the STL allow you to modify their default
|
<p>Some containers in the STL allow you to modify their default
|
||||||
|
|
@ -1347,7 +1352,7 @@ are provided.</p>
|
||||||
|
|
||||||
%include <std_set.i>
|
%include <std_set.i>
|
||||||
|
|
||||||
%typemap(IntSet) std::set< int, swig::BinaryPredicate >;
|
%template(IntSet) std::set< int, swig::BinaryPredicate >;
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<p>You can then use the set from Ruby with or without a proc
|
<p>You can then use the set from Ruby with or without a proc
|
||||||
|
|
@ -1375,7 +1380,7 @@ b
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Ruby_C_Iterators"></a>38.3.15 C++ STL Iterators</H3>
|
<H3><a name="Ruby_C_Iterators">38.3.15 C++ STL Iterators</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>The STL is well known for the use of iterators. There
|
<p>The STL is well known for the use of iterators. There
|
||||||
|
|
@ -1458,7 +1463,21 @@ i
|
||||||
|
|
||||||
<p>If you'd rather have STL classes without any iterators, you should define <tt>-DSWIG_NO_EXPORT_ITERATOR_METHODS</tt> when running swig.</p>
|
<p>If you'd rather have STL classes without any iterators, you should define <tt>-DSWIG_NO_EXPORT_ITERATOR_METHODS</tt> when running swig.</p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn24"></a>38.3.16 C++ Smart Pointers</H3>
|
<H3><a name="Ruby_nn24">38.3.16 C++ Smart Pointers</a></H3>
|
||||||
|
|
||||||
|
|
||||||
|
<H4><a name="Ruby_smart_pointers_shared_ptr">38.3.16.1 The shared_ptr Smart Pointer</a></H4>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The C++11 standard provides <tt>std::shared_ptr</tt> which was derived from the Boost
|
||||||
|
implementation, <tt>boost::shared_ptr</tt>.
|
||||||
|
Both of these are available for Ruby in the SWIG library and usage is outlined
|
||||||
|
in the <a href="Library.html#Library_std_shared_ptr">shared_ptr smart pointer</a> library section.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<H4><a name="Ruby_smart_pointers_generic">38.3.16.2 Generic Smart Pointers</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p> In certain C++ programs, it is common to use classes that
|
<p> In certain C++ programs, it is common to use classes that
|
||||||
|
|
@ -1523,7 +1542,7 @@ method. For example: </p>
|
||||||
<pre>irb(main):004:0> <b>f = p.__deref__()</b> # Returns underlying Foo *</pre>
|
<pre>irb(main):004:0> <b>f = p.__deref__()</b> # Returns underlying Foo *</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn25"></a>38.3.17 Cross-Language Polymorphism</H3>
|
<H3><a name="Ruby_nn25">38.3.17 Cross-Language Polymorphism</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> SWIG's Ruby module supports cross-language polymorphism
|
<p> SWIG's Ruby module supports cross-language polymorphism
|
||||||
|
|
@ -1532,7 +1551,7 @@ module. Rather than duplicate the information presented in the <a href="Python.h
|
||||||
section just notes the differences that you need to be aware of when
|
section just notes the differences that you need to be aware of when
|
||||||
using this feature with Ruby. </p>
|
using this feature with Ruby. </p>
|
||||||
|
|
||||||
<H4><a name="Ruby_nn26"></a>38.3.17.1 Exception Unrolling</H4>
|
<H4><a name="Ruby_nn26">38.3.17.1 Exception Unrolling</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p> Whenever a C++ director class routes one of its virtual
|
<p> Whenever a C++ director class routes one of its virtual
|
||||||
|
|
@ -1555,7 +1574,7 @@ method is "wrapped" using the <tt>rb_rescue2()</tt>
|
||||||
function from Ruby's C API. If any Ruby exception is raised, it will be
|
function from Ruby's C API. If any Ruby exception is raised, it will be
|
||||||
caught here and a C++ exception is raised in its place. </p>
|
caught here and a C++ exception is raised in its place. </p>
|
||||||
|
|
||||||
<H2><a name="Ruby_nn27"></a>38.4 Naming</H2>
|
<H2><a name="Ruby_nn27">38.4 Naming</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>Ruby has several common naming conventions. Constants are
|
<p>Ruby has several common naming conventions. Constants are
|
||||||
|
|
@ -1593,7 +1612,7 @@ generated
|
||||||
by SWIG, it is turned off by default in SWIG 1.3.28. However, it is
|
by SWIG, it is turned off by default in SWIG 1.3.28. However, it is
|
||||||
planned to become the default option in future releases.</p>
|
planned to become the default option in future releases.</p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn28"></a>38.4.1 Defining Aliases</H3>
|
<H3><a name="Ruby_nn28">38.4.1 Defining Aliases</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> It's a fairly common practice in the Ruby built-ins and
|
<p> It's a fairly common practice in the Ruby built-ins and
|
||||||
|
|
@ -1663,7 +1682,7 @@ matching rules used for other kinds of features apply (see the chapter
|
||||||
on <a href="Customization.html#Customization">"Customization
|
on <a href="Customization.html#Customization">"Customization
|
||||||
Features"</a>) for more details).</p>
|
Features"</a>) for more details).</p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn29"></a>38.4.2 Predicate Methods</H3>
|
<H3><a name="Ruby_nn29">38.4.2 Predicate Methods</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> Ruby methods that return a boolean value and end in a
|
<p> Ruby methods that return a boolean value and end in a
|
||||||
|
|
@ -1712,7 +1731,7 @@ using SWIG's "features" mechanism and so the same name matching rules
|
||||||
used for other kinds of features apply (see the chapter on <a href="Customization.html#Customization">"Customization
|
used for other kinds of features apply (see the chapter on <a href="Customization.html#Customization">"Customization
|
||||||
Features"</a>) for more details). </p>
|
Features"</a>) for more details). </p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn30"></a>38.4.3 Bang Methods</H3>
|
<H3><a name="Ruby_nn30">38.4.3 Bang Methods</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> Ruby methods that modify an object in-place and end in an
|
<p> Ruby methods that modify an object in-place and end in an
|
||||||
|
|
@ -1744,7 +1763,7 @@ using SWIG's "features" mechanism and so the same name matching rules
|
||||||
used for other kinds of features apply (see the chapter on <a href="Customization.html#Customization">"Customization
|
used for other kinds of features apply (see the chapter on <a href="Customization.html#Customization">"Customization
|
||||||
Features"</a>) for more details). </p>
|
Features"</a>) for more details). </p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn31"></a>38.4.4 Getters and Setters</H3>
|
<H3><a name="Ruby_nn31">38.4.4 Getters and Setters</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> Often times a C++ library will expose properties through
|
<p> Often times a C++ library will expose properties through
|
||||||
|
|
@ -1779,7 +1798,7 @@ irb(main):003:0> <b>puts foo.value</b></pre>
|
||||||
%rename("value=") Foo::setValue(int value);</pre>
|
%rename("value=") Foo::setValue(int value);</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H2><a name="Ruby_nn32"></a>38.5 Input and output parameters</H2>
|
<H2><a name="Ruby_nn32">38.5 Input and output parameters</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p> A common problem in some C programs is handling parameters
|
<p> A common problem in some C programs is handling parameters
|
||||||
|
|
@ -1918,10 +1937,10 @@ void get_dimensions(Matrix *m, int *rows, int*columns);</pre>
|
||||||
<pre>r, c = Example.get_dimensions(m)</pre>
|
<pre>r, c = Example.get_dimensions(m)</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H2><a name="Ruby_nn33"></a>38.6 Exception handling </H2>
|
<H2><a name="Ruby_nn33">38.6 Exception handling </a></H2>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Ruby_nn34"></a>38.6.1 Using the %exception directive </H3>
|
<H3><a name="Ruby_nn34">38.6.1 Using the %exception directive </a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>The SWIG <tt>%exception</tt> directive can be
|
<p>The SWIG <tt>%exception</tt> directive can be
|
||||||
|
|
@ -2030,7 +2049,7 @@ methods and functions named <tt>getitem</tt> and <tt>setitem</tt>.
|
||||||
limited to C++ exception handling. See the chapter on <a href="Customization.html#Customization">Customization
|
limited to C++ exception handling. See the chapter on <a href="Customization.html#Customization">Customization
|
||||||
Features</a> for more examples.</p>
|
Features</a> for more examples.</p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn34_2"></a>38.6.2 Handling Ruby Blocks </H3>
|
<H3><a name="Ruby_nn34_2">38.6.2 Handling Ruby Blocks </a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>One of the highlights of Ruby and most of its standard library
|
<p>One of the highlights of Ruby and most of its standard library
|
||||||
|
|
@ -2097,7 +2116,7 @@ a special in typemap, like:</p>
|
||||||
|
|
||||||
<p>For more information on typemaps, see <a href="#Ruby_nn37">Typemaps</a>.</p>
|
<p>For more information on typemaps, see <a href="#Ruby_nn37">Typemaps</a>.</p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn35"></a>38.6.3 Raising exceptions </H3>
|
<H3><a name="Ruby_nn35">38.6.3 Raising exceptions </a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>There are three ways to raise exceptions from C++ code to
|
<p>There are three ways to raise exceptions from C++ code to
|
||||||
|
|
@ -2254,7 +2273,7 @@ function. The first argument passed to <tt>rb_raise()</tt>
|
||||||
is the exception type. You can raise a custom exception type or one of
|
is the exception type. You can raise a custom exception type or one of
|
||||||
the built-in Ruby exception types.</p>
|
the built-in Ruby exception types.</p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn36"></a>38.6.4 Exception classes </H3>
|
<H3><a name="Ruby_nn36">38.6.4 Exception classes </a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>Starting with SWIG 1.3.28, the Ruby module supports the <tt>%exceptionclass</tt>
|
<p>Starting with SWIG 1.3.28, the Ruby module supports the <tt>%exceptionclass</tt>
|
||||||
|
|
@ -2291,7 +2310,7 @@ end </pre>
|
||||||
<p>For another example look at swig/Examples/ruby/exception_class.
|
<p>For another example look at swig/Examples/ruby/exception_class.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Ruby_nn37"></a>38.7 Typemaps</H2>
|
<H2><a name="Ruby_nn37">38.7 Typemaps</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p> This section describes how you can modify SWIG's default
|
<p> This section describes how you can modify SWIG's default
|
||||||
|
|
@ -2306,7 +2325,7 @@ a required part of using SWIG---the default wrapping behavior is enough
|
||||||
in most cases. Typemaps are only used if you want to change some aspect
|
in most cases. Typemaps are only used if you want to change some aspect
|
||||||
of the primitive C-Ruby interface.</p>
|
of the primitive C-Ruby interface.</p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn38"></a>38.7.1 What is a typemap?</H3>
|
<H3><a name="Ruby_nn38">38.7.1 What is a typemap?</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> A typemap is nothing more than a code generation rule that is
|
<p> A typemap is nothing more than a code generation rule that is
|
||||||
|
|
@ -2463,7 +2482,7 @@ to be used as follows (notice how the length parameter is omitted): </p>
|
||||||
2</pre>
|
2</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Ruby_Typemap_scope"></a>38.7.2 Typemap scope</H3>
|
<H3><a name="Ruby_Typemap_scope">38.7.2 Typemap scope</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> Once defined, a typemap remains in effect for all of the
|
<p> Once defined, a typemap remains in effect for all of the
|
||||||
|
|
@ -2509,7 +2528,7 @@ where the class itself is defined. For example:</p>
|
||||||
};</pre>
|
};</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Ruby_Copying_a_typemap"></a>38.7.3 Copying a typemap</H3>
|
<H3><a name="Ruby_Copying_a_typemap">38.7.3 Copying a typemap</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> A typemap is copied by using assignment. For example:</p>
|
<p> A typemap is copied by using assignment. For example:</p>
|
||||||
|
|
@ -2551,7 +2570,7 @@ rules as for <tt>
|
||||||
%apply (char *buf, int len) { (char *buffer, int size) }; // Multiple arguments</pre>
|
%apply (char *buf, int len) { (char *buffer, int size) }; // Multiple arguments</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Ruby_Deleting_a_typemap"></a>38.7.4 Deleting a typemap</H3>
|
<H3><a name="Ruby_Deleting_a_typemap">38.7.4 Deleting a typemap</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> A typemap can be deleted by simply defining no code. For
|
<p> A typemap can be deleted by simply defining no code. For
|
||||||
|
|
@ -2576,7 +2595,7 @@ defined by typemaps, clearing a fundamental type like <tt>int</tt>
|
||||||
will make that type unusable unless you also define a new set of
|
will make that type unusable unless you also define a new set of
|
||||||
typemaps immediately after the clear operation.</p>
|
typemaps immediately after the clear operation.</p>
|
||||||
|
|
||||||
<H3><a name="Ruby_Placement_of_typemaps"></a>38.7.5 Placement of typemaps</H3>
|
<H3><a name="Ruby_Placement_of_typemaps">38.7.5 Placement of typemaps</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> Typemap declarations can be declared in the global scope,
|
<p> Typemap declarations can be declared in the global scope,
|
||||||
|
|
@ -2647,13 +2666,13 @@ In this example, this is done using the class declaration <tt>class
|
||||||
string</tt>
|
string</tt>
|
||||||
.</p>
|
.</p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn39"></a>38.7.6 Ruby typemaps</H3>
|
<H3><a name="Ruby_nn39">38.7.6 Ruby typemaps</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>The following list details all of the typemap methods that
|
<p>The following list details all of the typemap methods that
|
||||||
can be used by the Ruby module: </p>
|
can be used by the Ruby module: </p>
|
||||||
|
|
||||||
<H4><a name="Ruby_in_typemap"></a>38.7.6.1 "in" typemap</H4>
|
<H4><a name="Ruby_in_typemap">38.7.6.1 "in" typemap</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>Converts Ruby objects to input
|
<p>Converts Ruby objects to input
|
||||||
|
|
@ -2720,7 +2739,7 @@ arguments to be specified. For example:</p>
|
||||||
|
|
||||||
<p> At this time, only zero or one arguments may be converted.</p>
|
<p> At this time, only zero or one arguments may be converted.</p>
|
||||||
|
|
||||||
<H4><a name="Ruby_typecheck_typemap"></a>38.7.6.2 "typecheck" typemap</H4>
|
<H4><a name="Ruby_typecheck_typemap">38.7.6.2 "typecheck" typemap</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p> The "typecheck" typemap is used to support overloaded
|
<p> The "typecheck" typemap is used to support overloaded
|
||||||
|
|
@ -2742,7 +2761,7 @@ program uses overloaded methods, you should also define a collection of
|
||||||
"typecheck" typemaps. More details about this follow in a later section
|
"typecheck" typemaps. More details about this follow in a later section
|
||||||
on "Typemaps and Overloading."</p>
|
on "Typemaps and Overloading."</p>
|
||||||
|
|
||||||
<H4><a name="Ruby_out_typemap"></a>38.7.6.3 "out" typemap</H4>
|
<H4><a name="Ruby_out_typemap">38.7.6.3 "out" typemap</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>Converts return value of a C function
|
<p>Converts return value of a C function
|
||||||
|
|
@ -2793,7 +2812,7 @@ version of the C datatype matched by the typemap.</td>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H4><a name="Ruby_arginit_typemap"></a>38.7.6.4 "arginit" typemap</H4>
|
<H4><a name="Ruby_arginit_typemap">38.7.6.4 "arginit" typemap</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p> The "arginit" typemap is used to set the initial value of a
|
<p> The "arginit" typemap is used to set the initial value of a
|
||||||
|
|
@ -2808,7 +2827,7 @@ applications. For example:</p>
|
||||||
}</pre>
|
}</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H4><a name="Ruby_default_typemap"></a>38.7.6.5 "default" typemap</H4>
|
<H4><a name="Ruby_default_typemap">38.7.6.5 "default" typemap</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p> The "default" typemap is used to turn an argument into a
|
<p> The "default" typemap is used to turn an argument into a
|
||||||
|
|
@ -2833,7 +2852,7 @@ arguments that follow must have default values. See the <a href="SWIG.html#SWIG_
|
||||||
Default/optional arguments</a> section for further information on
|
Default/optional arguments</a> section for further information on
|
||||||
default argument wrapping.</p>
|
default argument wrapping.</p>
|
||||||
|
|
||||||
<H4><a name="Ruby_check_typemap"></a>38.7.6.6 "check" typemap</H4>
|
<H4><a name="Ruby_check_typemap">38.7.6.6 "check" typemap</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p> The "check" typemap is used to supply value checking code
|
<p> The "check" typemap is used to supply value checking code
|
||||||
|
|
@ -2848,7 +2867,7 @@ arguments have been converted. For example:</p>
|
||||||
}</pre>
|
}</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H4><a name="Ruby_argout_typemap_"></a>38.7.6.7 "argout" typemap</H4>
|
<H4><a name="Ruby_argout_typemap_">38.7.6.7 "argout" typemap</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p> The "argout" typemap is used to return values from arguments.
|
<p> The "argout" typemap is used to return values from arguments.
|
||||||
|
|
@ -2902,7 +2921,7 @@ some function like SWIG_Ruby_AppendOutput.</p>
|
||||||
|
|
||||||
<p> See the <tt>typemaps.i</tt> library for examples.</p>
|
<p> See the <tt>typemaps.i</tt> library for examples.</p>
|
||||||
|
|
||||||
<H4><a name="Ruby_freearg_typemap_"></a>38.7.6.8 "freearg" typemap</H4>
|
<H4><a name="Ruby_freearg_typemap_">38.7.6.8 "freearg" typemap</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p> The "freearg" typemap is used to cleanup argument data. It is
|
<p> The "freearg" typemap is used to cleanup argument data. It is
|
||||||
|
|
@ -2929,7 +2948,7 @@ This code is also placed into a special variable <tt>$cleanup</tt>
|
||||||
that may be used in other typemaps whenever a wrapper function needs to
|
that may be used in other typemaps whenever a wrapper function needs to
|
||||||
abort prematurely.</p>
|
abort prematurely.</p>
|
||||||
|
|
||||||
<H4><a name="Ruby_newfree_typemap"></a>38.7.6.9 "newfree" typemap</H4>
|
<H4><a name="Ruby_newfree_typemap">38.7.6.9 "newfree" typemap</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p> The "newfree" typemap is used in conjunction with the <tt>%newobject</tt>
|
<p> The "newfree" typemap is used in conjunction with the <tt>%newobject</tt>
|
||||||
|
|
@ -2953,7 +2972,7 @@ string *foo();</pre>
|
||||||
<p> See <a href="Customization.html#Customization_ownership">Object
|
<p> See <a href="Customization.html#Customization_ownership">Object
|
||||||
ownership and %newobject</a> for further details.</p>
|
ownership and %newobject</a> for further details.</p>
|
||||||
|
|
||||||
<H4><a name="Ruby_memberin_typemap"></a>38.7.6.10 "memberin" typemap</H4>
|
<H4><a name="Ruby_memberin_typemap">38.7.6.10 "memberin" typemap</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p> The "memberin" typemap is used to copy data from<em> an
|
<p> The "memberin" typemap is used to copy data from<em> an
|
||||||
|
|
@ -2971,21 +2990,21 @@ example:</p>
|
||||||
already provides a default implementation for arrays, strings, and
|
already provides a default implementation for arrays, strings, and
|
||||||
other objects.</p>
|
other objects.</p>
|
||||||
|
|
||||||
<H4><a name="Ruby_varin_typemap"></a>38.7.6.11 "varin" typemap</H4>
|
<H4><a name="Ruby_varin_typemap">38.7.6.11 "varin" typemap</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p> The "varin" typemap is used to convert objects in the target
|
<p> The "varin" typemap is used to convert objects in the target
|
||||||
language to C for the purposes of assigning to a C/C++ global variable.
|
language to C for the purposes of assigning to a C/C++ global variable.
|
||||||
This is implementation specific.</p>
|
This is implementation specific.</p>
|
||||||
|
|
||||||
<H4><a name="Ruby_varout_typemap_"></a>38.7.6.12 "varout" typemap</H4>
|
<H4><a name="Ruby_varout_typemap_">38.7.6.12 "varout" typemap</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p> The "varout" typemap is used to convert a C/C++ object to an
|
<p> The "varout" typemap is used to convert a C/C++ object to an
|
||||||
object in the target language when reading a C/C++ global variable.
|
object in the target language when reading a C/C++ global variable.
|
||||||
This is implementation specific.</p>
|
This is implementation specific.</p>
|
||||||
|
|
||||||
<H4><a name="Ruby_throws_typemap"></a>38.7.6.13 "throws" typemap</H4>
|
<H4><a name="Ruby_throws_typemap">38.7.6.13 "throws" typemap</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p> The "throws" typemap is only used when SWIG parses a C++
|
<p> The "throws" typemap is only used when SWIG parses a C++
|
||||||
|
|
@ -3026,7 +3045,7 @@ specification yet they do throw exceptions, SWIG cannot know how to
|
||||||
deal with them. For a neat way to handle these, see the <a href="Customization.html#Customization_exception">Exception
|
deal with them. For a neat way to handle these, see the <a href="Customization.html#Customization_exception">Exception
|
||||||
handling with %exception</a> section.</p>
|
handling with %exception</a> section.</p>
|
||||||
|
|
||||||
<H4><a name="Ruby_directorin_typemap"></a>38.7.6.14 directorin typemap</H4>
|
<H4><a name="Ruby_directorin_typemap">38.7.6.14 directorin typemap</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>Converts C++ objects in director
|
<p>Converts C++ objects in director
|
||||||
|
|
@ -3085,7 +3104,7 @@ referring to the class itself.</td>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H4><a name="Ruby_directorout_typemap"></a>38.7.6.15 directorout typemap</H4>
|
<H4><a name="Ruby_directorout_typemap">38.7.6.15 directorout typemap</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>Converts Ruby objects in director
|
<p>Converts Ruby objects in director
|
||||||
|
|
@ -3158,7 +3177,7 @@ exception.
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H4><a name="Ruby_directorargout_typemap"></a>38.7.6.16 directorargout typemap</H4>
|
<H4><a name="Ruby_directorargout_typemap">38.7.6.16 directorargout typemap</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>Output argument processing in director
|
<p>Output argument processing in director
|
||||||
|
|
@ -3216,19 +3235,19 @@ referring to the instance of the class itself</td>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H4><a name="Ruby_ret_typemap"></a>38.7.6.17 ret typemap</H4>
|
<H4><a name="Ruby_ret_typemap">38.7.6.17 ret typemap</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>Cleanup of function return values
|
<p>Cleanup of function return values
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H4><a name="Ruby_globalin_typemap"></a>38.7.6.18 globalin typemap</H4>
|
<H4><a name="Ruby_globalin_typemap">38.7.6.18 globalin typemap</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>Setting of C global variables
|
<p>Setting of C global variables
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn40"></a>38.7.7 Typemap variables</H3>
|
<H3><a name="Ruby_nn40">38.7.7 Typemap variables</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3278,7 +3297,7 @@ so that their values can be properly assigned. </div>
|
||||||
<div class="indent">The Ruby name of the wrapper function
|
<div class="indent">The Ruby name of the wrapper function
|
||||||
being created. </div>
|
being created. </div>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn41"></a>38.7.8 Useful Functions</H3>
|
<H3><a name="Ruby_nn41">38.7.8 Useful Functions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> When you write a typemap, you usually have to work directly
|
<p> When you write a typemap, you usually have to work directly
|
||||||
|
|
@ -3293,7 +3312,7 @@ stick to the swig functions instead of the native Ruby functions.
|
||||||
That should help you avoid having to rewrite a lot of typemaps
|
That should help you avoid having to rewrite a lot of typemaps
|
||||||
across multiple languages.</p>
|
across multiple languages.</p>
|
||||||
|
|
||||||
<H4><a name="Ruby_nn42"></a>38.7.8.1 C Datatypes to Ruby Objects</H4>
|
<H4><a name="Ruby_nn42">38.7.8.1 C Datatypes to Ruby Objects</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<div class="diagram">
|
<div class="diagram">
|
||||||
|
|
@ -3335,7 +3354,7 @@ SWIG_From_float(float)</td>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H4><a name="Ruby_nn43"></a>38.7.8.2 Ruby Objects to C Datatypes</H4>
|
<H4><a name="Ruby_nn43">38.7.8.2 Ruby Objects to C Datatypes</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>Here, while the Ruby versions return the value directly, the SWIG
|
<p>Here, while the Ruby versions return the value directly, the SWIG
|
||||||
|
|
@ -3403,7 +3422,7 @@ versions do not, but return a status value to indicate success (<tt>SWIG_OK</tt>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H4><a name="Ruby_nn44"></a>38.7.8.3 Macros for VALUE</H4>
|
<H4><a name="Ruby_nn44">38.7.8.3 Macros for VALUE</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p> <tt>RSTRING_LEN(str)</tt> </p>
|
<p> <tt>RSTRING_LEN(str)</tt> </p>
|
||||||
|
|
@ -3426,7 +3445,7 @@ versions do not, but return a status value to indicate success (<tt>SWIG_OK</tt>
|
||||||
|
|
||||||
<div class="indent">pointer to array storage</div>
|
<div class="indent">pointer to array storage</div>
|
||||||
|
|
||||||
<H4><a name="Ruby_nn45"></a>38.7.8.4 Exceptions</H4>
|
<H4><a name="Ruby_nn45">38.7.8.4 Exceptions</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p> <tt>void rb_raise(VALUE exception, const char *fmt,
|
<p> <tt>void rb_raise(VALUE exception, const char *fmt,
|
||||||
|
|
@ -3505,7 +3524,7 @@ message to standard error if Ruby was invoked with the <tt>-w</tt>
|
||||||
flag. The given format string <i>fmt</i> and remaining
|
flag. The given format string <i>fmt</i> and remaining
|
||||||
arguments are interpreted as with <tt>printf()</tt>. </div>
|
arguments are interpreted as with <tt>printf()</tt>. </div>
|
||||||
|
|
||||||
<H4><a name="Ruby_nn46"></a>38.7.8.5 Iterators</H4>
|
<H4><a name="Ruby_nn46">38.7.8.5 Iterators</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p> <tt>void rb_iter_break()</tt> </p>
|
<p> <tt>void rb_iter_break()</tt> </p>
|
||||||
|
|
@ -3551,14 +3570,14 @@ VALUE), VALUE value)</tt></p>
|
||||||
<div class="indent"> Equivalent to Ruby's <tt>throw</tt>.
|
<div class="indent"> Equivalent to Ruby's <tt>throw</tt>.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn47"></a>38.7.9 Typemap Examples</H3>
|
<H3><a name="Ruby_nn47">38.7.9 Typemap Examples</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> This section includes a few examples of typemaps. For more
|
<p> This section includes a few examples of typemaps. For more
|
||||||
examples, you might look at the examples in the <tt>Example/ruby</tt>
|
examples, you might look at the examples in the <tt>Example/ruby</tt>
|
||||||
directory. </p>
|
directory. </p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn48"></a>38.7.10 Converting a Ruby array to a char **</H3>
|
<H3><a name="Ruby_nn48">38.7.10 Converting a Ruby array to a char **</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> A common problem in many C programs is the processing of
|
<p> A common problem in many C programs is the processing of
|
||||||
|
|
@ -3623,7 +3642,7 @@ array. Since dynamic memory allocation is used to allocate memory for
|
||||||
the array, the "freearg" typemap is used to later release this memory
|
the array, the "freearg" typemap is used to later release this memory
|
||||||
after the execution of the C function. </p>
|
after the execution of the C function. </p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn49"></a>38.7.11 Collecting arguments in a hash</H3>
|
<H3><a name="Ruby_nn49">38.7.11 Collecting arguments in a hash</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> Ruby's solution to the "keyword arguments" capability of some
|
<p> Ruby's solution to the "keyword arguments" capability of some
|
||||||
|
|
@ -3837,7 +3856,7 @@ memory leak. Fortunately, this typemap is a lot easier to write: </p>
|
||||||
program that uses the extension, can be found in the <tt>Examples/ruby/hashargs</tt>
|
program that uses the extension, can be found in the <tt>Examples/ruby/hashargs</tt>
|
||||||
directory of the SWIG distribution. </p>
|
directory of the SWIG distribution. </p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn50"></a>38.7.12 Pointer handling</H3>
|
<H3><a name="Ruby_nn50">38.7.12 Pointer handling</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> Occasionally, it might be necessary to convert pointer values
|
<p> Occasionally, it might be necessary to convert pointer values
|
||||||
|
|
@ -3896,7 +3915,7 @@ For example: </p>
|
||||||
}</pre>
|
}</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H4><a name="Ruby_nn51"></a>38.7.12.1 Ruby Datatype Wrapping</H4>
|
<H4><a name="Ruby_nn51">38.7.12.1 Ruby Datatype Wrapping</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p> <tt>VALUE Data_Wrap_Struct(VALUE class, void
|
<p> <tt>VALUE Data_Wrap_Struct(VALUE class, void
|
||||||
|
|
@ -3923,7 +3942,7 @@ as above. </div>
|
||||||
type <i>c-type</i> from the data object <i>obj</i>
|
type <i>c-type</i> from the data object <i>obj</i>
|
||||||
and assigns that pointer to <i>ptr</i>. </div>
|
and assigns that pointer to <i>ptr</i>. </div>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn52"></a>38.7.13 Example: STL Vector to Ruby Array</H3>
|
<H3><a name="Ruby_nn52">38.7.13 Example: STL Vector to Ruby Array</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>Another use for macros and type maps is to create a Ruby array
|
<p>Another use for macros and type maps is to create a Ruby array
|
||||||
|
|
@ -4015,7 +4034,7 @@ STL with ruby, you are advised to use the standard swig STL library,
|
||||||
which does much more than this. Refer to the section called
|
which does much more than this. Refer to the section called
|
||||||
the<a href="#Ruby_nn23_1"> C++ Standard Template Library</a>.
|
the<a href="#Ruby_nn23_1"> C++ Standard Template Library</a>.
|
||||||
|
|
||||||
<H2><a name="Ruby_nn65"></a>38.8 Docstring Features</H2>
|
<H2><a name="Ruby_nn65">38.8 Docstring Features</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -4049,7 +4068,7 @@ generate ri documentation from a c wrap file, you could do:</p>
|
||||||
$ rdoc -r file_wrap.c
|
$ rdoc -r file_wrap.c
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn66"></a>38.8.1 Module docstring</H3>
|
<H3><a name="Ruby_nn66">38.8.1 Module docstring</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -4079,7 +4098,7 @@ layout of controls on a panel, etc. to be loaded from an XML file."
|
||||||
%module(docstring=DOCSTRING) xrc</pre>
|
%module(docstring=DOCSTRING) xrc</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn67"></a>38.8.2 %feature("autodoc")</H3>
|
<H3><a name="Ruby_nn67">38.8.2 %feature("autodoc")</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>Since SWIG does know everything about the function it wraps,
|
<p>Since SWIG does know everything about the function it wraps,
|
||||||
|
|
@ -4100,7 +4119,7 @@ several options for autodoc controlled by the value given to the
|
||||||
feature, described below.
|
feature, described below.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H4><a name="Ruby_nn68"></a>38.8.2.1 %feature("autodoc", "0")</H4>
|
<H4><a name="Ruby_nn68">38.8.2.1 %feature("autodoc", "0")</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -4124,7 +4143,7 @@ Then Ruby code like this will be generated:
|
||||||
...</pre>
|
...</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H4><a name="Ruby_autodoc1"></a>38.8.2.2 %feature("autodoc", "1")</H4>
|
<H4><a name="Ruby_autodoc1">38.8.2.2 %feature("autodoc", "1")</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -4144,7 +4163,7 @@ this:
|
||||||
...</pre>
|
...</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H4><a name="Ruby_autodoc2"></a>38.8.2.3 %feature("autodoc", "2")</H4>
|
<H4><a name="Ruby_autodoc2">38.8.2.3 %feature("autodoc", "2")</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -4156,7 +4175,7 @@ parameter types with the "2" option will result in Ruby code like
|
||||||
this:
|
this:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H4><a name="Ruby_feature_autodoc3"></a>38.8.2.4 %feature("autodoc", "3")</H4>
|
<H4><a name="Ruby_feature_autodoc3">38.8.2.4 %feature("autodoc", "3")</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -4177,7 +4196,7 @@ Parameters:
|
||||||
bar - Bar</pre>
|
bar - Bar</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H4><a name="Ruby_nn70"></a>38.8.2.5 %feature("autodoc", "docstring")</H4>
|
<H4><a name="Ruby_nn70">38.8.2.5 %feature("autodoc", "docstring")</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -4193,7 +4212,7 @@ generated string. For example:
|
||||||
void GetPosition(int* OUTPUT, int* OUTPUT);</pre>
|
void GetPosition(int* OUTPUT, int* OUTPUT);</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn71"></a>38.8.3 %feature("docstring")</H3>
|
<H3><a name="Ruby_nn71">38.8.3 %feature("docstring")</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -4204,10 +4223,10 @@ docstring associated with classes, function or methods are output.
|
||||||
If an item already has an autodoc string then it is combined with the
|
If an item already has an autodoc string then it is combined with the
|
||||||
docstring and they are output together. </p>
|
docstring and they are output together. </p>
|
||||||
|
|
||||||
<H2><a name="Ruby_nn53"></a>38.9 Advanced Topics</H2>
|
<H2><a name="Ruby_nn53">38.9 Advanced Topics</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Ruby_operator_overloading"></a>38.9.1 Operator overloading</H3>
|
<H3><a name="Ruby_operator_overloading">38.9.1 Operator overloading</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> SWIG allows operator overloading with, by using the <tt>%extend</tt>
|
<p> SWIG allows operator overloading with, by using the <tt>%extend</tt>
|
||||||
|
|
@ -4388,7 +4407,7 @@ separate method for handling <i>inequality</i> since Ruby
|
||||||
parses the expression <i>a != b</i> as <i>!(a == b)</i>.
|
parses the expression <i>a != b</i> as <i>!(a == b)</i>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn55"></a>38.9.2 Creating Multi-Module Packages</H3>
|
<H3><a name="Ruby_nn55">38.9.2 Creating Multi-Module Packages</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> The chapter on <a href="Modules.html#Modules">Working
|
<p> The chapter on <a href="Modules.html#Modules">Working
|
||||||
|
|
@ -4514,7 +4533,7 @@ irb(main):005:0> <b>c.getX()</b>
|
||||||
5.0</pre>
|
5.0</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn56"></a>38.9.3 Specifying Mixin Modules</H3>
|
<H3><a name="Ruby_nn56">38.9.3 Specifying Mixin Modules</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p> The Ruby language doesn't support multiple inheritance, but
|
<p> The Ruby language doesn't support multiple inheritance, but
|
||||||
|
|
@ -4581,7 +4600,7 @@ matching rules used for other kinds of features apply (see the chapter
|
||||||
on <a href="Customization.html#Customization">"Customization
|
on <a href="Customization.html#Customization">"Customization
|
||||||
Features"</a>) for more details). </p>
|
Features"</a>) for more details). </p>
|
||||||
|
|
||||||
<H2><a name="Ruby_nn57"></a>38.10 Memory Management</H2>
|
<H2><a name="Ruby_nn57">38.10 Memory Management</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>One of the most common issues in generating SWIG bindings for
|
<p>One of the most common issues in generating SWIG bindings for
|
||||||
|
|
@ -4604,7 +4623,7 @@ to C++ (or vice versa) depending on what function or methods are
|
||||||
invoked. Clearly, developing a SWIG wrapper requires a thorough
|
invoked. Clearly, developing a SWIG wrapper requires a thorough
|
||||||
understanding of how the underlying library manages memory.</p>
|
understanding of how the underlying library manages memory.</p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn58"></a>38.10.1 Mark and Sweep Garbage Collector </H3>
|
<H3><a name="Ruby_nn58">38.10.1 Mark and Sweep Garbage Collector </a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>Ruby uses a mark and sweep garbage collector. When the garbage
|
<p>Ruby uses a mark and sweep garbage collector. When the garbage
|
||||||
|
|
@ -4618,8 +4637,7 @@ objects that have already been marked). Those objects, in turn, may
|
||||||
reference other objects. This process will continue until all active
|
reference other objects. This process will continue until all active
|
||||||
objects have been "marked." After the mark phase comes the sweep phase.
|
objects have been "marked." After the mark phase comes the sweep phase.
|
||||||
In the sweep phase, all objects that have not been marked will be
|
In the sweep phase, all objects that have not been marked will be
|
||||||
garbage collected. For more information about the Ruby garbage
|
garbage collected. </p>
|
||||||
collector please refer to <a href="http://rubygarden.org/ruby/ruby?GCAndExtensions"> <span style="text-decoration: underline;">http://rubygarden.org/ruby/ruby?GCAndExtensions</span></a>.</p>
|
|
||||||
|
|
||||||
<p>The Ruby C/API provides extension developers two hooks into
|
<p>The Ruby C/API provides extension developers two hooks into
|
||||||
the garbage collector - a "mark" function and a "sweep" function. By
|
the garbage collector - a "mark" function and a "sweep" function. By
|
||||||
|
|
@ -4636,7 +4654,7 @@ any memory has been allocated in creating the underlying C struct or
|
||||||
C++ struct, then a "free" function must be defined that deallocates
|
C++ struct, then a "free" function must be defined that deallocates
|
||||||
this memory. </p>
|
this memory. </p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn59"></a>38.10.2 Object Ownership</H3>
|
<H3><a name="Ruby_nn59">38.10.2 Object Ownership</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>As described above, memory management depends on clearly
|
<p>As described above, memory management depends on clearly
|
||||||
|
|
@ -4781,7 +4799,7 @@ public:
|
||||||
|
|
||||||
<p> This code can be seen in swig/examples/ruby/tracking.</p>
|
<p> This code can be seen in swig/examples/ruby/tracking.</p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn60"></a>38.10.3 Object Tracking</H3>
|
<H3><a name="Ruby_nn60">38.10.3 Object Tracking</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>The remaining parts of this section will use the class library
|
<p>The remaining parts of this section will use the class library
|
||||||
|
|
@ -4818,7 +4836,7 @@ public:
|
||||||
class Zoo
|
class Zoo
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
std::vector<animal *=""> animals;
|
std::vector<Animal *> animals;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Construct an empty zoo
|
// Construct an empty zoo
|
||||||
|
|
@ -4941,7 +4959,8 @@ class-by-class basis if needed. To fix the example above:</p>
|
||||||
<b>/* Tell SWIG that create_animal creates a new object */</b>
|
<b>/* Tell SWIG that create_animal creates a new object */</b>
|
||||||
<b>%newobject Zoo::create_animal;</b>
|
<b>%newobject Zoo::create_animal;</b>
|
||||||
|
|
||||||
<b>/* Tell SWIG to keep track of mappings between C/C++ structs/classes. */</b><b>%trackobjects;</b>
|
<b>/* Tell SWIG to keep track of mappings between C/C++ structs/classes. */</b>
|
||||||
|
<b>%trackobjects;</b>
|
||||||
|
|
||||||
%include "example.h"</pre>
|
%include "example.h"</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -5006,7 +5025,7 @@ However, if you implement your own free functions (see below) you may
|
||||||
also have to call the <tt>SWIG_RubyRemoveTracking</tt> and <tt>RubyUnlinkObjects</tt>
|
also have to call the <tt>SWIG_RubyRemoveTracking</tt> and <tt>RubyUnlinkObjects</tt>
|
||||||
methods.</p>
|
methods.</p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn61"></a>38.10.4 Mark Functions</H3>
|
<H3><a name="Ruby_nn61">38.10.4 Mark Functions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>With a bit more testing, we see that our class library still
|
<p>With a bit more testing, we see that our class library still
|
||||||
|
|
@ -5101,7 +5120,7 @@ static void mark_Zoo(void* ptr) {
|
||||||
<p> Note the <tt>mark</tt> function is dependent on
|
<p> Note the <tt>mark</tt> function is dependent on
|
||||||
the <tt>SWIG_RUBY_InstanceFor</tt> method, and thus
|
the <tt>SWIG_RUBY_InstanceFor</tt> method, and thus
|
||||||
requires that <tt>%trackobjects</tt> is enabled. For more
|
requires that <tt>%trackobjects</tt> is enabled. For more
|
||||||
information, please refer to the track_object.i test case in the SWIG
|
information, please refer to the ruby_track_objects.i test case in the SWIG
|
||||||
test suite.</p>
|
test suite.</p>
|
||||||
|
|
||||||
<p>When this code is compiled we now see:</p>
|
<p>When this code is compiled we now see:</p>
|
||||||
|
|
@ -5135,7 +5154,7 @@ irb(main):016:0></pre>
|
||||||
|
|
||||||
<p>This code can be seen in swig/examples/ruby/mark_function.</p>
|
<p>This code can be seen in swig/examples/ruby/mark_function.</p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn62"></a>38.10.5 Free Functions</H3>
|
<H3><a name="Ruby_nn62">38.10.5 Free Functions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>By default, SWIG creates a "free" function that is called when
|
<p>By default, SWIG creates a "free" function that is called when
|
||||||
|
|
@ -5168,13 +5187,14 @@ above. </p>
|
||||||
|
|
||||||
<p>To show how to use the <tt>%freefunc</tt>
|
<p>To show how to use the <tt>%freefunc</tt>
|
||||||
directive, let's slightly change our example. Assume that the zoo
|
directive, let's slightly change our example. Assume that the zoo
|
||||||
object is responsible for freeing animal that it contains. This means
|
object is responsible for freeing any animal that it contains. This means
|
||||||
that the <tt>Zoo::add_animal</tt>
|
that the <tt>Zoo::add_animal</tt>
|
||||||
function should be marked with a <tt>DISOWN</tt> typemap
|
function should be marked with a <tt>DISOWN</tt> typemap
|
||||||
and the destructor should be updated as below:</p>
|
and the destructor should be updated as below:</p>
|
||||||
|
|
||||||
<div class="code">
|
<div class="code">
|
||||||
<pre>Zoo::~Zoo() {
|
<pre>
|
||||||
|
Zoo::~Zoo() {
|
||||||
IterType iter = this->animals.begin();
|
IterType iter = this->animals.begin();
|
||||||
IterType end = this->animals.end();
|
IterType end = this->animals.end();
|
||||||
|
|
||||||
|
|
@ -5182,7 +5202,8 @@ and the destructor should be updated as below:</p>
|
||||||
Animal* animal = *iter;
|
Animal* animal = *iter;
|
||||||
delete animal;
|
delete animal;
|
||||||
}
|
}
|
||||||
}</pre>
|
}
|
||||||
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p>When we use these objects in IRB we see:</p>
|
<p>When we use these objects in IRB we see:</p>
|
||||||
|
|
@ -5230,8 +5251,7 @@ existing Ruby object to the destroyed C++ object and raise an exception.
|
||||||
#include "example.h"
|
#include "example.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
/* Specify that ownership is transferred to the zoo
|
/* Specify that ownership is transferred to the zoo when calling add_animal */
|
||||||
when calling add_animal */
|
|
||||||
%apply SWIGTYPE *DISOWN { Animal* animal };
|
%apply SWIGTYPE *DISOWN { Animal* animal };
|
||||||
|
|
||||||
/* Track objects */
|
/* Track objects */
|
||||||
|
|
@ -5302,7 +5322,7 @@ been freed, and thus raises a runtime exception.</p>
|
||||||
|
|
||||||
<p>This code can be seen in swig/examples/ruby/free_function.</p>
|
<p>This code can be seen in swig/examples/ruby/free_function.</p>
|
||||||
|
|
||||||
<H3><a name="Ruby_nn63"></a>38.10.6 Embedded Ruby and the C++ Stack</H3>
|
<H3><a name="Ruby_nn63">38.10.6 Embedded Ruby and the C++ Stack</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>As has been said, the Ruby GC runs and marks objects before
|
<p>As has been said, the Ruby GC runs and marks objects before
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>SWIG Basics</title>
|
<title>SWIG Basics</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
<H1><a name="SWIG"></a>5 SWIG Basics</H1>
|
<H1><a name="SWIG">5 SWIG Basics</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -24,8 +25,8 @@
|
||||||
<li><a href="#SWIG_nn10">Basic Type Handling</a>
|
<li><a href="#SWIG_nn10">Basic Type Handling</a>
|
||||||
<li><a href="#SWIG_nn11">Global Variables</a>
|
<li><a href="#SWIG_nn11">Global Variables</a>
|
||||||
<li><a href="#SWIG_nn12">Constants</a>
|
<li><a href="#SWIG_nn12">Constants</a>
|
||||||
<li><a href="#SWIG_nn13">A brief word about <tt>const</tt></a>
|
<li><a href="#SWIG_nn13">A brief word about const</a>
|
||||||
<li><a href="#SWIG_nn14">A cautionary tale of <tt>char *</tt></a>
|
<li><a href="#SWIG_nn14">A cautionary tale of char *</a>
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="#SWIG_nn15">Pointers and complex objects</a>
|
<li><a href="#SWIG_nn15">Pointers and complex objects</a>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -40,7 +41,7 @@
|
||||||
<li><a href="#SWIG_nn22">Passing structures by value</a>
|
<li><a href="#SWIG_nn22">Passing structures by value</a>
|
||||||
<li><a href="#SWIG_nn23">Return by value</a>
|
<li><a href="#SWIG_nn23">Return by value</a>
|
||||||
<li><a href="#SWIG_nn24">Linking to structure variables</a>
|
<li><a href="#SWIG_nn24">Linking to structure variables</a>
|
||||||
<li><a href="#SWIG_nn25">Linking to <tt>char *</tt></a>
|
<li><a href="#SWIG_nn25">Linking to char *</a>
|
||||||
<li><a href="#SWIG_nn26">Arrays</a>
|
<li><a href="#SWIG_nn26">Arrays</a>
|
||||||
<li><a href="#SWIG_readonly_variables">Creating read-only variables</a>
|
<li><a href="#SWIG_readonly_variables">Creating read-only variables</a>
|
||||||
<li><a href="#SWIG_rename_ignore">Renaming and ignoring declarations</a>
|
<li><a href="#SWIG_rename_ignore">Renaming and ignoring declarations</a>
|
||||||
|
|
@ -94,7 +95,7 @@ Specific details about each target language are described in later
|
||||||
chapters.
|
chapters.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="SWIG_nn2"></a>5.1 Running SWIG</H2>
|
<H2><a name="SWIG_nn2">5.1 Running SWIG</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -110,7 +111,7 @@ where <tt>filename</tt> is a SWIG interface file or a C/C++ header file.
|
||||||
Below is a subset of <em>options</em> that can be used.
|
Below is a subset of <em>options</em> that can be used.
|
||||||
Additional options are also defined for each target language. A full list
|
Additional options are also defined for each target language. A full list
|
||||||
can be obtained by typing <tt>swig -help</tt> or <tt>swig
|
can be obtained by typing <tt>swig -help</tt> or <tt>swig
|
||||||
-<em>lang</em> -help</tt>.
|
<em>-<lang></em> -help</tt> for language <em><lang></em> specific options.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="shell"><pre>
|
<div class="shell"><pre>
|
||||||
|
|
@ -119,44 +120,50 @@ can be obtained by typing <tt>swig -help</tt> or <tt>swig
|
||||||
-clisp Generate CLISP wrappers
|
-clisp Generate CLISP wrappers
|
||||||
-cffi Generate CFFI wrappers
|
-cffi Generate CFFI wrappers
|
||||||
-csharp Generate C# wrappers
|
-csharp Generate C# wrappers
|
||||||
|
-d Generate D wrappers
|
||||||
-go Generate Go wrappers
|
-go Generate Go wrappers
|
||||||
-guile Generate Guile wrappers
|
-guile Generate Guile wrappers
|
||||||
-java Generate Java wrappers
|
-java Generate Java wrappers
|
||||||
|
-javascript Generate Javascript wrappers
|
||||||
-lua Generate Lua wrappers
|
-lua Generate Lua wrappers
|
||||||
-modula3 Generate Modula 3 wrappers
|
-modula3 Generate Modula 3 wrappers
|
||||||
-mzscheme Generate Mzscheme wrappers
|
-mzscheme Generate Mzscheme wrappers
|
||||||
-ocaml Generate Ocaml wrappers
|
-ocaml Generate Ocaml wrappers
|
||||||
|
-octave Generate Octave wrappers
|
||||||
-perl Generate Perl wrappers
|
-perl Generate Perl wrappers
|
||||||
-php Generate PHP wrappers
|
-php5 Generate PHP5 wrappers
|
||||||
|
-php7 Generate PHP7 wrappers
|
||||||
-pike Generate Pike wrappers
|
-pike Generate Pike wrappers
|
||||||
-python Generate Python wrappers
|
-python Generate Python wrappers
|
||||||
-r Generate R (aka GNU S) wrappers
|
-r Generate R (aka GNU S) wrappers
|
||||||
-ruby Generate Ruby wrappers
|
-ruby Generate Ruby wrappers
|
||||||
|
-scilab Generate Scilab wrappers
|
||||||
-sexp Generate Lisp S-Expressions wrappers
|
-sexp Generate Lisp S-Expressions wrappers
|
||||||
-tcl Generate Tcl wrappers
|
-tcl Generate Tcl wrappers
|
||||||
-uffi Generate Common Lisp / UFFI wrappers
|
-uffi Generate Common Lisp / UFFI wrappers
|
||||||
-xml Generate XML wrappers
|
-xml Generate XML wrappers
|
||||||
|
|
||||||
-c++ Enable C++ parsing
|
-c++ Enable C++ processing
|
||||||
-cppext <em>ext</em> Change file extension of C++ generated files to <em>ext</em> (default is cxx, except for PHP which uses cpp)
|
-cppext <em>ext</em> Change file extension of C++ generated files to <em>ext</em>
|
||||||
|
(default is cxx, except for PHP5 which uses cpp)
|
||||||
-D<em>symbol</em> Define a preprocessor symbol
|
-D<em>symbol</em> Define a preprocessor symbol
|
||||||
-Fstandard Display error/warning messages in commonly used format
|
|
||||||
-Fmicrosoft Display error/warning messages in Microsoft format
|
-Fmicrosoft Display error/warning messages in Microsoft format
|
||||||
|
-Fstandard Display error/warning messages in commonly used format
|
||||||
-help Display all options
|
-help Display all options
|
||||||
-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>ifile</em> Include SWIG library file <ifile>
|
||||||
-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> Set name of C/C++ output file to <outfile>
|
-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>
|
-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
|
||||||
-swiglib Show location of SWIG library
|
-swiglib Report location of SWIG library and exit
|
||||||
-version Show SWIG version number
|
-version Display SWIG version number
|
||||||
|
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="SWIG_nn3"></a>5.1.1 Input format</H3>
|
<H3><a name="SWIG_nn3">5.1.1 Input format</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -203,7 +210,7 @@ semantics in SWIG is analogous to that of the declarations section
|
||||||
used in input files to parser generation tools such as yacc or bison.
|
used in input files to parser generation tools such as yacc or bison.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIG_output"></a>5.1.2 SWIG Output</H3>
|
<H3><a name="SWIG_output">5.1.2 SWIG Output</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -263,7 +270,7 @@ as the output directory for the language files is the same directory as the
|
||||||
generated C/C++ file if not overridden with <tt>-outdir</tt>.
|
generated C/C++ file if not overridden with <tt>-outdir</tt>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIG_nn5"></a>5.1.3 Comments</H3>
|
<H3><a name="SWIG_nn5">5.1.3 Comments</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -273,7 +280,7 @@ documentation files. However, this feature is currently under repair
|
||||||
and will reappear in a later SWIG release.
|
and will reappear in a later SWIG release.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIG_nn6"></a>5.1.4 C Preprocessor</H3>
|
<H3><a name="SWIG_nn6">5.1.4 C Preprocessor</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -297,7 +304,7 @@ make it more powerful than the normal C preprocessor. These
|
||||||
extensions are described in the "<a href="Preprocessor.html#Preprocessor">Preprocessor</a>" chapter.
|
extensions are described in the "<a href="Preprocessor.html#Preprocessor">Preprocessor</a>" chapter.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIG_nn7"></a>5.1.5 SWIG Directives</H3>
|
<H3><a name="SWIG_nn7">5.1.5 SWIG Directives</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -328,7 +335,7 @@ included in C header files using conditional compilation like this:
|
||||||
it is parsing an input file.
|
it is parsing an input file.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIG_nn8"></a>5.1.6 Parser Limitations</H3>
|
<H3><a name="SWIG_nn8">5.1.6 Parser Limitations</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -426,7 +433,7 @@ does not utilize a separate <em>typedef-name</em> terminal symbol as
|
||||||
described on p. 234 of K&R).
|
described on p. 234 of K&R).
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="SWIG_nn9"></a>5.2 Wrapping Simple C Declarations</H2>
|
<H2><a name="SWIG_nn9">5.2 Wrapping Simple C Declarations</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -489,7 +496,7 @@ environments, and semantics, it is not always possible to do so. The
|
||||||
next few sections describe various aspects of this mapping.
|
next few sections describe various aspects of this mapping.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIG_nn10"></a>5.2.1 Basic Type Handling</H3>
|
<H3><a name="SWIG_nn10">5.2.1 Basic Type Handling</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -614,7 +621,7 @@ will use the same internal representation (e.g., UCS-2 vs. UCS-4).
|
||||||
You may need to write some special conversion functions.
|
You may need to write some special conversion functions.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIG_nn11"></a>5.2.2 Global Variables</H3>
|
<H3><a name="SWIG_nn11">5.2.2 Global Variables</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -669,7 +676,7 @@ Earlier versions of SWIG incorrectly handled <tt>const</tt> and created
|
||||||
constants instead.
|
constants instead.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIG_nn12"></a>5.2.3 Constants</H3>
|
<H3><a name="SWIG_nn12">5.2.3 Constants</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -758,7 +765,7 @@ is only used when you want to add constants to the scripting language
|
||||||
interface that are not defined in the original header file.
|
interface that are not defined in the original header file.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIG_nn13"></a>5.2.4 A brief word about <tt>const</tt></H3>
|
<H3><a name="SWIG_nn13">5.2.4 A brief word about const</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -860,7 +867,7 @@ const int spam = 42;
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="SWIG_nn14"></a>5.2.5 A cautionary tale of <tt>char *</tt></H3>
|
<H3><a name="SWIG_nn14">5.2.5 A cautionary tale of char *</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -899,7 +906,7 @@ input values. However, it must be noted that you could change the behavior of
|
||||||
using <a href="Typemaps.html#Typemaps">typemaps</a>.
|
using <a href="Typemaps.html#Typemaps">typemaps</a>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="SWIG_nn15"></a>5.3 Pointers and complex objects</H2>
|
<H2><a name="SWIG_nn15">5.3 Pointers and complex objects</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -907,7 +914,7 @@ Most C programs manipulate arrays, structures, and other types of objects. This
|
||||||
discusses the handling of these datatypes.
|
discusses the handling of these datatypes.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIG_nn16"></a>5.3.1 Simple pointers</H3>
|
<H3><a name="SWIG_nn16">5.3.1 Simple pointers</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -973,7 +980,7 @@ simplified and less prone to error.
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<H3><a name="SWIG_nn17"></a>5.3.2 Run time pointer type checking</H3>
|
<H3><a name="SWIG_nn17">5.3.2 Run time pointer type checking</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -995,7 +1002,7 @@ as sentinel values or to denote a missing/empty value. Therefore,
|
||||||
SWIG leaves NULL pointer checking up to the application.
|
SWIG leaves NULL pointer checking up to the application.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIG_nn18"></a>5.3.3 Derived types, structs, and classes</H3>
|
<H3><a name="SWIG_nn18">5.3.3 Derived types, structs, and classes</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1044,7 +1051,6 @@ def filecopy(source,target):
|
||||||
fwrite(buffer,8192,1,f2)
|
fwrite(buffer,8192,1,f2)
|
||||||
nbytes = fread(buffer,8192,1,f1)
|
nbytes = fread(buffer,8192,1,f1)
|
||||||
free(buffer)
|
free(buffer)
|
||||||
|
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1052,7 +1058,7 @@ In this case <tt>f1</tt>, <tt>f2</tt>, and <tt>buffer</tt> are all
|
||||||
opaque objects containing C pointers. It doesn't matter what value
|
opaque objects containing C pointers. It doesn't matter what value
|
||||||
they contain--our program works just fine without this knowledge.</p>
|
they contain--our program works just fine without this knowledge.</p>
|
||||||
|
|
||||||
<H3><a name="SWIG_nn19"></a>5.3.4 Undefined datatypes</H3>
|
<H3><a name="SWIG_nn19">5.3.4 Undefined datatypes</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1112,7 +1118,7 @@ The only way to fix this problem is to make sure you properly declare type names
|
||||||
|
|
||||||
<!-- We might want to add an error reporting flag to swig -->
|
<!-- We might want to add an error reporting flag to swig -->
|
||||||
|
|
||||||
<H3><a name="SWIG_nn20"></a>5.3.5 Typedef</H3>
|
<H3><a name="SWIG_nn20">5.3.5 Typedef</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1201,7 +1207,7 @@ The corresponding wrapper function will accept arguments of
|
||||||
type <tt>unsigned int *</tt> or <tt>size_t *</tt>.
|
type <tt>unsigned int *</tt> or <tt>size_t *</tt>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="SWIG_nn21"></a>5.4 Other Practicalities</H2>
|
<H2><a name="SWIG_nn21">5.4 Other Practicalities</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1211,7 +1217,7 @@ more difficult to map to a scripting language interface. This section describes
|
||||||
some of these issues.
|
some of these issues.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIG_nn22"></a>5.4.1 Passing structures by value</H3>
|
<H3><a name="SWIG_nn22">5.4.1 Passing structures by value</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1242,7 +1248,7 @@ to Vectors instead of Vectors. For the most part, this transformation
|
||||||
is transparent so you might not notice.
|
is transparent so you might not notice.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIG_nn23"></a>5.4.2 Return by value</H3>
|
<H3><a name="SWIG_nn23">5.4.2 Return by value</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1297,7 +1303,7 @@ don't work correctly if <tt>Vector</tt> doesn't define a default
|
||||||
constructor. The section on SWIG and C++ has more information about this case.
|
constructor. The section on SWIG and C++ has more information about this case.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIG_nn24"></a>5.4.3 Linking to structure variables</H3>
|
<H3><a name="SWIG_nn24">5.4.3 Linking to structure variables</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1329,7 +1335,7 @@ C++ classes must supply a properly defined copy constructor in order for
|
||||||
assignment to work correctly.
|
assignment to work correctly.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIG_nn25"></a>5.4.4 Linking to <tt>char *</tt></H3>
|
<H3><a name="SWIG_nn25">5.4.4 Linking to char *</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1458,7 +1464,7 @@ value is not released.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="SWIG_nn26"></a>5.4.5 Arrays</H3>
|
<H3><a name="SWIG_nn26">5.4.5 Arrays</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1594,7 +1600,7 @@ void pathname_set(char *value) {
|
||||||
In the target language, the value can be set like a normal variable.
|
In the target language, the value can be set like a normal variable.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIG_readonly_variables"></a>5.4.6 Creating read-only variables</H3>
|
<H3><a name="SWIG_readonly_variables">5.4.6 Creating read-only variables</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1606,9 +1612,9 @@ directive as shown :</p>
|
||||||
|
|
||||||
int a; // Can read/write
|
int a; // Can read/write
|
||||||
%immutable;
|
%immutable;
|
||||||
int b,c,d // Read only variables
|
int b,c,d; // Read only variables
|
||||||
%mutable;
|
%mutable;
|
||||||
double x,y // read/write
|
double x,y; // read/write
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1668,10 +1674,10 @@ generate a warning message. Simply change the directives to <tt>%immutable;</t
|
||||||
<tt>%mutable;</tt> to silence the warning. Don't forget the extra semicolon!
|
<tt>%mutable;</tt> to silence the warning. Don't forget the extra semicolon!
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIG_rename_ignore"></a>5.4.7 Renaming and ignoring declarations</H3>
|
<H3><a name="SWIG_rename_ignore">5.4.7 Renaming and ignoring declarations</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<H4><a name="SWIG_nn29"></a>5.4.7.1 Simple renaming of specific identifiers</H4>
|
<H4><a name="SWIG_nn29">5.4.7.1 Simple renaming of specific identifiers</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1769,7 +1775,7 @@ This directive is still supported, but it is deprecated and should probably be a
|
||||||
directive is more powerful and better supports wrapping of raw header file information.
|
directive is more powerful and better supports wrapping of raw header file information.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H4><a name="SWIG_advanced_renaming"></a>5.4.7.2 Advanced renaming support</H4>
|
<H4><a name="SWIG_advanced_renaming">5.4.7.2 Advanced renaming support</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1883,6 +1889,13 @@ and a more descriptive one, but the two functions are otherwise equivalent:
|
||||||
literally, e.g. <tt>%rename("strip:[wx]")</tt></td>
|
literally, e.g. <tt>%rename("strip:[wx]")</tt></td>
|
||||||
<td><tt>wxPrint</tt></td><td><tt>Print</tt></td>
|
<td><tt>wxPrint</tt></td><td><tt>Print</tt></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><tt>rstrip:[suffix]</tt></td>
|
||||||
|
<td>String without the given suffix or the original string if it doesn't
|
||||||
|
end with this suffix. Note that square brackets should be used
|
||||||
|
literally, e.g. <tt>%rename("rstrip:[Cls]")</tt></td>
|
||||||
|
<td><tt>PrintCls</tt></td><td><tt>Print</tt></td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><span style="white-space: nowrap;"><tt>regex:/pattern/subst/</tt></span></td>
|
<td><span style="white-space: nowrap;"><tt>regex:/pattern/subst/</tt></span></td>
|
||||||
<td>String after (Perl-like) regex substitution operation. This function
|
<td>String after (Perl-like) regex substitution operation. This function
|
||||||
|
|
@ -1971,7 +1984,7 @@ are exactly equivalent and <tt>%rename</tt> can be used to selectively ignore
|
||||||
multiple declarations using the previously described matching possibilities.
|
multiple declarations using the previously described matching possibilities.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H4><a name="SWIG_limiting_renaming"></a>5.4.7.3 Limiting global renaming rules</H4>
|
<H4><a name="SWIG_limiting_renaming">5.4.7.3 Limiting global renaming rules</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2069,7 +2082,7 @@ wrap C++ overloaded functions and methods or C++ methods which use default argum
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H4><a name="SWIG_chosen_unignore"></a>5.4.7.4 Ignoring everything then wrapping a few selected symbols</H4>
|
<H4><a name="SWIG_chosen_unignore">5.4.7.4 Ignoring everything then wrapping a few selected symbols</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2111,7 +2124,7 @@ members of the class, so when the chosen class is unignored, all of its methods
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="SWIG_default_args"></a>5.4.8 Default/optional arguments</H3>
|
<H3><a name="SWIG_default_args">5.4.8 Default/optional arguments</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2148,7 +2161,7 @@ Please refer to the section on <a href="SWIGPlus.html#SWIGPlus_default_args">def
|
||||||
in the C++ chapter for further details.
|
in the C++ chapter for further details.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIG_nn30"></a>5.4.9 Pointers to functions and callbacks</H3>
|
<H3><a name="SWIG_nn30">5.4.9 Pointers to functions and callbacks</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2301,7 +2314,7 @@ See the <a href="Typemaps.html#Typemaps">Typemaps chapter</a> for more about typ
|
||||||
and individual target language chapters for more on callbacks and the 'director' feature.
|
and individual target language chapters for more on callbacks and the 'director' feature.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="SWIG_nn31"></a>5.5 Structures and unions</H2>
|
<H2><a name="SWIG_nn31">5.5 Structures and unions</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2383,7 +2396,7 @@ delete_Vector(v)
|
||||||
However, most of SWIG's language modules also provide a high-level interface that is more convenient. Keep reading.
|
However, most of SWIG's language modules also provide a high-level interface that is more convenient. Keep reading.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIG_nn32"></a>5.5.1 Typedef and structures</H3>
|
<H3><a name="SWIG_nn32">5.5.1 Typedef and structures</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2429,7 +2442,7 @@ vector_struct</tt>, SWIG knows that this is the same as
|
||||||
<tt>Vector</tt> and it generates the appropriate type-checking code.
|
<tt>Vector</tt> and it generates the appropriate type-checking code.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIG_nn33"></a>5.5.2 Character strings and structures</H3>
|
<H3><a name="SWIG_nn33">5.5.2 Character strings and structures</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2458,7 +2471,8 @@ char *Foo_name_get(Foo *obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char *Foo_name_set(Foo *obj, char *c) {
|
char *Foo_name_set(Foo *obj, char *c) {
|
||||||
if (obj->name) free(obj->name);
|
if (obj->name)
|
||||||
|
free(obj->name);
|
||||||
obj->name = (char *) malloc(strlen(c)+1);
|
obj->name = (char *) malloc(strlen(c)+1);
|
||||||
strcpy(obj->name,c);
|
strcpy(obj->name,c);
|
||||||
return obj->name;
|
return obj->name;
|
||||||
|
|
@ -2476,7 +2490,7 @@ Note: If the <tt>-c++</tt> option is used, <tt>new</tt> and <tt>delete</tt> are
|
||||||
perform memory allocation.
|
perform memory allocation.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIG_nn34"></a>5.5.3 Array members</H3>
|
<H3><a name="SWIG_nn34">5.5.3 Array members</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2498,7 +2512,7 @@ discussed in a later chapter. In many cases, the warning message is
|
||||||
harmless.
|
harmless.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIG_structure_data_members"></a>5.5.4 Structure data members</H3>
|
<H3><a name="SWIG_structure_data_members">5.5.4 Structure data members</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2604,7 +2618,7 @@ class, or union. This is unlikely to break existing code. However, if you need
|
||||||
datatype is really a struct, simply use a forward struct declaration such as <tt>"struct Foo;"</tt>.
|
datatype is really a struct, simply use a forward struct declaration such as <tt>"struct Foo;"</tt>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIG_nn36"></a>5.5.5 C constructors and destructors</H3>
|
<H3><a name="SWIG_nn36">5.5.5 C constructors and destructors</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2693,7 +2707,7 @@ the target languages, and it is highly recommended you don't use them.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="SWIG_adding_member_functions"></a>5.5.6 Adding member functions to C structures</H3>
|
<H3><a name="SWIG_adding_member_functions">5.5.6 Adding member functions to C structures</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2966,7 +2980,7 @@ be used to extend a structure with more than just methods, a more suitable
|
||||||
directive name has been chosen.
|
directive name has been chosen.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIG_nested_structs"></a>5.5.7 Nested structures</H3>
|
<H3><a name="SWIG_nested_structs">5.5.7 Nested structures</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3050,7 +3064,7 @@ Finally, note that nesting is handled differently in C++ mode,
|
||||||
see <a href="SWIGPlus.html#SWIGPlus_nested_classes">Nested classes</a>.
|
see <a href="SWIGPlus.html#SWIGPlus_nested_classes">Nested classes</a>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIG_nn39"></a>5.5.8 Other things to note about structure wrapping</H3>
|
<H3><a name="SWIG_nn39">5.5.8 Other things to note about structure wrapping</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3112,7 +3126,7 @@ interface described here, most of SWIG's language modules use it in
|
||||||
some way or another.
|
some way or another.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="SWIG_nn40"></a>5.6 Code Insertion</H2>
|
<H2><a name="SWIG_nn40">5.6 Code Insertion</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3122,7 +3136,7 @@ additional C code to perform initialization or other operations.
|
||||||
There are four common ways to insert code, but it's useful to know how the
|
There are four common ways to insert code, but it's useful to know how the
|
||||||
output of SWIG is structured first.</p>
|
output of SWIG is structured first.</p>
|
||||||
|
|
||||||
<H3><a name="SWIG_nn41"></a>5.6.1 The output of SWIG</H3>
|
<H3><a name="SWIG_nn41">5.6.1 The output of SWIG</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3158,7 +3172,7 @@ the module upon loading.
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<H3><a name="SWIG_nn42"></a>5.6.2 Code insertion blocks</H3>
|
<H3><a name="SWIG_nn42">5.6.2 Code insertion blocks</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3236,7 +3250,7 @@ static Vector *new_Vector() {
|
||||||
Vector *new_Vector();
|
Vector *new_Vector();
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="SWIG_nn43"></a>5.6.3 Inlined code blocks</H3>
|
<H3><a name="SWIG_nn43">5.6.3 Inlined code blocks</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3263,7 +3277,7 @@ declaration. Since the code inside an <tt>%inline %{ ... %}</tt> block
|
||||||
is given to both the C compiler and SWIG, it is illegal to include any
|
is given to both the C compiler and SWIG, it is illegal to include any
|
||||||
SWIG directives inside a <tt>%{ ... %}</tt> block.</p>
|
SWIG directives inside a <tt>%{ ... %}</tt> block.</p>
|
||||||
|
|
||||||
<H3><a name="SWIG_nn44"></a>5.6.4 Initialization blocks</H3>
|
<H3><a name="SWIG_nn44">5.6.4 Initialization blocks</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3278,7 +3292,7 @@ initialization on module loading, you could write this:
|
||||||
%}
|
%}
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H2><a name="SWIG_nn45"></a>5.7 An Interface Building Strategy</H2>
|
<H2><a name="SWIG_nn45">5.7 An Interface Building Strategy</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3286,7 +3300,7 @@ This section describes the general approach for building interfaces
|
||||||
with SWIG. The specifics related to a particular scripting language
|
with SWIG. The specifics related to a particular scripting language
|
||||||
are found in later chapters.</p>
|
are found in later chapters.</p>
|
||||||
|
|
||||||
<H3><a name="SWIG_nn46"></a>5.7.1 Preparing a C program for SWIG</H3>
|
<H3><a name="SWIG_nn46">5.7.1 Preparing a C program for SWIG</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3340,7 +3354,7 @@ to the <a href="http://www.swig.org/mail.html">swig-devel mailing list</a> or to
|
||||||
<a href="http://www.swig.org/bugs.html">SWIG bug tracker</a>.
|
<a href="http://www.swig.org/bugs.html">SWIG bug tracker</a>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIG_nn47"></a>5.7.2 The SWIG interface file</H3>
|
<H3><a name="SWIG_nn47">5.7.2 The SWIG interface file</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3393,7 +3407,7 @@ The main advantage of this approach is minimal maintenance of an interface file
|
||||||
In more complex projects, an interface file containing numerous <tt>%include</tt> and <tt>#include</tt> statements like this is one of the most common approaches to interface file design due to lower maintenance overhead.
|
In more complex projects, an interface file containing numerous <tt>%include</tt> and <tt>#include</tt> statements like this is one of the most common approaches to interface file design due to lower maintenance overhead.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIG_nn48"></a>5.7.3 Why use separate interface files?</H3>
|
<H3><a name="SWIG_nn48">5.7.3 Why use separate interface files?</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3422,7 +3436,7 @@ and immediately see what is available without having to dig it out of
|
||||||
header files.
|
header files.
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<H3><a name="SWIG_nn49"></a>5.7.4 Getting the right header files</H3>
|
<H3><a name="SWIG_nn49">5.7.4 Getting the right header files</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3442,7 +3456,7 @@ include certain header files by using a <tt>%{,%}</tt> block like this:
|
||||||
...
|
...
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="SWIG_nn50"></a>5.7.5 What to do with main()</H3>
|
<H3><a name="SWIG_nn50">5.7.5 What to do with main()</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>SWIG and C++</title>
|
<title>SWIG and C++</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
<H1><a name="SWIGPlus"></a>6 SWIG and C++</H1>
|
<H1><a name="SWIGPlus">6 SWIG and C++</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -75,7 +76,7 @@ how SWIG wraps ANSI C. Support for C++ builds upon ANSI C
|
||||||
wrapping and that material will be useful in understanding this chapter.
|
wrapping and that material will be useful in understanding this chapter.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="SWIGPlus_nn2"></a>6.1 Comments on C++ Wrapping</H2>
|
<H2><a name="SWIGPlus_nn2">6.1 Comments on C++ Wrapping</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -117,7 +118,7 @@ crossing language boundaries and provides many opportunities to shoot
|
||||||
yourself in the foot. You will just have to be careful.
|
yourself in the foot. You will just have to be careful.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="SWIGPlus_nn3"></a>6.2 Approach</H2>
|
<H2><a name="SWIGPlus_nn3">6.2 Approach</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -158,7 +159,7 @@ proxy classes. More detailed coverage can be found in the documentation
|
||||||
for each target language.
|
for each target language.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="SWIGPlus_nn4"></a>6.3 Supported C++ features</H2>
|
<H2><a name="SWIGPlus_nn4">6.3 Supported C++ features</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -197,7 +198,7 @@ in future releases. However, we make no promises. Also, submitting a bug repor
|
||||||
good way to get problems fixed (wink).
|
good way to get problems fixed (wink).
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="SWIGPlus_nn5"></a>6.4 Command line options and compilation</H2>
|
<H2><a name="SWIGPlus_nn5">6.4 Command line options and compilation</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -231,7 +232,7 @@ details. The SWIG Wiki also has further details.
|
||||||
The <tt>-noproxy</tt> commandline option is recognised by many target languages and will generate just this
|
The <tt>-noproxy</tt> commandline option is recognised by many target languages and will generate just this
|
||||||
interface as in earlier versions.
|
interface as in earlier versions.
|
||||||
|
|
||||||
<H2><a name="SWIGPlus_nn38"></a>6.5 Proxy classes</H2>
|
<H2><a name="SWIGPlus_nn38">6.5 Proxy classes</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -243,7 +244,7 @@ wrapped by a Python proxy class. Or if you're building a Java module, each
|
||||||
C++ class is wrapped by a Java proxy class.
|
C++ class is wrapped by a Java proxy class.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIGPlus_nn39"></a>6.5.1 Construction of proxy classes</H3>
|
<H3><a name="SWIGPlus_nn39">6.5.1 Construction of proxy classes</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -325,7 +326,7 @@ Whenever possible, proxies try to take advantage of language features that are s
|
||||||
might include operator overloading, exception handling, and other features.
|
might include operator overloading, exception handling, and other features.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIGPlus_nn40"></a>6.5.2 Resource management in proxies</H3>
|
<H3><a name="SWIGPlus_nn40">6.5.2 Resource management in proxies</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -479,7 +480,7 @@ every possible memory management problem. However, proxies do provide a mechani
|
||||||
can be used (if necessary) to address some of the more tricky memory management problems.
|
can be used (if necessary) to address some of the more tricky memory management problems.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIGPlus_nn41"></a>6.5.3 Language specific details</H3>
|
<H3><a name="SWIGPlus_nn41">6.5.3 Language specific details</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -487,7 +488,7 @@ Language specific details on proxy classes are contained in the chapters describ
|
||||||
chapter has merely introduced the topic in a very general way.
|
chapter has merely introduced the topic in a very general way.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="SWIGPlus_nn6"></a>6.6 Simple C++ wrapping</H2>
|
<H2><a name="SWIGPlus_nn6">6.6 Simple C++ wrapping</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -520,7 +521,7 @@ To generate wrappers for this class, SWIG first reduces the class to a collectio
|
||||||
accessor functions which are then used by the proxy classes.
|
accessor functions which are then used by the proxy classes.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIGPlus_nn7"></a>6.6.1 Constructors and destructors</H3>
|
<H3><a name="SWIGPlus_nn7">6.6.1 Constructors and destructors</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -537,7 +538,7 @@ void delete_List(List *l) {
|
||||||
|
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="SWIGPlus_nn8"></a>6.6.2 Default constructors, copy constructors and implicit destructors</H3>
|
<H3><a name="SWIGPlus_nn8">6.6.2 Default constructors, copy constructors and implicit destructors</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -686,7 +687,7 @@ leaks, and so it is strongly recommended to not use them.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="SWIGPlus_nn9"></a>6.6.3 When constructor wrappers aren't created</H3>
|
<H3><a name="SWIGPlus_nn9">6.6.3 When constructor wrappers aren't created</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -763,7 +764,7 @@ public:
|
||||||
More information about <tt>%feature</tt> can be found in the <a href="Customization.html#Customization">Customization features</a> chapter.
|
More information about <tt>%feature</tt> can be found in the <a href="Customization.html#Customization">Customization features</a> chapter.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIGPlus_nn10"></a>6.6.4 Copy constructors</H3>
|
<H3><a name="SWIGPlus_nn10">6.6.4 Copy constructors</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -865,7 +866,7 @@ constructor is set to <tt>new_CopyFoo()</tt>. This is the same as in
|
||||||
older versions.
|
older versions.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIGPlus_nn11"></a>6.6.5 Member functions</H3>
|
<H3><a name="SWIGPlus_nn11">6.6.5 Member functions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -891,7 +892,7 @@ wrapper functions. However, the name and calling convention of the
|
||||||
low-level procedural wrappers match the accessor function prototype described above.
|
low-level procedural wrappers match the accessor function prototype described above.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIGPlus_nn12"></a>6.6.6 Static members</H3>
|
<H3><a name="SWIGPlus_nn12">6.6.6 Static members</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -901,7 +902,7 @@ transformations. For example, the static member function
|
||||||
in the generated wrapper code.
|
in the generated wrapper code.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIGPlus_member_data"></a>6.6.7 Member data</H3>
|
<H3><a name="SWIGPlus_member_data">6.6.7 Member data</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1093,7 +1094,7 @@ a few problems related to structure wrapping and some of SWIG's
|
||||||
customization features.
|
customization features.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="SWIGPlus_default_args"></a>6.7 Default arguments</H2>
|
<H2><a name="SWIGPlus_default_args">6.7 Default arguments</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1199,7 +1200,7 @@ Keyword arguments are a language feature of some scripting languages, for exampl
|
||||||
SWIG is unable to support kwargs when wrapping overloaded methods, so the default approach cannot be used.
|
SWIG is unable to support kwargs when wrapping overloaded methods, so the default approach cannot be used.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="SWIGPlus_nn15"></a>6.8 Protection</H2>
|
<H2><a name="SWIGPlus_nn15">6.8 Protection</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1219,7 +1220,7 @@ until you explicitly give a `<tt>public:</tt>' declaration (This is
|
||||||
the same convention used by C++).
|
the same convention used by C++).
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="SWIGPlus_nn16"></a>6.9 Enums and constants</H2>
|
<H2><a name="SWIGPlus_nn16">6.9 Enums and constants</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1249,7 +1250,7 @@ Swig_STOUT = Swig::STOUT
|
||||||
Members declared as <tt>const</tt> are wrapped as read-only members and do not create constants.
|
Members declared as <tt>const</tt> are wrapped as read-only members and do not create constants.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="SWIGPlus_nn17"></a>6.10 Friends</H2>
|
<H2><a name="SWIGPlus_nn17">6.10 Friends</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1310,7 +1311,7 @@ namespace bar {
|
||||||
and a wrapper for the method 'blah' will not be generated.
|
and a wrapper for the method 'blah' will not be generated.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="SWIGPlus_nn18"></a>6.11 References and pointers</H2>
|
<H2><a name="SWIGPlus_nn18">6.11 References and pointers</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1410,7 +1411,7 @@ templates and the STL. This was first added in SWIG-1.3.12.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="SWIGPlus_nn19"></a>6.12 Pass and return by value</H2>
|
<H2><a name="SWIGPlus_nn19">6.12 Pass and return by value</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1514,7 +1515,7 @@ classes that don't define a default constructor.
|
||||||
It is not used for C++ pointers or references.
|
It is not used for C++ pointers or references.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="SWIGPlus_nn20"></a>6.13 Inheritance</H2>
|
<H2><a name="SWIGPlus_nn20">6.13 Inheritance</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1700,7 +1701,7 @@ functions for virtual members that are already defined in a base
|
||||||
class.
|
class.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="SWIGPlus_nn21"></a>6.14 A brief discussion of multiple inheritance, pointers, and type checking</H2>
|
<H2><a name="SWIGPlus_nn21">6.14 A brief discussion of multiple inheritance, pointers, and type checking</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1832,7 +1833,7 @@ int y = B_function((B *) pB);
|
||||||
In practice, the pointer is held as an integral number in the target language proxy class.
|
In practice, the pointer is held as an integral number in the target language proxy class.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="SWIGPlus_overloaded_methods"></a>6.15 Wrapping Overloaded Functions and Methods</H2>
|
<H2><a name="SWIGPlus_overloaded_methods">6.15 Wrapping Overloaded Functions and Methods</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1895,7 +1896,7 @@ it might be used like this
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="SWIGPlus_nn24"></a>6.15.1 Dispatch function generation</H3>
|
<H3><a name="SWIGPlus_nn24">6.15.1 Dispatch function generation</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2020,7 +2021,7 @@ checked in the same order as they appear in this ranking.
|
||||||
If you're still confused, don't worry about it---SWIG is probably doing the right thing.
|
If you're still confused, don't worry about it---SWIG is probably doing the right thing.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIGPlus_nn25"></a>6.15.2 Ambiguity in Overloading</H3>
|
<H3><a name="SWIGPlus_nn25">6.15.2 Ambiguity in Overloading</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2138,7 +2139,7 @@ it means that the target language module has not yet implemented support for ove
|
||||||
functions and methods. The only way to fix the problem is to read the next section.
|
functions and methods. The only way to fix the problem is to read the next section.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIGPlus_ambiguity_resolution_renaming"></a>6.15.3 Ambiguity resolution and renaming</H3>
|
<H3><a name="SWIGPlus_ambiguity_resolution_renaming">6.15.3 Ambiguity resolution and renaming</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2481,6 +2482,7 @@ above:
|
||||||
<li><p>
|
<li><p>
|
||||||
Currently no resolution is performed in order to match function parameters. This means function parameter types must match exactly.
|
Currently no resolution is performed in order to match function parameters. This means function parameter types must match exactly.
|
||||||
For example, namespace qualifiers and typedefs will not work. The following usage of typedefs demonstrates this:
|
For example, namespace qualifiers and typedefs will not work. The following usage of typedefs demonstrates this:
|
||||||
|
</p>
|
||||||
|
|
||||||
<div class="code">
|
<div class="code">
|
||||||
<pre>
|
<pre>
|
||||||
|
|
@ -2567,7 +2569,7 @@ to wrapping methods with default arguments was introduced.
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<H3><a name="SWIGPlus_nn27"></a>6.15.4 Comments on overloading</H3>
|
<H3><a name="SWIGPlus_nn27">6.15.4 Comments on overloading</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2584,7 +2586,7 @@ As a general rule, statically typed languages like Java are able to provide more
|
||||||
than dynamically typed languages like Perl, Python, Ruby, and Tcl.
|
than dynamically typed languages like Perl, Python, Ruby, and Tcl.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="SWIGPlus_nn28"></a>6.16 Wrapping overloaded operators</H2>
|
<H2><a name="SWIGPlus_nn28">6.16 Wrapping overloaded operators</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2761,14 +2763,33 @@ have to handle it like a normal function. For example:
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li><p>Certain operators are ignored by default. For instance, <tt>new</tt> and <tt>delete</tt> operators
|
<li><p>Certain operators are ignored by default. For instance, <tt>new</tt> and <tt>delete</tt> operators
|
||||||
are ignored as well as conversion operators.
|
are ignored as well as conversion and index operators. A warning such as the one below is shown:
|
||||||
</p></li>
|
</p>
|
||||||
|
|
||||||
|
<div class="shell">
|
||||||
|
<pre>
|
||||||
|
example.i:12: Warning 503: Can't wrap 'operator []' unless renamed to a valid identifier.
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li><p>The index operator, <tt>operator[]</tt>, is particularly difficult to overload due to differences in C++
|
||||||
|
implementations. Specifically, the get and set operators in other languages typically are separated
|
||||||
|
into two methods such that additional logic can be packed into the operations; C# uses
|
||||||
|
<tt>this[type key] { get { ... } set { ... }}</tt>, Python uses
|
||||||
|
<tt>__getitem__</tt> and <tt>__setitem__</tt>, etc. In C++ if the return
|
||||||
|
type of <tt>operator[]</tt> is a reference and the method is const, it is often indicative of the <i>setter</i>,
|
||||||
|
and and the <i>getter</i> is usually a const function return an object by value.
|
||||||
|
In the absence of any hard and fast rules and the fact that there may be multiple index operators,
|
||||||
|
it is up to the user to choose the getter and setter to use by using %rename as shown earlier.
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
|
|
||||||
<li>The semantics of certain C++ operators may not match those in the target language.
|
<li>The semantics of certain C++ operators may not match those in the target language.
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<H2><a name="SWIGPlus_class_extension"></a>6.17 Class extension</H2>
|
<H2><a name="SWIGPlus_class_extension">6.17 Class extension</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2867,7 +2888,7 @@ be used to extend a structure with more than just methods, a more suitable
|
||||||
directive name has been chosen.
|
directive name has been chosen.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="SWIGPlus_nn30"></a>6.18 Templates</H2>
|
<H2><a name="SWIGPlus_nn30">6.18 Templates</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3701,7 +3722,7 @@ as the class name. For example:
|
||||||
Similar changes apply to typemaps and other customization features.
|
Similar changes apply to typemaps and other customization features.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="SWIGPlus_namespaces"></a>6.19 Namespaces</H2>
|
<H2><a name="SWIGPlus_namespaces">6.19 Namespaces</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -4150,7 +4171,7 @@ with any namespace awareness. In the future, language modules may or may not p
|
||||||
more advanced namespace support.
|
more advanced namespace support.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="SWIGPlus_nspace"></a>6.19.1 The nspace feature for namespaces</H3>
|
<H3><a name="SWIGPlus_nspace">6.19.1 The nspace feature for namespaces</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -4231,7 +4252,7 @@ namespace MyWorld {
|
||||||
<b>Compatibility Note:</b> The nspace feature was first introduced in SWIG-2.0.0.
|
<b>Compatibility Note:</b> The nspace feature was first introduced in SWIG-2.0.0.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="SWIGPlus_renaming_templated_types_namespaces"></a>6.20 Renaming templated types in namespaces</H2>
|
<H2><a name="SWIGPlus_renaming_templated_types_namespaces">6.20 Renaming templated types in namespaces</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -4309,7 +4330,7 @@ namespace Space {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="SWIGPlus_exception_specifications"></a>6.21 Exception specifications</H2>
|
<H2><a name="SWIGPlus_exception_specifications">6.21 Exception specifications</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -4360,7 +4381,7 @@ Consult the "<a href="Customization.html#Customization_exception">Exception hand
|
||||||
The next section details a way of simulating an exception specification or replacing an existing one.
|
The next section details a way of simulating an exception specification or replacing an existing one.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="SWIGPlus_catches"></a>6.22 Exception handling with %catches</H2>
|
<H2><a name="SWIGPlus_catches">6.22 Exception handling with %catches</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -4410,7 +4431,7 @@ just a single catch handler for the base class, <tt>EBase</tt> will be generated
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="SWIGPlus_nn33"></a>6.23 Pointers to Members</H2>
|
<H2><a name="SWIGPlus_nn33">6.23 Pointers to Members</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -4460,7 +4481,7 @@ when checking types. However, no such support is currently provided
|
||||||
for member pointers.
|
for member pointers.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="SWIGPlus_smart_pointers"></a>6.24 Smart pointers and operator->()</H2>
|
<H2><a name="SWIGPlus_smart_pointers">6.24 Smart pointers and operator->()</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -4672,11 +4693,12 @@ p = f.__deref__() # Raw pointer from operator->
|
||||||
<b>Note:</b> Smart pointer support was first added in SWIG-1.3.14.
|
<b>Note:</b> Smart pointer support was first added in SWIG-1.3.14.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="SWIGPlus_ref_unref"></a>6.25 C++ reference counted objects - ref/unref feature</H2>
|
<H2><a name="SWIGPlus_ref_unref">6.25 C++ reference counted objects - ref/unref feature</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Another similar idiom in C++ is the use of reference counted objects. Consider for example:
|
Another similar idiom in C++ is the use of reference counted objects. Consider for example:
|
||||||
|
</p>
|
||||||
|
|
||||||
<div class="code">
|
<div class="code">
|
||||||
<pre>
|
<pre>
|
||||||
|
|
@ -4844,7 +4866,7 @@ exit # 'a' is released, SWIG unref 'a' called in the destructor wra
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="SWIGPlus_nn35"></a>6.26 Using declarations and inheritance</H2>
|
<H2><a name="SWIGPlus_nn35">6.26 Using declarations and inheritance</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -5007,7 +5029,7 @@ public:
|
||||||
</div>
|
</div>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<H2><a name="SWIGPlus_nested_classes"></a>6.27 Nested classes</H2>
|
<H2><a name="SWIGPlus_nested_classes">6.27 Nested classes</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -5071,7 +5093,7 @@ Nested class warnings could also not be suppressed using %warnfilter.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="SWIGPlus_const"></a>6.28 A brief rant about const-correctness</H2>
|
<H2><a name="SWIGPlus_const">6.28 A brief rant about const-correctness</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -5129,7 +5151,7 @@ using another tool if maintaining constness is the most important part
|
||||||
of your project.
|
of your project.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="SWIGPlus_nn42"></a>6.29 Where to go for more information</H2>
|
<H2><a name="SWIGPlus_nn42">6.29 Where to go for more information</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,15 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>SWIG and Scilab</title>
|
<title>SWIG and Scilab</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
|
|
||||||
<H1><a name="Scilab"></a>39 SWIG and Scilab</H1>
|
<H1><a name="Scilab">39 SWIG and Scilab</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -39,11 +40,12 @@
|
||||||
<li><a href="#Scilab_wrapping_pointers">Pointers</a>
|
<li><a href="#Scilab_wrapping_pointers">Pointers</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#Scilab_wrapping_pointers_pointer_adresses">Utility functions</a>
|
<li><a href="#Scilab_wrapping_pointers_pointer_adresses">Utility functions</a>
|
||||||
<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_cpp_overloading">C++ overloading</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>
|
||||||
<li><a href="#Scilab_wrapping_cpp_operators">C++ operators</a>
|
<li><a href="#Scilab_wrapping_cpp_operators">C++ operators</a>
|
||||||
|
|
@ -54,7 +56,6 @@
|
||||||
<li><a href="#Scilab_typemaps">Type mappings and libraries</a>
|
<li><a href="#Scilab_typemaps">Type mappings and libraries</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#Scilab_typemaps_primitive_types">Default primitive type mappings</a>
|
<li><a href="#Scilab_typemaps_primitive_types">Default primitive type mappings</a>
|
||||||
<li><a href="#Scilab_typemaps_non-primitive_types">Default type mappings for non-primitive types</a>
|
|
||||||
<li><a href="#Scilab_typemaps_arrays">Arrays</a>
|
<li><a href="#Scilab_typemaps_arrays">Arrays</a>
|
||||||
<li><a href="#Scilab_typemaps_pointer-to-pointers">Pointer-to-pointers</a>
|
<li><a href="#Scilab_typemaps_pointer-to-pointers">Pointer-to-pointers</a>
|
||||||
<li><a href="#Scilab_typemaps_matrices">Matrices</a>
|
<li><a href="#Scilab_typemaps_matrices">Matrices</a>
|
||||||
|
|
@ -87,7 +88,7 @@ This chapter explains how to use SWIG for Scilab. After this introduction, you s
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="Scilab_preliminaries"></a>39.1 Preliminaries</H2>
|
<H2><a name="Scilab_preliminaries">39.1 Preliminaries</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -104,7 +105,7 @@ SWIG for Scilab supports C language. C++ is partially supported. See <a href="#S
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="Scilab_running_swig"></a>39.2 Running SWIG</H2>
|
<H2><a name="Scilab_running_swig">39.2 Running SWIG</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -138,7 +139,7 @@ Note: a code in an <tt>%inline</tt> section is both parsed and wrapped by SWIG,
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Scilab_running_swig_generating_module"></a>39.2.1 Generating the module</H3>
|
<H3><a name="Scilab_running_swig_generating_module">39.2.1 Generating the module</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -181,7 +182,7 @@ The <tt>swig</tt> executable has several other command line options you can use.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Scilab_running_swig_building_module"></a>39.2.2 Building the module</H3>
|
<H3><a name="Scilab_running_swig_building_module">39.2.2 Building the module</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -201,7 +202,7 @@ $ gcc -shared example_wrap.o -o libexample.so
|
||||||
Note: we supposed in this example that the path to the Scilab include directory is <tt>/usr/local/include/scilab</tt> (which is the case in a Debian environment), this should be changed for another environment.
|
Note: we supposed in this example that the path to the Scilab include directory is <tt>/usr/local/include/scilab</tt> (which is the case in a Debian environment), this should be changed for another environment.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Scilab_running_swig_loading_module"></a>39.2.3 Loading the module</H3>
|
<H3><a name="Scilab_running_swig_loading_module">39.2.3 Loading the module</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -225,7 +226,7 @@ Link done.
|
||||||
which means that Scilab has successfully loaded the shared library. The module functions and other symbols are now available in Scilab.
|
which means that Scilab has successfully loaded the shared library. The module functions and other symbols are now available in Scilab.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Scilab_running_swig_using_module"></a>39.2.4 Using the module</H3>
|
<H3><a name="Scilab_running_swig_using_module">39.2.4 Using the module</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -259,7 +260,7 @@ ans =
|
||||||
Note: for conciseness, we assume in the subsequent Scilab code examples that the modules have been beforehand built and loaded in Scilab.
|
Note: for conciseness, we assume in the subsequent Scilab code examples that the modules have been beforehand built and loaded in Scilab.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Scilab_running_swig_options"></a>39.2.5 Scilab command line options</H3>
|
<H3><a name="Scilab_running_swig_options">39.2.5 Scilab command line options</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -314,19 +315,19 @@ $ swig -scilab -help
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="Scilab_wrapping"></a>39.3 A basic tour of C/C++ wrapping</H2>
|
<H2><a name="Scilab_wrapping">39.3 A basic tour of C/C++ wrapping</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Scilab_wrapping_overview"></a>39.3.1 Overview</H3>
|
<H3><a name="Scilab_wrapping_overview">39.3.1 Overview</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
SWIG for Scilab provides only a low-level C interface for Scilab (see <a href="Scripting.html">Scripting Languages</a> for the general approach to wrapping).
|
SWIG for Scilab provides only a low-level C interface for Scilab (see <a href="Scripting.html#Scripting">Scripting Languages</a> for the general approach to wrapping).
|
||||||
This means that functions, structs, classes, variables, etc... are interfaced through C functions. These C functions are mapped as Scilab functions.
|
This means that functions, structs, classes, variables, etc... are interfaced through C functions. These C functions are mapped as Scilab functions.
|
||||||
There are a few exceptions, such as constants and enumerations, which can be wrapped directly as Scilab variables.
|
There are a few exceptions, such as constants and enumerations, which can be wrapped directly as Scilab variables.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Scilab_wrapping_identifiers"></a>39.3.2 Identifiers</H3>
|
<H3><a name="Scilab_wrapping_identifiers">39.3.2 Identifiers</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -337,7 +338,7 @@ In Scilab 5.x, identifier names are composed of 24 characters maximum (this limi
|
||||||
In these cases, the <a href="SWIG.html#SWIG_rename_ignore">%rename directive</a> can be used to choose a different Scilab name.
|
In these cases, the <a href="SWIG.html#SWIG_rename_ignore">%rename directive</a> can be used to choose a different Scilab name.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Scilab_wrapping_functions"></a>39.3.3 Functions</H3>
|
<H3><a name="Scilab_wrapping_functions">39.3.3 Functions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -368,7 +369,7 @@ ans =
|
||||||
24.
|
24.
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H4><a name="Scilab_nn13"></a>39.3.3.1 Argument passing</H4>
|
<H4><a name="Scilab_nn13">39.3.3.1 Argument passing</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -421,7 +422,7 @@ In Scilab, parameters are passed by value. The output (and inout) parameters are
|
||||||
7.
|
7.
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H4><a name="Scilab_nn14"></a>39.3.3.2 Multiple output arguments</H4>
|
<H4><a name="Scilab_nn14">39.3.3.2 Multiple output arguments</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -447,8 +448,9 @@ int divide(int n, int d, int q*, int *r) {
|
||||||
*q = n / d;
|
*q = n / d;
|
||||||
*r = n % d;
|
*r = n % d;
|
||||||
return 1;
|
return 1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
else return 0;
|
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
@ -469,7 +471,7 @@ int divide(int n, int d, int q*, int *r) {
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Scilab_wrapping_global_variables"></a>39.3.4 Global variables</H3>
|
<H3><a name="Scilab_wrapping_global_variables">39.3.4 Global variables</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -538,10 +540,10 @@ It works the same:</p>
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Scilab_wrapping_constants_and_enums"></a>39.3.5 Constants and enumerations</H3>
|
<H3><a name="Scilab_wrapping_constants_and_enums">39.3.5 Constants and enumerations</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<H4><a name="Scilab_wrapping_constants"></a>39.3.5.1 Constants</H4>
|
<H4><a name="Scilab_wrapping_constants">39.3.5.1 Constants</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -682,7 +684,7 @@ are mapped to Scilab variables, with the same name:
|
||||||
3.14
|
3.14
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H4><a name="Scilab_wrapping_enums"></a>39.3.5.2 Enumerations</H4>
|
<H4><a name="Scilab_wrapping_enums">39.3.5.2 Enumerations</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -747,15 +749,29 @@ typedef enum { RED, BLUE, GREEN } color;
|
||||||
|
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Scilab_wrapping_pointers"></a>39.3.6 Pointers</H3>
|
<H3><a name="Scilab_wrapping_pointers">39.3.6 Pointers</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
C/C++ pointers are fully supported by SWIG. They are mapped to the Scilab pointer type ("pointer", type ID: 128).
|
Pointers are supported by SWIG. A pointer can be returned from a wrapped C/C++ function, stored in a Scilab variable, and used in input argument of another C/C++ function.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Also, thanks to the SWIG runtime which stores informations about types, pointer types are tracked between exchanges Scilab and the native code. Indeed pointer types are stored alongside the pointer adress.
|
||||||
|
A pointer is mapped to a Scilab structure (<a href="https://help.scilab.org/docs/5.5.2/en_US/tlist.html">tlist</a>), which contains as fields the pointer address and the pointer type (in fact a pointer to the type information structure in the SWIG runtime).
|
||||||
|
<br>
|
||||||
|
Why a native pointer is not mapped to a Scilab pointer (type name: "pointer", type ID: 128) ? The big advantage of mapping to a <tt>tlist</tt> is that it exposes a new type for the pointer in Scilab, type which can be acessed in Scilab with the <a href="https://help.scilab.org/docs/5.5.2/en_US/typeof.html">typeof</a> function, and manipulated using the <a href="https://help.scilab.org/docs/5.5.2/en_US/overloading.html">overloading</a> mechanism.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Given a wrapping of some of the C file functions:
|
Notes:
|
||||||
|
</p>
|
||||||
|
<ul>
|
||||||
|
<li>type tracking needs the SWIG runtime to be first initialized with the appropriate function (see the <a href="#Scilab_module_initialization">Module initialization</a> section).</li>
|
||||||
|
<li>for any reason, if a wrapped pointer type is unknown (or if the SWIG runtime is not initialized), SWIG maps it to a Scilab pointer. Also, a Scilab pointer is always accepted as a pointer argument of a wrapped function. The drawaback is that pointer type is lost.</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Following is an example of the wrapping of the C <tt>FILE*</tt> pointer:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="code"><pre>
|
<div class="code"><pre>
|
||||||
|
|
@ -771,29 +787,35 @@ int fclose(FILE *);
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
These functions can be used in a natural way from Scilab:
|
These functions can be used the same way as in C from Scilab:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="targetlang"><pre>
|
<div class="targetlang"><pre>
|
||||||
|
--> example_Init();
|
||||||
|
|
||||||
--> f = fopen("junk", "w");
|
--> f = fopen("junk", "w");
|
||||||
--> typeof(f)
|
--> typeof(f)
|
||||||
ans =
|
ans =
|
||||||
|
|
||||||
pointer
|
_p_FILE
|
||||||
|
|
||||||
--> fputs("Hello World", f);
|
--> fputs("Hello World", f);
|
||||||
--> fclose(f);
|
--> fclose(f);
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Note: the type name <tt>_p_FILE</tt> which means "pointer to FILE".
|
||||||
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
The user of a pointer is responsible for freeing it or, like in the example, closing any resources associated with it (just as is required in a C program).
|
The user of a pointer is responsible for freeing it or, like in the example, closing any resources associated with it (just as is required in a C program).
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H4><a name="Scilab_wrapping_pointers_pointer_adresses"></a>39.3.6.1 Utility functions</H4>
|
<H4><a name="Scilab_wrapping_pointers_pointer_adresses">39.3.6.1 Utility functions</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Most of time pointer manipulation is not needed in a scripting language such as Scilab.
|
As a scripting language, Scilab does not provide functions to manipulate pointers.
|
||||||
However, in some cases it can be useful, such as for testing or debugging.
|
However, in some cases it can be useful, such as for testing or debugging.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
@ -805,7 +827,11 @@ SWIG comes with two pointer utility functions:
|
||||||
<li><tt>SWIG_ptr()</tt>: creates a pointer from an address value</li>
|
<li><tt>SWIG_ptr()</tt>: creates a pointer from an address value</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<p>Following illustrates their use on the last example:</p>
|
<p>
|
||||||
|
Note: a pointer created by <tt>SWIG_ptr()</tt> does not have any type and is mapped as a Scilab pointer.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>Following we use the utility functions on the previous example:</p>
|
||||||
|
|
||||||
<div class="targetlang"><pre>
|
<div class="targetlang"><pre>
|
||||||
--> f = fopen("junk", "w");
|
--> f = fopen("junk", "w");
|
||||||
|
|
@ -816,15 +842,21 @@ SWIG comes with two pointer utility functions:
|
||||||
8219088.
|
8219088.
|
||||||
|
|
||||||
--> p = SWIG_ptr(addr);
|
--> p = SWIG_ptr(addr);
|
||||||
|
--> typeof(p)
|
||||||
|
ans =
|
||||||
|
|
||||||
|
pointer
|
||||||
|
|
||||||
--> fputs(" World", p);
|
--> fputs(" World", p);
|
||||||
--> fclose(f);
|
--> fclose(f);
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H4><a name="Scilab_wrapping_pointers_null_pointers"></a>39.3.6.2 Null pointers</H4>
|
|
||||||
|
<H4><a name="Scilab_wrapping_pointers_null_pointers">39.3.6.2 Null pointers:</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>By default, Scilab does not provide a way to test or create null pointers.
|
<p>
|
||||||
But it is possible to have a null pointer by using the previous functions <tt>SWIG_this()</tt> and <tt>SWIG_ptr()</tt>, like this:
|
Using the previous <tt>SWIG_this()</tt> and <tt>SWIG_ptr()</tt>, it is possible to create and check null pointers:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="targetlang"><pre>
|
<div class="targetlang"><pre>
|
||||||
|
|
@ -836,7 +868,7 @@ But it is possible to have a null pointer by using the previous functions <tt>SW
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Scilab_wrapping_structs"></a>39.3.7 Structures</H3>
|
<H3><a name="Scilab_wrapping_structs">39.3.7 Structures</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -872,6 +904,7 @@ Several functions are generated:
|
||||||
<li>a destructor function <tt>delete_Foo()</tt> to release the struct pointer.</li>
|
<li>a destructor function <tt>delete_Foo()</tt> to release the struct pointer.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Usage example:
|
Usage example:
|
||||||
</p>
|
</p>
|
||||||
|
|
@ -930,8 +963,21 @@ ans =
|
||||||
20.
|
20.
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Note: the pointer to the struct works as described in <a href="Scilab_wrapping_pointers">Pointers</a>. For example, the type of the struct pointer can be get with <tt>typeof</tt>, as following:
|
||||||
|
</p>
|
||||||
|
|
||||||
<H3><a name="Scilab_wrapping_cpp_classes"></a>39.3.8 C++ classes</H3>
|
<div class="targetlang"><pre>
|
||||||
|
--> example_Init();
|
||||||
|
--> b = new_Bar();
|
||||||
|
--> typeof(b)
|
||||||
|
ans =
|
||||||
|
|
||||||
|
_p_Bar
|
||||||
|
--> delete_Bar(b);
|
||||||
|
</pre></div>
|
||||||
|
|
||||||
|
<H3><a name="Scilab_wrapping_cpp_classes">39.3.8 C++ classes</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -981,7 +1027,25 @@ ans =
|
||||||
--> delete_Point(p2);
|
--> delete_Point(p2);
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Scilab_wrapping_cpp_inheritance"></a>39.3.9 C++ inheritance</H3>
|
<p>
|
||||||
|
Note: like structs, class pointers are mapped as described in <a href="Scilab_wrapping_pointers">Pointers</a>. Let's give an example which shows that each class pointer type is a new type in Scilab that can be used for example (through <a href="https://help.scilab.org/docs/5.5.2/en_US/overloading.html">overloading</a>) to implement a custom print for the <tt>Point</tt> class:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="targetlang"><pre>
|
||||||
|
--> function %_p_Point_p(p)
|
||||||
|
--> mprintf('[%d, %d]\n', Point_x_get(p), Point_y_get(p));
|
||||||
|
--> endfunction
|
||||||
|
|
||||||
|
--> example_Init();
|
||||||
|
--> p = new_Point(1, 2)
|
||||||
|
p =
|
||||||
|
|
||||||
|
[1, 2]
|
||||||
|
|
||||||
|
--> delete_Point(p);
|
||||||
|
</pre></div>
|
||||||
|
|
||||||
|
<H3><a name="Scilab_wrapping_cpp_inheritance">39.3.9 C++ inheritance</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1056,7 +1120,47 @@ But we can use either use the <tt>get_perimeter()</tt> function of the parent cl
|
||||||
18.84
|
18.84
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Scilab_wrapping_pointers_references_values_arrays"></a>39.3.10 Pointers, references, values, and arrays</H3>
|
<H3><a name="Scilab_wrapping_cpp_overloading">39.3.10 C++ overloading</a></H3>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
As explained in <a href="SWIGPlus.html#SWIGPlus_overloaded_methods">6.15</a> SWIG provides support for overloaded functions and constructors.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>As SWIG knows pointer types, the overloading works also with pointer types, here is is an example with a function <tt>magnify</tt> overloaded for the previous classes <tt>Shape</tt> and <tt>Circle</tt>:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="code"><pre>
|
||||||
|
%module example
|
||||||
|
|
||||||
|
void magnify(Square *square, double factor) {
|
||||||
|
square->size *= factor;
|
||||||
|
};
|
||||||
|
|
||||||
|
void magnify(Circle *circle, double factor) {
|
||||||
|
square->radius *= factor;
|
||||||
|
};
|
||||||
|
</pre></div>
|
||||||
|
|
||||||
|
<div class="targetlang"><pre>
|
||||||
|
--> example_Init();
|
||||||
|
--> c = new_Circle(3);
|
||||||
|
--> s = new_Square(2);
|
||||||
|
|
||||||
|
--> magnify(c, 10);
|
||||||
|
--> Circle_get_radius(c)
|
||||||
|
ans =
|
||||||
|
|
||||||
|
30;
|
||||||
|
--> magnify(s, 10);
|
||||||
|
--> Square_get_size(s)
|
||||||
|
ans =
|
||||||
|
|
||||||
|
20;
|
||||||
|
</pre></div>
|
||||||
|
|
||||||
|
|
||||||
|
<H3><a name="Scilab_wrapping_pointers_references_values_arrays">39.3.11 Pointers, references, values, and arrays</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1114,7 +1218,7 @@ All these functions will return a pointer to an instance of <tt>Foo</tt>.
|
||||||
As the function <tt>spam7</tt> returns a value, new instance of <tt>Foo</tt> has to be allocated, and a pointer on this instance is returned.
|
As the function <tt>spam7</tt> returns a value, new instance of <tt>Foo</tt> has to be allocated, and a pointer on this instance is returned.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Scilab_wrapping_cpp_templates"></a>39.3.11 C++ templates</H3>
|
<H3><a name="Scilab_wrapping_cpp_templates">39.3.12 C++ templates</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1122,8 +1226,7 @@ As in other languages, function and class templates are supported in SWIG Scilab
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
You have to tell SWIG to create wrappers for a particular
|
You have to tell SWIG to create wrappers for a particular template instantiation. The <tt>%template</tt> directive is used for this purpose.
|
||||||
template instantiation. The <tt>%template</tt> directive is used for this purpose.
|
|
||||||
For example:
|
For example:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
@ -1174,7 +1277,7 @@ Then in Scilab:
|
||||||
More details on template support can be found in the <a href="SWIGPlus.html#SWIGPlus_nn30">templates</a> documentation.
|
More details on template support can be found in the <a href="SWIGPlus.html#SWIGPlus_nn30">templates</a> documentation.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Scilab_wrapping_cpp_operators"></a>39.3.12 C++ operators</H3>
|
<H3><a name="Scilab_wrapping_cpp_operators">39.3.13 C++ operators</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1227,7 +1330,7 @@ private:
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Scilab_wrapping_cpp_namespaces"></a>39.3.13 C++ namespaces</H3>
|
<H3><a name="Scilab_wrapping_cpp_namespaces">39.3.14 C++ namespaces</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1301,11 +1404,11 @@ namespace Bar {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Note: the <a href="SWIGPlus.html#SWIGPlus_nspace"><tt>nspace</tt></a> feature is not supported.
|
Note: the <a href="SWIGPlus.html#SWIGPlus_nspace">nspace</a> feature is not supported.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Scilab_wrapping_cpp_exceptions"></a>39.3.14 C++ exceptions</H3>
|
<H3><a name="Scilab_wrapping_cpp_exceptions">39.3.15 C++ exceptions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1388,17 +1491,17 @@ More complex or custom exception types require specific exception typemaps to be
|
||||||
See the <a href="SWIGPlus.html#SWIGPlus">SWIG C++ documentation</a> for more details.
|
See the <a href="SWIGPlus.html#SWIGPlus">SWIG C++ documentation</a> for more details.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Scilab_wrapping_cpp_stl"></a>39.3.15 C++ STL</H3>
|
<H3><a name="Scilab_wrapping_cpp_stl">39.3.16 C++ STL</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
The Standard Template Library (STL) is partially supported. See <a href="#Scilab_typemaps_stl">STL</a> for more details.
|
The Standard Template Library (STL) is partially supported. See <a href="#Scilab_typemaps_stl">STL</a> for more details.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Scilab_typemaps"></a>39.4 Type mappings and libraries</H2>
|
<H2><a name="Scilab_typemaps">39.4 Type mappings and libraries</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Scilab_typemaps_primitive_types"></a>39.4.1 Default primitive type mappings</H3>
|
<H3><a name="Scilab_typemaps_primitive_types">39.4.1 Default primitive type mappings</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1447,15 +1550,9 @@ The default behaviour is for SWIG to generate code that will give a runtime erro
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Scilab_typemaps_non-primitive_types"></a>39.4.2 Default type mappings for non-primitive types</H3>
|
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<H3><a name="Scilab_typemaps_arrays">39.4.2 Arrays</a></H3>
|
||||||
The default mapped type for C/C++ non-primitive types is the Scilab pointer, for example for C structs, C++ classes, etc...
|
|
||||||
</p>
|
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Scilab_typemaps_arrays"></a>39.4.3 Arrays</H3>
|
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1510,7 +1607,7 @@ void printArray(int values[], int len) {
|
||||||
[ 0 1 2 3 ]
|
[ 0 1 2 3 ]
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Scilab_typemaps_pointer-to-pointers"></a>39.4.4 Pointer-to-pointers</H3>
|
<H3><a name="Scilab_typemaps_pointer-to-pointers">39.4.3 Pointer-to-pointers</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1583,7 +1680,7 @@ void print_matrix(double **M, int nbRows, int nbCols) {
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Scilab_typemaps_matrices"></a>39.4.5 Matrices</H3>
|
<H3><a name="Scilab_typemaps_matrices">39.4.4 Matrices</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1676,7 +1773,7 @@ The remarks made earlier for arrays also apply here:
|
||||||
<li>There is no control while converting <tt>double</tt> values to integers, <tt>double</tt> values are truncated without any checking or warning.</li>
|
<li>There is no control while converting <tt>double</tt> values to integers, <tt>double</tt> values are truncated without any checking or warning.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<H3><a name="Scilab_typemaps_stl"></a>39.4.6 STL</H3>
|
<H3><a name="Scilab_typemaps_stl">39.4.5 STL</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1876,15 +1973,15 @@ ans =
|
||||||
--> delete_PersonPtrSet(p);
|
--> delete_PersonPtrSet(p);
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H2><a name="Scilab_module_initialization"></a>39.5 Module initialization</H2>
|
<H2><a name="Scilab_module_initialization">39.5 Module initialization</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
The wrapped module contains an initialization function to:
|
The wrapped module contains an initialization function to:
|
||||||
</p>
|
</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>initialize the SWIG runtime, which is necessary when working with the STL</li>
|
<li>initialize the SWIG runtime, needed for pointer type tracking or when working with the STL</li>
|
||||||
<li>initialize in Scilab the module constants and enumerations declared with <tt>%scilabconst()</tt></li>
|
<li>initialize the module constants and enumerations declared with <tt>%scilabconst()</tt></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1900,7 +1997,7 @@ For example, to initialize the module <tt>example</tt>:
|
||||||
--> example_Init();
|
--> example_Init();
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H2><a name="Scilab_building_modes"></a>39.6 Building modes</H2>
|
<H2><a name="Scilab_building_modes">39.6 Building modes</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1915,7 +2012,7 @@ To produce a dynamic module, when generating the wrapper, there are two possibil
|
||||||
<li>the <tt>builder</tt> mode. In this mode, Scilab is responsible of building.
|
<li>the <tt>builder</tt> mode. In this mode, Scilab is responsible of building.
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<H3><a name="Scilab_building_modes_nobuilder_mode"></a>39.6.1 No-builder mode</H3>
|
<H3><a name="Scilab_building_modes_nobuilder_mode">39.6.1 No-builder mode</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1928,7 +2025,7 @@ This mode is the best option to use when you have to integrate the module build
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Scilab_building_modes_builder_mode"></a>39.6.2 Builder mode</H3>
|
<H3><a name="Scilab_building_modes_builder_mode">39.6.2 Builder mode</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1968,14 +2065,14 @@ The command is:
|
||||||
$ swig -scilab -builder -buildercflags -I/opt/foo/include -builderldflags "-L/opt/foo/lib -lfoo" -buildersources baa1.cxx,baa2.cxx example.i
|
$ swig -scilab -builder -buildercflags -I/opt/foo/include -builderldflags "-L/opt/foo/lib -lfoo" -buildersources baa1.cxx,baa2.cxx example.i
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H2><a name="Scilab_generated_scripts"></a>39.7 Generated scripts</H2>
|
<H2><a name="Scilab_generated_scripts">39.7 Generated scripts</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
In this part we give some details about the generated Scilab scripts.
|
In this part we give some details about the generated Scilab scripts.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Scilab_generated_scripts_builder_script"></a>39.7.1 Builder script</H3>
|
<H3><a name="Scilab_generated_scripts_builder_script">39.7.1 Builder script</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2000,7 +2097,7 @@ ilib_build(ilib_name,table,files,libs);
|
||||||
<li><tt><b>table</b></tt>: two column string matrix containing a table of pairs of 'scilab function name', 'C function name'.</li>
|
<li><tt><b>table</b></tt>: two column string matrix containing a table of pairs of 'scilab function name', 'C function name'.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<H3><a name="Scilab_generated_scripts_loader_script"></a>39.7.2 Loader script</H3>
|
<H3><a name="Scilab_generated_scripts_loader_script">39.7.2 Loader script</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2039,7 +2136,7 @@ clear get_file_path;
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="Scilab_other_resources"></a>39.8 Other resources</H2>
|
<H2><a name="Scilab_other_resources">39.8 Other resources</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Scripting Languages</title>
|
<title>Scripting Languages</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
<H1><a name="Scripting"></a>4 Scripting Languages</H1>
|
<H1><a name="Scripting">4 Scripting Languages</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -37,7 +38,7 @@ programming and the mechanisms by which scripting language interpreters
|
||||||
access C and C++ code.
|
access C and C++ code.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Scripting_nn2"></a>4.1 The two language view of the world</H2>
|
<H2><a name="Scripting_nn2">4.1 The two language view of the world</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -68,7 +69,7 @@ languages can be used for rapid prototyping, interactive debugging,
|
||||||
scripting, and access to high-level data structures such associative
|
scripting, and access to high-level data structures such associative
|
||||||
arrays. </p>
|
arrays. </p>
|
||||||
|
|
||||||
<H2><a name="Scripting_nn3"></a>4.2 How does a scripting language talk to C?</H2>
|
<H2><a name="Scripting_nn3">4.2 How does a scripting language talk to C?</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -93,7 +94,7 @@ function, arguments, and so forth. The next few sections illustrate
|
||||||
the process.
|
the process.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Scripting_nn4"></a>4.2.1 Wrapper functions</H3>
|
<H3><a name="Scripting_nn4">4.2.1 Wrapper functions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -101,8 +102,10 @@ Suppose you have an ordinary C function like this :</p>
|
||||||
|
|
||||||
<div class="code"><pre>
|
<div class="code"><pre>
|
||||||
int fact(int n) {
|
int fact(int n) {
|
||||||
if (n <= 1) return 1;
|
if (n <= 1)
|
||||||
else return n*fact(n-1);
|
return 1;
|
||||||
|
else
|
||||||
|
return n*fact(n-1);
|
||||||
}
|
}
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
|
|
@ -123,8 +126,7 @@ As an example, the Tcl wrapper function for the <tt>fact()</tt>
|
||||||
function above example might look like the following : </p>
|
function above example might look like the following : </p>
|
||||||
|
|
||||||
<div class="code"><pre>
|
<div class="code"><pre>
|
||||||
int wrap_fact(ClientData clientData, Tcl_Interp *interp,
|
int wrap_fact(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) {
|
||||||
int argc, char *argv[]) {
|
|
||||||
int result;
|
int result;
|
||||||
int arg0;
|
int arg0;
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
|
|
@ -165,7 +167,7 @@ Python. Both require special wrappers to be written and both need
|
||||||
additional initialization code. Only the specific details are
|
additional initialization code. Only the specific details are
|
||||||
different.</p>
|
different.</p>
|
||||||
|
|
||||||
<H3><a name="Scripting_nn5"></a>4.2.2 Variable linking</H3>
|
<H3><a name="Scripting_nn5">4.2.2 Variable linking</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -201,7 +203,7 @@ typing <tt>$Foo = 4</tt> would call the underlying set function to change
|
||||||
the value.
|
the value.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Scripting_nn6"></a>4.2.3 Constants</H3>
|
<H3><a name="Scripting_nn6">4.2.3 Constants</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -222,7 +224,7 @@ functions for creating variables so installing constants is usually
|
||||||
a trivial exercise.
|
a trivial exercise.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Scripting_nn7"></a>4.2.4 Structures and classes</H3>
|
<H3><a name="Scripting_nn7">4.2.4 Structures and classes</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -283,7 +285,7 @@ internals of an object, the interpreter does not need to know anything
|
||||||
about the actual representation of a <tt>Vector</tt>.
|
about the actual representation of a <tt>Vector</tt>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Scripting_nn8"></a>4.2.5 Proxy classes</H3>
|
<H3><a name="Scripting_nn8">4.2.5 Proxy classes</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -345,7 +347,7 @@ affect both objects equally and for all practical purposes, it appears
|
||||||
as if you are simply manipulating a C/C++ object.
|
as if you are simply manipulating a C/C++ object.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Scripting_nn9"></a>4.3 Building scripting language extensions</H2>
|
<H2><a name="Scripting_nn9">4.3 Building scripting language extensions</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -358,7 +360,7 @@ recompile the scripting language interpreter with your extensions
|
||||||
added to it.
|
added to it.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Scripting_nn10"></a>4.3.1 Shared libraries and dynamic loading</H3>
|
<H3><a name="Scripting_nn10">4.3.1 Shared libraries and dynamic loading</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -400,7 +402,7 @@ changing the link line to the following :</p>
|
||||||
c++ -shared example.o example_wrap.o -o example.so
|
c++ -shared example.o example_wrap.o -o example.so
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Scripting_nn11"></a>4.3.2 Linking with shared libraries</H3>
|
<H3><a name="Scripting_nn11">4.3.2 Linking with shared libraries</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -447,7 +449,7 @@ the path using linker options instead.
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<H3><a name="Scripting_nn12"></a>4.3.3 Static linking</H3>
|
<H3><a name="Scripting_nn12">4.3.3 Static linking</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,19 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>SWIG-3.0 Documentation</title>
|
<title>SWIG-3.0 Documentation</title>
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
<H1><a name="Sections"></a>SWIG-3.0 Documentation</H1>
|
<H1><a name="Sections">SWIG-3.0 Documentation</a></H1>
|
||||||
|
|
||||||
Last update : SWIG-3.0.7 (in progress)
|
<p>
|
||||||
|
Last update : SWIG-3.0.11 (in progress)
|
||||||
|
</p>
|
||||||
|
|
||||||
<H2>Sections</H2>
|
<H2><a name="Sections_Sections">Sections</a></H2>
|
||||||
|
|
||||||
<H3>SWIG Core Documentation</H3>
|
<H3><a name="Sections_core_docs">SWIG Core Documentation</a></H3>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="Preface.html#Preface">Preface</a></li>
|
<li><a href="Preface.html#Preface">Preface</a></li>
|
||||||
<li><a href="Introduction.html#Introduction">Introduction</a></li>
|
<li><a href="Introduction.html#Introduction">Introduction</a></li>
|
||||||
|
|
@ -31,7 +34,7 @@ Last update : SWIG-3.0.7 (in progress)
|
||||||
<li><a href="CCache.html#CCache">Using SWIG with ccache</a></li>
|
<li><a href="CCache.html#CCache">Using SWIG with ccache</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<H3>Language Module Documentation</H3>
|
<H3><a name="Sections_language_modules">Language Module Documentation</a></H3>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="Allegrocl.html#Allegrocl">Allegro Common Lisp support</a></li>
|
<li><a href="Allegrocl.html#Allegrocl">Allegro Common Lisp support</a></li>
|
||||||
|
|
@ -59,7 +62,7 @@ Last update : SWIG-3.0.7 (in progress)
|
||||||
<li><a href="Tcl.html#Tcl">Tcl support</a></li>
|
<li><a href="Tcl.html#Tcl">Tcl support</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<H3>Developer Documentation</H3>
|
<H3><a name="Sections_developers_docs">Developer Documentation</a></H3>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="Extending.html#Extending">Extending SWIG</a></li>
|
<li><a href="Extending.html#Extending">Extending SWIG</a></li>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>SWIG and Tcl</title>
|
<title>SWIG and Tcl</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
<H1><a name="Tcl"></a>40 SWIG and Tcl</H1>
|
<H1><a name="Tcl">40 SWIG and Tcl</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -83,7 +84,7 @@ Tcl 8.0 or a later release. Earlier releases of SWIG supported Tcl 7.x, but
|
||||||
this is no longer supported.
|
this is no longer supported.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Tcl_nn2"></a>40.1 Preliminaries</H2>
|
<H2><a name="Tcl_nn2">40.1 Preliminaries</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -109,7 +110,7 @@ build a Tcl extension module. To finish building the module, you
|
||||||
need to compile this file and link it with the rest of your program.
|
need to compile this file and link it with the rest of your program.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn3"></a>40.1.1 Getting the right header files</H3>
|
<H3><a name="Tcl_nn3">40.1.1 Getting the right header files</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -127,7 +128,7 @@ this is the case, you should probably make a symbolic link so that <tt>tcl.h</tt
|
||||||
header file.
|
header file.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn4"></a>40.1.2 Compiling a dynamic module</H3>
|
<H3><a name="Tcl_nn4">40.1.2 Compiling a dynamic module</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -163,7 +164,7 @@ The name of the module is specified using the <tt>%module</tt> directive or the
|
||||||
<tt>-module</tt> command line option.
|
<tt>-module</tt> command line option.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn5"></a>40.1.3 Static linking</H3>
|
<H3><a name="Tcl_nn5">40.1.3 Static linking</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -229,7 +230,7 @@ minimal in most situations (and quite frankly not worth the extra
|
||||||
hassle in the opinion of this author).
|
hassle in the opinion of this author).
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn6"></a>40.1.4 Using your module</H3>
|
<H3><a name="Tcl_nn6">40.1.4 Using your module</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -357,7 +358,7 @@ to the default system configuration (this requires root access and you will need
|
||||||
the man pages).
|
the man pages).
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn7"></a>40.1.5 Compilation of C++ extensions</H3>
|
<H3><a name="Tcl_nn7">40.1.5 Compilation of C++ extensions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -440,7 +441,7 @@ erratic program behavior. If working with lots of software components, you
|
||||||
might want to investigate using a more formal standard such as COM.
|
might want to investigate using a more formal standard such as COM.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn8"></a>40.1.6 Compiling for 64-bit platforms</H3>
|
<H3><a name="Tcl_nn8">40.1.6 Compiling for 64-bit platforms</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -467,7 +468,7 @@ also introduce problems on platforms that support more than one
|
||||||
linking standard (e.g., -o32 and -n32 on Irix).
|
linking standard (e.g., -o32 and -n32 on Irix).
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn9"></a>40.1.7 Setting a package prefix</H3>
|
<H3><a name="Tcl_nn9">40.1.7 Setting a package prefix</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -486,7 +487,7 @@ option will append the prefix to the name when creating a command and
|
||||||
call it "<tt>Foo_bar</tt>".
|
call it "<tt>Foo_bar</tt>".
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn10"></a>40.1.8 Using namespaces</H3>
|
<H3><a name="Tcl_nn10">40.1.8 Using namespaces</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -508,7 +509,7 @@ When the <tt>-namespace</tt> option is used, objects in the module
|
||||||
are always accessed with the namespace name such as <tt>Foo::bar</tt>.
|
are always accessed with the namespace name such as <tt>Foo::bar</tt>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Tcl_nn11"></a>40.2 Building Tcl/Tk Extensions under Windows 95/NT</H2>
|
<H2><a name="Tcl_nn11">40.2 Building Tcl/Tk Extensions under Windows 95/NT</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -519,7 +520,7 @@ covers the process of using SWIG with Microsoft Visual C++.
|
||||||
although the procedure may be similar with other compilers.
|
although the procedure may be similar with other compilers.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn12"></a>40.2.1 Running SWIG from Developer Studio</H3>
|
<H3><a name="Tcl_nn12">40.2.1 Running SWIG from Developer Studio</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -577,7 +578,7 @@ MSDOS > tclsh80
|
||||||
%
|
%
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn13"></a>40.2.2 Using NMAKE</H3>
|
<H3><a name="Tcl_nn13">40.2.2 Using NMAKE</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -625,7 +626,7 @@ CFLAGS = /Z7 /Od /c /nologo
|
||||||
TCL_INCLUDES = -Id:\tcl8.0a2\generic -Id:\tcl8.0a2\win
|
TCL_INCLUDES = -Id:\tcl8.0a2\generic -Id:\tcl8.0a2\win
|
||||||
TCLLIB = d:\tcl8.0a2\win\tcl80.lib
|
TCLLIB = d:\tcl8.0a2\win\tcl80.lib
|
||||||
|
|
||||||
tcl::
|
tcl:
|
||||||
..\..\swig -tcl -o $(WRAPFILE) $(INTERFACE)
|
..\..\swig -tcl -o $(WRAPFILE) $(INTERFACE)
|
||||||
$(CC) $(CFLAGS) $(TCL_INCLUDES) $(SRCS) $(WRAPFILE)
|
$(CC) $(CFLAGS) $(TCL_INCLUDES) $(SRCS) $(WRAPFILE)
|
||||||
set LIB=$(TOOLS)\lib
|
set LIB=$(TOOLS)\lib
|
||||||
|
|
@ -640,7 +641,7 @@ to get you started. With a little practice, you'll be making lots of
|
||||||
Tcl extensions.
|
Tcl extensions.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Tcl_nn14"></a>40.3 A tour of basic C/C++ wrapping</H2>
|
<H2><a name="Tcl_nn14">40.3 A tour of basic C/C++ wrapping</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -651,7 +652,7 @@ classes. This section briefly covers the essential aspects of this
|
||||||
wrapping.
|
wrapping.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn15"></a>40.3.1 Modules</H3>
|
<H3><a name="Tcl_nn15">40.3.1 Modules</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -685,7 +686,7 @@ To fix this, supply an extra argument to <tt>load</tt> like this:
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn16"></a>40.3.2 Functions</H3>
|
<H3><a name="Tcl_nn16">40.3.2 Functions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -710,7 +711,7 @@ like you think it does:
|
||||||
%
|
%
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn17"></a>40.3.3 Global variables</H3>
|
<H3><a name="Tcl_nn17">40.3.3 Global variables</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -790,7 +791,7 @@ extern char *path; // Read-only (due to %immutable)
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn18"></a>40.3.4 Constants and enums</H3>
|
<H3><a name="Tcl_nn18">40.3.4 Constants and enums</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -874,7 +875,7 @@ When an identifier name is given, it is used to perform an implicit hash-table l
|
||||||
conversion. This allows the <tt>global</tt> statement to be omitted.
|
conversion. This allows the <tt>global</tt> statement to be omitted.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn19"></a>40.3.5 Pointers</H3>
|
<H3><a name="Tcl_nn19">40.3.5 Pointers</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -970,7 +971,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return
|
||||||
<tt>None</tt> if the conversion can't be performed.
|
<tt>None</tt> if the conversion can't be performed.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn20"></a>40.3.6 Structures</H3>
|
<H3><a name="Tcl_nn20">40.3.6 Structures</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1252,7 +1253,7 @@ Note: Tcl only destroys the underlying object if it has ownership. See the
|
||||||
memory management section that appears shortly.
|
memory management section that appears shortly.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn21"></a>40.3.7 C++ classes</H3>
|
<H3><a name="Tcl_nn21">40.3.7 C++ classes</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1303,7 +1304,6 @@ class Spam {
|
||||||
public:
|
public:
|
||||||
static void foo();
|
static void foo();
|
||||||
static int bar;
|
static int bar;
|
||||||
|
|
||||||
};
|
};
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -1319,7 +1319,7 @@ In Tcl, the static member is accessed as follows:
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn22"></a>40.3.8 C++ inheritance</H3>
|
<H3><a name="Tcl_nn22">40.3.8 C++ inheritance</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1368,7 +1368,7 @@ For instance:
|
||||||
It is safe to use multiple inheritance with SWIG.
|
It is safe to use multiple inheritance with SWIG.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn23"></a>40.3.9 Pointers, references, values, and arrays</H3>
|
<H3><a name="Tcl_nn23">40.3.9 Pointers, references, values, and arrays</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1422,7 +1422,7 @@ to hold the result and a pointer is returned (Tcl will release this memory
|
||||||
when the return value is garbage collected).
|
when the return value is garbage collected).
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn24"></a>40.3.10 C++ overloaded functions</H3>
|
<H3><a name="Tcl_nn24">40.3.10 C++ overloaded functions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1545,7 +1545,7 @@ first declaration takes precedence.
|
||||||
Please refer to the "SWIG and C++" chapter for more information about overloading.
|
Please refer to the "SWIG and C++" chapter for more information about overloading.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn25"></a>40.3.11 C++ operators</H3>
|
<H3><a name="Tcl_nn25">40.3.11 C++ operators</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1647,7 +1647,7 @@ There are ways to make this operator appear as part of the class using the <tt>%
|
||||||
Keep reading.
|
Keep reading.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn26"></a>40.3.12 C++ namespaces</H3>
|
<H3><a name="Tcl_nn26">40.3.12 C++ namespaces</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1711,7 +1711,7 @@ utilizes thousands of small deeply nested namespaces each with
|
||||||
identical symbol names, well, then you get what you deserve.
|
identical symbol names, well, then you get what you deserve.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn27"></a>40.3.13 C++ templates</H3>
|
<H3><a name="Tcl_nn27">40.3.13 C++ templates</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1763,7 +1763,7 @@ More details can be found in the <a href="SWIGPlus.html#SWIGPlus">SWIG and C++</
|
||||||
examples will appear later.
|
examples will appear later.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn28"></a>40.3.14 C++ Smart Pointers</H3>
|
<H3><a name="Tcl_nn28">40.3.14 C++ Smart Pointers</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1847,7 +1847,7 @@ simply use the <tt>__deref__()</tt> method. For example:
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H2><a name="Tcl_nn29"></a>40.4 Further details on the Tcl class interface</H2>
|
<H2><a name="Tcl_nn29">40.4 Further details on the Tcl class interface</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1860,7 +1860,7 @@ of low-level details were omitted. This section provides a brief overview
|
||||||
of how the proxy classes work.
|
of how the proxy classes work.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn30"></a>40.4.1 Proxy classes</H3>
|
<H3><a name="Tcl_nn30">40.4.1 Proxy classes</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1925,7 +1925,7 @@ function. This allows objects to be encapsulated objects that look a lot like
|
||||||
as shown in the last section.
|
as shown in the last section.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn31"></a>40.4.2 Memory management</H3>
|
<H3><a name="Tcl_nn31">40.4.2 Memory management</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2113,7 +2113,7 @@ typemaps--an advanced topic discussed later.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="Tcl_nn32"></a>40.5 Input and output parameters</H2>
|
<H2><a name="Tcl_nn32">40.5 Input and output parameters</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2301,7 +2301,7 @@ set c [lindex $dim 1]
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H2><a name="Tcl_nn33"></a>40.6 Exception handling </H2>
|
<H2><a name="Tcl_nn33">40.6 Exception handling </a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2435,7 +2435,7 @@ Since SWIG's exception handling is user-definable, you are not limited to C++ ex
|
||||||
See the chapter on "<a href="Customization.html#Customization">Customization Features</a>" for more examples.
|
See the chapter on "<a href="Customization.html#Customization">Customization Features</a>" for more examples.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Tcl_nn34"></a>40.7 Typemaps</H2>
|
<H2><a name="Tcl_nn34">40.7 Typemaps</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2452,7 +2452,7 @@ Typemaps are only used if you want to change some aspect of the primitive
|
||||||
C-Tcl interface.
|
C-Tcl interface.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn35"></a>40.7.1 What is a typemap?</H3>
|
<H3><a name="Tcl_nn35">40.7.1 What is a typemap?</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2465,7 +2465,8 @@ you might define a typemap like this:
|
||||||
%module example
|
%module example
|
||||||
|
|
||||||
%typemap(in) int {
|
%typemap(in) int {
|
||||||
if (Tcl_GetIntFromObj(interp,$input,&$1) == TCL_ERROR) return TCL_ERROR;
|
if (Tcl_GetIntFromObj(interp,$input,&$1) == TCL_ERROR)
|
||||||
|
return TCL_ERROR;
|
||||||
printf("Received an integer : %d\n",$1);
|
printf("Received an integer : %d\n",$1);
|
||||||
}
|
}
|
||||||
%inline %{
|
%inline %{
|
||||||
|
|
@ -2503,7 +2504,8 @@ You can refine this by supplying an optional parameter name. For example:
|
||||||
%module example
|
%module example
|
||||||
|
|
||||||
%typemap(in) int n {
|
%typemap(in) int n {
|
||||||
if (Tcl_GetIntFromObj(interp,$input,&$1) == TCL_ERROR) return TCL_ERROR;
|
if (Tcl_GetIntFromObj(interp,$input,&$1) == TCL_ERROR)
|
||||||
|
return TCL_ERROR;
|
||||||
printf("n = %d\n",$1);
|
printf("n = %d\n",$1);
|
||||||
}
|
}
|
||||||
%inline %{
|
%inline %{
|
||||||
|
|
@ -2526,7 +2528,8 @@ the typemap system follows <tt>typedef</tt> declarations. For example:
|
||||||
<div class="code">
|
<div class="code">
|
||||||
<pre>
|
<pre>
|
||||||
%typemap(in) int n {
|
%typemap(in) int n {
|
||||||
if (Tcl_GetIntFromObj(interp,$input,&$1) == TCL_ERROR) return TCL_ERROR;
|
if (Tcl_GetIntFromObj(interp,$input,&$1) == TCL_ERROR)
|
||||||
|
return TCL_ERROR;
|
||||||
printf("n = %d\n",$1);
|
printf("n = %d\n",$1);
|
||||||
}
|
}
|
||||||
%inline %{
|
%inline %{
|
||||||
|
|
@ -2569,7 +2572,7 @@ parameter is omitted):
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn36"></a>40.7.2 Tcl typemaps</H3>
|
<H3><a name="Tcl_nn36">40.7.2 Tcl typemaps</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2707,7 +2710,7 @@ Initialize an argument to a value before any conversions occur.
|
||||||
Examples of these methods will appear shortly.
|
Examples of these methods will appear shortly.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn37"></a>40.7.3 Typemap variables</H3>
|
<H3><a name="Tcl_nn37">40.7.3 Typemap variables</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2778,7 +2781,7 @@ properly assigned.
|
||||||
The Tcl name of the wrapper function being created.
|
The Tcl name of the wrapper function being created.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn38"></a>40.7.4 Converting a Tcl list to a char ** </H3>
|
<H3><a name="Tcl_nn38">40.7.4 Converting a Tcl list to a char ** </a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2840,7 +2843,7 @@ argv[2] = Larry
|
||||||
3
|
3
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn39"></a>40.7.5 Returning values in arguments</H3>
|
<H3><a name="Tcl_nn39">40.7.5 Returning values in arguments</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2882,7 +2885,7 @@ result, a Tcl function using these typemaps will work like this :
|
||||||
%
|
%
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn40"></a>40.7.6 Useful functions</H3>
|
<H3><a name="Tcl_nn40">40.7.6 Useful functions</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2958,7 +2961,7 @@ int Tcl_IsShared(Tcl_Obj *obj);
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn41"></a>40.7.7 Standard typemaps</H3>
|
<H3><a name="Tcl_nn41">40.7.7 Standard typemaps</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3028,7 +3031,6 @@ work)
|
||||||
int len;
|
int len;
|
||||||
$1 = Tcl_GetStringFromObj(interp, &len);
|
$1 = Tcl_GetStringFromObj(interp, &len);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -3043,7 +3045,7 @@ work)
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn42"></a>40.7.8 Pointer handling</H3>
|
<H3><a name="Tcl_nn42">40.7.8 Pointer handling</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3086,7 +3088,9 @@ is usually accessed as follows:
|
||||||
<div class="indent">
|
<div class="indent">
|
||||||
<pre>
|
<pre>
|
||||||
Foo *f;
|
Foo *f;
|
||||||
if (SWIG_ConvertPtr($input, (void **) &f, SWIGTYPE_p_Foo, 0) == -1) return NULL;
|
if (!SWIG_IsOK(SWIG_ConvertPtr($input, (void **) &f, SWIGTYPE_p_Foo, 0))) {
|
||||||
|
SWIG_exception_fail(SWIG_TypeError, "in method '$symname', expecting type Foo");
|
||||||
|
}
|
||||||
|
|
||||||
Tcl_Obj *;
|
Tcl_Obj *;
|
||||||
obj = SWIG_NewPointerObj(f, SWIGTYPE_p_Foo, 0);
|
obj = SWIG_NewPointerObj(f, SWIGTYPE_p_Foo, 0);
|
||||||
|
|
@ -3101,7 +3105,9 @@ variable <tt>$1_descriptor</tt>. For example:
|
||||||
<div class="indent">
|
<div class="indent">
|
||||||
<pre>
|
<pre>
|
||||||
%typemap(in) Foo * {
|
%typemap(in) Foo * {
|
||||||
if ((SWIG_ConvertPtr($input,(void **) &$1, $1_descriptor,0)) == -1) return NULL;
|
if (!SWIG_IsOK(SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, 0))) {
|
||||||
|
SWIG_exception_fail(SWIG_TypeError, "in method '$symname', expecting type Foo");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -3114,12 +3120,14 @@ For example:
|
||||||
<div class="indent">
|
<div class="indent">
|
||||||
<pre>
|
<pre>
|
||||||
%typemap(in) Foo * {
|
%typemap(in) Foo * {
|
||||||
if ((SWIG_ConvertPtr($input,(void **) &$1, $descriptor(Foo *), 0)) == -1) return NULL;
|
if (!SWIG_IsOK(SWIG_ConvertPtr($input, (void **) &$1, $descriptor(Foo *), 0))) {
|
||||||
|
SWIG_exception_fail(SWIG_TypeError, "in method '$symname', expecting type Foo");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H2><a name="Tcl_nn43"></a>40.8 Turning a SWIG module into a Tcl Package.</H2>
|
<H2><a name="Tcl_nn43">40.8 Turning a SWIG module into a Tcl Package.</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3191,7 +3199,7 @@ As a final note, most SWIG examples do not yet use the
|
||||||
to use the <tt>load</tt> command instead.
|
to use the <tt>load</tt> command instead.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Tcl_nn44"></a>40.9 Building new kinds of Tcl interfaces (in Tcl)</H2>
|
<H2><a name="Tcl_nn44">40.9 Building new kinds of Tcl interfaces (in Tcl)</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3290,7 +3298,7 @@ danger of blowing something up (although it is easily accomplished
|
||||||
with an out of bounds array access).
|
with an out of bounds array access).
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Tcl_nn45"></a>40.9.1 Proxy classes</H3>
|
<H3><a name="Tcl_nn45">40.9.1 Proxy classes</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3411,7 +3419,7 @@ short, but clever Tcl script can be combined with SWIG to do many
|
||||||
interesting things.
|
interesting things.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Tcl_nn46"></a>40.10 Tcl/Tk Stubs</H2>
|
<H2><a name="Tcl_nn46">40.10 Tcl/Tk Stubs</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Typemaps</title>
|
<title>Typemaps</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
<H1><a name="Typemaps"></a>11 Typemaps</H1>
|
<H1><a name="Typemaps">11 Typemaps</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -48,6 +49,8 @@
|
||||||
<li><a href="#Typemaps_special_macro_descriptor">$descriptor(type)</a>
|
<li><a href="#Typemaps_special_macro_descriptor">$descriptor(type)</a>
|
||||||
<li><a href="#Typemaps_special_macro_typemap">$typemap(method, typepattern)</a>
|
<li><a href="#Typemaps_special_macro_typemap">$typemap(method, typepattern)</a>
|
||||||
</ul>
|
</ul>
|
||||||
|
<li><a href="#Typemaps_special_variable_attributes">Special variables and typemap attributes</a>
|
||||||
|
<li><a href="#Typemaps_special_variables_and_macros">Special variables combined with special variable macros</a>
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="#Typemaps_nn25">Common typemap methods</a>
|
<li><a href="#Typemaps_nn25">Common typemap methods</a>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -60,6 +63,7 @@
|
||||||
<li><a href="#Typemaps_nn32">"argout" typemap</a>
|
<li><a href="#Typemaps_nn32">"argout" typemap</a>
|
||||||
<li><a href="#Typemaps_nn33">"freearg" typemap</a>
|
<li><a href="#Typemaps_nn33">"freearg" typemap</a>
|
||||||
<li><a href="#Typemaps_nn34">"newfree" typemap</a>
|
<li><a href="#Typemaps_nn34">"newfree" typemap</a>
|
||||||
|
<li><a href="#Typemaps_ret">"ret" typemap</a>
|
||||||
<li><a href="#Typemaps_nn35">"memberin" typemap</a>
|
<li><a href="#Typemaps_nn35">"memberin" typemap</a>
|
||||||
<li><a href="#Typemaps_nn36">"varin" typemap</a>
|
<li><a href="#Typemaps_nn36">"varin" typemap</a>
|
||||||
<li><a href="#Typemaps_nn37">"varout" typemap</a>
|
<li><a href="#Typemaps_nn37">"varout" typemap</a>
|
||||||
|
|
@ -85,7 +89,7 @@
|
||||||
<li><a href="#Typemaps_runtime_type_checker_usage">Usage</a>
|
<li><a href="#Typemaps_runtime_type_checker_usage">Usage</a>
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="#Typemaps_overloading">Typemaps and overloading</a>
|
<li><a href="#Typemaps_overloading">Typemaps and overloading</a>
|
||||||
<li><a href="#Typemaps_nn48">More about <tt>%apply</tt> and <tt>%clear</tt></a>
|
<li><a href="#Typemaps_nn48">More about %apply and %clear</a>
|
||||||
<li><a href="#Typemaps_nn47">Passing data between typemaps</a>
|
<li><a href="#Typemaps_nn47">Passing data between typemaps</a>
|
||||||
<li><a href="#Typemaps_nn52">C++ "this" pointer</a>
|
<li><a href="#Typemaps_nn52">C++ "this" pointer</a>
|
||||||
<li><a href="#Typemaps_nn51">Where to go for more information?</a>
|
<li><a href="#Typemaps_nn51">Where to go for more information?</a>
|
||||||
|
|
@ -95,7 +99,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="Typemaps_nn2"></a>11.1 Introduction</H2>
|
<H2><a name="Typemaps_nn2">11.1 Introduction</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -112,7 +116,7 @@ to re-read the earlier chapters if you have found your way to this
|
||||||
chapter with only a vague idea of what SWIG already does by default.
|
chapter with only a vague idea of what SWIG already does by default.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Typemaps_nn3"></a>11.1.1 Type conversion</H3>
|
<H3><a name="Typemaps_nn3">11.1.1 Type conversion</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -205,7 +209,7 @@ to read the extension documentation for your favorite language to know
|
||||||
how it works (an exercise left to the reader).
|
how it works (an exercise left to the reader).
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Typemaps_nn4"></a>11.1.2 Typemaps</H3>
|
<H3><a name="Typemaps_nn4">11.1.2 Typemaps</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -306,7 +310,7 @@ parts of the generated wrapper functions. Because arbitrary code can be insert
|
||||||
possible to completely change the way in which values are converted.
|
possible to completely change the way in which values are converted.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Typemaps_nn5"></a>11.1.3 Pattern matching</H3>
|
<H3><a name="Typemaps_nn5">11.1.3 Pattern matching</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -372,7 +376,7 @@ example, you could write a typemap like this:
|
||||||
$1 = PyFloat_AsDouble($input);
|
$1 = PyFloat_AsDouble($input);
|
||||||
if ($1 < 0) {
|
if ($1 < 0) {
|
||||||
PyErr_SetString(PyExc_ValueError,"argument must be nonnegative.");
|
PyErr_SetString(PyExc_ValueError,"argument must be nonnegative.");
|
||||||
return NULL;
|
SWIG_fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -408,7 +412,7 @@ In this case, a single input object is expanded into a pair of C arguments. Thi
|
||||||
provides a hint to the unusual variable naming scheme involving <tt>$1</tt>, <tt>$2</tt>, and so forth.
|
provides a hint to the unusual variable naming scheme involving <tt>$1</tt>, <tt>$2</tt>, and so forth.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Typemaps_nn6"></a>11.1.4 Reusing typemaps</H3>
|
<H3><a name="Typemaps_nn6">11.1.4 Reusing typemaps</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -464,7 +468,7 @@ typedef int size_t;
|
||||||
then SWIG already knows that the <tt>int</tt> typemaps apply. You don't have to do anything.
|
then SWIG already knows that the <tt>int</tt> typemaps apply. You don't have to do anything.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Typemaps_nn7"></a>11.1.5 What can be done with typemaps?</H3>
|
<H3><a name="Typemaps_nn7">11.1.5 What can be done with typemaps?</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -485,7 +489,7 @@ int foo(<b>int x, double y, char *s</b>);
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>Input argument conversion ("in" typemap).</li>
|
<li>Input argument conversion ("in" typemap).</li>
|
||||||
<li>Input argument type checking ("typecheck" typemap).</li>
|
<li>Input argument type checking for types used in overloaded methods ("typecheck" typemap).</li>
|
||||||
<li>Output argument handling ("argout" typemap).</li>
|
<li>Output argument handling ("argout" typemap).</li>
|
||||||
<li>Input argument value checking ("check" typemap).</li>
|
<li>Input argument value checking ("check" typemap).</li>
|
||||||
<li>Input argument initialization ("arginit" typemap).</li>
|
<li>Input argument initialization ("arginit" typemap).</li>
|
||||||
|
|
@ -576,7 +580,7 @@ typemaps that expand upon this list. For example, the Java module defines a var
|
||||||
aspects of the Java bindings. Consult language specific documentation for further details.
|
aspects of the Java bindings. Consult language specific documentation for further details.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Typemaps_nn8"></a>11.1.6 What can't be done with typemaps?</H3>
|
<H3><a name="Typemaps_nn8">11.1.6 What can't be done with typemaps?</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -639,7 +643,7 @@ void wrap_foo(char *s, int x) {
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Typemaps_aspects"></a>11.1.7 Similarities to Aspect Oriented Programming</H3>
|
<H3><a name="Typemaps_aspects">11.1.7 Similarities to Aspect Oriented Programming</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -653,11 +657,11 @@ The <a href="http://en.wikipedia.org/wiki/Aspect-oriented_programming#Terminolog
|
||||||
<li> <b>Aspect</b>: Aspects are the combination of the pointcut and the advice, hence each typemap is an aspect.
|
<li> <b>Aspect</b>: Aspects are the combination of the pointcut and the advice, hence each typemap is an aspect.
|
||||||
</ul>
|
</ul>
|
||||||
<p>
|
<p>
|
||||||
SWIG can also be viewed as has having a second set of aspects based around <a href="Customization.html">%feature</a>.
|
SWIG can also be viewed as has having a second set of aspects based around <a href="Customization.html#Customization">%feature</a>.
|
||||||
Features such as <tt>%exception</tt> are also cross-cutting concerns as they encapsulate code that can be used to add logging or exception handling to any function.
|
Features such as <tt>%exception</tt> are also cross-cutting concerns as they encapsulate code that can be used to add logging or exception handling to any function.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Typemaps_nn9"></a>11.1.8 The rest of this chapter</H3>
|
<H3><a name="Typemaps_nn9">11.1.8 The rest of this chapter</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -677,14 +681,14 @@ of "The C Programming Language" by Kernighan and Ritchie or
|
||||||
"The C++ Programming Language" by Stroustrup before going any further.
|
"The C++ Programming Language" by Stroustrup before going any further.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Typemaps_nn10"></a>11.2 Typemap specifications</H2>
|
<H2><a name="Typemaps_nn10">11.2 Typemap specifications</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
This section describes the behavior of the <tt>%typemap</tt> directive itself.
|
This section describes the behavior of the <tt>%typemap</tt> directive itself.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Typemaps_defining"></a>11.2.1 Defining a typemap</H3>
|
<H3><a name="Typemaps_defining">11.2.1 Defining a typemap</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -747,7 +751,7 @@ code : { ... }
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Note that the preprocessor will expand code within the {} delimiters, but not in the last two styles of delimiters,
|
Note that the preprocessor will expand code within the {} delimiters, but not in the last two styles of delimiters,
|
||||||
see <a href="Preprocessor.html#Preprocessor_typemap_delimiters">Preprocessor and Typemaps</a>.
|
see <a href="Preprocessor.html#Preprocessor_delimiters">Preprocessor and Typemaps</a>.
|
||||||
Here are some examples of valid typemap specifications:
|
Here are some examples of valid typemap specifications:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
@ -797,7 +801,7 @@ Admittedly, it's not the most readable syntax at first glance. However, the pur
|
||||||
individual pieces will become clear.
|
individual pieces will become clear.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Typemaps_nn12"></a>11.2.2 Typemap scope</H3>
|
<H3><a name="Typemaps_nn12">11.2.2 Typemap scope</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -847,7 +851,7 @@ class Foo {
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Typemaps_nn13"></a>11.2.3 Copying a typemap</H3>
|
<H3><a name="Typemaps_nn13">11.2.3 Copying a typemap</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -905,7 +909,7 @@ The patterns for <tt>%apply</tt> follow the same rules as for <tt>%typemap</tt>.
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Typemaps_nn14"></a>11.2.4 Deleting a typemap</H3>
|
<H3><a name="Typemaps_nn14">11.2.4 Deleting a typemap</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -938,7 +942,7 @@ For example:
|
||||||
after the clear operation.
|
after the clear operation.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Typemaps_nn15"></a>11.2.5 Placement of typemaps</H3>
|
<H3><a name="Typemaps_nn15">11.2.5 Placement of typemaps</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1018,7 +1022,7 @@ It should be noted that for scoping to work, SWIG has to know that <tt>string</t
|
||||||
within a particular namespace. In this example, this is done using the forward class declaration <tt>class string</tt>.
|
within a particular namespace. In this example, this is done using the forward class declaration <tt>class string</tt>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Typemaps_pattern_matching"></a>11.3 Pattern matching rules</H2>
|
<H2><a name="Typemaps_pattern_matching">11.3 Pattern matching rules</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1026,7 +1030,7 @@ The section describes the pattern matching rules by which C/C++ datatypes are as
|
||||||
The matching rules can be observed in practice by using the debugging options also described.
|
The matching rules can be observed in practice by using the debugging options also described.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Typemaps_nn17"></a>11.3.1 Basic matching rules</H3>
|
<H3><a name="Typemaps_nn17">11.3.1 Basic matching rules</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1125,7 +1129,7 @@ void F(int x[1000]); // int [ANY] rule (typemap 5)
|
||||||
stripped all qualifiers in one step.
|
stripped all qualifiers in one step.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Typemaps_typedef_reductions"></a>11.3.2 Typedef reductions matching</H3>
|
<H3><a name="Typemaps_typedef_reductions">11.3.2 Typedef reductions matching</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1300,7 +1304,7 @@ void go(Struct aStruct);
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Typemaps_nn19"></a>11.3.3 Default typemap matching rules</H3>
|
<H3><a name="Typemaps_nn19">11.3.3 Default typemap matching rules</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1438,7 +1442,7 @@ Finally the best way to view the typemap matching rules in action is via the <a
|
||||||
simpler scheme to match the current C++ class template partial specialization matching rules.
|
simpler scheme to match the current C++ class template partial specialization matching rules.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Typemaps_multi_argument_typemaps_patterns"></a>11.3.4 Multi-arguments typemaps</H3>
|
<H3><a name="Typemaps_multi_argument_typemaps_patterns">11.3.4 Multi-arguments typemaps</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1468,7 +1472,7 @@ but all subsequent arguments must match exactly.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Typemaps_matching_template_comparison"></a>11.3.5 Matching rules compared to C++ templates</H3>
|
<H3><a name="Typemaps_matching_template_comparison">11.3.5 Matching rules compared to C++ templates</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1627,7 +1631,7 @@ are similar to those for specialized template handling.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Typemaps_debugging_search"></a>11.3.6 Debugging typemap pattern matching</H3>
|
<H3><a name="Typemaps_debugging_search">11.3.6 Debugging typemap pattern matching</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1840,7 +1844,7 @@ Also the types may be displayed slightly differently - <tt>char const *</tt> and
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<H2><a name="Typemaps_nn21"></a>11.4 Code generation rules</H2>
|
<H2><a name="Typemaps_nn21">11.4 Code generation rules</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1848,7 +1852,7 @@ This section describes rules by which typemap code is inserted into
|
||||||
the generated wrapper code.
|
the generated wrapper code.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Typemaps_nn22"></a>11.4.1 Scope</H3>
|
<H3><a name="Typemaps_nn22">11.4.1 Scope</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1926,7 +1930,7 @@ a block scope when it is emitted. This sometimes results in a less complicated
|
||||||
Note that only the third of the three typemaps have the typemap code passed through the SWIG preprocessor.
|
Note that only the third of the three typemaps have the typemap code passed through the SWIG preprocessor.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Typemaps_nn23"></a>11.4.2 Declaring new local variables</H3>
|
<H3><a name="Typemaps_nn23">11.4.2 Declaring new local variables</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2093,7 +2097,7 @@ each type must have its own local variable declaration.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Typemaps_special_variables"></a>11.4.3 Special variables</H3>
|
<H3><a name="Typemaps_special_variables">11.4.3 Special variables</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2345,7 +2349,7 @@ Another approach, which only works for arrays is to use the <tt>$1_basetype</tt>
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Typemaps_special_variable_macros"></a>11.4.4 Special variable macros</H3>
|
<H3><a name="Typemaps_special_variable_macros">11.4.4 Special variable macros</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2357,7 +2361,7 @@ it is done during the SWIG parsing/compilation stages.
|
||||||
The following special variable macros are available across all language modules.
|
The following special variable macros are available across all language modules.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H4><a name="Typemaps_special_macro_descriptor"></a>11.4.4.1 $descriptor(type)</H4>
|
<H4><a name="Typemaps_special_macro_descriptor">11.4.4.1 $descriptor(type)</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2368,7 +2372,7 @@ For example, <tt>$descriptor(std::vector<int> *)</tt> will expand into <tt
|
||||||
This macro is mostly used in the scripting target languages and is demonstrated later in the <a href="#Typemaps_runtime_type_checker_usage">Run-time type checker usage</a> section.
|
This macro is mostly used in the scripting target languages and is demonstrated later in the <a href="#Typemaps_runtime_type_checker_usage">Run-time type checker usage</a> section.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H4><a name="Typemaps_special_macro_typemap"></a>11.4.4.2 $typemap(method, typepattern)</H4>
|
<H4><a name="Typemaps_special_macro_typemap">11.4.4.2 $typemap(method, typepattern)</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2425,7 +2429,77 @@ The result is the following expansion
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H2><a name="Typemaps_nn25"></a>11.5 Common typemap methods</H2>
|
|
||||||
|
<H3><a name="Typemaps_special_variable_attributes">11.4.5 Special variables and typemap attributes</a></H3>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
As of SWIG-3.0.7 typemap attributes will also expand special variables and special variable macros.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Example usage showing the expansion in the 'out' attribute (C# specific) as well as the main typemap body:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="code">
|
||||||
|
<pre>
|
||||||
|
%typemap(ctype, out="$*1_ltype") unsigned int& "$*1_ltype"
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
is equivalent to the following as <tt>$*1_ltype</tt> expands to <tt>unsigned int</tt>:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="code">
|
||||||
|
<pre>
|
||||||
|
%typemap(ctype, out="unsigned int") unsigned int& "unsigned int"
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<H3><a name="Typemaps_special_variables_and_macros">11.4.6 Special variables combined with special variable macros</a></H3>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Special variables can also be used within special variable macros.
|
||||||
|
The special variables are expanded before they are used in the special variable macros.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Consider the following C# typemaps:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="code">
|
||||||
|
<pre>
|
||||||
|
%typemap(cstype) unsigned int "uint"
|
||||||
|
%typemap(cstype, out="$typemap(cstype, $*1_ltype)") unsigned int& "$typemap(cstype, $*1_ltype)"
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Special variables are expanded first and hence the above is equivalent to:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="code">
|
||||||
|
<pre>
|
||||||
|
%typemap(cstype) unsigned int "uint"
|
||||||
|
%typemap(cstype, out="$typemap(cstype, unsigned int)") unsigned int& "$typemap(cstype, unsigned int)"
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
which then expands to:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="code">
|
||||||
|
<pre>
|
||||||
|
%typemap(cstype) unsigned int "uint"
|
||||||
|
%typemap(cstype, out="uint") unsigned int& "uint"
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<H2><a name="Typemaps_nn25">11.5 Common typemap methods</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2433,7 +2507,7 @@ The set of typemaps recognized by a language module may vary. However,
|
||||||
the following typemap methods are nearly universal:
|
the following typemap methods are nearly universal:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Typemaps_nn26"></a>11.5.1 "in" typemap</H3>
|
<H3><a name="Typemaps_nn26">11.5.1 "in" typemap</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2493,7 +2567,7 @@ Usually <tt>numinputs</tt> is not specified, whereupon the default value is 1, t
|
||||||
is the same as the old "ignore" typemap.
|
is the same as the old "ignore" typemap.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Typemaps_nn27"></a>11.5.2 "typecheck" typemap</H3>
|
<H3><a name="Typemaps_nn27">11.5.2 "typecheck" typemap</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2512,6 +2586,7 @@ to see whether or not it matches a specific type. For example:
|
||||||
<p>
|
<p>
|
||||||
For typechecking, the $1 variable is always a simple integer that is set to 1 or 0 depending on whether or not
|
For typechecking, the $1 variable is always a simple integer that is set to 1 or 0 depending on whether or not
|
||||||
the input argument is the correct type.
|
the input argument is the correct type.
|
||||||
|
Set to 1 if the input argument is the correct type otherwise set to 0.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2519,7 +2594,7 @@ If you define new "in" typemaps <em>and</em> your program uses overloaded method
|
||||||
"typecheck" typemaps. More details about this follow in the <a href="#Typemaps_overloading">Typemaps and overloading</a> section.
|
"typecheck" typemaps. More details about this follow in the <a href="#Typemaps_overloading">Typemaps and overloading</a> section.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Typemaps_nn28"></a>11.5.3 "out" typemap</H3>
|
<H3><a name="Typemaps_nn28">11.5.3 "out" typemap</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2550,7 +2625,7 @@ $symname - Name of function/method being wrapped
|
||||||
The "out" typemap supports an optional attribute flag called "optimal". This is for code optimisation and is detailed in the <a href="#Typemaps_optimal">Optimal code generation when returning by value</a> section.
|
The "out" typemap supports an optional attribute flag called "optimal". This is for code optimisation and is detailed in the <a href="#Typemaps_optimal">Optimal code generation when returning by value</a> section.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Typemaps_nn29"></a>11.5.4 "arginit" typemap</H3>
|
<H3><a name="Typemaps_nn29">11.5.4 "arginit" typemap</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2569,7 +2644,7 @@ For example:
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Typemaps_nn30"></a>11.5.5 "default" typemap</H3>
|
<H3><a name="Typemaps_nn30">11.5.5 "default" typemap</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2602,7 +2677,7 @@ See the <a href="SWIG.html#SWIG_default_args">Default/optional arguments</a> sec
|
||||||
for further information on default argument wrapping.
|
for further information on default argument wrapping.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Typemaps_nn31"></a>11.5.6 "check" typemap</H3>
|
<H3><a name="Typemaps_nn31">11.5.6 "check" typemap</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2621,7 +2696,7 @@ converted. For example:
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Typemaps_nn32"></a>11.5.7 "argout" typemap</H3>
|
<H3><a name="Typemaps_nn32">11.5.7 "argout" typemap</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2667,7 +2742,7 @@ return values are often appended to return value of the function.
|
||||||
See the <tt>typemaps.i</tt> library file for examples.
|
See the <tt>typemaps.i</tt> library file for examples.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Typemaps_nn33"></a>11.5.8 "freearg" typemap</H3>
|
<H3><a name="Typemaps_nn33">11.5.8 "freearg" typemap</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2700,7 +2775,7 @@ be used in other typemaps whenever a wrapper function needs to abort
|
||||||
prematurely.
|
prematurely.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Typemaps_nn34"></a>11.5.9 "newfree" typemap</H3>
|
<H3><a name="Typemaps_nn34">11.5.9 "newfree" typemap</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2729,7 +2804,46 @@ string *foo();
|
||||||
See <a href="Customization.html#Customization_ownership">Object ownership and %newobject</a> for further details.
|
See <a href="Customization.html#Customization_ownership">Object ownership and %newobject</a> for further details.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Typemaps_nn35"></a>11.5.10 "memberin" typemap</H3>
|
<H3><a name="Typemaps_ret">11.5.10 "ret" typemap</a></H3>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The "ret" typemap is not used very often, but can be useful for anything associated with
|
||||||
|
the return type, such as resource management, return value error checking, etc.
|
||||||
|
Usually this can all be done in the "out" typemap, but sometimes it is handy to use the
|
||||||
|
"out" typemap code untouched and add to the generated code using the code in the "ret" typemap.
|
||||||
|
One such case is memory clean up. For example, a <tt>stringheap_t</tt> type is defined indicating
|
||||||
|
that the returned memory must be deleted and a <tt>string_t</tt> type is defined indicating
|
||||||
|
that the returned memory must not be deleted.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="code">
|
||||||
|
<pre>
|
||||||
|
%typemap(ret) stringheap_t %{
|
||||||
|
free($1);
|
||||||
|
%}
|
||||||
|
|
||||||
|
typedef char * string_t;
|
||||||
|
typedef char * stringheap_t;
|
||||||
|
|
||||||
|
string_t MakeString1();
|
||||||
|
stringheap_t MakeString2();
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The "ret" typemap above will only be used for <tt>MakeString2</tt>, but both functions
|
||||||
|
will use the default "out" typemap for <tt>char *</tt> provided by SWIG.
|
||||||
|
The code above would ensure the appropriate memory is freed in all target languages as the need
|
||||||
|
to provide custom "out" typemaps (which involve target language specific code) is not necessary.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
This approach is an alternative to using the "newfree" typemap and <tt>%newobject</tt> as there
|
||||||
|
is no need to list all the functions that require the memory cleanup, it is purely done on types.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<H3><a name="Typemaps_nn35">11.5.11 "memberin" typemap</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2751,7 +2865,7 @@ It is rarely necessary to write "memberin" typemaps---SWIG already provides
|
||||||
a default implementation for arrays, strings, and other objects.
|
a default implementation for arrays, strings, and other objects.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Typemaps_nn36"></a>11.5.11 "varin" typemap</H3>
|
<H3><a name="Typemaps_nn36">11.5.12 "varin" typemap</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2759,7 +2873,7 @@ The "varin" typemap is used to convert objects in the target language to C for t
|
||||||
purposes of assigning to a C/C++ global variable. This is implementation specific.
|
purposes of assigning to a C/C++ global variable. This is implementation specific.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Typemaps_nn37"></a>11.5.12 "varout" typemap</H3>
|
<H3><a name="Typemaps_nn37">11.5.13 "varout" typemap</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2767,7 +2881,7 @@ The "varout" typemap is used to convert a C/C++ object to an object in the targe
|
||||||
language when reading a C/C++ global variable. This is implementation specific.
|
language when reading a C/C++ global variable. This is implementation specific.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="throws_typemap"></a>11.5.13 "throws" typemap</H3>
|
<H3><a name="throws_typemap">11.5.14 "throws" typemap</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2802,7 +2916,6 @@ try {
|
||||||
catch(char const *_e) {
|
catch(char const *_e) {
|
||||||
PyErr_SetString(PyExc_RuntimeError, _e);
|
PyErr_SetString(PyExc_RuntimeError, _e);
|
||||||
SWIG_fail;
|
SWIG_fail;
|
||||||
|
|
||||||
}
|
}
|
||||||
...
|
...
|
||||||
</pre>
|
</pre>
|
||||||
|
|
@ -2813,7 +2926,7 @@ Note that if your methods do not have an exception specification yet they do thr
|
||||||
For a neat way to handle these, see the <a href="Customization.html#Customization_exception">Exception handling with %exception</a> section.
|
For a neat way to handle these, see the <a href="Customization.html#Customization_exception">Exception handling with %exception</a> section.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Typemaps_nn39"></a>11.6 Some typemap examples</H2>
|
<H2><a name="Typemaps_nn39">11.6 Some typemap examples</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2821,7 +2934,7 @@ This section contains a few examples. Consult language module documentation
|
||||||
for more examples.
|
for more examples.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Typemaps_nn40"></a>11.6.1 Typemaps for arrays</H3>
|
<H3><a name="Typemaps_nn40">11.6.1 Typemaps for arrays</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2851,11 +2964,11 @@ similar to this:
|
||||||
int i;
|
int i;
|
||||||
if (!PySequence_Check($input)) {
|
if (!PySequence_Check($input)) {
|
||||||
PyErr_SetString(PyExc_ValueError,"Expected a sequence");
|
PyErr_SetString(PyExc_ValueError,"Expected a sequence");
|
||||||
return NULL;
|
SWIG_fail;
|
||||||
}
|
}
|
||||||
if (PySequence_Length($input) != 4) {
|
if (PySequence_Length($input) != 4) {
|
||||||
PyErr_SetString(PyExc_ValueError,"Size mismatch. Expected 4 elements");
|
PyErr_SetString(PyExc_ValueError,"Size mismatch. Expected 4 elements");
|
||||||
return NULL;
|
SWIG_fail;
|
||||||
}
|
}
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
PyObject *o = PySequence_GetItem($input,i);
|
PyObject *o = PySequence_GetItem($input,i);
|
||||||
|
|
@ -2863,7 +2976,7 @@ similar to this:
|
||||||
temp[i] = (float) PyFloat_AsDouble(o);
|
temp[i] = (float) PyFloat_AsDouble(o);
|
||||||
} else {
|
} else {
|
||||||
PyErr_SetString(PyExc_ValueError,"Sequence elements must be numbers");
|
PyErr_SetString(PyExc_ValueError,"Sequence elements must be numbers");
|
||||||
return NULL;
|
SWIG_fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$1 = temp;
|
$1 = temp;
|
||||||
|
|
@ -2896,11 +3009,11 @@ If you wanted to generalize the typemap to apply to arrays of all dimensions you
|
||||||
int i;
|
int i;
|
||||||
if (!PySequence_Check($input)) {
|
if (!PySequence_Check($input)) {
|
||||||
PyErr_SetString(PyExc_ValueError,"Expected a sequence");
|
PyErr_SetString(PyExc_ValueError,"Expected a sequence");
|
||||||
return NULL;
|
SWIG_fail;
|
||||||
}
|
}
|
||||||
if (PySequence_Length($input) != $1_dim0) {
|
if (PySequence_Length($input) != $1_dim0) {
|
||||||
PyErr_SetString(PyExc_ValueError,"Size mismatch. Expected $1_dim0 elements");
|
PyErr_SetString(PyExc_ValueError,"Size mismatch. Expected $1_dim0 elements");
|
||||||
return NULL;
|
SWIG_fail;
|
||||||
}
|
}
|
||||||
for (i = 0; i < $1_dim0; i++) {
|
for (i = 0; i < $1_dim0; i++) {
|
||||||
PyObject *o = PySequence_GetItem($input,i);
|
PyObject *o = PySequence_GetItem($input,i);
|
||||||
|
|
@ -2908,7 +3021,7 @@ If you wanted to generalize the typemap to apply to arrays of all dimensions you
|
||||||
temp[i] = (float) PyFloat_AsDouble(o);
|
temp[i] = (float) PyFloat_AsDouble(o);
|
||||||
} else {
|
} else {
|
||||||
PyErr_SetString(PyExc_ValueError,"Sequence elements must be numbers");
|
PyErr_SetString(PyExc_ValueError,"Sequence elements must be numbers");
|
||||||
return NULL;
|
SWIG_fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$1 = temp;
|
$1 = temp;
|
||||||
|
|
@ -2940,11 +3053,11 @@ as shown. To work with heap allocated data, the following technique can be use
|
||||||
int i;
|
int i;
|
||||||
if (!PySequence_Check($input)) {
|
if (!PySequence_Check($input)) {
|
||||||
PyErr_SetString(PyExc_ValueError,"Expected a sequence");
|
PyErr_SetString(PyExc_ValueError,"Expected a sequence");
|
||||||
return NULL;
|
SWIG_fail;
|
||||||
}
|
}
|
||||||
if (PySequence_Length($input) != $1_dim0) {
|
if (PySequence_Length($input) != $1_dim0) {
|
||||||
PyErr_SetString(PyExc_ValueError,"Size mismatch. Expected $1_dim0 elements");
|
PyErr_SetString(PyExc_ValueError,"Size mismatch. Expected $1_dim0 elements");
|
||||||
return NULL;
|
SWIG_fail;
|
||||||
}
|
}
|
||||||
$1 = (float *) malloc($1_dim0*sizeof(float));
|
$1 = (float *) malloc($1_dim0*sizeof(float));
|
||||||
for (i = 0; i < $1_dim0; i++) {
|
for (i = 0; i < $1_dim0; i++) {
|
||||||
|
|
@ -2952,9 +3065,9 @@ as shown. To work with heap allocated data, the following technique can be use
|
||||||
if (PyNumber_Check(o)) {
|
if (PyNumber_Check(o)) {
|
||||||
$1[i] = (float) PyFloat_AsDouble(o);
|
$1[i] = (float) PyFloat_AsDouble(o);
|
||||||
} else {
|
} else {
|
||||||
PyErr_SetString(PyExc_ValueError,"Sequence elements must be numbers");
|
|
||||||
free($1);
|
free($1);
|
||||||
return NULL;
|
PyErr_SetString(PyExc_ValueError,"Sequence elements must be numbers");
|
||||||
|
SWIG_fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3080,7 +3193,7 @@ Now, you will find that member access is quite nice:
|
||||||
useless and has since been eliminated. To return structure members, simply use the "out" typemap.
|
useless and has since been eliminated. To return structure members, simply use the "out" typemap.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Typemaps_nn41"></a>11.6.2 Implementing constraints with typemaps</H3>
|
<H3><a name="Typemaps_nn41">11.6.2 Implementing constraints with typemaps</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3116,7 +3229,7 @@ pointers. For example:</p>
|
||||||
%typemap(check) Vector * {
|
%typemap(check) Vector * {
|
||||||
if ($1 == 0) {
|
if ($1 == 0) {
|
||||||
PyErr_SetString(PyExc_TypeError,"NULL Pointer not allowed");
|
PyErr_SetString(PyExc_TypeError,"NULL Pointer not allowed");
|
||||||
return NULL;
|
SWIG_fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3128,7 +3241,7 @@ a NULL pointer. As a result, SWIG can often prevent a potential
|
||||||
segmentation faults or other run-time problems by raising an exception
|
segmentation faults or other run-time problems by raising an exception
|
||||||
rather than blindly passing values to the underlying C/C++ program.</p>
|
rather than blindly passing values to the underlying C/C++ program.</p>
|
||||||
|
|
||||||
<H2><a name="Typemaps_nn43"></a>11.7 Typemaps for multiple target languages</H2>
|
<H2><a name="Typemaps_nn43">11.7 Typemaps for multiple target languages</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3158,7 +3271,7 @@ The example above also shows a common approach of issuing a warning for an as ye
|
||||||
<tt>%typemap(ruby,in) int "$1 = NUM2INT($input);"</tt>.
|
<tt>%typemap(ruby,in) int "$1 = NUM2INT($input);"</tt>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Typemaps_optimal"></a>11.8 Optimal code generation when returning by value</H2>
|
<H2><a name="Typemaps_optimal">11.8 Optimal code generation when returning by value</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3347,7 +3460,7 @@ example.i:7: Warning 475: optimal attribute usage in the out typemap.
|
||||||
However, it doesn't always get it right, for example when <tt>$1</tt> is within some commented out code.
|
However, it doesn't always get it right, for example when <tt>$1</tt> is within some commented out code.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Typemaps_multi_argument_typemaps"></a>11.9 Multi-argument typemaps</H2>
|
<H2><a name="Typemaps_multi_argument_typemaps">11.9 Multi-argument typemaps</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3395,7 +3508,7 @@ maps perform the conversion described for the above example:
|
||||||
int i;
|
int i;
|
||||||
if (!PyList_Check($input)) {
|
if (!PyList_Check($input)) {
|
||||||
PyErr_SetString(PyExc_ValueError, "Expecting a list");
|
PyErr_SetString(PyExc_ValueError, "Expecting a list");
|
||||||
return NULL;
|
SWIG_fail;
|
||||||
}
|
}
|
||||||
$1 = PyList_Size($input);
|
$1 = PyList_Size($input);
|
||||||
$2 = (char **) malloc(($1+1)*sizeof(char *));
|
$2 = (char **) malloc(($1+1)*sizeof(char *));
|
||||||
|
|
@ -3404,7 +3517,7 @@ maps perform the conversion described for the above example:
|
||||||
if (!PyString_Check(s)) {
|
if (!PyString_Check(s)) {
|
||||||
free($2);
|
free($2);
|
||||||
PyErr_SetString(PyExc_ValueError, "List items must be strings");
|
PyErr_SetString(PyExc_ValueError, "List items must be strings");
|
||||||
return NULL;
|
SWIG_fail;
|
||||||
}
|
}
|
||||||
$2[i] = PyString_AsString(s);
|
$2[i] = PyString_AsString(s);
|
||||||
}
|
}
|
||||||
|
|
@ -3414,6 +3527,11 @@ maps perform the conversion described for the above example:
|
||||||
%typemap(freearg) (int argc, char *argv[]) {
|
%typemap(freearg) (int argc, char *argv[]) {
|
||||||
if ($2) free($2);
|
if ($2) free($2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Required for C++ method overloading */
|
||||||
|
%typecheck(SWIG_TYPECHECK_STRING_ARRAY) (int argc, char *argv[]) {
|
||||||
|
$1 = PyList_Check($input) ? 1 : 0;
|
||||||
|
}
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -3481,6 +3599,11 @@ Other directives such as <tt>%apply</tt> and <tt>%clear</tt> also work with mult
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Don't forget to also provide a suitable <a href="#Typemaps_overloading">typemap for overloaded functions</a>, such as <tt>%typecheck</tt> shown for foo above.
|
||||||
|
This is only required if the function is overloaded in C++.
|
||||||
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Although multi-argument typemaps may seem like an exotic, little used feature, there
|
Although multi-argument typemaps may seem like an exotic, little used feature, there
|
||||||
are several situations where they make sense. First, suppose you wanted to wrap
|
are several situations where they make sense. First, suppose you wanted to wrap
|
||||||
|
|
@ -3510,7 +3633,7 @@ might write typemaps like this:
|
||||||
%typemap(in) (void *wbuffer, size_t len) {
|
%typemap(in) (void *wbuffer, size_t len) {
|
||||||
if (!PyString_Check($input)) {
|
if (!PyString_Check($input)) {
|
||||||
PyErr_SetString(PyExc_ValueError, "Expecting a string");
|
PyErr_SetString(PyExc_ValueError, "Expecting a string");
|
||||||
return NULL;
|
SWIG_fail;
|
||||||
}
|
}
|
||||||
$1 = (void *) PyString_AsString($input);
|
$1 = (void *) PyString_AsString($input);
|
||||||
$2 = PyString_Size($input);
|
$2 = PyString_Size($input);
|
||||||
|
|
@ -3520,12 +3643,12 @@ might write typemaps like this:
|
||||||
%typemap(in) (void *rbuffer, size_t len) {
|
%typemap(in) (void *rbuffer, size_t len) {
|
||||||
if (!PyInt_Check($input)) {
|
if (!PyInt_Check($input)) {
|
||||||
PyErr_SetString(PyExc_ValueError, "Expecting an integer");
|
PyErr_SetString(PyExc_ValueError, "Expecting an integer");
|
||||||
return NULL;
|
SWIG_fail;
|
||||||
}
|
}
|
||||||
$2 = PyInt_AsLong($input);
|
$2 = PyInt_AsLong($input);
|
||||||
if ($2 < 0) {
|
if ($2 < 0) {
|
||||||
PyErr_SetString(PyExc_ValueError, "Positive integer expected");
|
PyErr_SetString(PyExc_ValueError, "Positive integer expected");
|
||||||
return NULL;
|
SWIG_fail;
|
||||||
}
|
}
|
||||||
$1 = (void *) malloc($2);
|
$1 = (void *) malloc($2);
|
||||||
}
|
}
|
||||||
|
|
@ -3614,7 +3737,7 @@ with non-consecutive C/C++ arguments; a workaround such as a helper function re-
|
||||||
the arguments to make them consecutive will need to be written.
|
the arguments to make them consecutive will need to be written.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Typemaps_warnings"></a>11.10 Typemap warnings</H2>
|
<H2><a name="Typemaps_warnings">11.10 Typemap warnings</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3623,7 +3746,7 @@ See the information in the <a href="Warnings.html#Warnings_nn5">issuing warnings
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="Typemaps_fragments"></a>11.11 Typemap fragments</H2>
|
<H2><a name="Typemaps_fragments">11.11 Typemap fragments</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3876,7 +3999,7 @@ fragment usage unless a desire to really get to grips
|
||||||
with some powerful but tricky macro and fragment usage that is used in parts of the SWIG typemap library.
|
with some powerful but tricky macro and fragment usage that is used in parts of the SWIG typemap library.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Typemaps_fragment_type_specialization"></a>11.11.1 Fragment type specialization</H3>
|
<H3><a name="Typemaps_fragment_type_specialization">11.11.1 Fragment type specialization</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3909,7 +4032,7 @@ struct A {
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H3><a name="Typemaps_automatic_specialization"></a>11.11.2 Fragments and automatic typemap specialization</H3>
|
<H3><a name="Typemaps_automatic_specialization">11.11.2 Fragments and automatic typemap specialization</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3955,7 +4078,7 @@ The interested (or very brave) reader can take a look at the fragments.swg file
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="Typemaps_runtime_type_checker"></a>11.12 The run-time type checker</H2>
|
<H2><a name="Typemaps_runtime_type_checker">11.12 The run-time type checker</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3981,7 +4104,7 @@ language modules.</li>
|
||||||
<li>Modules can be unloaded from the type system.</li>
|
<li>Modules can be unloaded from the type system.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<H3><a name="Typemaps_nn45"></a>11.12.1 Implementation</H3>
|
<H3><a name="Typemaps_nn45">11.12.1 Implementation</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -4016,14 +4139,17 @@ For example:
|
||||||
<div class="code">
|
<div class="code">
|
||||||
<pre>
|
<pre>
|
||||||
class Foo {
|
class Foo {
|
||||||
|
public:
|
||||||
int x;
|
int x;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Bar {
|
class Bar {
|
||||||
|
public:
|
||||||
int y;
|
int y;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FooBar : public Foo, public Bar {
|
class FooBar : public Foo, public Bar {
|
||||||
|
public:
|
||||||
int z;
|
int z;
|
||||||
};
|
};
|
||||||
</pre>
|
</pre>
|
||||||
|
|
@ -4058,12 +4184,15 @@ handling of pointer values (and to make adjustments when needed).
|
||||||
<p>
|
<p>
|
||||||
In the wrapper code generated for each language, pointers are handled through
|
In the wrapper code generated for each language, pointers are handled through
|
||||||
the use of special type descriptors and conversion functions. For example,
|
the use of special type descriptors and conversion functions. For example,
|
||||||
if you look at the wrapper code for Python, you will see code like this:
|
if you look at the wrapper code for Python, you will see code similar to the following
|
||||||
|
(simplified for brevity):
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="code">
|
<div class="code">
|
||||||
<pre>
|
<pre>
|
||||||
if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Foo,1)) == -1) return NULL;
|
if (!SWIG_IsOK(SWIG_ConvertPtr(obj0, (void **) &arg1, SWIGTYPE_p_Foo, 0))) {
|
||||||
|
SWIG_exception_fail(SWIG_TypeError, "in method 'GrabVal', expecting type Foo");
|
||||||
|
}
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -4075,8 +4204,10 @@ target language, a list of equivalent typenames (via typedef or
|
||||||
inheritance), and pointer value handling information (if applicable).
|
inheritance), and pointer value handling information (if applicable).
|
||||||
The <tt>SWIG_ConvertPtr()</tt> function is simply a utility function
|
The <tt>SWIG_ConvertPtr()</tt> function is simply a utility function
|
||||||
that takes a pointer object in the target language and a
|
that takes a pointer object in the target language and a
|
||||||
type-descriptor objects and uses this information to generate a C++
|
type-descriptor object and uses this information to generate a C++ pointer.
|
||||||
pointer. However, the exact name and calling conventions of the conversion
|
The <tt>SWIG_IsOK</tt> macro checks the return value for errors and
|
||||||
|
<tt>SWIG_exception_fail</tt> can be called to raise an exception in the target language.
|
||||||
|
However, the exact name and calling conventions of the conversion
|
||||||
function depends on the target language (see language specific chapters for details).
|
function depends on the target language (see language specific chapters for details).
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
@ -4167,7 +4298,7 @@ structures rather than creating new ones. These <tt>swig_module_info</tt>
|
||||||
structures are chained together in a circularly linked list.
|
structures are chained together in a circularly linked list.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Typemaps_runtime_type_checker_usage"></a>11.12.2 Usage</H3>
|
<H3><a name="Typemaps_runtime_type_checker_usage">11.12.2 Usage</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>This section covers how to use these functions from typemaps. To learn how to
|
<p>This section covers how to use these functions from typemaps. To learn how to
|
||||||
|
|
@ -4182,7 +4313,9 @@ similar to this:
|
||||||
<div class="code">
|
<div class="code">
|
||||||
<pre>
|
<pre>
|
||||||
%typemap(in) Foo * {
|
%typemap(in) Foo * {
|
||||||
if ((SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor)) == -1) return NULL;
|
if (!SWIG_IsOK(SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, 0))) {
|
||||||
|
SWIG_exception_fail(SWIG_TypeError, "in method '$symname', expecting type Foo");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -4215,10 +4348,10 @@ descriptor name for any C datatype. For example:
|
||||||
<div class="code">
|
<div class="code">
|
||||||
<pre>
|
<pre>
|
||||||
%typemap(in) Foo * {
|
%typemap(in) Foo * {
|
||||||
if ((SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor)) == -1) {
|
if (!SWIG_IsOK(SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, 0))) {
|
||||||
Bar *temp;
|
Bar *temp;
|
||||||
if ((SWIG_ConvertPtr($input, (void **) &temp, <b>$descriptor(Bar *)</b>) == -1) {
|
if (!SWIG_IsOK(SWIG_ConvertPtr($input, (void **) &temp, $descriptor(Bar *), 0))) {
|
||||||
return NULL;
|
SWIG_exception_fail(SWIG_TypeError, "in method '$symname', expecting type Foo or Bar");
|
||||||
}
|
}
|
||||||
$1 = (Foo *)temp;
|
$1 = (Foo *)temp;
|
||||||
}
|
}
|
||||||
|
|
@ -4261,7 +4394,7 @@ probably just look at the output of SWIG to get a better sense for how types are
|
||||||
managed.
|
managed.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Typemaps_overloading"></a>11.13 Typemaps and overloading</H2>
|
<H2><a name="Typemaps_overloading">11.13 Typemaps and overloading</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -4466,38 +4599,13 @@ The following excerpt from the Python module illustrates this:
|
||||||
$1 = PyString_Check($input) ? 1 : 0;
|
$1 = PyString_Check($input) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
|
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE * {
|
||||||
void *ptr;
|
void *vptr = 0;
|
||||||
if (SWIG_ConvertPtr($input, (void **) &ptr, $1_descriptor, 0) == -1) {
|
int res = SWIG_ConvertPtr($input, &vptr, $1_descriptor, 0);
|
||||||
$1 = 0;
|
$1 = SWIG_IsOK(res) ? 1 : 0;
|
||||||
PyErr_Clear();
|
|
||||||
} else {
|
|
||||||
$1 = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE {
|
%typecheck(SWIG_TYPECHECK_POINTER) PyObject * {
|
||||||
void *ptr;
|
|
||||||
if (SWIG_ConvertPtr($input, (void **) &ptr, $&1_descriptor, 0) == -1) {
|
|
||||||
$1 = 0;
|
|
||||||
PyErr_Clear();
|
|
||||||
} else {
|
|
||||||
$1 = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
%typecheck(SWIG_TYPECHECK_VOIDPTR) void * {
|
|
||||||
void *ptr;
|
|
||||||
if (SWIG_ConvertPtr($input, (void **) &ptr, 0, 0) == -1) {
|
|
||||||
$1 = 0;
|
|
||||||
PyErr_Clear();
|
|
||||||
} else {
|
|
||||||
$1 = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
%typecheck(SWIG_TYPECHECK_POINTER) PyObject *
|
|
||||||
{
|
|
||||||
$1 = ($input != 0);
|
$1 = ($input != 0);
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
|
|
@ -4592,7 +4700,7 @@ Subsequent "in" typemaps would then perform more extensive type-checking.
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<H2><a name="Typemaps_nn48"></a>11.14 More about <tt>%apply</tt> and <tt>%clear</tt></H2>
|
<H2><a name="Typemaps_nn48">11.14 More about %apply and %clear</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -4678,7 +4786,7 @@ example:
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="Typemaps_nn47"></a>11.15 Passing data between typemaps</H2>
|
<H2><a name="Typemaps_nn47">11.15 Passing data between typemaps</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -4715,7 +4823,7 @@ sure that the typemaps sharing information have exactly the same types and names
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="Typemaps_nn52"></a>11.16 C++ "this" pointer</H2>
|
<H2><a name="Typemaps_nn52">11.16 C++ "this" pointer</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -4775,7 +4883,7 @@ will also match the typemap. One work around is to create an interface file tha
|
||||||
the method, but gives the argument a name other than <tt>self</tt>.
|
the method, but gives the argument a name other than <tt>self</tt>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Typemaps_nn51"></a>11.17 Where to go for more information?</H2>
|
<H2><a name="Typemaps_nn51">11.17 Where to go for more information?</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Variable Length Arguments</title>
|
<title>Variable Length Arguments</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
<H1><a name="Varargs"></a>14 Variable Length Arguments</H1>
|
<H1><a name="Varargs">14 Variable Length Arguments</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -42,7 +43,7 @@ added in SWIG-1.3.12. Most other wrapper generation tools have
|
||||||
wisely chosen to avoid this issue.
|
wisely chosen to avoid this issue.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Varargs_nn2"></a>14.1 Introduction</H2>
|
<H2><a name="Varargs_nn2">14.1 Introduction</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -139,7 +140,7 @@ List make_list(const char *s, ...) {
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H2><a name="Varargs_nn3"></a>14.2 The Problem</H2>
|
<H2><a name="Varargs_nn3">14.2 The Problem</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -232,7 +233,7 @@ can also support real varargs wrapping (with stack-frame manipulation) if you
|
||||||
are willing to get hands dirty. Keep reading.
|
are willing to get hands dirty. Keep reading.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Varargs_nn4"></a>14.3 Default varargs support</H2>
|
<H2><a name="Varargs_nn4">14.3 Default varargs support</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -301,7 +302,7 @@ Read on for further solutions.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="Varargs_nn5"></a>14.4 Argument replacement using %varargs</H2>
|
<H2><a name="Varargs_nn5">14.4 Argument replacement using %varargs</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -412,7 +413,7 @@ mixed argument types such as <tt>printf()</tt>. Providing general purpose
|
||||||
wrappers to such functions presents special problems (covered shortly).
|
wrappers to such functions presents special problems (covered shortly).
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Varargs_nn6"></a>14.5 Varargs and typemaps</H2>
|
<H2><a name="Varargs_nn6">14.5 Varargs and typemaps</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -516,7 +517,7 @@ like this:
|
||||||
argc = PyTuple_Size(varargs);
|
argc = PyTuple_Size(varargs);
|
||||||
if (argc > 10) {
|
if (argc > 10) {
|
||||||
PyErr_SetString(PyExc_ValueError, "Too many arguments");
|
PyErr_SetString(PyExc_ValueError, "Too many arguments");
|
||||||
return NULL;
|
SWIG_fail;
|
||||||
}
|
}
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
PyObject *pyobj = PyTuple_GetItem(varargs, i);
|
PyObject *pyobj = PyTuple_GetItem(varargs, i);
|
||||||
|
|
@ -525,7 +526,7 @@ like this:
|
||||||
PyObject *pystr;
|
PyObject *pystr;
|
||||||
if (!PyUnicode_Check(pyobj)) {
|
if (!PyUnicode_Check(pyobj)) {
|
||||||
PyErr_SetString(PyExc_ValueError, "Expected a string");
|
PyErr_SetString(PyExc_ValueError, "Expected a string");
|
||||||
return NULL;
|
SWIG_fail;
|
||||||
}
|
}
|
||||||
pystr = PyUnicode_AsUTF8String(pyobj);
|
pystr = PyUnicode_AsUTF8String(pyobj);
|
||||||
str = strdup(PyBytes_AsString(pystr));
|
str = strdup(PyBytes_AsString(pystr));
|
||||||
|
|
@ -533,7 +534,7 @@ like this:
|
||||||
%#else
|
%#else
|
||||||
if (!PyString_Check(pyobj)) {
|
if (!PyString_Check(pyobj)) {
|
||||||
PyErr_SetString(PyExc_ValueError, "Expected a string");
|
PyErr_SetString(PyExc_ValueError, "Expected a string");
|
||||||
return NULL;
|
SWIG_fail;
|
||||||
}
|
}
|
||||||
str = PyString_AsString(pyobj);
|
str = PyString_AsString(pyobj);
|
||||||
%#endif
|
%#endif
|
||||||
|
|
@ -589,7 +590,7 @@ really want to elevate your guru status and increase your job
|
||||||
security, continue to the next section.
|
security, continue to the next section.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Varargs_nn7"></a>14.6 Varargs wrapping with libffi</H2>
|
<H2><a name="Varargs_nn7">14.6 Varargs wrapping with libffi</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -605,7 +606,7 @@ you need to bring out some bigger guns.
|
||||||
<p>
|
<p>
|
||||||
One way to do this is to use a special purpose library such as libffi
|
One way to do this is to use a special purpose library such as libffi
|
||||||
(<a
|
(<a
|
||||||
href="http://sources.redhat.com/libffi/">http://sources.redhat.com/libffi</a>).
|
href="http://www.sourceware.org/libffi/">http://www.sourceware.org/libffi/</a>).
|
||||||
libffi is a library that allows you to dynamically construct
|
libffi is a library that allows you to dynamically construct
|
||||||
call-stacks and invoke procedures in a relatively platform independent
|
call-stacks and invoke procedures in a relatively platform independent
|
||||||
manner. Details about the library can be found in the libffi
|
manner. Details about the library can be found in the libffi
|
||||||
|
|
@ -634,9 +635,9 @@ example. For example:
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
PyObject *o = PyTuple_GetItem(varargs,i);
|
PyObject *o = PyTuple_GetItem(varargs,i);
|
||||||
if (!PyString_Check(o)) {
|
if (!PyString_Check(o)) {
|
||||||
PyErr_SetString(PyExc_ValueError,"Expected a string");
|
|
||||||
free(argv);
|
free(argv);
|
||||||
return NULL;
|
PyErr_SetString(PyExc_ValueError,"Expected a string");
|
||||||
|
SWIG_fail;
|
||||||
}
|
}
|
||||||
argv[i] = PyString_AsString(o);
|
argv[i] = PyString_AsString(o);
|
||||||
}
|
}
|
||||||
|
|
@ -675,11 +676,11 @@ example. For example:
|
||||||
&ffi_type_uint, types) == FFI_OK) {
|
&ffi_type_uint, types) == FFI_OK) {
|
||||||
ffi_call(&cif, (void (*)()) execlp, &result, values);
|
ffi_call(&cif, (void (*)()) execlp, &result, values);
|
||||||
} else {
|
} else {
|
||||||
PyErr_SetString(PyExc_RuntimeError, "Whoa!!!!!");
|
|
||||||
free(types);
|
free(types);
|
||||||
free(values);
|
free(values);
|
||||||
free(arg3);
|
free(arg3);
|
||||||
return NULL;
|
PyErr_SetString(PyExc_RuntimeError, "Whoa!!!!!");
|
||||||
|
SWIG_fail;
|
||||||
}
|
}
|
||||||
free(types);
|
free(types);
|
||||||
free(values);
|
free(values);
|
||||||
|
|
@ -743,8 +744,8 @@ As a more extreme example of libffi, here is some code that attempts to wrap <tt
|
||||||
argv[i].type = VT_POINTER;
|
argv[i].type = VT_POINTER;
|
||||||
argv[i].val.pvalue = (void *) PyString_AsString(o);
|
argv[i].val.pvalue = (void *) PyString_AsString(o);
|
||||||
} else {
|
} else {
|
||||||
PyErr_SetString(PyExc_ValueError,"Unsupported argument type");
|
|
||||||
free(argv);
|
free(argv);
|
||||||
|
PyErr_SetString(PyExc_ValueError,"Unsupported argument type");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -792,11 +793,11 @@ As a more extreme example of libffi, here is some code that attempts to wrap <tt
|
||||||
&ffi_type_uint, types) == FFI_OK) {
|
&ffi_type_uint, types) == FFI_OK) {
|
||||||
ffi_call(&cif, (void (*)()) printf, &result, values);
|
ffi_call(&cif, (void (*)()) printf, &result, values);
|
||||||
} else {
|
} else {
|
||||||
PyErr_SetString(PyExc_RuntimeError, "Whoa!!!!!");
|
|
||||||
free(types);
|
free(types);
|
||||||
free(values);
|
free(values);
|
||||||
free(args);
|
free(args);
|
||||||
return NULL;
|
PyErr_SetString(PyExc_RuntimeError, "Whoa!!!!!");
|
||||||
|
SWIG_fail;
|
||||||
}
|
}
|
||||||
free(types);
|
free(types);
|
||||||
free(values);
|
free(values);
|
||||||
|
|
@ -841,7 +842,7 @@ provide an argument number for the first extra argument. This can be used to in
|
||||||
values. Please consult the chapter on each language module for more details.
|
values. Please consult the chapter on each language module for more details.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Varargs_nn8"></a>14.7 Wrapping of va_list</H2>
|
<H2><a name="Varargs_nn8">14.7 Wrapping of va_list</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -895,7 +896,7 @@ int my_vprintf(const char *fmt, ...) {
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H2><a name="Varargs_nn9"></a>14.8 C++ Issues</H2>
|
<H2><a name="Varargs_nn9">14.8 C++ Issues</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -964,7 +965,7 @@ design or to provide an alternative interface using a helper function than it is
|
||||||
fully general wrapper to a varargs C++ member function.
|
fully general wrapper to a varargs C++ member function.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Varargs_nn10"></a>14.9 Discussion</H2>
|
<H2><a name="Varargs_nn10">14.9 Discussion</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Warning Messages</title>
|
<title>Warning Messages</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
<H1><a name="Warnings"></a>15 Warning Messages</H1>
|
<H1><a name="Warnings">15 Warning Messages</a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -35,7 +36,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="Warnings_nn2"></a>15.1 Introduction</H2>
|
<H2><a name="Warnings_nn2">15.1 Introduction</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -55,7 +56,7 @@ where the generated wrapper code will probably compile, but it may not
|
||||||
work like you expect.
|
work like you expect.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Warnings_suppression"></a>15.2 Warning message suppression</H2>
|
<H2><a name="Warnings_suppression">15.2 Warning message suppression</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -147,7 +148,7 @@ your interface. Ignore the warning messages at your own peril.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="Warnings_nn4"></a>15.3 Enabling extra warnings</H2>
|
<H2><a name="Warnings_nn4">15.3 Enabling extra warnings</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -220,7 +221,7 @@ that is, any warnings suppressed or added in <tt>%warnfilter</tt>, <tt>#pragma S
|
||||||
or the <tt>-w</tt> option.
|
or the <tt>-w</tt> option.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Warnings_nn5"></a>15.4 Issuing a warning message</H2>
|
<H2><a name="Warnings_nn5">15.4 Issuing a warning message</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -274,7 +275,7 @@ example.i:24: Warning 901: You are really going to regret this usage of blah * s
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H2><a name="Warnings_symbolic_symbols"></a>15.5 Symbolic symbols</H2>
|
<H2><a name="Warnings_symbolic_symbols">15.5 Symbolic symbols</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -309,7 +310,7 @@ or
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<H2><a name="Warnings_nn6"></a>15.6 Commentary</H2>
|
<H2><a name="Warnings_nn6">15.6 Commentary</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -326,7 +327,7 @@ no obvious recovery. There is no mechanism for suppressing error
|
||||||
messages.
|
messages.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Warnings_nn7"></a>15.7 Warnings as errors</H2>
|
<H2><a name="Warnings_nn7">15.7 Warnings as errors</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -335,7 +336,7 @@ option. This will cause SWIG to exit with a non successful exit code if a
|
||||||
warning is encountered.
|
warning is encountered.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Warnings_nn8"></a>15.8 Message output format</H2>
|
<H2><a name="Warnings_nn8">15.8 Message output format</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -354,10 +355,10 @@ $ swig -python -Fmicrosoft example.i
|
||||||
example.i(4) : Syntax error in input(1).
|
example.i(4) : Syntax error in input(1).
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H2><a name="Warnings_nn9"></a>15.9 Warning number reference</H2>
|
<H2><a name="Warnings_nn9">15.9 Warning number reference</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Warnings_nn10"></a>15.9.1 Deprecated features (100-199)</H3>
|
<H3><a name="Warnings_nn10">15.9.1 Deprecated features (100-199)</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -385,7 +386,7 @@ example.i(4) : Syntax error in input(1).
|
||||||
<li>126. The 'nestedworkaround' feature is deprecated.
|
<li>126. The 'nestedworkaround' feature is deprecated.
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<H3><a name="Warnings_nn11"></a>15.9.2 Preprocessor (200-299)</H3>
|
<H3><a name="Warnings_nn11">15.9.2 Preprocessor (200-299)</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -397,7 +398,7 @@ example.i(4) : Syntax error in input(1).
|
||||||
<li>206. Unexpected tokens after #<em>directive</em> directive.
|
<li>206. Unexpected tokens after #<em>directive</em> directive.
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<H3><a name="Warnings_nn12"></a>15.9.3 C/C++ Parser (300-399)</H3>
|
<H3><a name="Warnings_nn12">15.9.3 C/C++ Parser (300-399)</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -474,7 +475,7 @@ example.i(4) : Syntax error in input(1).
|
||||||
<li>395. operator delete[] ignored.
|
<li>395. operator delete[] ignored.
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<H3><a name="Warnings_nn13"></a>15.9.4 Types and typemaps (400-499) </H3>
|
<H3><a name="Warnings_nn13">15.9.4 Types and typemaps (400-499) </a></H3>
|
||||||
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -505,7 +506,7 @@ example.i(4) : Syntax error in input(1).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Warnings_nn14"></a>15.9.5 Code generation (500-599)</H3>
|
<H3><a name="Warnings_nn14">15.9.5 Code generation (500-599)</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -534,7 +535,7 @@ example.i(4) : Syntax error in input(1).
|
||||||
<li>523. Use of an illegal destructor name '<em>name</em>' in %extend is deprecated, the destructor name should be '<em>name</em>'.
|
<li>523. Use of an illegal destructor name '<em>name</em>' in %extend is deprecated, the destructor name should be '<em>name</em>'.
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<H3><a name="Warnings_nn15"></a>15.9.6 Language module specific (700-899) </H3>
|
<H3><a name="Warnings_nn15">15.9.6 Language module specific (700-899) </a></H3>
|
||||||
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -545,7 +546,7 @@ example.i(4) : Syntax error in input(1).
|
||||||
<li>810. No jni typemap defined for <em>type</em> (Java).
|
<li>810. No jni typemap defined for <em>type</em> (Java).
|
||||||
<li>811. No jtype typemap defined for <em>type</em> (Java).
|
<li>811. No jtype typemap defined for <em>type</em> (Java).
|
||||||
<li>812. No jstype typemap defined for <em>type</em> (Java).
|
<li>812. No jstype typemap defined for <em>type</em> (Java).
|
||||||
<li>813. Warning for <em>classname</em>: Base <em>baseclass</em> ignored. Multiple inheritance is not supported in Java. (Java).
|
<li>813. Warning for <em>classname</em>, base <em>baseclass</em> ignored. Multiple inheritance is not supported in Java. (Java).
|
||||||
<li>814.
|
<li>814.
|
||||||
<li>815. No javafinalize typemap defined for <em>type</em> (Java).
|
<li>815. No javafinalize typemap defined for <em>type</em> (Java).
|
||||||
<li>816. No javabody typemap defined for <em>type</em> (Java).
|
<li>816. No javabody typemap defined for <em>type</em> (Java).
|
||||||
|
|
@ -565,7 +566,7 @@ example.i(4) : Syntax error in input(1).
|
||||||
<li>830. No ctype typemap defined for <em>type</em> (C#).
|
<li>830. No ctype typemap defined for <em>type</em> (C#).
|
||||||
<li>831. No cstype typemap defined for <em>type</em> (C#).
|
<li>831. No cstype typemap defined for <em>type</em> (C#).
|
||||||
<li>832. No cswtype typemap defined for <em>type</em> (C#).
|
<li>832. No cswtype typemap defined for <em>type</em> (C#).
|
||||||
<li>833. Warning for <em>classname</em>: Base <em>baseclass</em> ignored. Multiple inheritance is not supported in C#. (C#).
|
<li>833. Warning for <em>classname</em>, base <em>baseclass</em> ignored. Multiple inheritance is not supported in C#. (C#).
|
||||||
<li>834.
|
<li>834.
|
||||||
<li>835. No csfinalize typemap defined for <em>type</em> (C#).
|
<li>835. No csfinalize typemap defined for <em>type</em> (C#).
|
||||||
<li>836. No csbody typemap defined for <em>type</em> (C#).
|
<li>836. No csbody typemap defined for <em>type</em> (C#).
|
||||||
|
|
@ -581,18 +582,18 @@ example.i(4) : Syntax error in input(1).
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>870. Warning for <em>classname</em>: Base <em>baseclass</em> ignored. Multiple inheritance is not supported in PHP.
|
<li>870. Warning for <em>classname</em>: Base <em>baseclass</em> ignored. Multiple inheritance is not supported in PHP. (Php).
|
||||||
<li>871. Unrecognized pragma <em>pragma</em>. (Php).
|
<li>871. Unrecognized pragma <em>pragma</em>. (Php).
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<H3><a name="Warnings_nn16"></a>15.9.7 User defined (900-999)</H3>
|
<H3><a name="Warnings_nn16">15.9.7 User defined (900-999)</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
These numbers can be used by your own application.
|
These numbers can be used by your own application.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Warnings_nn17"></a>15.10 History</H2>
|
<H2><a name="Warnings_nn17">15.10 History</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Getting started on Windows</title>
|
<title>Getting started on Windows</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
<H1><a name="Windows"></a>3 Getting started on Windows </H1>
|
<H1><a name="Windows">3 Getting started on Windows </a></H1>
|
||||||
<!-- INDEX -->
|
<!-- INDEX -->
|
||||||
<div class="sectiontoc">
|
<div class="sectiontoc">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -52,7 +53,7 @@ Usage within the Unix like environments MinGW and Cygwin is also detailed.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="Windows_installation"></a>3.1 Installation on Windows</H2>
|
<H2><a name="Windows_installation">3.1 Installation on Windows</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -63,7 +64,7 @@ SWIG does not come with the usual Windows type installation program, however it
|
||||||
<li>Set environment variables as described in the <a href="#Windows_examples">SWIG Windows Examples</a> section in order to run examples using Visual C++.
|
<li>Set environment variables as described in the <a href="#Windows_examples">SWIG Windows Examples</a> section in order to run examples using Visual C++.
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<H3><a name="Windows_executable"></a>3.1.1 Windows Executable</H3>
|
<H3><a name="Windows_executable">3.1.1 Windows Executable</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -72,7 +73,7 @@ If you want to build your own swig.exe have a look at <a href="#Windows_swig_exe
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H2><a name="Windows_examples"></a>3.2 SWIG Windows Examples</H2>
|
<H2><a name="Windows_examples">3.2 SWIG Windows Examples</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -87,7 +88,7 @@ Alternatively run the <a href="#Windows_examples_cygwin">examples using Cygwin</
|
||||||
<p>
|
<p>
|
||||||
More information on each of the examples is available with the examples distributed with SWIG (Examples/index.html).
|
More information on each of the examples is available with the examples distributed with SWIG (Examples/index.html).
|
||||||
|
|
||||||
<H3><a name="Windows_visual_studio"></a>3.2.1 Instructions for using the Examples with Visual Studio</H3>
|
<H3><a name="Windows_visual_studio">3.2.1 Instructions for using the Examples with Visual Studio</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -105,7 +106,7 @@ If you don't want to use environment variables then change all occurrences of th
|
||||||
If you are interested in how the project files are set up there is explanatory information in some of the language module's documentation.
|
If you are interested in how the project files are set up there is explanatory information in some of the language module's documentation.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H4><a name="Windows_csharp"></a>3.2.1.1 C#</H4>
|
<H4><a name="Windows_csharp">3.2.1.1 C#</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -115,7 +116,7 @@ The accompanying C# and C++ project files are automatically used by the solution
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H4><a name="Windows_java"></a>3.2.1.2 Java</H4>
|
<H4><a name="Windows_java">3.2.1.2 Java</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -129,7 +130,7 @@ JAVA_BIN: D:\jdk1.3\bin<br>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H4><a name="Windows_perl"></a>3.2.1.3 Perl</H4>
|
<H4><a name="Windows_perl">3.2.1.3 Perl</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -143,7 +144,7 @@ PERL5_LIB: D:\nsPerl5.004_04\lib\CORE\perl.lib<br>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H4><a name="Windows_python"></a>3.2.1.4 Python</H4>
|
<H4><a name="Windows_python">3.2.1.4 Python</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -157,7 +158,7 @@ PYTHON_LIB: D:\python21\libs\python21.lib<br>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H4><a name="Windows_tcl"></a>3.2.1.5 TCL</H4>
|
<H4><a name="Windows_tcl">3.2.1.5 TCL</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -171,7 +172,7 @@ TCL_LIB: D:\tcl\lib\tcl83.lib<br>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H4><a name="Windows_r"></a>3.2.1.6 R</H4>
|
<H4><a name="Windows_r">3.2.1.6 R</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -185,7 +186,7 @@ R_LIB: C:\Program Files\R\R-2.5.1\bin\Rdll.lib<br>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H4><a name="Windows_ruby"></a>3.2.1.7 Ruby</H4>
|
<H4><a name="Windows_ruby">3.2.1.7 Ruby</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -199,21 +200,21 @@ RUBY_LIB: D:\ruby\lib\mswin32-ruby16.lib<br>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Windows_other_compilers"></a>3.2.2 Instructions for using the Examples with other compilers</H3>
|
<H3><a name="Windows_other_compilers">3.2.2 Instructions for using the Examples with other compilers</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
If you do not have access to Visual C++ you will have to set up project files / Makefiles for your chosen compiler. There is a section in each of the language modules detailing what needs setting up using Visual C++ which may be of some guidance. Alternatively you may want to use Cygwin as described in the following section.
|
If you do not have access to Visual C++ you will have to set up project files / Makefiles for your chosen compiler. There is a section in each of the language modules detailing what needs setting up using Visual C++ which may be of some guidance. Alternatively you may want to use Cygwin as described in the following section.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Windows_cygwin_mingw"></a>3.3 SWIG on Cygwin and MinGW</H2>
|
<H2><a name="Windows_cygwin_mingw">3.3 SWIG on Cygwin and MinGW</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
SWIG can also be compiled and run using <a href="http://www.cygwin.com">Cygwin</a> or <a href="http://www.mingw.org">MinGW</a> which provides a Unix like front end to Windows and comes free with gcc, an ANSI C/C++ compiler. However, this is not a recommended approach as the prebuilt executable is supplied.
|
SWIG can also be compiled and run using <a href="http://www.cygwin.com">Cygwin</a> or <a href="http://www.mingw.org">MinGW</a> which provides a Unix like front end to Windows and comes free with gcc, an ANSI C/C++ compiler. However, this is not a recommended approach as the prebuilt executable is supplied.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H3><a name="Windows_swig_exe"></a>3.3.1 Building swig.exe on Windows</H3>
|
<H3><a name="Windows_swig_exe">3.3.1 Building swig.exe on Windows</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -223,7 +224,7 @@ This information is provided for those that want to modify the SWIG source code
|
||||||
Normally this is not needed, so most people will want to ignore this section.
|
Normally this is not needed, so most people will want to ignore this section.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H4><a name="Windows_mingw_msys"></a>3.3.1.1 Building swig.exe using MinGW and MSYS</H4>
|
<H4><a name="Windows_mingw_msys">3.3.1.1 Building swig.exe using MinGW and MSYS</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -341,7 +342,7 @@ make
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
<H4><a name="Windows_cygwin"></a>3.3.1.2 Building swig.exe using Cygwin</H4>
|
<H4><a name="Windows_cygwin">3.3.1.2 Building swig.exe using Cygwin</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -352,7 +353,7 @@ Note that the Cygwin environment will also allow one to regenerate the autotool
|
||||||
These files are generated using the <tt>autogen.sh</tt> script and will only need regenerating in circumstances such as changing the build system.
|
These files are generated using the <tt>autogen.sh</tt> script and will only need regenerating in circumstances such as changing the build system.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H4><a name="Windows_building_alternatives"></a>3.3.1.3 Building swig.exe alternatives</H4>
|
<H4><a name="Windows_building_alternatives">3.3.1.3 Building swig.exe alternatives</a></H4>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -362,7 +363,7 @@ file in order to build swig.exe from the Visual C++ IDE.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H3><a name="Windows_examples_cygwin"></a>3.3.2 Running the examples on Windows using Cygwin</H3>
|
<H3><a name="Windows_examples_cygwin">3.3.2 Running the examples on Windows using Cygwin</a></H3>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -371,7 +372,7 @@ The modules which are known to work are Python, Tcl, Perl, Ruby, Java and C#.
|
||||||
Follow the Unix instructions in the README file in the SWIG root directory to build the examples.
|
Follow the Unix instructions in the README file in the SWIG root directory to build the examples.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<H2><a name="Windows_interface_file"></a>3.4 Microsoft extensions and other Windows quirks</H2>
|
<H2><a name="Windows_interface_file">3.4 Microsoft extensions and other Windows quirks</a></H2>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
# Adds the SWIG stylesheet to the generated documentation on a single page
|
# Replace the inline htmldoc stylesheet with the SWIG stylesheet
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import string
|
import string
|
||||||
|
|
@ -14,11 +14,16 @@ swigstyle = "\n" + open("style.css").read()
|
||||||
|
|
||||||
lines = data.splitlines()
|
lines = data.splitlines()
|
||||||
result = [ ]
|
result = [ ]
|
||||||
|
skip = False
|
||||||
for s in lines:
|
for s in lines:
|
||||||
if s == "<STYLE TYPE=\"text/css\"><!--":
|
if not skip:
|
||||||
result.append(s + swigstyle)
|
|
||||||
else:
|
|
||||||
result.append(s)
|
result.append(s)
|
||||||
|
if s == "<STYLE TYPE=\"text/css\"><!--":
|
||||||
|
result.append(swigstyle)
|
||||||
|
skip = True
|
||||||
|
elif s == "--></STYLE>":
|
||||||
|
result.append(s)
|
||||||
|
skip = False
|
||||||
|
|
||||||
data = "\n".join(result)
|
data = "\n".join(result)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>SWIG-3.0 Documentation</title>
|
<title>SWIG-3.0 Documentation</title>
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
<H1><a name="index"></a>SWIG-3.0 Documentation</h1>
|
<H1><a name="index">SWIG-3.0 Documentation</a></H1>
|
||||||
|
|
||||||
The SWIG documentation is available in one of the following formats.
|
The SWIG documentation is available in one of the following formats.
|
||||||
<ul>
|
<ul>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
[checking]
|
|
||||||
anchors=1
|
|
||||||
|
|
||||||
[filtering]
|
[filtering]
|
||||||
ignorewarnings=http-robots-denied
|
ignorewarnings=http-robots-denied
|
||||||
|
ignorewarnings=https-certificate-error
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ import string
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
# Regexs for <a name="..."></a>
|
# Regexs for <a name="..."></a>
|
||||||
alink = re.compile(r"<a *name *= *\"(.*)\"></a>", re.IGNORECASE)
|
alink = re.compile(r"<a *name *= *\"(.*)\">.*</a>", re.IGNORECASE)
|
||||||
heading = re.compile(r"(_nn\d)", re.IGNORECASE)
|
heading = re.compile(r"(_nn\d)", re.IGNORECASE)
|
||||||
|
|
||||||
def getheadingname(m):
|
def getheadingname(m):
|
||||||
|
|
@ -38,6 +38,19 @@ def getheadingname(m):
|
||||||
headingname = "%s_nn%d" % (filenamebase, nameindex)
|
headingname = "%s_nn%d" % (filenamebase, nameindex)
|
||||||
return headingname
|
return headingname
|
||||||
|
|
||||||
|
# Return heading - 1.1. Introduction in the examples below:
|
||||||
|
# old style example: <H2><a name="Preface_nn2"></a>1.1 Introduction</H2>
|
||||||
|
# new style example: <H2><a name="Preface_nn2">1.1 Introduction</a></H2>
|
||||||
|
def getheadingtext(m, s):
|
||||||
|
prevheadingtext_newstyle = m.group(2)
|
||||||
|
prevheadingtext_oldstyle = m.group(3)
|
||||||
|
if len(prevheadingtext_oldstyle) == 0 and len(prevheadingtext_newstyle) == 0:
|
||||||
|
raise RuntimeError("No heading text in line:\n%s" % s)
|
||||||
|
if len(prevheadingtext_oldstyle) > 0 and len(prevheadingtext_newstyle) > 0:
|
||||||
|
raise RuntimeError("Two heading texts, only one should be specified in line:\n%s" % s)
|
||||||
|
prevheadingtext = prevheadingtext_oldstyle if len(prevheadingtext_oldstyle) > 0 else prevheadingtext_newstyle
|
||||||
|
return prevheadingtext
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Main program
|
# Main program
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
@ -59,11 +72,11 @@ name = ""
|
||||||
|
|
||||||
# Regexs for <h1>,... <h5> sections
|
# Regexs for <h1>,... <h5> sections
|
||||||
|
|
||||||
h1 = re.compile(r".*?<H1>(<a.*a>)*[\d\.\s]*(.*?)</H1>", re.IGNORECASE)
|
h1 = re.compile(r".*?<H1>(<a.*?>\s*[\d\s]*(.*?)</a>)*[\d\s]*(.*?)</H1>", re.IGNORECASE)
|
||||||
h2 = re.compile(r".*?<H2>(<a.*a>)*[\d\.\s]*(.*?)</H2>", re.IGNORECASE)
|
h2 = re.compile(r".*?<H2>(<a.*?>\s*[\d\.\s]*(.*?)</a>)*[\d\.\s]*(.*?)</H2>", re.IGNORECASE)
|
||||||
h3 = re.compile(r".*?<H3>(<a.*a>)*[\d\.\s]*(.*?)</H3>", re.IGNORECASE)
|
h3 = re.compile(r".*?<H3>(<a.*?>\s*[\d\.\s]*(.*?)</a>)*[\d\.\s]*(.*?)</H3>", re.IGNORECASE)
|
||||||
h4 = re.compile(r".*?<H4>(<a.*a>)*[\d\.\s]*(.*?)</H4>", re.IGNORECASE)
|
h4 = re.compile(r".*?<H4>(<a.*?>\s*[\d\.\s]*(.*?)</a>)*[\d\.\s]*(.*?)</H4>", re.IGNORECASE)
|
||||||
h5 = re.compile(r".*?<H5>(<a.*a>)*[\d\.\s]*(.*?)</H5>", re.IGNORECASE)
|
h5 = re.compile(r".*?<H5>(<a.*?>\s*[\d\.\s]*(.*?)</a>)*[\d\.\s]*(.*?)</H5>", re.IGNORECASE)
|
||||||
|
|
||||||
data = open(filename).read() # Read data
|
data = open(filename).read() # Read data
|
||||||
open(filename+".bak","w").write(data) # Make backup
|
open(filename+".bak","w").write(data) # Make backup
|
||||||
|
|
@ -95,10 +108,10 @@ for s in lines:
|
||||||
|
|
||||||
m = h1.match(s)
|
m = h1.match(s)
|
||||||
if m:
|
if m:
|
||||||
prevheadingtext = m.group(2)
|
prevheadingtext = getheadingtext(m, s)
|
||||||
nameindex += 1
|
nameindex += 1
|
||||||
headingname = getheadingname(m)
|
headingname = getheadingname(m)
|
||||||
result.append("""<H1><a name="%s"></a>%d %s</H1>""" % (headingname,num,prevheadingtext))
|
result.append("""<H1><a name="%s">%d %s</a></H1>""" % (headingname,num,prevheadingtext))
|
||||||
result.append("@INDEX@")
|
result.append("@INDEX@")
|
||||||
section = 0
|
section = 0
|
||||||
subsection = 0
|
subsection = 0
|
||||||
|
|
@ -109,11 +122,11 @@ for s in lines:
|
||||||
continue
|
continue
|
||||||
m = h2.match(s)
|
m = h2.match(s)
|
||||||
if m:
|
if m:
|
||||||
prevheadingtext = m.group(2)
|
prevheadingtext = getheadingtext(m, s)
|
||||||
nameindex += 1
|
nameindex += 1
|
||||||
section += 1
|
section += 1
|
||||||
headingname = getheadingname(m)
|
headingname = getheadingname(m)
|
||||||
result.append("""<H2><a name="%s"></a>%d.%d %s</H2>""" % (headingname,num,section, prevheadingtext))
|
result.append("""<H2><a name="%s">%d.%d %s</a></H2>""" % (headingname,num,section, prevheadingtext))
|
||||||
|
|
||||||
if subsubsubsection:
|
if subsubsubsection:
|
||||||
index += "</ul>\n"
|
index += "</ul>\n"
|
||||||
|
|
@ -132,11 +145,11 @@ for s in lines:
|
||||||
continue
|
continue
|
||||||
m = h3.match(s)
|
m = h3.match(s)
|
||||||
if m:
|
if m:
|
||||||
prevheadingtext = m.group(2)
|
prevheadingtext = getheadingtext(m, s)
|
||||||
nameindex += 1
|
nameindex += 1
|
||||||
subsection += 1
|
subsection += 1
|
||||||
headingname = getheadingname(m)
|
headingname = getheadingname(m)
|
||||||
result.append("""<H3><a name="%s"></a>%d.%d.%d %s</H3>""" % (headingname,num,section, subsection, prevheadingtext))
|
result.append("""<H3><a name="%s">%d.%d.%d %s</a></H3>""" % (headingname,num,section, subsection, prevheadingtext))
|
||||||
|
|
||||||
if subsubsubsection:
|
if subsubsubsection:
|
||||||
index += "</ul>\n"
|
index += "</ul>\n"
|
||||||
|
|
@ -151,12 +164,12 @@ for s in lines:
|
||||||
continue
|
continue
|
||||||
m = h4.match(s)
|
m = h4.match(s)
|
||||||
if m:
|
if m:
|
||||||
prevheadingtext = m.group(2)
|
prevheadingtext = getheadingtext(m, s)
|
||||||
nameindex += 1
|
nameindex += 1
|
||||||
subsubsection += 1
|
subsubsection += 1
|
||||||
|
|
||||||
headingname = getheadingname(m)
|
headingname = getheadingname(m)
|
||||||
result.append("""<H4><a name="%s"></a>%d.%d.%d.%d %s</H4>""" % (headingname,num,section, subsection, subsubsection, prevheadingtext))
|
result.append("""<H4><a name="%s">%d.%d.%d.%d %s</a></H4>""" % (headingname,num,section, subsection, subsubsection, prevheadingtext))
|
||||||
|
|
||||||
if subsubsubsection:
|
if subsubsubsection:
|
||||||
index += "</ul>\n"
|
index += "</ul>\n"
|
||||||
|
|
@ -169,11 +182,11 @@ for s in lines:
|
||||||
continue
|
continue
|
||||||
m = h5.match(s)
|
m = h5.match(s)
|
||||||
if m:
|
if m:
|
||||||
prevheadingtext = m.group(2)
|
prevheadingtext = getheadingtext(m, s)
|
||||||
nameindex += 1
|
nameindex += 1
|
||||||
subsubsubsection += 1
|
subsubsubsection += 1
|
||||||
headingname = getheadingname(m)
|
headingname = getheadingname(m)
|
||||||
result.append("""<H5><a name="%s"></a>%d.%d.%d.%d.%d %s</H5>""" % (headingname,num,section, subsection, subsubsection, subsubsubsection, prevheadingtext))
|
result.append("""<H5><a name="%s">%d.%d.%d.%d.%d %s</a></H5>""" % (headingname,num,section, subsection, subsubsection, subsubsubsection, prevheadingtext))
|
||||||
|
|
||||||
if subsubsubsection == 1:
|
if subsubsubsection == 1:
|
||||||
index += "<ul>\n"
|
index += "<ul>\n"
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,14 @@ chs = open("chapters").readlines()
|
||||||
|
|
||||||
f = open("Contents.html","w")
|
f = open("Contents.html","w")
|
||||||
print >>f, """
|
print >>f, """
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<HTML>
|
<HTML>
|
||||||
<HEAD>
|
<HEAD>
|
||||||
<TITLE>SWIG Users Manual</TITLE>
|
<TITLE>SWIG Users Manual</TITLE>
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</HEAD>
|
</HEAD>
|
||||||
<BODY BGCOLOR="#ffffff">
|
<BODY BGCOLOR="#ffffff">
|
||||||
|
|
||||||
<H1><a name="Contents"></a>SWIG Users Manual</H1>
|
<H1><a name="Contents"></a>SWIG Users Manual</H1>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -1,277 +0,0 @@
|
||||||
# This patch is against htmldoc 1.8.27, and it hacks in support for
|
|
||||||
# correctly indenting the <div class=""> sections in the SWIG manual.
|
|
||||||
# This patch should only be used until the 1.9 branch of htmldoc
|
|
||||||
# stabilizes, since the 1.9 branch includes true CSS1 support.
|
|
||||||
#
|
|
||||||
# This patch only affects the PDF generation, an unpatched htmldoc
|
|
||||||
# creates the one-page html documentation just fine.
|
|
||||||
#
|
|
||||||
diff -Naur htmldoc-1.8.27/htmldoc/htmldoc.cxx htmldoc-1.8.27-margin-left/htmldoc/htmldoc.cxx
|
|
||||||
--- htmldoc-1.8.27/htmldoc/htmldoc.cxx 2006-03-30 14:01:20.000000000 +0100
|
|
||||||
+++ htmldoc-1.8.27-margin-left/htmldoc/htmldoc.cxx 2013-05-11 10:11:47.428435647 +0100
|
|
||||||
@@ -65,6 +65,8 @@
|
|
||||||
const char *__XOS2RedirRoot(const char *);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
+
|
|
||||||
+extern void parse_style(char *);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
@@ -1115,6 +1117,7 @@
|
|
||||||
else if (compare_strings(argv[i], "--version", 6) == 0)
|
|
||||||
{
|
|
||||||
puts(SVERSION);
|
|
||||||
+ puts("Patched with margin-left.patch");
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
else if (compare_strings(argv[i], "--webpage", 3) == 0)
|
|
||||||
@@ -2403,6 +2406,10 @@
|
|
||||||
}
|
|
||||||
else if (strcmp(temp, "--cookies") == 0)
|
|
||||||
file_cookies(temp2);
|
|
||||||
+ else if (strcmp(temp, "--stylesheet") == 0)
|
|
||||||
+ {
|
|
||||||
+ parse_style(temp2);
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
diff -Naur htmldoc-1.8.27/htmldoc/Makefile htmldoc-1.8.27-margin-left/htmldoc/Makefile
|
|
||||||
--- htmldoc-1.8.27/htmldoc/Makefile 2005-10-28 21:32:59.000000000 +0100
|
|
||||||
+++ htmldoc-1.8.27-margin-left/htmldoc/Makefile 2013-05-11 09:39:04.392367869 +0100
|
|
||||||
@@ -36,7 +36,7 @@
|
|
||||||
OBJS = gui.o file.o html.o htmldoc.o htmllib.o htmlsep.o \
|
|
||||||
http.o http-addr.o http-addrlist.o http-support.o image.o \
|
|
||||||
iso8859.o license.o md5.o progress.o ps-pdf.o rc4.o \
|
|
||||||
- snprintf.o string.o toc.o util.o
|
|
||||||
+ snprintf.o string.o toc.o util.o style.o
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
diff -Naur htmldoc-1.8.27/htmldoc/ps-pdf.cxx htmldoc-1.8.27-margin-left/htmldoc/ps-pdf.cxx
|
|
||||||
--- htmldoc-1.8.27/htmldoc/ps-pdf.cxx 2006-08-01 17:58:50.000000000 +0100
|
|
||||||
+++ htmldoc-1.8.27-margin-left/htmldoc/ps-pdf.cxx 2013-05-11 09:37:40.096364957 +0100
|
|
||||||
@@ -160,6 +160,7 @@
|
|
||||||
# undef page_t
|
|
||||||
#endif // __hpux
|
|
||||||
|
|
||||||
+extern int lookup_div_class(uchar *);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Output options...
|
|
||||||
@@ -4230,9 +4231,24 @@
|
|
||||||
para->child = para->last_child = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
- parse_doc(t->child, left, right, bottom, top, x, y, page, NULL,
|
|
||||||
+ {
|
|
||||||
+ int num_indent = 0;
|
|
||||||
+ uchar *cname;
|
|
||||||
+
|
|
||||||
+ if (cname = htmlGetVariable(t, (uchar *)"class")) {
|
|
||||||
+ num_indent = lookup_div_class(cname);
|
|
||||||
+ *left += 5.0f * num_indent;
|
|
||||||
+ *x = *left;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ parse_doc(t->child, left, right, bottom, top, x, y, page, NULL,
|
|
||||||
needspace);
|
|
||||||
|
|
||||||
+ if (num_indent > 0) {
|
|
||||||
+ *left -= 5.0f * num_indent;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
if (para->child != NULL)
|
|
||||||
{
|
|
||||||
parse_paragraph(para, *left, *right, *bottom, *top, x, y, page, *needspace);
|
|
||||||
diff -Naur htmldoc-1.8.27/htmldoc/style.cxx htmldoc-1.8.27-margin-left/htmldoc/style.cxx
|
|
||||||
--- htmldoc-1.8.27/htmldoc/style.cxx 1970-01-01 01:00:00.000000000 +0100
|
|
||||||
+++ htmldoc-1.8.27-margin-left/htmldoc/style.cxx 2013-05-11 09:37:40.096364957 +0100
|
|
||||||
@@ -0,0 +1,185 @@
|
|
||||||
+/* Extreamly simple parsing routines for CSS style sheets.
|
|
||||||
+ * We only parse div.class { } sections, and only look
|
|
||||||
+ * for margin-left: <num>em;
|
|
||||||
+ *
|
|
||||||
+ * Copyright (C) 2005 John Lenz <lenz@cs.wisc.edu>
|
|
||||||
+ *
|
|
||||||
+ * Released under GNU GPL v2 or above.
|
|
||||||
+ */
|
|
||||||
+
|
|
||||||
+#include <stdio.h>
|
|
||||||
+#include <stdlib.h>
|
|
||||||
+#include <fcntl.h>
|
|
||||||
+#include <string.h>
|
|
||||||
+#include <ctype.h>
|
|
||||||
+
|
|
||||||
+#include "types.h"
|
|
||||||
+
|
|
||||||
+#define BUFF_SIZE 512
|
|
||||||
+
|
|
||||||
+struct div_entry {
|
|
||||||
+ uchar class_name[BUFF_SIZE];
|
|
||||||
+ int indent;
|
|
||||||
+ struct div_entry *next;
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+static struct div_entry *head = 0;
|
|
||||||
+
|
|
||||||
+/* These are the parsing states */
|
|
||||||
+#define IGNORE_TILL_SEMI 0
|
|
||||||
+#define IGNORE_TILL_CLOSE_BRACE 1
|
|
||||||
+#define READING_DIV 2
|
|
||||||
+#define READING_CLASS 3
|
|
||||||
+#define READING_ATTRIBUTE 4
|
|
||||||
+#define READING_NUM 5
|
|
||||||
+#define CHECKING_ONLY_DIV 6
|
|
||||||
+
|
|
||||||
+static int at_eof = 0;
|
|
||||||
+
|
|
||||||
+static int strucmp(uchar *a, uchar *b) {
|
|
||||||
+ int i;
|
|
||||||
+ for (i = 0; a[i] && b[i]; i++) {
|
|
||||||
+ if (a[i] < b[i]) return -1;
|
|
||||||
+ if (a[i] > b[i]) return 1;
|
|
||||||
+ }
|
|
||||||
+ /* This isn't right, but who cares...*/
|
|
||||||
+ if (a[i] || b[i]) return 1;
|
|
||||||
+ return 0;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static int read_word(FILE *f, const char *word) {
|
|
||||||
+ char c;
|
|
||||||
+ for (int idx = 0; word[idx]; idx++) {
|
|
||||||
+ c = getc(f);
|
|
||||||
+ if (c == EOF) {
|
|
||||||
+ at_eof = 1;
|
|
||||||
+ return 0;
|
|
||||||
+ }
|
|
||||||
+ if (c != word[idx])
|
|
||||||
+ return 0;
|
|
||||||
+ }
|
|
||||||
+ return 1;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+int lookup_div_class(uchar *name) {
|
|
||||||
+ struct div_entry *node = head;
|
|
||||||
+
|
|
||||||
+ while (node) {
|
|
||||||
+ if (strucmp(node->class_name, name) == 0)
|
|
||||||
+ return node->indent;
|
|
||||||
+ node = node->next;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return 0;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+void parse_style(char *fname) {
|
|
||||||
+ FILE *f;
|
|
||||||
+ char c;
|
|
||||||
+ int state;
|
|
||||||
+ struct div_entry *cur = 0;
|
|
||||||
+ int class_idx = 0;
|
|
||||||
+ char num[BUFF_SIZE];
|
|
||||||
+ int num_idx = 0;
|
|
||||||
+
|
|
||||||
+ if (!fname) return;
|
|
||||||
+
|
|
||||||
+ f = fopen(fname, "r");
|
|
||||||
+ if (!f) {
|
|
||||||
+ fprintf(stderr, "Unable to parse style\n");
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ state = READING_DIV;
|
|
||||||
+ while (!at_eof && (c = getc(f)) != EOF) {
|
|
||||||
+ switch (state) {
|
|
||||||
+
|
|
||||||
+ case IGNORE_TILL_SEMI:
|
|
||||||
+ if (c == ';')
|
|
||||||
+ state = READING_ATTRIBUTE;
|
|
||||||
+ break;
|
|
||||||
+
|
|
||||||
+ case IGNORE_TILL_CLOSE_BRACE:
|
|
||||||
+ if (c == '}')
|
|
||||||
+ state = READING_DIV;
|
|
||||||
+ break;
|
|
||||||
+
|
|
||||||
+ case READING_DIV:
|
|
||||||
+ if (c != ' ' && c != '\t' && c != '\n') {
|
|
||||||
+ if (c == 'd' && read_word(f, "iv.")) {
|
|
||||||
+ state = READING_CLASS;
|
|
||||||
+ cur = (struct div_entry *) malloc(sizeof(struct div_entry));
|
|
||||||
+ memset(cur, 0, sizeof(struct div_entry));
|
|
||||||
+ class_idx = 0;
|
|
||||||
+ } else
|
|
||||||
+ state = IGNORE_TILL_CLOSE_BRACE;
|
|
||||||
+ }
|
|
||||||
+ break;
|
|
||||||
+
|
|
||||||
+ case READING_CLASS:
|
|
||||||
+ if (isalpha(c)) {
|
|
||||||
+ if (class_idx >= BUFF_SIZE-1) {
|
|
||||||
+ fprintf(stderr, "class size %s too long\n", cur->class_name);
|
|
||||||
+ free(cur);
|
|
||||||
+ state = IGNORE_TILL_CLOSE_BRACE;
|
|
||||||
+ } else {
|
|
||||||
+ cur->class_name[class_idx++] = c;
|
|
||||||
+ }
|
|
||||||
+ } else {
|
|
||||||
+ if (c == '{') {
|
|
||||||
+ cur->next = head;
|
|
||||||
+ head = cur;
|
|
||||||
+ state = READING_ATTRIBUTE;
|
|
||||||
+ } else
|
|
||||||
+ state = CHECKING_ONLY_DIV;
|
|
||||||
+ }
|
|
||||||
+ break;
|
|
||||||
+
|
|
||||||
+ case READING_ATTRIBUTE:
|
|
||||||
+ if (c != ' ' && c != '\t' && c != '\n') {
|
|
||||||
+ if (c == '}')
|
|
||||||
+ state = READING_DIV;
|
|
||||||
+ else {
|
|
||||||
+ if (c == 'm' && read_word(f, "argin-left:")) {
|
|
||||||
+ num_idx = 0;
|
|
||||||
+ memset(num, 0, sizeof(num));
|
|
||||||
+ state = READING_NUM;
|
|
||||||
+ } else {
|
|
||||||
+ state = IGNORE_TILL_SEMI;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ break;
|
|
||||||
+
|
|
||||||
+ case READING_NUM:
|
|
||||||
+ if (isdigit(c)) {
|
|
||||||
+ if (num_idx >= BUFF_SIZE - 1) {
|
|
||||||
+ fprintf(stderr, "Number too long\n");
|
|
||||||
+ state = IGNORE_TILL_SEMI;
|
|
||||||
+ } else {
|
|
||||||
+ num[num_idx++] = c;
|
|
||||||
+ }
|
|
||||||
+ } else if (c != ' ' && c != '\t') {
|
|
||||||
+ if (num_idx > 0 && c == 'e' && read_word(f, "m"))
|
|
||||||
+ cur->indent = atoi(num);
|
|
||||||
+ state = IGNORE_TILL_SEMI;
|
|
||||||
+ }
|
|
||||||
+ break;
|
|
||||||
+
|
|
||||||
+ case CHECKING_ONLY_DIV:
|
|
||||||
+ if (c != ' ' && c != '\t' && c != '\n') {
|
|
||||||
+ if (c == '{') {
|
|
||||||
+ cur->next = head;
|
|
||||||
+ head = cur;
|
|
||||||
+ state = READING_ATTRIBUTE;
|
|
||||||
+ } else {
|
|
||||||
+ free(cur);
|
|
||||||
+ state = IGNORE_TILL_CLOSE_BRACE;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ fclose(f);
|
|
||||||
+}
|
|
||||||
|
|
@ -32,6 +32,7 @@ div.code {
|
||||||
margin-left: 4em;
|
margin-left: 4em;
|
||||||
margin-right: 4em;
|
margin-right: 4em;
|
||||||
background-color: #F0FFFF;
|
background-color: #F0FFFF;
|
||||||
|
font-family: "Courier New", Courier, "Courier 10 Pitch", monospace;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.targetlang {
|
div.targetlang {
|
||||||
|
|
@ -41,9 +42,9 @@ div.targetlang {
|
||||||
margin-left: 4em;
|
margin-left: 4em;
|
||||||
margin-right: 4em;
|
margin-right: 4em;
|
||||||
background-color: #d7f6bb;
|
background-color: #d7f6bb;
|
||||||
|
font-family: "Courier New", Courier, "Courier 10 Pitch", monospace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
div.shell {
|
div.shell {
|
||||||
border-style: solid;
|
border-style: solid;
|
||||||
border-width: 1px;
|
border-width: 1px;
|
||||||
|
|
@ -51,6 +52,7 @@ div.shell {
|
||||||
margin-left: 4em;
|
margin-left: 4em;
|
||||||
margin-right: 4em;
|
margin-right: 4em;
|
||||||
background-color: #DCDCDC;
|
background-color: #DCDCDC;
|
||||||
|
font-family: "Courier New", Courier, "Courier 10 Pitch", monospace;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.diagram {
|
div.diagram {
|
||||||
|
|
@ -60,6 +62,7 @@ div.diagram {
|
||||||
margin-left: 4em;
|
margin-left: 4em;
|
||||||
margin-right: 4em;
|
margin-right: 4em;
|
||||||
background-color: #FFEBCD;
|
background-color: #FFEBCD;
|
||||||
|
font-family: "Courier New", Courier, "Courier 10 Pitch", monospace;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul li p {
|
ul li p {
|
||||||
|
|
@ -82,3 +85,8 @@ div.indent p {
|
||||||
margin-right: 0;
|
margin-right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pre, code, tt {
|
||||||
|
font-family: "Courier New", Courier, "Courier 10 Pitch", monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
body { font-family: serif; }
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,13 @@ INTERFACE =
|
||||||
INTERFACEDIR =
|
INTERFACEDIR =
|
||||||
INTERFACEPATH = $(SRCDIR)$(INTERFACEDIR)$(INTERFACE)
|
INTERFACEPATH = $(SRCDIR)$(INTERFACEDIR)$(INTERFACE)
|
||||||
SWIGOPT =
|
SWIGOPT =
|
||||||
SWIG = swig
|
|
||||||
|
# SWIG_LIB_DIR and SWIGEXE must be explicitly set by Makefiles using this Makefile
|
||||||
|
SWIG_LIB_DIR = ./Lib
|
||||||
|
SWIGEXE = swig
|
||||||
|
SWIG_LIB_SET = @SWIG_LIB_SET@
|
||||||
|
SWIGTOOL =
|
||||||
|
SWIG = $(SWIG_LIB_SET) $(SWIGTOOL) $(SWIGEXE)
|
||||||
|
|
||||||
LIBM = @LIBM@
|
LIBM = @LIBM@
|
||||||
LIBC = @LIBC@
|
LIBC = @LIBC@
|
||||||
|
|
@ -133,6 +139,13 @@ distclean:
|
||||||
rm -f d/example.mk
|
rm -f d/example.mk
|
||||||
rm -f xml/Makefile
|
rm -f xml/Makefile
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
# Very generic invocation of swig
|
||||||
|
##################################################################
|
||||||
|
|
||||||
|
swiginvoke:
|
||||||
|
$(SWIG) $(SWIGOPT)
|
||||||
|
|
||||||
##################################################################
|
##################################################################
|
||||||
##### Tcl/Tk ######
|
##### Tcl/Tk ######
|
||||||
##################################################################
|
##################################################################
|
||||||
|
|
@ -314,11 +327,11 @@ else
|
||||||
endif
|
endif
|
||||||
PYTHON_SO = @PYTHON_SO@
|
PYTHON_SO = @PYTHON_SO@
|
||||||
|
|
||||||
# SWIG option for Python
|
# SWIG option for Python3
|
||||||
ifeq (,$(PY3))
|
ifeq (,$(PY3))
|
||||||
SWIGPYTHON = $(SWIG) -python
|
SWIGOPTPY3 =
|
||||||
else
|
else
|
||||||
SWIGPYTHON = $(SWIG) -python -py3
|
SWIGOPTPY3 = -py3
|
||||||
endif
|
endif
|
||||||
|
|
||||||
PEP8 = @PEP8@
|
PEP8 = @PEP8@
|
||||||
|
|
@ -329,7 +342,7 @@ PEP8_FLAGS = --ignore=E402,E501,E30,W291,W391
|
||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
|
|
||||||
python: $(SRCDIR_SRCS)
|
python: $(SRCDIR_SRCS)
|
||||||
$(SWIGPYTHON) $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
|
$(SWIG) -python $(SWIGOPTPY3) $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
|
||||||
$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) $(PYTHON_INCLUDE)
|
$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) $(PYTHON_INCLUDE)
|
||||||
$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(PYTHON_DLNK) $(LIBS) -o $(LIBPREFIX)_$(TARGET)$(PYTHON_SO)
|
$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(PYTHON_DLNK) $(LIBS) -o $(LIBPREFIX)_$(TARGET)$(PYTHON_SO)
|
||||||
|
|
||||||
|
|
@ -338,7 +351,7 @@ python: $(SRCDIR_SRCS)
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
|
|
||||||
python_cpp: $(SRCDIR_SRCS)
|
python_cpp: $(SRCDIR_SRCS)
|
||||||
$(SWIGPYTHON) -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
|
$(SWIG) -python $(SWIGOPTPY3) -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
|
||||||
$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(PYTHON_INCLUDE)
|
$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(PYTHON_INCLUDE)
|
||||||
$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(PYTHON_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)_$(TARGET)$(PYTHON_SO)
|
$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(PYTHON_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)_$(TARGET)$(PYTHON_SO)
|
||||||
|
|
||||||
|
|
@ -354,12 +367,12 @@ TKINTER =
|
||||||
PYTHON_LIBOPTS = $(PYTHON_LINK) @LIBS@ $(TKINTER) $(SYSLIBS)
|
PYTHON_LIBOPTS = $(PYTHON_LINK) @LIBS@ $(TKINTER) $(SYSLIBS)
|
||||||
|
|
||||||
python_static: $(SRCDIR_SRCS)
|
python_static: $(SRCDIR_SRCS)
|
||||||
$(SWIGPYTHON) -lembed.i $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
|
$(SWIG) -python $(SWIGOPTPY3) -lembed.i $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) \
|
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) \
|
||||||
$(PYTHON_INCLUDE) $(LIBS) -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET)
|
$(PYTHON_INCLUDE) $(LIBS) -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET)
|
||||||
|
|
||||||
python_static_cpp: $(SRCDIR_SRCS)
|
python_static_cpp: $(SRCDIR_SRCS)
|
||||||
$(SWIGPYTHON) -c++ -lembed.i $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
|
$(SWIG) -python $(SWIGOPTPY3) -c++ -lembed.i $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
|
||||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) \
|
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) \
|
||||||
$(PYTHON_INCLUDE) $(LIBS) -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET)
|
$(PYTHON_INCLUDE) $(LIBS) -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET)
|
||||||
|
|
||||||
|
|
@ -377,7 +390,7 @@ PY2TO3 = 2to3 `2to3 -l | grep -v -E "Available|import$$" | awk '{print "-f "$$0}
|
||||||
|
|
||||||
python_run: $(PYSCRIPT)
|
python_run: $(PYSCRIPT)
|
||||||
ifneq (,$(PEP8))
|
ifneq (,$(PEP8))
|
||||||
$(PEP8) $(PEP8_FLAGS) $(PYSCRIPT)
|
$(COMPILETOOL) $(PEP8) $(PEP8_FLAGS) $(PYSCRIPT)
|
||||||
endif
|
endif
|
||||||
env PYTHONPATH=$$PWD $(RUNTOOL) $(PYTHON) $(PYSCRIPT) $(RUNPIPE)
|
env PYTHONPATH=$$PWD $(RUNTOOL) $(PYTHON) $(PYSCRIPT) $(RUNPIPE)
|
||||||
|
|
||||||
|
|
@ -416,7 +429,7 @@ python_clean:
|
||||||
##################################################################
|
##################################################################
|
||||||
|
|
||||||
# Make sure these locate your Octave installation
|
# Make sure these locate your Octave installation
|
||||||
OCTAVE = OCTAVE_HISTFILE=/dev/null @OCTAVE@
|
OCTAVE = @OCTAVE@
|
||||||
OCTAVE_CXX = $(DEFS) @OCTAVE_CPPFLAGS@ @OCTAVE_CXXFLAGS@
|
OCTAVE_CXX = $(DEFS) @OCTAVE_CPPFLAGS@ @OCTAVE_CXXFLAGS@
|
||||||
|
|
||||||
# Extra Octave specific dynamic linking options
|
# Extra Octave specific dynamic linking options
|
||||||
|
|
@ -450,7 +463,7 @@ octave_cpp: $(SRCDIR_SRCS)
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
|
|
||||||
octave_run:
|
octave_run:
|
||||||
$(RUNTOOL) $(OCTAVE) $(OCTAVE_SCRIPT) $(RUNPIPE)
|
OCTAVE_HISTFILE=/dev/null $(RUNTOOL) $(OCTAVE) $(OCTAVE_SCRIPT) $(RUNPIPE)
|
||||||
|
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
# Version display
|
# Version display
|
||||||
|
|
@ -574,6 +587,7 @@ JAVASO =@JAVASO@
|
||||||
JAVALDSHARED = @JAVALDSHARED@
|
JAVALDSHARED = @JAVALDSHARED@
|
||||||
JAVACXXSHARED = @JAVACXXSHARED@
|
JAVACXXSHARED = @JAVACXXSHARED@
|
||||||
JAVACFLAGS = @JAVACFLAGS@
|
JAVACFLAGS = @JAVACFLAGS@
|
||||||
|
JAVAFLAGS = @JAVAFLAGS@
|
||||||
JAVA = @JAVA@
|
JAVA = @JAVA@
|
||||||
JAVAC = @JAVAC@ -d .
|
JAVAC = @JAVAC@ -d .
|
||||||
|
|
||||||
|
|
@ -607,7 +621,7 @@ java_compile: $(SRCDIR_SRCS)
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
|
|
||||||
java_run:
|
java_run:
|
||||||
env LD_LIBRARY_PATH=$$PWD $(RUNTOOL) $(JAVA) $(RUNME) $(RUNPIPE)
|
env LD_LIBRARY_PATH=$$PWD $(RUNTOOL) $(JAVA) $(JAVAFLAGS) $(RUNME) $(RUNPIPE)
|
||||||
|
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
# Version display
|
# Version display
|
||||||
|
|
@ -1084,7 +1098,7 @@ ruby_cpp_static: $(SRCDIR_SRCS)
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
|
|
||||||
ruby_run:
|
ruby_run:
|
||||||
$(RUNTOOL) $(RUBY) -I. $(RUBY_SCRIPT) $(RUNPIPE)
|
$(RUNTOOL) $(RUBY) $(RUBYFLAGS) -I. $(RUBY_SCRIPT) $(RUNPIPE)
|
||||||
|
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
# Version display
|
# Version display
|
||||||
|
|
@ -1103,7 +1117,57 @@ ruby_clean:
|
||||||
rm -f *.@OBJEXT@ *$(RUBY_SO)
|
rm -f *.@OBJEXT@ *$(RUBY_SO)
|
||||||
|
|
||||||
##################################################################
|
##################################################################
|
||||||
##### PHP ######
|
##### PHP5 ######
|
||||||
|
##################################################################
|
||||||
|
|
||||||
|
PHP5 = @PHP5@
|
||||||
|
PHP5_INCLUDE = @PHP5INC@
|
||||||
|
PHP5_SO = @PHP5_SO@
|
||||||
|
PHP5_SCRIPT = $(SRCDIR)$(RUNME).php
|
||||||
|
|
||||||
|
# -------------------------------------------------------------------
|
||||||
|
# Build a PHP5 dynamically loadable module (C)
|
||||||
|
# -------------------------------------------------------------------
|
||||||
|
|
||||||
|
php5: $(SRCDIR_SRCS)
|
||||||
|
$(SWIG) -php5 $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
|
||||||
|
$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES) $(PHP5_INCLUDE)
|
||||||
|
$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(PHP5_SO)
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------
|
||||||
|
# Build a PHP5 dynamically loadable module (C++)
|
||||||
|
# --------------------------------------------------------------------
|
||||||
|
|
||||||
|
php5_cpp: $(SRCDIR_SRCS)
|
||||||
|
$(SWIG) -php5 -cppext cxx -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
|
||||||
|
$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PHP5_INCLUDE)
|
||||||
|
$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(PHP5_SO)
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------
|
||||||
|
# Running a PHP5 example
|
||||||
|
# -----------------------------------------------------------------
|
||||||
|
|
||||||
|
php5_run:
|
||||||
|
$(RUNTOOL) $(PHP5) -n -q -d extension_dir=. -d safe_mode=Off $(PHP5_SCRIPT) $(RUNPIPE)
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------
|
||||||
|
# Version display
|
||||||
|
# -----------------------------------------------------------------
|
||||||
|
|
||||||
|
php5_version:
|
||||||
|
$(PHP5) -v | head -n 1
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------
|
||||||
|
# Cleaning the PHP5 examples
|
||||||
|
# -----------------------------------------------------------------
|
||||||
|
|
||||||
|
php5_clean:
|
||||||
|
rm -f *_wrap* *~ .~* example.php php_example.h
|
||||||
|
rm -f core @EXTRA_CLEAN@
|
||||||
|
rm -f *.@OBJEXT@ *$(PHP5_SO)
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
##### PHP7 ######
|
||||||
##################################################################
|
##################################################################
|
||||||
|
|
||||||
PHP = @PHP@
|
PHP = @PHP@
|
||||||
|
|
@ -1116,7 +1180,7 @@ PHP_SCRIPT = $(SRCDIR)$(RUNME).php
|
||||||
# -------------------------------------------------------------------
|
# -------------------------------------------------------------------
|
||||||
|
|
||||||
php: $(SRCDIR_SRCS)
|
php: $(SRCDIR_SRCS)
|
||||||
$(SWIG) -php $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
|
$(SWIG) -php7 $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
|
||||||
$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES) $(PHP_INCLUDE)
|
$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES) $(PHP_INCLUDE)
|
||||||
$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(PHP_SO)
|
$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(PHP_SO)
|
||||||
|
|
||||||
|
|
@ -1125,7 +1189,7 @@ php: $(SRCDIR_SRCS)
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
|
|
||||||
php_cpp: $(SRCDIR_SRCS)
|
php_cpp: $(SRCDIR_SRCS)
|
||||||
$(SWIG) -php -cppext cxx -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
|
$(SWIG) -php7 -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
|
||||||
$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PHP_INCLUDE)
|
$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PHP_INCLUDE)
|
||||||
$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(PHP_SO)
|
$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(PHP_SO)
|
||||||
|
|
||||||
|
|
@ -1448,6 +1512,12 @@ lua_cpp: $(SRCDIR_SRCS) $(GENCXXSRCS)
|
||||||
$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(GENCXXSRCS) $(INCLUDES) $(LUA_INCLUDE)
|
$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(GENCXXSRCS) $(INCLUDES) $(LUA_INCLUDE)
|
||||||
$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(LUA_LIB) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(LUA_SO)
|
$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(LUA_LIB) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(LUA_SO)
|
||||||
|
|
||||||
|
lua_externalhdr:
|
||||||
|
$(SWIG) -lua -external-runtime $(TARGET)
|
||||||
|
|
||||||
|
lua_swig_cpp:
|
||||||
|
$(SWIG) -c++ -lua $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
|
||||||
|
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
# Build statically linked Lua interpreter
|
# Build statically linked Lua interpreter
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
|
|
@ -1652,7 +1722,8 @@ R = R
|
||||||
RCXXSRCS = $(INTERFACE:.i=_wrap.cpp) #Need to use _wrap.cpp for R build system as it does not understand _wrap.cxx
|
RCXXSRCS = $(INTERFACE:.i=_wrap.cpp) #Need to use _wrap.cpp for R build system as it does not understand _wrap.cxx
|
||||||
RRSRC = $(INTERFACE:.i=.R)
|
RRSRC = $(INTERFACE:.i=.R)
|
||||||
R_CFLAGS=-fPIC
|
R_CFLAGS=-fPIC
|
||||||
R_SCRIPT=$(RUNME).R
|
R_OPT = --slave --quiet --no-save --no-restore
|
||||||
|
R_SCRIPT=$(SRCDIR)$(RUNME).R
|
||||||
|
|
||||||
# need to compile .cxx files outside of R build system to make sure that
|
# need to compile .cxx files outside of R build system to make sure that
|
||||||
# we get -fPIC
|
# we get -fPIC
|
||||||
|
|
@ -1684,7 +1755,7 @@ endif
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
|
|
||||||
r_run:
|
r_run:
|
||||||
$(RUNTOOL) $(R) CMD BATCH $(R_SCRIPT) $(RUNPIPE)
|
$(RUNTOOL) $(R) $(R_OPT) -f $(R_SCRIPT) $(RUNPIPE)
|
||||||
|
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
# Version display
|
# Version display
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIGEXE = $(TOP)/../swig
|
||||||
|
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||||
TARGET = example
|
TARGET = example
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
INTERFACEDIR = jni/
|
INTERFACEDIR = jni/
|
||||||
|
|
@ -13,8 +14,9 @@ TARGETID = 1
|
||||||
check: build
|
check: build
|
||||||
|
|
||||||
build:
|
build:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
|
||||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' \
|
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||||
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' \
|
||||||
PROJECTNAME='$(PROJECTNAME)' TARGETID='$(TARGETID)' android_cpp
|
PROJECTNAME='$(PROJECTNAME)' TARGETID='$(TARGETID)' android_cpp
|
||||||
|
|
||||||
install:
|
install:
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIGEXE = $(TOP)/../swig
|
||||||
|
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||||
TARGET = example
|
TARGET = example
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
INTERFACEDIR = jni/
|
INTERFACEDIR = jni/
|
||||||
|
|
@ -13,8 +14,9 @@ TARGETID = 1
|
||||||
check: build
|
check: build
|
||||||
|
|
||||||
build:
|
build:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
|
||||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' \
|
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||||
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' \
|
||||||
PROJECTNAME='$(PROJECTNAME)' TARGETID='$(TARGETID)' android_cpp
|
PROJECTNAME='$(PROJECTNAME)' TARGETID='$(TARGETID)' android_cpp
|
||||||
|
|
||||||
install:
|
install:
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIGEXE = $(TOP)/../swig
|
||||||
|
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||||
TARGET = example
|
TARGET = example
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
INTERFACEDIR = jni/
|
INTERFACEDIR = jni/
|
||||||
|
|
@ -13,8 +14,9 @@ TARGETID = 1
|
||||||
check: build
|
check: build
|
||||||
|
|
||||||
build:
|
build:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
|
||||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' \
|
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||||
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' \
|
||||||
PROJECTNAME='$(PROJECTNAME)' TARGETID='$(TARGETID)' android
|
PROJECTNAME='$(PROJECTNAME)' TARGETID='$(TARGETID)' android
|
||||||
|
|
||||||
install:
|
install:
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIGEXE = $(TOP)/../swig
|
||||||
|
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
SRCS =
|
SRCS =
|
||||||
CXXSRCS = example.cxx
|
CXXSRCS = example.cxx
|
||||||
|
|
@ -22,14 +23,16 @@ build: $(TARGET) $(TARGET)_proxy
|
||||||
$(TARGET): $(INTERFACE) $(SRCS)
|
$(TARGET): $(INTERFACE) $(SRCS)
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
|
||||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
||||||
|
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
|
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
|
||||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp
|
INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp
|
||||||
|
|
||||||
$(TARGET)_proxy: $(INTERFACE) $(SRCS)
|
$(TARGET)_proxy: $(INTERFACE) $(SRCS)
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
|
||||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
||||||
|
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT) -proxy' TARGET='$(TARGET)_proxy' \
|
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT) -proxy' TARGET='$(TARGET)_proxy' \
|
||||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp
|
INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIGEXE = $(TOP)/../swig
|
||||||
|
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
SRCS =
|
SRCS =
|
||||||
CXXSRCS =
|
CXXSRCS =
|
||||||
|
|
@ -20,8 +21,9 @@ build: $(TARGET)
|
||||||
$(TARGET): $(INTERFACE) $(SRCS)
|
$(TARGET): $(INTERFACE) $(SRCS)
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
|
||||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
||||||
|
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
|
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
|
||||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
|
INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
SWIG = ../../../preinst-swig
|
TOP = ../..
|
||||||
|
SWIGEXE = $(TOP)/../swig
|
||||||
|
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||||
|
|
||||||
check: build
|
check: build
|
||||||
cd eggs/install && csi ../../test.scm
|
cd eggs/install && csi ../../test.scm
|
||||||
|
|
@ -14,7 +16,7 @@ single: single_wrap.cxx
|
||||||
|
|
||||||
# compile the single module with -nounit
|
# compile the single module with -nounit
|
||||||
single_wrap.cxx: single.i
|
single_wrap.cxx: single.i
|
||||||
$(SWIG) -chicken -c++ -proxy -nounit single.i
|
$(SWIGEXE) -chicken -c++ -proxy -nounit single.i
|
||||||
|
|
||||||
# Now build both mod1 and mod2 into a single egg
|
# Now build both mod1 and mod2 into a single egg
|
||||||
multi: mod1_wrap.cxx mod2_wrap.cxx
|
multi: mod1_wrap.cxx mod2_wrap.cxx
|
||||||
|
|
@ -23,10 +25,10 @@ multi: mod1_wrap.cxx mod2_wrap.cxx
|
||||||
rm -f mod1.scm mod1_wrap.cxx mod2.scm mod2_wrap.cxx
|
rm -f mod1.scm mod1_wrap.cxx mod2.scm mod2_wrap.cxx
|
||||||
|
|
||||||
mod1_wrap.cxx: mod1.i
|
mod1_wrap.cxx: mod1.i
|
||||||
$(SWIG) -chicken -c++ -proxy mod1.i
|
$(SWIGEXE) -chicken -c++ -proxy mod1.i
|
||||||
|
|
||||||
mod2_wrap.cxx: mod2.i
|
mod2_wrap.cxx: mod2.i
|
||||||
$(SWIG) -chicken -c++ -proxy mod2.i
|
$(SWIGEXE) -chicken -c++ -proxy mod2.i
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf eggs
|
rm -rf eggs
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIGEXE = $(TOP)/../swig
|
||||||
|
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
SRCS = example.c
|
SRCS = example.c
|
||||||
CXXSRCS =
|
CXXSRCS =
|
||||||
|
|
@ -20,8 +21,9 @@ build: $(TARGET)
|
||||||
$(TARGET): $(INTERFACE) $(SRCS)
|
$(TARGET): $(INTERFACE) $(SRCS)
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
|
||||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
||||||
|
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
|
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
|
||||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
|
INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIGEXE = $(TOP)/../swig
|
||||||
|
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
SRCS =
|
SRCS =
|
||||||
CXXSRCS = example.cxx
|
CXXSRCS = example.cxx
|
||||||
|
|
@ -20,8 +21,9 @@ build: $(TARGET)
|
||||||
$(TARGET): $(INTERFACE) $(SRCS)
|
$(TARGET): $(INTERFACE) $(SRCS)
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
|
||||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
||||||
|
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
|
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
|
||||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp
|
INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIGEXE = $(TOP)/../swig
|
||||||
|
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
SRCS = example.c
|
SRCS = example.c
|
||||||
CXXSRCS =
|
CXXSRCS =
|
||||||
|
|
@ -20,8 +21,9 @@ build: $(TARGET)
|
||||||
$(TARGET): $(INTERFACE) $(SRCS)
|
$(TARGET): $(INTERFACE) $(SRCS)
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
|
||||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
||||||
|
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
|
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
|
||||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
|
INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIGEXE = $(TOP)/../swig
|
||||||
|
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||||
SRCS = example.c
|
SRCS = example.c
|
||||||
TARGET = example
|
TARGET = example
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
|
|
@ -11,7 +12,8 @@ check: build
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run
|
||||||
|
|
||||||
build:
|
build:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
|
||||||
|
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIGEXE = $(TOP)/../swig
|
||||||
|
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||||
CXXSRCS = example.cxx
|
CXXSRCS = example.cxx
|
||||||
TARGET = example
|
TARGET = example
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
|
|
@ -11,7 +12,8 @@ check: build
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run
|
||||||
|
|
||||||
build:
|
build:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
|
||||||
|
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIGEXE = $(TOP)/../swig
|
||||||
|
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||||
CXXSRCS = example.cxx
|
CXXSRCS = example.cxx
|
||||||
TARGET = example
|
TARGET = example
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
|
|
@ -11,7 +12,8 @@ check: build
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run
|
||||||
|
|
||||||
build:
|
build:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
|
||||||
|
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIGEXE = $(TOP)/../swig
|
||||||
|
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||||
CXXSRCS = example.cxx
|
CXXSRCS = example.cxx
|
||||||
TARGET = example
|
TARGET = example
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
|
|
@ -11,7 +12,8 @@ check: build
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run
|
||||||
|
|
||||||
build:
|
build:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
|
||||||
|
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIGEXE = $(TOP)/../swig
|
||||||
|
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||||
CXXSRCS = example.cxx
|
CXXSRCS = example.cxx
|
||||||
TARGET = example
|
TARGET = example
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
|
|
@ -11,7 +12,8 @@ check: build
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run
|
||||||
|
|
||||||
build:
|
build:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
|
||||||
|
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIGEXE = $(TOP)/../swig
|
||||||
|
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||||
SRCS = example.c
|
SRCS = example.c
|
||||||
TARGET = example
|
TARGET = example
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
|
|
@ -11,7 +12,8 @@ check: build
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run
|
||||||
|
|
||||||
build:
|
build:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
|
||||||
|
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIGEXE = $(TOP)/../swig
|
||||||
|
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||||
CXXSRCS = example.cxx
|
CXXSRCS = example.cxx
|
||||||
TARGET = example
|
TARGET = example
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
|
|
@ -11,7 +12,8 @@ check: build
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run
|
||||||
|
|
||||||
build:
|
build:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
|
||||||
|
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIGEXE = $(TOP)/../swig
|
||||||
|
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||||
CXXSRCS = example.cxx
|
CXXSRCS = example.cxx
|
||||||
TARGET = example
|
TARGET = example
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
|
|
@ -11,7 +12,8 @@ check: build
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run
|
||||||
|
|
||||||
build:
|
build:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
|
||||||
|
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIGEXE = $(TOP)/../swig
|
||||||
|
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||||
SRCS = example.c
|
SRCS = example.c
|
||||||
TARGET = example
|
TARGET = example
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
|
|
@ -11,7 +12,8 @@ check: build
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run
|
||||||
|
|
||||||
build:
|
build:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
|
||||||
|
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIGEXE = $(TOP)/../swig
|
||||||
|
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||||
CXXSRCS =
|
CXXSRCS =
|
||||||
TARGET = example
|
TARGET = example
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
|
|
@ -11,7 +12,8 @@ check: build
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run
|
||||||
|
|
||||||
build:
|
build:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
|
||||||
|
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIGEXE = $(TOP)/../swig
|
||||||
|
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||||
SRCS = example.c
|
SRCS = example.c
|
||||||
TARGET = example
|
TARGET = example
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
|
|
@ -11,7 +12,8 @@ check: build
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run
|
||||||
|
|
||||||
build:
|
build:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
|
||||||
|
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,8 @@ endif
|
||||||
|
|
||||||
EXAMPLES_TOP = ../../..
|
EXAMPLES_TOP = ../../..
|
||||||
SWIG_TOP = ../../../..
|
SWIG_TOP = ../../../..
|
||||||
SWIG = $(SWIG_TOP)/preinst-swig
|
SWIGEXE = $(SWIG_TOP)/swig
|
||||||
|
SWIG_LIB_DIR = $(SWIG_TOP)/$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||||
EXTRA_CFLAGS =
|
EXTRA_CFLAGS =
|
||||||
EXTRA_CXXFLAGS =
|
EXTRA_CXXFLAGS =
|
||||||
EXTRA_LDFLAGS =
|
EXTRA_LDFLAGS =
|
||||||
|
|
@ -44,11 +45,17 @@ check: build
|
||||||
build:
|
build:
|
||||||
mkdir -p $(VERSION_DIR)
|
mkdir -p $(VERSION_DIR)
|
||||||
if [ -f $(SRCDIR)example.cxx ]; then \
|
if [ -f $(SRCDIR)example.cxx ]; then \
|
||||||
$(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' EXTRA_CXXFLAGS='$(EXTRA_CXXFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' CXXSRCS='example.cxx' d_cpp; \
|
$(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' EXTRA_CXXFLAGS='$(EXTRA_CXXFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' \
|
||||||
|
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||||
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' CXXSRCS='example.cxx' d_cpp; \
|
||||||
elif [ -f $(SRCDIR)example.c ]; then \
|
elif [ -f $(SRCDIR)example.c ]; then \
|
||||||
$(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' SRCS='example.c' d; \
|
$(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' \
|
||||||
|
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||||
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' SRCS='example.c' d; \
|
||||||
else \
|
else \
|
||||||
$(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' SRCS='' d; \
|
$(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' \
|
||||||
|
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||||
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' SRCS='' d; \
|
||||||
fi
|
fi
|
||||||
$(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
|
$(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIGEXE = $(TOP)/../swig
|
||||||
|
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||||
CXXSRCS = callback.cxx
|
CXXSRCS = callback.cxx
|
||||||
|
GOSRCS = gocallback.go
|
||||||
TARGET = example
|
TARGET = example
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
SWIGOPT =
|
SWIGOPT =
|
||||||
|
|
@ -9,8 +11,16 @@ check: build
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
|
||||||
|
|
||||||
build:
|
build:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
if [ -n '$(SRCDIR)' ]; then \
|
||||||
|
cp $(GOSRCS:%=$(SRCDIR)/%) .; \
|
||||||
|
fi
|
||||||
|
@# Note: example.go gets generated by SWIG
|
||||||
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' GOSRCS='example.go $(GOSRCS)' \
|
||||||
|
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
if [ -n '$(SRCDIR)' ]; then \
|
||||||
|
rm -f $(GOSRCS); \
|
||||||
|
fi
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean
|
||||||
|
|
|
||||||
|
|
@ -20,4 +20,3 @@ public:
|
||||||
void setCallback(Callback *cb) { delCallback(); _callback = cb; }
|
void setCallback(Callback *cb) { delCallback(); _callback = cb; }
|
||||||
void call() { if (_callback) _callback->run(); }
|
void call() { if (_callback) _callback->run(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
41
Examples/go/callback/gocallback.go
Normal file
41
Examples/go/callback/gocallback.go
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
package example
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GoCallback interface {
|
||||||
|
Callback
|
||||||
|
deleteCallback()
|
||||||
|
IsGoCallback()
|
||||||
|
}
|
||||||
|
|
||||||
|
type goCallback struct {
|
||||||
|
Callback
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *goCallback) deleteCallback() {
|
||||||
|
DeleteDirectorCallback(p.Callback)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *goCallback) IsGoCallback() {}
|
||||||
|
|
||||||
|
type overwrittenMethodsOnCallback struct {
|
||||||
|
p Callback
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewGoCallback() GoCallback {
|
||||||
|
om := &overwrittenMethodsOnCallback{}
|
||||||
|
p := NewDirectorCallback(om)
|
||||||
|
om.p = p
|
||||||
|
|
||||||
|
return &goCallback{Callback: p}
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeleteGoCallback(p GoCallback) {
|
||||||
|
p.deleteCallback()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *goCallback) Run() {
|
||||||
|
fmt.Println("GoCallback.Run")
|
||||||
|
}
|
||||||
|
|
@ -12,67 +12,17 @@
|
||||||
<H2>Implementing C++ callbacks in Go</H2>
|
<H2>Implementing C++ callbacks in Go</H2>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
This example illustrates how to use directors to implement C++
|
This example illustrates how to use directors to implement C++ callbacks in Go.
|
||||||
callbacks in Go.
|
See the <a href="../../../Doc/Manual/Go.html#Go_director_classes">Go Director
|
||||||
</p>
|
Classes</a> documentation subsection for an in-depth explanation how to use the
|
||||||
|
director feature.
|
||||||
<p>
|
|
||||||
Because Go and C++ use inheritance differently, you must call a
|
|
||||||
different function to create a class which uses callbacks. Instead of
|
|
||||||
calling the usual constructor function whose name is <tt>New</tt>
|
|
||||||
followed by the capitalized name of the class, you call a function
|
|
||||||
named <tt>NewDirector</tt> followed by the capitalized name of the
|
|
||||||
class.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
The first argument to the <tt>NewDirector</tt> function is an instance
|
|
||||||
of a type. The <tt>NewDirector</tt> function will return an interface
|
|
||||||
value as usual. However, when calling any method on the returned
|
|
||||||
value, the program will first check whether the value passed
|
|
||||||
to <tt>NewDirector</tt> implements that method. If it does, the
|
|
||||||
method will be called in Go. This is true whether the method is
|
|
||||||
called from Go code or C++ code.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
Note that the Go code will be called with just the Go value, not the
|
|
||||||
C++ value. If the Go code needs to call a C++ method on itself, you
|
|
||||||
need to get a copy of the C++ object. This is typically done as
|
|
||||||
follows:
|
|
||||||
|
|
||||||
<blockquote>
|
|
||||||
<pre>
|
|
||||||
type Child struct { abi Parent }
|
|
||||||
func (p *Child) ChildMethod() {
|
|
||||||
p.abi.ParentMethod()
|
|
||||||
}
|
|
||||||
func f() {
|
|
||||||
p := &Child{nil}
|
|
||||||
d := NewDirectorParent(p)
|
|
||||||
p.abi = d
|
|
||||||
...
|
|
||||||
}
|
|
||||||
</pre>
|
|
||||||
</blockquote>
|
|
||||||
|
|
||||||
In other words, we first create the Go value. We pass that to
|
|
||||||
the <tt>NewDirector</tt> function to create the C++ value; this C++
|
|
||||||
value will be created with an association to the Go value. We then
|
|
||||||
store the C++ value in the Go value, giving us the reverse
|
|
||||||
association. That permits us to call parent methods from the child.
|
|
||||||
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
To delete a director object, use the function <tt>DeleteDirector</tt>
|
|
||||||
followed by the capitalized name of the class.
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="example.h">example.h</a>. Header file containing some enums.
|
<li><a href="example.h">example.h</a>. Header with the definition of the Caller and Callback classes.
|
||||||
<li><a href="example.i">example.i</a>. Interface file.
|
<li><a href="example.i">example.i</a>. SWIG interface file.
|
||||||
|
<li><a href="gocallback.go">gocallback.go</a>. Go source with the definition of the GoCallback class.
|
||||||
<li><a href="runme.go">runme.go</a>. Sample Go program.
|
<li><a href="runme.go">runme.go</a>. Sample Go program.
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,26 +16,18 @@ func main() {
|
||||||
caller.Call()
|
caller.Call()
|
||||||
caller.DelCallback()
|
caller.DelCallback()
|
||||||
|
|
||||||
callback = NewDirectorCallback(new(GoCallback))
|
go_callback := NewGoCallback()
|
||||||
|
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
fmt.Println("Adding and calling a Go callback")
|
fmt.Println("Adding and calling a Go callback")
|
||||||
fmt.Println("------------------------------------")
|
fmt.Println("--------------------------------")
|
||||||
|
|
||||||
caller.SetCallback(callback)
|
caller.SetCallback(go_callback)
|
||||||
caller.Call()
|
caller.Call()
|
||||||
caller.DelCallback()
|
caller.DelCallback()
|
||||||
|
|
||||||
// Test that a double delete does not occur as the object has
|
DeleteGoCallback(go_callback)
|
||||||
// already been deleted from the C++ layer.
|
|
||||||
DeleteDirectorCallback(callback)
|
|
||||||
|
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
fmt.Println("Go exit")
|
fmt.Println("Go exit")
|
||||||
}
|
}
|
||||||
|
|
||||||
type GoCallback struct{}
|
|
||||||
|
|
||||||
func (p *GoCallback) Run() {
|
|
||||||
fmt.Println("GoCallback.Run")
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
callback
|
callback
|
||||||
class
|
class
|
||||||
constants
|
constants
|
||||||
|
director
|
||||||
enum
|
enum
|
||||||
extend
|
extend
|
||||||
funcptr
|
funcptr
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIGEXE = $(TOP)/../swig
|
||||||
|
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||||
CXXSRCS = class.cxx
|
CXXSRCS = class.cxx
|
||||||
TARGET = example
|
TARGET = example
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
|
|
@ -9,7 +10,8 @@ check: build
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
|
||||||
|
|
||||||
build:
|
build:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
|
||||||
|
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp
|
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig
|
SWIGEXE = $(TOP)/../swig
|
||||||
|
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||||
CXXSRCS =
|
CXXSRCS =
|
||||||
TARGET = example
|
TARGET = example
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
|
|
@ -9,7 +10,8 @@ check: build
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
|
||||||
|
|
||||||
build:
|
build:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
|
||||||
|
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|
|
||||||
26
Examples/go/director/Makefile
Normal file
26
Examples/go/director/Makefile
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
TOP = ../..
|
||||||
|
SWIGEXE = $(TOP)/../swig
|
||||||
|
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||||
|
CXXSRCS =
|
||||||
|
GOSRCS = director.go
|
||||||
|
TARGET = example
|
||||||
|
INTERFACE = example.i
|
||||||
|
SWIGOPT =
|
||||||
|
|
||||||
|
check: build
|
||||||
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
|
||||||
|
|
||||||
|
build:
|
||||||
|
if [ -n '$(SRCDIR)' ]; then \
|
||||||
|
cp $(GOSRCS:%=$(SRCDIR)/%) .; \
|
||||||
|
fi
|
||||||
|
@# Note: example.go gets generated by SWIG
|
||||||
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' GOSRCS='example.go $(GOSRCS)' \
|
||||||
|
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||||
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp
|
||||||
|
|
||||||
|
clean:
|
||||||
|
if [ -n '$(SRCDIR)' ]; then \
|
||||||
|
rm -f $(GOSRCS); \
|
||||||
|
fi
|
||||||
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean
|
||||||
72
Examples/go/director/director.go
Normal file
72
Examples/go/director/director.go
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
package example
|
||||||
|
|
||||||
|
// FooBarGo is a superset of FooBarAbstract and hence FooBarGo can be used as a
|
||||||
|
// drop in replacement for FooBarAbstract but the reverse causes a compile time
|
||||||
|
// error.
|
||||||
|
type FooBarGo interface {
|
||||||
|
FooBarAbstract
|
||||||
|
deleteFooBarAbstract()
|
||||||
|
IsFooBarGo()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Via embedding fooBarGo "inherits" all methods of FooBarAbstract.
|
||||||
|
type fooBarGo struct {
|
||||||
|
FooBarAbstract
|
||||||
|
}
|
||||||
|
|
||||||
|
func (fbgs *fooBarGo) deleteFooBarAbstract() {
|
||||||
|
DeleteDirectorFooBarAbstract(fbgs.FooBarAbstract)
|
||||||
|
}
|
||||||
|
|
||||||
|
// The IsFooBarGo method ensures that FooBarGo is a superset of FooBarAbstract.
|
||||||
|
// This is also how the class hierarchy gets represented by the SWIG generated
|
||||||
|
// wrapper code. For an instance FooBarCpp has the IsFooBarAbstract and
|
||||||
|
// IsFooBarCpp methods.
|
||||||
|
func (fbgs *fooBarGo) IsFooBarGo() {}
|
||||||
|
|
||||||
|
// Go type that defines the DirectorInterface. It contains the Foo and Bar
|
||||||
|
// methods that overwrite the respective virtual C++ methods on FooBarAbstract.
|
||||||
|
type overwrittenMethodsOnFooBarAbstract struct {
|
||||||
|
// Backlink to FooBarAbstract so that the rest of the class can be used by
|
||||||
|
// the overridden methods.
|
||||||
|
fb FooBarAbstract
|
||||||
|
|
||||||
|
// If additional constructor arguments have been given they are typically
|
||||||
|
// stored here so that the overriden methods can use them.
|
||||||
|
}
|
||||||
|
|
||||||
|
func (om *overwrittenMethodsOnFooBarAbstract) Foo() string {
|
||||||
|
// DirectorFooBarAbstractFoo calls the base method FooBarAbstract::Foo.
|
||||||
|
return "Go " + DirectorFooBarAbstractFoo(om.fb)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (om *overwrittenMethodsOnFooBarAbstract) Bar() string {
|
||||||
|
return "Go Bar"
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewFooBarGo() FooBarGo {
|
||||||
|
// Instantiate FooBarAbstract with selected methods overridden. The methods
|
||||||
|
// that will be overwritten are defined on
|
||||||
|
// overwrittenMethodsOnFooBarAbstract and have a compatible signature to the
|
||||||
|
// respective virtual C++ methods. Furthermore additional constructor
|
||||||
|
// arguments will be typically stored in the
|
||||||
|
// overwrittenMethodsOnFooBarAbstract struct.
|
||||||
|
om := &overwrittenMethodsOnFooBarAbstract{}
|
||||||
|
fb := NewDirectorFooBarAbstract(om)
|
||||||
|
om.fb = fb // Backlink causes cycle as fb.v = om!
|
||||||
|
|
||||||
|
fbgs := &fooBarGo{FooBarAbstract: fb}
|
||||||
|
// The memory of the FooBarAbstract director object instance can be
|
||||||
|
// automatically freed once the FooBarGo instance is garbage collected by
|
||||||
|
// uncommenting the following line. Please make sure to understand the
|
||||||
|
// runtime.SetFinalizer specific gotchas before doing this. Furthemore
|
||||||
|
// DeleteFooBarGo should be deleted if a finalizer is in use or the fooBarGo
|
||||||
|
// struct needs additional data to prevent double deletion.
|
||||||
|
// runtime.SetFinalizer(fbgs, FooBarGo.deleteFooBarAbstract)
|
||||||
|
return fbgs
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recommended to be removed if runtime.SetFinalizer is in use.
|
||||||
|
func DeleteFooBarGo(fbg FooBarGo) {
|
||||||
|
fbg.deleteFooBarAbstract()
|
||||||
|
}
|
||||||
41
Examples/go/director/director.h
Normal file
41
Examples/go/director/director.h
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
#ifndef DIRECTOR_H
|
||||||
|
#define DIRECTOR_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
|
class FooBarAbstract
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FooBarAbstract() {};
|
||||||
|
virtual ~FooBarAbstract() {};
|
||||||
|
|
||||||
|
std::string FooBar() {
|
||||||
|
return this->Foo() + ", " + this->Bar();
|
||||||
|
};
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual std::string Foo() {
|
||||||
|
return "Foo";
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual std::string Bar() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class FooBarCpp : public FooBarAbstract
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
virtual std::string Foo() {
|
||||||
|
return "C++ " + FooBarAbstract::Foo();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual std::string Bar() {
|
||||||
|
return "C++ Bar";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
11
Examples/go/director/example.i
Normal file
11
Examples/go/director/example.i
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
/* File : example.i */
|
||||||
|
%module(directors="1") example
|
||||||
|
|
||||||
|
%include "std_string.i"
|
||||||
|
|
||||||
|
%header %{
|
||||||
|
#include "director.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%feature("director") FooBarAbstract;
|
||||||
|
%include "director.h"
|
||||||
28
Examples/go/director/index.html
Normal file
28
Examples/go/director/index.html
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>SWIG:Examples:go:director</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body bgcolor="#ffffff">
|
||||||
|
|
||||||
|
<tt>SWIG/Examples/go/director/</tt>
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<H2>How to subclass a C++ class with a Go type</H2>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
See the <a href="../../../Doc/Manual/Go.html#Go_director_classes">Go Director
|
||||||
|
Classes</a> documentation subsection for an explanation of this example.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<ul>
|
||||||
|
<li><a href="director.go">director.go</a>. Go source with the definition of the FooBarGo class.
|
||||||
|
<li><a href="director.h">director.h</a>. Header with the definition of the FooBarAbstract and FooBarCpp classes.
|
||||||
|
<li><a href="example.i">example.i</a>. SWIG interface file.
|
||||||
|
<li><a href="runme.go">runme.go</a>. Sample Go program.
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
39
Examples/go/director/runme.go
Normal file
39
Examples/go/director/runme.go
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"./example"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Compare(name string, got string, exp string) error {
|
||||||
|
fmt.Printf("%s; Got: '%s'; Expected: '%s'\n", name, got, exp)
|
||||||
|
if got != exp {
|
||||||
|
return fmt.Errorf("%s returned unexpected string! Got: '%s'; Expected: '%s'\n", name, got, exp)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFooBarCpp() error {
|
||||||
|
fb := example.NewFooBarCpp()
|
||||||
|
defer example.DeleteFooBarCpp(fb)
|
||||||
|
return Compare("FooBarCpp.FooBar()", fb.FooBar(), "C++ Foo, C++ Bar")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFooBarGo() error {
|
||||||
|
fb := example.NewFooBarGo()
|
||||||
|
defer example.DeleteFooBarGo(fb)
|
||||||
|
return Compare("FooBarGo.FooBar()", fb.FooBar(), "Go Foo, Go Bar")
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
fmt.Println("Test output:")
|
||||||
|
fmt.Println("------------")
|
||||||
|
err := TestFooBarCpp()
|
||||||
|
err = TestFooBarGo()
|
||||||
|
fmt.Println("------------")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "Tests failed! Last error: %s\n", err.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue