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