diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..1e8faff7d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,457 @@ +name: CI + +on: + push: + paths-ignore: + - 'CHANGES*' + - 'Doc/**' + - 'appveyor.yml' + pull_request: + branches: master + paths-ignore: + - 'CHANGES*' + - 'Doc/**' + - 'appveyor.yml' + +jobs: + build: + + # When continue-on-error is true for an individual build, that build can fail (it'll show red), + # but it won't fail the overall build + continue-on-error: ${{ matrix.continue-on-error || false }} + + runs-on: ${{ matrix.os || 'ubuntu-20.04' }} + + # By default, the name of the build is the language used and SWIG options, but matrix entries + # can define the additional "desc" field with any additional information to include in the name. + name: ${{ matrix.SWIGLANG || 'none' }}${{ matrix.PY3 }} ${{ matrix.ENGINE}} ${{ matrix.VER }} ${{ matrix.SWIG_FEATURES }} ${{ (matrix.compiler || 'gcc') }}${{ matrix.GCC }} ${{ matrix.CPPSTD }} ${{ matrix.CSTD }} ${{ matrix.desc }} ${{ matrix.continue-on-error && '(can fail)' }} + + strategy: + matrix: + include: + - SWIGLANG: "" + - SWIGLANG: "" + GCC: 7 + - SWIGLANG: "" + GCC: 8 + - SWIGLANG: "" + GCC: 9 + - SWIGLANG: "" + GCC: 10 + - SWIGLANG: "" + GCC: 11 + - SWIGLANG: "" + compiler: clang + - SWIGLANG: csharp + # D support can't be enabled because dmd 2.066 fails to build anything + # under Ubuntu 18.04 due to its standard library (libphobos2.a) not + # being compiled with -FPIC, but system gcc using -fpie by default, + # resulting in linking errors for any output. And later versions, such + # as 2.086.1, are not supported and result in errors in SWIG test suite. + # + # - SWIGLANG: d + # VER: '2.066.0' + # os: ubuntu-18.04 # This dlang version doesn't work under 20.04. + - SWIGLANG: go + VER: '1.6' + CSTD: gnu11 + - SWIGLANG: go + VER: '1.8' + - SWIGLANG: go + VER: '1.12' + CSTD: gnu11 + - SWIGLANG: go + VER: '1.17' + - SWIGLANG: guile + - SWIGLANG: java + - SWIGLANG: javascript + ENGINE: node + VER: '6' + CPPSTD: c++11 + os: ubuntu-18.04 + - SWIGLANG: javascript + ENGINE: node + VER: '8' + CPPSTD: c++11 + os: ubuntu-18.04 + - SWIGLANG: javascript + ENGINE: node + VER: '10' + CPPSTD: c++11 + os: ubuntu-18.04 + - SWIGLANG: javascript + ENGINE: node + VER: '12' + CPPSTD: c++11 + - SWIGLANG: javascript + ENGINE: node + VER: '17' + CPPSTD: c++14 + - SWIGLANG: javascript + ENGINE: jsc + - SWIGLANG: lua + - SWIGLANG: lua + VER: '5.3' + - SWIGLANG: octave + CPPSTD: c++11 + - SWIGLANG: octave + VER: '6.4' + CPPSTD: c++11 + - SWIGLANG: perl5 + - SWIGLANG: php + VER: '7.0' + - SWIGLANG: php + VER: '7.1' + - SWIGLANG: php + VER: '7.2' + - SWIGLANG: php + VER: '7.3' + - SWIGLANG: php + VER: '7.4' + - SWIGLANG: php + - SWIGLANG: php + VER: '8.1' + - SWIGLANG: python + - SWIGLANG: python + PY3: 3 + VER: '3.2' + os: ubuntu-18.04 # Python < 3.5 not available for 20.04. + - SWIGLANG: python + PY3: 3 + VER: '3.3' + os: ubuntu-18.04 # Python < 3.5 not available for 20.04. + - SWIGLANG: python + PY3: 3 + VER: '3.4' + os: ubuntu-18.04 # Python < 3.5 not available for 20.04. + - SWIGLANG: python + PY3: 3 + VER: '3.5' + - SWIGLANG: python + PY3: 3 + VER: '3.6' + - SWIGLANG: python + PY3: 3 + VER: '3.7' + - SWIGLANG: python + PY3: 3 + VER: '3.8' + - SWIGLANG: python + PY3: 3 + VER: '3.9' + - SWIGLANG: python + PY3: 3 + VER: '3.10' + - SWIGLANG: python + SWIG_FEATURES: -builtin + - SWIGLANG: python + SWIG_FEATURES: -builtin -O + - SWIGLANG: python + PY3: 3 + SWIG_FEATURES: -builtin + - SWIGLANG: python + PY3: 3 + SWIG_FEATURES: -builtin -O + - SWIGLANG: r + - SWIGLANG: ruby + VER: '1.9' + os: ubuntu-18.04 + - SWIGLANG: ruby + VER: '2.0' + os: ubuntu-18.04 + - SWIGLANG: ruby + VER: '2.1' + os: ubuntu-18.04 + - SWIGLANG: ruby + VER: '2.2' + os: ubuntu-18.04 + - SWIGLANG: ruby + VER: '2.3' + os: ubuntu-18.04 + - SWIGLANG: ruby + VER: '2.4' + - SWIGLANG: ruby + VER: '2.5' + - SWIGLANG: ruby + VER: '2.6' + - SWIGLANG: ruby + VER: '2.7' + - SWIGLANG: ruby + VER: '3.0' + CPPSTD: c++11 + - SWIGLANG: scilab + os: ubuntu-18.04 # scilab-6.1 in ubuntu-20.04 not yet working + - SWIGLANG: tcl + # c++11 testing + - SWIGLANG: csharp + CPPSTD: c++11 + - SWIGLANG: go + VER: '1.17' + CPPSTD: c++11 + CSTD: gnu11 + - SWIGLANG: guile + CPPSTD: c++11 + - SWIGLANG: java + CPPSTD: c++11 + - SWIGLANG: javascript + ENGINE: node + VER: '14' + CPPSTD: c++11 + - SWIGLANG: lua + CPPSTD: c++11 + - SWIGLANG: perl5 + CPPSTD: c++11 + - SWIGLANG: php + CPPSTD: c++11 + CSTD: gnu11 + - SWIGLANG: python + CPPSTD: c++11 + PY3: 3 + - SWIGLANG: r + CPPSTD: c++11 + - SWIGLANG: ruby + CPPSTD: c++11 + - SWIGLANG: scilab + CPPSTD: c++11 + os: ubuntu-18.04 # scilab-6.1 in ubuntu-20.04 not yet working + - SWIGLANG: tcl + CPPSTD: c++11 + # c++14 testing + - SWIGLANG: csharp + CPPSTD: c++14 + - SWIGLANG: go + VER: '1.17' + CPPSTD: c++14 + CSTD: gnu11 + - SWIGLANG: guile + CPPSTD: c++14 + - SWIGLANG: java + CPPSTD: c++14 + - SWIGLANG: javascript + ENGINE: node + VER: '16' + CPPSTD: c++14 + - SWIGLANG: lua + CPPSTD: c++14 + - SWIGLANG: octave + CPPSTD: c++14 + - SWIGLANG: perl5 + CPPSTD: c++14 + - SWIGLANG: php + CPPSTD: c++14 + CSTD: gnu11 + - SWIGLANG: python + CPPSTD: c++14 + PY3: 3 + - SWIGLANG: r + CPPSTD: c++14 + - SWIGLANG: ruby + CPPSTD: c++14 + - SWIGLANG: scilab + CPPSTD: c++14 + os: ubuntu-18.04 # scilab-6.1 in ubuntu-20.04 not yet working + - SWIGLANG: tcl + CPPSTD: c++14 + # c++17 testing (using gcc11) + - SWIGLANG: csharp + CPPSTD: c++17 + GCC: 11 + - SWIGLANG: go + VER: '1.17' + CPPSTD: c++17 + GCC: 11 + CSTD: gnu17 + - SWIGLANG: guile + CPPSTD: c++17 + GCC: 11 + - SWIGLANG: java + CPPSTD: c++17 + GCC: 11 + - SWIGLANG: javascript + ENGINE: node + VER: '17' + CPPSTD: c++17 + GCC: 11 + - SWIGLANG: lua + CPPSTD: c++17 + GCC: 11 + - SWIGLANG: octave + CPPSTD: c++17 + GCC: 11 + - SWIGLANG: perl5 + CPPSTD: c++17 + GCC: 11 + - SWIGLANG: php + CPPSTD: c++17 + CSTD: gnu17 + GCC: 11 + - SWIGLANG: python + CPPSTD: c++17 + GCC: 11 + PY3: 3 + - SWIGLANG: r + CPPSTD: c++17 + GCC: 11 + - SWIGLANG: ruby + CPPSTD: c++17 + GCC: 11 + - SWIGLANG: scilab + CPPSTD: c++17 + GCC: 11 + os: ubuntu-18.04 # scilab-6.1 in ubuntu-20.04 not yet working + - SWIGLANG: tcl + CPPSTD: c++17 + GCC: 11 + # Experimental languages (these are allowed to fail) + - SWIGLANG: mzscheme + continue-on-error: true + - SWIGLANG: ocaml + continue-on-error: true + os: ubuntu-18.04 # ocaml-4.08 in ubuntu-20.04 not yet working + # Run all of them, as opposed to aborting when one fails + fail-fast: false + + env: + SWIGLANG: ${{ matrix.SWIGLANG }} + PY3: ${{ matrix.PY3 }} + VER: ${{ matrix.VER }} + ENGINE: ${{ matrix.ENGINE }} + SWIG_FEATURES: ${{ matrix.SWIG_FEATURES }} + GCC: ${{ matrix.GCC }} + CSTD: ${{ matrix.CSTD }} + CPPSTD: ${{ matrix.CPPSTD }} + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Install CCache + uses: hendrikmuhs/ccache-action@v1 + with: + key: ${{ matrix.os || 'ubuntu-20.04' }}-${{ matrix.compiler || 'gcc' }}${{ matrix.GCC }} + +# Uncomment to debug via ssh, see https://github.com/mxschmitt/action-tmate +# - name: Setup tmate session +# uses: mxschmitt/action-tmate@v3 + + - name: Install Dependencies + run: | + set -x + export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" + echo PATH="$PATH" >> $GITHUB_ENV + + source $GITHUB_WORKSPACE/Tools/GHA-linux-install.sh + echo WITHLANG="$WITHLANG" >> $GITHUB_ENV + + case $(uname) in + Linux) + cpu_count=$(nproc) + ;; + + Darwin) + cpu_count=$(sysctl -n hw.ncpu) + ;; + + *) + cpu_count=1 + ;; + esac + + if [[ $cpu_count != 1 ]]; then + echo SWIGJOBS=-j$cpu_count >> $GITHUB_ENV + fi + + if test '${{ matrix.compiler }}' = 'clang'; then + CC="clang" + CXX="clang++" + + CFLAGS="$CFLAGS -fPIE" + CXXFLAGS="$CXXFLAGS -fPIE" + elif test -n "$GCC"; then + CC="gcc-$GCC" + CXX="g++-$GCC" + else + CC="gcc" + CXX="g++" + fi + + export CC CXX + + echo CC="$CC" >> $GITHUB_ENV + echo CXX="$CXX" >> $GITHUB_ENV + + ls -la $(which $CC) $(which $CXX) + $CC --version + $CXX --version + + - name: Configure + run: | + source $GITHUB_WORKSPACE/Tools/CI-linux-environment.sh + set -x + + if [[ -z "$CSTD" ]]; then + case "$CPPSTD" in + c++11) export CSTD=c11 ;; + c++14) export CSTD=c11 ;; + c++17) export CSTD=c17 ;; + esac + echo CSTD="$CSTD" >> $GITHUB_ENV + fi + if test -n "$CPPSTD"; then CONFIGOPTS+=(--enable-cpp11-testing "CXXFLAGS=-std=$CPPSTD $CXXFLAGS"); fi + if test -n "$CSTD"; then CONFIGOPTS+=("CFLAGS=-std=$CSTD $CFLAGS"); fi + if test -n "$SWIGLANG"; then CONFIGOPTS+=(--without-alllang --with-$WITHLANG); fi + echo "${CONFIGOPTS[@]}" + ./autogen.sh && mkdir -p build/build && cd build/build && ../../configure "${CONFIGOPTS[@]}" + + - name: Build + working-directory: build/build + run: | + set -x + make -s $SWIGJOBS + ./swig -version && ./swig -pcreversion + + - name: Test + working-directory: build/build + run: | + source $GITHUB_WORKSPACE/Tools/CI-linux-environment.sh + set -x + + if test -z "$SWIGLANG"; then + make $SWIGJOBS check-ccache + make $SWIGJOBS check-errors-test-suite + else + case "$SWIGLANG" in + javascript) + case "$ENGINE" in + v8 | jsc) + # Running tests using v8 or jsc involves creating a custom + # interpreter in Tools/javascript, which is currently broken + # for parallel builds (we attempt to update this interpreter + # while running, resulting in "Text file busy" error). + unset SWIGJOBS + esac + ;; + esac + + # Stricter compile flags for examples. Various headers and SWIG generated code prevents full use of -pedantic. + cflags=$($GITHUB_WORKSPACE/Tools/testflags.py --language $SWIGLANG --cflags --std=$CSTD --compiler=$CC) + cxxflags=$($GITHUB_WORKSPACE/Tools/testflags.py --language $SWIGLANG --cxxflags --std=$CPPSTD --compiler=$CC) + make check-$SWIGLANG-version + make check-$SWIGLANG-enabled + make $SWIGJOBS check-$SWIGLANG-examples CFLAGS="$cflags" CXXFLAGS="$cxxflags" + make $SWIGJOBS check-$SWIGLANG-test-suite CFLAGS="$cflags" CXXFLAGS="$cxxflags" + fi + + - name: Install + working-directory: build/build + run: | + set -x + if test -z "$SWIGLANG"; then sudo make install && swig -version && ccache-swig -V; fi + + - name: Clean + working-directory: build/build + run: | + set -x + make check-maintainer-clean && ../../configure diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c11479fed..000000000 --- a/.travis.yml +++ /dev/null @@ -1,499 +0,0 @@ -language: cpp -matrix: - include: - - compiler: clang - os: linux - env: SWIGLANG= - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG= - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG= BUILDSYSTEM=cmake - dist: xenial - - os: linux - env: SWIGLANG= GCC=4.4 - dist: xenial - - os: linux - env: SWIGLANG= GCC=4.6 - dist: xenial - - os: linux - env: SWIGLANG= GCC=4.7 - dist: xenial - - os: linux - env: SWIGLANG= GCC=4.8 - dist: xenial - - os: linux - env: SWIGLANG= GCC=4.9 - dist: xenial - - os: linux - env: SWIGLANG= GCC=6 - dist: xenial - - os: linux - env: SWIGLANG= GCC=7 - dist: xenial - - os: linux - env: SWIGLANG= GCC=8 - dist: xenial - - os: linux - env: SWIGLANG= GCC=9 - dist: xenial - - os: linux - env: SWIGLANG= GCC=10 - dist: focal - - compiler: gcc - os: linux - env: SWIGLANG=csharp - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=d VER=2.066.0 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=d VER=2.086.1 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=go VER=1.3 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=go VER=1.8 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=go VER=1.12 CSTD=gnu99 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=go VER=1.16 CSTD=gnu99 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=guile - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=java - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=javascript ENGINE=node VER=6 CPP11=1 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=javascript ENGINE=node VER=8 CPP11=1 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=javascript ENGINE=node VER=10 CPP11=1 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=javascript ENGINE=node VER=12 CPP11=1 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=javascript ENGINE=node VER=14 CPP11=1 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=javascript ENGINE=node VER=16 CPP14=1 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=javascript ENGINE=jsc - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=javascript ENGINE=v8 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=lua - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=lua VER=5.3 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=mzscheme - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=ocaml - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=octave SWIGJOBS=-j2 - dist: xenial # Octave v4.0.0 - - compiler: gcc - os: linux - env: SWIGLANG=octave SWIGJOBS=-j2 CPP11=1 - dist: bionic # Octave v4.2.2 - - compiler: gcc - os: linux - env: SWIGLANG=perl5 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=php VER=7.4 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=php VER=8.0 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=php VER=7.0 CONFIGOPTS=--enable-cpp11-testing CPPSTD=c++11 - dist: bionic - - compiler: gcc - os: linux - env: SWIGLANG=php VER=7.1 CONFIGOPTS=--enable-cpp11-testing CPPSTD=c++11 - dist: bionic - - compiler: gcc - os: linux - env: SWIGLANG=php VER=7.2 CONFIGOPTS=--enable-cpp11-testing CPPSTD=c++11 - dist: bionic - - compiler: gcc - os: linux - env: SWIGLANG=php VER=7.3 CONFIGOPTS=--enable-cpp11-testing CPPSTD=c++11 - dist: bionic - - compiler: gcc - os: linux - env: SWIGLANG=php VER=7.4 CONFIGOPTS=--enable-cpp11-testing CPPSTD=c++11 - dist: bionic - - compiler: gcc - os: linux - env: SWIGLANG=php VER=8.0 CONFIGOPTS=--enable-cpp11-testing CPPSTD=c++11 - dist: bionic - - compiler: gcc - os: linux - env: SWIGLANG=python # 2.7 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=python PY3=3 VER=3.2 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=python PY3=3 VER=3.3 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=python PY3=3 VER=3.4 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=python PY3=3 VER=3.5 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=python PY3=3 VER=3.6 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=python PY3=3 VER=3.7 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=python PY3=3 VER=3.8 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=python PY3=3 VER=3.9 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=python SWIG_FEATURES=-builtin - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=python SWIG_FEATURES="-builtin -O" - dist: xenial - - os: linux - env: SWIGLANG=python SWIG_FEATURES=-builtin GCC=6 CPP11=1 - dist: xenial - - os: linux - env: SWIGLANG=python SWIG_FEATURES=-builtin GCC=6 CPP11=1 PY3=3 VER=3.9 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.4 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.5 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.7 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.8 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.9 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=python SWIG_FEATURES="-builtin -O" PY3=3 VER=3.9 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.9 SWIGOPTPY3= - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=python SWIG_FEATURES=-O - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=python SWIG_FEATURES=-O PY3=3 VER=3.9 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=r - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=ruby VER=1.9 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=ruby VER=2.0 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=ruby VER=2.1 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=ruby VER=2.2 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=ruby VER=2.3 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=ruby VER=2.4 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=ruby VER=2.5 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=ruby VER=2.6 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=ruby VER=2.7 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=ruby VER=3.0 CSTD=c99 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=scilab - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=tcl - dist: xenial - - os: linux - env: SWIGLANG=csharp CPP11=1 - dist: xenial - - os: linux - env: SWIGLANG=go VER=1.6 CPP11=1 - dist: xenial - - os: linux - env: SWIGLANG=java CPP11=1 - dist: xenial - - os: linux - env: SWIGLANG=python CPP11=1 - dist: xenial - - os: linux - env: SWIGLANG=r CPP11=1 # Note: making 'R CMD SHLIB' use a different compiler is non-trivial - dist: xenial - - os: linux - env: SWIGLANG=ruby CPP11=1 - dist: xenial - - os: linux - env: SWIGLANG=tcl CPP11=1 - dist: xenial - - os: linux - env: SWIGLANG=csharp GCC=6 CPP14=1 - dist: xenial - - os: linux - env: SWIGLANG=go VER=1.6 GCC=6 CPP14=1 - dist: xenial - - os: linux - env: SWIGLANG=java GCC=6 CPP14=1 - dist: xenial - - os: linux - env: SWIGLANG=python GCC=6 CPP14=1 - dist: xenial - - os: linux - env: SWIGLANG=ruby GCC=6 CPP14=1 - dist: xenial - - os: linux - env: SWIGLANG=tcl GCC=6 CPP14=1 - dist: xenial - - os: linux - env: SWIGLANG=java GCC=7 CPP14=1 - dist: xenial - - os: linux - env: SWIGLANG=python GCC=7 CPP14=1 - dist: xenial - - os: linux - env: SWIGLANG=csharp GCC=8 CPP17=1 - dist: xenial - - os: linux - env: SWIGLANG=java GCC=8 CPP17=1 - dist: xenial - - os: linux - env: SWIGLANG=python GCC=8 CPP17=1 PY3=3 VER=3.9 - dist: xenial - - os: linux - env: SWIGLANG=csharp GCC=9 CPP17=1 - dist: xenial - - os: linux - env: SWIGLANG=java GCC=9 CPP17=1 - dist: xenial - - os: linux - env: SWIGLANG=python GCC=9 CPP17=1 PY3=3 VER=3.9 - dist: xenial - - os: linux - arch: s390x - env: SWIGLANG=ruby CPP11=1 - dist: xenial - - compiler: gcc - os: osx - osx_image: xcode12.2 - env: SWIGLANG= - - compiler: clang - os: osx - osx_image: xcode12.2 - env: SWIGLANG= BUILDSYSTEM=cmake - - compiler: clang - os: osx - osx_image: xcode12.2 - env: SWIGLANG= - - compiler: clang - os: osx - osx_image: xcode12.2 - env: SWIGLANG=csharp - - compiler: clang - os: osx - osx_image: xcode12.2 - env: SWIGLANG=go CSTD=gnu99 - - compiler: clang - os: osx - osx_image: xcode12.2 - env: SWIGLANG=guile CSTD=c11 - - compiler: clang - os: osx - osx_image: xcode12.2 - env: SWIGLANG=java - - compiler: clang - os: osx - osx_image: xcode12.2 - env: SWIGLANG=lua -# octave-6.1 not working -# - compiler: clang -# os: osx -# osx_image: xcode12.2 -# env: SWIGLANG=octave SWIGJOBS=-j2 CPP11=1 - - compiler: clang - os: osx - osx_image: xcode12.2 - env: SWIGLANG=perl5 - - compiler: clang - os: osx - osx_image: xcode12.2 - env: SWIGLANG=python - - compiler: clang - os: osx - osx_image: xcode12.2 - env: SWIGLANG=python PY3=3 - - compiler: clang - os: osx - osx_image: xcode12.2 - env: SWIGLANG=ruby - - compiler: clang - os: osx - osx_image: xcode12.2 - env: SWIGLANG=tcl - - compiler: clang - os: osx - osx_image: xcode12.2 - env: SWIGLANG=java CPP17=1 - - compiler: clang - os: osx - osx_image: xcode12.2 - env: SWIGLANG=python PY3=3 CPP17=1 - - allow_failures: - # Newer version of D not yet working/supported - - compiler: gcc - os: linux - env: SWIGLANG=d VER=2.086.1 - dist: xenial - # Experimental languages - - compiler: gcc - os: linux - env: SWIGLANG=mzscheme - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=ocaml - dist: xenial - -before_install: - - date -u - - uname -a - - if test "$TRAVIS_OS_NAME" = "linux"; then lscpu; grep "model name" /proc/cpuinfo || echo 'Unknown CPU model'; grep "MemTotal" /proc/meminfo || echo 'Unknown system memory amount'; fi - - if test "$TRAVIS_OS_NAME" = "osx"; then sysctl -a | grep brand_string; fi - # Travis overrides CC environment with compiler predefined values - - if test -n "$GCC"; then export CC="gcc-$GCC" && export CXX="g++-$GCC"; fi -install: - - if test "$TRAVIS_OS_NAME" = "linux"; then source Tools/travis-linux-install.sh; fi - - if test "$TRAVIS_OS_NAME" = "osx"; then source Tools/travis-osx-install.sh; fi - - ls -la $(which $CC) $(which $CXX) && $CC --version && $CXX --version -script: - - if test "$BUILDSYSTEM" = "cmake"; then cmake --version && mkdir -p build/build && cd build/build && CXXFLAGS="-Wall -Wextra -Werror" CFLAGS="-Wall -Wextra -Werror" cmake -DCMAKE_INSTALL_PREFIX=~/.local ../.. && make install && ctest --output-on-failure -V && exit 0; fi - - echo 'Configuring...' && echo -en 'travis_fold:start:script.1\\r' - - if test -n "$CPP11"; then CONFIGOPTS+=(--enable-cpp11-testing "CXXFLAGS=-std=c++11 $CXXFLAGS" "CFLAGS=-std=c11 $CFLAGS") && export CSTD=c11 && export CPPSTD=c++11; fi - - if test -n "$CPP14"; then CONFIGOPTS+=(--enable-cpp11-testing "CXXFLAGS=-std=c++14 $CXXFLAGS" "CFLAGS=-std=c11 $CFLAGS") && export CSTD=c11 && export CPPSTD=c++14; fi - - if test -n "$CPP17"; then CONFIGOPTS+=(--enable-cpp11-testing "CXXFLAGS=-std=c++17 $CXXFLAGS" "CFLAGS=-std=c17 $CFLAGS") && export CSTD=c17 && export CPPSTD=c++17; fi - - if test -n "$SWIGLANG"; then CONFIGOPTS+=(--without-alllang --with-$WITHLANG); fi - - 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 - - if test -z "$SWIGLANG"; then make -s $SWIGJOBS check-ccache; fi - - if test -z "$SWIGLANG"; then make -s $SWIGJOBS check-errors-test-suite; fi - - echo 'Installing...' && echo -en 'travis_fold:start:script.2\\r' - - if test -z "$SWIGLANG"; then sudo make -s install && swig -version && ccache-swig -V; fi - - echo -en 'travis_fold:end:script.2\\r' - # Stricter compile flags for examples. Various headers and SWIG generated code prevents full use of -pedantic. - - if test -n "$SWIGLANG"; then cflags=$($TRAVIS_BUILD_DIR/Tools/testflags.py --language $SWIGLANG --cflags --std=$CSTD --compiler=$CC) && echo $cflags; fi - - if test -n "$SWIGLANG"; then cxxflags=$($TRAVIS_BUILD_DIR/Tools/testflags.py --language $SWIGLANG --cxxflags --std=$CPPSTD --compiler=$CC) && echo $cxxflags; fi - - if test -n "$SWIGLANG"; then make -s check-$SWIGLANG-version; fi - - if test -n "$SWIGLANG"; then make check-$SWIGLANG-enabled; fi - - if test -n "$SWIGLANG"; then make $SWIGJOBS check-$SWIGLANG-examples CFLAGS="$cflags" CXXFLAGS="$cxxflags"; fi - - if test -n "$SWIGLANG"; then make $SWIGJOBS check-$SWIGLANG-test-suite CFLAGS="$cflags" CXXFLAGS="$cxxflags"; fi - - echo 'Cleaning...' && echo -en 'travis_fold:start:script.3\\r' - # Skip on osx as often fails with: rm: Resource temporarily unavailable - - if test "$TRAVIS_OS_NAME" != "osx"; then make check-maintainer-clean && ../../configure $CONFIGOPTS; fi - - echo -en 'travis_fold:end:script.3\\r' diff --git a/CCache/README.swig b/CCache/README.swig index aea0f3d82..82055d146 100644 --- a/CCache/README.swig +++ b/CCache/README.swig @@ -2,7 +2,7 @@ This directory contains a version of ccache. The initial version was based on cc debian patches 01-02, 04-14, see the debian/patches subdirectory. The ccache-win32-2.4 modifications to ccache-2.4 have also been merged in. -Changes have been made to support cacheing the output from SWIG. The ability to cache c/c++ compiler +Changes have been made to support caching the output from SWIG. The ability to cache c/c++ compiler output has been retained. Additional features added are the CCACHE_VERBOSE and CCACHE_SWIG environment variables, see docs. diff --git a/CCache/execute.c b/CCache/execute.c index 6df025e95..8c65e0ce0 100644 --- a/CCache/execute.c +++ b/CCache/execute.c @@ -137,7 +137,7 @@ int execute(char **argv, _dup2(fd, 2); _close(fd); - /* Spawn process (_exec* familly doesn't return) */ + /* Spawn process (_exec* family doesn't return) */ status = _spawnv(_P_WAIT, argv[0], (const char **)argv); /* Restore descriptors */ diff --git a/CCache/snprintf.c b/CCache/snprintf.c index 9bf8a817b..1a76c7d1b 100644 --- a/CCache/snprintf.c +++ b/CCache/snprintf.c @@ -16,7 +16,7 @@ * for string length. This covers a nasty loophole. * * The other functions are there to prevent NULL pointers from - * causing nast effects. + * causing nasty effects. * * More Recently: * Brandon Long 9/15/96 for mutt 0.43 @@ -30,7 +30,7 @@ * probably requires libm on most operating systems. Don't yet * support the exponent (e,E) and sigfig (g,G). Also, fmtint() * was pretty badly broken, it just wasn't being exercised in ways - * which showed it, so that's been fixed. Also, formated the code + * which showed it, so that's been fixed. Also, formatted the code * to mutt conventions, and removed dead code left over from the * original. Also, there is now a builtin-test, just compile with: * gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm diff --git a/CCache/web/index.html b/CCache/web/index.html index 4af839135..bc46916d2 100644 --- a/CCache/web/index.html +++ b/CCache/web/index.html @@ -34,7 +34,7 @@ on the new options.

