diff --git a/.gitignore b/.gitignore
index 400ce4469..4001af7c3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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
diff --git a/.travis.yml b/.travis.yml
index 8d814e7f8..9b47611b7 100644
--- a/.travis.yml
+++ b/.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
diff --git a/ANNOUNCE b/ANNOUNCE
index 96b1904ac..f7d7eb8a9 100644
--- a/ANNOUNCE
+++ b/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.
diff --git a/CCache/test.sh b/CCache/test.sh
index f64c3e3de..6e5d26703 100755
--- a/CCache/test.sh
+++ b/CCache/test.sh
@@ -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
diff --git a/CHANGES b/CHANGES
index 8bea8c1c2..eb500e5f4 100644
--- a/CHANGES
+++ b/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
+The following table lists the additional commandline options available for the C# module. They can also be seen by using: +
+ ++swig -csharp -help +
| C# specific options | +|
|---|---|
| -dllimport <dl> | +Override DllImport attribute name to <dl> | +
| -namespace <nm> | +Generate wrappers into C# namespace <nm> | +
| -noproxy | +Generate the low-level functional interface instead of proxy classes | +
| -oldvarnames | +Old intermediary method names for variable wrappers | +
| -outfile <file> | +Write all C# into a single <file> located in the output directory + | +
+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 -outfile for large projects. +
+diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index ae00a6617..839c0ec42 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -725,6 +725,7 @@
When generating Go code, SWIG will generate the following - files:
+There are two different approaches to generating output files, + controlled by SWIG's -cgo option. The -cgo option + works with Go version 1.2 or later. It is required when using Go + version 1.5 or later.
+ +With or without the -cgo option, SWIG will generate the + following files when generating Go code:
When neither the -cgo nor the -gccgo option is + used, SWIG will also generate an additional file:
+ +@@ -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 go build and go install commands will +automatically run SWIG for you and will build the interface code.
-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 -cgo option, SWIG will generate files that can be used +directly by go build. Put your SWIG input file in a +directory under GOPATH/src, and give it a name that does not end in +.swig or .swigcxx. +
+ ++% swig -go -cgo example.i +% go install +
+You will now have a Go package that you can import from other Go +packages as usual. +
+ ++To use SWIG without the -cgo 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:
@@ -227,9 +268,8 @@ sequence when using the gc compiler would look like this: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:
@@ -396,34 +436,120 @@ for this by calling the Swigcptr() method.-Calling NewClassName for some C++ class ClassName -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 DeleteClassName. -
- --A common technique is to store the C++ object into a Go object, and -use the Go function runtime.SetFinalizer to free the C++ object when -the Go object is freed. It is strongly recommended to read the -runtime.SetFinalizer -documentation before using this technique to understand its limitations. -For example, if the SWIG package is imported as "wrap": +Calling NewClassName for a C++ class ClassName 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 +DeleteClassName.
+
+The most Go idiomatic way to manage the memory for some C++ class is to call +NewClassName followed by a +defer of +the DeleteClassName call. Using defer ensures that the memory +of the C++ object is freed as soon as the function containing the defer +statement returns. Furthemore defer works great for short-lived +objects and fits nicely C++'s RAII idiom. Example:+ ++func UseClassName(...) ... { + o := NewClassName(...) + defer DeleteClassName(o) + // Use the ClassName object + return ... +} +++With increasing complexity, especially complex C++ object hierarchies, the +correct placement of defer 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: +
+++ ++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) +} +++Using defer 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 runtime.SetFinalizer to add a finalizer which frees +the C++ object when the Go object is freed. It is strongly recommended to read +the runtime.SetFinalizer + documentation before using this technique to understand the +runtime.SetFinalizer limitations.
+
++Common pitfalls with runtime.SetFinalizer are: +
+
+runtime.SetFinalizer Example: +
+
+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.
}