You can get this release from the download directory -

NOTE! This release changes the hash input slighly, so you will +

NOTE! This release changes the hash input slightly, so you will probably find that you will not get any hits against your existing cache when you upgrade. diff --git a/CHANGES.current b/CHANGES.current index 9ab912b15..46c567a02 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,149 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.1.0 (in progress) =========================== +2022-02-02: olly + [Ruby] https://sourceforge.net/p/swig/bugs/1136/ Fix remove of prefix + from method name to only remove it at the start. + +2022-02-01: olly + #231 Handle returning an object by reference in a C++ trailing + return type. + +2022-02-01: davidcl + [Scilab] #745 use SWIG__Init() as a C module init function. + +2022-02-01: olly + [OCaml] #2083 Fix to work when CAML_SAFE_STRING is on, which it is + by default in recent Ocaml releases. + +2022-01-31: mreeez + https://sourceforge.net/p/swig/bugs/1147/ + Fix copyToR() generated for a struct in a namespace. + +2022-01-29: fschlimb + #655 Better handling of using declarations. + +2022-01-29: dontpanic92 + #676 Fix code generated for a C++ class with a non-capitalised + name. + +2022-01-26: trex58 + #1919 #1921 #1923 Various fixes for AIX portability. + +2022-01-26: olly + #1935 Don't crash on an unclosed HTML tag in a doxygen comment + when -doxygen is specified. + +2022-01-25: olly + Constant expressions now support member access with `.` such as + `foo.bar`. Previous this only worked in a case like `x->foo.bar`. + +2022-01-25: olly + #2091 Support most cases of `sizeof` applied to an expression + in constant expressions. Previously there was only support for + `sizeof()` and expressions which syntactically look like a + type (such as `sizeof(foo)`). + +2022-01-25: olly + #80 #635 https://sourceforge.net/p/swig/bugs/1139/ + Add support for parsing common cases of `<` and `>` comparisons + in constant expressions. Adding full support for these seems hard + to do without introducing conflicts into the parser grammar, but in + fact all reported cases have had parentheses around the comparison + and we can support that with a few restrictions on the left side of + `<`. + +2022-01-25: wsfulton + New warning 327 for extern templates, eg: + + extern template class std::vector; + extern template void Func(); + + results in warning + + example.i:3: Warning 327: Extern template ignored. + example.i:4: Warning 327: Extern template ignored. + + Extern template classes previously resulted in warning 320. + +2022-01-24: romintomasetti + #2131 #2157 C++11 extern function template parsing error fix. + +2022-01-21: wsfulton + #2120 #2138 Replace legacy PCRE dependency with PCRE2. + This requires changes for building SWIG from source. See updated + html documentation in Preface.html and Windows.html. Updated + instructions are also shown when running ./configure if PCRE2 is not + found. Note that debian based systems can install PCRE2 using: + + apt install libpcre2-dev + + Note that https://github.com/swig/swig/wiki/Getting-Started also has + updated information for building from source. + +2022-01-19: olly + [PHP] #2027 Automatically generate PHP type declarations for PHP 8. + The generate code still compiles for PHP 7.x, but without type + declarations since PHP 7.x has much more limited type declaration + support. + +2022-01-18: olly + [Perl] #1629 Perl 5.8.0 is now the oldest version we aim to support. + +2022-01-14: wsfulton + [Python] Fix %callback and specifying the callback function as a + static member function using Python staticmethod syntax, such as + Klass.memberfunction instead of Klass_memberfunction when using + -builtin and -fastproxy. + +2022-01-11: wsfulton + [Python] Accept keyword arguments accessing static member functions when + using -builtin and kwargs feature and Python class staticmethod syntax. + The missing keyword argument support was only when using the + class staticmethod syntax, such as Klass.memberfunction, and not when + using the flat static method syntax, such as Klass_memberfunction. + +2022-01-04: juierror + [Go] #2045 Add support for std::array in std_array.i. + +2021-12-18: olly + [PHP] Add PHP keyword 'readonly' (added in 8.1) to the list SWIG + knows to automatically rename. This keyword is special in that PHP + allows it to be used as a function (or method) name. + +2021-12-07: vstinner + [Python] #2116 Python 3.11 support: use Py_SET_TYPE() + +2021-12-05: rwf1 + [Octave] #2020 #1893 Add support for Octave 6 up to and including 6.4. + Also add support for compiling with -Bsymbolic which is used by default + by mkoctfile. + +2021-12-02: jsenn + [Python] #2102 Fixed crashes when using embedded Python interpreters. + +2021-11-12: wsfulton + [Javascript] v8 and node only. Fix mismatched new char[] and free() + when wrapping C code char arrays. Now calloc is now used instead of + new char[] in SWIG_AsCharPtrAndSize. + +2021-10-03: ajrh1 + [Perl] #2074: Avoid -Wmisleading-indentation in generated code + when using gcc11. + +2021-10-03: jschueller + [CMake] #2065: Add option to enable or disable PCRE support. + +2021-09-16: ianlancetaylor + [Go] Improved _cgo_panic implementation. + +2021-09-16: ianlancetaylor + [Go] Don't use crosscall2 for panicking. Instead rely on documented + and exported interfaces. + +2021-09-14: ianlancetaylor + [Go] Remove -no-cgo option (long unsupported in Go) + 2021-05-04: olly [PHP] #2014 Throw PHP exceptions instead of using PHP errors diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b6743471..8a8862f63 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,11 +73,11 @@ if (MSVC) set (CMAKE_CXX_FLAGS "/EHsc ${CMAKE_CXX_FLAGS}") endif () -set (PCRE_REQUIRED_ARG "REQUIRED" CACHE STRING "required arg") -find_package (PCRE ${PCRE_REQUIRED_ARG}) -if (PCRE_FOUND) +option (WITH_PCRE "Enable PCRE" ON) +if (WITH_PCRE) + find_package (PCRE2 REQUIRED) set (HAVE_PCRE 1) - include_directories (${PCRE_INCLUDE_DIRS}) + include_directories (${PCRE2_INCLUDE_DIRS}) endif() if (WIN32) @@ -145,8 +145,8 @@ add_executable (swig ${PROJECT_BINARY_DIR}/Source/CParse/parser.c ${PROJECT_BINARY_DIR}/Source/CParse/parser.h ) -if (PCRE_FOUND) - target_link_libraries (swig ${PCRE_LIBRARIES}) +if (PCRE2_FOUND) + target_link_libraries (swig ${PCRE2_LIBRARIES}) endif () install (TARGETS swig DESTINATION bin) @@ -160,6 +160,7 @@ include (CPack) # few tests enable_testing () add_test (NAME cmd_version COMMAND swig -version) +add_test (NAME cmd_pcreversion COMMAND swig -pcreversion) add_test (NAME cmd_swiglib COMMAND swig -swiglib) add_test (NAME cmd_external_runtime COMMAND swig -external-runtime ext_rt.h) set_tests_properties(cmd_external_runtime PROPERTIES ENVIRONMENT "SWIG_LIB=${PROJECT_SOURCE_DIR}/Lib") diff --git a/Doc/Devel/internals.html b/Doc/Devel/internals.html index c9082d3f6..0fc6623e8 100644 --- a/Doc/Devel/internals.html +++ b/Doc/Devel/internals.html @@ -441,12 +441,12 @@ Resulting output:

-hash len: 5
-get: hashval2
-hash item: hashval5 [h5]
-hash item: hashval1 [h1]
-hash item: hashval2 [h2]
-hash item: hashval3 [h3]
+list len: 5
+get: listval2
+list item: newlistval1
+list item: listval2
+list item: listval3
+list item: listval5
 
@@ -494,12 +494,12 @@ Resulting output:
-list len: 5
-get: listval2
-list item: newlistval1
-list item: listval2
-list item: listval3
-list item: listval5
+hash len: 5
+get: hashval2
+hash item: hashval5 [h5]
+hash item: hashval1 [h1]
+hash item: hashval2 [h2]
+hash item: hashval3 [h3]
 
diff --git a/Doc/Manual/CPlusPlus11.html b/Doc/Manual/CPlusPlus11.html index e5d7fbc2d..86a35bfaa 100644 --- a/Doc/Manual/CPlusPlus11.html +++ b/Doc/Manual/CPlusPlus11.html @@ -144,14 +144,39 @@ When either of these is used from a target language, a runtime call is made to o

7.2.3 Extern template

-

SWIG correctly parses the keywords extern template. +

SWIG correctly parses extern template explicit instantiation declarations. However, this template instantiation suppression in a translation unit has no relevance outside of the C++ compiler and so is not used by SWIG. -SWIG only uses %template for instantiating and wrapping templates.

+SWIG only uses %template for instantiating and wrapping templates. +Consider the class template below: +

-template class std::vector<int>;        // C++03 explicit instantiation in C++
-extern template class std::vector<int>; // C++11 explicit instantiation suppression in C++
-%template(VectorInt) std::vector<int>;  // SWIG instantiation
+// Class template
+template class std::vector<int>;        // C++03 template explicit instantiation definition in C++
+extern template class std::vector<int>; // C++11 template explicit instantiation declaration (extern template)
+%template(VectorInt) std::vector<int>;  // SWIG template instantiation
+
+ +

+The above result in warnings: +

+ +
+
+example.i:2: Warning 320: Explicit template instantiation ignored.
+example.i:3: Warning 327: Extern template ignored.
+
+
+ +

+Similarly for the function template below: +

+ +
+// Function template
+template void Func<int>();              // C++03 template explicit instantiation definition in C++
+extern template void Func<int>();       // C++11 template explicit instantiation declaration (extern template)
+%template(FuncInt) Func<int>;           // SWIG template instantiation
 

7.2.4 Initializer lists

diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 47b41186e..a3d0dcb4e 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -91,17 +91,16 @@
  • Instructions for using the Examples with other compilers -
  • SWIG on Cygwin and MinGW -
  • Microsoft extensions and other Windows quirks @@ -172,6 +171,7 @@
  • Renaming and ignoring declarations
  • Overloaded operators
  • Class extension +
  • Templates @@ -3660,9 +3660,9 @@ Some minimum requirements and notes about languages with the 'Experimental' stat The number of tests in these lists should be no greater than half of the number of tests in the full test-suite.
  • - The examples and test-suite must also be fully functioning on the Travis Continuous Integration platform. - However, experimental languages will be set as 'allow_failures'. - This means that pull requests and normal development commits will not break the entire Travis build should an experimental language fail. + The examples and test-suite must also be fully functioning on the Github Actions Continuous Integration platform. + However, experimental languages will be flagged as 'continue-on-error'. + This means that pull requests and normal development commits will not break the entire Github Actions build should an experimental language fail.
  • Any new failed tests will be fixed on a 'best effort' basis by core developers with no promises made. diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index 1a5bb08c7..4e230c78b 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -71,6 +71,7 @@ code. SWIG fills this gap. There are (at least) two different Go compilers. The first is the gc compiler of the Go distribution, normally invoked via the go tool. +SWIG supports the gc compiler version 1.2 or later. The second Go compiler is the gccgo compiler, which is a frontend to the GCC compiler suite. The interface to C/C++ code is completely different for the two Go compilers. @@ -142,44 +143,6 @@ You will now have a Go package that you can import from other Go packages as usual.

    -

    -SWIG can be used without cgo, via the -no-cgo option, but -more steps are required. 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 Go compiler of the Go -distribution would look like this: -

    - -
    -% swig -go -no-cgo example.i
    -% gcc -c code.c    # The C library being wrapped.
    -% gcc -c example_wrap.c
    -% go tool 6g example.go
    -% go tool 6c example_gc.c
    -% go tool pack grc example.a example.6 example_gc.6 code.o example_wrap.o
    -% go tool 6g main.go
    -% go tool 6l main.6
    -
    - -

    -You can also put the wrapped code into a shared library, and when using the Go -versions before 1.2 this is the only supported option. A typical command -sequence for this approach would look like this: -

    - -
    -% swig -go -no-cgo -use-shlib example.i
    -% gcc -c -fpic example.c
    -% gcc -c -fpic example_wrap.c
    -% gcc -shared example.o example_wrap.o -o example.so
    -% go tool 6g example.go
    -% go tool 6c example_gc.c
    -% go tool pack grc example.a example.6 example_gc.6
    -% go tool 6g main.go  # your code, not generated by SWIG
    -% go tool 6l main.6
    -
    -

    25.3.1 Go-specific Commandline Options

    @@ -206,9 +169,7 @@ swig -go -help -no-cgo -Generate files that can be used directly, rather than via the Go - cgo tool. This option does not work with Go 1.5 or later. It is - required for versions of Go before 1.2. +This option is no longer supported. @@ -279,13 +240,10 @@ swig -go -help

    25.3.2 Generated Wrapper Files

    -

    There are two different approaches to generating wrapper files, - controlled by SWIG's -no-cgo option. The -no-cgo - option only works with version of Go before 1.5. It is required - when using versions of Go before 1.2.

    - -

    With or without the -no-cgo option, SWIG will generate the - following files when generating wrapper code:

    +

    +SWIG will generate the following files when generating wrapper +code: +

    -

    When the -no-cgo option is used, and the -gccgo - option is not used, SWIG will also generate an additional file:

    - - -

    25.4 A tour of basic C/C++ wrapping

    diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 3b24c5ba8..03e3c9124 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -9067,6 +9067,11 @@ You may have to add in some "jtype", "jstype", "javain" and "javaout" typemaps w Here the default typemaps work for int and char *.

    +

    +Note that if you're wanting to effectively replace the JNI code generated for a C/C++ function then you'll need to use %ignore as well +to tell SWIG not to automatically generate a JNI wrapper for it. +

    +

    In summary the %native directive is telling SWIG to generate the Java code to access the JNI C code, but not the JNI C function itself. This directive is only really useful if you want to mix your own hand crafted JNI code and the SWIG generated code into one Java class or package. @@ -9100,7 +9105,7 @@ This method normally calls the C++ destructor or free() for C code.

    The generated code can be debugged using both a Java debugger and a C++ debugger using the usual debugging techniques. Breakpoints can be set in either Java or C++ code and so both can be debugged simultaneously. -Most debuggers do not understand both Java and C++, with one noteable exception of Sun Studio, +Most debuggers do not understand both Java and C++, with one notable exception of Sun Studio, where it is possible to step from Java code into a JNI method within one environment.

    diff --git a/Doc/Manual/Javascript.html b/Doc/Manual/Javascript.html index 54bd68521..ab8657510 100644 --- a/Doc/Manual/Javascript.html +++ b/Doc/Manual/Javascript.html @@ -89,24 +89,10 @@ $ swig -javascript -jsc example.i
     $ swig -c++ -javascript -jsc example.i
    -

    The V8 code that SWIG generates should work with most versions from 3.11.10. -However, the only early version that receives some testing is 3.14.5, which is -still shipped with Ubuntu for some reason. Other than that it's probably safer -to assume that versions earlier than 5.0 are no longer supported. Keep in mind -that these are V8 versions, not Node.js. To give some perspective, Node.js v6.0 +

    The V8 code that SWIG generates requires at least V8 5.0. Keep in mind +that this is theV8 version, not Node.js. To give some perspective, Node.js v6.0 uses V8 5.0, v12.0 - 7.4, v14.0 - 8.1...

    -

    The API headers for V8 >= 4.3.10 define constants which SWIG can use to -determine the V8 version it is compiling for. For versions < 4.3.10, you -need to specify the V8 version when running SWIG. This is specified as a hex -constant, but the constant is read as pairs of decimal digits, so for V8 -3.25.30 use constant 0x032530. This scheme can't represent components > 99, -but this constant is only useful for V8 < 4.3.10, and no V8 versions from -that era had a component > 99. For example:

    -
    -
    -$ swig -c++ -javascript -v8 -DV8_VERSION=0x032530 example.i
    -
    -

    If you're targeting V8 >= 4.3.10, you would just run swig like so:

    +

    To generate code for V8, you would run swig like so:

     $ swig -c++ -javascript -v8 example.i
    diff --git a/Doc/Manual/Ocaml.html b/Doc/Manual/Ocaml.html index 4ae07e969..9b59eec61 100644 --- a/Doc/Manual/Ocaml.html +++ b/Doc/Manual/Ocaml.html @@ -720,7 +720,6 @@ Here's a simple example using Trolltech's Qt Library: class QApplication { public: QApplication( int argc, char **argv ); - void setMainWidget( QWidget *widget ); void exec(); }; @@ -736,16 +735,15 @@ public:
    -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$ 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 qt.mli
    -bash-2.05a$ ocamlc -c qt.ml
    -bash-2.05a$ ocamlmktop -custom swig.cmo -I `camlp4 -where` \
    +$ QTPATH=/your/qt/path
    +$ for file in swig.mli swig.ml swigp4.ml ; do swig -ocaml -co $file ; done
    +$ ocamlc -c swig.mli ; ocamlc -c swig.ml
    +$ ocamlc -I `camlp4 -where` -pp "camlp4o pa_extend.cmo q_MLast.cmo" -c swigp4.ml
    +$ swig -ocaml -c++ -o qt_wrap.c qt.i
    +$ ocamlc -c -ccopt -xc++ -ccopt -g -g -ccopt -I$QTPATH/include qt_wrap.c
    +$ ocamlc -c qt.mli
    +$ ocamlc -c qt.ml
    +$ ocamlmktop -custom swig.cmo -I `camlp4 -where` \
       camlp4o.cma swigp4.cmo qt_wrap.o qt.cmo -o qt_top -cclib \
       -L$QTPATH/lib -cclib -lqt
     
    diff --git a/Doc/Manual/Octave.html b/Doc/Manual/Octave.html index bdef5db7c..151957cff 100644 --- a/Doc/Manual/Octave.html +++ b/Doc/Manual/Octave.html @@ -570,13 +570,13 @@ __mul__ a * b __div__ a / b __pow__ a ^ b __ldiv__ a \ b -__lshift__ a << b -__rshift__ a >> b -__lt__ a < b -__le__ a <= b +__lshift__ a << b +__rshift__ a >> b +__lt__ a < b +__le__ a <= b __eq__ a == b -__ge__ a >= b -__gt__ a > b +__ge__ a >= b +__gt__ a > b __ne__ a != b __el_mul__ a .* b __el_div__ a ./ b @@ -598,16 +598,16 @@ On the C++ side, the default mappings are as follows: %rename(__mul__) *::operator*; %rename(__div__) *::operator/; %rename(__mod__) *::operator%; -%rename(__lshift__) *::operator<<; -%rename(__rshift__) *::operator>>; +%rename(__lshift__) *::operator<<; +%rename(__rshift__) *::operator>>; %rename(__el_and__) *::operator&&; %rename(__el_or__) *::operator||; %rename(__xor__) *::operator^; %rename(__invert__) *::operator~; -%rename(__lt__) *::operator<; -%rename(__le__) *::operator<=; -%rename(__gt__) *::operator>; -%rename(__ge__) *::operator>=; +%rename(__lt__) *::operator<; +%rename(__le__) *::operator<=; +%rename(__gt__) *::operator>; +%rename(__ge__) *::operator>=; %rename(__eq__) *::operator==; %rename(__ne__) *::operator!=; %rename(__not__) *::operator!; @@ -634,7 +634,7 @@ You can use it to define special behavior, like for example defining Octave oper %extend A { string __str__() { stringstream sout; - sout<<$self->value; + sout<<$self->value; return sout.str(); } } diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html index 85c2545cf..03dcfe6bb 100644 --- a/Doc/Manual/Perl5.html +++ b/Doc/Manual/Perl5.html @@ -91,10 +91,10 @@

    This chapter describes SWIG's support of Perl5. Although the Perl5 module is one of the earliest SWIG modules, it has continued to evolve -and has been improved greatly with the help of SWIG users. For the -best results, it is recommended that SWIG be used with Perl 5.8 or -later. We're no longer testing regularly with older versions, but -Perl 5.6 seems to mostly work, while older versions don't. +and has been improved greatly with the help of SWIG users. As of SWIG +4.1.0, the minimum version of Perl we aim to support is Perl 5.8.0. +We can no longer easily test with older versions, and they no longer +seem to be in active use.

    31.1 Overview

    @@ -680,7 +680,6 @@ files(s) field". installation under "Additional include directories".
  • Define the symbols WIN32 and MSWIN32 under preprocessor options. -If using the ActiveWare port, also define the symbol PERL_OBJECT. Note that all extensions to the ActiveWare port must be compiled with the C++ compiler since Perl has been encapsulated in a C++ class. @@ -2651,8 +2650,8 @@ constructors and destructors for the package and are always named "new" and "DESTROY". The constructor always returns a tied hash table. This hash table is used to access the member variables of a structure in addition to being able to invoke member functions. The -%OWNER and %BLESSEDMEMBERS hash tables are used -internally and described shortly. +%OWNER and %BLESSEDMEMBERS hash tables are +implementation details used internally and described shortly.

    @@ -2740,8 +2739,15 @@ to a C function that remembers the object, and then destroy the corresponding Perl object (this situation turns out to come up frequently when constructing objects like linked lists and trees). When C takes possession of an object, you can change Perl's ownership -by simply deleting the object from the %OWNER hash. This is -done using the DISOWN method. +by calling the DISOWN method (which will delete the object +from the internal %OWNER hash). +

    + +

    +The %OWNER hash is an implementation detail, discussed here +only to help clarify the operation of ACQUIRE and DISOWN. +You should not access %OWNER directly - the details of how it +works (and possibly even its existence) may chance in future SWIG versions.

    diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html
    index 5aea878b2..8963a6c8d 100644
    --- a/Doc/Manual/Php.html
    +++ b/Doc/Manual/Php.html
    @@ -50,18 +50,19 @@
     
     
     

    -In this chapter, we discuss SWIG's support of PHP. SWIG currently supports -generating wrappers for PHP7 and PHP8. Support for PHP5 was removed in SWIG -4.0.0 and support for PHP4 was removed in SWIG 1.3.37. +In this chapter, we discuss SWIG's support of PHP. Currently any PHP7 or PHP8 +release should work.

    -Currently any PHP7 or PHP8 release should work. +Support for PHP7 was added in SWIG 3.0.11 and for PHP8 in 4.1.0. +Support for PHP5 was removed in SWIG 4.0.0 and support for PHP4 was removed in +SWIG 1.3.37. There never was a PHP6 release.

    In order to use this module, you will need to have a copy of the PHP -include files to compile the SWIG generated files. If you installed +include files to compile the SWIG generated C/C++ sources. If you installed PHP from a binary package, you may need to install a "php-dev" or "php-devel" package for these to be installed. You can find out where these files are by running php-config --includes. To use the built PHP module you @@ -161,7 +162,7 @@ default extension directory, you also need to specify the path, for example:

    -	extension=/path/to/modulename.so
    +        extension=/path/to/modulename.so
     

    @@ -343,6 +344,80 @@ $c = bar(3.5); # Use default argument for 2nd parameter

    +

    +SWIG generates PHP type declarations for function parameters and return +types for PHP 8 and later (we don't try to support PHP 7's more limited type +declarations and the generated wrappers compiled for PHP 7 will not have any +type declarations). +

    + +

    +You can control the generation of PHP type declarations using +the "php:type" %feature. This has three settings: +

    + + + +

    +If you have an existing PHP interface and are upgrading to SWIG >= 4.1.0 +then the default "compat" setting should work well. +

    + +

    +If you're writing a new set of bindings and only targetting PHP8 or newer +then enabling type declarations everywhere probably makes sense. It will +only actually make a difference if you enable directors and are wrapping C++ +classes with virtual methods, but doing it anyway means you won't forget to if +the code you are wrapping later evolves to have such classes and methods. +

    + +

    +The type declaration information will make the generated source code and +compiler extension module larger, so you might want to turn off type +declarations if keeping these small is important to you. If you find you +need to turn off type declarations to fix a problem, please let us know +via our github issue tracker. +

    + +

    +Note that being a SWIG feature this can be specified globally (like above) or +per class, per method, etc. See the %feature directives +section for full details of how to control at a fine-grained level. +

    + +

    +The PHP type information is specified via a "phptype" attribute on "in" and +"out" typemaps, and these have been added for all the typemaps we supply for +PHP. We don't currently support this for "argout" templates, but probably +will in a future version. +

    + +

    +If you have written custom SWIG typemaps for PHP and want to add PHP type +declarations, then the syntax is very like how you'd specify the type in +PHP code, e.g. %typemap(in, phptype="int|string|Foo") means the +typemap accepts a PHP int or string or an object of class Foo, +%typemap(in, phptype="?int") means a PHP int or NULL, etc. +As well as the standard PHP type declaration types, SWIG also understands the +special type "SWIGTYPE" as an entry in phptype, which means the PHP type +corresponding to the type that this typemap matched on - for a object this +will give you the PHP class for the object, and for a pointer to a non-class +type it will give you the name of the PHP class SWIG created for that +pointer type. +

    +